cliodot 1.2.2 → 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 (147) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +81 -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 +178 -0
  7. package/dist/CommercialAppClient.d.ts.map +1 -0
  8. package/dist/CommercialAppClient.js +576 -0
  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 +23 -0
  17. package/dist/IdentityAppClient.d.ts.map +1 -0
  18. package/dist/IdentityAppClient.js +197 -0
  19. package/dist/MemoryAppClient.d.ts +28 -0
  20. package/dist/MemoryAppClient.d.ts.map +1 -0
  21. package/dist/MemoryAppClient.js +149 -0
  22. package/dist/MemoryClient.d.ts +8 -0
  23. package/dist/MemoryClient.d.ts.map +1 -0
  24. package/dist/MemoryClient.js +20 -0
  25. package/dist/OAuthAppClient.d.ts +1 -0
  26. package/dist/OAuthAppClient.d.ts.map +1 -1
  27. package/dist/OAuthAppClient.js +269 -1
  28. package/dist/ProviderServicesClient.d.ts +24 -0
  29. package/dist/ProviderServicesClient.d.ts.map +1 -0
  30. package/dist/ProviderServicesClient.js +158 -0
  31. package/dist/Surface.d.ts +2 -0
  32. package/dist/Surface.d.ts.map +1 -1
  33. package/dist/Surface.js +255 -1
  34. package/dist/ValidatorBuilder.js +24 -1
  35. package/dist/Webhooks.d.ts +20 -0
  36. package/dist/Webhooks.d.ts.map +1 -0
  37. package/dist/Webhooks.js +61 -0
  38. package/dist/WorkflowBuilder.js +279 -1
  39. package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
  40. package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
  41. package/dist/__tests__/CommercialAppClient.test.js +217 -0
  42. package/dist/__tests__/Events.test.js +191 -1
  43. package/dist/__tests__/IdentityAppClient.test.d.ts +2 -0
  44. package/dist/__tests__/IdentityAppClient.test.d.ts.map +1 -0
  45. package/dist/__tests__/IdentityAppClient.test.js +232 -0
  46. package/dist/__tests__/OAuthAppClient.test.js +300 -1
  47. package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
  48. package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
  49. package/dist/__tests__/ProviderServicesClient.test.js +131 -0
  50. package/dist/__tests__/Surface.test.js +150 -1
  51. package/dist/__tests__/errors.test.js +54 -1
  52. package/dist/__tests__/function.test.js +58 -1
  53. package/dist/__tests__/helpers.d.ts +5 -0
  54. package/dist/__tests__/helpers.d.ts.map +1 -0
  55. package/dist/__tests__/helpers.js +10 -0
  56. package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
  57. package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
  58. package/dist/__tests__/localhost-lookup.test.js +26 -0
  59. package/dist/__tests__/parse-api-error.test.js +26 -1
  60. package/dist/__tests__/runner.test.js +156 -1
  61. package/dist/connectors/builtin.js +354 -1
  62. package/dist/connectors/registry.js +300 -1
  63. package/dist/decorators/build.js +105 -1
  64. package/dist/decorators/connector.js +56 -1
  65. package/dist/decorators/index.js +34 -1
  66. package/dist/decorators/metadata.js +338 -1
  67. package/dist/decorators/steps.js +220 -1
  68. package/dist/decorators/workflow.js +52 -1
  69. package/dist/errors.js +76 -1
  70. package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
  71. package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
  72. package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
  73. package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
  74. package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
  75. package/dist/http/__tests__/cliodot-result.test.js +57 -0
  76. package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
  77. package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
  78. package/dist/http/__tests__/events-instance-id.test.js +45 -0
  79. package/dist/http/cliodot-request.d.ts +35 -0
  80. package/dist/http/cliodot-request.d.ts.map +1 -0
  81. package/dist/http/cliodot-request.js +105 -0
  82. package/dist/http/cliodot-result.d.ts +40 -0
  83. package/dist/http/cliodot-result.d.ts.map +1 -0
  84. package/dist/http/cliodot-result.js +139 -0
  85. package/dist/http/create-client.d.ts +3 -0
  86. package/dist/http/create-client.d.ts.map +1 -0
  87. package/dist/http/create-client.js +14 -0
  88. package/dist/http/events-instance-id.d.ts +11 -0
  89. package/dist/http/events-instance-id.d.ts.map +1 -0
  90. package/dist/http/events-instance-id.js +86 -0
  91. package/dist/http/localhost-lookup.d.ts +12 -0
  92. package/dist/http/localhost-lookup.d.ts.map +1 -0
  93. package/dist/http/localhost-lookup.js +67 -0
  94. package/dist/http/parse-api-error.js +56 -1
  95. package/dist/http/sanitize-execution-headers.js +79 -1
  96. package/dist/identity-offline-verify.d.ts +6 -0
  97. package/dist/identity-offline-verify.d.ts.map +1 -0
  98. package/dist/identity-offline-verify.js +174 -0
  99. package/dist/identity-token-cache.d.ts +6 -0
  100. package/dist/identity-token-cache.d.ts.map +1 -0
  101. package/dist/identity-token-cache.js +51 -0
  102. package/dist/index.d.ts +10 -0
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +108 -1
  105. package/dist/runner/ProcessorEngine.js +1311 -1
  106. package/dist/runner/connector.executor.js +1786 -1
  107. package/dist/runner/utilities/math.executor.js +153 -1
  108. package/dist/runner/utilities/random.executor.js +151 -1
  109. package/dist/runner/utilities/string.executor.js +825 -1
  110. package/dist/template.js +127 -1
  111. package/dist/transformers/StepsToNodesTransformer.js +214 -1
  112. package/dist/transformers/WorkflowTransformer.js +189 -1
  113. package/dist/types/auth-app.api.d.ts +2 -0
  114. package/dist/types/auth-app.api.d.ts.map +1 -1
  115. package/dist/types/auth-app.api.js +2 -1
  116. package/dist/types/builtin.js +2 -1
  117. package/dist/types/client.api.js +2 -1
  118. package/dist/types/commercial-app.api.d.ts +963 -0
  119. package/dist/types/commercial-app.api.d.ts.map +1 -0
  120. package/dist/types/commercial-app.api.js +2 -0
  121. package/dist/types/connector.js +2 -1
  122. package/dist/types/context.js +2 -1
  123. package/dist/types/event-app.api.d.ts +8 -0
  124. package/dist/types/event-app.api.d.ts.map +1 -1
  125. package/dist/types/event-app.api.js +2 -1
  126. package/dist/types/function.js +2 -1
  127. package/dist/types/identity-app.api.d.ts +99 -0
  128. package/dist/types/identity-app.api.d.ts.map +1 -0
  129. package/dist/types/identity-app.api.js +2 -0
  130. package/dist/types/index.js +23 -1
  131. package/dist/types/memory-app.api.d.ts +140 -0
  132. package/dist/types/memory-app.api.d.ts.map +1 -0
  133. package/dist/types/memory-app.api.js +2 -0
  134. package/dist/types/oauth-app.api.d.ts +2 -0
  135. package/dist/types/oauth-app.api.d.ts.map +1 -1
  136. package/dist/types/oauth-app.api.js +105 -1
  137. package/dist/types/provider-services.api.d.ts +98 -0
  138. package/dist/types/provider-services.api.d.ts.map +1 -0
  139. package/dist/types/provider-services.api.js +2 -0
  140. package/dist/types/validator.js +2 -1
  141. package/dist/types/webhook-app.api.d.ts +2 -0
  142. package/dist/types/webhook-app.api.d.ts.map +1 -0
  143. package/dist/types/webhook-app.api.js +2 -0
  144. package/dist/types/workflow.js +33 -1
  145. package/dist/validators/validators.js +478 -1
  146. package/dist/variable.js +37 -1
  147. package/package.json +3 -2
