@flexprice/sdk 2.1.47-dev.17 → 2.1.47-dev.18

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 (44) hide show
  1. package/docs/sdk/models/get-price-history-request.md +17 -0
  2. package/docs/sdk/models/get-subscription-line-item-history-request.md +17 -0
  3. package/docs/sdks/prices/README.md +72 -0
  4. package/docs/sdks/subscriptions/README.md +72 -0
  5. package/esm/funcs/prices-get-price-history.d.ts +17 -0
  6. package/esm/funcs/prices-get-price-history.d.ts.map +1 -0
  7. package/esm/funcs/prices-get-price-history.js +91 -0
  8. package/esm/funcs/prices-get-price-history.js.map +1 -0
  9. package/esm/funcs/subscriptions-get-subscription-line-item-history.d.ts +17 -0
  10. package/esm/funcs/subscriptions-get-subscription-line-item-history.d.ts.map +1 -0
  11. package/esm/funcs/subscriptions-get-subscription-line-item-history.js +91 -0
  12. package/esm/funcs/subscriptions-get-subscription-line-item-history.js.map +1 -0
  13. package/esm/lib/config.d.ts +2 -2
  14. package/esm/lib/config.js +2 -2
  15. package/esm/sdk/models/get-price-history-op.d.ts +15 -0
  16. package/esm/sdk/models/get-price-history-op.d.ts.map +1 -0
  17. package/esm/sdk/models/get-price-history-op.js +12 -0
  18. package/esm/sdk/models/get-price-history-op.js.map +1 -0
  19. package/esm/sdk/models/get-subscription-line-item-history-op.d.ts +15 -0
  20. package/esm/sdk/models/get-subscription-line-item-history-op.d.ts.map +1 -0
  21. package/esm/sdk/models/get-subscription-line-item-history-op.js +12 -0
  22. package/esm/sdk/models/get-subscription-line-item-history-op.js.map +1 -0
  23. package/esm/sdk/models/index.d.ts +2 -0
  24. package/esm/sdk/models/index.d.ts.map +1 -1
  25. package/esm/sdk/models/index.js +2 -0
  26. package/esm/sdk/models/index.js.map +1 -1
  27. package/esm/sdk/prices.d.ts +7 -0
  28. package/esm/sdk/prices.d.ts.map +1 -1
  29. package/esm/sdk/prices.js +10 -0
  30. package/esm/sdk/prices.js.map +1 -1
  31. package/esm/sdk/subscriptions.d.ts +7 -0
  32. package/esm/sdk/subscriptions.d.ts.map +1 -1
  33. package/esm/sdk/subscriptions.js +10 -0
  34. package/esm/sdk/subscriptions.js.map +1 -1
  35. package/jsr.json +1 -1
  36. package/package.json +1 -1
  37. package/src/funcs/prices-get-price-history.ts +181 -0
  38. package/src/funcs/subscriptions-get-subscription-line-item-history.ts +185 -0
  39. package/src/lib/config.ts +2 -2
  40. package/src/sdk/models/get-price-history-op.ts +33 -0
  41. package/src/sdk/models/get-subscription-line-item-history-op.ts +36 -0
  42. package/src/sdk/models/index.ts +2 -0
  43. package/src/sdk/prices.ts +18 -0
  44. package/src/sdk/subscriptions.ts +18 -0
