@strimz/shared-types 0.1.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.
- package/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/agents.cjs +148 -0
- package/dist/agents.cjs.map +1 -0
- package/dist/agents.d.cts +317 -0
- package/dist/agents.d.ts +317 -0
- package/dist/agents.js +137 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-keys.cjs +91 -0
- package/dist/api-keys.cjs.map +1 -0
- package/dist/api-keys.d.cts +155 -0
- package/dist/api-keys.d.ts +155 -0
- package/dist/api-keys.js +84 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/common.cjs +56 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +82 -0
- package/dist/common.d.ts +82 -0
- package/dist/common.js +37 -0
- package/dist/common.js.map +1 -0
- package/dist/compliance.cjs +61 -0
- package/dist/compliance.cjs.map +1 -0
- package/dist/compliance.d.cts +59 -0
- package/dist/compliance.d.ts +59 -0
- package/dist/compliance.js +56 -0
- package/dist/compliance.js.map +1 -0
- package/dist/customers.cjs +56 -0
- package/dist/customers.cjs.map +1 -0
- package/dist/customers.d.cts +64 -0
- package/dist/customers.d.ts +64 -0
- package/dist/customers.js +53 -0
- package/dist/customers.js.map +1 -0
- package/dist/events.cjs +675 -0
- package/dist/events.cjs.map +1 -0
- package/dist/events.d.cts +7907 -0
- package/dist/events.d.ts +7907 -0
- package/dist/events.js +650 -0
- package/dist/events.js.map +1 -0
- package/dist/index.cjs +976 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +113 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.js +858 -0
- package/dist/index.js.map +1 -0
- package/dist/invoices.cjs +72 -0
- package/dist/invoices.cjs.map +1 -0
- package/dist/invoices.d.cts +159 -0
- package/dist/invoices.d.ts +159 -0
- package/dist/invoices.js +67 -0
- package/dist/invoices.js.map +1 -0
- package/dist/merchants.cjs +104 -0
- package/dist/merchants.cjs.map +1 -0
- package/dist/merchants.d.cts +259 -0
- package/dist/merchants.d.ts +259 -0
- package/dist/merchants.js +93 -0
- package/dist/merchants.js.map +1 -0
- package/dist/payment-sessions.cjs +125 -0
- package/dist/payment-sessions.cjs.map +1 -0
- package/dist/payment-sessions.d.cts +180 -0
- package/dist/payment-sessions.d.ts +180 -0
- package/dist/payment-sessions.js +120 -0
- package/dist/payment-sessions.js.map +1 -0
- package/dist/refunds.cjs +81 -0
- package/dist/refunds.cjs.map +1 -0
- package/dist/refunds.d.cts +91 -0
- package/dist/refunds.d.ts +91 -0
- package/dist/refunds.js +75 -0
- package/dist/refunds.js.map +1 -0
- package/dist/storefronts.cjs +223 -0
- package/dist/storefronts.cjs.map +1 -0
- package/dist/storefronts.d.cts +177 -0
- package/dist/storefronts.d.ts +177 -0
- package/dist/storefronts.js +216 -0
- package/dist/storefronts.js.map +1 -0
- package/dist/subscriptions.cjs +175 -0
- package/dist/subscriptions.cjs.map +1 -0
- package/dist/subscriptions.d.cts +290 -0
- package/dist/subscriptions.d.ts +290 -0
- package/dist/subscriptions.js +163 -0
- package/dist/subscriptions.js.map +1 -0
- package/dist/transactions.cjs +67 -0
- package/dist/transactions.cjs.map +1 -0
- package/dist/transactions.d.cts +78 -0
- package/dist/transactions.d.ts +78 -0
- package/dist/transactions.js +63 -0
- package/dist/transactions.js.map +1 -0
- package/dist/webhooks.cjs +116 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +201 -0
- package/dist/webhooks.d.ts +201 -0
- package/dist/webhooks.js +107 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +134 -0
- package/src/agents.ts +149 -0
- package/src/api-keys.ts +78 -0
- package/src/common.ts +113 -0
- package/src/compliance.ts +40 -0
- package/src/customers.ts +40 -0
- package/src/events.ts +176 -0
- package/src/index.ts +23 -0
- package/src/invoices.ts +53 -0
- package/src/merchants.ts +104 -0
- package/src/payment-sessions.ts +131 -0
- package/src/refunds.ts +68 -0
- package/src/storefronts.ts +89 -0
- package/src/subscriptions.ts +180 -0
- package/src/tokens.ts +60 -0
- package/src/transactions.ts +52 -0
- package/src/webhooks.ts +109 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Webhook endpoints and deliveries.
|
|
5
|
+
*
|
|
6
|
+
* Endpoint = the URL the merchant registered.
|
|
7
|
+
* Event = the thing that happened.
|
|
8
|
+
* Delivery = one attempt to POST a specific event to a specific endpoint.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Every webhook event name in the system. Listed here (not imported from
|
|
13
|
+
* `@strimz/shared-config`) so Zod can produce a concrete string union.
|
|
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"]>;
|
|
16
|
+
type WebhookEventName = z.infer<typeof webhookEventNameSchema>;
|
|
17
|
+
declare const webhookEndpointStatusSchema: z.ZodEnum<["active", "disabled"]>;
|
|
18
|
+
type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>;
|
|
19
|
+
declare const webhookEndpointSchema: z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
merchantId: z.ZodString;
|
|
22
|
+
mode: z.ZodEnum<["test", "live"]>;
|
|
23
|
+
url: z.ZodEffects<z.ZodString, string, string>;
|
|
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">;
|
|
26
|
+
status: z.ZodEnum<["active", "disabled"]>;
|
|
27
|
+
signingSecretPrefix: z.ZodString;
|
|
28
|
+
lastDeliveredAt: z.ZodNullable<z.ZodString>;
|
|
29
|
+
createdAt: z.ZodString;
|
|
30
|
+
updatedAt: z.ZodString;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
status: "disabled" | "active";
|
|
33
|
+
id: string;
|
|
34
|
+
merchantId: string;
|
|
35
|
+
mode: "test" | "live";
|
|
36
|
+
createdAt: string;
|
|
37
|
+
description: string | null;
|
|
38
|
+
updatedAt: string;
|
|
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")[]];
|
|
41
|
+
signingSecretPrefix: string;
|
|
42
|
+
lastDeliveredAt: string | null;
|
|
43
|
+
}, {
|
|
44
|
+
status: "disabled" | "active";
|
|
45
|
+
id: string;
|
|
46
|
+
merchantId: string;
|
|
47
|
+
mode: "test" | "live";
|
|
48
|
+
createdAt: string;
|
|
49
|
+
description: string | null;
|
|
50
|
+
updatedAt: string;
|
|
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")[]];
|
|
53
|
+
signingSecretPrefix: string;
|
|
54
|
+
lastDeliveredAt: string | null;
|
|
55
|
+
}>;
|
|
56
|
+
type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>;
|
|
57
|
+
declare const createWebhookEndpointInputSchema: z.ZodObject<{
|
|
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">;
|
|
60
|
+
description: z.ZodOptional<z.ZodString>;
|
|
61
|
+
mode: z.ZodEnum<["test", "live"]>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
mode: "test" | "live";
|
|
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")[]];
|
|
66
|
+
description?: string | undefined;
|
|
67
|
+
}, {
|
|
68
|
+
mode: "test" | "live";
|
|
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")[]];
|
|
71
|
+
description?: string | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>;
|
|
74
|
+
declare const createWebhookEndpointOutputSchema: z.ZodObject<{
|
|
75
|
+
endpoint: z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
merchantId: z.ZodString;
|
|
78
|
+
mode: z.ZodEnum<["test", "live"]>;
|
|
79
|
+
url: z.ZodEffects<z.ZodString, string, string>;
|
|
80
|
+
description: z.ZodNullable<z.ZodString>;
|
|
81
|
+
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
|
+
status: z.ZodEnum<["active", "disabled"]>;
|
|
83
|
+
signingSecretPrefix: z.ZodString;
|
|
84
|
+
lastDeliveredAt: z.ZodNullable<z.ZodString>;
|
|
85
|
+
createdAt: z.ZodString;
|
|
86
|
+
updatedAt: z.ZodString;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
status: "disabled" | "active";
|
|
89
|
+
id: string;
|
|
90
|
+
merchantId: string;
|
|
91
|
+
mode: "test" | "live";
|
|
92
|
+
createdAt: string;
|
|
93
|
+
description: string | null;
|
|
94
|
+
updatedAt: string;
|
|
95
|
+
url: string;
|
|
96
|
+
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
|
+
signingSecretPrefix: string;
|
|
98
|
+
lastDeliveredAt: string | null;
|
|
99
|
+
}, {
|
|
100
|
+
status: "disabled" | "active";
|
|
101
|
+
id: string;
|
|
102
|
+
merchantId: string;
|
|
103
|
+
mode: "test" | "live";
|
|
104
|
+
createdAt: string;
|
|
105
|
+
description: string | null;
|
|
106
|
+
updatedAt: string;
|
|
107
|
+
url: string;
|
|
108
|
+
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
|
+
signingSecretPrefix: string;
|
|
110
|
+
lastDeliveredAt: string | null;
|
|
111
|
+
}>;
|
|
112
|
+
/** Full signing secret — shown exactly once. */
|
|
113
|
+
signingSecret: z.ZodString;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
endpoint: {
|
|
116
|
+
status: "disabled" | "active";
|
|
117
|
+
id: string;
|
|
118
|
+
merchantId: string;
|
|
119
|
+
mode: "test" | "live";
|
|
120
|
+
createdAt: string;
|
|
121
|
+
description: string | null;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
url: string;
|
|
124
|
+
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
|
+
signingSecretPrefix: string;
|
|
126
|
+
lastDeliveredAt: string | null;
|
|
127
|
+
};
|
|
128
|
+
signingSecret: string;
|
|
129
|
+
}, {
|
|
130
|
+
endpoint: {
|
|
131
|
+
status: "disabled" | "active";
|
|
132
|
+
id: string;
|
|
133
|
+
merchantId: string;
|
|
134
|
+
mode: "test" | "live";
|
|
135
|
+
createdAt: string;
|
|
136
|
+
description: string | null;
|
|
137
|
+
updatedAt: string;
|
|
138
|
+
url: string;
|
|
139
|
+
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
|
+
signingSecretPrefix: string;
|
|
141
|
+
lastDeliveredAt: string | null;
|
|
142
|
+
};
|
|
143
|
+
signingSecret: string;
|
|
144
|
+
}>;
|
|
145
|
+
type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>;
|
|
146
|
+
declare const webhookDeliveryStatusSchema: z.ZodEnum<["pending", "delivered", "retrying", "permanently_failed"]>;
|
|
147
|
+
type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>;
|
|
148
|
+
declare const webhookDeliverySchema: z.ZodObject<{
|
|
149
|
+
id: z.ZodString;
|
|
150
|
+
merchantId: z.ZodString;
|
|
151
|
+
endpointId: z.ZodString;
|
|
152
|
+
eventId: z.ZodString;
|
|
153
|
+
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
|
+
status: z.ZodEnum<["pending", "delivered", "retrying", "permanently_failed"]>;
|
|
155
|
+
attempt: z.ZodNumber;
|
|
156
|
+
responseCode: z.ZodNullable<z.ZodNumber>;
|
|
157
|
+
responseMs: z.ZodNullable<z.ZodNumber>;
|
|
158
|
+
lastError: z.ZodNullable<z.ZodString>;
|
|
159
|
+
nextAttemptAt: z.ZodNullable<z.ZodString>;
|
|
160
|
+
deliveredAt: z.ZodNullable<z.ZodString>;
|
|
161
|
+
createdAt: z.ZodString;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
status: "pending" | "retrying" | "delivered" | "permanently_failed";
|
|
164
|
+
id: string;
|
|
165
|
+
merchantId: string;
|
|
166
|
+
createdAt: string;
|
|
167
|
+
endpointId: string;
|
|
168
|
+
eventId: string;
|
|
169
|
+
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
|
+
attempt: number;
|
|
171
|
+
responseCode: number | null;
|
|
172
|
+
responseMs: number | null;
|
|
173
|
+
lastError: string | null;
|
|
174
|
+
nextAttemptAt: string | null;
|
|
175
|
+
deliveredAt: string | null;
|
|
176
|
+
}, {
|
|
177
|
+
status: "pending" | "retrying" | "delivered" | "permanently_failed";
|
|
178
|
+
id: string;
|
|
179
|
+
merchantId: string;
|
|
180
|
+
createdAt: string;
|
|
181
|
+
endpointId: string;
|
|
182
|
+
eventId: string;
|
|
183
|
+
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
|
+
attempt: number;
|
|
185
|
+
responseCode: number | null;
|
|
186
|
+
responseMs: number | null;
|
|
187
|
+
lastError: string | null;
|
|
188
|
+
nextAttemptAt: string | null;
|
|
189
|
+
deliveredAt: string | null;
|
|
190
|
+
}>;
|
|
191
|
+
type WebhookDelivery = z.infer<typeof webhookDeliverySchema>;
|
|
192
|
+
declare const replayDeliveryInputSchema: z.ZodObject<{
|
|
193
|
+
id: z.ZodString;
|
|
194
|
+
}, "strip", z.ZodTypeAny, {
|
|
195
|
+
id: string;
|
|
196
|
+
}, {
|
|
197
|
+
id: string;
|
|
198
|
+
}>;
|
|
199
|
+
type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>;
|
|
200
|
+
|
|
201
|
+
export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
|
package/dist/webhooks.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/webhooks.ts
|
|
4
|
+
var idSchema = z.string().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/, "id must be URL-safe");
|
|
5
|
+
z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a 0x-prefixed 40-character hex EVM address").transform((v) => v.toLowerCase());
|
|
6
|
+
z.string().regex(/^0x[a-fA-F0-9]{64}$/, "must be a 0x-prefixed 64-character hex EVM transaction hash");
|
|
7
|
+
z.string().email().trim().toLowerCase().max(320);
|
|
8
|
+
var httpsUrlSchema = z.string().url().refine((v) => v.startsWith("https://"), {
|
|
9
|
+
message: "must be an https:// URL"
|
|
10
|
+
});
|
|
11
|
+
z.string().url();
|
|
12
|
+
z.string().regex(/^[0-9]+$/, "must be a non-negative integer string (base-10)").refine((v) => BigInt(v) >= 0n, "must be >= 0");
|
|
13
|
+
z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
14
|
+
var isoTimestampSchema = z.string().datetime({ offset: true, message: "must be an ISO-8601 timestamp" });
|
|
15
|
+
z.string().length(2).regex(/^[A-Z]{2}$/, "must be an ISO-3166 alpha-2 country code");
|
|
16
|
+
z.object({
|
|
17
|
+
limit: z.number().int().min(1).max(100).default(25),
|
|
18
|
+
cursor: z.string().min(1).max(200).nullish()
|
|
19
|
+
});
|
|
20
|
+
z.record(
|
|
21
|
+
z.string().min(1).max(40),
|
|
22
|
+
z.union([z.string().max(500), z.number(), z.boolean(), z.null()])
|
|
23
|
+
).refine((m) => Object.keys(m).length <= 50, "at most 50 metadata keys").default({});
|
|
24
|
+
var modeSchema = z.enum(["test", "live"]);
|
|
25
|
+
z.enum(["USDC", "EURC"]);
|
|
26
|
+
z.enum(["USDC", "EURC", "USYC"]);
|
|
27
|
+
z.enum(["free", "growth", "business", "enterprise"]);
|
|
28
|
+
z.enum(["testnet", "mainnet"]);
|
|
29
|
+
|
|
30
|
+
// src/webhooks.ts
|
|
31
|
+
var webhookEventNameSchema = z.enum([
|
|
32
|
+
"payment.created",
|
|
33
|
+
"payment.completed",
|
|
34
|
+
"payment.failed",
|
|
35
|
+
"subscription.created",
|
|
36
|
+
"subscription.charged",
|
|
37
|
+
"subscription.charge_failed",
|
|
38
|
+
"subscription.recovery_attempt",
|
|
39
|
+
"subscription.recovery_outcome",
|
|
40
|
+
"subscription.cancelled",
|
|
41
|
+
"subscription.lapsed",
|
|
42
|
+
"refund.created",
|
|
43
|
+
"refund.completed",
|
|
44
|
+
"refund.failed",
|
|
45
|
+
"invoice.created",
|
|
46
|
+
"invoice.paid",
|
|
47
|
+
"invoice.overdue",
|
|
48
|
+
"agent.action_executed",
|
|
49
|
+
"agent.job_proposed",
|
|
50
|
+
"agent.job_completed",
|
|
51
|
+
"agent.job_disputed",
|
|
52
|
+
"compliance.wallet_flagged",
|
|
53
|
+
"compliance.wallet_blocked"
|
|
54
|
+
]);
|
|
55
|
+
var webhookEndpointStatusSchema = z.enum(["active", "disabled"]);
|
|
56
|
+
var webhookEndpointSchema = z.object({
|
|
57
|
+
id: idSchema,
|
|
58
|
+
merchantId: idSchema,
|
|
59
|
+
mode: modeSchema,
|
|
60
|
+
url: httpsUrlSchema,
|
|
61
|
+
description: z.string().max(200).nullable(),
|
|
62
|
+
events: z.array(webhookEventNameSchema).nonempty(),
|
|
63
|
+
status: webhookEndpointStatusSchema,
|
|
64
|
+
signingSecretPrefix: z.string().min(4).max(12),
|
|
65
|
+
lastDeliveredAt: isoTimestampSchema.nullable(),
|
|
66
|
+
createdAt: isoTimestampSchema,
|
|
67
|
+
updatedAt: isoTimestampSchema
|
|
68
|
+
});
|
|
69
|
+
var createWebhookEndpointInputSchema = z.object({
|
|
70
|
+
url: httpsUrlSchema,
|
|
71
|
+
events: z.array(webhookEventNameSchema).nonempty(),
|
|
72
|
+
description: z.string().max(200).optional(),
|
|
73
|
+
mode: modeSchema
|
|
74
|
+
});
|
|
75
|
+
var createWebhookEndpointOutputSchema = z.object({
|
|
76
|
+
endpoint: webhookEndpointSchema,
|
|
77
|
+
/** Full signing secret — shown exactly once. */
|
|
78
|
+
signingSecret: z.string()
|
|
79
|
+
});
|
|
80
|
+
var webhookDeliveryStatusSchema = z.enum([
|
|
81
|
+
"pending",
|
|
82
|
+
"delivered",
|
|
83
|
+
"retrying",
|
|
84
|
+
"permanently_failed"
|
|
85
|
+
]);
|
|
86
|
+
var webhookDeliverySchema = z.object({
|
|
87
|
+
id: idSchema,
|
|
88
|
+
merchantId: idSchema,
|
|
89
|
+
endpointId: idSchema,
|
|
90
|
+
eventId: idSchema,
|
|
91
|
+
eventName: webhookEventNameSchema,
|
|
92
|
+
status: webhookDeliveryStatusSchema,
|
|
93
|
+
attempt: z.number().int().min(1).max(6),
|
|
94
|
+
responseCode: z.number().int().min(100).max(599).nullable(),
|
|
95
|
+
responseMs: z.number().int().min(0).nullable(),
|
|
96
|
+
lastError: z.string().max(1e3).nullable(),
|
|
97
|
+
nextAttemptAt: isoTimestampSchema.nullable(),
|
|
98
|
+
deliveredAt: isoTimestampSchema.nullable(),
|
|
99
|
+
createdAt: isoTimestampSchema
|
|
100
|
+
});
|
|
101
|
+
var replayDeliveryInputSchema = z.object({
|
|
102
|
+
id: idSchema
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export { createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
|
|
106
|
+
//# sourceMappingURL=webhooks.js.map
|
|
107
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +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,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,CAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D;AAGlE,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAA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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;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 .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\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.infer<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 — mirrors `@strimz/shared-config`. */\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 — mirrors `@strimz/shared-config`. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', '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 here (not imported from\n * `@strimz/shared-config`) so Zod can 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.infer<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\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@strimz/shared-types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zod schemas and inferred TypeScript types for every Strimz platform entity, API input, and webhook event.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Strimz <hello@strimz.finance>",
|
|
7
|
+
"homepage": "https://github.com/StrimzLab/strimz/tree/main/packages/shared-types#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/StrimzLab/strimz.git",
|
|
11
|
+
"directory": "packages/shared-types"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/StrimzLab/strimz/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"strimz",
|
|
18
|
+
"zod",
|
|
19
|
+
"types",
|
|
20
|
+
"schemas",
|
|
21
|
+
"billing"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/index.cjs",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./common": {
|
|
38
|
+
"types": "./dist/common.d.ts",
|
|
39
|
+
"import": "./dist/common.js",
|
|
40
|
+
"require": "./dist/common.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./merchants": {
|
|
43
|
+
"types": "./dist/merchants.d.ts",
|
|
44
|
+
"import": "./dist/merchants.js",
|
|
45
|
+
"require": "./dist/merchants.cjs"
|
|
46
|
+
},
|
|
47
|
+
"./api-keys": {
|
|
48
|
+
"types": "./dist/api-keys.d.ts",
|
|
49
|
+
"import": "./dist/api-keys.js",
|
|
50
|
+
"require": "./dist/api-keys.cjs"
|
|
51
|
+
},
|
|
52
|
+
"./customers": {
|
|
53
|
+
"types": "./dist/customers.d.ts",
|
|
54
|
+
"import": "./dist/customers.js",
|
|
55
|
+
"require": "./dist/customers.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./payment-sessions": {
|
|
58
|
+
"types": "./dist/payment-sessions.d.ts",
|
|
59
|
+
"import": "./dist/payment-sessions.js",
|
|
60
|
+
"require": "./dist/payment-sessions.cjs"
|
|
61
|
+
},
|
|
62
|
+
"./transactions": {
|
|
63
|
+
"types": "./dist/transactions.d.ts",
|
|
64
|
+
"import": "./dist/transactions.js",
|
|
65
|
+
"require": "./dist/transactions.cjs"
|
|
66
|
+
},
|
|
67
|
+
"./subscriptions": {
|
|
68
|
+
"types": "./dist/subscriptions.d.ts",
|
|
69
|
+
"import": "./dist/subscriptions.js",
|
|
70
|
+
"require": "./dist/subscriptions.cjs"
|
|
71
|
+
},
|
|
72
|
+
"./refunds": {
|
|
73
|
+
"types": "./dist/refunds.d.ts",
|
|
74
|
+
"import": "./dist/refunds.js",
|
|
75
|
+
"require": "./dist/refunds.cjs"
|
|
76
|
+
},
|
|
77
|
+
"./webhooks": {
|
|
78
|
+
"types": "./dist/webhooks.d.ts",
|
|
79
|
+
"import": "./dist/webhooks.js",
|
|
80
|
+
"require": "./dist/webhooks.cjs"
|
|
81
|
+
},
|
|
82
|
+
"./compliance": {
|
|
83
|
+
"types": "./dist/compliance.d.ts",
|
|
84
|
+
"import": "./dist/compliance.js",
|
|
85
|
+
"require": "./dist/compliance.cjs"
|
|
86
|
+
},
|
|
87
|
+
"./agents": {
|
|
88
|
+
"types": "./dist/agents.d.ts",
|
|
89
|
+
"import": "./dist/agents.js",
|
|
90
|
+
"require": "./dist/agents.cjs"
|
|
91
|
+
},
|
|
92
|
+
"./storefronts": {
|
|
93
|
+
"types": "./dist/storefronts.d.ts",
|
|
94
|
+
"import": "./dist/storefronts.js",
|
|
95
|
+
"require": "./dist/storefronts.cjs"
|
|
96
|
+
},
|
|
97
|
+
"./invoices": {
|
|
98
|
+
"types": "./dist/invoices.d.ts",
|
|
99
|
+
"import": "./dist/invoices.js",
|
|
100
|
+
"require": "./dist/invoices.cjs"
|
|
101
|
+
},
|
|
102
|
+
"./events": {
|
|
103
|
+
"types": "./dist/events.d.ts",
|
|
104
|
+
"import": "./dist/events.js",
|
|
105
|
+
"require": "./dist/events.cjs"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"files": [
|
|
109
|
+
"dist",
|
|
110
|
+
"src",
|
|
111
|
+
"README.md",
|
|
112
|
+
"LICENSE"
|
|
113
|
+
],
|
|
114
|
+
"dependencies": {
|
|
115
|
+
"zod": "^3.24.1",
|
|
116
|
+
"@strimz/shared-config": "0.1.0"
|
|
117
|
+
},
|
|
118
|
+
"devDependencies": {
|
|
119
|
+
"eslint": "^9.18.0",
|
|
120
|
+
"tsup": "^8.3.5",
|
|
121
|
+
"typescript": "^5.7.3",
|
|
122
|
+
"vitest": "^2.1.8",
|
|
123
|
+
"@strimz/eslint-config": "0.0.0",
|
|
124
|
+
"@strimz/tsconfig": "0.0.0"
|
|
125
|
+
},
|
|
126
|
+
"scripts": {
|
|
127
|
+
"build": "tsup",
|
|
128
|
+
"dev": "tsup --watch",
|
|
129
|
+
"lint": "eslint .",
|
|
130
|
+
"typecheck": "tsc --noEmit",
|
|
131
|
+
"test": "vitest run --passWithNoTests",
|
|
132
|
+
"clean": "rm -rf dist .turbo *.tsbuildinfo"
|
|
133
|
+
}
|
|
134
|
+
}
|
package/src/agents.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI AutoPay Agent — identity, configuration, activity log, and ERC-8183 jobs.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod'
|
|
6
|
+
import {
|
|
7
|
+
evmAddressSchema,
|
|
8
|
+
evmTxHashSchema,
|
|
9
|
+
idSchema,
|
|
10
|
+
isoTimestampSchema,
|
|
11
|
+
metadataSchema,
|
|
12
|
+
tokenAmountSchema,
|
|
13
|
+
} from './common.js'
|
|
14
|
+
|
|
15
|
+
// ---------- Identity ----------
|
|
16
|
+
|
|
17
|
+
export const agentIdentitySchema = z.object({
|
|
18
|
+
id: idSchema,
|
|
19
|
+
/** ERC-8004 on-chain identity address. */
|
|
20
|
+
onchainAddress: evmAddressSchema,
|
|
21
|
+
/** Public key or agent credential digest, as emitted by ERC-8004. */
|
|
22
|
+
credentialDigest: z.string().regex(/^0x[a-fA-F0-9]+$/),
|
|
23
|
+
name: z.string().min(1).max(120),
|
|
24
|
+
version: z.string().min(1).max(40),
|
|
25
|
+
reputationScore: z.number().min(0).max(100).nullable(),
|
|
26
|
+
registeredAt: isoTimestampSchema,
|
|
27
|
+
})
|
|
28
|
+
export type AgentIdentity = z.infer<typeof agentIdentitySchema>
|
|
29
|
+
|
|
30
|
+
// ---------- Merchant config ----------
|
|
31
|
+
|
|
32
|
+
export const agentCapabilitySchema = z.enum([
|
|
33
|
+
'identity',
|
|
34
|
+
'recovery',
|
|
35
|
+
'routing',
|
|
36
|
+
'cashflow',
|
|
37
|
+
'commerce',
|
|
38
|
+
'pricing_intelligence',
|
|
39
|
+
])
|
|
40
|
+
export type AgentCapability = z.infer<typeof agentCapabilitySchema>
|
|
41
|
+
|
|
42
|
+
export const agentMerchantConfigSchema = z.object({
|
|
43
|
+
merchantId: idSchema,
|
|
44
|
+
enabledCapabilities: z.array(agentCapabilitySchema).default([]),
|
|
45
|
+
recovery: z.object({
|
|
46
|
+
gracePeriodHours: z.union([z.literal(24), z.literal(48), z.literal(72)]).default(48),
|
|
47
|
+
strategy: z.enum(['once', 'twice', 'until_grace_ends']).default('twice'),
|
|
48
|
+
notificationTemplate: z.string().max(2000).nullable(),
|
|
49
|
+
}),
|
|
50
|
+
cashflow: z.object({
|
|
51
|
+
digestEnabled: z.boolean().default(false),
|
|
52
|
+
anomalySensitivity: z.enum(['low', 'medium', 'high']).default('medium'),
|
|
53
|
+
autoConvertToYield: z.boolean().default(false),
|
|
54
|
+
minimumLiquidReserveCents: z.number().int().nonnegative().default(100_000),
|
|
55
|
+
}),
|
|
56
|
+
commerce: z.object({
|
|
57
|
+
requireHumanApprovalAboveUsdCents: z.number().int().nonnegative().default(100_000),
|
|
58
|
+
approvedVendors: z.array(evmAddressSchema).default([]),
|
|
59
|
+
monthlySpendCapUsdCents: z.number().int().nonnegative().nullable(),
|
|
60
|
+
}),
|
|
61
|
+
updatedAt: isoTimestampSchema,
|
|
62
|
+
})
|
|
63
|
+
export type AgentMerchantConfig = z.infer<typeof agentMerchantConfigSchema>
|
|
64
|
+
|
|
65
|
+
export const updateAgentConfigInputSchema = agentMerchantConfigSchema
|
|
66
|
+
.omit({ merchantId: true, updatedAt: true })
|
|
67
|
+
.partial()
|
|
68
|
+
export type UpdateAgentConfigInput = z.infer<typeof updateAgentConfigInputSchema>
|
|
69
|
+
|
|
70
|
+
// ---------- Activity log ----------
|
|
71
|
+
|
|
72
|
+
export const agentActionTypeSchema = z.enum([
|
|
73
|
+
'recovery_notification_sent',
|
|
74
|
+
'recovery_retry_scheduled',
|
|
75
|
+
'recovery_retry_executed',
|
|
76
|
+
'recovery_abandoned',
|
|
77
|
+
'routing_bridge_initiated',
|
|
78
|
+
'routing_payment_completed',
|
|
79
|
+
'cashflow_digest_sent',
|
|
80
|
+
'cashflow_anomaly_flagged',
|
|
81
|
+
'cashflow_yield_converted',
|
|
82
|
+
'commerce_job_created',
|
|
83
|
+
'commerce_job_approved',
|
|
84
|
+
'commerce_job_completed',
|
|
85
|
+
'commerce_job_disputed',
|
|
86
|
+
])
|
|
87
|
+
export type AgentActionType = z.infer<typeof agentActionTypeSchema>
|
|
88
|
+
|
|
89
|
+
export const agentActionOutcomeSchema = z.enum(['success', 'failure', 'pending', 'skipped'])
|
|
90
|
+
export type AgentActionOutcome = z.infer<typeof agentActionOutcomeSchema>
|
|
91
|
+
|
|
92
|
+
export const agentActivityLogSchema = z.object({
|
|
93
|
+
id: idSchema,
|
|
94
|
+
merchantId: idSchema,
|
|
95
|
+
capability: agentCapabilitySchema,
|
|
96
|
+
actionType: agentActionTypeSchema,
|
|
97
|
+
outcome: agentActionOutcomeSchema,
|
|
98
|
+
subscriptionId: idSchema.nullable(),
|
|
99
|
+
transactionId: idSchema.nullable(),
|
|
100
|
+
jobId: idSchema.nullable(),
|
|
101
|
+
metadata: metadataSchema,
|
|
102
|
+
createdAt: isoTimestampSchema,
|
|
103
|
+
})
|
|
104
|
+
export type AgentActivityLog = z.infer<typeof agentActivityLogSchema>
|
|
105
|
+
|
|
106
|
+
// ---------- ERC-8183 jobs ----------
|
|
107
|
+
|
|
108
|
+
export const agentJobStatusSchema = z.enum([
|
|
109
|
+
'proposed',
|
|
110
|
+
'accepted',
|
|
111
|
+
'in_progress',
|
|
112
|
+
'delivered',
|
|
113
|
+
'approved',
|
|
114
|
+
'completed',
|
|
115
|
+
'disputed',
|
|
116
|
+
'cancelled',
|
|
117
|
+
])
|
|
118
|
+
export type AgentJobStatus = z.infer<typeof agentJobStatusSchema>
|
|
119
|
+
|
|
120
|
+
export const agentJobSchema = z.object({
|
|
121
|
+
id: idSchema,
|
|
122
|
+
merchantId: idSchema,
|
|
123
|
+
/** On-chain job id from StrimzAgentEscrow. */
|
|
124
|
+
onchainJobId: z.number().int().nonnegative().nullable(),
|
|
125
|
+
vendorAddress: evmAddressSchema,
|
|
126
|
+
description: z.string().min(1).max(2000),
|
|
127
|
+
amount: tokenAmountSchema,
|
|
128
|
+
currency: z.enum(['USDC', 'EURC']),
|
|
129
|
+
status: agentJobStatusSchema,
|
|
130
|
+
assessorAddress: evmAddressSchema,
|
|
131
|
+
deliverableHash: z
|
|
132
|
+
.string()
|
|
133
|
+
.regex(/^0x[a-fA-F0-9]+$/)
|
|
134
|
+
.nullable(),
|
|
135
|
+
escrowTxHash: evmTxHashSchema.nullable(),
|
|
136
|
+
releaseTxHash: evmTxHashSchema.nullable(),
|
|
137
|
+
createdAt: isoTimestampSchema,
|
|
138
|
+
completedAt: isoTimestampSchema.nullable(),
|
|
139
|
+
})
|
|
140
|
+
export type AgentJob = z.infer<typeof agentJobSchema>
|
|
141
|
+
|
|
142
|
+
export const createAgentJobInputSchema = z.object({
|
|
143
|
+
vendorAddress: evmAddressSchema,
|
|
144
|
+
description: z.string().min(1).max(2000),
|
|
145
|
+
amount: tokenAmountSchema,
|
|
146
|
+
currency: z.enum(['USDC', 'EURC']),
|
|
147
|
+
assessorAddress: evmAddressSchema.optional(),
|
|
148
|
+
})
|
|
149
|
+
export type CreateAgentJobInput = z.infer<typeof createAgentJobInputSchema>
|