@flexprice/sdk 2.1.25 → 2.1.26

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 (181) hide show
  1. package/docs/sdk/models/billing-period-behaviour.md +17 -0
  2. package/docs/sdk/models/billing-period-config.md +18 -0
  3. package/docs/sdk/models/credit-grant-application-response.md +1 -1
  4. package/docs/sdk/models/entitlement-response.md +1 -1
  5. package/docs/sdk/models/entity-change-behaviour.md +2 -2
  6. package/docs/sdk/models/entity-change-policy.md +4 -4
  7. package/docs/sdk/models/entity-change-result.md +6 -6
  8. package/docs/sdk/models/invoice-sync-settings.md +6 -4
  9. package/docs/sdk/models/list-usage-records-response.md +16 -0
  10. package/docs/sdk/models/metadata-custom-field-source.md +17 -0
  11. package/docs/sdk/models/metadata-custom-field.md +17 -0
  12. package/docs/sdk/models/on-pending-schedule-policy.md +15 -0
  13. package/docs/sdk/models/plan-price-sync-status-response.md +17 -0
  14. package/docs/sdk/models/plan-response.md +1 -0
  15. package/docs/sdk/models/price-feature-response.md +15 -0
  16. package/docs/sdk/models/price-response.md +1 -0
  17. package/docs/sdk/models/subscription-change-billing-period-result.md +18 -0
  18. package/docs/sdk/models/subscription-change-conflict-policies.md +15 -0
  19. package/docs/sdk/models/subscription-change-entity-type.md +17 -0
  20. package/docs/sdk/models/subscription-change-v2-request.md +11 -8
  21. package/docs/sdk/models/subscription-change-v2-response.md +16 -14
  22. package/docs/sdk/models/usage-record-filter-order.md +15 -0
  23. package/docs/sdk/models/usage-record-filter.md +31 -0
  24. package/docs/sdk/models/usage-record-response.md +33 -0
  25. package/docs/sdk/models/usage-record-sync-entry.md +20 -0
  26. package/docs/sdks/prices/README.md +1 -1
  27. package/docs/sdks/subscriptions/README.md +3 -1
  28. package/docs/sdks/usagerecords/README.md +78 -0
  29. package/esm/funcs/prices-get-price-by-lookup-key.js +1 -1
  30. package/esm/funcs/prices-get-price-by-lookup-key.js.map +1 -1
  31. package/esm/funcs/subscriptions-execute-subscription-plan-change-v2.d.ts +3 -1
  32. package/esm/funcs/subscriptions-execute-subscription-plan-change-v2.d.ts.map +1 -1
  33. package/esm/funcs/subscriptions-execute-subscription-plan-change-v2.js +3 -1
  34. package/esm/funcs/subscriptions-execute-subscription-plan-change-v2.js.map +1 -1
  35. package/esm/funcs/usage-records-post-usage-records-search.d.ts +17 -0
  36. package/esm/funcs/usage-records-post-usage-records-search.d.ts.map +1 -0
  37. package/esm/funcs/usage-records-post-usage-records-search.js +83 -0
  38. package/esm/funcs/usage-records-post-usage-records-search.js.map +1 -0
  39. package/esm/lib/config.d.ts +3 -3
  40. package/esm/lib/config.js +3 -3
  41. package/esm/sdk/models/billing-period-behaviour.d.ts +13 -0
  42. package/esm/sdk/models/billing-period-behaviour.d.ts.map +1 -0
  43. package/esm/sdk/models/billing-period-behaviour.js +14 -0
  44. package/esm/sdk/models/billing-period-behaviour.js.map +1 -0
  45. package/esm/sdk/models/billing-period-config.d.ts +20 -0
  46. package/esm/sdk/models/billing-period-config.d.ts.map +1 -0
  47. package/esm/sdk/models/billing-period-config.js +25 -0
  48. package/esm/sdk/models/billing-period-config.js.map +1 -0
  49. package/esm/sdk/models/credit-grant-application-response.d.ts +1 -1
  50. package/esm/sdk/models/credit-grant-application-response.js +1 -1
  51. package/esm/sdk/models/entitlement-response.d.ts +1 -1
  52. package/esm/sdk/models/entitlement-response.js +1 -1
  53. package/esm/sdk/models/entity-change-behaviour.d.ts +1 -0
  54. package/esm/sdk/models/entity-change-behaviour.d.ts.map +1 -1
  55. package/esm/sdk/models/entity-change-behaviour.js +1 -0
  56. package/esm/sdk/models/entity-change-behaviour.js.map +1 -1
  57. package/esm/sdk/models/entity-change-policy.d.ts +3 -0
  58. package/esm/sdk/models/entity-change-policy.d.ts.map +1 -1
  59. package/esm/sdk/models/entity-change-policy.js.map +1 -1
  60. package/esm/sdk/models/entity-change-result.d.ts +2 -2
  61. package/esm/sdk/models/entity-change-result.d.ts.map +1 -1
  62. package/esm/sdk/models/entity-change-result.js +2 -2
  63. package/esm/sdk/models/entity-change-result.js.map +1 -1
  64. package/esm/sdk/models/index.d.ts +14 -0
  65. package/esm/sdk/models/index.d.ts.map +1 -1
  66. package/esm/sdk/models/index.js +14 -0
  67. package/esm/sdk/models/index.js.map +1 -1
  68. package/esm/sdk/models/invoice-sync-settings.d.ts +17 -0
  69. package/esm/sdk/models/invoice-sync-settings.d.ts.map +1 -1
  70. package/esm/sdk/models/invoice-sync-settings.js +5 -0
  71. package/esm/sdk/models/invoice-sync-settings.js.map +1 -1
  72. package/esm/sdk/models/list-usage-records-response.d.ts +13 -0
  73. package/esm/sdk/models/list-usage-records-response.d.ts.map +1 -0
  74. package/esm/sdk/models/list-usage-records-response.js +17 -0
  75. package/esm/sdk/models/list-usage-records-response.js.map +1 -0
  76. package/esm/sdk/models/metadata-custom-field-source.d.ts +10 -0
  77. package/esm/sdk/models/metadata-custom-field-source.d.ts.map +1 -0
  78. package/esm/sdk/models/metadata-custom-field-source.js +11 -0
  79. package/esm/sdk/models/metadata-custom-field-source.js.map +1 -0
  80. package/esm/sdk/models/metadata-custom-field.d.ts +13 -0
  81. package/esm/sdk/models/metadata-custom-field.d.ts.map +1 -0
  82. package/esm/sdk/models/metadata-custom-field.js +22 -0
  83. package/esm/sdk/models/metadata-custom-field.js.map +1 -0
  84. package/esm/sdk/models/on-pending-schedule-policy.d.ts +10 -0
  85. package/esm/sdk/models/on-pending-schedule-policy.d.ts.map +1 -0
  86. package/esm/sdk/models/on-pending-schedule-policy.js +11 -0
  87. package/esm/sdk/models/on-pending-schedule-policy.js.map +1 -0
  88. package/esm/sdk/models/plan-price-sync-status-response.d.ts +12 -0
  89. package/esm/sdk/models/plan-price-sync-status-response.d.ts.map +1 -0
  90. package/esm/sdk/models/plan-price-sync-status-response.js +22 -0
  91. package/esm/sdk/models/plan-price-sync-status-response.js.map +1 -0
  92. package/esm/sdk/models/plan-response.d.ts +2 -0
  93. package/esm/sdk/models/plan-response.d.ts.map +1 -1
  94. package/esm/sdk/models/plan-response.js +3 -0
  95. package/esm/sdk/models/plan-response.js.map +1 -1
  96. package/esm/sdk/models/price-feature-response.d.ts +11 -0
  97. package/esm/sdk/models/price-feature-response.d.ts.map +1 -0
  98. package/esm/sdk/models/price-feature-response.js +20 -0
  99. package/esm/sdk/models/price-feature-response.js.map +1 -0
  100. package/esm/sdk/models/price-response.d.ts +2 -0
  101. package/esm/sdk/models/price-response.d.ts.map +1 -1
  102. package/esm/sdk/models/price-response.js +2 -0
  103. package/esm/sdk/models/price-response.js.map +1 -1
  104. package/esm/sdk/models/subscription-change-billing-period-result.d.ts +14 -0
  105. package/esm/sdk/models/subscription-change-billing-period-result.d.ts.map +1 -0
  106. package/esm/sdk/models/subscription-change-billing-period-result.js +25 -0
  107. package/esm/sdk/models/subscription-change-billing-period-result.js.map +1 -0
  108. package/esm/sdk/models/subscription-change-conflict-policies.d.ts +13 -0
  109. package/esm/sdk/models/subscription-change-conflict-policies.d.ts.map +1 -0
  110. package/esm/sdk/models/subscription-change-conflict-policies.js +18 -0
  111. package/esm/sdk/models/subscription-change-conflict-policies.js.map +1 -0
  112. package/esm/sdk/models/subscription-change-entity-type.d.ts +13 -0
  113. package/esm/sdk/models/subscription-change-entity-type.d.ts.map +1 -0
  114. package/esm/sdk/models/subscription-change-entity-type.js +14 -0
  115. package/esm/sdk/models/subscription-change-entity-type.js.map +1 -0
  116. package/esm/sdk/models/subscription-change-v2-request.d.ts +9 -0
  117. package/esm/sdk/models/subscription-change-v2-request.d.ts.map +1 -1
  118. package/esm/sdk/models/subscription-change-v2-request.js +9 -0
  119. package/esm/sdk/models/subscription-change-v2-request.js.map +1 -1
  120. package/esm/sdk/models/subscription-change-v2-response.d.ts +9 -0
  121. package/esm/sdk/models/subscription-change-v2-response.d.ts.map +1 -1
  122. package/esm/sdk/models/subscription-change-v2-response.js +5 -0
  123. package/esm/sdk/models/subscription-change-v2-response.js.map +1 -1
  124. package/esm/sdk/models/usage-record-filter.d.ts +67 -0
  125. package/esm/sdk/models/usage-record-filter.d.ts.map +1 -0
  126. package/esm/sdk/models/usage-record-filter.js +49 -0
  127. package/esm/sdk/models/usage-record-filter.js.map +1 -0
  128. package/esm/sdk/models/usage-record-response.d.ts +32 -0
  129. package/esm/sdk/models/usage-record-response.d.ts.map +1 -0
  130. package/esm/sdk/models/usage-record-response.js +50 -0
  131. package/esm/sdk/models/usage-record-response.js.map +1 -0
  132. package/esm/sdk/models/usage-record-sync-entry.d.ts +32 -0
  133. package/esm/sdk/models/usage-record-sync-entry.d.ts.map +1 -0
  134. package/esm/sdk/models/usage-record-sync-entry.js +28 -0
  135. package/esm/sdk/models/usage-record-sync-entry.js.map +1 -0
  136. package/esm/sdk/sdk.d.ts +3 -0
  137. package/esm/sdk/sdk.d.ts.map +1 -1
  138. package/esm/sdk/sdk.js +5 -0
  139. package/esm/sdk/sdk.js.map +1 -1
  140. package/esm/sdk/subscriptions.d.ts +3 -1
  141. package/esm/sdk/subscriptions.d.ts.map +1 -1
  142. package/esm/sdk/subscriptions.js +3 -1
  143. package/esm/sdk/subscriptions.js.map +1 -1
  144. package/esm/sdk/usage-records.d.ts +12 -0
  145. package/esm/sdk/usage-records.d.ts.map +1 -0
  146. package/esm/sdk/usage-records.js +18 -0
  147. package/esm/sdk/usage-records.js.map +1 -0
  148. package/jsr.json +1 -1
  149. package/package.json +1 -1
  150. package/src/funcs/prices-get-price-by-lookup-key.ts +1 -1
  151. package/src/funcs/subscriptions-execute-subscription-plan-change-v2.ts +3 -1
  152. package/src/funcs/usage-records-post-usage-records-search.ts +172 -0
  153. package/src/lib/config.ts +3 -3
  154. package/src/sdk/models/billing-period-behaviour.ts +25 -0
  155. package/src/sdk/models/billing-period-config.ts +57 -0
  156. package/src/sdk/models/credit-grant-application-response.ts +2 -2
  157. package/src/sdk/models/entitlement-response.ts +2 -2
  158. package/src/sdk/models/entity-change-behaviour.ts +1 -0
  159. package/src/sdk/models/entity-change-policy.ts +3 -0
  160. package/src/sdk/models/entity-change-result.ts +5 -5
  161. package/src/sdk/models/index.ts +14 -0
  162. package/src/sdk/models/invoice-sync-settings.ts +26 -0
  163. package/src/sdk/models/list-usage-records-response.ts +41 -0
  164. package/src/sdk/models/metadata-custom-field-source.ts +21 -0
  165. package/src/sdk/models/metadata-custom-field.ts +47 -0
  166. package/src/sdk/models/on-pending-schedule-policy.ts +19 -0
  167. package/src/sdk/models/plan-price-sync-status-response.ts +44 -0
  168. package/src/sdk/models/plan-response.ts +9 -0
  169. package/src/sdk/models/price-feature-response.ts +43 -0
  170. package/src/sdk/models/price-response.ts +6 -0
  171. package/src/sdk/models/subscription-change-billing-period-result.ts +52 -0
  172. package/src/sdk/models/subscription-change-conflict-policies.ts +44 -0
  173. package/src/sdk/models/subscription-change-entity-type.ts +24 -0
  174. package/src/sdk/models/subscription-change-v2-request.ts +30 -0
  175. package/src/sdk/models/subscription-change-v2-response.ts +18 -0
  176. package/src/sdk/models/usage-record-filter.ts +130 -0
  177. package/src/sdk/models/usage-record-response.ts +93 -0
  178. package/src/sdk/models/usage-record-sync-entry.ts +70 -0
  179. package/src/sdk/sdk.ts +6 -0
  180. package/src/sdk/subscriptions.ts +3 -1
  181. package/src/sdk/usage-records.ts +27 -0