@@ -0,0 +1,185 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { FlexpriceCore } from "../core.js";
7
+ import { encodeSimple } from "../lib/encodings.js";
8
+ import { matchStatusCode } from "../lib/http.js";
9
+ import * as M from "../lib/matchers.js";
10
+ import { compactMap } from "../lib/primitives.js";
11
+ import { safeParse } from "../lib/schemas.js";
12
+ import { RequestOptions } from "../lib/sdks.js";
13
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
14
+ import { pathToFunc } from "../lib/url.js";
15
+ import { FlexPriceError } from "../sdk/models/flex-price-error.js";
16
+ import {
17
+ ConnectionError,
18
+ InvalidRequestError,
19
+ RequestAbortedError,
20
+ RequestTimeoutError,
21
+ UnexpectedClientError,
22
+ } from "../sdk/models/http-client-errors.js";
23
+ import * as models from "../sdk/models/index.js";
24
+ import { ResponseValidationError } from "../sdk/models/response-validation-error.js";
25
+ import { SDKValidationError } from "../sdk/models/sdk-validation-error.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Get subscription line item history
31
+ *
32
+ * @remarks
33
+ * Use when you need every version of a subscription line item, oldest first. Pass the ID of any version; the same timeline is returned. Versions cancelled before they started are left out unless requested directly.
34
+ */
35
+ export function subscriptionsGetSubscriptionLineItemHistory(
36
+ client: FlexpriceCore,
37
+ id: string,
38
+ options?: RequestOptions,
39
+ ): APIPromise<
40
+ Result<
41
+ models.ListSubscriptionLineItemsResponse,
42
+ | models.ErrorsErrorResponse
43
+ | FlexPriceError
44
+ | ResponseValidationError
45
+ | ConnectionError
46
+ | RequestAbortedError
47
+ | RequestTimeoutError
48
+ | InvalidRequestError
49
+ | UnexpectedClientError
50
+ | SDKValidationError
51
+ >
52
+ > {
53
+ return new APIPromise($do(
54
+ client,
55
+ id,
56
+ options,
57
+ ));
58
+ }
59
+
60
+ async function $do(
61
+ client: FlexpriceCore,
62
+ id: string,
63
+ options?: RequestOptions,
64
+ ): Promise<
65
+ [
66
+ Result<
67
+ models.ListSubscriptionLineItemsResponse,
68
+ | models.ErrorsErrorResponse
69
+ | FlexPriceError
70
+ | ResponseValidationError
71
+ | ConnectionError
72
+ | RequestAbortedError
73
+ | RequestTimeoutError
74
+ | InvalidRequestError
75
+ | UnexpectedClientError
76
+ | SDKValidationError
77
+ >,
78
+ APICall,
79
+ ]
80
+ > {
81
+ const input: models.GetSubscriptionLineItemHistoryRequest = {
82
+ id: id,
83
+ };
84
+
85
+ const parsed = safeParse(
86
+ input,
87
+ (value) =>
88
+ z.parse(
89
+ models.GetSubscriptionLineItemHistoryRequest$outboundSchema,
90
+ value,
91
+ ),
92
+ "Input validation failed",
93
+ );
94
+ if (!parsed.ok) {
95
+ return [parsed, { status: "invalid" }];
96
+ }
97
+ const payload = parsed.value;
98
+ const body = null;
99
+
100
+ const pathParams = {
101
+ id: encodeSimple("id", payload.id, {
102
+ explode: false,
103
+ charEncoding: "percent",
104
+ }),
105
+ };
106
+ const path = pathToFunc("/subscriptions/lineitems/{id}/history")(pathParams);
107
+
108
+ const headers = new Headers(compactMap({
109
+ Accept: "application/json",
110
+ }));
111
+
112
+ const secConfig = await extractSecurity(client._options.apiKeyAuth);
113
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
114
+ const requestSecurity = resolveGlobalSecurity(securityInput);
115
+
116
+ const context = {
117
+ options: client._options,
118
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
119
+ operationID: "getSubscriptionLineItemHistory",
120
+ oAuth2Scopes: null,
121
+
122
+ resolvedSecurity: requestSecurity,
123
+
124
+ securitySource: client._options.apiKeyAuth,
125
+ retryConfig: options?.retries
126
+ || client._options.retryConfig
127
+ || { strategy: "none" },
128
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
129
+ };
130
+
131
+ const requestRes = client._createRequest(context, {
132
+ security: requestSecurity,
133
+ method: "GET",
134
+ baseURL: options?.serverURL,
135
+ path: path,
136
+ headers: headers,
137
+ body: body,
138
+ userAgent: client._options.userAgent,
139
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
140
+ }, options);
141
+ if (!requestRes.ok) {
142
+ return [requestRes, { status: "invalid" }];
143
+ }
144
+ const req = requestRes.value;
145
+
146
+ const doResult = await client._do(req, {
147
+ context,
148
+ isErrorStatusCode: (statusCode: number) =>
149
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
150
+ retryConfig: context.retryConfig,
151
+ retryCodes: context.retryCodes,
152
+ });
153
+ if (!doResult.ok) {
154
+ return [doResult, { status: "request-error", request: req }];
155
+ }
156
+ const response = doResult.value;
157
+
158
+ const responseFields = {
159
+ HttpMeta: { Response: response, Request: req },
160
+ };
161
+
162
+ const [result] = await M.match<
163
+ models.ListSubscriptionLineItemsResponse,
164
+ | models.ErrorsErrorResponse
165
+ | FlexPriceError
166
+ | ResponseValidationError
167
+ | ConnectionError
168
+ | RequestAbortedError
169
+ | RequestTimeoutError
170
+ | InvalidRequestError
171
+ | UnexpectedClientError
172
+ | SDKValidationError
173
+ >(
174
+ M.json(200, models.ListSubscriptionLineItemsResponse$inboundSchema),
175
+ M.jsonErr([400, 404], models.ErrorsErrorResponse$inboundSchema),
176
+ M.jsonErr(500, models.ErrorsErrorResponse$inboundSchema),
177
+ M.fail("4XX"),
178
+ M.fail("5XX"),
179
+ )(response, req, { extraFields: responseFields });
180
+ if (!result.ok) {
181
+ return [result, { status: "complete", request: req, response }];
182
+ }
183
+
184
+ return [result, { status: "complete", request: req, response }];
185
+ }
package/src/lib/config.ts CHANGED
@@ -69,8 +69,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
69
69
  export const SDK_METADATA = {
70
70
  language: "typescript",
71
71
  openapiDocVersion: "1.0",
72
- sdkVersion: "2.1.47-dev.17",
72
+ sdkVersion: "2.1.47-dev.18",
73
73
  genVersion: "2.954.8",
74
74
  userAgent:
75
- "speakeasy-sdk/typescript 2.1.47-dev.17 2.954.8 1.0 @flexprice/sdk",
75
+ "speakeasy-sdk/typescript 2.1.47-dev.18 2.954.8 1.0 @flexprice/sdk",
76
76
  } as const;
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+
7
+ export type GetPriceHistoryRequest = {
8
+ /**
9
+ * Price ID
10
+ */
11
+ id: string;
12
+ };
13
+
14
+ /** @internal */
15
+ export type GetPriceHistoryRequest$Outbound = {
16
+ id: string;
17
+ };
18
+
19
+ /** @internal */
20
+ export const GetPriceHistoryRequest$outboundSchema: z.ZodMiniType<
21
+ GetPriceHistoryRequest$Outbound,
22
+ GetPriceHistoryRequest
23
+ > = z.object({
24
+ id: z.string(),
25
+ });
26
+
27
+ export function getPriceHistoryRequestToJSON(
28
+ getPriceHistoryRequest: GetPriceHistoryRequest,
29
+ ): string {
30
+ return JSON.stringify(
31
+ GetPriceHistoryRequest$outboundSchema.parse(getPriceHistoryRequest),
32
+ );
33
+ }
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+
7
+ export type GetSubscriptionLineItemHistoryRequest = {
8
+ /**
9
+ * Line item ID
10
+ */
11
+ id: string;
12
+ };
13
+
14
+ /** @internal */
15
+ export type GetSubscriptionLineItemHistoryRequest$Outbound = {
16
+ id: string;
17
+ };
18
+
19
+ /** @internal */
20
+ export const GetSubscriptionLineItemHistoryRequest$outboundSchema:
21
+ z.ZodMiniType<
22
+ GetSubscriptionLineItemHistoryRequest$Outbound,
23
+ GetSubscriptionLineItemHistoryRequest
24
+ > = z.object({
25
+ id: z.string(),
26
+ });
27
+
28
+ export function getSubscriptionLineItemHistoryRequestToJSON(
29
+ getSubscriptionLineItemHistoryRequest: GetSubscriptionLineItemHistoryRequest,
30
+ ): string {
31
+ return JSON.stringify(
32
+ GetSubscriptionLineItemHistoryRequest$outboundSchema.parse(
33
+ getSubscriptionLineItemHistoryRequest,
34
+ ),
35
+ );
36
+ }
@@ -356,6 +356,7 @@ export * from "./get-plan-entitlements-op.js";
356
356
  export * from "./get-plan-op.js";
