cliodot 1.2.3 → 1.2.4

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 (135) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +2 -0
  3. package/dist/AuthAppClient.d.ts +1 -0
  4. package/dist/AuthAppClient.d.ts.map +1 -1
  5. package/dist/AuthAppClient.js +199 -1
  6. package/dist/CommercialAppClient.d.ts +50 -9
  7. package/dist/CommercialAppClient.d.ts.map +1 -1
  8. package/dist/CommercialAppClient.js +576 -1
  9. package/dist/ConnectorBuilder.js +104 -1
  10. package/dist/Events.d.ts +2 -0
  11. package/dist/Events.d.ts.map +1 -1
  12. package/dist/Events.js +325 -1
  13. package/dist/Flosync.js +296 -1
  14. package/dist/FlosyncClient.js +429 -1
  15. package/dist/FunctionBuilder.js +65 -1
  16. package/dist/IdentityAppClient.d.ts +1 -0
  17. package/dist/IdentityAppClient.d.ts.map +1 -1
  18. package/dist/IdentityAppClient.js +197 -1
  19. package/dist/MemoryAppClient.d.ts +1 -0
  20. package/dist/MemoryAppClient.d.ts.map +1 -1
  21. package/dist/MemoryAppClient.js +149 -1
  22. package/dist/MemoryClient.js +20 -1
  23. package/dist/OAuthAppClient.d.ts +1 -0
  24. package/dist/OAuthAppClient.d.ts.map +1 -1
  25. package/dist/OAuthAppClient.js +269 -1
  26. package/dist/ProviderServicesClient.d.ts +24 -0
  27. package/dist/ProviderServicesClient.d.ts.map +1 -0
  28. package/dist/ProviderServicesClient.js +158 -0
  29. package/dist/Surface.d.ts +2 -0
  30. package/dist/Surface.d.ts.map +1 -1
  31. package/dist/Surface.js +255 -1
  32. package/dist/ValidatorBuilder.js +24 -1
  33. package/dist/Webhooks.js +61 -1
  34. package/dist/WorkflowBuilder.js +279 -1
  35. package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
  36. package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
  37. package/dist/__tests__/CommercialAppClient.test.js +217 -0
  38. package/dist/__tests__/Events.test.js +191 -1
  39. package/dist/__tests__/IdentityAppClient.test.js +232 -1
  40. package/dist/__tests__/OAuthAppClient.test.js +300 -1
  41. package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
  42. package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
  43. package/dist/__tests__/ProviderServicesClient.test.js +131 -0
  44. package/dist/__tests__/Surface.test.js +150 -1
  45. package/dist/__tests__/errors.test.js +54 -1
  46. package/dist/__tests__/function.test.js +58 -1
  47. package/dist/__tests__/helpers.d.ts +5 -0
  48. package/dist/__tests__/helpers.d.ts.map +1 -0
  49. package/dist/__tests__/helpers.js +10 -0
  50. package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
  51. package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
  52. package/dist/__tests__/localhost-lookup.test.js +26 -0
  53. package/dist/__tests__/parse-api-error.test.js +26 -1
  54. package/dist/__tests__/runner.test.js +156 -1
  55. package/dist/connectors/builtin.js +354 -1
  56. package/dist/connectors/registry.js +300 -1
  57. package/dist/decorators/build.js +105 -1
  58. package/dist/decorators/connector.js +56 -1
  59. package/dist/decorators/index.js +34 -1
  60. package/dist/decorators/metadata.js +338 -1
  61. package/dist/decorators/steps.js +220 -1
  62. package/dist/decorators/workflow.js +52 -1
  63. package/dist/errors.js +76 -1
  64. package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
  65. package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
  66. package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
  67. package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
  68. package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
  69. package/dist/http/__tests__/cliodot-result.test.js +57 -0
  70. package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
  71. package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
  72. package/dist/http/__tests__/events-instance-id.test.js +45 -0
  73. package/dist/http/cliodot-request.d.ts +35 -0
  74. package/dist/http/cliodot-request.d.ts.map +1 -0
  75. package/dist/http/cliodot-request.js +105 -0
  76. package/dist/http/cliodot-result.d.ts +40 -0
  77. package/dist/http/cliodot-result.d.ts.map +1 -0
  78. package/dist/http/cliodot-result.js +139 -0
  79. package/dist/http/create-client.d.ts +3 -0
  80. package/dist/http/create-client.d.ts.map +1 -0
  81. package/dist/http/create-client.js +14 -0
  82. package/dist/http/events-instance-id.d.ts +11 -0
  83. package/dist/http/events-instance-id.d.ts.map +1 -0
  84. package/dist/http/events-instance-id.js +86 -0
  85. package/dist/http/localhost-lookup.d.ts +12 -0
  86. package/dist/http/localhost-lookup.d.ts.map +1 -0
  87. package/dist/http/localhost-lookup.js +67 -0
  88. package/dist/http/parse-api-error.js +56 -1
  89. package/dist/http/sanitize-execution-headers.js +79 -1
  90. package/dist/identity-offline-verify.js +174 -1
  91. package/dist/identity-token-cache.js +51 -1
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +108 -1
  95. package/dist/runner/ProcessorEngine.js +1311 -1
  96. package/dist/runner/connector.executor.js +1786 -1
  97. package/dist/runner/utilities/math.executor.js +153 -1
  98. package/dist/runner/utilities/random.executor.js +151 -1
  99. package/dist/runner/utilities/string.executor.js +825 -1
  100. package/dist/template.js +127 -1
  101. package/dist/transformers/StepsToNodesTransformer.js +214 -1
  102. package/dist/transformers/WorkflowTransformer.js +189 -1
  103. package/dist/types/auth-app.api.d.ts +2 -0
  104. package/dist/types/auth-app.api.d.ts.map +1 -1
  105. package/dist/types/auth-app.api.js +2 -1
  106. package/dist/types/builtin.js +2 -1
  107. package/dist/types/client.api.js +2 -1
  108. package/dist/types/commercial-app.api.d.ts +407 -11
  109. package/dist/types/commercial-app.api.d.ts.map +1 -1
  110. package/dist/types/commercial-app.api.js +2 -1
  111. package/dist/types/connector.js +2 -1
  112. package/dist/types/context.js +2 -1
  113. package/dist/types/event-app.api.d.ts +8 -0
  114. package/dist/types/event-app.api.d.ts.map +1 -1
  115. package/dist/types/event-app.api.js +2 -1
  116. package/dist/types/function.js +2 -1
  117. package/dist/types/identity-app.api.d.ts +2 -0
  118. package/dist/types/identity-app.api.d.ts.map +1 -1
  119. package/dist/types/identity-app.api.js +2 -1
  120. package/dist/types/index.js +23 -1
  121. package/dist/types/memory-app.api.d.ts +2 -0
  122. package/dist/types/memory-app.api.d.ts.map +1 -1
  123. package/dist/types/memory-app.api.js +2 -1
  124. package/dist/types/oauth-app.api.d.ts +2 -0
  125. package/dist/types/oauth-app.api.d.ts.map +1 -1
  126. package/dist/types/oauth-app.api.js +105 -1
  127. package/dist/types/provider-services.api.d.ts +98 -0
  128. package/dist/types/provider-services.api.d.ts.map +1 -0
  129. package/dist/types/provider-services.api.js +2 -0
  130. package/dist/types/validator.js +2 -1
  131. package/dist/types/webhook-app.api.js +2 -1
  132. package/dist/types/workflow.js +33 -1
  133. package/dist/validators/validators.js +478 -1
  134. package/dist/variable.js +37 -1
  135. package/package.json +3 -2
