@strimz/shared-types 0.13.1 → 0.15.0

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 (56) hide show
  1. package/dist/analytics.cjs +36 -0
  2. package/dist/analytics.cjs.map +1 -1
  3. package/dist/analytics.d.cts +136 -136
  4. package/dist/analytics.d.ts +136 -136
  5. package/dist/analytics.js +36 -0
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/api-keys.d.cts +20 -20
  8. package/dist/api-keys.d.ts +20 -20
  9. package/dist/compliance.d.cts +4 -4
  10. package/dist/compliance.d.ts +4 -4
  11. package/dist/customers.d.cts +6 -6
  12. package/dist/customers.d.ts +6 -6
  13. package/dist/events.cjs +37 -25
  14. package/dist/events.cjs.map +1 -1
  15. package/dist/events.d.cts +1397 -2203
  16. package/dist/events.d.ts +1397 -2203
  17. package/dist/events.js +38 -23
  18. package/dist/events.js.map +1 -1
  19. package/dist/index.cjs +40 -24
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +16 -16
  22. package/dist/index.d.ts +16 -16
  23. package/dist/index.js +37 -22
  24. package/dist/index.js.map +1 -1
  25. package/dist/invoices.d.cts +10 -10
  26. package/dist/invoices.d.ts +10 -10
  27. package/dist/merchants.d.cts +20 -20
  28. package/dist/merchants.d.ts +20 -20
  29. package/dist/payment-sessions.d.cts +16 -16
  30. package/dist/payment-sessions.d.ts +16 -16
  31. package/dist/refunds.d.cts +36 -36
  32. package/dist/refunds.d.ts +36 -36
  33. package/dist/storefronts.cjs +151 -0
  34. package/dist/storefronts.cjs.map +1 -1
  35. package/dist/storefronts.d.cts +27 -27
  36. package/dist/storefronts.d.ts +27 -27
  37. package/dist/storefronts.js +151 -0
  38. package/dist/storefronts.js.map +1 -1
  39. package/dist/subscriptions.cjs +153 -0
  40. package/dist/subscriptions.cjs.map +1 -1
  41. package/dist/subscriptions.d.cts +110 -33
  42. package/dist/subscriptions.d.ts +110 -33
  43. package/dist/subscriptions.js +150 -1
  44. package/dist/subscriptions.js.map +1 -1
  45. package/dist/transactions.d.cts +12 -12
  46. package/dist/transactions.d.ts +12 -12
  47. package/dist/webhooks.cjs +0 -3
  48. package/dist/webhooks.cjs.map +1 -1
  49. package/dist/webhooks.d.cts +40 -40
  50. package/dist/webhooks.d.ts +40 -40
  51. package/dist/webhooks.js +0 -3
  52. package/dist/webhooks.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/events.ts +1 -24
  55. package/src/subscriptions.ts +49 -0
  56. package/src/webhooks.ts +0 -3
@@ -12,7 +12,7 @@ import { z } from 'zod';
12
12
  * Every webhook event name in the system. Listed inline so Zod can
13
13
  * produce a concrete string union.
14
14
  */
15
- declare const webhookEventNameSchema: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
15
+ declare const webhookEventNameSchema: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
16
16
  type WebhookEventName = z.infer<typeof webhookEventNameSchema>;
17
17
  declare const webhookEndpointStatusSchema: z.ZodEnum<["active", "disabled"]>;
18
18
  type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>;