357
357
  export * from "./get-preview-invoice-request.js";
358
358
  export * from "./get-price-by-lookup-key-op.js";
359
+ export * from "./get-price-history-op.js";
359
360
  export * from "./get-price-op.js";
360
361
  export * from "./get-price-unit-by-code-op.js";
361
362
  export * from "./get-price-unit-op.js";
@@ -365,6 +366,7 @@ export * from "./get-refund-op.js";
365
366
  export * from "./get-scheduled-task-op.js";
366
367
  export * from "./get-subscription-addon-associations-op.js";
367
368
  export * from "./get-subscription-entitlements-op.js";
369
+ export * from "./get-subscription-line-item-history-op.js";
368
370
  export * from "./get-subscription-op.js";
369
371
  export * from "./get-subscription-schedule-op.js";
370
372
  export * from "./get-subscription-upcoming-grants-op.js";
package/src/sdk/prices.ts CHANGED
@@ -6,6 +6,7 @@ import { pricesCreatePrice } from "../funcs/prices-create-price.js";
6
6
  import { pricesCreatePricesBulk } from "../funcs/prices-create-prices-bulk.js";
7
7
  import { pricesDeletePrice } from "../funcs/prices-delete-price.js";
8
8
  import { pricesGetPriceByLookupKey } from "../funcs/prices-get-price-by-lookup-key.js";
