@openmeter/sdk 1.0.0-beta.24 → 1.0.0-beta.240

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 (165) hide show
  1. package/README.md +234 -146
  2. package/dist/cjs/index.cjs +18 -0
  3. package/dist/cjs/index.cjs.map +1 -0
  4. package/dist/cjs/index.d.cts +1 -0
  5. package/dist/cjs/src/client/addons.cjs +105 -0
  6. package/dist/cjs/src/client/addons.cjs.map +1 -0
  7. package/dist/cjs/src/client/addons.d.cts +152 -0
  8. package/dist/cjs/src/client/apps.cjs +247 -0
  9. package/dist/cjs/src/client/apps.cjs.map +1 -0
  10. package/dist/cjs/src/client/apps.d.cts +327 -0
  11. package/dist/cjs/src/client/billing.cjs +375 -0
  12. package/dist/cjs/src/client/billing.cjs.map +1 -0
  13. package/dist/cjs/src/client/billing.d.cts +563 -0
  14. package/dist/cjs/src/client/common.cjs +47 -0
  15. package/dist/cjs/src/client/common.cjs.map +1 -0
  16. package/dist/cjs/src/client/common.d.cts +30 -0
  17. package/dist/cjs/src/client/customers.cjs +469 -0
  18. package/dist/cjs/src/client/customers.cjs.map +1 -0
  19. package/dist/cjs/src/client/customers.d.cts +620 -0
  20. package/dist/cjs/src/client/debug.cjs +27 -0
  21. package/dist/cjs/src/client/debug.cjs.map +1 -0
  22. package/dist/cjs/src/client/debug.d.cts +17 -0
  23. package/dist/cjs/src/client/entitlements.cjs +372 -0
  24. package/dist/cjs/src/client/entitlements.cjs.map +1 -0
  25. package/dist/cjs/src/client/entitlements.d.cts +670 -0
  26. package/dist/cjs/src/client/events.cjs +113 -0
  27. package/dist/cjs/src/client/events.cjs.map +1 -0
  28. package/dist/cjs/src/client/events.d.cts +48 -0
  29. package/dist/cjs/src/client/features.cjs +78 -0
  30. package/dist/cjs/src/client/features.cjs.map +1 -0
  31. package/dist/cjs/src/client/features.d.cts +90 -0
  32. package/dist/cjs/src/client/index.cjs +122 -0
  33. package/dist/cjs/src/client/index.cjs.map +1 -0
  34. package/dist/cjs/src/client/index.d.cts +54 -0
  35. package/dist/cjs/src/client/info.cjs +42 -0
  36. package/dist/cjs/src/client/info.cjs.map +1 -0
  37. package/dist/cjs/src/client/info.d.cts +34 -0
  38. package/dist/cjs/src/client/meters.cjs +160 -0
  39. package/dist/cjs/src/client/meters.cjs.map +1 -0
  40. package/dist/cjs/src/client/meters.d.cts +220 -0
  41. package/dist/cjs/src/client/notifications.cjs +269 -0
  42. package/dist/cjs/src/client/notifications.cjs.map +1 -0
  43. package/dist/cjs/src/client/notifications.d.cts +412 -0
  44. package/dist/cjs/src/client/plans.cjs +204 -0
  45. package/dist/cjs/src/client/plans.cjs.map +1 -0
  46. package/dist/cjs/src/client/plans.d.cts +252 -0
  47. package/dist/cjs/src/client/portal.cjs +55 -0
  48. package/dist/cjs/src/client/portal.cjs.map +1 -0
  49. package/dist/cjs/src/client/portal.d.cts +48 -0
  50. package/dist/cjs/src/client/schemas.cjs +3 -0
  51. package/dist/cjs/src/client/schemas.cjs.map +1 -0
  52. package/dist/cjs/src/client/schemas.d.cts +28137 -0
  53. package/dist/cjs/src/client/subjects.cjs +76 -0
  54. package/dist/cjs/src/client/subjects.cjs.map +1 -0
  55. package/dist/cjs/src/client/subjects.d.cts +79 -0
  56. package/dist/cjs/src/client/subscription-addons.cjs +70 -0
  57. package/dist/cjs/src/client/subscription-addons.cjs.map +1 -0
  58. package/dist/cjs/src/client/subscription-addons.d.cts +123 -0
  59. package/dist/cjs/src/client/subscriptions.cjs +132 -0
  60. package/dist/cjs/src/client/subscriptions.cjs.map +1 -0
  61. package/dist/cjs/src/client/subscriptions.d.cts +195 -0
  62. package/dist/cjs/src/client/utils.cjs +67 -0
  63. package/dist/cjs/src/client/utils.cjs.map +1 -0
  64. package/dist/cjs/src/client/utils.d.cts +12 -0
  65. package/dist/cjs/src/portal/index.cjs +89 -0
  66. package/dist/cjs/src/portal/index.cjs.map +1 -0
  67. package/dist/cjs/src/portal/index.d.cts +43 -0
  68. package/dist/cjs/src/react/context.cjs +35 -0
  69. package/dist/cjs/src/react/context.cjs.map +1 -0
  70. package/dist/cjs/src/react/context.d.cts +9 -0
  71. package/dist/cjs/src/zod/index.cjs +13895 -0
  72. package/dist/cjs/src/zod/index.cjs.map +1 -0
  73. package/dist/cjs/src/zod/index.d.cts +6388 -0
  74. package/dist/index.d.ts +1 -14
  75. package/dist/index.js +2 -15
  76. package/dist/index.js.map +1 -0
  77. package/dist/src/client/addons.d.ts +152 -0
  78. package/dist/src/client/addons.js +101 -0
  79. package/dist/src/client/addons.js.map +1 -0
  80. package/dist/src/client/apps.d.ts +327 -0
  81. package/dist/src/client/apps.js +240 -0
  82. package/dist/src/client/apps.js.map +1 -0
  83. package/dist/src/client/billing.d.ts +563 -0
  84. package/dist/src/client/billing.js +368 -0
  85. package/dist/src/client/billing.js.map +1 -0
  86. package/dist/src/client/common.d.ts +30 -0
  87. package/dist/src/client/common.js +42 -0
  88. package/dist/src/client/common.js.map +1 -0
  89. package/dist/src/client/customers.d.ts +620 -0
  90. package/dist/src/client/customers.js +461 -0
  91. package/dist/src/client/customers.js.map +1 -0
  92. package/dist/src/client/debug.d.ts +17 -0
  93. package/dist/src/client/debug.js +23 -0
  94. package/dist/src/client/debug.js.map +1 -0
  95. package/dist/src/client/entitlements.d.ts +670 -0
  96. package/dist/src/client/entitlements.js +365 -0
  97. package/dist/src/client/entitlements.js.map +1 -0
  98. package/dist/src/client/events.d.ts +48 -0
  99. package/dist/src/client/events.js +108 -0
  100. package/dist/src/client/events.js.map +1 -0
  101. package/dist/src/client/features.d.ts +90 -0
  102. package/dist/src/client/features.js +74 -0
  103. package/dist/src/client/features.js.map +1 -0
  104. package/dist/src/client/index.d.ts +54 -0
  105. package/dist/src/client/index.js +82 -0
  106. package/dist/src/client/index.js.map +1 -0
  107. package/dist/src/client/info.d.ts +34 -0
  108. package/dist/src/client/info.js +38 -0
  109. package/dist/src/client/info.js.map +1 -0
  110. package/dist/src/client/meters.d.ts +220 -0
  111. package/dist/src/client/meters.js +156 -0
  112. package/dist/src/client/meters.js.map +1 -0
  113. package/dist/src/client/notifications.d.ts +412 -0
  114. package/dist/src/client/notifications.js +262 -0
  115. package/dist/src/client/notifications.js.map +1 -0
  116. package/dist/src/client/plans.d.ts +252 -0
  117. package/dist/src/client/plans.js +199 -0
  118. package/dist/src/client/plans.js.map +1 -0
  119. package/dist/src/client/portal.d.ts +48 -0
  120. package/dist/src/client/portal.js +51 -0
  121. package/dist/src/client/portal.js.map +1 -0
  122. package/dist/src/client/schemas.d.ts +28137 -0
  123. package/dist/src/client/schemas.js +2 -0
  124. package/dist/src/client/schemas.js.map +1 -0
  125. package/dist/src/client/subjects.d.ts +79 -0
  126. package/dist/src/client/subjects.js +72 -0
  127. package/dist/src/client/subjects.js.map +1 -0
  128. package/dist/src/client/subscription-addons.d.ts +123 -0
  129. package/dist/src/client/subscription-addons.js +66 -0
  130. package/dist/src/client/subscription-addons.js.map +1 -0
  131. package/dist/src/client/subscriptions.d.ts +195 -0
  132. package/dist/src/client/subscriptions.js +128 -0
  133. package/dist/src/client/subscriptions.js.map +1 -0
  134. package/dist/src/client/utils.d.ts +12 -0
  135. package/dist/src/client/utils.js +61 -0
  136. package/dist/src/client/utils.js.map +1 -0
  137. package/dist/src/portal/index.d.ts +43 -0
  138. package/dist/src/portal/index.js +52 -0
  139. package/dist/src/portal/index.js.map +1 -0
  140. package/dist/src/react/context.d.ts +9 -0
  141. package/dist/src/react/context.js +16 -0
  142. package/dist/src/react/context.js.map +1 -0
  143. package/dist/src/zod/index.d.ts +6388 -0
  144. package/dist/src/zod/index.js +13831 -0
  145. package/dist/src/zod/index.js.map +1 -0
  146. package/dist/tsconfig.tsbuildinfo +1 -1
  147. package/package.json +83 -40
  148. package/dist/clients/client.d.ts +0 -40
  149. package/dist/clients/client.js +0 -104
  150. package/dist/clients/event.d.ts +0 -79
  151. package/dist/clients/event.js +0 -53
  152. package/dist/clients/meter.d.ts +0 -71
  153. package/dist/clients/meter.js +0 -64
  154. package/dist/clients/portal.d.ts +0 -23
  155. package/dist/clients/portal.js +0 -37
  156. package/dist/next.d.ts +0 -15
  157. package/dist/next.js +0 -46
  158. package/dist/schemas/openapi.d.ts +0 -460
  159. package/dist/schemas/openapi.js +0 -5
  160. package/dist/test/agent.d.ts +0 -2
  161. package/dist/test/agent.js +0 -178
  162. package/dist/test/mocks.d.ts +0 -12
  163. package/dist/test/mocks.js +0 -32
  164. package/index.ts +0 -22
  165. package/next.ts +0 -76
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/client/schemas.ts"],"names":[],"mappings":""}
@@ -0,0 +1,79 @@
1
+ import type { Client } from 'openapi-fetch';
2
+ import type { RequestOptions } from './common.js';
3
+ import type { operations, paths, SubjectUpsert } from './schemas.js';
4
+ /**
5
+ * Subjects
6
+ * @description Subjects are entities that consume resources you wish to meter. These can range from users, servers, and services to devices. The design of subjects is intentionally generic, enabling flexible application across various metering scenarios. Meters are aggregating events for each subject..
7
+ */
8
+ export declare class Subjects {
9
+ private client;
10
+ constructor(client: Client<paths, `${string}/${string}`>);
11
+ /**
12
+ * Upsert one or multiple subjects
13
+ * If the subject does not exist, it will be created, otherwise it will be updated.
14
+ *
15
+ * @param subjects - The subjects to upsert
16
+ * @param signal - An optional abort signal
17
+ * @returns The upserted subjects
18
+ */
19
+ upsert(subjects: SubjectUpsert | SubjectUpsert[], options?: RequestOptions): Promise<{
20
+ readonly createdAt: Date;
21
+ readonly updatedAt: Date;
22
+ readonly deletedAt?: Date;
23
+ readonly id: string;
24
+ key: string;
25
+ displayName?: string | null;
26
+ metadata?: {
27
+ [key: string]: unknown;
28
+ } | null;
29
+ currentPeriodStart?: Date;
30
+ currentPeriodEnd?: Date;
31
+ stripeCustomerId?: string | null;
32
+ }[] | undefined>;
33
+ /**
34
+ * Get a subject by ID or key
35
+ * @param idOrKey - The ID or key of the subject
36
+ * @param signal - An optional abort signal
37
+ * @returns The subject
38
+ */
39
+ get(idOrKey: operations['getSubject']['parameters']['path']['subjectIdOrKey'], options?: RequestOptions): Promise<{
40
+ readonly createdAt: Date;
41
+ readonly updatedAt: Date;
42
+ readonly deletedAt?: Date;
43
+ readonly id: string;
44
+ key: string;
45
+ displayName?: string | null;
46
+ metadata?: {
47
+ [key: string]: unknown;
48
+ } | null;
49
+ currentPeriodStart?: Date;
50
+ currentPeriodEnd?: Date;
51
+ stripeCustomerId?: string | null;
52
+ } | undefined>;
53
+ /**
54
+ * List subjects
55
+ * @param signal - An optional abort signal
56
+ * @returns The subjects
57
+ */
58
+ list(options?: RequestOptions): Promise<{
59
+ readonly createdAt: Date;
60
+ readonly updatedAt: Date;
61
+ readonly deletedAt?: Date;
62
+ readonly id: string;
63
+ key: string;
64
+ displayName?: string | null;
65
+ metadata?: {
66
+ [key: string]: unknown;
67
+ } | null;
68
+ currentPeriodStart?: Date;
69
+ currentPeriodEnd?: Date;
70
+ stripeCustomerId?: string | null;
71
+ }[] | undefined>;
72
+ /**
73
+ * Delete a subject by ID or key
74
+ * @param idOrKey - The ID or key of the subject
75
+ * @param signal - An optional abort signal
76
+ * @returns The deleted subject
77
+ */
78
+ delete(idOrKey: operations['deleteSubject']['parameters']['path']['subjectIdOrKey'], options?: RequestOptions): Promise<undefined>;
79
+ }
@@ -0,0 +1,72 @@
1
+ import { transformResponse } from './utils.js';
2
+ /**
3
+ * Subjects
4
+ * @description Subjects are entities that consume resources you wish to meter. These can range from users, servers, and services to devices. The design of subjects is intentionally generic, enabling flexible application across various metering scenarios. Meters are aggregating events for each subject..
5
+ */
6
+ export class Subjects {
7
+ client;
8
+ constructor(client) {
9
+ this.client = client;
10
+ }
11
+ /**
12
+ * Upsert one or multiple subjects
13
+ * If the subject does not exist, it will be created, otherwise it will be updated.
14
+ *
15
+ * @param subjects - The subjects to upsert
16
+ * @param signal - An optional abort signal
17
+ * @returns The upserted subjects
18
+ */
19
+ async upsert(subjects, options) {
20
+ const resp = await this.client.POST('/api/v1/subjects', {
21
+ body: Array.isArray(subjects) ? subjects : [subjects],
22
+ ...options,
23
+ });
24
+ return transformResponse(resp);
25
+ }
26
+ /**
27
+ * Get a subject by ID or key
28
+ * @param idOrKey - The ID or key of the subject
29
+ * @param signal - An optional abort signal
30
+ * @returns The subject
31
+ */
32
+ async get(idOrKey, options) {
33
+ const resp = await this.client.GET('/api/v1/subjects/{subjectIdOrKey}', {
34
+ params: {
35
+ path: {
36
+ subjectIdOrKey: idOrKey,
37
+ },
38
+ },
39
+ ...options,
40
+ });
41
+ return transformResponse(resp);
42
+ }
43
+ /**
44
+ * List subjects
45
+ * @param signal - An optional abort signal
46
+ * @returns The subjects
47
+ */
48
+ async list(options) {
49
+ const resp = await this.client.GET('/api/v1/subjects', {
50
+ ...options,
51
+ });
52
+ return transformResponse(resp);
53
+ }
54
+ /**
55
+ * Delete a subject by ID or key
56
+ * @param idOrKey - The ID or key of the subject
57
+ * @param signal - An optional abort signal
58
+ * @returns The deleted subject
59
+ */
60
+ async delete(idOrKey, options) {
61
+ const resp = await this.client.DELETE('/api/v1/subjects/{subjectIdOrKey}', {
62
+ params: {
63
+ path: {
64
+ subjectIdOrKey: idOrKey,
65
+ },
66
+ },
67
+ ...options,
68
+ });
69
+ return transformResponse(resp);
70
+ }
71
+ }
72
+ //# sourceMappingURL=subjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subjects.js","sourceRoot":"","sources":["../../../src/client/subjects.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACC;IAApB,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;IAAG,CAAC;IAEpE;;;;;;;OAOG;IACI,KAAK,CAAC,MAAM,CACjB,QAAyC,EACzC,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE;YACtD,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YACrD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CACd,OAAyE,EACzE,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mCAAmC,EAAE;YACtE,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,cAAc,EAAE,OAAO;iBACxB;aACF;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,OAAwB;QACxC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE;YACrD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CACjB,OAA4E,EAC5E,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mCAAmC,EAAE;YACzE,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,cAAc,EAAE,OAAO;iBACxB;aACF;YACD,GAAG,OAAO;SACX,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
@@ -0,0 +1,123 @@
1
+ import type { Client } from 'openapi-fetch';
2
+ import type { RequestOptions } from './common.js';
3
+ import type { operations, paths } from './schemas.js';
4
+ export declare class SubscriptionAddons {
5
+ private client;
6
+ constructor(client: Client<paths, `${string}/${string}`>);
7
+ /**
8
+ * Create a new subscription addon
9
+ * @param subscriptionId - The ID of the subscription
10
+ * @param addon - The subscription addon to create
11
+ * @param options - Optional request options
12
+ * @returns The created subscription addon
13
+ */
14
+ create(subscriptionId: string, addon: operations['createSubscriptionAddon']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<{
15
+ readonly id: string;
16
+ name: string;
17
+ description?: string;
18
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
19
+ readonly createdAt: Date;
20
+ readonly updatedAt: Date;
21
+ readonly deletedAt?: Date;
22
+ readonly activeFrom: Date;
23
+ readonly activeTo?: Date;
24
+ addon: {
25
+ id: string;
26
+ readonly key: string;
27
+ readonly version: number;
28
+ readonly instanceType: import("./schemas.js").components["schemas"]["AddonInstanceType"];
29
+ };
30
+ readonly quantityAt: Date;
31
+ quantity: number;
32
+ readonly timeline: import("./schemas.js").components["schemas"]["SubscriptionAddonTimelineSegment"][];
33
+ readonly subscriptionId: string;
34
+ readonly rateCards: import("./schemas.js").components["schemas"]["SubscriptionAddonRateCard"][];
35
+ } | undefined>;
36
+ /**
37
+ * List all addons of a subscription
38
+ * @param subscriptionId - The ID of the subscription
39
+ * @param options - Optional request options
40
+ * @returns A list of subscription addons
41
+ */
42
+ list(subscriptionId: string, options?: RequestOptions): Promise<{
43
+ readonly id: string;
44
+ name: string;
45
+ description?: string;
46
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
47
+ readonly createdAt: Date;
48
+ readonly updatedAt: Date;
49
+ readonly deletedAt?: Date;
50
+ readonly activeFrom: Date;
51
+ readonly activeTo?: Date;
52
+ addon: {
53
+ id: string;
54
+ readonly key: string;
55
+ readonly version: number;
56
+ readonly instanceType: import("./schemas.js").components["schemas"]["AddonInstanceType"];
57
+ };
58
+ readonly quantityAt: Date;
59
+ quantity: number;
60
+ readonly timeline: import("./schemas.js").components["schemas"]["SubscriptionAddonTimelineSegment"][];
61
+ readonly subscriptionId: string;
62
+ readonly rateCards: import("./schemas.js").components["schemas"]["SubscriptionAddonRateCard"][];
63
+ }[] | undefined>;
64
+ /**
65
+ * Get a subscription addon by id
66
+ * @param subscriptionId - The ID of the subscription
67
+ * @param subscriptionAddonId - The ID of the subscription addon
68
+ * @param options - Optional request options
69
+ * @returns The subscription addon
70
+ */
71
+ get(subscriptionId: string, subscriptionAddonId: string, options?: RequestOptions): Promise<{
72
+ readonly id: string;
73
+ name: string;
74
+ description?: string;
75
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
76
+ readonly createdAt: Date;
77
+ readonly updatedAt: Date;
78
+ readonly deletedAt?: Date;
79
+ readonly activeFrom: Date;
80
+ readonly activeTo?: Date;
81
+ addon: {
82
+ id: string;
83
+ readonly key: string;
84
+ readonly version: number;
85
+ readonly instanceType: import("./schemas.js").components["schemas"]["AddonInstanceType"];
86
+ };
87
+ readonly quantityAt: Date;
88
+ quantity: number;
89
+ readonly timeline: import("./schemas.js").components["schemas"]["SubscriptionAddonTimelineSegment"][];
90
+ readonly subscriptionId: string;
91
+ readonly rateCards: import("./schemas.js").components["schemas"]["SubscriptionAddonRateCard"][];
92
+ } | undefined>;
93
+ /**
94
+ * Updates a subscription addon
95
+ * @param subscriptionId - The ID of the subscription
96
+ * @param subscriptionAddonId - The ID of the subscription addon to update
97
+ * @param addon - The subscription addon data to update
98
+ * @param options - Optional request options
99
+ * @returns The updated subscription addon
100
+ */
101
+ update(subscriptionId: string, subscriptionAddonId: string, addon: operations['updateSubscriptionAddon']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<{
102
+ readonly id: string;
103
+ name: string;
104
+ description?: string;
105
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
106
+ readonly createdAt: Date;
107
+ readonly updatedAt: Date;
108
+ readonly deletedAt?: Date;
109
+ readonly activeFrom: Date;
110
+ readonly activeTo?: Date;
111
+ addon: {
112
+ id: string;
113
+ readonly key: string;
114
+ readonly version: number;
115
+ readonly instanceType: import("./schemas.js").components["schemas"]["AddonInstanceType"];
116
+ };
117
+ readonly quantityAt: Date;
118
+ quantity: number;
119
+ readonly timeline: import("./schemas.js").components["schemas"]["SubscriptionAddonTimelineSegment"][];
120
+ readonly subscriptionId: string;
121
+ readonly rateCards: import("./schemas.js").components["schemas"]["SubscriptionAddonRateCard"][];
122
+ } | undefined>;
123
+ }
@@ -0,0 +1,66 @@
1
+ import { transformResponse } from './utils.js';
2
+ export class SubscriptionAddons {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ /**
8
+ * Create a new subscription addon
9
+ * @param subscriptionId - The ID of the subscription
10
+ * @param addon - The subscription addon to create
11
+ * @param options - Optional request options
12
+ * @returns The created subscription addon
13
+ */
14
+ async create(subscriptionId, addon, options) {
15
+ const resp = await this.client.POST('/api/v1/subscriptions/{subscriptionId}/addons', {
16
+ body: addon,
17
+ params: { path: { subscriptionId } },
18
+ ...options,
19
+ });
20
+ return transformResponse(resp);
21
+ }
22
+ /**
23
+ * List all addons of a subscription
24
+ * @param subscriptionId - The ID of the subscription
25
+ * @param options - Optional request options
26
+ * @returns A list of subscription addons
27
+ */
28
+ async list(subscriptionId, options) {
29
+ const resp = await this.client.GET('/api/v1/subscriptions/{subscriptionId}/addons', {
30
+ params: { path: { subscriptionId } },
31
+ ...options,
32
+ });
33
+ return transformResponse(resp);
34
+ }
35
+ /**
36
+ * Get a subscription addon by id
37
+ * @param subscriptionId - The ID of the subscription
38
+ * @param subscriptionAddonId - The ID of the subscription addon
39
+ * @param options - Optional request options
40
+ * @returns The subscription addon
41
+ */
42
+ async get(subscriptionId, subscriptionAddonId, options) {
43
+ const resp = await this.client.GET('/api/v1/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}', {
44
+ params: { path: { subscriptionAddonId, subscriptionId } },
45
+ ...options,
46
+ });
47
+ return transformResponse(resp);
48
+ }
49
+ /**
50
+ * Updates a subscription addon
51
+ * @param subscriptionId - The ID of the subscription
52
+ * @param subscriptionAddonId - The ID of the subscription addon to update
53
+ * @param addon - The subscription addon data to update
54
+ * @param options - Optional request options
55
+ * @returns The updated subscription addon
56
+ */
57
+ async update(subscriptionId, subscriptionAddonId, addon, options) {
58
+ const resp = await this.client.PATCH('/api/v1/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}', {
59
+ body: addon,
60
+ params: { path: { subscriptionAddonId, subscriptionId } },
61
+ ...options,
62
+ });
63
+ return transformResponse(resp);
64
+ }
65
+ }
66
+ //# sourceMappingURL=subscription-addons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-addons.js","sourceRoot":"","sources":["../../../src/client/subscription-addons.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,OAAO,kBAAkB;IACT;IAApB,YAAoB,MAA4C;QAA5C,WAAM,GAAN,MAAM,CAAsC;IAAG,CAAC;IAEpE;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CACjB,cAAsB,EACtB,KAA0F,EAC1F,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACjC,+CAA+C,EAC/C;YACE,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,EAAE;YACpC,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAAC,cAAsB,EAAE,OAAwB;QAChE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAChC,+CAA+C,EAC/C;YACE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,EAAE;YACpC,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,GAAG,CACd,cAAsB,EACtB,mBAA2B,EAC3B,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAChC,qEAAqE,EACrE;YACE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,mBAAmB,EAAE,cAAc,EAAE,EAAE;YACzD,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,MAAM,CACjB,cAAsB,EACtB,mBAA2B,EAC3B,KAA0F,EAC1F,OAAwB;QAExB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAClC,qEAAqE,EACrE;YACE,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,mBAAmB,EAAE,cAAc,EAAE,EAAE;YACzD,GAAG,OAAO;SACX,CACF,CAAA;QAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"}
@@ -0,0 +1,195 @@
1
+ import type { Client } from 'openapi-fetch';
2
+ import type { RequestOptions } from './common.js';
3
+ import type { operations, paths, SubscriptionChange, SubscriptionCreate, SubscriptionEdit } from './schemas.js';
4
+ /**
5
+ * Subscriptions
6
+ */
7
+ export declare class Subscriptions {
8
+ private readonly client;
9
+ constructor(client: Client<paths, `${string}/${string}`>);
10
+ /**
11
+ * Create a subscription
12
+ * @param body - The subscription to create
13
+ * @param signal - An optional abort signal
14
+ * @returns The created subscription
15
+ */
16
+ create(body: SubscriptionCreate, options?: RequestOptions): Promise<{
17
+ readonly id: string;
18
+ name: string;
19
+ description?: string;
20
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
21
+ readonly createdAt: Date;
22
+ readonly updatedAt: Date;
23
+ readonly deletedAt?: Date;
24
+ activeFrom: Date;
25
+ activeTo?: Date;
26
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
27
+ alignment?: import("./schemas.js").components["schemas"]["Alignment"];
28
+ readonly status: import("./schemas.js").components["schemas"]["SubscriptionStatus"];
29
+ customerId: string;
30
+ plan?: import("./schemas.js").components["schemas"]["PlanReference"];
31
+ currency: import("./schemas.js").components["schemas"]["CurrencyCode"];
32
+ readonly costBasisMode: import("./schemas.js").components["schemas"]["SubscriptionCostBasisMode"];
33
+ readonly costBasisPins: import("./schemas.js").components["schemas"]["SubscriptionCostBasisPin"][];
34
+ readonly billingCadence: string;
35
+ readonly proRatingConfig?: import("./schemas.js").components["schemas"]["ProRatingConfig"];
36
+ readonly billingAnchor: Date;
37
+ readonly billingStartsAt?: Date;
38
+ readonly settlementMode: import("./schemas.js").components["schemas"]["BillingSettlementMode"];
39
+ } | undefined>;
40
+ /**
41
+ * Get a subscription
42
+ * @param id - The subscription ID
43
+ * @param signal - An optional abort signal
44
+ * @returns The subscription
45
+ */
46
+ get(id: operations['getSubscription']['parameters']['path']['subscriptionId'], options?: RequestOptions): Promise<{
47
+ readonly id: string;
48
+ name: string;
49
+ description?: string;
50
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
51
+ readonly createdAt: Date;
52
+ readonly updatedAt: Date;
53
+ readonly deletedAt?: Date;
54
+ activeFrom: Date;
55
+ activeTo?: Date;
56
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
57
+ readonly status: import("./schemas.js").components["schemas"]["SubscriptionStatus"];
58
+ customerId: string;
59
+ plan?: import("./schemas.js").components["schemas"]["PlanReference"];
60
+ currency: import("./schemas.js").components["schemas"]["CurrencyCode"];
61
+ readonly costBasisMode: import("./schemas.js").components["schemas"]["SubscriptionCostBasisMode"];
62
+ readonly costBasisPins: import("./schemas.js").components["schemas"]["SubscriptionCostBasisPin"][];
63
+ readonly billingCadence: string;
64
+ readonly proRatingConfig?: import("./schemas.js").components["schemas"]["ProRatingConfig"];
65
+ readonly billingAnchor: Date;
66
+ readonly billingStartsAt?: Date;
67
+ readonly settlementMode: import("./schemas.js").components["schemas"]["BillingSettlementMode"];
68
+ alignment?: import("./schemas.js").components["schemas"]["SubscriptionAlignment"];
69
+ phases: import("./schemas.js").components["schemas"]["SubscriptionPhaseExpanded"][];
70
+ } | undefined>;
71
+ /**
72
+ * Edit a subscription
73
+ * @param id - The subscription ID
74
+ * @param body - The subscription to edit
75
+ * @param signal - An optional abort signal
76
+ * @returns The edited subscription
77
+ */
78
+ edit(id: operations['editSubscription']['parameters']['path']['subscriptionId'], body: SubscriptionEdit, options?: RequestOptions): Promise<{
79
+ readonly id: string;
80
+ name: string;
81
+ description?: string;
82
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
83
+ readonly createdAt: Date;
84
+ readonly updatedAt: Date;
85
+ readonly deletedAt?: Date;
86
+ activeFrom: Date;
87
+ activeTo?: Date;
88
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
89
+ alignment?: import("./schemas.js").components["schemas"]["Alignment"];
90
+ readonly status: import("./schemas.js").components["schemas"]["SubscriptionStatus"];
91
+ customerId: string;
92
+ plan?: import("./schemas.js").components["schemas"]["PlanReference"];
93
+ currency: import("./schemas.js").components["schemas"]["CurrencyCode"];
94
+ readonly costBasisMode: import("./schemas.js").components["schemas"]["SubscriptionCostBasisMode"];
95
+ readonly costBasisPins: import("./schemas.js").components["schemas"]["SubscriptionCostBasisPin"][];
96
+ readonly billingCadence: string;
97
+ readonly proRatingConfig?: import("./schemas.js").components["schemas"]["ProRatingConfig"];
98
+ readonly billingAnchor: Date;
99
+ readonly billingStartsAt?: Date;
100
+ readonly settlementMode: import("./schemas.js").components["schemas"]["BillingSettlementMode"];
101
+ } | undefined>;
102
+ /**
103
+ * Cancel a subscription
104
+ * @param id - The subscription ID
105
+ * @param body - The subscription to cancel
106
+ * @param signal - An optional abort signal
107
+ * @returns The canceled subscription
108
+ */
109
+ cancel(id: operations['cancelSubscription']['parameters']['path']['subscriptionId'], body: operations['cancelSubscription']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<{
110
+ readonly id: string;
111
+ name: string;
112
+ description?: string;
113
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
114
+ readonly createdAt: Date;
115
+ readonly updatedAt: Date;
116
+ readonly deletedAt?: Date;
117
+ activeFrom: Date;
118
+ activeTo?: Date;
119
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
120
+ alignment?: import("./schemas.js").components["schemas"]["Alignment"];
121
+ readonly status: import("./schemas.js").components["schemas"]["SubscriptionStatus"];
122
+ customerId: string;
123
+ plan?: import("./schemas.js").components["schemas"]["PlanReference"];
124
+ currency: import("./schemas.js").components["schemas"]["CurrencyCode"];
125
+ readonly costBasisMode: import("./schemas.js").components["schemas"]["SubscriptionCostBasisMode"];
126
+ readonly costBasisPins: import("./schemas.js").components["schemas"]["SubscriptionCostBasisPin"][];
127
+ readonly billingCadence: string;
128
+ readonly proRatingConfig?: import("./schemas.js").components["schemas"]["ProRatingConfig"];
129
+ readonly billingAnchor: Date;
130
+ readonly billingStartsAt?: Date;
131
+ readonly settlementMode: import("./schemas.js").components["schemas"]["BillingSettlementMode"];
132
+ } | undefined>;
133
+ /**
134
+ * Change a subscription
135
+ * @description Closes a running subscription and starts a new one according to the specification. Can be used for upgrades, downgrades, and plan changes.
136
+ * @param id - The subscription ID
137
+ * @param body - The subscription to change
138
+ * @param signal - An optional abort signal
139
+ * @returns The changed subscription
140
+ */
141
+ change(id: operations['changeSubscription']['parameters']['path']['subscriptionId'], body: SubscriptionChange, options?: RequestOptions): Promise<{
142
+ current: import("./schemas.js").components["schemas"]["Subscription"];
143
+ next: import("./schemas.js").components["schemas"]["SubscriptionExpanded"];
144
+ } | undefined>;
145
+ /**
146
+ * Migrate a subscription
147
+ * @description Migrates the subscripiton to the provided version of the current plan.
148
+ * @param id - The subscription ID
149
+ * @param body - The subscription to migrate
150
+ * @param signal - An optional abort signal
151
+ * @returns The migrated subscription
152
+ */
153
+ migrate(id: operations['migrateSubscription']['parameters']['path']['subscriptionId'], body: operations['migrateSubscription']['requestBody']['content']['application/json'], options?: RequestOptions): Promise<{
154
+ current: import("./schemas.js").components["schemas"]["Subscription"];
155
+ next: import("./schemas.js").components["schemas"]["SubscriptionExpanded"];
156
+ } | undefined>;
157
+ /**
158
+ * Unschedule a cancelation
159
+ * @param id - The subscription ID
160
+ * @param signal - An optional abort signal
161
+ * @returns The unscheduled subscription
162
+ */
163
+ unscheduleCancelation(id: operations['unscheduleCancelation']['parameters']['path']['subscriptionId'], options?: RequestOptions): Promise<{
164
+ readonly id: string;
165
+ name: string;
166
+ description?: string;
167
+ metadata?: import("./schemas.js").components["schemas"]["Metadata"] | null;
168
+ readonly createdAt: Date;
169
+ readonly updatedAt: Date;
170
+ readonly deletedAt?: Date;
171
+ activeFrom: Date;
172
+ activeTo?: Date;
173
+ readonly annotations?: import("./schemas.js").components["schemas"]["Annotations"];
174
+ alignment?: import("./schemas.js").components["schemas"]["Alignment"];
175
+ readonly status: import("./schemas.js").components["schemas"]["SubscriptionStatus"];
176
+ customerId: string;
177
+ plan?: import("./schemas.js").components["schemas"]["PlanReference"];
178
+ currency: import("./schemas.js").components["schemas"]["CurrencyCode"];
179
+ readonly costBasisMode: import("./schemas.js").components["schemas"]["SubscriptionCostBasisMode"];
180
+ readonly costBasisPins: import("./schemas.js").components["schemas"]["SubscriptionCostBasisPin"][];
181
+ readonly billingCadence: string;
182
+ readonly proRatingConfig?: import("./schemas.js").components["schemas"]["ProRatingConfig"];
183
+ readonly billingAnchor: Date;
184
+ readonly billingStartsAt?: Date;
185
+ readonly settlementMode: import("./schemas.js").components["schemas"]["BillingSettlementMode"];
186
+ } | undefined>;
187
+ /**
188
+ * Delete subscription
189
+ * @description Deletes a subscription. Only scheduled subscriptions can be deleted.
190
+ * @param subscriptionId - The ID of the subscription to delete
191
+ * @param options - Optional request options
192
+ * @returns void or standard error response structure
193
+ */
194
+ delete(subscriptionId: operations['deleteSubscription']['parameters']['path']['subscriptionId'], options?: RequestOptions): Promise<undefined>;
195
+ }