@openmeter/client 1.0.0-beta.230 → 1.0.0-beta.232

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +365 -76
  3. package/dist/core.d.ts +0 -1
  4. package/dist/core.js +11 -1
  5. package/dist/funcs/addons.d.ts +49 -1
  6. package/dist/funcs/addons.js +109 -12
  7. package/dist/funcs/apps.d.ts +55 -2
  8. package/dist/funcs/apps.js +179 -4
  9. package/dist/funcs/billing.d.ts +46 -1
  10. package/dist/funcs/billing.js +81 -8
  11. package/dist/funcs/currencies.d.ts +39 -2
  12. package/dist/funcs/currencies.js +93 -6
  13. package/dist/funcs/customers.d.ts +165 -2
  14. package/dist/funcs/customers.js +402 -40
  15. package/dist/funcs/defaults.d.ts +10 -1
  16. package/dist/funcs/defaults.js +11 -1
  17. package/dist/funcs/entitlements.d.ts +5 -1
  18. package/dist/funcs/entitlements.js +18 -4
  19. package/dist/funcs/events.d.ts +14 -1
  20. package/dist/funcs/events.js +18 -1
  21. package/dist/funcs/features.d.ts +42 -1
  22. package/dist/funcs/features.js +91 -10
  23. package/dist/funcs/governance.d.ts +14 -1
  24. package/dist/funcs/governance.js +15 -1
  25. package/dist/funcs/index.d.ts +0 -1
  26. package/dist/funcs/index.js +1 -1
  27. package/dist/funcs/invoices.d.ts +102 -2
  28. package/dist/funcs/invoices.js +247 -8
  29. package/dist/funcs/llmCost.d.ts +36 -1
  30. package/dist/funcs/llmCost.js +63 -6
  31. package/dist/funcs/meters.d.ts +53 -1
  32. package/dist/funcs/meters.js +113 -12
  33. package/dist/funcs/planAddons.d.ts +35 -1
  34. package/dist/funcs/planAddons.js +101 -18
  35. package/dist/funcs/plans.d.ts +49 -1
  36. package/dist/funcs/plans.js +109 -12
  37. package/dist/funcs/subscriptions.d.ts +59 -1
  38. package/dist/funcs/subscriptions.js +147 -18
  39. package/dist/funcs/tax.d.ts +25 -1
  40. package/dist/funcs/tax.js +60 -8
  41. package/dist/index.d.ts +4 -7
  42. package/dist/index.js +4 -6
  43. package/dist/lib/config.d.ts +2 -3
  44. package/dist/lib/config.js +1 -1
  45. package/dist/lib/encodings.d.ts +0 -1
  46. package/dist/lib/encodings.js +1 -1
  47. package/dist/lib/paginate.d.ts +56 -0
  48. package/dist/lib/paginate.js +60 -0
  49. package/dist/lib/request.d.ts +0 -1
  50. package/dist/lib/request.js +1 -1
  51. package/dist/lib/to-error.d.ts +0 -1
  52. package/dist/lib/to-error.js +1 -1
  53. package/dist/lib/types.d.ts +0 -1
  54. package/dist/lib/types.js +1 -1
  55. package/dist/lib/version.d.ts +1 -0
  56. package/dist/lib/version.js +5 -0
  57. package/dist/lib/wire.d.ts +4 -1
  58. package/dist/lib/wire.js +118 -7
  59. package/dist/models/errors.d.ts +13 -2
  60. package/dist/models/errors.js +31 -4
  61. package/dist/models/operations/addons.d.ts +0 -1
  62. package/dist/models/operations/addons.js +1 -1
  63. package/dist/models/operations/apps.d.ts +26 -5
  64. package/dist/models/operations/apps.js +1 -1
  65. package/dist/models/operations/billing.d.ts +0 -1
  66. package/dist/models/operations/billing.js +1 -1
  67. package/dist/models/operations/currencies.d.ts +10 -1
  68. package/dist/models/operations/currencies.js +1 -1
  69. package/dist/models/operations/customers.d.ts +11 -7
  70. package/dist/models/operations/customers.js +1 -1
  71. package/dist/models/operations/defaults.d.ts +0 -1
  72. package/dist/models/operations/defaults.js +1 -1
  73. package/dist/models/operations/entitlements.d.ts +0 -1
  74. package/dist/models/operations/entitlements.js +1 -1
  75. package/dist/models/operations/events.d.ts +0 -1
  76. package/dist/models/operations/events.js +1 -1
  77. package/dist/models/operations/features.d.ts +0 -1
  78. package/dist/models/operations/features.js +1 -1
  79. package/dist/models/operations/governance.d.ts +0 -1
  80. package/dist/models/operations/governance.js +1 -1
  81. package/dist/models/operations/invoices.d.ts +20 -7
  82. package/dist/models/operations/invoices.js +1 -1
  83. package/dist/models/operations/llmCost.d.ts +0 -1
  84. package/dist/models/operations/llmCost.js +1 -1
  85. package/dist/models/operations/meters.d.ts +0 -1
  86. package/dist/models/operations/meters.js +1 -1
  87. package/dist/models/operations/planAddons.d.ts +0 -1
  88. package/dist/models/operations/planAddons.js +1 -1
  89. package/dist/models/operations/plans.d.ts +0 -1
  90. package/dist/models/operations/plans.js +1 -1
  91. package/dist/models/operations/subscriptions.d.ts +0 -1
  92. package/dist/models/operations/subscriptions.js +1 -1
  93. package/dist/models/operations/tax.d.ts +0 -1
  94. package/dist/models/operations/tax.js +1 -1
  95. package/dist/models/schemas.d.ts +11651 -6090
  96. package/dist/models/schemas.js +991 -468
  97. package/dist/models/types.d.ts +941 -810
  98. package/dist/models/types.js +1 -1
  99. package/dist/sdk/addons.d.ts +60 -1
  100. package/dist/sdk/addons.js +63 -1
  101. package/dist/sdk/apps.d.ts +68 -2
  102. package/dist/sdk/apps.js +81 -2
  103. package/dist/sdk/billing.d.ts +57 -1
  104. package/dist/sdk/billing.js +60 -1
  105. package/dist/sdk/customers.d.ts +211 -2
  106. package/dist/sdk/customers.js +222 -2
  107. package/dist/sdk/defaults.d.ts +10 -1
  108. package/dist/sdk/defaults.js +11 -1
  109. package/dist/sdk/entitlements.d.ts +5 -1
  110. package/dist/sdk/entitlements.js +6 -1
  111. package/dist/sdk/events.d.ts +25 -1
  112. package/dist/sdk/events.js +28 -1
  113. package/dist/sdk/features.d.ts +53 -1
  114. package/dist/sdk/features.js +56 -1
  115. package/dist/sdk/internal.d.ts +328 -0
  116. package/dist/sdk/internal.js +404 -0
  117. package/dist/sdk/invoices.d.ts +5 -2
  118. package/dist/sdk/invoices.js +13 -2
  119. package/dist/sdk/llmCost.d.ts +57 -1
  120. package/dist/sdk/llmCost.js +62 -1
  121. package/dist/sdk/meters.d.ts +64 -1
  122. package/dist/sdk/meters.js +67 -1
  123. package/dist/sdk/planAddons.d.ts +46 -1
  124. package/dist/sdk/planAddons.js +49 -1
  125. package/dist/sdk/plans.d.ts +60 -1
  126. package/dist/sdk/plans.js +63 -1
  127. package/dist/sdk/sdk.d.ts +9 -13
  128. package/dist/sdk/sdk.js +11 -20
  129. package/dist/sdk/subscriptions.d.ts +72 -3
  130. package/dist/sdk/subscriptions.js +77 -5
  131. package/dist/sdk/tax.d.ts +34 -1
  132. package/dist/sdk/tax.js +37 -1
  133. package/package.json +30 -6
  134. package/dist/sdk/currencies.d.ts +0 -12
  135. package/dist/sdk/currencies.js +0 -21
  136. package/dist/sdk/governance.d.ts +0 -9
  137. package/dist/sdk/governance.js +0 -12
