@paygentic/sdk 0.7.10 → 0.7.12

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 (178) hide show
  1. package/dist/commonjs/funcs/entitlementsIssue.d.ts +1 -1
  2. package/dist/commonjs/funcs/entitlementsIssue.d.ts.map +1 -1
  3. package/dist/commonjs/funcs/entitlementsIssue.js +1 -1
  4. package/dist/commonjs/funcs/entitlementsIssue.js.map +1 -1
  5. package/dist/commonjs/funcs/entitlementsList.d.ts +4 -0
  6. package/dist/commonjs/funcs/entitlementsList.d.ts.map +1 -1
  7. package/dist/commonjs/funcs/entitlementsList.js +4 -0
  8. package/dist/commonjs/funcs/entitlementsList.js.map +1 -1
  9. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts +1 -1
  10. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js +1 -1
  11. package/dist/commonjs/lib/config.d.ts +2 -2
  12. package/dist/commonjs/lib/config.js +2 -2
  13. package/dist/commonjs/models/booleanentitlementdetail.d.ts +16 -19
  14. package/dist/commonjs/models/booleanentitlementdetail.d.ts.map +1 -1
  15. package/dist/commonjs/models/booleanentitlementdetail.js +8 -15
  16. package/dist/commonjs/models/booleanentitlementdetail.js.map +1 -1
  17. package/dist/commonjs/models/booleanentitlementlistitem.d.ts +66 -0
  18. package/dist/commonjs/models/booleanentitlementlistitem.d.ts.map +1 -0
  19. package/dist/commonjs/models/{entitlement.js → booleanentitlementlistitem.js} +16 -27
  20. package/dist/commonjs/models/booleanentitlementlistitem.js.map +1 -0
  21. package/dist/commonjs/models/entitlementlistitem.d.ts +14 -0
  22. package/dist/commonjs/models/entitlementlistitem.d.ts.map +1 -0
  23. package/dist/commonjs/models/entitlementlistitem.js +55 -0
  24. package/dist/commonjs/models/entitlementlistitem.js.map +1 -0
  25. package/dist/commonjs/models/entitlementstatus.d.ts +17 -0
  26. package/dist/commonjs/models/entitlementstatus.d.ts.map +1 -0
  27. package/dist/commonjs/models/entitlementstatus.js +51 -0
  28. package/dist/commonjs/models/entitlementstatus.js.map +1 -0
  29. package/dist/commonjs/models/index.d.ts +5 -2
  30. package/dist/commonjs/models/index.d.ts.map +1 -1
  31. package/dist/commonjs/models/index.js +5 -2
  32. package/dist/commonjs/models/index.js.map +1 -1
  33. package/dist/commonjs/models/invoice.d.ts +4 -0
  34. package/dist/commonjs/models/invoice.d.ts.map +1 -1
  35. package/dist/commonjs/models/invoice.js +1 -0
  36. package/dist/commonjs/models/invoice.js.map +1 -1
  37. package/dist/commonjs/models/meteredentitlementdetail.d.ts +20 -23
  38. package/dist/commonjs/models/meteredentitlementdetail.d.ts.map +1 -1
  39. package/dist/commonjs/models/meteredentitlementdetail.js +10 -17
  40. package/dist/commonjs/models/meteredentitlementdetail.js.map +1 -1
  41. package/dist/commonjs/models/meteredentitlementlistitem.d.ts +90 -0
  42. package/dist/commonjs/models/meteredentitlementlistitem.d.ts.map +1 -0
  43. package/dist/commonjs/models/{entitlementaccessresult.js → meteredentitlementlistitem.js} +23 -37
  44. package/dist/commonjs/models/meteredentitlementlistitem.js.map +1 -0
  45. package/dist/commonjs/models/operations/listentitlements.d.ts +2 -2
  46. package/dist/commonjs/models/operations/listentitlements.d.ts.map +1 -1
  47. package/dist/commonjs/models/operations/listentitlements.js +1 -1
  48. package/dist/commonjs/models/operations/listentitlements.js.map +1 -1
  49. package/dist/commonjs/models/operations/listpaymentsessions.d.ts +1 -1
  50. package/dist/commonjs/models/operations/updatesubscription.d.ts +3 -0
  51. package/dist/commonjs/models/operations/updatesubscription.d.ts.map +1 -1
  52. package/dist/commonjs/models/operations/updatesubscription.js.map +1 -1
  53. package/dist/commonjs/models/schemaspaymentsession.d.ts +8 -0
  54. package/dist/commonjs/models/schemaspaymentsession.d.ts.map +1 -1
  55. package/dist/commonjs/models/schemaspaymentsession.js +2 -0
  56. package/dist/commonjs/models/schemaspaymentsession.js.map +1 -1
  57. package/dist/commonjs/models/staticentitlementdetail.d.ts +12 -21
  58. package/dist/commonjs/models/staticentitlementdetail.d.ts.map +1 -1
  59. package/dist/commonjs/models/staticentitlementdetail.js +8 -16
  60. package/dist/commonjs/models/staticentitlementdetail.js.map +1 -1
  61. package/dist/commonjs/models/staticentitlementlistitem.d.ts +66 -0
  62. package/dist/commonjs/models/staticentitlementlistitem.d.ts.map +1 -0
  63. package/dist/commonjs/models/staticentitlementlistitem.js +63 -0
  64. package/dist/commonjs/models/staticentitlementlistitem.js.map +1 -0
  65. package/dist/commonjs/sdk/entitlements.d.ts +5 -1
  66. package/dist/commonjs/sdk/entitlements.d.ts.map +1 -1
  67. package/dist/commonjs/sdk/entitlements.js +4 -0
  68. package/dist/commonjs/sdk/entitlements.js.map +1 -1
  69. package/dist/commonjs/sdk/paymentsessions.d.ts +1 -1
  70. package/dist/commonjs/sdk/paymentsessions.js +1 -1
  71. package/dist/esm/funcs/entitlementsIssue.d.ts +1 -1
  72. package/dist/esm/funcs/entitlementsIssue.d.ts.map +1 -1
  73. package/dist/esm/funcs/entitlementsIssue.js +1 -1
  74. package/dist/esm/funcs/entitlementsIssue.js.map +1 -1
  75. package/dist/esm/funcs/entitlementsList.d.ts +4 -0
  76. package/dist/esm/funcs/entitlementsList.d.ts.map +1 -1
  77. package/dist/esm/funcs/entitlementsList.js +4 -0
  78. package/dist/esm/funcs/entitlementsList.js.map +1 -1
  79. package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts +1 -1
  80. package/dist/esm/funcs/paymentSessionsListPaymentSessions.js +1 -1
  81. package/dist/esm/lib/config.d.ts +2 -2
  82. package/dist/esm/lib/config.js +2 -2
  83. package/dist/esm/models/booleanentitlementdetail.d.ts +16 -19
  84. package/dist/esm/models/booleanentitlementdetail.d.ts.map +1 -1
  85. package/dist/esm/models/booleanentitlementdetail.js +7 -14
  86. package/dist/esm/models/booleanentitlementdetail.js.map +1 -1
  87. package/dist/esm/models/booleanentitlementlistitem.d.ts +66 -0
  88. package/dist/esm/models/booleanentitlementlistitem.d.ts.map +1 -0
  89. package/dist/esm/models/booleanentitlementlistitem.js +26 -0
  90. package/dist/esm/models/booleanentitlementlistitem.js.map +1 -0
  91. package/dist/esm/models/entitlementlistitem.d.ts +14 -0
  92. package/dist/esm/models/entitlementlistitem.d.ts.map +1 -0
  93. package/dist/esm/models/entitlementlistitem.js +18 -0
  94. package/dist/esm/models/entitlementlistitem.js.map +1 -0
  95. package/dist/esm/models/entitlementstatus.d.ts +17 -0
  96. package/dist/esm/models/entitlementstatus.d.ts.map +1 -0
  97. package/dist/esm/models/entitlementstatus.js +15 -0
  98. package/dist/esm/models/entitlementstatus.js.map +1 -0
  99. package/dist/esm/models/index.d.ts +5 -2
  100. package/dist/esm/models/index.d.ts.map +1 -1
  101. package/dist/esm/models/index.js +5 -2
  102. package/dist/esm/models/index.js.map +1 -1
  103. package/dist/esm/models/invoice.d.ts +4 -0
  104. package/dist/esm/models/invoice.d.ts.map +1 -1
  105. package/dist/esm/models/invoice.js +1 -0
  106. package/dist/esm/models/invoice.js.map +1 -1
  107. package/dist/esm/models/meteredentitlementdetail.d.ts +20 -23
  108. package/dist/esm/models/meteredentitlementdetail.d.ts.map +1 -1
  109. package/dist/esm/models/meteredentitlementdetail.js +9 -16
  110. package/dist/esm/models/meteredentitlementdetail.js.map +1 -1
  111. package/dist/esm/models/meteredentitlementlistitem.d.ts +90 -0
  112. package/dist/esm/models/meteredentitlementlistitem.d.ts.map +1 -0
  113. package/dist/esm/models/meteredentitlementlistitem.js +32 -0
  114. package/dist/esm/models/meteredentitlementlistitem.js.map +1 -0
  115. package/dist/esm/models/operations/listentitlements.d.ts +2 -2
  116. package/dist/esm/models/operations/listentitlements.d.ts.map +1 -1
  117. package/dist/esm/models/operations/listentitlements.js +1 -1
  118. package/dist/esm/models/operations/listentitlements.js.map +1 -1
  119. package/dist/esm/models/operations/listpaymentsessions.d.ts +1 -1
  120. package/dist/esm/models/operations/updatesubscription.d.ts +3 -0
  121. package/dist/esm/models/operations/updatesubscription.d.ts.map +1 -1
  122. package/dist/esm/models/operations/updatesubscription.js.map +1 -1
  123. package/dist/esm/models/schemaspaymentsession.d.ts +8 -0
  124. package/dist/esm/models/schemaspaymentsession.d.ts.map +1 -1
  125. package/dist/esm/models/schemaspaymentsession.js +2 -0
  126. package/dist/esm/models/schemaspaymentsession.js.map +1 -1
  127. package/dist/esm/models/staticentitlementdetail.d.ts +12 -21
  128. package/dist/esm/models/staticentitlementdetail.d.ts.map +1 -1
  129. package/dist/esm/models/staticentitlementdetail.js +7 -15
  130. package/dist/esm/models/staticentitlementdetail.js.map +1 -1
  131. package/dist/esm/models/staticentitlementlistitem.d.ts +66 -0
  132. package/dist/esm/models/staticentitlementlistitem.d.ts.map +1 -0
  133. package/dist/esm/models/staticentitlementlistitem.js +26 -0
  134. package/dist/esm/models/staticentitlementlistitem.js.map +1 -0
  135. package/dist/esm/sdk/entitlements.d.ts +5 -1
  136. package/dist/esm/sdk/entitlements.d.ts.map +1 -1
  137. package/dist/esm/sdk/entitlements.js +4 -0
  138. package/dist/esm/sdk/entitlements.js.map +1 -1
  139. package/dist/esm/sdk/paymentsessions.d.ts +1 -1
  140. package/dist/esm/sdk/paymentsessions.js +1 -1
  141. package/jsr.json +1 -1
  142. package/package.json +1 -1
  143. package/src/funcs/entitlementsIssue.ts +4 -4
  144. package/src/funcs/entitlementsList.ts +4 -0
  145. package/src/funcs/paymentSessionsListPaymentSessions.ts +1 -1
  146. package/src/lib/config.ts +2 -2
  147. package/src/models/booleanentitlementdetail.ts +22 -28
  148. package/src/models/booleanentitlementlistitem.ts +100 -0
  149. package/src/models/entitlementlistitem.ts +49 -0
  150. package/src/models/entitlementstatus.ts +24 -0
  151. package/src/models/index.ts +5 -2
  152. package/src/models/invoice.ts +5 -0
  153. package/src/models/meteredentitlementdetail.ts +28 -34
  154. package/src/models/meteredentitlementlistitem.ts +134 -0
  155. package/src/models/operations/listentitlements.ts +3 -3
  156. package/src/models/operations/listpaymentsessions.ts +1 -1
  157. package/src/models/operations/updatesubscription.ts +3 -0
  158. package/src/models/schemaspaymentsession.ts +10 -0
  159. package/src/models/staticentitlementdetail.ts +19 -30
  160. package/src/models/staticentitlementlistitem.ts +100 -0
  161. package/src/sdk/entitlements.ts +5 -1
  162. package/src/sdk/paymentsessions.ts +1 -1
  163. package/dist/commonjs/models/entitlement.d.ts +0 -71
  164. package/dist/commonjs/models/entitlement.d.ts.map +0 -1
  165. package/dist/commonjs/models/entitlement.js.map +0 -1
  166. package/dist/commonjs/models/entitlementaccessresult.d.ts +0 -99
  167. package/dist/commonjs/models/entitlementaccessresult.d.ts.map +0 -1
  168. package/dist/commonjs/models/entitlementaccessresult.js.map +0 -1
  169. package/dist/esm/models/entitlement.d.ts +0 -71
  170. package/dist/esm/models/entitlement.d.ts.map +0 -1
  171. package/dist/esm/models/entitlement.js +0 -37
  172. package/dist/esm/models/entitlement.js.map +0 -1
  173. package/dist/esm/models/entitlementaccessresult.d.ts +0 -99
  174. package/dist/esm/models/entitlementaccessresult.d.ts.map +0 -1
  175. package/dist/esm/models/entitlementaccessresult.js +0 -46
  176. package/dist/esm/models/entitlementaccessresult.js.map +0 -1
  177. package/src/models/entitlement.ts +0 -107
  178. package/src/models/entitlementaccessresult.ts +0 -147
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paygentic/sdk",
3
- "version": "0.7.10",
3
+ "version": "0.7.12",
4
4
  "author": "Speakeasy",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,7 +37,7 @@ export function entitlementsIssue(
37
37
  options?: RequestOptions,
38
38
  ): APIPromise<