9
+ import { pricesGetPriceHistory } from "../funcs/prices-get-price-history.js";
9
10
  import { pricesGetPrice } from "../funcs/prices-get-price.js";
10
11
  import { pricesQueryPrice } from "../funcs/prices-query-price.js";
11
12
  import { pricesUpdatePrice } from "../funcs/prices-update-price.js";
@@ -136,4 +137,21 @@ export class Prices extends ClientSDK {
136
137
  options,
137
138
  ));
138
139
  }
140
+
141
+ /**
142
+ * Get price history
143
+ *
144
+ * @remarks
145
+ * Use when you need every version of a plan price, oldest first. Pass the ID of any version; the same timeline is returned.
146
+ */
147
+ async getPriceHistory(
148
+ id: string,
149
+ options?: RequestOptions,
150
+ ): Promise<models.ListPricesResponse> {
151
+ return unwrapAsync(pricesGetPriceHistory(
152
+ this,
153
+ id,
154
+ options,
155
+ ));
156
+ }
139
157
  }
@@ -14,6 +14,7 @@ import { subscriptionsExecuteSubscriptionModify } from "../funcs/subscriptions-e
14
14
  import { subscriptionsExecuteSubscriptionPlanChangeV2 } from "../funcs/subscriptions-execute-subscription-plan-change-v2.js";
15
15
  import { subscriptionsGetSubscriptionAddonAssociations } from "../funcs/subscriptions-get-subscription-addon-associations.js";
16
16
  import { subscriptionsGetSubscriptionEntitlements } from "../funcs/subscriptions-get-subscription-entitlements.js";
17
+ import { subscriptionsGetSubscriptionLineItemHistory } from "../funcs/subscriptions-get-subscription-line-item-history.js";
17
18
  import { subscriptionsGetSubscriptionSchedule } from "../funcs/subscriptions-get-subscription-schedule.js";
18
19
  import { subscriptionsGetSubscriptionUpcomingGrants } from "../funcs/subscriptions-get-subscription-upcoming-grants.js";
19
20
  import { subscriptionsGetSubscriptionUsage } from "../funcs/subscriptions-get-subscription-usage.js";
@@ -148,6 +149,23 @@ export class Subscriptions extends ClientSDK {
148
149
  ));
149
150
  }
150
151
 
152
+ /**
153
+ * Get subscription line item history
154
+ *
155
+ * @remarks
156
+ * Use when you need every version of a subscription line item, oldest first. Pass the ID of any version; the same timeline is returned. Versions cancelled before they started are left out unless requested directly.
157
+ */
158
+ async getSubscriptionLineItemHistory(
159
+ id: string,
160
+ options?: RequestOptions,
161
+ ): Promise<models.ListSubscriptionLineItemsResponse> {
162
+ return unwrapAsync(subscriptionsGetSubscriptionLineItemHistory(
163
+ this,
164
+ id,
165
+ options,
166
+ ));
167
+ }
168
+
151
169
  /**
152
170
  * List all subscription schedules
153
171
  *