@@ -1,8 +1,16 @@
1
+ // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
1
2
  import { http } from '../core.js';
2
3
  import { request } from '../lib/request.js';
3
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
4
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
5
6
  import * as schemas from '../models/schemas.js';
7
+ /**
8
+ * Create meter
9
+ *
10
+ * Create a meter.
11
+ *
12
+ * POST /openmeter/meters
13
+ */
6
14
  export function createMeter(client, req, options) {
7
15
  return request(() => {
8
16
  const body = toWire(req, schemas.createMeterBody);
@@ -20,13 +28,29 @@ export function createMeter(client, req, options) {
20
28
  });
21
29
  });
22
30
  }
31
+ /**
32
+ * Get meter
33
+ *
34
+ * Get a meter by ID.
35
+ *
36
+ * GET /openmeter/meters/{meterId}
37
+ */
23
38
  export function getMeter(client, req, options) {
24
39
  return request(() => {
40
+ const pathParamsInput = {
41
+ meterId: req.meterId,
42
+ };
43
+ const pathParams = client._options.validate
44
+ ? toPathWire(pathParamsInput, schemas.getMeterPathParams)
45
+ : pathParamsInput;
46
+ if (client._options.validate) {
47
+ assertValid(schemas.getMeterPathParamsWire, pathParams);
48
+ }
25
49
  const path = `openmeter/meters/${(() => {
26
- if (req.meterId === undefined) {
50
+ if (pathParams.meterId === undefined) {
27
51
  throw new Error('missing path parameter: meterId');
28
52
  }
29
- return encodeURIComponent(String(req.meterId));
53
+ return encodeURIComponent(String(pathParams.meterId));
30
54
  })()}`;
31
55
  return http(client)
32
56
  .get(path, options)
@@ -39,8 +63,18 @@ export function getMeter(client, req, options) {
39
63
  });
40
64
  });
