Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export function listPlanAddons(
): Promise<Result<ListPlanAddonsResponse>> {
const searchParams = toURLSearchParams({
page: req.page,
sort: encodeSort(req.sort),
filter: req.filter,
})
const path = encodePath('openmeter/plans/{planId}/addons', {
planId: req.planId,
Expand Down
1 change: 1 addition & 0 deletions api/spec/packages/aip-client-javascript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export type {
ListSubscriptionsParamsFilter,
ListFeatureParamsFilter,
ListAddonsParamsFilter,
ListPlanAddonsParamsFilter,
CreateCreditGrantTaxConfig,
CreditGrantTaxConfig,
TaxConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ import { z } from 'zod'
import * as schemas from '../schemas.js'
import type {
CreatePlanAddonRequest as CreatePlanAddonRequestBody,
ListPlanAddonsParamsFilter,
PlanAddon,
PlanAddonPagePaginatedResponse,
SortQueryInput,
UpsertPlanAddonRequest,
} from '../types.js'

export interface ListPlanAddonsQuery {
/** Determines which page of the collection to retrieve. */
page?: { size?: number; number?: number }
/** Sort plan add-ons returned in the response. Supported sort attributes are: - `id` (default) - `created_at` - `updated_at` The `asc` suffix is optional as the default sort order is ascending. The `desc` suffix is used to specify a descending order. */
sort?: SortQueryInput
/** Filter plan add-ons returned in the response. */
filter?: ListPlanAddonsParamsFilter
}

export type ListPlanAddonsRequest = ListPlanAddonsQuery & { planId: string }
Expand Down
13 changes: 13 additions & 0 deletions api/spec/packages/aip-client-javascript/src/models/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2914,6 +2914,17 @@ export const listAddonsParamsFilter = z
})
.describe('Filter options for listing add-ons.')

export const listPlanAddonsParamsFilter = z
.object({
id: ulidFieldFilter.optional(),
plan_key: stringFieldFilter.optional(),
addon_id: ulidFieldFilter.optional(),
addon_key: stringFieldFilter.optional(),
addon_name: stringFieldFilter.optional(),
plan_currency: stringFieldFilter.optional(),
})
.describe('Filter options for listing plan add-ons.')

export const createCreditGrantTaxConfig = z
.object({
behavior: taxBehavior.optional(),
Expand Down Expand Up @@ -5463,6 +5474,8 @@ export const listPlanAddonsQueryParams = z.object({
})
.optional()
.describe('Determines which page of the collection to retrieve.'),
sort: sortQuery.optional(),
filter: listPlanAddonsParamsFilter.optional(),
})

export const listPlanAddonsResponse = z.object({
Expand Down
62 changes: 62 additions & 0 deletions api/spec/packages/aip-client-javascript/src/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,68 @@ export interface ListAddonsParamsFilter {
currency?: string | { eq?: string; oeq?: string[]; neq?: string }
}

/** Filter options for listing plan add-ons. */
export interface ListPlanAddonsParamsFilter {
id?: string | { eq?: string; oeq?: string[]; neq?: string }
plan_key?:
| string
| {
eq?: string
neq?: string
contains?: string
ocontains?: string[]
oeq?: string[]
gt?: string
gte?: string
lt?: string
lte?: string
exists?: boolean
}
addon_id?: string | { eq?: string; oeq?: string[]; neq?: string }
addon_key?:
| string
| {
eq?: string
neq?: string
contains?: string
ocontains?: string[]
oeq?: string[]
gt?: string
gte?: string
lt?: string
lte?: string
exists?: boolean
}
addon_name?:
| string
| {
eq?: string
neq?: string
contains?: string
ocontains?: string[]
oeq?: string[]
gt?: string
gte?: string
lt?: string
lte?: string
exists?: boolean
}
plan_currency?:
| string
| {
eq?: string
neq?: string
contains?: string
ocontains?: string[]
oeq?: string[]
gt?: string
gte?: string
lt?: string
lte?: string
exists?: boolean
}
}

/** Tax configuration for a credit grant. Tax configuration should be provided to ensure correct revenue recognition, including for externally funded grants. */
export interface CreateCreditGrantTaxConfig {
/** Tax behavior applied to the invoice line item. */
Expand Down
44 changes: 43 additions & 1 deletion api/spec/packages/aip/src/productcatalog/operations.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,25 @@ interface AddonOperations {
| Common.NotFound;
}

/**
* Filter options for listing plan add-ons.
*/
@friendlyName("ListPlanAddonsParamsFilter")
model ListPlanAddonsParamsFilter {
#suppress "@openmeter/api-spec-aip/doc-decorator" "shared model"
id?: Common.ULIDFieldFilter;
#suppress "@openmeter/api-spec-aip/doc-decorator" "shared model"
plan_key?: Common.StringFieldFilter;
#suppress "@openmeter/api-spec-aip/doc-decorator" "shared model"
addon_id?: Common.ULIDFieldFilter;
#suppress "@openmeter/api-spec-aip/doc-decorator" "shared model"
addon_key?: Common.StringFieldFilter;
#suppress "@openmeter/api-spec-aip/doc-decorator" "shared model"
addon_name?: Common.StringFieldFilter;
#suppress "@openmeter/api-spec-aip/doc-decorator" "shared model"
plan_currency?: Common.StringFieldFilter;
}

interface PlanAddonOperations {
/**
* List add-ons associated with a plan.
Expand All @@ -282,7 +301,30 @@ interface PlanAddonOperations {
@operationId("list-plan-addons")
@summary("List add-ons for plan")
@extension(Shared.UnstableExtension, true)
listPlanAddons(@path planId: Shared.ULID, ...Common.PagePaginationQuery):
@extension(Shared.InternalExtension, true)
listPlanAddons(
@path planId: Shared.ULID,
...Common.PagePaginationQuery,

/**
* Sort plan add-ons returned in the response. Supported sort attributes are:
*
* - `id` (default)
* - `created_at`
* - `updated_at`
*
* The `asc` suffix is optional as the default sort order is ascending. The `desc`
* suffix is used to specify a descending order.
*/
@query(#{ name: "sort" })
sort?: Common.SortQuery,

/**
* Filter plan add-ons returned in the response.
*/
@query(#{ style: "deepObject", explode: true })
filter?: ListPlanAddonsParamsFilter,
):
| Shared.PagePaginatedResponse<PlanAddon>
| Common.ErrorResponses
| Common.NotFound;
Expand Down
Loading
Loading