@stewardhq/sdk 0.1.0-rc.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/README.md +437 -0
- package/dist/_chunks/errors.js +73 -0
- package/dist/_chunks/events.d.ts +537 -0
- package/dist/_chunks/events.js +350 -0
- package/dist/_chunks/index.d.ts +6005 -0
- package/dist/_chunks/locale.d.ts +17 -0
- package/dist/_chunks/locale.js +17 -0
- package/dist/_chunks/src.js +1202 -0
- package/dist/_chunks/steward.d.ts +2588 -0
- package/dist/_chunks/steward.js +578 -0
- package/dist/_chunks/validators.d.ts +23 -0
- package/dist/_chunks/validators.js +106 -0
- package/dist/_chunks/webhook-core.d.ts +32 -0
- package/dist/_chunks/webhook-core.js +64 -0
- package/dist/_chunks/webhook.d.ts +22 -0
- package/dist/_chunks/webhook.js +53 -0
- package/dist/contract.d.ts +4 -0
- package/dist/contract.js +4 -0
- package/dist/index.d.ts +268 -0
- package/dist/index.js +784 -0
- package/dist/server.d.ts +236 -0
- package/dist/server.js +384 -0
- package/dist/testing/fixtures/events/LOCK.json +27 -0
- package/dist/testing/fixtures/events/account.deleted.json +36 -0
- package/dist/testing/fixtures/events/account.state_changed.json +53 -0
- package/dist/testing/fixtures/events/account.updated.json +37 -0
- package/dist/testing/fixtures/events/checkout.completed.json +36 -0
- package/dist/testing/fixtures/events/checkout.expired.json +26 -0
- package/dist/testing/fixtures/events/checkout.failed.json +27 -0
- package/dist/testing/fixtures/events/invoice.created.json +37 -0
- package/dist/testing/fixtures/events/invoice.issued.json +38 -0
- package/dist/testing/fixtures/events/invoice.voided.json +39 -0
- package/dist/testing/fixtures/events/subscription.activated.json +40 -0
- package/dist/testing/fixtures/events/subscription.cancel_scheduled.json +38 -0
- package/dist/testing/fixtures/events/subscription.canceled.json +29 -0
- package/dist/testing/fixtures/events/subscription.expired.json +27 -0
- package/dist/testing/fixtures/events/subscription.payment_failed.json +38 -0
- package/dist/testing/fixtures/events/subscription.reactivated.json +36 -0
- package/dist/testing/fixtures/events/subscription.renewed.json +39 -0
- package/dist/testing/fixtures/events/subscription.suspended.json +36 -0
- package/dist/testing/fixtures/events/subscription.terminated.json +28 -0
- package/dist/testing.d.ts +629 -0
- package/dist/testing.js +3759 -0
- package/dist/webhook/web.d.ts +17 -0
- package/dist/webhook/web.js +66 -0
- package/dist/webhook.d.ts +3 -0
- package/dist/webhook.js +3 -0
- package/package.json +70 -0
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region ../contract/src/accounts.d.ts
|
|
3
|
+
declare const AccountUpsertInputSchema: z.ZodObject<{
|
|
4
|
+
displayName: z.ZodString;
|
|
5
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
type AccountUpsertInput = z.input<typeof AccountUpsertInputSchema>;
|
|
8
|
+
declare const BillingProfileKindSchema: z.ZodEnum<{
|
|
9
|
+
individual: "individual";
|
|
10
|
+
company: "company";
|
|
11
|
+
}>;
|
|
12
|
+
declare const BillingProfileSchema: z.ZodObject<{
|
|
13
|
+
kind: z.ZodEnum<{
|
|
14
|
+
individual: "individual";
|
|
15
|
+
company: "company";
|
|
16
|
+
}>;
|
|
17
|
+
contactName: z.ZodString;
|
|
18
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
19
|
+
taxOffice: z.ZodOptional<z.ZodString>;
|
|
20
|
+
taxId: z.ZodOptional<z.ZodString>;
|
|
21
|
+
email: z.ZodEmail;
|
|
22
|
+
phone: z.ZodString;
|
|
23
|
+
address: z.ZodString;
|
|
24
|
+
city: z.ZodString;
|
|
25
|
+
country: z.ZodDefault<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
type BillingProfile = z.output<typeof BillingProfileSchema>;
|
|
28
|
+
type BillingProfileInput = z.input<typeof BillingProfileSchema>;
|
|
29
|
+
declare const AccessStateSchema: z.ZodEnum<{
|
|
30
|
+
active: "active";
|
|
31
|
+
suspended: "suspended";
|
|
32
|
+
}>;
|
|
33
|
+
type AccessState = z.infer<typeof AccessStateSchema>;
|
|
34
|
+
declare const SubscriptionStatusSchema: z.ZodEnum<{
|
|
35
|
+
active: "active";
|
|
36
|
+
suspended: "suspended";
|
|
37
|
+
past_due: "past_due";
|
|
38
|
+
canceled: "canceled";
|
|
39
|
+
expired: "expired";
|
|
40
|
+
}>;
|
|
41
|
+
type SubscriptionStatus = z.infer<typeof SubscriptionStatusSchema>;
|
|
42
|
+
/** Snapshot içindeki canlı abonelik özeti (yoksa null). */
|
|
43
|
+
declare const SubscriptionSummarySchema: z.ZodObject<{
|
|
44
|
+
id: z.ZodUUID;
|
|
45
|
+
status: z.ZodEnum<{
|
|
46
|
+
active: "active";
|
|
47
|
+
suspended: "suspended";
|
|
48
|
+
past_due: "past_due";
|
|
49
|
+
canceled: "canceled";
|
|
50
|
+
expired: "expired";
|
|
51
|
+
}>;
|
|
52
|
+
planCode: z.ZodString;
|
|
53
|
+
interval: z.ZodEnum<{
|
|
54
|
+
month: "month";
|
|
55
|
+
year: "year";
|
|
56
|
+
}>;
|
|
57
|
+
amountMinor: z.ZodNumber;
|
|
58
|
+
currency: z.ZodString;
|
|
59
|
+
currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
|
|
60
|
+
cancelAt: z.ZodNullable<z.ZodISODateTime>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
type SubscriptionSummary = z.infer<typeof SubscriptionSummarySchema>;
|
|
63
|
+
declare const EntitlementSnapshotSchema: z.ZodObject<{
|
|
64
|
+
version: z.ZodNumber;
|
|
65
|
+
planCode: z.ZodString;
|
|
66
|
+
accessState: z.ZodEnum<{
|
|
67
|
+
active: "active";
|
|
68
|
+
suspended: "suspended";
|
|
69
|
+
}>;
|
|
70
|
+
entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
|
|
71
|
+
subscription: z.ZodNullable<z.ZodObject<{
|
|
72
|
+
id: z.ZodUUID;
|
|
73
|
+
status: z.ZodEnum<{
|
|
74
|
+
active: "active";
|
|
75
|
+
suspended: "suspended";
|
|
76
|
+
past_due: "past_due";
|
|
77
|
+
canceled: "canceled";
|
|
78
|
+
expired: "expired";
|
|
79
|
+
}>;
|
|
80
|
+
planCode: z.ZodString;
|
|
81
|
+
interval: z.ZodEnum<{
|
|
82
|
+
month: "month";
|
|
83
|
+
year: "year";
|
|
84
|
+
}>;
|
|
85
|
+
amountMinor: z.ZodNumber;
|
|
86
|
+
currency: z.ZodString;
|
|
87
|
+
currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
|
|
88
|
+
cancelAt: z.ZodNullable<z.ZodISODateTime>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
type EntitlementSnapshot = z.infer<typeof EntitlementSnapshotSchema>;
|
|
92
|
+
/** Dunning'deki aboneliğin adımı. `step` tamamlanan politika adımı sayısı (başlangıçta 0). */
|
|
93
|
+
declare const AccountDunningStateSchema: z.ZodObject<{
|
|
94
|
+
step: z.ZodNumber;
|
|
95
|
+
nextActionAt: z.ZodNullable<z.ZodISODateTime>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
type AccountDunningState = z.infer<typeof AccountDunningStateSchema>;
|
|
98
|
+
/** Dönem sonunda uygulanacak plan değişikliği. F4b'ye kadar her zaman null. */
|
|
99
|
+
declare const AccountScheduledChangeSchema: z.ZodObject<{
|
|
100
|
+
planCode: z.ZodString;
|
|
101
|
+
interval: z.ZodEnum<{
|
|
102
|
+
month: "month";
|
|
103
|
+
year: "year";
|
|
104
|
+
}>;
|
|
105
|
+
effectiveAt: z.ZodISODateTime;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
type AccountScheduledChange = z.infer<typeof AccountScheduledChangeSchema>;
|
|
108
|
+
declare const AccountSubscriptionStateSchema: z.ZodObject<{
|
|
109
|
+
id: z.ZodUUID;
|
|
110
|
+
status: z.ZodEnum<{
|
|
111
|
+
active: "active";
|
|
112
|
+
suspended: "suspended";
|
|
113
|
+
past_due: "past_due";
|
|
114
|
+
canceled: "canceled";
|
|
115
|
+
expired: "expired";
|
|
116
|
+
}>;
|
|
117
|
+
planCode: z.ZodString;
|
|
118
|
+
interval: z.ZodEnum<{
|
|
119
|
+
month: "month";
|
|
120
|
+
year: "year";
|
|
121
|
+
}>;
|
|
122
|
+
amountMinor: z.ZodNumber;
|
|
123
|
+
currency: z.ZodString;
|
|
124
|
+
currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
|
|
125
|
+
cancelAt: z.ZodNullable<z.ZodISODateTime>;
|
|
126
|
+
cancelAtPeriodEnd: z.ZodBoolean;
|
|
127
|
+
pastDueSince: z.ZodNullable<z.ZodISODateTime>;
|
|
128
|
+
currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
|
|
129
|
+
dunning: z.ZodNullable<z.ZodObject<{
|
|
130
|
+
step: z.ZodNumber;
|
|
131
|
+
nextActionAt: z.ZodNullable<z.ZodISODateTime>;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
scheduledChange: z.ZodNullable<z.ZodObject<{
|
|
134
|
+
planCode: z.ZodString;
|
|
135
|
+
interval: z.ZodEnum<{
|
|
136
|
+
month: "month";
|
|
137
|
+
year: "year";
|
|
138
|
+
}>;
|
|
139
|
+
effectiveAt: z.ZodISODateTime;
|
|
140
|
+
}, z.core.$strip>>;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
type AccountSubscriptionState = z.infer<typeof AccountSubscriptionStateSchema>;
|
|
143
|
+
/** Hesabın açık (tamamlanmamış, süresi dolmamış) checkout oturumu. */
|
|
144
|
+
declare const AccountOpenCheckoutSchema: z.ZodObject<{
|
|
145
|
+
id: z.ZodUUID;
|
|
146
|
+
planCode: z.ZodString;
|
|
147
|
+
interval: z.ZodEnum<{
|
|
148
|
+
month: "month";
|
|
149
|
+
year: "year";
|
|
150
|
+
}>;
|
|
151
|
+
intervalCount: z.ZodNumber;
|
|
152
|
+
currency: z.ZodString;
|
|
153
|
+
amountMinor: z.ZodNumber;
|
|
154
|
+
expiresAt: z.ZodISODateTime;
|
|
155
|
+
}, z.core.$strip>;
|
|
156
|
+
type AccountOpenCheckout = z.infer<typeof AccountOpenCheckoutSchema>;
|
|
157
|
+
/** Fatura profili özeti: yalnızca var mı ve türü (alanlar PII, burada yok). */
|
|
158
|
+
declare const AccountProfileStateSchema: z.ZodObject<{
|
|
159
|
+
present: z.ZodBoolean;
|
|
160
|
+
kind: z.ZodNullable<z.ZodEnum<{
|
|
161
|
+
individual: "individual";
|
|
162
|
+
company: "company";
|
|
163
|
+
}>>;
|
|
164
|
+
}, z.core.$strip>;
|
|
165
|
+
type AccountProfileState = z.infer<typeof AccountProfileStateSchema>;
|
|
166
|
+
declare const AccountStateSchema: z.ZodObject<{
|
|
167
|
+
version: z.ZodNumber;
|
|
168
|
+
planCode: z.ZodString;
|
|
169
|
+
accessState: z.ZodEnum<{
|
|
170
|
+
active: "active";
|
|
171
|
+
suspended: "suspended";
|
|
172
|
+
}>;
|
|
173
|
+
entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
|
|
174
|
+
ref: z.ZodString;
|
|
175
|
+
displayName: z.ZodString;
|
|
176
|
+
updatedAt: z.ZodISODateTime;
|
|
177
|
+
catalogVersion: z.ZodNullable<z.ZodString>;
|
|
178
|
+
subscription: z.ZodNullable<z.ZodObject<{
|
|
179
|
+
id: z.ZodUUID;
|
|
180
|
+
status: z.ZodEnum<{
|
|
181
|
+
active: "active";
|
|
182
|
+
suspended: "suspended";
|
|
183
|
+
past_due: "past_due";
|
|
184
|
+
canceled: "canceled";
|
|
185
|
+
expired: "expired";
|
|
186
|
+
}>;
|
|
187
|
+
planCode: z.ZodString;
|
|
188
|
+
interval: z.ZodEnum<{
|
|
189
|
+
month: "month";
|
|
190
|
+
year: "year";
|
|
191
|
+
}>;
|
|
192
|
+
amountMinor: z.ZodNumber;
|
|
193
|
+
currency: z.ZodString;
|
|
194
|
+
currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
|
|
195
|
+
cancelAt: z.ZodNullable<z.ZodISODateTime>;
|
|
196
|
+
cancelAtPeriodEnd: z.ZodBoolean;
|
|
197
|
+
pastDueSince: z.ZodNullable<z.ZodISODateTime>;
|
|
198
|
+
currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
|
|
199
|
+
dunning: z.ZodNullable<z.ZodObject<{
|
|
200
|
+
step: z.ZodNumber;
|
|
201
|
+
nextActionAt: z.ZodNullable<z.ZodISODateTime>;
|
|
202
|
+
}, z.core.$strip>>;
|
|
203
|
+
scheduledChange: z.ZodNullable<z.ZodObject<{
|
|
204
|
+
planCode: z.ZodString;
|
|
205
|
+
interval: z.ZodEnum<{
|
|
206
|
+
month: "month";
|
|
207
|
+
year: "year";
|
|
208
|
+
}>;
|
|
209
|
+
effectiveAt: z.ZodISODateTime;
|
|
210
|
+
}, z.core.$strip>>;
|
|
211
|
+
}, z.core.$strip>>;
|
|
212
|
+
openCheckout: z.ZodNullable<z.ZodObject<{
|
|
213
|
+
id: z.ZodUUID;
|
|
214
|
+
planCode: z.ZodString;
|
|
215
|
+
interval: z.ZodEnum<{
|
|
216
|
+
month: "month";
|
|
217
|
+
year: "year";
|
|
218
|
+
}>;
|
|
219
|
+
intervalCount: z.ZodNumber;
|
|
220
|
+
currency: z.ZodString;
|
|
221
|
+
amountMinor: z.ZodNumber;
|
|
222
|
+
expiresAt: z.ZodISODateTime;
|
|
223
|
+
}, z.core.$strip>>;
|
|
224
|
+
profile: z.ZodObject<{
|
|
225
|
+
present: z.ZodBoolean;
|
|
226
|
+
kind: z.ZodNullable<z.ZodEnum<{
|
|
227
|
+
individual: "individual";
|
|
228
|
+
company: "company";
|
|
229
|
+
}>>;
|
|
230
|
+
}, z.core.$strip>;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
type AccountState = z.infer<typeof AccountStateSchema>;
|
|
233
|
+
declare const AccountSchema: z.ZodObject<{
|
|
234
|
+
ref: z.ZodString;
|
|
235
|
+
displayName: z.ZodString;
|
|
236
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
237
|
+
createdAt: z.ZodISODateTime;
|
|
238
|
+
snapshot: z.ZodObject<{
|
|
239
|
+
version: z.ZodNumber;
|
|
240
|
+
planCode: z.ZodString;
|
|
241
|
+
accessState: z.ZodEnum<{
|
|
242
|
+
active: "active";
|
|
243
|
+
suspended: "suspended";
|
|
244
|
+
}>;
|
|
245
|
+
entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
|
|
246
|
+
subscription: z.ZodNullable<z.ZodObject<{
|
|
247
|
+
id: z.ZodUUID;
|
|
248
|
+
status: z.ZodEnum<{
|
|
249
|
+
active: "active";
|
|
250
|
+
suspended: "suspended";
|
|
251
|
+
past_due: "past_due";
|
|
252
|
+
canceled: "canceled";
|
|
253
|
+
expired: "expired";
|
|
254
|
+
}>;
|
|
255
|
+
planCode: z.ZodString;
|
|
256
|
+
interval: z.ZodEnum<{
|
|
257
|
+
month: "month";
|
|
258
|
+
year: "year";
|
|
259
|
+
}>;
|
|
260
|
+
amountMinor: z.ZodNumber;
|
|
261
|
+
currency: z.ZodString;
|
|
262
|
+
currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
|
|
263
|
+
cancelAt: z.ZodNullable<z.ZodISODateTime>;
|
|
264
|
+
}, z.core.$strip>>;
|
|
265
|
+
}, z.core.$strip>;
|
|
266
|
+
}, z.core.$strip>;
|
|
267
|
+
type Account = z.infer<typeof AccountSchema>;
|
|
268
|
+
declare const AccountDeleteResponseSchema: z.ZodObject<{
|
|
269
|
+
ref: z.ZodString;
|
|
270
|
+
deletedAt: z.ZodISODateTime;
|
|
271
|
+
}, z.core.$strip>;
|
|
272
|
+
type AccountDeleteResponse = z.infer<typeof AccountDeleteResponseSchema>;
|
|
273
|
+
declare const ACCOUNT_INCLUDES: readonly ["profile", "subscriptions", "checkouts", "payments", "invoices", "grants"];
|
|
274
|
+
type AccountInclude = (typeof ACCOUNT_INCLUDES)[number];
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region ../contract/src/events.d.ts
|
|
277
|
+
declare const EventIdSchema: z.ZodString;
|
|
278
|
+
declare const ApiVersionSchema: z.ZodString;
|
|
279
|
+
declare const EVENT_DETAIL_SCHEMAS: {
|
|
280
|
+
readonly "account.updated": z.ZodObject<{
|
|
281
|
+
changed: z.ZodArray<z.ZodString>;
|
|
282
|
+
}, z.core.$strip>;
|
|
283
|
+
readonly "checkout.completed": z.ZodObject<{
|
|
284
|
+
subscriptionId: z.ZodUUID;
|
|
285
|
+
checkoutSessionId: z.ZodUUID;
|
|
286
|
+
}, z.core.$strip>;
|
|
287
|
+
readonly "checkout.failed": z.ZodObject<{
|
|
288
|
+
checkoutSessionId: z.ZodUUID;
|
|
289
|
+
reason: z.ZodString;
|
|
290
|
+
}, z.core.$strip>;
|
|
291
|
+
readonly "checkout.expired": z.ZodObject<{
|
|
292
|
+
checkoutSessionId: z.ZodUUID;
|
|
293
|
+
}, z.core.$strip>;
|
|
294
|
+
readonly "subscription.activated": z.ZodObject<{
|
|
295
|
+
planCode: z.ZodString;
|
|
296
|
+
interval: z.ZodEnum<{
|
|
297
|
+
month: "month";
|
|
298
|
+
year: "year";
|
|
299
|
+
}>;
|
|
300
|
+
amountMinor: z.ZodNumber;
|
|
301
|
+
currency: z.ZodString;
|
|
302
|
+
actorRef: z.ZodNullable<z.ZodString>;
|
|
303
|
+
subscriptionId: z.ZodUUID;
|
|
304
|
+
}, z.core.$strip>;
|
|
305
|
+
readonly "subscription.renewed": z.ZodObject<{
|
|
306
|
+
paymentId: z.ZodUUID;
|
|
307
|
+
periodStart: z.ZodNullable<z.ZodISODateTime>;
|
|
308
|
+
periodEnd: z.ZodNullable<z.ZodISODateTime>;
|
|
309
|
+
invoiceId: z.ZodNullable<z.ZodUUID>;
|
|
310
|
+
subscriptionId: z.ZodUUID;
|
|
311
|
+
}, z.core.$strip>;
|
|
312
|
+
readonly "subscription.payment_failed": z.ZodObject<{
|
|
313
|
+
paymentId: z.ZodNullable<z.ZodUUID>;
|
|
314
|
+
attempt: z.ZodNumber;
|
|
315
|
+
nextRetryAt: z.ZodNullable<z.ZodISODateTime>;
|
|
316
|
+
subscriptionId: z.ZodUUID;
|
|
317
|
+
}, z.core.$strip>;
|
|
318
|
+
readonly "subscription.suspended": z.ZodObject<{
|
|
319
|
+
dunningDay: z.ZodNumber;
|
|
320
|
+
subscriptionId: z.ZodUUID;
|
|
321
|
+
}, z.core.$strip>;
|
|
322
|
+
readonly "subscription.reactivated": z.ZodObject<{
|
|
323
|
+
paymentId: z.ZodNullable<z.ZodUUID>;
|
|
324
|
+
subscriptionId: z.ZodUUID;
|
|
325
|
+
}, z.core.$strip>;
|
|
326
|
+
readonly "subscription.cancel_scheduled": z.ZodObject<{
|
|
327
|
+
cancelAt: z.ZodISODateTime;
|
|
328
|
+
reason: z.ZodString;
|
|
329
|
+
actorRef: z.ZodNullable<z.ZodString>;
|
|
330
|
+
subscriptionId: z.ZodUUID;
|
|
331
|
+
}, z.core.$strip>;
|
|
332
|
+
readonly "subscription.canceled": z.ZodObject<{
|
|
333
|
+
reason: z.ZodString;
|
|
334
|
+
effectiveAt: z.ZodISODateTime;
|
|
335
|
+
actorRef: z.ZodNullable<z.ZodString>;
|
|
336
|
+
subscriptionId: z.ZodUUID;
|
|
337
|
+
}, z.core.$strip>;
|
|
338
|
+
readonly "subscription.expired": z.ZodObject<{
|
|
339
|
+
effectiveAt: z.ZodISODateTime;
|
|
340
|
+
subscriptionId: z.ZodUUID;
|
|
341
|
+
}, z.core.$strip>;
|
|
342
|
+
readonly "subscription.terminated": z.ZodObject<{
|
|
343
|
+
reason: z.ZodEnum<{
|
|
344
|
+
nonpayment: "nonpayment";
|
|
345
|
+
}>;
|
|
346
|
+
dunningDay: z.ZodNumber;
|
|
347
|
+
subscriptionId: z.ZodUUID;
|
|
348
|
+
}, z.core.$strip>;
|
|
349
|
+
readonly "invoice.created": z.ZodObject<{
|
|
350
|
+
invoiceId: z.ZodUUID;
|
|
351
|
+
totalMinor: z.ZodNumber;
|
|
352
|
+
currency: z.ZodString;
|
|
353
|
+
}, z.core.$strip>;
|
|
354
|
+
readonly "invoice.issued": z.ZodObject<{
|
|
355
|
+
invoiceId: z.ZodUUID;
|
|
356
|
+
number: z.ZodString;
|
|
357
|
+
totalMinor: z.ZodNumber;
|
|
358
|
+
currency: z.ZodString;
|
|
359
|
+
}, z.core.$strip>;
|
|
360
|
+
readonly "invoice.voided": z.ZodObject<{
|
|
361
|
+
invoiceId: z.ZodUUID;
|
|
362
|
+
number: z.ZodNullable<z.ZodString>;
|
|
363
|
+
totalMinor: z.ZodNumber;
|
|
364
|
+
currency: z.ZodString;
|
|
365
|
+
reason: z.ZodString;
|
|
366
|
+
}, z.core.$strip>;
|
|
367
|
+
readonly "account.state_changed": z.ZodObject<{
|
|
368
|
+
cause: z.ZodString;
|
|
369
|
+
causeEventId: z.ZodNullable<z.ZodString>;
|
|
370
|
+
}, z.core.$strip>;
|
|
371
|
+
readonly "account.deleted": z.ZodObject<{
|
|
372
|
+
deletedAt: z.ZodISODateTime;
|
|
373
|
+
actorRef: z.ZodNullable<z.ZodString>;
|
|
374
|
+
}, z.core.$strip>;
|
|
375
|
+
};
|
|
376
|
+
type EventType = keyof typeof EVENT_DETAIL_SCHEMAS;
|
|
377
|
+
/** Tüm event tipleri (yenileri dahil). */
|
|
378
|
+
declare const EVENT_TYPES: EventType[];
|
|
379
|
+
/**
|
|
380
|
+
* 0.1 sözleşmesinin 15 tipi: `event_types` filtresi olmayan (NULL) endpoint'in
|
|
381
|
+
* aldığı küme. Değişmez; yeni tip buraya EKLENMEZ.
|
|
382
|
+
*/
|
|
383
|
+
declare const LEGACY_EVENT_TYPES: readonly ["account.updated", "checkout.completed", "checkout.failed", "checkout.expired", "subscription.activated", "subscription.renewed", "subscription.payment_failed", "subscription.suspended", "subscription.reactivated", "subscription.cancel_scheduled", "subscription.canceled", "subscription.expired", "subscription.terminated", "invoice.created", "invoice.issued"];
|
|
384
|
+
type LegacyEventType = (typeof LEGACY_EVENT_TYPES)[number];
|
|
385
|
+
/** `account.state_changed.detail.cause` — bilinen değerler; küme açık. */
|
|
386
|
+
type AccountStateChangeCause = LegacyEventType | "account.upserted" | "billing_profile.updated" | "checkout.opened" | "checkout.initialize_failed" | "checkout.canceled" | "grant.created" | "grant.revoked" | "grant.window_applied" | "dunning.advanced" | "dunning_policy.updated" | "payment.recorded" | "catalog.synced" | "account.refreshed" | "grant.plan_set" | "resync" | "account.deleted" | (string & Record<never, never>);
|
|
387
|
+
type FullStateEventType = "account.state_changed" | "account.deleted";
|
|
388
|
+
type AccountSchemaOf<T extends EventType> = T extends FullStateEventType ? typeof AccountStateSchema : typeof EntitlementSnapshotSchema;
|
|
389
|
+
declare function envelope<T extends EventType>(type: T): z.ZodObject<{
|
|
390
|
+
id: z.ZodString;
|
|
391
|
+
type: z.ZodLiteral<T>;
|
|
392
|
+
apiVersion: z.ZodString;
|
|
393
|
+
createdAt: z.ZodISODateTime;
|
|
394
|
+
product: z.ZodString;
|
|
395
|
+
accountRef: z.ZodString;
|
|
396
|
+
data: z.ZodObject<{
|
|
397
|
+
account: AccountSchemaOf<T>;
|
|
398
|
+
detail: {
|
|
399
|
+
readonly "account.updated": z.ZodObject<{
|
|
400
|
+
changed: z.ZodArray<z.ZodString>;
|
|
401
|
+
}, z.core.$strip>;
|
|
402
|
+
readonly "checkout.completed": z.ZodObject<{
|
|
403
|
+
subscriptionId: z.ZodUUID;
|
|
404
|
+
checkoutSessionId: z.ZodUUID;
|
|
405
|
+
}, z.core.$strip>;
|
|
406
|
+
readonly "checkout.failed": z.ZodObject<{
|
|
407
|
+
checkoutSessionId: z.ZodUUID;
|
|
408
|
+
reason: z.ZodString;
|
|
409
|
+
}, z.core.$strip>;
|
|
410
|
+
readonly "checkout.expired": z.ZodObject<{
|
|
411
|
+
checkoutSessionId: z.ZodUUID;
|
|
412
|
+
}, z.core.$strip>;
|
|
413
|
+
readonly "subscription.activated": z.ZodObject<{
|
|
414
|
+
planCode: z.ZodString;
|
|
415
|
+
interval: z.ZodEnum<{
|
|
416
|
+
month: "month";
|
|
417
|
+
year: "year";
|
|
418
|
+
}>;
|
|
419
|
+
amountMinor: z.ZodNumber;
|
|
420
|
+
currency: z.ZodString;
|
|
421
|
+
actorRef: z.ZodNullable<z.ZodString>;
|
|
422
|
+
subscriptionId: z.ZodUUID;
|
|
423
|
+
}, z.core.$strip>;
|
|
424
|
+
readonly "subscription.renewed": z.ZodObject<{
|
|
425
|
+
paymentId: z.ZodUUID;
|
|
426
|
+
periodStart: z.ZodNullable<z.ZodISODateTime>;
|
|
427
|
+
periodEnd: z.ZodNullable<z.ZodISODateTime>;
|
|
428
|
+
invoiceId: z.ZodNullable<z.ZodUUID>;
|
|
429
|
+
subscriptionId: z.ZodUUID;
|
|
430
|
+
}, z.core.$strip>;
|
|
431
|
+
readonly "subscription.payment_failed": z.ZodObject<{
|
|
432
|
+
paymentId: z.ZodNullable<z.ZodUUID>;
|
|
433
|
+
attempt: z.ZodNumber;
|
|
434
|
+
nextRetryAt: z.ZodNullable<z.ZodISODateTime>;
|
|
435
|
+
subscriptionId: z.ZodUUID;
|
|
436
|
+
}, z.core.$strip>;
|
|
437
|
+
readonly "subscription.suspended": z.ZodObject<{
|
|
438
|
+
dunningDay: z.ZodNumber;
|
|
439
|
+
subscriptionId: z.ZodUUID;
|
|
440
|
+
}, z.core.$strip>;
|
|
441
|
+
readonly "subscription.reactivated": z.ZodObject<{
|
|
442
|
+
paymentId: z.ZodNullable<z.ZodUUID>;
|
|
443
|
+
subscriptionId: z.ZodUUID;
|
|
444
|
+
}, z.core.$strip>;
|
|
445
|
+
readonly "subscription.cancel_scheduled": z.ZodObject<{
|
|
446
|
+
cancelAt: z.ZodISODateTime;
|
|
447
|
+
reason: z.ZodString;
|
|
448
|
+
actorRef: z.ZodNullable<z.ZodString>;
|
|
449
|
+
subscriptionId: z.ZodUUID;
|
|
450
|
+
}, z.core.$strip>;
|
|
451
|
+
readonly "subscription.canceled": z.ZodObject<{
|
|
452
|
+
reason: z.ZodString;
|
|
453
|
+
effectiveAt: z.ZodISODateTime;
|
|
454
|
+
actorRef: z.ZodNullable<z.ZodString>;
|
|
455
|
+
subscriptionId: z.ZodUUID;
|
|
456
|
+
}, z.core.$strip>;
|
|
457
|
+
readonly "subscription.expired": z.ZodObject<{
|
|
458
|
+
effectiveAt: z.ZodISODateTime;
|
|
459
|
+
subscriptionId: z.ZodUUID;
|
|
460
|
+
}, z.core.$strip>;
|
|
461
|
+
readonly "subscription.terminated": z.ZodObject<{
|
|
462
|
+
reason: z.ZodEnum<{
|
|
463
|
+
nonpayment: "nonpayment";
|
|
464
|
+
}>;
|
|
465
|
+
dunningDay: z.ZodNumber;
|
|
466
|
+
subscriptionId: z.ZodUUID;
|
|
467
|
+
}, z.core.$strip>;
|
|
468
|
+
readonly "invoice.created": z.ZodObject<{
|
|
469
|
+
invoiceId: z.ZodUUID;
|
|
470
|
+
totalMinor: z.ZodNumber;
|
|
471
|
+
currency: z.ZodString;
|
|
472
|
+
}, z.core.$strip>;
|
|
473
|
+
readonly "invoice.issued": z.ZodObject<{
|
|
474
|
+
invoiceId: z.ZodUUID;
|
|
475
|
+
number: z.ZodString;
|
|
476
|
+
totalMinor: z.ZodNumber;
|
|
477
|
+
currency: z.ZodString;
|
|
478
|
+
}, z.core.$strip>;
|
|
479
|
+
readonly "invoice.voided": z.ZodObject<{
|
|
480
|
+
invoiceId: z.ZodUUID;
|
|
481
|
+
number: z.ZodNullable<z.ZodString>;
|
|
482
|
+
totalMinor: z.ZodNumber;
|
|
483
|
+
currency: z.ZodString;
|
|
484
|
+
reason: z.ZodString;
|
|
485
|
+
}, z.core.$strip>;
|
|
486
|
+
readonly "account.state_changed": z.ZodObject<{
|
|
487
|
+
cause: z.ZodString;
|
|
488
|
+
causeEventId: z.ZodNullable<z.ZodString>;
|
|
489
|
+
}, z.core.$strip>;
|
|
490
|
+
readonly "account.deleted": z.ZodObject<{
|
|
491
|
+
deletedAt: z.ZodISODateTime;
|
|
492
|
+
actorRef: z.ZodNullable<z.ZodString>;
|
|
493
|
+
}, z.core.$strip>;
|
|
494
|
+
}[T];
|
|
495
|
+
}, z.core.$strip>;
|
|
496
|
+
}, z.core.$strip>;
|
|
497
|
+
type EnvelopeSchema<T extends EventType> = ReturnType<typeof envelope<T>>;
|
|
498
|
+
type EnvelopeSchemas = { [T in EventType]: EnvelopeSchema<T>; };
|
|
499
|
+
type AnyEnvelopeSchema = EnvelopeSchemas[EventType];
|
|
500
|
+
declare const BillingEventSchema: z.ZodDiscriminatedUnion<[AnyEnvelopeSchema, ...AnyEnvelopeSchema[]], "type">;
|
|
501
|
+
type BillingEvent = { [T in EventType]: z.infer<EnvelopeSchemas[T]>; }[EventType];
|
|
502
|
+
type BillingEventOf<T extends EventType> = Extract<BillingEvent, {
|
|
503
|
+
type: T;
|
|
504
|
+
}>;
|
|
505
|
+
type EventDetail<T extends EventType> = z.infer<(typeof EVENT_DETAIL_SCHEMAS)[T]>;
|
|
506
|
+
declare function isEventType<T extends EventType>(event: BillingEvent, type: T): event is BillingEventOf<T>;
|
|
507
|
+
/**
|
|
508
|
+
* Gevşek zarf: bu sürümün tanımadığı (gelecekteki) event tipini de kabul eder.
|
|
509
|
+
* Alıcı önce `BillingEventSchema` dener; tutmazsa bununla id/version/hesap
|
|
510
|
+
* alanlarını okuyup tekrarı ayıklar ve bilinmeyen tipi 2xx ile geçer (400
|
|
511
|
+
* dönmek teslimat sırasını tıkar). `data.account` ve `data.detail` doğrulanmaz.
|
|
512
|
+
*/
|
|
513
|
+
declare const AnyBillingEventSchema: z.ZodObject<{
|
|
514
|
+
id: z.ZodString;
|
|
515
|
+
type: z.ZodString;
|
|
516
|
+
apiVersion: z.ZodString;
|
|
517
|
+
createdAt: z.ZodISODateTime;
|
|
518
|
+
product: z.ZodString;
|
|
519
|
+
accountRef: z.ZodString;
|
|
520
|
+
data: z.ZodObject<{
|
|
521
|
+
account: z.ZodUnknown;
|
|
522
|
+
detail: z.ZodUnknown;
|
|
523
|
+
}, z.core.$loose>;
|
|
524
|
+
}, z.core.$loose>;
|
|
525
|
+
type AnyBillingEvent = z.infer<typeof AnyBillingEventSchema>;
|
|
526
|
+
declare const PING_EVENT_TYPE = "endpoint.ping";
|
|
527
|
+
declare const PingSchema: z.ZodObject<{
|
|
528
|
+
id: z.ZodString;
|
|
529
|
+
type: z.ZodLiteral<"endpoint.ping">;
|
|
530
|
+
apiVersion: z.ZodString;
|
|
531
|
+
createdAt: z.ZodISODateTime;
|
|
532
|
+
product: z.ZodString;
|
|
533
|
+
endpointId: z.ZodUUID;
|
|
534
|
+
}, z.core.$strip>;
|
|
535
|
+
type Ping = z.infer<typeof PingSchema>;
|
|
536
|
+
//#endregion
|
|
537
|
+
export { AccountProfileState as A, AccountUpsertInputSchema as B, AccountDeleteResponse as C, AccountInclude as D, AccountDunningStateSchema as E, AccountState as F, EntitlementSnapshot as G, BillingProfileInput as H, AccountStateSchema as I, SubscriptionStatusSchema as J, EntitlementSnapshotSchema as K, AccountSubscriptionState as L, AccountScheduledChange as M, AccountScheduledChangeSchema as N, AccountOpenCheckout as O, AccountSchema as P, AccountSubscriptionStateSchema as R, Account as S, AccountDunningState as T, BillingProfileKindSchema as U, BillingProfile as V, BillingProfileSchema as W, SubscriptionSummarySchema as X, SubscriptionSummary as Y, PingSchema as _, BillingEvent as a, AccessState as b, EVENT_DETAIL_SCHEMAS as c, EventIdSchema as d, EventType as f, Ping as g, PING_EVENT_TYPE as h, ApiVersionSchema as i, AccountProfileStateSchema as j, AccountOpenCheckoutSchema as k, EVENT_TYPES as l, LegacyEventType as m, AnyBillingEvent as n, BillingEventOf as o, LEGACY_EVENT_TYPES as p, SubscriptionStatus as q, AnyBillingEventSchema as r, BillingEventSchema as s, AccountStateChangeCause as t, EventDetail as u, isEventType as v, AccountDeleteResponseSchema as w, AccessStateSchema as x, ACCOUNT_INCLUDES as y, AccountUpsertInput as z };
|