41
65
  }
66
+ /**
67
+ * List meters
68
+ *
69
+ * List meters.
70
+ *
71
+ * GET /openmeter/meters
72
+ */
42
73
  export function listMeters(client, req = {}, options) {
43
74
  return request(() => {
75
+ if (client._options.validate && req.sort !== undefined) {
76
+ assertValid(schemas.listMetersQueryParams.shape.sort, req.sort);
77
+ }
44
78
  const query = toWire({
45
79
  page: req.page,
46
80
  sort: encodeSort(req.sort, toSnakeCase),
@@ -61,13 +95,29 @@ export function listMeters(client, req = {}, options) {
61
95
  });
62
96
  });
63
97
  }
98
+ /**
99
+ * Update meter
100
+ *
101
+ * Update a meter.
102
+ *
103
+ * PUT /openmeter/meters/{meterId}
104
+ */
64
105
  export function updateMeter(client, req, options) {
65
106
  return request(() => {
107
+ const pathParamsInput = {
108
+ meterId: req.meterId,
109
+ };
110
+ const pathParams = client._options.validate
111
+ ? toPathWire(pathParamsInput, schemas.updateMeterPathParams)
112
+ : pathParamsInput;
113
+ if (client._options.validate) {
114
+ assertValid(schemas.updateMeterPathParamsWire, pathParams);
115
+ }
66
116
  const path = `openmeter/meters/${(() => {
67
- if (req.meterId === undefined) {
117
+ if (pathParams.meterId === undefined) {
68
118
  throw new Error('missing path parameter: meterId');
69
119
  }
70
- return encodeURIComponent(String(req.meterId));
120
+ return encodeURIComponent(String(pathParams.meterId));
71
121
  })()}`;
72
122
  const body = toWire(req.body, schemas.updateMeterBody);
73
123
  if (client._options.validate) {
@@ -84,24 +134,66 @@ export function updateMeter(client, req, options) {
84
134
  });
85
135
  });
86
136
  }
137
+ /**
138
+ * Delete meter
139
+ *
140
+ * Delete a meter.
141
+ *
142
+ * DELETE /openmeter/meters/{meterId}
143
+ */
87
144
  export function deleteMeter(client, req, options) {
88
145
  return request(async () => {
146
+ const pathParamsInput = {
147
+ meterId: req.meterId,
148
+ };
149
+ const pathParams = client._options.validate
150
+ ? toPathWire(pathParamsInput, schemas.deleteMeterPathParams)
151
+ : pathParamsInput;
152
+ if (client._options.validate) {
153
+ assertValid(schemas.deleteMeterPathParamsWire, pathParams);
154
+ }
89
155
  const path = `openmeter/meters/${(() => {
90
- if (req.meterId === undefined) {
156
+ if (pathParams.meterId === undefined) {
91
157
  throw new Error('missing path parameter: meterId');
92
158
  }
93
- return encodeURIComponent(String(req.meterId));
159
+ return encodeURIComponent(String(pathParams.meterId));
94
160
  })()}`;
95
161
  await http(client).delete(path, options);
96
162
  });
97
163
  }
164
+ /**
165
+ * Query meter
166
+ *
167
+ * Query a meter for usage.
168
+ *
169
+ * Set `Accept: application/json` (the default) to get a structured JSON response.
170
+ * Set `Accept: text/csv` to download the same data as a CSV file suitable for
171
+ * spreadsheets. The CSV columns, in order, are:
172
+ *
173
+ * `from, to, [subject,] [customer_id, customer_key, customer_name,] <dimensions...>, value`
174
+ *
175
+ * The `subject` column is emitted only when `subject` is in the query's
176
+ * `group_by_dimensions`. The three `customer_*` columns are emitted together only
177
+ * when `customer_id` is in the query's `group_by_dimensions`.
178
+ *
179
+ * POST /openmeter/meters/{meterId}/query
180
+ */
98
181
  export function queryMeter(client, req, options) {
99
182
  return request(() => {
183
+ const pathParamsInput = {
184
+ meterId: req.meterId,
185
+ };
186
+ const pathParams = client._options.validate
187
+ ? toPathWire(pathParamsInput, schemas.queryMeterPathParams)
188
+ : pathParamsInput;
189
+ if (client._options.validate) {
190
+ assertValid(schemas.queryMeterPathParamsWire, pathParams);
191
+ }
100
192
  const path = `openmeter/meters/${(() => {
101
- if (req.meterId === undefined) {
193
+ if (pathParams.meterId === undefined) {
102
194
  throw new Error('missing path parameter: meterId');
103
195
  }
104
- return encodeURIComponent(String(req.meterId));
196
+ return encodeURIComponent(String(pathParams.meterId));
105
197
  })()}/query`;
106
198
  const body = toWire(req.body, schemas.queryMeterBody);
107
199
  if (client._options.validate) {
@@ -118,15 +210,25 @@ export function queryMeter(client, req, options) {
118
210
  });
119
211
  });
120
212
  }
213
+ /** POST /openmeter/meters/{meterId}/query */
121
214
  export function queryMeterCsv(client, req, options) {
122
215
  const headers = new Headers(options?.headers);
123
216
  headers.set('accept', 'text/csv');
124
217
  return request(() => {
218
+ const pathParamsInput = {
219
+ meterId: req.meterId,
220
+ };
221
+ const pathParams = client._options.validate
222
+ ? toPathWire(pathParamsInput, schemas.queryMeterCsvPathParams)
223
+ : pathParamsInput;
224
+ if (client._options.validate) {
225
+ assertValid(schemas.queryMeterCsvPathParamsWire, pathParams);
226
+ }
125
227
  const path = `openmeter/meters/${(() => {
126
- if (req.meterId === undefined) {
228
+ if (pathParams.meterId === undefined) {
127
229
  throw new Error('missing path parameter: meterId');
128
230
  }
129
- return encodeURIComponent(String(req.meterId));
231
+ return encodeURIComponent(String(pathParams.meterId));
130
232
  })()}/query`;
131
233
  const body = toWire(req.body, schemas.queryMeterCsvBody);
132
234
  if (client._options.validate) {
@@ -137,4 +239,3 @@ export function queryMeterCsv(client, req, options) {
137
239
  .text();
138
240
  });
139
241
  }
140
- //# sourceMappingURL=meters.js.map
@@ -1,9 +1,43 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type Result, type RequestOptions } from '../lib/types.js';
3
3
  import type { ListPlanAddonsRequest, ListPlanAddonsResponse, CreatePlanAddonRequest, CreatePlanAddonResponse, GetPlanAddonRequest, GetPlanAddonResponse, UpdatePlanAddonRequest, UpdatePlanAddonResponse, DeletePlanAddonRequest, DeletePlanAddonResponse } from '../models/operations/planAddons.js';
4
+ /**
5
+ * List add-ons for plan
6
+ *
7
+ * List add-ons associated with a plan.
8
+ *
9
+ * GET /openmeter/plans/{planId}/addons
10
+ */
4
11
  export declare function listPlanAddons(client: Client, req: ListPlanAddonsRequest, options?: RequestOptions): Promise<Result<ListPlanAddonsResponse>>;
12
+ /**
13
+ * Add add-on to plan
14
+ *
15
+ * Add an add-on to a plan.
16
+ *
17
+ * POST /openmeter/plans/{planId}/addons
18
+ */
5
19
  export declare function createPlanAddon(client: Client, req: CreatePlanAddonRequest, options?: RequestOptions): Promise<Result<CreatePlanAddonResponse>>;
20
+ /**
21
+ * Get add-on association for plan
22
+ *
23
+ * Get an add-on association for a plan.
24
+ *
25
+ * GET /openmeter/plans/{planId}/addons/{planAddonId}
26
+ */
6
27
  export declare function getPlanAddon(client: Client, req: GetPlanAddonRequest, options?: RequestOptions): Promise<Result<GetPlanAddonResponse>>;
28
+ /**
29
+ * Update add-on association for plan
30
+ *
31
+ * Update an add-on association for a plan.
32
+ *
33
+ * PUT /openmeter/plans/{planId}/addons/{planAddonId}
34
+ */
7
35
  export declare function updatePlanAddon(client: Client, req: UpdatePlanAddonRequest, options?: RequestOptions): Promise<Result<UpdatePlanAddonResponse>>;
36
+ /**
37
+ * Remove add-on from plan
38
+ *
39
+ * Remove an add-on from a plan.
40
+ *
41
+ * DELETE /openmeter/plans/{planId}/addons/{planAddonId}
42
+ */
8
43
  export declare function deletePlanAddon(client: Client, req: DeletePlanAddonRequest, options?: RequestOptions): Promise<Result<DeletePlanAddonResponse>>;
9
- //# sourceMappingURL=planAddons.d.ts.map
@@ -1,15 +1,32 @@
1
+ // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
1
2
  import { http } from '../core.js';
2
3
  import { request } from '../lib/request.js';
3
4
  import { toURLSearchParams } from '../lib/encodings.js';
4
- import { toWire, fromWire, assertValid } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js';
5
6
  import * as schemas from '../models/schemas.js';
7
+ /**
8
+ * List add-ons for plan
9
+ *
10
+ * List add-ons associated with a plan.
11
+ *
12
+ * GET /openmeter/plans/{planId}/addons
13
+ */
6
14
  export function listPlanAddons(client, req, options) {
7
15
  return request(() => {
16
+ const pathParamsInput = {
17
+ planId: req.planId,
18
+ };
19
+ const pathParams = client._options.validate
20
+ ? toPathWire(pathParamsInput, schemas.listPlanAddonsPathParams)
21
+ : pathParamsInput;
22
+ if (client._options.validate) {
23
+ assertValid(schemas.listPlanAddonsPathParamsWire, pathParams);
24
+ }
8
25
  const path = `openmeter/plans/${(() => {
9
- if (req.planId === undefined) {
26
+ if (pathParams.planId === undefined) {
10
27
  throw new Error('missing path parameter: planId');
11
28
  }
12
- return encodeURIComponent(String(req.planId));
29
+ return encodeURIComponent(String(pathParams.planId));
13
30
  })()}/addons`;
14
31
  const query = toWire({
15
32
  page: req.page,
@@ -29,13 +46,29 @@ export function listPlanAddons(client, req, options) {
29
46
  });
30
47
  });
31
48
  }
49
+ /**
50
+ * Add add-on to plan
51
+ *
52
+ * Add an add-on to a plan.
53
+ *
54
+ * POST /openmeter/plans/{planId}/addons
55
+ */
32
56
  export function createPlanAddon(client, req, options) {
33
57
  return request(() => {
58
+ const pathParamsInput = {
59
+ planId: req.planId,
60
+ };
61
+ const pathParams = client._options.validate
62
+ ? toPathWire(pathParamsInput, schemas.createPlanAddonPathParams)
63
+ : pathParamsInput;
64
+ if (client._options.validate) {
65
+ assertValid(schemas.createPlanAddonPathParamsWire, pathParams);
66
+ }
34
67
  const path = `openmeter/plans/${(() => {
35
- if (req.planId === undefined) {
68
+ if (pathParams.planId === undefined) {
36
69
  throw new Error('missing path parameter: planId');
37
70
  }
38
- return encodeURIComponent(String(req.planId));
71
+ return encodeURIComponent(String(pathParams.planId));
39
72
  })()}/addons`;
40
73
  const body = toWire(req.body, schemas.createPlanAddonBody);
41
74
  if (client._options.validate) {
@@ -52,18 +85,35 @@ export function createPlanAddon(client, req, options) {
52
85
  });
53
86
  });
54
87
  }
88
+ /**
89
+ * Get add-on association for plan
90
+ *
91
+ * Get an add-on association for a plan.
92
+ *
93
+ * GET /openmeter/plans/{planId}/addons/{planAddonId}
94
+ */
55
95
  export function getPlanAddon(client, req, options) {
56
96
  return request(() => {
97
+ const pathParamsInput = {
98
+ planId: req.planId,
99
+ planAddonId: req.planAddonId,
100
+ };
101
+ const pathParams = client._options.validate
102
+ ? toPathWire(pathParamsInput, schemas.getPlanAddonPathParams)
103
+ : pathParamsInput;
104
+ if (client._options.validate) {
105
+ assertValid(schemas.getPlanAddonPathParamsWire, pathParams);
106
+ }
57
107
  const path = `openmeter/plans/${(() => {
58
- if (req.planId === undefined) {
108
+ if (pathParams.planId === undefined) {
59
109
  throw new Error('missing path parameter: planId');
60
110
  }
61
- return encodeURIComponent(String(req.planId));
111
+ return encodeURIComponent(String(pathParams.planId));
62
112
  })()}/addons/${(() => {
63
- if (req.planAddonId === undefined) {
113
+ if (pathParams.planAddonId === undefined) {
64
114
  throw new Error('missing path parameter: planAddonId');
65
115
  }
66
- return encodeURIComponent(String(req.planAddonId));
116
+ return encodeURIComponent(String(pathParams.planAddonId));
67
117
  })()}`;
68
118
  return http(client)
69
119
  .get(path, options)
@@ -76,18 +126,35 @@ export function getPlanAddon(client, req, options) {
76
126
  });
77
127
  });
78
128
  }
129
+ /**
130
+ * Update add-on association for plan
131
+ *
132
+ * Update an add-on association for a plan.
133
+ *
134
+ * PUT /openmeter/plans/{planId}/addons/{planAddonId}
135
+ */
79
136
  export function updatePlanAddon(client, req, options) {
80
137
  return request(() => {
138
+ const pathParamsInput = {
139
+ planId: req.planId,
140
+ planAddonId: req.planAddonId,
141
+ };
142
+ const pathParams = client._options.validate
143
+ ? toPathWire(pathParamsInput, schemas.updatePlanAddonPathParams)
144
+ : pathParamsInput;
145
+ if (client._options.validate) {
146
+ assertValid(schemas.updatePlanAddonPathParamsWire, pathParams);
147
+ }
81
148
  const path = `openmeter/plans/${(() => {
82
- if (req.planId === undefined) {
149
+ if (pathParams.planId === undefined) {
83
150
  throw new Error('missing path parameter: planId');
84
151
  }
85
- return encodeURIComponent(String(req.planId));
152
+ return encodeURIComponent(String(pathParams.planId));
86
153
  })()}/addons/${(() => {
87
- if (req.planAddonId === undefined) {
154
+ if (pathParams.planAddonId === undefined) {
88
155
  throw new Error('missing path parameter: planAddonId');
89
156
  }
90
- return encodeURIComponent(String(req.planAddonId));
157
+ return encodeURIComponent(String(pathParams.planAddonId));
91
158
  })()}`;
92
159
  const body = toWire(req.body, schemas.updatePlanAddonBody);
93
160
  if (client._options.validate) {
@@ -104,20 +171,36 @@ export function updatePlanAddon(client, req, options) {
104
171
  });
105
172
  });
106
173
  }
174
+ /**
175
+ * Remove add-on from plan
176
+ *
177
+ * Remove an add-on from a plan.
178
+ *
179
+ * DELETE /openmeter/plans/{planId}/addons/{planAddonId}
180
+ */
107
181
  export function deletePlanAddon(client, req, options) {
108
182
  return request(async () => {
183
+ const pathParamsInput = {
184
+ planId: req.planId,
185
+ planAddonId: req.planAddonId,
186
+ };
187
+ const pathParams = client._options.validate
188
+ ? toPathWire(pathParamsInput, schemas.deletePlanAddonPathParams)
189
+ : pathParamsInput;
190
+ if (client._options.validate) {
191
+ assertValid(schemas.deletePlanAddonPathParamsWire, pathParams);
192
+ }
109
193
  const path = `openmeter/plans/${(() => {
110
- if (req.planId === undefined) {
194
+ if (pathParams.planId === undefined) {
111
195
  throw new Error('missing path parameter: planId');
112
196
  }
113
- return encodeURIComponent(String(req.planId));
197
+ return encodeURIComponent(String(pathParams.planId));
114
198
  })()}/addons/${(() => {
115
- if (req.planAddonId === undefined) {
199
+ if (pathParams.planAddonId === undefined) {
116
200
  throw new Error('missing path parameter: planAddonId');
117
201
  }
118
- return encodeURIComponent(String(req.planAddonId));
202
+ return encodeURIComponent(String(pathParams.planAddonId));
119
203
  })()}`;
120
204
  await http(client).delete(path, options);
121
205
  });
122
206
  }
123
- //# sourceMappingURL=planAddons.js.map
@@ -1,11 +1,59 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type Result, type RequestOptions } from '../lib/types.js';
3
3
  import type { ListPlansRequest, ListPlansResponse, CreatePlanRequest, CreatePlanResponse, UpdatePlanRequest, UpdatePlanResponse, GetPlanRequest, GetPlanResponse, DeletePlanRequest, DeletePlanResponse, ArchivePlanRequest, ArchivePlanResponse, PublishPlanRequest, PublishPlanResponse } from '../models/operations/plans.js';
4
+ /**
5
+ * List plans
6
+ *
7
+ * List all plans.
8
+ *
9
+ * GET /openmeter/plans
10
+ */
4
11
  export declare function listPlans(client: Client, req?: ListPlansRequest, options?: RequestOptions): Promise<Result<ListPlansResponse>>;
12
+ /**
13
+ * Create plan
14
+ *
15
+ * Create a new plan.
16
+ *
17
+ * POST /openmeter/plans
18
+ */
5
19
  export declare function createPlan(client: Client, req: CreatePlanRequest, options?: RequestOptions): Promise<Result<CreatePlanResponse>>;
20
+ /**
21
+ * Update plan
22
+ *
23
+ * Update a plan by id.
24
+ *
25
+ * PUT /openmeter/plans/{planId}
26
+ */
6
27
  export declare function updatePlan(client: Client, req: UpdatePlanRequest, options?: RequestOptions): Promise<Result<UpdatePlanResponse>>;
28
+ /**
29
+ * Get plan
30
+ *
31
+ * Get a plan by id.
32
+ *
33
+ * GET /openmeter/plans/{planId}
34
+ */
7
35
  export declare function getPlan(client: Client, req: GetPlanRequest, options?: RequestOptions): Promise<Result<GetPlanResponse>>;
36
+ /**
37
+ * Delete plan
38
+ *
39
+ * Delete a plan by id.
40
+ *
41
+ * DELETE /openmeter/plans/{planId}
42
+ */
8
43
  export declare function deletePlan(client: Client, req: DeletePlanRequest, options?: RequestOptions): Promise<Result<DeletePlanResponse>>;
44
+ /**
45
+ * Archive plan version
46
+ *
47
+ * Archive a plan version.
48
+ *
49
+ * POST /openmeter/plans/{planId}/archive
50
+ */
9
51
  export declare function archivePlan(client: Client, req: ArchivePlanRequest, options?: RequestOptions): Promise<Result<ArchivePlanResponse>>;
52
+ /**
53
+ * Publish plan version
54
+ *
55
+ * Publish a plan version.
56
+ *
57
+ * POST /openmeter/plans/{planId}/publish
58
+ */
10
59
  export declare function publishPlan(client: Client, req: PublishPlanRequest, options?: RequestOptions): Promise<Result<PublishPlanResponse>>;
11
- //# sourceMappingURL=plans.d.ts.map
@@ -1,10 +1,21 @@
1
+ // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
1
2
  import { http } from '../core.js';
2
3
  import { request } from '../lib/request.js';
3
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
4
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
5
6
  import * as schemas from '../models/schemas.js';
7
+ /**
8
+ * List plans
9
+ *
10
+ * List all plans.
11
+ *
12
+ * GET /openmeter/plans
13
+ */
6
14
  export function listPlans(client, req = {}, options) {
7
15
  return request(() => {
16
+ if (client._options.validate && req.sort !== undefined) {
17
+ assertValid(schemas.listPlansQueryParams.shape.sort, req.sort);
18
+ }
8
19
  const query = toWire({
9
20
  page: req.page,
10
21
  sort: encodeSort(req.sort, toSnakeCase),
@@ -25,6 +36,13 @@ export function listPlans(client, req = {}, options) {
25
36
  });
26
37
  });
27
38
  }
39
+ /**
40
+ * Create plan
41
+ *
42
+ * Create a new plan.
43
+ *
44
+ * POST /openmeter/plans
45
+ */
28
46
  export function createPlan(client, req, options) {
29
47
  return request(() => {
30
48
  const body = toWire(req, schemas.createPlanBody);
@@ -42,13 +60,29 @@ export function createPlan(client, req, options) {
42
60
  });
43
61
  });
44
62
  }
63
+ /**
64
+ * Update plan
65
+ *
66
+ * Update a plan by id.
67
+ *
68
+ * PUT /openmeter/plans/{planId}
69
+ */
45
70
  export function updatePlan(client, req, options) {
46
71
  return request(() => {
72
+ const pathParamsInput = {
73
+ planId: req.planId,
74
+ };
75
+ const pathParams = client._options.validate
76
+ ? toPathWire(pathParamsInput, schemas.updatePlanPathParams)
77
+ : pathParamsInput;
78
+ if (client._options.validate) {
79
+ assertValid(schemas.updatePlanPathParamsWire, pathParams);
80
+ }
47
81
  const path = `openmeter/plans/${(() => {
48
- if (req.planId === undefined) {
82
+ if (pathParams.planId === undefined) {
49
83
  throw new Error('missing path parameter: planId');
50
84
  }
51
- return encodeURIComponent(String(req.planId));
85
+ return encodeURIComponent(String(pathParams.planId));
52
86
  })()}`;
53
87
  const body = toWire(req.body, schemas.updatePlanBody);
54
88
  if (client._options.validate) {
@@ -65,13 +99,29 @@ export function updatePlan(client, req, options) {
65
99
  });
66
100
  });
67
101
  }
102
+ /**
103
+ * Get plan
104
+ *
105
+ * Get a plan by id.
106
+ *
107
+ * GET /openmeter/plans/{planId}
108
+ */
68
109
  export function getPlan(client, req, options) {
69
110
  return request(() => {
111
+ const pathParamsInput = {
112
+ planId: req.planId,
113
+ };
114
+ const pathParams = client._options.validate
115
+ ? toPathWire(pathParamsInput, schemas.getPlanPathParams)
116
+ : pathParamsInput;
117
+ if (client._options.validate) {
118
+ assertValid(schemas.getPlanPathParamsWire, pathParams);
119
+ }
70
120
  const path = `openmeter/plans/${(() => {
71
- if (req.planId === undefined) {
121
+ if (pathParams.planId === undefined) {
72
122
  throw new Error('missing path parameter: planId');
73
123
  }
74
- return encodeURIComponent(String(req.planId));
124
+ return encodeURIComponent(String(pathParams.planId));
75
125
  })()}`;
76
126
  return http(client)
77
127
  .get(path, options)
@@ -84,24 +134,56 @@ export function getPlan(client, req, options) {
84
134
  });
85
135
  });
86
136
  }