@@ -22,7 +22,7 @@ declare const webhookEndpointSchema: z.ZodObject<{
22
22
  mode: z.ZodEnum<["test", "live"]>;
23
23
  url: z.ZodEffects<z.ZodString, string, string>;
24
24
  description: z.ZodNullable<z.ZodString>;
25
- events: z.ZodArray<z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>, "atleastone">;
25
+ events: z.ZodArray<z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>, "atleastone">;
26
26
  status: z.ZodEnum<["active", "disabled"]>;
27
27
  signingSecretPrefix: z.ZodString;
28
28
  lastDeliveredAt: z.ZodNullable<z.ZodString>;
@@ -30,44 +30,44 @@ declare const webhookEndpointSchema: z.ZodObject<{
30
30
  updatedAt: z.ZodString;
31
31
  }, "strip", z.ZodTypeAny, {
32
32
  status: "active" | "disabled";
33
- id: string;
34
- merchantId: string;
35
33
  mode: "test" | "live";
36
- createdAt: string;
34
+ merchantId: string;
37
35
  description: string | null;
36
+ id: string;
37
+ createdAt: string;
38
38
  updatedAt: string;
39
39
  url: string;
40
- events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
40
+ events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
41
41
  signingSecretPrefix: string;
42
42
  lastDeliveredAt: string | null;
43
43
  }, {
44
44
  status: "active" | "disabled";
45
- id: string;
46
- merchantId: string;
47
45
  mode: "test" | "live";
48
- createdAt: string;
46
+ merchantId: string;
49
47
  description: string | null;
48
+ id: string;
49
+ createdAt: string;
50
50
  updatedAt: string;
51
51
  url: string;
52
- events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
52
+ events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
53
53
  signingSecretPrefix: string;
54
54
  lastDeliveredAt: string | null;
55
55
  }>;
56
56
  type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>;
57
57
  declare const createWebhookEndpointInputSchema: z.ZodObject<{
58
58
  url: z.ZodEffects<z.ZodString, string, string>;
59
- events: z.ZodArray<z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>, "atleastone">;
59
+ events: z.ZodArray<z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>, "atleastone">;
60
60
  description: z.ZodOptional<z.ZodString>;
61
61
  mode: z.ZodEnum<["test", "live"]>;
62
62
  }, "strip", z.ZodTypeAny, {
63
63
  mode: "test" | "live";
64
64
  url: string;
65
- events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
65
+ events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
66
66
  description?: string | undefined;
67
67
  }, {
68
68
  mode: "test" | "live";
69
69
  url: string;
70
- events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
70
+ events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
71
71
  description?: string | undefined;
72
72
  }>;
73
73
  type CreateWebhookEndpointInput = z.input<typeof createWebhookEndpointInputSchema>;
@@ -79,7 +79,7 @@ declare const createWebhookEndpointOutputSchema: z.ZodObject<{
79
79
  mode: z.ZodEnum<["test", "live"]>;
80
80
  url: z.ZodEffects<z.ZodString, string, string>;
81
81
  description: z.ZodNullable<z.ZodString>;
82
- events: z.ZodArray<z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>, "atleastone">;
82
+ events: z.ZodArray<z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>, "atleastone">;
83
83
  status: z.ZodEnum<["active", "disabled"]>;
84
84
  signingSecretPrefix: z.ZodString;
85
85
  lastDeliveredAt: z.ZodNullable<z.ZodString>;
@@ -87,26 +87,26 @@ declare const createWebhookEndpointOutputSchema: z.ZodObject<{
87
87
  updatedAt: z.ZodString;
88
88
  }, "strip", z.ZodTypeAny, {
89
89
  status: "active" | "disabled";
90
- id: string;
91
- merchantId: string;
92
90
  mode: "test" | "live";
93
- createdAt: string;
91
+ merchantId: string;
94
92
  description: string | null;
93
+ id: string;
94
+ createdAt: string;
95
95
  updatedAt: string;
96
96
  url: string;
97
- events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
97
+ events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
98
98
  signingSecretPrefix: string;
99
99
  lastDeliveredAt: string | null;
100
100
  }, {
101
101
  status: "active" | "disabled";
102
- id: string;
103
- merchantId: string;
104
102
  mode: "test" | "live";
105
- createdAt: string;
103
+ merchantId: string;
106
104
  description: string | null;
105
+ id: string;
106
+ createdAt: string;
107
107
  updatedAt: string;
108
108
  url: string;
109
- events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
109
+ events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
110
110
  signingSecretPrefix: string;
111
111
  lastDeliveredAt: string | null;
112
112
  }>;
@@ -115,14 +115,14 @@ declare const createWebhookEndpointOutputSchema: z.ZodObject<{
115
115
  }, "strip", z.ZodTypeAny, {
116
116
  endpoint: {
117
117
  status: "active" | "disabled";
118
- id: string;
119
- merchantId: string;
120
118
  mode: "test" | "live";
121
- createdAt: string;
119
+ merchantId: string;
122
120
  description: string | null;
121
+ id: string;
122
+ createdAt: string;
123
123
  updatedAt: string;
124
124
  url: string;
125
- events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
125
+ events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
126
126
  signingSecretPrefix: string;
127
127
  lastDeliveredAt: string | null;
128
128
  };
@@ -130,14 +130,14 @@ declare const createWebhookEndpointOutputSchema: z.ZodObject<{
130
130
  }, {
131
131
  endpoint: {
132
132
  status: "active" | "disabled";
133
- id: string;
134
- merchantId: string;
135
133
  mode: "test" | "live";
136
- createdAt: string;
134
+ merchantId: string;
137
135
  description: string | null;
136
+ id: string;
137
+ createdAt: string;
138
138
  updatedAt: string;
139
139
  url: string;
140
- events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
140
+ events: ["payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked", ...("payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked")[]];
141
141
  signingSecretPrefix: string;
142
142
  lastDeliveredAt: string | null;
143
143
  };
@@ -151,7 +151,7 @@ declare const webhookDeliverySchema: z.ZodObject<{
151
151
  merchantId: z.ZodString;
152
152
  endpointId: z.ZodString;
153
153
  eventId: z.ZodString;
154
- eventName: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
154
+ eventName: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
155
155
  status: z.ZodEnum<["pending", "delivered", "retrying", "permanently_failed"]>;
156
156
  attempt: z.ZodNumber;
157
157
  responseCode: z.ZodNullable<z.ZodNumber>;
@@ -162,12 +162,12 @@ declare const webhookDeliverySchema: z.ZodObject<{
162
162
  createdAt: z.ZodString;
163
163
  }, "strip", z.ZodTypeAny, {
164
164
  status: "pending" | "retrying" | "delivered" | "permanently_failed";
165
- id: string;
166
165
  merchantId: string;
166
+ id: string;
167
167
  createdAt: string;
168
168
  endpointId: string;
169
169
  eventId: string;
170
- eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
170
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
171
171
  attempt: number;
172
172
  responseCode: number | null;
173
173
  responseMs: number | null;
@@ -176,12 +176,12 @@ declare const webhookDeliverySchema: z.ZodObject<{
176
176
  deliveredAt: string | null;
177
177
  }, {
178
178
  status: "pending" | "retrying" | "delivered" | "permanently_failed";
179
- id: string;
180
179
  merchantId: string;
180
+ id: string;
181
181
  createdAt: string;
182
182
  endpointId: string;
183
183
  eventId: string;
184
- eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
184
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
185
185
  attempt: number;
186
186
  responseCode: number | null;
187
187
  responseMs: number | null;
@@ -200,7 +200,7 @@ declare const webhookDeliveryDetailSchema: z.ZodObject<{
200
200
  merchantId: z.ZodString;
201
201
  endpointId: z.ZodString;
202
202
  eventId: z.ZodString;
203
- eventName: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
203
+ eventName: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
204
204
  status: z.ZodEnum<["pending", "delivered", "retrying", "permanently_failed"]>;
205
205
  attempt: z.ZodNumber;
206
206
  responseCode: z.ZodNullable<z.ZodNumber>;
@@ -215,12 +215,12 @@ declare const webhookDeliveryDetailSchema: z.ZodObject<{
215
215
  requestPayload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
216
216
  }, "strip", z.ZodTypeAny, {
217
217
  status: "pending" | "retrying" | "delivered" | "permanently_failed";
218
- id: string;
219
218
  merchantId: string;
219
+ id: string;
220
220
  createdAt: string;
221
221
  endpointId: string;
222
222
  eventId: string;
223
- eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
223
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
224
224
  attempt: number;
225
225
  responseCode: number | null;
226
226
  responseMs: number | null;
@@ -232,12 +232,12 @@ declare const webhookDeliveryDetailSchema: z.ZodObject<{
232
232
  requestPayload: Record<string, unknown>;
233
233
  }, {
234
234
  status: "pending" | "retrying" | "delivered" | "permanently_failed";
235
- id: string;
236
235
  merchantId: string;
236
+ id: string;
237
237
  createdAt: string;
238
238
  endpointId: string;
239
239
  eventId: string;
240
- eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
240
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
241
241
  attempt: number;
242
242
  responseCode: number | null;
243
243
  responseMs: number | null;
package/dist/webhooks.js CHANGED
@@ -36,16 +36,13 @@ var webhookEventNameSchema = z.enum([
36
36
  "subscription.charged",
37
37
  "subscription.charge_failed",
38
38
  "subscription.recovery_attempt",
39
- "subscription.recovery_outcome",
40
39
  "subscription.cancelled",
41
40
  "subscription.lapsed",
42
41
  "refund.created",
43
42
  "refund.completed",
44
- "refund.failed",
45
43
  "invoice.created",
46
44
  "invoice.paid",
47
45
  "invoice.overdue",
48
- "agent.action_executed",
49
46
  "agent.job_proposed",
50
47
  "agent.job_completed",
51
48
  "agent.job_disputed",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAAA,GAAW,CAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,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,EAAE,MAAA,CAAO;AAAA,EAC5C,EAAA,EAAI,QAAA;AAAA,EACJ,UAAA,EAAY,QAAA;AAAA,EACZ,UAAA,EAAY,QAAA;AAAA,EACZ,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,sBAAA;AAAA,EACX,MAAA,EAAQ,2BAAA;AAAA,EACR,OAAA,EAASA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA;AAAA,EACtC,YAAA,EAAcA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA,EAC1D,UAAA,EAAYA,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC7C,WAAWA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAI,EAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,mBAAmB,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,mBAAmB,QAAA,EAAS;AAAA,EACzC,SAAA,EAAW;AACb,CAAC;AAQM,IAAM,2BAAA,GAA8B,sBAAsB,MAAA,CAAO;AAAA,EACtE,UAAA,EAAYA,EAAE,MAAA,EAAO;AAAA,EACrB,YAAA,EAAcA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAClC,cAAA,EAAgBA,EAAE,MAAA,CAAOA,CAAAA,CAAE,QAAO,EAAGA,CAAAA,CAAE,SAAS;AAClD,CAAC;AAGM,IAAM,yBAAA,GAA4BA,EAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.input<typeof paginationInputSchema>\nexport type PaginationParsed = z.output<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'starter', 'growth', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed inline so Zod can\n * produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.input<typeof createWebhookEndpointInputSchema>\nexport type CreateWebhookEndpointParsed = z.output<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret. Shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\n/**\n * Detail projection returned by GET /v1/webhook-deliveries/:id.\n * Carries the payload envelope, response body, and the deliveryId\n * header the receiver saw. Kept separate so list responses stay slim.\n */\nexport const webhookDeliveryDetailSchema = webhookDeliverySchema.extend({\n deliveryId: z.string(),\n responseBody: z.string().nullable(),\n requestPayload: z.record(z.string(), z.unknown()),\n})\nexport type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.input<typeof replayDeliveryInputSchema>\nexport type ReplayDeliveryParsed = z.output<typeof replayDeliveryInputSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAAA,GAAW,CAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAGlB,CAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa;AAGJ,CAA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,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA;AAAA,EACtC,YAAA,EAAcA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA,EAC1D,UAAA,EAAYA,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC7C,WAAWA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAI,EAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,mBAAmB,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,mBAAmB,QAAA,EAAS;AAAA,EACzC,SAAA,EAAW;AACb,CAAC;AAQM,IAAM,2BAAA,GAA8B,sBAAsB,MAAA,CAAO;AAAA,EACtE,UAAA,EAAYA,EAAE,MAAA,EAAO;AAAA,EACrB,YAAA,EAAcA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAClC,cAAA,EAAgBA,EAAE,MAAA,CAAOA,CAAAA,CAAE,QAAO,EAAGA,CAAAA,CAAE,SAAS;AAClD,CAAC;AAGM,IAAM,yBAAA,GAA4BA,EAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.input<typeof paginationInputSchema>\nexport type PaginationParsed = z.output<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'starter', 'growth', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed inline so Zod can\n * produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.input<typeof createWebhookEndpointInputSchema>\nexport type CreateWebhookEndpointParsed = z.output<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret. Shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\n/**\n * Detail projection returned by GET /v1/webhook-deliveries/:id.\n * Carries the payload envelope, response body, and the deliveryId\n * header the receiver saw. Kept separate so list responses stay slim.\n */\nexport const webhookDeliveryDetailSchema = webhookDeliverySchema.extend({\n deliveryId: z.string(),\n responseBody: z.string().nullable(),\n requestPayload: z.record(z.string(), z.unknown()),\n})\nexport type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.input<typeof replayDeliveryInputSchema>\nexport type ReplayDeliveryParsed = z.output<typeof replayDeliveryInputSchema>\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strimz/shared-types",
3
- "version": "0.13.1",
3
+ "version": "0.15.0",
4
4
  "description": "Zod schemas and inferred TypeScript types for every Strimz platform entity, API input, and webhook event.",
5
5
  "license": "MIT",
6
6
  "author": "Strimz <hello@strimz.finance>",
@@ -118,7 +118,7 @@
118
118
  ],
119
119
  "dependencies": {
120
120
  "zod": "^3.24.1",
121
- "@strimz/shared-config": "0.7.1"
121
+ "@strimz/shared-config": "0.8.0"
122
122
  },
123
123
  "devDependencies": {
124
124
  "eslint": "^9.18.0",
package/src/events.ts CHANGED
@@ -16,7 +16,7 @@ import { transactionSchema } from './transactions.js'
16
16
  import { subscriptionSchema, subscriptionChargeSchema } from './subscriptions.js'
17
17
  import { refundSchema } from './refunds.js'
18
18
  import { invoiceSchema } from './invoices.js'
19
- import { agentActivityLogSchema, agentJobSchema } from './agents.js'
19
+ import { agentJobSchema } from './agents.js'
20
20
  import { complianceLogSchema } from './compliance.js'
21
21
  import { webhookEventNameSchema } from './webhooks.js'
22
22
 
@@ -62,13 +62,6 @@ export const subscriptionRecoveryAttemptEventSchema = envelope(
62
62
  'subscription.recovery_attempt',
63
63
  z.object({ subscription: subscriptionSchema, attemptNumber: z.number().int().min(1) }),
64
64
  )
65
- export const subscriptionRecoveryOutcomeEventSchema = envelope(
66
- 'subscription.recovery_outcome',
67
- z.object({
68
- subscription: subscriptionSchema,
69
- outcome: z.enum(['recovered', 'churned']),
70
- }),
71
- )
72
65
  export const subscriptionCancelledEventSchema = envelope(
73
66
  'subscription.cancelled',
74
67
  subscriptionSchema,
@@ -82,10 +75,6 @@ export const refundCompletedEventSchema = envelope(
82
75
  'refund.completed',
83
76
  z.object({ refund: refundSchema, transaction: transactionSchema }),
84
77
  )
85
- export const refundFailedEventSchema = envelope(
86
- 'refund.failed',
87
- z.object({ refund: refundSchema, reason: z.string() }),
88
- )
89
78
 
90
79
  // ---------- Invoice ----------
91
80
 
@@ -98,10 +87,6 @@ export const invoiceOverdueEventSchema = envelope('invoice.overdue', invoiceSche
98
87
 
99
88
  // ---------- Agent ----------
100
89
 
101
- export const agentActionExecutedEventSchema = envelope(
102
- 'agent.action_executed',
103
- agentActivityLogSchema,
104
- )
105
90
  export const agentJobProposedEventSchema = envelope('agent.job_proposed', agentJobSchema)
106
91
  export const agentJobCompletedEventSchema = envelope('agent.job_completed', agentJobSchema)
107
92
  export const agentJobDisputedEventSchema = envelope('agent.job_disputed', agentJobSchema)
@@ -127,16 +112,13 @@ export const webhookEventSchema = z.discriminatedUnion('type', [
127
112
  subscriptionChargedEventSchema,
128
113
  subscriptionChargeFailedEventSchema,
129
114
  subscriptionRecoveryAttemptEventSchema,
130
- subscriptionRecoveryOutcomeEventSchema,
131
115
  subscriptionCancelledEventSchema,
132
116
  subscriptionLapsedEventSchema,
133
117
  refundCreatedEventSchema,
134
118
  refundCompletedEventSchema,
135
- refundFailedEventSchema,
136
119
  invoiceCreatedEventSchema,
137
120
  invoicePaidEventSchema,
138
121
  invoiceOverdueEventSchema,
139
- agentActionExecutedEventSchema,
140
122
  agentJobProposedEventSchema,
141
123
  agentJobCompletedEventSchema,
142
124
  agentJobDisputedEventSchema,
@@ -155,18 +137,13 @@ export type SubscriptionChargeFailedEvent = z.infer<typeof subscriptionChargeFai
155
137
  export type SubscriptionRecoveryAttemptEvent = z.infer<
156
138
  typeof subscriptionRecoveryAttemptEventSchema
157
139
  >
158
- export type SubscriptionRecoveryOutcomeEvent = z.infer<
159
- typeof subscriptionRecoveryOutcomeEventSchema
160
- >
161
140
  export type SubscriptionCancelledEvent = z.infer<typeof subscriptionCancelledEventSchema>
162
141
  export type SubscriptionLapsedEvent = z.infer<typeof subscriptionLapsedEventSchema>
163
142
  export type RefundCreatedEvent = z.infer<typeof refundCreatedEventSchema>
164
143
  export type RefundCompletedEvent = z.infer<typeof refundCompletedEventSchema>
165
- export type RefundFailedEvent = z.infer<typeof refundFailedEventSchema>
166
144
  export type InvoiceCreatedEvent = z.infer<typeof invoiceCreatedEventSchema>
167
145
  export type InvoicePaidEvent = z.infer<typeof invoicePaidEventSchema>
168
146
  export type InvoiceOverdueEvent = z.infer<typeof invoiceOverdueEventSchema>
169
- export type AgentActionExecutedEvent = z.infer<typeof agentActionExecutedEventSchema>
170
147
  export type AgentJobProposedEvent = z.infer<typeof agentJobProposedEventSchema>
171
148
  export type AgentJobCompletedEvent = z.infer<typeof agentJobCompletedEventSchema>
172
149
  export type AgentJobDisputedEvent = z.infer<typeof agentJobDisputedEventSchema>
@@ -18,6 +18,7 @@ import {
18
18
  paymentCurrencySchema,
19
19
  tokenAmountSchema,
20
20
  } from './common.js'
21
+ import { callbackUrlSchema } from './payment-sessions.js'
21
22
 
22
23
  // ---------- Plans ----------
23
24
 
@@ -65,6 +66,9 @@ export const subscriptionPlanSchema = z.object({
65
66
  intervalCount: z.number().int().min(1).max(365),
66
67
  trialPeriodDays: z.number().int().min(0).max(365).nullable(),
67
68
  status: subscriptionPlanStatusSchema,
69
+ /** `{SUBSCRIPTION_ID}` and `{ON_CHAIN_TX_HASH}` are filled in on redirect. */
70
+ successUrl: callbackUrlSchema.nullable(),
71
+ cancelUrl: callbackUrlSchema.nullable(),
68
72
  metadata: metadataSchema,
69
73
  createdAt: isoTimestampSchema,
70
74
  updatedAt: isoTimestampSchema,
@@ -79,11 +83,56 @@ export const createSubscriptionPlanInputSchema = z.object({
79
83
  interval: subscriptionIntervalSchema,
80
84
  intervalCount: z.number().int().min(1).max(365).default(1),
81
85
  trialPeriodDays: z.number().int().min(0).max(365).optional(),
86
+ successUrl: callbackUrlSchema.optional(),
87
+ cancelUrl: callbackUrlSchema.optional(),
82
88
  metadata: metadataSchema.optional(),
83
89
  })
84
90
  export type CreateSubscriptionPlanInput = z.input<typeof createSubscriptionPlanInputSchema>
85
91
  export type CreateSubscriptionPlanParsed = z.output<typeof createSubscriptionPlanInputSchema>
86
92
 
93
+ /** Price, interval and trial are fixed once a plan exists; only these change. */
94
+ export const updateSubscriptionPlanInputSchema = z
95
+ .object({
96
+ successUrl: callbackUrlSchema.nullable().optional(),
97
+ cancelUrl: callbackUrlSchema.nullable().optional(),
98
+ })
99
+ .strict()
100
+ .refine((v) => v.successUrl !== undefined || v.cancelUrl !== undefined, {
101
+ message: 'set successUrl or cancelUrl',
102
+ })
103
+ export type UpdateSubscriptionPlanInput = z.input<typeof updateSubscriptionPlanInputSchema>
104
+ export type UpdateSubscriptionPlanParsed = z.output<typeof updateSubscriptionPlanInputSchema>
105
+
106
+ export const subscriptionResultErrorCodes = [
107
+ 'load_failed',
108
+ 'merchant_not_ready',
109
+ 'payment_reverted',
110
+ 'already_subscribed',
111
+ ] as const
112
+ export const subscriptionResultErrorCodeSchema = z.enum(subscriptionResultErrorCodes)
113
+ export type SubscriptionResultErrorCode = z.infer<typeof subscriptionResultErrorCodeSchema>
114
+
115
+ /** What `/sub/{planId}` posts to the page that embedded or opened it. */
116
+ export const subscriptionResultMessageSchema = z.discriminatedUnion('type', [
117
+ z.object({
118
+ type: z.literal('strimz:subscription:success'),
119
+ planId: idSchema,
120
+ subscriptionId: idSchema.nullable(),
121
+ txHash: evmTxHashSchema,
122
+ }),
123
+ z.object({
124
+ type: z.literal('strimz:subscription:cancel'),
125
+ planId: idSchema,
126
+ }),
127
+ z.object({
128
+ type: z.literal('strimz:subscription:error'),
129
+ planId: idSchema,
130
+ code: subscriptionResultErrorCodeSchema,
131
+ message: z.string().min(1).max(500),
132
+ }),
133
+ ])
134
+ export type SubscriptionResultMessage = z.infer<typeof subscriptionResultMessageSchema>
135
+
87
136
  // ---------- Subscriptions ----------
88
137
 
89
138
  export const subscriptionStatusSchema = z.enum([
package/src/webhooks.ts CHANGED
@@ -23,16 +23,13 @@ export const webhookEventNameSchema = z.enum([
23
23
  'subscription.charged',
24
24
  'subscription.charge_failed',
25
25
  'subscription.recovery_attempt',
26
- 'subscription.recovery_outcome',
27
26
  'subscription.cancelled',
28
27
  'subscription.lapsed',
29
28
  'refund.created',
30
29
  'refund.completed',
31
- 'refund.failed',
32
30
  'invoice.created',
33
31
  'invoice.paid',
34
32
  'invoice.overdue',
35
- 'agent.action_executed',
36
33
  'agent.job_proposed',
37
34
  'agent.job_completed',
38
35
  'agent.job_disputed',