@@ -0,0 +1,963 @@
1
+ export type CommercialAppClientConfig = {
2
+ baseUrl: string;
3
+ appId: string;
4
+ apiKey?: string;
5
+ appApiKey?: string;
6
+ appSecret?: string;
7
+ debug?: boolean;
8
+ /** Pin project env bag for connector auth templates. Omit to follow the project switch. */
9
+ environment?: "dev" | "prod" | "development" | "production";
10
+ };
11
+ export type CommercialPaginationMeta = {
12
+ totalDocs: number;
13
+ totalPages: number;
14
+ page: number;
15
+ limit: number;
16
+ hasNextPage: boolean;
17
+ hasPrevPage: boolean;
18
+ };
19
+ export type CommercialListParams = {
20
+ page?: number;
21
+ limit?: number;
22
+ q?: string;
23
+ };
24
+ export type CommercialCustomer = {
25
+ _id: string;
26
+ tenant_id: string;
27
+ app_id: string;
28
+ customer_key: string;
29
+ name?: string;
30
+ email?: string;
31
+ status: string;
32
+ preferred_currency?: string;
33
+ tax_ids?: Array<{
34
+ type: string;
35
+ value: string;
36
+ }>;
37
+ billing_address?: {
38
+ country: string;
39
+ region?: string;
40
+ city?: string;
41
+ line1?: string;
42
+ postal_code?: string;
43
+ };
44
+ credit_balances?: Array<{
45
+ currency: string;
46
+ amount: number;
47
+ }>;
48
+ metadata?: Record<string, unknown>;
49
+ createdAt?: string | Date;
50
+ updatedAt?: string | Date;
51
+ };
52
+ export type CommercialCreateCustomerInput = {
53
+ customer_key: string;
54
+ name: string;
55
+ email?: string;
56
+ preferred_currency?: string;
57
+ tax_ids?: Array<{
58
+ type: string;
59
+ value: string;
60
+ }>;
61
+ billing_address?: {
62
+ country: string;
63
+ region?: string;
64
+ city?: string;
65
+ line1?: string;
66
+ postal_code?: string;
67
+ };
68
+ metadata?: Record<string, unknown>;
69
+ };
70
+ export type CommercialFeature = {
71
+ _id: string;
72
+ tenant_id: string;
73
+ app_id: string;
74
+ key: string;
75
+ name: string;
76
+ kind: "boolean" | "metered" | "limit" | string;
77
+ unit?: string;
78
+ default_increment?: number;
79
+ description?: string;
80
+ };
81
+ export type CommercialPlanEntitlement = {
82
+ feature_key: string;
83
+ enabled: boolean;
84
+ limit: number | null;
85
+ unit_prices?: CommercialPrice[];
86
+ topup_packs?: Array<{
87
+ units: number;
88
+ prices: CommercialPrice[];
89
+ }>;
90
+ };
91
+ export type CommercialPrice = {
92
+ currency: string;
93
+ amount: number;
94
+ active?: boolean;
95
+ metadata?: Record<string, unknown>;
96
+ };
97
+ export type CommercialPlanInterval = "daily" | "weekly" | "monthly" | "quarterly" | "biannual" | "yearly" | "custom" | "lifetime" | "none" | (string & {});
98
+ export type CommercialPlan = {
99
+ _id: string;
100
+ tenant_id: string;
101
+ app_id: string;
102
+ key: string;
103
+ name: string;
104
+ description?: string;
105
+ currency?: string;
106
+ amount?: number;
107
+ prices?: CommercialPrice[];
108
+ default_currency?: string;
109
+ interval: CommercialPlanInterval;
110
+ interval_days?: number;
111
+ entitlements: CommercialPlanEntitlement[];
112
+ trial_days?: number;
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;
118
+ metadata?: Record<string, unknown>;
119
+ };
120
+ export type CommercialSubscription = {
121
+ _id: string;
122
+ tenant_id: string;
123
+ app_id: string;
124
+ customer_id: string;
125
+ plan_id: string;
126
+ plan_key: string;
127
+ plan_name: string;
128
+ plan_interval: CommercialPlanInterval;
129
+ plan_interval_days?: number;
130
+ plan_entitlements: CommercialPlanEntitlement[];
131
+ status: string;
132
+ currency?: string;
133
+ amount?: number;
134
+ billing_interval?: CommercialPlanInterval;
135
+ billing_interval_days?: number;
136
+ discount?: Record<string, unknown> | null;
137
+ tax_rate_id?: string;
138
+ tax_percent?: number;
139
+ addons?: Array<{
140
+ addon_key: string;
141
+ quantity: number;
142
+ unit_amount: number;
143
+ currency: string;
144
+ metadata?: Record<string, unknown>;
145
+ }>;
146
+ seats_purchased?: number;
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;
189
+ trial_starts_at?: string | Date | null;
190
+ trial_ends_at?: string | Date | null;
191
+ starts_at?: string | Date | null;
192
+ ends_at?: string | Date | null;
193
+ current_period_start?: string | Date | null;
194
+ current_period_end?: string | Date | null;
195
+ cancel_at?: string | Date | null;
196
+ metadata?: Record<string, unknown>;
197
+ };
198
+ export type CommercialCheckInput = {
199
+ customer: string;
200
+ feature: string;
201
+ quantity?: number;
202
+ };
203
+ export type CommercialCheckResult = {
204
+ ok: true;
205
+ allowed: boolean;
206
+ reason: string;
207
+ quantity: number;
208
+ subscription: {
209
+ active: boolean;
210
+ expired: boolean;
211
+ status: string | null;
212
+ expires_at: string | null;
213
+ days_remaining: number | null;
214
+ plan_key: string | null;
215
+ };
216
+ entitlement: {
217
+ enabled: boolean;
218
+ limit: number | null;
219
+ };
220
+ usage: {
221
+ used: number;
222
+ limit: number | null;
223
+ remaining: number | null;
224
+ };
225
+ trial: {
226
+ active: boolean;
227
+ starts_at: string | null;
228
+ ends_at: string | null;
229
+ };
230
+ seats?: {
231
+ purchased: number;
232
+ assigned: number;
233
+ available: number;
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;
269
+ };
270
+ export type CommercialConsumeInput = CommercialCheckInput;
271
+ export type CommercialConsumeResult = CommercialCheckResult & {
272
+ consumed?: number;
273
+ };
274
+ export type CommercialStateInput = {
275
+ customer: string;
276
+ include_billing?: boolean;
277
+ };
278
+ export type CommercialStateResult = {
279
+ ok: true;
280
+ customer: CommercialCustomer;
281
+ subscription: CommercialSubscription | null;
282
+ plan: {
283
+ key: string;
284
+ name: string;
285
+ interval: CommercialPlanInterval;
286
+ interval_days?: number;
287
+ } | null;
288
+ features: Record<string, {
289
+ enabled: boolean;
290
+ kind: string;
291
+ limit: number | null;
292
+ used: number;
293
+ remaining: number | null;
294
+ }>;
295
+ trial: {
296
+ active: boolean;
297
+ starts_at: string | null;
298
+ ends_at: string | null;
299
+ };
300
+ seats?: {
301
+ purchased: number;
302
+ assigned: number;
303
+ available: number;
304
+ };
305
+ invoices?: CommercialInvoice[];
306
+ payments?: Array<Record<string, unknown>>;
307
+ };
308
+ export type CommercialListCustomersResponse = {
309
+ ok: true;
310
+ customers: CommercialCustomer[];
311
+ pagination: CommercialPaginationMeta;
312
+ };
313
+ export type CommercialListFeaturesResponse = {
314
+ ok: true;
315
+ features: CommercialFeature[];
316
+ pagination: CommercialPaginationMeta;
317
+ };
318
+ export type CommercialListPlansResponse = {
319
+ ok: true;
320
+ plans: CommercialPlan[];
321
+ pagination: CommercialPaginationMeta;
322
+ };
323
+ export type CommercialListSubscriptionsParams = CommercialListParams & {
324
+ customer_id?: string;
325
+ customer?: string;
326
+ customer_key?: string;
327
+ status?: string;
328
+ include_archived?: boolean | string;
329
+ };
330
+ export type CommercialListSubscriptionsResponse = {
331
+ ok: true;
332
+ subscriptions: CommercialSubscription[];
333
+ pagination: CommercialPaginationMeta;
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
+ };
344
+ export type CommercialInvoice = {
345
+ _id: string;
346
+ tenant_id: string;
347
+ app_id: string;
348
+ customer_id: string;
349
+ customer_key?: string;
350
+ customer_name?: string;
351
+ customer_email?: string;
352
+ subscription_id?: string;
353
+ provider: string;
354
+ provider_type?: string;
355
+ provider_name?: string;
356
+ payment_method_key?: string;
357
+ provider_invoice_id?: string;
358
+ status: string;
359
+ currency: string;
360
+ amount: number;
361
+ line_items?: CommercialInvoiceLineItem[];
362
+ subtotal?: number;
363
+ discount_total?: number;
364
+ tax_total?: number;
365
+ total?: number;
366
+ period_start?: string | Date;
367
+ period_end?: string | Date;
368
+ due_at?: string | Date;
369
+ paid_at?: string | Date;
370
+ metadata?: Record<string, unknown>;
371
+ createdAt?: string | Date;
372
+ updatedAt?: string | Date;
373
+ };
374
+ export type CommercialListInvoicesParams = CommercialListParams & {
375
+ customer_id?: string;
376
+ customer?: string;
377
+ customer_key?: string;
378
+ subscription_id?: string;
379
+ status?: string;
380
+ };
381
+ export type CommercialListInvoicesResponse = {
382
+ ok: true;
383
+ invoices: CommercialInvoice[];
384
+ pagination: CommercialPaginationMeta;
385
+ };
386
+ export type CommercialPricingQuoteInput = {
387
+ plan: string;
388
+ customer?: string;
389
+ currency?: string;
390
+ discount_code?: string;
391
+ tax_rate?: string;
392
+ addons?: Array<{
393
+ key: string;
394
+ quantity: number;
395
+ }>;
396
+ seats_purchased?: number;
397
+ metadata?: Record<string, unknown>;
398
+ };
399
+ export type CommercialPricingQuote = {
400
+ currency: string;
401
+ plan_key: string;
402
+ plan_amount: number;
403
+ addon_total: number;
404
+ seat_total: number;
405
+ subtotal: number;
406
+ discount_total: number;
407
+ tax_total: number;
408
+ total: number;
409
+ line_items: Array<{
410
+ kind: string;
411
+ description: string;
412
+ quantity: number;
413
+ unit_amount: number;
414
+ amount: number;
415
+ currency: string;
416
+ metadata?: Record<string, unknown>;
417
+ }>;
418
+ discount?: Record<string, unknown> | null;
419
+ tax_rate_key?: string | null;
420
+ metadata?: Record<string, unknown>;
421
+ };
422
+ export type CommercialCreateSubscriptionInput = {
423
+ customer: string;
424
+ plan: string;
425
+ status?: string;
426
+ currency?: string;
427
+ discount_code?: string;
428
+ tax_rate?: string;
429
+ addons?: Array<{
430
+ key: string;
431
+ quantity: number;
432
+ }>;
433
+ seats_purchased?: number;
434
+ metadata?: Record<string, unknown>;
435
+ payment_method?: string;
436
+ card?: string;
437
+ card_id?: string;
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";
443
+ };
444
+ export type CommercialChangePlanInput = {
445
+ subscriptionId: string;
446
+ plan: string;
447
+ currency?: string;
448
+ discount_code?: string;
449
+ tax_rate?: string;
450
+ addons?: Array<{
451
+ key: string;
452
+ quantity: number;
453
+ }>;
454
+ seats_purchased?: number;
455
+ payment_method?: string;
456
+ card?: string;
457
+ card_id?: string;
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>;
483
+ };
484
+ export type CommercialPaymentMethodSummary = {
485
+ key: string;
486
+ name: string;
487
+ is_default: boolean;
488
+ connector_name?: string;
489
+ action_name?: string;
490
+ renewal_mode: "platform" | "provider";
491
+ };
492
+ export type CommercialInitiatePaymentInput = {
493
+ customer: string;
494
+ subscription?: string;
495
+ invoice?: string;
496
+ payment_method?: string;
497
+ card?: string;
498
+ card_id?: string;
499
+ input?: Record<string, unknown>;
500
+ currency?: string;
501
+ discount_code?: string;
502
+ };
503
+ export type CommercialInitiatePaymentResult = {
504
+ ok: boolean;
505
+ reference: string;
506
+ invoice: {
507
+ _id: string;
508
+ status: string;
509
+ currency: string;
510
+ amount: number;
511
+ total?: number;
512
+ metadata?: Record<string, unknown>;
513
+ };
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>;
717
+ };
718
+ export type CommercialConfirmPaymentInput = {
719
+ reference: string;
720
+ status: "succeeded" | "failed" | "pending";
721
+ provider_payment_id?: string;
722
+ failure_reason?: string;
723
+ metadata?: Record<string, unknown>;
724
+ };
725
+ export type CommercialConfirmPaymentResult = {
726
+ ok: true;
727
+ reference: string;
728
+ invoice: {
729
+ _id: string;
730
+ status: string;
731
+ currency: string;
732
+ amount: number;
733
+ total?: number;
734
+ };
735
+ payment: {
736
+ _id?: string;
737
+ status: string;
738
+ provider_payment_id?: string;
739
+ };
740
+ };
741
+ export type CommercialUpdateSubscriptionStatusInput = {
742
+ subscriptionId: string;
743
+ status: string;
744
+ };
745
+ export type CommercialSeatAssignInput = {
746
+ customer: string;
747
+ subject_key: string;
748
+ email?: string;
749
+ metadata?: Record<string, unknown>;
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
+ };
770
+ export type CommercialLicenseIssueInput = {
771
+ customer: string;
772
+ expires_at?: string;
773
+ metadata?: Record<string, unknown>;
774
+ };
775
+ export type CommercialLicenseValidateInput = {
776
+ license_key: string;
777
+ };
778
+ export type CommercialAnalyticsParams = {
779
+ period?: string;
780
+ from?: string;
781
+ to?: string;
782
+ granularity?: string;
783
+ customer_ids?: string[] | string;
784
+ customer_keys?: string[] | string;
785
+ plan_keys?: string[] | string;
786
+ statuses?: string[] | string;
787
+ feature_keys?: string[] | string;
788
+ event_types?: string[] | string;
789
+ currency?: string;
790
+ expiring_within_days?: number;
791
+ include_charts?: boolean;
792
+ include_tables?: boolean;
793
+ include_insights?: boolean;
794
+ limit?: number;
795
+ };
796
+ export type CommercialAppClientApi = {
797
+ check(input: CommercialCheckInput): Promise<CommercialCheckResult>;
798
+ consume(input: CommercialConsumeInput): Promise<CommercialConsumeResult>;
799
+ state(input: CommercialStateInput): Promise<CommercialStateResult>;
800
+ getCustomerSubscription(customerId: string, options?: {
801
+ include_billing?: boolean;
802
+ }): Promise<CommercialStateResult>;
803
+ listCustomers(params?: CommercialListParams): Promise<CommercialListCustomersResponse>;
804
+ getCustomer(customerId: string): Promise<{
805
+ ok: true;
806
+ customer: CommercialCustomer;
807
+ }>;
808
+ createCustomer(input: CommercialCreateCustomerInput): Promise<{
809
+ ok: true;
810
+ customer: CommercialCustomer;
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
+ }>;
840
+ listFeatures(params?: CommercialListParams): Promise<CommercialListFeaturesResponse>;
841
+ getFeature(featureId: string): Promise<{
842
+ ok: true;
843
+ feature: CommercialFeature;
844
+ }>;
845
+ listPlans(params?: CommercialListParams): Promise<CommercialListPlansResponse>;
846
+ getPlan(planId: string): Promise<{
847
+ ok: true;
848
+ plan: CommercialPlan;
849
+ }>;
850
+ listSubscriptions(params?: CommercialListSubscriptionsParams): Promise<CommercialListSubscriptionsResponse>;
851
+ getSubscription(subscriptionId: string): Promise<{
852
+ ok: true;
853
+ subscription: CommercialSubscription;
854
+ }>;
855
+ listInvoices(params?: CommercialListInvoicesParams): Promise<CommercialListInvoicesResponse>;
856
+ getInvoice(invoiceId: string | {
857
+ invoiceId?: string;
858
+ _id?: string;
859
+ id?: string;
860
+ reference?: string;
861
+ }): Promise<{
862
+ ok: true;
863
+ invoice: CommercialInvoice;
864
+ }>;
865
+ createSubscription(input: CommercialCreateSubscriptionInput): Promise<{
866
+ ok: true;
867
+ subscription: CommercialSubscription;
868
+ }>;
869
+ subscribe(input: CommercialCreateSubscriptionInput): Promise<{
870
+ ok: true;
871
+ subscription: CommercialSubscription;
872
+ }>;
873
+ updatePendingSubscription(input: CommercialUpdatePendingSubscriptionInput): Promise<{
874
+ ok: true;
875
+ subscription: CommercialSubscription;
876
+ }>;
877
+ changePlan(input: CommercialChangePlanInput): Promise<{
878
+ ok: true;
879
+ subscription: CommercialSubscription;
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>;
889
+ updateSubscriptionStatus(input: CommercialUpdateSubscriptionStatusInput): Promise<{
890
+ ok: true;
891
+ subscription: CommercialSubscription;
892
+ }>;
893
+ archiveSubscription(subscriptionId: string): Promise<{
894
+ ok: true;
895
+ subscription: CommercialSubscription;
896
+ }>;
897
+ quote(input: CommercialPricingQuoteInput): Promise<{
898
+ ok: true;
899
+ quote: CommercialPricingQuote;
900
+ }>;
901
+ listPaymentMethods(): Promise<{
902
+ ok: true;
903
+ payment_methods: CommercialPaymentMethodSummary[];
904
+ }>;
905
+ initiatePayment(input: CommercialInitiatePaymentInput): Promise<CommercialInitiatePaymentResult>;
906
+ confirmPayment(input: CommercialConfirmPaymentInput): Promise<CommercialConfirmPaymentResult>;
907
+ previewDiscount(input: {
908
+ code: string;
909
+ plan: string;
910
+ currency?: string;
911
+ customer?: string;
912
+ }): Promise<{
913
+ ok: true;
914
+ discount: CommercialDiscount;
915
+ quote: CommercialPricingQuote;
916
+ }>;
917
+ listDiscounts(params?: CommercialListParams): Promise<{
918
+ ok: true;
919
+ discounts: CommercialDiscount[];
920
+ pagination: CommercialPaginationMeta;
921
+ }>;
922
+ listTaxRates(params?: CommercialListParams): Promise<{
923
+ ok: true;
924
+ tax_rates: CommercialTaxRate[];
925
+ pagination: CommercialPaginationMeta;
926
+ }>;
927
+ listAddons(params?: CommercialListParams): Promise<{
928
+ ok: true;
929
+ addons: CommercialAddon[];
930
+ pagination: CommercialPaginationMeta;
931
+ }>;
932
+ assignSeat(input: CommercialSeatAssignInput): Promise<{
933
+ ok: true;
934
+ assignment: CommercialSeatAssignment;
935
+ }>;
936
+ unassignSeat(input: CommercialSeatAssignInput): Promise<{
937
+ ok: boolean;
938
+ }>;
939
+ issueLicense(input: CommercialLicenseIssueInput): Promise<{
940
+ ok: true;
941
+ license: CommercialLicense;
942
+ license_key: string;
943
+ }>;
944
+ validateLicense(input: CommercialLicenseValidateInput): Promise<{
945
+ ok: true;
946
+ valid: boolean;
947
+ license?: CommercialLicense;
948
+ [key: string]: unknown;
949
+ }>;
950
+ revokeLicense(licenseId: string): Promise<{
951
+ ok: true;
952
+ license: CommercialLicense;
953
+ }>;
954
+ analytics(params?: CommercialAnalyticsParams): Promise<{
955
+ ok: true;
956
+ analytics: unknown;
957
+ }>;
958
+ analyticsCharts(params?: CommercialAnalyticsParams): Promise<{
959
+ ok: true;
960
+ [key: string]: unknown;
961
+ }>;
962
+ };
963
+ //# sourceMappingURL=commercial-app.api.d.ts.map