137
+ /**
138
+ * Delete plan
139
+ *
140
+ * Delete a plan by id.
141
+ *
142
+ * DELETE /openmeter/plans/{planId}
143
+ */
87
144
  export function deletePlan(client, req, options) {
88
145
  return request(async () => {
146
+ const pathParamsInput = {
147
+ planId: req.planId,
148
+ };
149
+ const pathParams = client._options.validate
150
+ ? toPathWire(pathParamsInput, schemas.deletePlanPathParams)
151
+ : pathParamsInput;
152
+ if (client._options.validate) {
153
+ assertValid(schemas.deletePlanPathParamsWire, pathParams);
154
+ }
89
155
  const path = `openmeter/plans/${(() => {
90
- if (req.planId === undefined) {
156
+ if (pathParams.planId === undefined) {
91
157
  throw new Error('missing path parameter: planId');
92
158
  }
93
- return encodeURIComponent(String(req.planId));
159
+ return encodeURIComponent(String(pathParams.planId));
94
160
  })()}`;
95
161
  await http(client).delete(path, options);
96
162
  });
97
163
  }
164
+ /**
165
+ * Archive plan version
166
+ *
167
+ * Archive a plan version.
168
+ *
169
+ * POST /openmeter/plans/{planId}/archive
170
+ */
98
171
  export function archivePlan(client, req, options) {
99
172
  return request(() => {
173
+ const pathParamsInput = {
174
+ planId: req.planId,
175
+ };
176
+ const pathParams = client._options.validate
177
+ ? toPathWire(pathParamsInput, schemas.archivePlanPathParams)
178
+ : pathParamsInput;
179
+ if (client._options.validate) {
180
+ assertValid(schemas.archivePlanPathParamsWire, pathParams);
181
+ }
100
182
  const path = `openmeter/plans/${(() => {
101
- if (req.planId === undefined) {
183
+ if (pathParams.planId === undefined) {
102
184
  throw new Error('missing path parameter: planId');
103
185
  }
104
- return encodeURIComponent(String(req.planId));
186
+ return encodeURIComponent(String(pathParams.planId));
105
187
  })()}/archive`;
106
188
  return http(client)
107
189
  .post(path, options)
@@ -114,13 +196,29 @@ export function archivePlan(client, req, options) {
114
196
  });
115
197
  });