@@ -1 +1,2 @@
1
- 'use strict';var _0x3c694a=_0x2546;function _0x5141(){var _0x4443f0=['mtKXndaWogjyEu1dBa','mte0vNL5zLDm','n0rqwuTVDW','mta3ntCWBeLPDgDJ','ndvgsNPfq3a','mJu4nti4mff2sgTHqG','mJeZmty0v0rUwLLz','zgvMAw5LuhjVCgvYDhK','nJq5uhL5rhD4','mJy1nJq4mKXMBeL2va','mtmZmdeWvfzusgTj','mZvSweXwyLK','mtq0ntu3uvbtEvzM'];_0x5141=function(){return _0x4443f0;};return _0x5141();}(function(_0x18b6c5,_0x1d2d7a){var _0x1b976d=_0x2546,_0x2b8646=_0x18b6c5();while(!![]){try{var _0x457444=parseInt(_0x1b976d(0xf7))/0x1*(-parseInt(_0x1b976d(0xf8))/0x2)+parseInt(_0x1b976d(0xf1))/0x3+parseInt(_0x1b976d(0xee))/0x4*(parseInt(_0x1b976d(0xf3))/0x5)+-parseInt(_0x1b976d(0xf6))/0x6*(-parseInt(_0x1b976d(0xf4))/0x7)+parseInt(_0x1b976d(0xf5))/0x8*(-parseInt(_0x1b976d(0xec))/0x9)+-parseInt(_0x1b976d(0xf2))/0xa*(-parseInt(_0x1b976d(0xf0))/0xb)+-parseInt(_0x1b976d(0xed))/0xc;if(_0x457444===_0x1d2d7a)break;else _0x2b8646['push'](_0x2b8646['shift']());}catch(_0x461f33){_0x2b8646['push'](_0x2b8646['shift']());}}}(_0x5141,0x9e12d));function _0x2546(_0x995f7,_0x346457){_0x995f7=_0x995f7-0xec;var _0x514198=_0x5141();var _0x25464b=_0x514198[_0x995f7];if(_0x2546['uZunBI']===undefined){var _0x4cc395=function(_0x50d215){var _0x366cb4='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x3a03fd='',_0x21d37c='';for(var _0x504ab9=0x0,_0x3d6c6c,_0x3e22a2,_0x3a49cd=0x0;_0x3e22a2=_0x50d215['charAt'](_0x3a49cd++);~_0x3e22a2&&(_0x3d6c6c=_0x504ab9%0x4?_0x3d6c6c*0x40+_0x3e22a2:_0x3e22a2,_0x504ab9++%0x4)?_0x3a03fd+=String['fromCharCode'](0xff&_0x3d6c6c>>(-0x2*_0x504ab9&0x6)):0x0){_0x3e22a2=_0x366cb4['indexOf'](_0x3e22a2);}for(var _0x4c9538=0x0,_0x388067=_0x3a03fd['length'];_0x4c9538<_0x388067;_0x4c9538++){_0x21d37c+='%'+('00'+_0x3a03fd['charCodeAt'](_0x4c9538)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x21d37c);};_0x2546['WDmPnO']=_0x4cc395,_0x2546['ZafyHk']={},_0x2546['uZunBI']=!![];}var _0x4936f3=_0x514198[0x0],_0x3b9911=_0x995f7+_0x4936f3,_0x16ae09=_0x2546['ZafyHk'][_0x3b9911];return!_0x16ae09?(_0x25464b=_0x2546['WDmPnO'](_0x25464b),_0x2546['ZafyHk'][_0x3b9911]=_0x25464b):_0x25464b=_0x16ae09,_0x25464b;}Object[_0x3c694a(0xef)](exports,'__esModule',{'value':!![]});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- 'use strict';var _0x37167=_0x1355;function _0x3e17(){var _0x3a9050=['mJi5ntyWnxrlsunACq','ntm4nZaZne90AMHsza','mJeWodm1vuTnyM5T','ntm5nMv1whjXra','x19LC01VzhvSzq','otqWndiYn1jprez2Ca','zgvMAw5LuhjVCgvYDhK','mJaXoxn4tg9Vuq','mJi1mJmWnMnTAhf2BW','mte1ntKYoefQu3rPvG'];_0x3e17=function(){return _0x3a9050;};return _0x3e17();}function _0x1355(_0x1701cb,_0x18ab24){_0x1701cb=_0x1701cb-0x6b;var _0x3e1761=_0x3e17();var _0x1355da=_0x3e1761[_0x1701cb];if(_0x1355['RfqBiX']===undefined){var _0x3645dc=function(_0x4f5147){var _0x39c409='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x452d4a='',_0x365d73='';for(var _0xc06bb1=0x0,_0x4c703e,_0x3e3a43,_0x1341a2=0x0;_0x3e3a43=_0x4f5147['charAt'](_0x1341a2++);~_0x3e3a43&&(_0x4c703e=_0xc06bb1%0x4?_0x4c703e*0x40+_0x3e3a43:_0x3e3a43,_0xc06bb1++%0x4)?_0x452d4a+=String['fromCharCode'](0xff&_0x4c703e>>(-0x2*_0xc06bb1&0x6)):0x0){_0x3e3a43=_0x39c409['indexOf'](_0x3e3a43);}for(var _0x5a3b73=0x0,_0x25e6c0=_0x452d4a['length'];_0x5a3b73<_0x25e6c0;_0x5a3b73++){_0x365d73+='%'+('00'+_0x452d4a['charCodeAt'](_0x5a3b73)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x365d73);};_0x1355['eoFDnx']=_0x3645dc,_0x1355['BQtZTr']={},_0x1355['RfqBiX']=!![];}var _0x35655d=_0x3e1761[0x0],_0x299004=_0x1701cb+_0x35655d,_0x5f1bcf=_0x1355['BQtZTr'][_0x299004];return!_0x5f1bcf?(_0x1355da=_0x1355['eoFDnx'](_0x1355da),_0x1355['BQtZTr'][_0x299004]=_0x1355da):_0x1355da=_0x5f1bcf,_0x1355da;}(function(_0x2e395d,_0x484e8d){var _0x3c8b4=_0x1355,_0x3acc5b=_0x2e395d();while(!![]){try{var _0x459d34=parseInt(_0x3c8b4(0x73))/0x1+-parseInt(_0x3c8b4(0x6f))/0x2+parseInt(_0x3c8b4(0x6e))/0x3*(parseInt(_0x3c8b4(0x74))/0x4)+parseInt(_0x3c8b4(0x71))/0x5+-parseInt(_0x3c8b4(0x72))/0x6+parseInt(_0x3c8b4(0x6c))/0x7+-parseInt(_0x3c8b4(0x70))/0x8;if(_0x459d34===_0x484e8d)break;else _0x3acc5b['push'](_0x3acc5b['shift']());}catch(_0x428f88){_0x3acc5b['push'](_0x3acc5b['shift']());}}}(_0x3e17,0xb7cab));Object[_0x37167(0x6d)](exports,_0x37167(0x6b),{'value':!![]});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,6 +5,8 @@ export type CommercialAppClientConfig = {
5
5
  appApiKey?: string;
6
6
  appSecret?: string;
7
7
  debug?: boolean;
8
+ /** Pin project env bag for connector auth templates. Omit to follow the project switch. */
9
+ environment?: "dev" | "prod" | "development" | "production";
8
10
  };
9
11
  export type CommercialPaginationMeta = {
10
12
  totalDocs: number;
@@ -39,6 +41,10 @@ export type CommercialCustomer = {
39
41
  line1?: string;
40
42
  postal_code?: string;
41
43
  };
44
+ credit_balances?: Array<{
45
+ currency: string;
46
+ amount: number;
47
+ }>;
42
48
  metadata?: Record<string, unknown>;
43
49
  createdAt?: string | Date;
44
50
  updatedAt?: string | Date;
@@ -76,6 +82,11 @@ export type CommercialPlanEntitlement = {
76
82
  feature_key: string;
77
83
  enabled: boolean;
78
84
  limit: number | null;
85
+ unit_prices?: CommercialPrice[];
86
+ topup_packs?: Array<{
87
+ units: number;
88
+ prices: CommercialPrice[];
89
+ }>;
79
90
  };
80
91
  export type CommercialPrice = {
81
92
  currency: string;
@@ -100,6 +111,10 @@ export type CommercialPlan = {
100
111
  entitlements: CommercialPlanEntitlement[];
101
112
  trial_days?: number;
102
113
  allowed_addon_keys?: string[];
114
+ billing_mode?: "recurring" | "payg" | "hybrid" | string;
115
+ payg_overage_policy?: "deny" | "accrue" | "immediate_topup" | "accrue_and_topup" | string;
116
+ payg_charge_threshold_amount?: number;
117
+ payg_hard_cap_amount?: number;
103
118
  metadata?: Record<string, unknown>;
104
119
  };
105
120
  export type CommercialSubscription = {
@@ -130,6 +145,47 @@ export type CommercialSubscription = {
130
145
  }>;
131
146
  seats_purchased?: number;
132
147
  price_metadata?: Record<string, unknown>;
148
+ pricing?: {
149
+ currency: string;
150
+ plan_amount: number;
151
+ addon_total: number;
152
+ seat_total: number;
153
+ subtotal: number;
154
+ discount_total: number;
155
+ tax_total: number;
156
+ total: number;
157
+ line_items: Array<{
158
+ kind: string;
159
+ description: string;
160
+ quantity: number;
161
+ unit_amount: number;
162
+ amount: number;
163
+ currency: string;
164
+ metadata?: Record<string, unknown>;
165
+ }>;
166
+ };
167
+ auto_renew?: boolean;
168
+ renewal_mode?: "platform" | "provider";
169
+ skip_trial?: boolean;
170
+ usage_rollover?: "none" | "carry_unused";
171
+ pending_plan_change?: Record<string, unknown> | null;
172
+ usage_rollover_credits?: Record<string, number>;
173
+ billing_mode?: "recurring" | "payg" | "hybrid" | string;
174
+ payg_overage_policy?: "deny" | "accrue" | "immediate_topup" | "accrue_and_topup" | string;
175
+ payg_charge_threshold_amount?: number;
176
+ payg_hard_cap_amount?: number;
177
+ unbilled_usage?: {
178
+ currency: string;
179
+ amount: number;
180
+ units_by_feature?: Record<string, number>;
181
+ amounts_by_feature?: Record<string, number>;
182
+ since?: string | Date;
183
+ };
184
+ payg_charge_status?: "idle" | "processing" | "failed" | string;
185
+ payg_pack_credits?: Record<string, number>;
186
+ pending_topup_invoice_id?: string;
187
+ payment_method_key?: string;
188
+ payment_card_id?: string;
133
189
  trial_starts_at?: string | Date | null;
134
190
  trial_ends_at?: string | Date | null;
135
191
  starts_at?: string | Date | null;
@@ -176,6 +232,40 @@ export type CommercialCheckResult = {
176
232
  assigned: number;
177
233
  available: number;
178
234
  };
235
+ topup_packs?: Array<{
236
+ units: number;
237
+ prices: CommercialPrice[];
238
+ }>;
239
+ pending_topup_invoice_id?: string;
240
+ unbilled?: {
241
+ currency: string;
242
+ amount: number;
243
+ units_by_feature?: Record<string, number>;
244
+ amounts_by_feature?: Record<string, number>;
245
+ };
246
+ payg?: {
247
+ billing_mode: string;
248
+ overage_policy: string;
249
+ charge_status: string;
250
+ };
251
+ breakdown?: CommercialConsumeBreakdown;
252
+ };
253
+ export type CommercialConsumeBreakdown = {
254
+ feature_key: string;
255
+ quantity: number;
256
+ currency?: string;
257
+ unit_amount?: number | null;
258
+ cost: number;
259
+ plan_quantity: number;
260
+ pack_quantity: number;
261
+ overage_quantity: number;
262
+ credited_amount: number;
263
+ accrued_amount: number;
264
+ credited_quantity?: number;
265
+ accrued_quantity?: number;
266
+ unbilled_after?: number;
267
+ credit_balance_after?: number;
268
+ summary: string;
179
269
  };
180
270
  export type CommercialConsumeInput = CommercialCheckInput;
181
271
  export type CommercialConsumeResult = CommercialCheckResult & {
@@ -212,8 +302,8 @@ export type CommercialStateResult = {
212
302
  assigned: number;
213
303
  available: number;
214
304
  };
215
- invoices?: unknown[];
216
- payments?: unknown[];
305
+ invoices?: CommercialInvoice[];
306
+ payments?: Array<Record<string, unknown>>;
217
307
  };
218
308
  export type CommercialListCustomersResponse = {
219
309
  ok: true;
@@ -242,6 +332,15 @@ export type CommercialListSubscriptionsResponse = {
242
332
  subscriptions: CommercialSubscription[];
243
333
  pagination: CommercialPaginationMeta;
244
334
  };
335
+ export type CommercialInvoiceLineItem = {
336
+ kind: string;
337
+ description: string;
338
+ quantity: number;
339
+ unit_amount: number;
340
+ amount: number;
341
+ currency: string;
342
+ metadata?: Record<string, unknown>;
343
+ };
245
344
  export type CommercialInvoice = {
246
345
  _id: string;
247
346
  tenant_id: string;
@@ -259,7 +358,7 @@ export type CommercialInvoice = {
259
358
  status: string;
260
359
  currency: string;
261
360
  amount: number;
262
- line_items?: Array<Record<string, unknown>>;
361
+ line_items?: CommercialInvoiceLineItem[];
263
362
  subtotal?: number;
264
363
  discount_total?: number;
265
364
  tax_total?: number;
@@ -334,7 +433,13 @@ export type CommercialCreateSubscriptionInput = {
334
433
  seats_purchased?: number;
335
434
  metadata?: Record<string, unknown>;
336
435
  payment_method?: string;
436
+ card?: string;
437
+ card_id?: string;
337
438
  payment_input?: Record<string, unknown>;
439
+ auto_renew?: boolean;
440
+ renewal_mode?: "platform" | "provider";
441
+ skip_trial?: boolean;
442
+ usage_rollover?: "none" | "carry_unused";
338
443
  };
339
444
  export type CommercialChangePlanInput = {
340
445
  subscriptionId: string;
@@ -348,7 +453,33 @@ export type CommercialChangePlanInput = {
348
453
  }>;
349
454
  seats_purchased?: number;
350
455
  payment_method?: string;
456
+ card?: string;
457
+ card_id?: string;
351
458
  payment_input?: Record<string, unknown>;
459
+ auto_renew?: boolean;
460
+ renewal_mode?: "platform" | "provider";
461
+ apply_at?: "immediate" | "next_renewal";
462
+ usage_rollover?: "none" | "carry_unused";
463
+ };
464
+ export type CommercialUpdatePendingSubscriptionInput = {
465
+ subscriptionId: string;
466
+ plan?: string;
467
+ currency?: string;
468
+ discount_code?: string;
469
+ tax_rate?: string;
470
+ addons?: Array<{
471
+ key: string;
472
+ quantity: number;
473
+ }>;
474
+ seats_purchased?: number;
475
+ payment_method?: string;
476
+ card?: string;
477
+ card_id?: string;
478
+ payment_input?: Record<string, unknown>;
479
+ auto_renew?: boolean;
480
+ renewal_mode?: "platform" | "provider";
481
+ skip_trial?: boolean;
482
+ metadata?: Record<string, unknown>;
352
483
  };
353
484
  export type CommercialPaymentMethodSummary = {
354
485
  key: string;
@@ -363,6 +494,8 @@ export type CommercialInitiatePaymentInput = {
363
494
  subscription?: string;
364
495
  invoice?: string;
365
496
  payment_method?: string;
497
+ card?: string;
498
+ card_id?: string;
366
499
  input?: Record<string, unknown>;
367
500
  currency?: string;
368
501
  discount_code?: string;
@@ -376,8 +509,211 @@ export type CommercialInitiatePaymentResult = {
376
509
  currency: string;
377
510
  amount: number;
378
511
  total?: number;
512
+ metadata?: Record<string, unknown>;
379
513
  };
380
514
  charge: unknown;
515
+ error?: string;
516
+ failure_reason?: string;
517
+ };
518
+ export type CommercialChargeUsageInput = {
519
+ subscriptionId: string;
520
+ amount?: number;
521
+ payment_method?: string;
522
+ card?: string;
523
+ card_id?: string;
524
+ payment_input?: Record<string, unknown>;
525
+ };
526
+ export type CommercialChargeUsageResult = CommercialInitiatePaymentResult & {
527
+ billed_amount: number;
528
+ unbilled_remaining: number;
529
+ };
530
+ export type CommercialRenewSubscriptionInput = {
531
+ subscriptionId: string;
532
+ payment_method?: string;
533
+ };
534
+ export type CommercialRenewSubscriptionResult = {
535
+ ok: true;
536
+ invoice: CommercialInvoice;
537
+ subscription: CommercialSubscription;
538
+ created: boolean;
539
+ };
540
+ export type CommercialCreditBalance = {
541
+ currency: string;
542
+ amount: number;
543
+ };
544
+ export type CommercialCreditLedgerEvent = {
545
+ _id: string;
546
+ tenant_id: string;
547
+ app_id: string;
548
+ customer_id: string;
549
+ currency: string;
550
+ delta: number;
551
+ balance_after: number;
552
+ reason: string;
553
+ invoice_id?: string;
554
+ subscription_id?: string;
555
+ feature_key?: string;
556
+ quantity?: number;
557
+ unit_amount?: number;
558
+ cost?: number;
559
+ plan_quantity?: number;
560
+ pack_quantity?: number;
561
+ overage_quantity?: number;
562
+ credited_amount?: number;
563
+ accrued_amount?: number;
564
+ summary?: string;
565
+ at: string | Date;
566
+ createdAt?: string | Date;
567
+ };
568
+ export type CommercialListCreditsParams = CommercialListParams;
569
+ export type CommercialListCreditsResponse = {
570
+ ok: true;
571
+ credit_balances: CommercialCreditBalance[];
572
+ events: CommercialCreditLedgerEvent[];
573
+ pagination: Pick<CommercialPaginationMeta, "totalDocs" | "page" | "limit"> & Partial<CommercialPaginationMeta>;
574
+ };
575
+ export type CommercialCustomerCard = {
576
+ _id: string;
577
+ tenant_id: string;
578
+ app_id: string;
579
+ customer_id: string;
580
+ token?: string;
581
+ fingerprint?: string;
582
+ last4?: string;
583
+ brand?: string;
584
+ exp_month?: number;
585
+ exp_year?: number;
586
+ payment_method_key?: string;
587
+ provider_customer_id?: string;
588
+ is_default: boolean;
589
+ status: "active" | "expired" | "revoked" | string;
590
+ metadata?: Record<string, unknown>;
591
+ createdAt?: string | Date;
592
+ updatedAt?: string | Date;
593
+ };
594
+ export type CommercialAddCardInput = {
595
+ token?: string;
596
+ authorization_code?: string;
597
+ fingerprint?: string;
598
+ hash?: string;
599
+ last4?: string;
600
+ brand?: string;
601
+ exp_month?: number;
602
+ exp_year?: number;
603
+ payment_method_key?: string;
604
+ provider_customer_id?: string;
605
+ is_default?: boolean;
606
+ metadata?: Record<string, unknown>;
607
+ };
608
+ export type CommercialListCardsParams = CommercialListParams & {
609
+ include_revoked?: boolean;
610
+ };
611
+ export type CommercialListCardsResponse = {
612
+ ok: true;
613
+ cards: CommercialCustomerCard[];
614
+ pagination: CommercialPaginationMeta;
615
+ };
616
+ export type CommercialLifecycleEvent = {
617
+ _id: string;
618
+ tenant_id: string;
619
+ app_id: string;
620
+ customer_id?: string;
621
+ subscription_id?: string;
622
+ type: string;
623
+ at: string | Date;
624
+ actor?: string;
625
+ actor_id?: string;
626
+ payload?: Record<string, unknown>;
627
+ createdAt?: string | Date;
628
+ };
629
+ export type CommercialUsageEvent = {
630
+ _id: string;
631
+ tenant_id: string;
632
+ app_id: string;
633
+ customer_id: string;
634
+ subscription_id?: string;
635
+ feature_key: string;
636
+ quantity: number;
637
+ period_key: string;
638
+ at: string | Date;
639
+ allowed: boolean;
640
+ remaining?: number | null;
641
+ reason?: string;
642
+ currency?: string;
643
+ unit_amount?: number | null;
644
+ cost?: number;
645
+ plan_quantity?: number;
646
+ pack_quantity?: number;
647
+ overage_quantity?: number;
648
+ credited_amount?: number;
649
+ accrued_amount?: number;
650
+ credited_quantity?: number;
651
+ accrued_quantity?: number;
652
+ unbilled_after?: number;
653
+ credit_balance_after?: number;
654
+ summary?: string;
655
+ createdAt?: string | Date;
656
+ };
657
+ export type CommercialListEventsParams = CommercialListParams & {
658
+ type?: string;
659
+ feature?: string;
660
+ };
661
+ export type CommercialListEventsResponse = {
662
+ ok: true;
663
+ events: CommercialLifecycleEvent[];
664
+ pagination: CommercialPaginationMeta;
665
+ };
666
+ export type CommercialListUsageEventsResponse = {
667
+ ok: true;
668
+ events: CommercialUsageEvent[];
669
+ pagination: CommercialPaginationMeta;
670
+ };
671
+ export type CommercialDiscount = {
672
+ _id: string;
673
+ key?: string;
674
+ code?: string;
675
+ name?: string;
676
+ type?: string;
677
+ percent?: number;
678
+ amount?: number;
679
+ currency?: string;
680
+ duration?: string;
681
+ metadata?: Record<string, unknown>;
682
+ };
683
+ export type CommercialTaxRate = {
684
+ _id: string;
685
+ key?: string;
686
+ name?: string;
687
+ percent?: number;
688
+ inclusive?: boolean;
689
+ country?: string;
690
+ metadata?: Record<string, unknown>;
691
+ };
692
+ export type CommercialAddon = {
693
+ _id: string;
694
+ key: string;
695
+ name: string;
696
+ kind?: string;
697
+ prices?: CommercialPrice[];
698
+ metadata?: Record<string, unknown>;
699
+ };
700
+ export type CommercialSeatAssignment = {
701
+ _id: string;
702
+ customer_id: string;
703
+ subscription_id?: string;
704
+ subject_key: string;
705
+ email?: string;
706
+ metadata?: Record<string, unknown>;
707
+ assigned_at?: string | Date;
708
+ };
709
+ export type CommercialLicense = {
710
+ _id: string;
711
+ customer_id: string;
712
+ license_key_prefix?: string;
713
+ status: string;
714
+ plan_key?: string;
715
+ expires_at?: string | Date | null;
716
+ metadata?: Record<string, unknown>;
381
717
  };
382
718
  export type CommercialConfirmPaymentInput = {
383
719
  reference: string;
@@ -412,6 +748,25 @@ export type CommercialSeatAssignInput = {
412
748
  email?: string;
413
749
  metadata?: Record<string, unknown>;
414
750
  };
751
+ export type CommercialEntitlementTopupInput = {
752
+ subscriptionId: string;
753
+ feature: string;
754
+ pack_units?: number;
755
+ pack_index?: number;
756
+ payment_method?: string;
757
+ card?: string;
758
+ card_id?: string;
759
+ payment_input?: Record<string, unknown>;
760
+ };
761
+ export type CommercialCreditsTopupInput = {
762
+ customerId: string;
763
+ currency: string;
764
+ amount: number;
765
+ payment_method?: string;
766
+ card?: string;
767
+ card_id?: string;
768
+ payment_input?: Record<string, unknown>;
769
+ };
415
770
  export type CommercialLicenseIssueInput = {
416
771
  customer: string;
417
772
  expires_at?: string;
@@ -454,6 +809,34 @@ export type CommercialAppClientApi = {
454
809
  ok: true;
455
810
  customer: CommercialCustomer;
456
811
  }>;
812
+ listCredits(customerId: string, params?: CommercialListCreditsParams): Promise<CommercialListCreditsResponse>;
813
+ topupCredits(input: CommercialCreditsTopupInput): Promise<{
814
+ ok: true;
815
+ invoice: CommercialInvoice;
816
+ }>;
817
+ listCards(customerId: string, params?: CommercialListCardsParams): Promise<CommercialListCardsResponse>;
818
+ addCard(customerId: string, input: CommercialAddCardInput): Promise<{
819
+ ok: true;
820
+ card: CommercialCustomerCard;
821
+ }>;
822
+ updateCard(customerId: string, cardId: string, input: CommercialAddCardInput): Promise<{
823
+ ok: true;
824
+ card: CommercialCustomerCard;
825
+ }>;
826
+ removeCard(customerId: string, cardId: string): Promise<{
827
+ ok: true;
828
+ card: CommercialCustomerCard;
829
+ }>;
830
+ setDefaultCard(customerId: string, cardId: string): Promise<{
831
+ ok: true;
832
+ card: CommercialCustomerCard;
833
+ }>;
834
+ listEvents(customerId: string, params?: CommercialListEventsParams): Promise<CommercialListEventsResponse>;
835
+ listUsageEvents(customerId: string, params?: CommercialListEventsParams): Promise<CommercialListUsageEventsResponse>;
836
+ listEventTypes(): Promise<{
837
+ ok: true;
838
+ event_types: string[];
839
+ }>;
457
840
  listFeatures(params?: CommercialListParams): Promise<CommercialListFeaturesResponse>;
458
841
  getFeature(featureId: string): Promise<{
459
842
  ok: true;
@@ -487,10 +870,22 @@ export type CommercialAppClientApi = {
487
870
  ok: true;
488
871
  subscription: CommercialSubscription;
489
872
  }>;
873
+ updatePendingSubscription(input: CommercialUpdatePendingSubscriptionInput): Promise<{
874
+ ok: true;
875
+ subscription: CommercialSubscription;
876
+ }>;
490
877
  changePlan(input: CommercialChangePlanInput): Promise<{
491
878
  ok: true;
492
879
  subscription: CommercialSubscription;
493
880
  }>;
881
+ entitlementTopup(input: CommercialEntitlementTopupInput): Promise<{
882
+ ok: true;
883
+ invoice: CommercialInvoice;
884
+ subscription: CommercialSubscription;
885
+ }>;
886
+ chargeUsage(input: CommercialChargeUsageInput): Promise<CommercialChargeUsageResult>;
887
+ renewSubscription(input: CommercialRenewSubscriptionInput): Promise<CommercialRenewSubscriptionResult>;
888
+ renew(input: CommercialRenewSubscriptionInput): Promise<CommercialRenewSubscriptionResult>;
494
889
  updateSubscriptionStatus(input: CommercialUpdateSubscriptionStatusInput): Promise<{
495
890
  ok: true;
496
891
  subscription: CommercialSubscription;
@@ -516,44 +911,45 @@ export type CommercialAppClientApi = {
516
911
  customer?: string;
517
912
  }): Promise<{
518
913
  ok: true;
519
- discount: unknown;
520
- quote: unknown;
914
+ discount: CommercialDiscount;
915
+ quote: CommercialPricingQuote;
521
916
  }>;
522
917
  listDiscounts(params?: CommercialListParams): Promise<{
523
918
  ok: true;
524
- discounts: unknown[];
919
+ discounts: CommercialDiscount[];
525
920
  pagination: CommercialPaginationMeta;
526
921
  }>;
527
922
  listTaxRates(params?: CommercialListParams): Promise<{
528
923
  ok: true;
529
- tax_rates: unknown[];
924
+ tax_rates: CommercialTaxRate[];
530
925
  pagination: CommercialPaginationMeta;
531
926
  }>;
532
927
  listAddons(params?: CommercialListParams): Promise<{
533
928
  ok: true;
534
- addons: unknown[];
929
+ addons: CommercialAddon[];
535
930
  pagination: CommercialPaginationMeta;
536
931
  }>;
537
932
  assignSeat(input: CommercialSeatAssignInput): Promise<{
538
933
  ok: true;
539
- assignment: unknown;
934
+ assignment: CommercialSeatAssignment;
540
935
  }>;
541
936
  unassignSeat(input: CommercialSeatAssignInput): Promise<{
542
937
  ok: boolean;
543
938
  }>;
544
939
  issueLicense(input: CommercialLicenseIssueInput): Promise<{
545
940
  ok: true;
546
- license: unknown;
941
+ license: CommercialLicense;
547
942
  license_key: string;
548
943
  }>;
549
944
  validateLicense(input: CommercialLicenseValidateInput): Promise<{
550
945
  ok: true;
551
946
  valid: boolean;
947
+ license?: CommercialLicense;
552
948
  [key: string]: unknown;
553
949
  }>;
554
950
  revokeLicense(licenseId: string): Promise<{
555
951
  ok: true;
556
- license: unknown;
952
+ license: CommercialLicense;
557
953
  }>;
558
954
  analytics(params?: CommercialAnalyticsParams): Promise<{
559
955
  ok: true;