39
39
  Result<
40
- models.Entitlement,
40
+ models.EntitlementDetail,
41
41
  | errors.BadRequest
42
42
  | errors.ErrorT
43
43
  | PaygenticError
@@ -64,7 +64,7 @@ async function $do(
64
64
  ): Promise<
65
65
  [
66
66
  Result<
67
- models.Entitlement,
67
+ models.EntitlementDetail,
68
68
  | errors.BadRequest
69
69
  | errors.ErrorT
70
70
  | PaygenticError
@@ -147,7 +147,7 @@ async function $do(
147
147
  };
148
148
 
149
149
  const [result] = await M.match<
150
- models.Entitlement,
150
+ models.EntitlementDetail,
151
151
  | errors.BadRequest
152
152
  | errors.ErrorT
153
153
  | PaygenticError
@@ -159,7 +159,7 @@ async function $do(
159
159
  | UnexpectedClientError
160
160
  | SDKValidationError
161
161
  >(
162
- M.json(201, models.Entitlement$inboundSchema),
162
+ M.json(201, models.EntitlementDetail$inboundSchema),
163
163
  M.jsonErr(400, errors.BadRequest$inboundSchema),
164
164
  M.jsonErr([403, 404, 409], errors.ErrorT$inboundSchema),
165
165
  M.jsonErr(500, errors.ErrorT$inboundSchema),
@@ -30,6 +30,10 @@ import { Result } from "../types/fp.js";
30
30
  *
31
31
  * @remarks
32
32
  * Retrieve all entitlements for a customer, optionally filtered by feature or product.
33
+ *
34
+ * List items identify the entitlement with `entitlementId` (the original list contract). The get-by-id endpoint (`GET /v1/entitlements/{entitlementId}`) returns the same object but with a top-level `id` and `object: "entitlement"` instead — so use `item.entitlementId`, not `item.id`, when chaining a list result into a get-by-id call.
35
+ *
36
+ * For metered entitlements, each item carries live balance/usage fields, which the API resolves with one grant-engine balance lookup per metered item (bounded concurrency, up to `limit` items per page).
33
37
  */
34
38
  export function entitlementsList(
35
39
  client: PaygenticCore,
@@ -29,7 +29,7 @@ import { Result } from "../types/fp.js";
29
29
  * List
30
30
  *
31
31
  * @remarks
32
- * List payment sessions for the authenticated merchant with optional filters. Supports filtering by subscriptionId, customerId, status, and entityType. When subscriptionId is provided the result includes both the subscription's own activation session (entityType='subscription') and any session attached to invoices for that subscription (entityType='invoice').
32
+ * List payment sessions for the authenticated merchant with optional filters. Supports filtering by subscriptionId, customerId, status, and entityType. When subscriptionId is provided the result includes both the subscription's own activation session (entityType='subscription') and any session attached to invoices for that subscription (entityType='invoice'). When customerId is provided the result covers the customer's full payment history: payment-link sessions (entityType='payment'), the activation sessions of the customer's subscriptions, and the sessions of those subscriptions' invoices.
33
33
  */
34
34
  export function paymentSessionsListPaymentSessions(
35
35
  client: PaygenticCore,
package/src/lib/config.ts CHANGED
@@ -65,7 +65,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
65
65
  export const SDK_METADATA = {
66
66
  language: "typescript",
67
67
  openapiDocVersion: "0.1.0",
68
- sdkVersion: "0.7.10",
68
+ sdkVersion: "0.7.12",
69
69
  genVersion: "2.879.13",
70
- userAgent: "speakeasy-sdk/typescript 0.7.10 2.879.13 0.1.0 @paygentic/sdk",
70
+ userAgent: "speakeasy-sdk/typescript 0.7.12 2.879.13 0.1.0 @paygentic/sdk",
71
71
  } as const;
@@ -6,6 +6,10 @@ import * as z from "zod/v3";
6
6
  import { safeParse } from "../lib/schemas.js";
7
7
  import { ClosedEnum } from "../types/enums.js";
8
8
  import { Result as SafeParseResult } from "../types/fp.js";
9
+ import {
10
+ EntitlementStatus,
11
+ EntitlementStatus$inboundSchema,
12
+ } from "./entitlementstatus.js";
9
13
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
14
 
11
15
  export const BooleanEntitlementDetailObject = {
@@ -15,21 +19,6 @@ export type BooleanEntitlementDetailObject = ClosedEnum<
15
19
  typeof BooleanEntitlementDetailObject
16
20
  >;
17
21
 
18
- /**
19
- * Current status of the entitlement.
20
- */
21
- export const BooleanEntitlementDetailStatus = {
22
- Active: "active",
23
- Canceled: "canceled",
24
- Expired: "expired",
25
- } as const;
26
- /**
27
- * Current status of the entitlement.
28
- */
29
- export type BooleanEntitlementDetailStatus = ClosedEnum<
30
- typeof BooleanEntitlementDetailStatus
31
- >;
32
-
33
22
  /**
34
23
  * Common fields shared by all entitlement types.
35
24
  */
@@ -52,14 +41,18 @@ export type BooleanEntitlementDetail = {
52
41
  */
53
42
  featureKey: string;
54
43
  featureType: "boolean";
44
+ /**
45
+ * Unique identifier for a product
46
+ */
47
+ productId: string;
55
48
  /**
56
49
  * The subscription this entitlement is associated with, if any.
57
50
  */
58
- subscriptionId?: string | null | undefined;
51
+ subscriptionId: string | null;
59
52
  /**
60
53
  * Current status of the entitlement.
61
54
  */
62
- status: BooleanEntitlementDetailStatus;
55
+ status: EntitlementStatus;
63
56
  /**
64
57
  * When the entitlement becomes active.
65
58
  */
@@ -67,7 +60,7 @@ export type BooleanEntitlementDetail = {
67
60
  /**
68
61
  * When the entitlement expires. Null means no expiration.
69
62
  */
70
- activeTo?: Date | null | undefined;
63
+ activeTo: Date | null;
71
64
  /**
72
65
  * Whether the customer currently has active access to this entitlement.
73
66
  */
@@ -75,7 +68,11 @@ export type BooleanEntitlementDetail = {
75
68
  /**
76
69
  * Additional metadata for the entitlement.
77
70
  */
78
- metadata?: { [k: string]: string } | undefined;
71
+ metadata: { [k: string]: string };
72
+ /**
73
+ * Always `null` for boolean entitlements. Surfaced on every entitlement so clients can read `config` without first switching on `featureType`.
74
+ */
75
+ config: { [k: string]: any } | null;
79
76
  };
80
77
 
81
78
  /** @internal */
@@ -83,11 +80,6 @@ export const BooleanEntitlementDetailObject$inboundSchema: z.ZodNativeEnum<
83
80
  typeof BooleanEntitlementDetailObject
84
81
  > = z.nativeEnum(BooleanEntitlementDetailObject);
85
82
 
86
- /** @internal */
87
- export const BooleanEntitlementDetailStatus$inboundSchema: z.ZodNativeEnum<
88
- typeof BooleanEntitlementDetailStatus
89
- > = z.nativeEnum(BooleanEntitlementDetailStatus);
90
-
91
83
  /** @internal */
92
84
  export const BooleanEntitlementDetail$inboundSchema: z.ZodType<
93
85
  BooleanEntitlementDetail,
@@ -100,14 +92,16 @@ export const BooleanEntitlementDetail$inboundSchema: z.ZodType<
100
92
  featureId: z.string(),
101
93
  featureKey: z.string(),
102
94
  featureType: z.literal("boolean"),
103
- subscriptionId: z.nullable(z.string()).optional(),
104
- status: BooleanEntitlementDetailStatus$inboundSchema,
95
+ productId: z.string(),
96
+ subscriptionId: z.nullable(z.string()),
97
+ status: EntitlementStatus$inboundSchema,
105
98
  activeFrom: z.string().datetime({ offset: true }).transform(v => new Date(v)),
106
99
  activeTo: z.nullable(
107
100
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
108
- ).optional(),
101
+ ),
109
102
  hasAccess: z.boolean(),
110
- metadata: z.record(z.string()).optional(),
103
+ metadata: z.record(z.string()),
104
+ config: z.nullable(z.record(z.any())),
111
105
  });
112
106
 
113
107
  export function booleanEntitlementDetailFromJSON(
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import {
9
+ EntitlementStatus,
10
+ EntitlementStatus$inboundSchema,
11
+ } from "./entitlementstatus.js";
12
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
13
+
14
+ /**
15
+ * Common fields shared by all entitlement list items. List items use `entitlementId` (not `id`) to preserve the original public field name on `/v1/entitlements`. The get-by-id endpoint returns the same object with a top-level `id` and `object: "entitlement"` instead.
16
+ */
17
+ export type BooleanEntitlementListItem = {
18
+ /**
19
+ * Unique identifier for the entitlement.
20
+ */
21
+ entitlementId: string;
22
+ /**
23
+ * Unique identifier for a customer
24
+ */
25
+ customerId: string;
26
+ /**
27
+ * The feature this entitlement grants access to.
28
+ */
29
+ featureId: string;
30
+ /**
31
+ * The unique key identifying the feature.
32
+ */
33
+ featureKey: string;
34
+ featureType: "boolean";
35
+ /**
36
+ * Unique identifier for a product
37
+ */
38
+ productId: string;
39
+ /**
40
+ * The subscription this entitlement is associated with, if any.
41
+ */
42
+ subscriptionId: string | null;
43
+ /**
44
+ * Current status of the entitlement.
45
+ */
46
+ status: EntitlementStatus;
47
+ /**
48
+ * When the entitlement becomes active.
49
+ */
50
+ activeFrom: Date;
51
+ /**
52
+ * When the entitlement expires. Null means no expiration.
53
+ */
54
+ activeTo: Date | null;
55
+ /**
56
+ * Whether the customer currently has active access to this entitlement.
57
+ */
58
+ hasAccess: boolean;
59
+ /**
60
+ * Additional metadata for the entitlement.
61
+ */
62
+ metadata: { [k: string]: string };
63
+ /**
64
+ * Always `null` for boolean entitlements. Surfaced on every list item so clients can read `item.config` without first switching on `featureType`.
65
+ */
66
+ config: { [k: string]: any } | null;
67
+ };
68
+
69
+ /** @internal */
70
+ export const BooleanEntitlementListItem$inboundSchema: z.ZodType<
71
+ BooleanEntitlementListItem,
72
+ z.ZodTypeDef,
73
+ unknown
74
+ > = z.object({
75
+ entitlementId: z.string(),
76
+ customerId: z.string(),
77
+ featureId: z.string(),
78
+ featureKey: z.string(),
79
+ featureType: z.literal("boolean"),
80
+ productId: z.string(),
81
+ subscriptionId: z.nullable(z.string()),
82
+ status: EntitlementStatus$inboundSchema,
83
+ activeFrom: z.string().datetime({ offset: true }).transform(v => new Date(v)),
84
+ activeTo: z.nullable(
85
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
86
+ ),
87
+ hasAccess: z.boolean(),
88
+ metadata: z.record(z.string()),
89
+ config: z.nullable(z.record(z.any())),
90
+ });
91
+
92
+ export function booleanEntitlementListItemFromJSON(
93
+ jsonString: string,
94
+ ): SafeParseResult<BooleanEntitlementListItem, SDKValidationError> {
95
+ return safeParse(
96
+ jsonString,
97
+ (x) => BooleanEntitlementListItem$inboundSchema.parse(JSON.parse(x)),
98
+ `Failed to parse 'BooleanEntitlementListItem' from JSON`,
99
+ );
100
+ }
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import {
9
+ BooleanEntitlementListItem,
10
+ BooleanEntitlementListItem$inboundSchema,
11
+ } from "./booleanentitlementlistitem.js";
12
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
13
+ import {
14
+ MeteredEntitlementListItem,
15
+ MeteredEntitlementListItem$inboundSchema,
16
+ } from "./meteredentitlementlistitem.js";
17
+ import {
18
+ StaticEntitlementListItem,
19
+ StaticEntitlementListItem$inboundSchema,
20
+ } from "./staticentitlementlistitem.js";
21
+
22
+ /**
23
+ * An entitlement as returned by the list endpoint. The shape varies by featureType. Uses `entitlementId` (not `id`) for backwards compatibility with the original list contract.
24
+ */
25
+ export type EntitlementListItem =
26
+ | BooleanEntitlementListItem
27
+ | StaticEntitlementListItem
28
+ | MeteredEntitlementListItem;
29
+
30
+ /** @internal */
31
+ export const EntitlementListItem$inboundSchema: z.ZodType<
32
+ EntitlementListItem,
33
+ z.ZodTypeDef,
34
+ unknown
35
+ > = z.union([
36
+ BooleanEntitlementListItem$inboundSchema,
37
+ StaticEntitlementListItem$inboundSchema,
38
+ MeteredEntitlementListItem$inboundSchema,
39
+ ]);
40
+
41
+ export function entitlementListItemFromJSON(
42
+ jsonString: string,
43
+ ): SafeParseResult<EntitlementListItem, SDKValidationError> {
44
+ return safeParse(
45
+ jsonString,
46
+ (x) => EntitlementListItem$inboundSchema.parse(JSON.parse(x)),
47
+ `Failed to parse 'EntitlementListItem' from JSON`,
48
+ );
49
+ }
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { ClosedEnum } from "../types/enums.js";
7
+
8
+ /**
9
+ * Current status of the entitlement.
10
+ */
11
+ export const EntitlementStatus = {
12
+ Active: "active",
13
+ Canceled: "canceled",
14
+ Expired: "expired",
15
+ } as const;
16
+ /**
17
+ * Current status of the entitlement.
18
+ */
19
+ export type EntitlementStatus = ClosedEnum<typeof EntitlementStatus>;
20
+
21
+ /** @internal */
22
+ export const EntitlementStatus$inboundSchema: z.ZodNativeEnum<
23
+ typeof EntitlementStatus
24
+ > = z.nativeEnum(EntitlementStatus);
@@ -5,6 +5,7 @@
5
5
  export * from "./address.js";
6
6
  export * from "./billablemetric.js";
7
7
  export * from "./booleanentitlementdetail.js";
8
+ export * from "./booleanentitlementlistitem.js";
8
9
  export * from "./cost.js";
9
10
  export * from "./costreportgroup.js";
10
11
  export * from "./costreportresponse.js";
@@ -15,9 +16,9 @@ export * from "./createmanuallineitemrequest.js";
15
16
  export * from "./createrulerequest.js";
16
17
  export * from "./currencybreakdownentry.js";
17
18
  export * from "./customer.js";
18
- export * from "./entitlement.js";
19
- export * from "./entitlementaccessresult.js";
20
19
  export * from "./entitlementdetail.js";
20
+ export * from "./entitlementlistitem.js";
21
+ export * from "./entitlementstatus.js";
21
22
  export * from "./entitlementtemplate.js";
22
23
  export * from "./eventresponse.js";
23
24
  export * from "./feature.js";
@@ -36,6 +37,7 @@ export * from "./lineitem.js";
36
37
  export * from "./lineitemsresponse.js";
37
38
  export * from "./lineitemssummary.js";
38
39
  export * from "./meteredentitlementdetail.js";
40
+ export * from "./meteredentitlementlistitem.js";
39
41
  export * from "./meterevent.js";
40
42
  export * from "./metereventlist.js";
41
43
  export * from "./offsetpagination.js";
@@ -64,6 +66,7 @@ export * from "./source.js";
64
66
  export * from "./sourceevent.js";
65
67
  export * from "./sourcerule.js";
66
68
  export * from "./staticentitlementdetail.js";
69
+ export * from "./staticentitlementlistitem.js";
67
70
  export * from "./subscription.js";
68
71
  export * from "./subscriptionmetadata.js";
69
72
  export * from "./subscriptionportal.js";
@@ -129,6 +129,10 @@ export type Invoice = {
129
129
  * ISO 4217 currency code (e.g., USD, EUR)
130
130
  */
131
131
  currency: string;
132
+ /**
133
+ * Machine-readable reason code for the most recent failure (e.g. CALCULATION_FAILED). Present only when status is FAILED or PAYMENT_FAILED.
134
+ */
135
+ failureReason?: string | undefined;
132
136
  /**
133
137
  * The end of the grace period for accepting usage events
134
138
  */
@@ -297,6 +301,7 @@ export const Invoice$inboundSchema: z.ZodType<Invoice, z.ZodTypeDef, unknown> =
297
301
  new Date(v)
298
302
  ),
299
303
  currency: z.string(),
304
+ failureReason: z.string().optional(),
300
305
  gracePeriodEnd: z.string().datetime({ offset: true }).transform(v =>
301
306
  new Date(v)
302
307
  ),
@@ -6,6 +6,10 @@ import * as z from "zod/v3";
6
6
  import { safeParse } from "../lib/schemas.js";
7
7
  import { ClosedEnum } from "../types/enums.js";
8
8
  import { Result as SafeParseResult } from "../types/fp.js";
9
+ import {
10
+ EntitlementStatus,
11
+ EntitlementStatus$inboundSchema,
12
+ } from "./entitlementstatus.js";
9
13
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
14
 
11
15
  export const MeteredEntitlementDetailObject = {
@@ -15,21 +19,6 @@ export type MeteredEntitlementDetailObject = ClosedEnum<
15
19
  typeof MeteredEntitlementDetailObject
16
20
  >;
17
21
 
18
- /**
19
- * Current status of the entitlement.
20
- */
21
- export const MeteredEntitlementDetailStatus = {
22
- Active: "active",
23
- Canceled: "canceled",
24
- Expired: "expired",
25
- } as const;
26
- /**
27
- * Current status of the entitlement.
28
- */
29
- export type MeteredEntitlementDetailStatus = ClosedEnum<
30
- typeof MeteredEntitlementDetailStatus
31
- >;
32
-
33
22
  /**
34
23
  * Common fields shared by all entitlement types.
35
24
  */
@@ -52,14 +41,18 @@ export type MeteredEntitlementDetail = {
52
41
  */
53
42
  featureKey: string;
54
43
  featureType: "metered";
44
+ /**
45
+ * Unique identifier for a product
46
+ */
47
+ productId: string;
55
48
  /**
56
49
  * The subscription this entitlement is associated with, if any.
57
50
  */
58
- subscriptionId?: string | null | undefined;
51
+ subscriptionId: string | null;
59
52
  /**
60
53
  * Current status of the entitlement.
61
54
  */
62
- status: MeteredEntitlementDetailStatus;
55
+ status: EntitlementStatus;
63
56
  /**
64
57
  * When the entitlement becomes active.
65
58
  */
@@ -67,7 +60,7 @@ export type MeteredEntitlementDetail = {
67
60
  /**
68
61
  * When the entitlement expires. Null means no expiration.
69
62
  */
70
- activeTo?: Date | null | undefined;
63
+ activeTo: Date | null;
71
64
  /**
72
65
  * Whether the customer currently has active access to this entitlement.
73
66
  */
@@ -75,7 +68,11 @@ export type MeteredEntitlementDetail = {
75
68
  /**
76
69
  * Additional metadata for the entitlement.
77
70
  */
78
- metadata?: { [k: string]: string } | undefined;
71
+ metadata: { [k: string]: string };
72
+ /**
73
+ * Always `null` for metered entitlements. Surfaced on every entitlement so clients can read `config` without first switching on `featureType`.
74
+ */
75
+ config: { [k: string]: any } | null;
79
76
  /**
80
77
  * When false (hard limit), access is blocked when balance is exhausted and overage is not charged on invoices. When true (soft limit), access continues past the grant and overage is charged at the per-unit rate.
81
78
  */
@@ -93,13 +90,13 @@ export type MeteredEntitlementDetail = {
93
90
  */
94
91
  overage: number;
95
92
  /**
96
- * Start of the current usage period.
93
+ * Start of the current usage period. Before the entitlement activates (the pre-activation "dark window", when the query time is earlier than `activeFrom`) this instead describes the pre-activation `[subscription start, activation)` window and may be `null` when there is no associated subscription.
97
94
  */
98
- currentPeriodStart?: Date | null | undefined;
95
+ currentPeriodStart: Date | null;
99
96
  /**
100
- * End of the current usage period.
97
+ * End of the current usage period. Before the entitlement activates (the pre-activation "dark window", when the query time is earlier than `activeFrom`) this instead holds `activeFrom` — the end of the pre-activation `[subscription start, activation)` window.
101
98
  */
102
- currentPeriodEnd?: Date | null | undefined;
99
+ currentPeriodEnd: Date | null;
103
100
  };
104
101
 
105
102
  /** @internal */
@@ -107,11 +104,6 @@ export const MeteredEntitlementDetailObject$inboundSchema: z.ZodNativeEnum<
107
104
  typeof MeteredEntitlementDetailObject
108
105
  > = z.nativeEnum(MeteredEntitlementDetailObject);
109
106
 
110
- /** @internal */
111
- export const MeteredEntitlementDetailStatus$inboundSchema: z.ZodNativeEnum<
112
- typeof MeteredEntitlementDetailStatus
113
- > = z.nativeEnum(MeteredEntitlementDetailStatus);
114
-
115
107
  /** @internal */
116
108
  export const MeteredEntitlementDetail$inboundSchema: z.ZodType<
117
109
  MeteredEntitlementDetail,
@@ -124,24 +116,26 @@ export const MeteredEntitlementDetail$inboundSchema: z.ZodType<
124
116
  featureId: z.string(),
125
117
  featureKey: z.string(),
126
118
  featureType: z.literal("metered"),
127
- subscriptionId: z.nullable(z.string()).optional(),
128
- status: MeteredEntitlementDetailStatus$inboundSchema,
119
+ productId: z.string(),
120
+ subscriptionId: z.nullable(z.string()),
121
+ status: EntitlementStatus$inboundSchema,
129
122
  activeFrom: z.string().datetime({ offset: true }).transform(v => new Date(v)),
130
123
  activeTo: z.nullable(
131
124
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
132
- ).optional(),
125
+ ),
133
126
  hasAccess: z.boolean(),
134
- metadata: z.record(z.string()).optional(),
127
+ metadata: z.record(z.string()),
128
+ config: z.nullable(z.record(z.any())),
135
129
  isSoftLimit: z.boolean(),
136
130
  balance: z.number(),
137
131
  usageInPeriod: z.number(),
138
132
  overage: z.number(),
139
133
  currentPeriodStart: z.nullable(
140
134
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
141
- ).optional(),
135
+ ),
142
136
  currentPeriodEnd: z.nullable(
143
137
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
144
- ).optional(),
138
+ ),
145
139
  });
146
140
 
147
141
  export function meteredEntitlementDetailFromJSON(
@@ -0,0 +1,134 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import {
9
+ EntitlementStatus,
10
+ EntitlementStatus$inboundSchema,
11
+ } from "./entitlementstatus.js";
12
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
13
+
14
+ /**
15
+ * Common fields shared by all entitlement list items. List items use `entitlementId` (not `id`) to preserve the original public field name on `/v1/entitlements`. The get-by-id endpoint returns the same object with a top-level `id` and `object: "entitlement"` instead.
16
+ */
17
+ export type MeteredEntitlementListItem = {
18
+ /**
19
+ * Unique identifier for the entitlement.
20
+ */
21
+ entitlementId: string;
22
+ /**
23
+ * Unique identifier for a customer
24
+ */
25
+ customerId: string;
26
+ /**
27
+ * The feature this entitlement grants access to.
28
+ */
29
+ featureId: string;
30
+ /**
31
+ * The unique key identifying the feature.
32
+ */
33
+ featureKey: string;
34
+ featureType: "metered";
35
+ /**
36
+ * Unique identifier for a product
37
+ */
38
+ productId: string;
39
+ /**
40
+ * The subscription this entitlement is associated with, if any.
41
+ */
42
+ subscriptionId: string | null;
43
+ /**
44
+ * Current status of the entitlement.
45
+ */
46
+ status: EntitlementStatus;
47
+ /**
48
+ * When the entitlement becomes active.
49
+ */
50
+ activeFrom: Date;
51
+ /**
52
+ * When the entitlement expires. Null means no expiration.
53
+ */
54
+ activeTo: Date | null;
55
+ /**
56
+ * Whether the customer currently has active access to this entitlement.
57
+ */
58
+ hasAccess: boolean;
59
+ /**
60
+ * Additional metadata for the entitlement.
61
+ */
62
+ metadata: { [k: string]: string };
63
+ /**
64
+ * Always `null` for metered entitlements. Surfaced on every list item so clients can read `item.config` without first switching on `featureType`.
65
+ */
66
+ config: { [k: string]: any } | null;
67
+ /**
68
+ * When false (hard limit), access is blocked when balance is exhausted and overage is not charged on invoices. When true (soft limit), access continues past the grant and overage is charged at the per-unit rate.
69
+ */
70
+ isSoftLimit: boolean;
71
+ /**
72
+ * Remaining grant balance for the current period.
73
+ */
74
+ balance: number;
75
+ /**
76
+ * Total usage consumed in the current billing period.
77
+ */
78
+ usageInPeriod: number;
79
+ /**
80
+ * Amount of usage exceeding the granted balance.
81
+ */
82
+ overage: number;
83
+ /**
84
+ * Start of the current usage period. Before the entitlement activates (the pre-activation "dark window", when the query time is earlier than `activeFrom`) this instead describes the pre-activation `[subscription start, activation)` window and may be `null` when there is no associated subscription.
85
+ */
86
+ currentPeriodStart: Date | null;
87
+ /**
88
+ * End of the current usage period. Before the entitlement activates (the pre-activation "dark window", when the query time is earlier than `activeFrom`) this instead holds `activeFrom` — the end of the pre-activation `[subscription start, activation)` window.
89
+ */
90
+ currentPeriodEnd: Date | null;
91
+ };
92
+
93
+ /** @internal */
94
+ export const MeteredEntitlementListItem$inboundSchema: z.ZodType<
95
+ MeteredEntitlementListItem,
96
+ z.ZodTypeDef,
97
+ unknown
98
+ > = z.object({
99
+ entitlementId: z.string(),
100
+ customerId: z.string(),
101
+ featureId: z.string(),
102
+ featureKey: z.string(),
103
+ featureType: z.literal("metered"),
104
+ productId: z.string(),
105
+ subscriptionId: z.nullable(z.string()),
106
+ status: EntitlementStatus$inboundSchema,
107
+ activeFrom: z.string().datetime({ offset: true }).transform(v => new Date(v)),
108
+ activeTo: z.nullable(
109
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
110
+ ),
111
+ hasAccess: z.boolean(),
112
+ metadata: z.record(z.string()),
113
+ config: z.nullable(z.record(z.any())),
114
+ isSoftLimit: z.boolean(),
115
+ balance: z.number(),
116
+ usageInPeriod: z.number(),
117
+ overage: z.number(),
118
+ currentPeriodStart: z.nullable(
119
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
120
+ ),
121
+ currentPeriodEnd: z.nullable(
122
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
123
+ ),
124
+ });
125
+
126
+ export function meteredEntitlementListItemFromJSON(
127
+ jsonString: string,
128
+ ): SafeParseResult<MeteredEntitlementListItem, SDKValidationError> {
129
+ return safeParse(
130
+ jsonString,
131
+ (x) => MeteredEntitlementListItem$inboundSchema.parse(JSON.parse(x)),
132
+ `Failed to parse 'MeteredEntitlementListItem' from JSON`,
133
+ );
134
+ }