116
198
  }
199
+ /**
200
+ * Publish plan version
201
+ *
202
+ * Publish a plan version.
203
+ *
204
+ * POST /openmeter/plans/{planId}/publish
205
+ */
117
206
  export function publishPlan(client, req, options) {
118
207
  return request(() => {
208
+ const pathParamsInput = {
209
+ planId: req.planId,
210
+ };
211
+ const pathParams = client._options.validate
212
+ ? toPathWire(pathParamsInput, schemas.publishPlanPathParams)
213
+ : pathParamsInput;
214
+ if (client._options.validate) {
215
+ assertValid(schemas.publishPlanPathParamsWire, pathParams);
216
+ }
119
217
  const path = `openmeter/plans/${(() => {
120
- if (req.planId === undefined) {
218
+ if (pathParams.planId === undefined) {
121
219
  throw new Error('missing path parameter: planId');
122
220
  }
123
- return encodeURIComponent(String(req.planId));
221
+ return encodeURIComponent(String(pathParams.planId));
124
222
  })()}/publish`;
125
223
  return http(client)
126
224
  .post(path, options)
@@ -133,4 +231,3 @@ export function publishPlan(client, req, options) {
133
231
  });
134
232
  });
135
233
  }
136
- //# sourceMappingURL=plans.js.map