@@ -4,11 +4,25 @@
4
4
 
5
5
  import * as z from "zod/v4-mini";
6
6
  import { remap as remap$ } from "../../lib/primitives.js";
7
+ import {
8
+ BillingPeriodBehaviour,
9
+ BillingPeriodBehaviour$outboundSchema,
10
+ } from "./billing-period-behaviour.js";
11
+ import {
12
+ BillingPeriodConfig,
13
+ BillingPeriodConfig$Outbound,
14
+ BillingPeriodConfig$outboundSchema,
15
+ } from "./billing-period-config.js";
7
16
  import {
8
17
  ProrationBehavior,
9
18
  ProrationBehavior$outboundSchema,
10
19
  } from "./proration-behavior.js";
11
20
  import { ScheduleType, ScheduleType$outboundSchema } from "./schedule-type.js";
21
+ import {
22
+ SubscriptionChangeConflictPolicies,
23
+ SubscriptionChangeConflictPolicies$Outbound,
24
+ SubscriptionChangeConflictPolicies$outboundSchema,
25
+ } from "./subscription-change-conflict-policies.js";
12
26
  import {
13
27
  SubscriptionChangeEntityPolicies,
14
28
  SubscriptionChangeEntityPolicies$Outbound,
@@ -16,20 +30,28 @@ import {
16
30
  } from "./subscription-change-entity-policies.js";
17
31
 
18
32
  export type SubscriptionChangeV2Request = {
33
+ billingPeriodBehaviour?: BillingPeriodBehaviour | undefined;
34
+ billingPeriodConfig?: BillingPeriodConfig | undefined;
19
35
  changeAt?: ScheduleType | undefined;
20
36
  entityPolicies?: SubscriptionChangeEntityPolicies | undefined;
21
37
  idempotencyKey?: string | undefined;
22
38
  metadata?: { [k: string]: string } | undefined;
39
+ onConflictPolicies?: SubscriptionChangeConflictPolicies | undefined;
23
40
  prorationBehavior: ProrationBehavior;
24
41
  targetPlanId: string;
25
42
  };
26
43
 
27
44
  /** @internal */
28
45
  export type SubscriptionChangeV2Request$Outbound = {
46
+ billing_period_behaviour?: string | undefined;
47
+ billing_period_config?: BillingPeriodConfig$Outbound | undefined;
29
48
  change_at?: string | undefined;
30
49
  entity_policies?: SubscriptionChangeEntityPolicies$Outbound | undefined;
31
50
  idempotency_key?: string | undefined;
32
51
  metadata?: { [k: string]: string } | undefined;
52
+ on_conflict_policies?:
53
+ | SubscriptionChangeConflictPolicies$Outbound
54
+ | undefined;
33
55
  proration_behavior: string;
34
56
  target_plan_id: string;
35
57
  };
@@ -40,18 +62,26 @@ export const SubscriptionChangeV2Request$outboundSchema: z.ZodMiniType<
40
62
  SubscriptionChangeV2Request
41
63
  > = z.pipe(
42
64
  z.object({
65
+ billingPeriodBehaviour: z.optional(BillingPeriodBehaviour$outboundSchema),
66
+ billingPeriodConfig: z.optional(BillingPeriodConfig$outboundSchema),
43
67
  changeAt: z.optional(ScheduleType$outboundSchema),
44
68
  entityPolicies: z.optional(SubscriptionChangeEntityPolicies$outboundSchema),
45
69
  idempotencyKey: z.optional(z.string()),
46
70
  metadata: z.optional(z.record(z.string(), z.string())),
71
+ onConflictPolicies: z.optional(
72
+ SubscriptionChangeConflictPolicies$outboundSchema,
73
+ ),
47
74
  prorationBehavior: ProrationBehavior$outboundSchema,
48
75
  targetPlanId: z.string(),
49
76
  }),
50
77
  z.transform((v) => {
51
78
  return remap$(v, {
79
+ billingPeriodBehaviour: "billing_period_behaviour",
80
+ billingPeriodConfig: "billing_period_config",
52
81
  changeAt: "change_at",
53
82
  entityPolicies: "entity_policies",
54
83
  idempotencyKey: "idempotency_key",
84
+ onConflictPolicies: "on_conflict_policies",
55
85
  prorationBehavior: "proration_behavior",
56
86
  targetPlanId: "target_plan_id",
57
87
  });
@@ -17,6 +17,10 @@ import {
17
17
  } from "./entity-change-result.js";
18
18
  import { PlanSummary, PlanSummary$inboundSchema } from "./plan-summary.js";
19
19
  import { SDKValidationError } from "./sdk-validation-error.js";
20
+ import {
21
+ SubscriptionChangeBillingPeriodResult,
22
+ SubscriptionChangeBillingPeriodResult$inboundSchema,
23
+ } from "./subscription-change-billing-period-result.js";
20
24
  import {
21
25
  SubscriptionChangeType,
22
26
  SubscriptionChangeType$inboundSchema,
@@ -27,6 +31,7 @@ import {
27
31
  } from "./subscription-response.js";
28
32
 
29
33
  export type SubscriptionChangeV2Response = {
34
+ billingPeriod?: SubscriptionChangeBillingPeriodResult | undefined;
30
35
  changeType?: SubscriptionChangeType | undefined;
31
36
  changedResources?: ChangedResources | undefined;
32
37
  effectiveAt?: Date | undefined;
@@ -43,6 +48,13 @@ export type SubscriptionChangeV2Response = {
43
48
  scheduleId?: string | undefined;
44
49
  scheduledAt?: Date | undefined;
45
50
  subscription?: SubscriptionResponse | undefined;
51
+ /**
52
+ * SupersededSchedules lists the plan-change schedules this request cancelled under
53
+ *
54
+ * @remarks
55
+ * on_conflict_policies.on_pending_schedule. Preview reports what execute would cancel.
56
+ */
57
+ supersededSchedules?: Array<string> | undefined;
46
58
  toPlan?: PlanSummary | undefined;
47
59
  warnings?: Array<string> | undefined;
48
60
  };
@@ -53,6 +65,9 @@ export const SubscriptionChangeV2Response$inboundSchema: z.ZodMiniType<
53
65
  unknown
54
66
  > = z.pipe(
55
67
  z.object({
68
+ billing_period: types.optional(
69
+ SubscriptionChangeBillingPeriodResult$inboundSchema,
70
+ ),
56
71
  change_type: types.optional(SubscriptionChangeType$inboundSchema),
57
72
  changed_resources: types.optional(ChangedResources$inboundSchema),
58
73
  effective_at: types.optional(types.date()),
@@ -63,11 +78,13 @@ export const SubscriptionChangeV2Response$inboundSchema: z.ZodMiniType<
63
78
  schedule_id: types.optional(types.string()),
64
79
  scheduled_at: types.optional(types.date()),
65
80
  subscription: types.optional(SubscriptionResponse$inboundSchema),
81
+ superseded_schedules: types.optional(z.array(types.string())),
66
82
  to_plan: types.optional(PlanSummary$inboundSchema),
67
83
  warnings: types.optional(z.array(types.string())),
68
84
  }),
69
85
  z.transform((v) => {
70
86
  return remap$(v, {
87
+ "billing_period": "billingPeriod",
71
88
  "change_type": "changeType",
72
89
  "changed_resources": "changedResources",
73
90
  "effective_at": "effectiveAt",
@@ -76,6 +93,7 @@ export const SubscriptionChangeV2Response$inboundSchema: z.ZodMiniType<
76
93
  "is_scheduled": "isScheduled",
77
94
  "schedule_id": "scheduleId",
78
95
  "scheduled_at": "scheduledAt",
96
+ "superseded_schedules": "supersededSchedules",
79
97
  "to_plan": "toPlan",
80
98
  });
81
99
  }),
@@ -0,0 +1,130 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { ClosedEnum } from "../../types/enums.js";
8
+ import {
9
+ FilterCondition,
10
+ FilterCondition$Outbound,
11
+ FilterCondition$outboundSchema,
12
+ } from "./filter-condition.js";
13
+ import {
14
+ SortCondition,
15
+ SortCondition$Outbound,
16
+ SortCondition$outboundSchema,
17
+ } from "./sort-condition.js";
18
+ import { Status, Status$outboundSchema } from "./status.js";
19
+
20
+ export const UsageRecordFilterOrder = {
21
+ Asc: "asc",
22
+ Desc: "desc",
23
+ } as const;
24
+ export type UsageRecordFilterOrder = ClosedEnum<typeof UsageRecordFilterOrder>;
25
+
26
+ export type UsageRecordFilter = {
27
+ currency?: string | undefined;
28
+ customerExternalId?: string | undefined;
29
+ customerId?: string | undefined;
30
+ endTime?: Date | undefined;
31
+ expand?: string | undefined;
32
+ /**
33
+ * Generic predicate and ordering escape hatch, for comparisons that have no dedicated field
34
+ *
35
+ * @remarks
36
+ * below — a range such as period_end at or after a cutoff goes here.
37
+ */
38
+ filters?: Array<FilterCondition> | undefined;
39
+ limit?: number | undefined;
40
+ offset?: number | undefined;
41
+ order?: UsageRecordFilterOrder | undefined;
42
+ periodEnd?: Date | undefined;
43
+ /**
44
+ * Exact-match on the window boundaries. Together with SubscriptionID these identify a single row:
45
+ *
46
+ * @remarks
47
+ * they are the columns the table's unique index is built on.
48
+ */
49
+ periodStart?: Date | undefined;
50
+ planId?: string | undefined;
51
+ sort?: Array<SortCondition> | undefined;
52
+ startTime?: Date | undefined;
53
+ status?: Status | undefined;
54
+ subscriptionId?: string | undefined;
55
+ synced?: boolean | undefined;
56
+ };
57
+
58
+ /** @internal */
59
+ export const UsageRecordFilterOrder$outboundSchema: z.ZodMiniEnum<
60
+ typeof UsageRecordFilterOrder
61
+ > = z.enum(UsageRecordFilterOrder);
62
+
63
+ /** @internal */
64
+ export type UsageRecordFilter$Outbound = {
65
+ currency?: string | undefined;
66
+ customer_external_id?: string | undefined;
67
+ customer_id?: string | undefined;
68
+ end_time?: string | undefined;
69
+ expand?: string | undefined;
70
+ filters?: Array<FilterCondition$Outbound> | undefined;
71
+ limit?: number | undefined;
72
+ offset?: number | undefined;
73
+ order?: string | undefined;
74
+ period_end?: string | undefined;
75
+ period_start?: string | undefined;
76
+ plan_id?: string | undefined;
77
+ sort?: Array<SortCondition$Outbound> | undefined;
78
+ start_time?: string | undefined;
79
+ status?: string | undefined;
80
+ subscription_id?: string | undefined;
81
+ synced?: boolean | undefined;
82
+ };
83
+
84
+ /** @internal */
85
+ export const UsageRecordFilter$outboundSchema: z.ZodMiniType<
86
+ UsageRecordFilter$Outbound,
87
+ UsageRecordFilter
88
+ > = z.pipe(
89
+ z.object({
90
+ currency: z.optional(z.string()),
91
+ customerExternalId: z.optional(z.string()),
92
+ customerId: z.optional(z.string()),
93
+ endTime: z.optional(z.pipe(z.date(), z.transform(v => v.toISOString()))),
94
+ expand: z.optional(z.string()),
95
+ filters: z.optional(z.array(FilterCondition$outboundSchema)),
96
+ limit: z.optional(z.int()),
97
+ offset: z.optional(z.int()),
98
+ order: z.optional(UsageRecordFilterOrder$outboundSchema),
99
+ periodEnd: z.optional(z.pipe(z.date(), z.transform(v => v.toISOString()))),
100
+ periodStart: z.optional(
101
+ z.pipe(z.date(), z.transform(v => v.toISOString())),
102
+ ),
103
+ planId: z.optional(z.string()),
104
+ sort: z.optional(z.array(SortCondition$outboundSchema)),
105
+ startTime: z.optional(z.pipe(z.date(), z.transform(v => v.toISOString()))),
106
+ status: z.optional(Status$outboundSchema),
107
+ subscriptionId: z.optional(z.string()),
108
+ synced: z.optional(z.boolean()),
109
+ }),
110
+ z.transform((v) => {
111
+ return remap$(v, {
112
+ customerExternalId: "customer_external_id",
113
+ customerId: "customer_id",
114
+ endTime: "end_time",
115
+ periodEnd: "period_end",
116
+ periodStart: "period_start",
117
+ planId: "plan_id",
118
+ startTime: "start_time",
119
+ subscriptionId: "subscription_id",
120
+ });
121
+ }),
122
+ );
123
+
124
+ export function usageRecordFilterToJSON(
125
+ usageRecordFilter: UsageRecordFilter,
126
+ ): string {
127
+ return JSON.stringify(
128
+ UsageRecordFilter$outboundSchema.parse(usageRecordFilter),
129
+ );
130
+ }
@@ -0,0 +1,93 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import * as types from "../../types/primitives.js";
10
+ import { SDKValidationError } from "./sdk-validation-error.js";
11
+ import { Status, Status$inboundSchema } from "./status.js";
12
+ import {
13
+ UsageRecordSyncEntry,
14
+ UsageRecordSyncEntry$inboundSchema,
15
+ } from "./usage-record-sync-entry.js";
16
+
17
+ export type UsageRecordResponse = {
18
+ amount?: number | undefined;
19
+ createdAt?: Date | undefined;
20
+ createdBy?: string | undefined;
21
+ currency?: string | undefined;
22
+ customerExternalId?: string | undefined;
23
+ customerId?: string | undefined;
24
+ environmentId?: string | undefined;
25
+ id?: string | undefined;
26
+ periodEnd?: Date | undefined;
27
+ periodStart?: Date | undefined;
28
+ planId?: string | undefined;
29
+ quantity?: number | undefined;
30
+ status?: Status | undefined;
31
+ subscriptionId?: string | undefined;
32
+ synced?: boolean | undefined;
33
+ syncs?: { [k: string]: UsageRecordSyncEntry } | undefined;
34
+ tenantId?: string | undefined;
35
+ updatedAt?: Date | undefined;
36
+ updatedBy?: string | undefined;
37
+ };
38
+
39
+ /** @internal */
40
+ export const UsageRecordResponse$inboundSchema: z.ZodMiniType<
41
+ UsageRecordResponse,
42
+ unknown
43
+ > = z.pipe(
44
+ z.object({
45
+ amount: types.optional(types.number()),
46
+ created_at: types.optional(types.date()),
47
+ created_by: types.optional(types.string()),
48
+ currency: types.optional(types.string()),
49
+ customer_external_id: types.optional(types.string()),
50
+ customer_id: types.optional(types.string()),
51
+ environment_id: types.optional(types.string()),
52
+ id: types.optional(types.string()),
53
+ period_end: types.optional(types.date()),
54
+ period_start: types.optional(types.date()),
55
+ plan_id: types.optional(types.string()),
56
+ quantity: types.optional(types.number()),
57
+ status: types.optional(Status$inboundSchema),
58
+ subscription_id: types.optional(types.string()),
59
+ synced: types.optional(types.boolean()),
60
+ syncs: types.optional(
61
+ z.record(z.string(), UsageRecordSyncEntry$inboundSchema),
62
+ ),
63
+ tenant_id: types.optional(types.string()),
64
+ updated_at: types.optional(types.date()),
65
+ updated_by: types.optional(types.string()),
66
+ }),
67
+ z.transform((v) => {
68
+ return remap$(v, {
69
+ "created_at": "createdAt",
70
+ "created_by": "createdBy",
71
+ "customer_external_id": "customerExternalId",
72
+ "customer_id": "customerId",
73
+ "environment_id": "environmentId",
74
+ "period_end": "periodEnd",
75
+ "period_start": "periodStart",
76
+ "plan_id": "planId",
77
+ "subscription_id": "subscriptionId",
78
+ "tenant_id": "tenantId",
79
+ "updated_at": "updatedAt",
80
+ "updated_by": "updatedBy",
81
+ });
82
+ }),
83
+ );
84
+
85
+ export function usageRecordResponseFromJSON(
86
+ jsonString: string,
87
+ ): SafeParseResult<UsageRecordResponse, SDKValidationError> {
88
+ return safeParse(
89
+ jsonString,
90
+ (x) => UsageRecordResponse$inboundSchema.parse(JSON.parse(x)),
91
+ `Failed to parse 'UsageRecordResponse' from JSON`,
92
+ );
93
+ }
@@ -0,0 +1,70 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import * as types from "../../types/primitives.js";
10
+ import { SDKValidationError } from "./sdk-validation-error.js";
11
+
12
+ export type UsageRecordSyncEntry = {
13
+ /**
14
+ * AgreementID is the subscription's identifier on this marketplace: license_arn on AWS,
15
+ *
16
+ * @remarks
17
+ * usage_reporting_id on GCP, resource_id on Azure. It records which agreement the usage was
18
+ * billed against, which stays meaningful after the connection that reported it is replaced.
19
+ */
20
+ agreementId?: string | undefined;
21
+ /**
22
+ * ConnectionID is the connection that reported this entry, kept for tracing which credentials
23
+ *
24
+ * @remarks
25
+ * were used. It is deliberately not part of the map key: a replaced connection must not make an
26
+ * already reported record look unreported.
27
+ */
28
+ connectionId?: string | undefined;
29
+ reportingId?: string | undefined;
30
+ skipReason?: string | undefined;
31
+ skipped?: boolean | undefined;
32
+ /**
33
+ * SyncedAt is when the marketplace accepted the record. Zero on a skip, since nothing was sent.
34
+ */
35
+ syncedAt?: Date | undefined;
36
+ };
37
+
38
+ /** @internal */
39
+ export const UsageRecordSyncEntry$inboundSchema: z.ZodMiniType<
40
+ UsageRecordSyncEntry,
41
+ unknown
42
+ > = z.pipe(
43
+ z.object({
44
+ agreement_id: types.optional(types.string()),
45
+ connection_id: types.optional(types.string()),
46
+ reporting_id: types.optional(types.string()),
47
+ skip_reason: types.optional(types.string()),
48
+ skipped: types.optional(types.boolean()),
49
+ synced_at: types.optional(types.date()),
50
+ }),
51
+ z.transform((v) => {
52
+ return remap$(v, {
53
+ "agreement_id": "agreementId",
54
+ "connection_id": "connectionId",
55
+ "reporting_id": "reportingId",
56
+ "skip_reason": "skipReason",
57
+ "synced_at": "syncedAt",
58
+ });
59
+ }),
60
+ );
61
+
62
+ export function usageRecordSyncEntryFromJSON(
63
+ jsonString: string,
64
+ ): SafeParseResult<UsageRecordSyncEntry, SDKValidationError> {
65
+ return safeParse(
66
+ jsonString,
67
+ (x) => UsageRecordSyncEntry$inboundSchema.parse(JSON.parse(x)),
68
+ `Failed to parse 'UsageRecordSyncEntry' from JSON`,
69
+ );
70
+ }
package/src/sdk/sdk.ts CHANGED
@@ -33,6 +33,7 @@ import { Tasks } from "./tasks.js";
33
33
  import { TaxAssociations } from "./tax-associations.js";
34
34
  import { TaxRates } from "./tax-rates.js";
35
35
  import { Tenants } from "./tenants.js";
36
+ import { UsageRecords } from "./usage-records.js";
36
37
  import { Users } from "./users.js";
37
38
  import { Wallets } from "./wallets.js";
38
39
  import { WebhookEvents } from "./webhook-events.js";
@@ -194,6 +195,11 @@ export class Flexprice extends ClientSDK {
194
195
  return (this._tenants ??= new Tenants(this._options));
195
196
  }
196
197
 
198
+ private _usageRecords?: UsageRecords;
199
+ get usageRecords(): UsageRecords {
200
+ return (this._usageRecords ??= new UsageRecords(this._options));
201
+ }
202
+
197
203
  private _users?: Users;
198
204
  get users(): Users {
199
205
  return (this._users ??= new Users(this._options));
@@ -319,7 +319,9 @@ export class Subscriptions extends ClientSDK {
319
319
  *
320
320
  * scheduled_at is resolved from the subscription's current period end at request time. If that period end is already in the past (a backdated start date, a resumed pause, or worker downtime can all leave a subscription behind), the change is due immediately and fires on the next billing scan rather than a period away — inspect scheduled_at to see this.
321
321
  *
322
- * Only one plan change may be pending per subscription; request a second one and this returns 400. Cancel the existing schedule via POST /subscriptions/schedules/{schedule_id}/cancel first. Pending schedules are listable via GET /subscriptions/{id}/schedules.
322
+ * Only one plan change may be pending per subscription. By default (on_conflict_policies.on_pending_schedule = 'reject') a second request returns 400; cancel the existing schedule via POST /subscriptions/schedules/{schedule_id}/cancel first. Pending schedules are listable via GET /subscriptions/{id}/schedules.
323
+ *
324
+ * Set on_conflict_policies.on_pending_schedule to 'supersede' to replace the queued change instead: the pending schedule is cancelled and this request applied in the same transaction, so both land or neither does. The cancelled schedule ids are returned in superseded_schedules, and preview reports the same list without writing.
323
325
  */
324
326
  async executeSubscriptionPlanChangeV2(
325
327
  id: string,
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { usageRecordsPostUsageRecordsSearch } from "../funcs/usage-records-post-usage-records-search.js";
6
+ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
7
+ import { unwrapAsync } from "../types/fp.js";
8
+ import * as models from "./models/index.js";
9
+
10
+ export class UsageRecords extends ClientSDK {
11
+ /**
12
+ * List usage records
13
+ *
14
+ * @remarks
15
+ * Lists usage records. Also accepts filters/sort for a filtered query.
16
+ */
17
+ async postUsageRecordsSearch(
18
+ request: models.UsageRecordFilter,
19
+ options?: RequestOptions,
20
+ ): Promise<models.ListUsageRecordsResponse> {
21
+ return unwrapAsync(usageRecordsPostUsageRecordsSearch(
22
+ this,
23
+ request,
24
+ options,
25
+ ));
26
+ }
27
+ }