zpan-cloud-sdk 1.0.0 → 1.0.1
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 +1 -1
- package/dist/chunk-YQNXMZK4.js +572 -0
- package/dist/index.d.ts +201 -441
- package/dist/index.js +92 -1
- package/dist/schemas.d.ts +1167 -2
- package/dist/schemas.js +83 -1
- package/package.json +1 -1
- package/dist/chunk-VMYIHGPC.js +0 -218
- package/dist/schemas-R0lkMmfq.d.ts +0 -366
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ import { createCloudClient } from 'zpan-cloud-sdk'
|
|
|
7
7
|
import type { ZpanCloudEvent } from 'zpan-cloud-sdk'
|
|
8
8
|
|
|
9
9
|
const cloud = createCloudClient({
|
|
10
|
-
baseUrl: 'https://cloud.example.com
|
|
10
|
+
baseUrl: 'https://cloud.example.com',
|
|
11
11
|
token: process.env.ZPAN_CLOUD_TOKEN,
|
|
12
12
|
})
|
|
13
13
|
```
|
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
// src/schemas.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var paginationQuerySchema = z.object({
|
|
4
|
+
limit: z.coerce.number().int().min(1).max(100).optional().default(50),
|
|
5
|
+
offset: z.coerce.number().int().min(0).optional().default(0)
|
|
6
|
+
});
|
|
7
|
+
var pageSchema = (itemSchema) => z.object({
|
|
8
|
+
items: z.array(itemSchema),
|
|
9
|
+
total: z.number().int().min(0),
|
|
10
|
+
limit: z.number().int().min(0),
|
|
11
|
+
offset: z.number().int().min(0)
|
|
12
|
+
});
|
|
13
|
+
var createPairingSchema = z.object({
|
|
14
|
+
instanceId: z.string().min(1).max(255),
|
|
15
|
+
instanceName: z.string().min(1).max(255),
|
|
16
|
+
instanceHost: z.string().min(1).max(512)
|
|
17
|
+
});
|
|
18
|
+
var pairingCreateResponseSchema = z.object({
|
|
19
|
+
code: z.string(),
|
|
20
|
+
pairingUrl: z.string(),
|
|
21
|
+
expiresAt: z.string()
|
|
22
|
+
});
|
|
23
|
+
var pairingPreviewSchema = z.object({
|
|
24
|
+
licenseId: z.string(),
|
|
25
|
+
licenseName: z.string(),
|
|
26
|
+
licenseHost: z.string()
|
|
27
|
+
});
|
|
28
|
+
var pairingPollResponseSchema = z.discriminatedUnion("status", [
|
|
29
|
+
z.object({ status: z.enum(["pending", "denied", "expired"]) }),
|
|
30
|
+
z.object({
|
|
31
|
+
status: z.literal("approved"),
|
|
32
|
+
refreshToken: z.string(),
|
|
33
|
+
certificate: z.string(),
|
|
34
|
+
binding: z.object({
|
|
35
|
+
id: z.string(),
|
|
36
|
+
instanceId: z.string(),
|
|
37
|
+
storeId: z.string(),
|
|
38
|
+
authorizedHosts: z.array(z.string())
|
|
39
|
+
}),
|
|
40
|
+
account: z.object({ id: z.string(), email: z.string() })
|
|
41
|
+
})
|
|
42
|
+
]);
|
|
43
|
+
var pairingActionSchema = z.object({
|
|
44
|
+
action: z.enum(["approve", "deny"])
|
|
45
|
+
});
|
|
46
|
+
var pairingActionResponseSchema = z.object({
|
|
47
|
+
status: z.enum(["approved", "denied"])
|
|
48
|
+
});
|
|
49
|
+
var entitlementRefreshResponseSchema = z.object({
|
|
50
|
+
certificate: z.string(),
|
|
51
|
+
refreshToken: z.string(),
|
|
52
|
+
nextRefreshAfter: z.string(),
|
|
53
|
+
binding: z.object({
|
|
54
|
+
id: z.string(),
|
|
55
|
+
instanceId: z.string(),
|
|
56
|
+
storeId: z.string(),
|
|
57
|
+
authorizedHosts: z.array(z.string())
|
|
58
|
+
}),
|
|
59
|
+
account: z.object({ id: z.string(), email: z.string() })
|
|
60
|
+
});
|
|
61
|
+
var productPriceSchema = z.object({
|
|
62
|
+
id: z.string().min(1).optional(),
|
|
63
|
+
currency: z.string().min(1),
|
|
64
|
+
amount: z.number().int().positive(),
|
|
65
|
+
lookupKey: z.string().min(1).nullable().optional(),
|
|
66
|
+
nickname: z.string().nullable().optional(),
|
|
67
|
+
recurring: z.object({
|
|
68
|
+
interval: z.enum(["day", "week", "month", "year"]),
|
|
69
|
+
intervalCount: z.number().int().positive(),
|
|
70
|
+
usageType: z.enum(["licensed", "metered"]).optional()
|
|
71
|
+
}).nullable().optional(),
|
|
72
|
+
metadata: z.record(z.string(), z.string()).optional()
|
|
73
|
+
});
|
|
74
|
+
var deliverableSchema = z.record(z.string(), z.unknown());
|
|
75
|
+
var productMetadataSchema = z.object({
|
|
76
|
+
deliverable: deliverableSchema
|
|
77
|
+
});
|
|
78
|
+
function isTrafficMeteredPrice(price) {
|
|
79
|
+
return price.recurring?.usageType === "metered" && price.metadata?.usageResource === "traffic_egress";
|
|
80
|
+
}
|
|
81
|
+
function validateTrafficMeteredPricePairs(prices, ctx) {
|
|
82
|
+
if (!prices) return;
|
|
83
|
+
for (const [index, price] of prices.entries()) {
|
|
84
|
+
if (price.recurring && (price.recurring.interval !== "month" || price.recurring.intervalCount !== 1)) {
|
|
85
|
+
ctx.addIssue({
|
|
86
|
+
code: z.ZodIssueCode.custom,
|
|
87
|
+
path: ["prices", index, "recurring"],
|
|
88
|
+
message: "Subscription prices must bill monthly"
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (price.recurring?.usageType === "metered" && price.metadata?.usageResource !== "traffic_egress") {
|
|
92
|
+
ctx.addIssue({
|
|
93
|
+
code: z.ZodIssueCode.custom,
|
|
94
|
+
path: ["prices", index],
|
|
95
|
+
message: "Metered traffic prices must set usageResource to traffic_egress"
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (price.metadata?.usageResource === "traffic_egress" && price.recurring?.usageType !== "metered") {
|
|
99
|
+
ctx.addIssue({
|
|
100
|
+
code: z.ZodIssueCode.custom,
|
|
101
|
+
path: ["prices", index],
|
|
102
|
+
message: "Traffic overage prices must use metered billing"
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const recurringPrices = prices.filter((price) => price.recurring);
|
|
107
|
+
const currencies = new Set(recurringPrices.map((price) => price.currency));
|
|
108
|
+
for (const currency of currencies) {
|
|
109
|
+
const monthlyCount = recurringPrices.filter(
|
|
110
|
+
(price) => price.currency === currency && !isTrafficMeteredPrice(price)
|
|
111
|
+
).length;
|
|
112
|
+
if (monthlyCount !== 1) {
|
|
113
|
+
ctx.addIssue({
|
|
114
|
+
code: z.ZodIssueCode.custom,
|
|
115
|
+
path: ["prices"],
|
|
116
|
+
message: `Subscription prices for ${currency} must have exactly one monthly price`
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const meteredCount = recurringPrices.filter(
|
|
120
|
+
(price) => price.currency === currency && isTrafficMeteredPrice(price)
|
|
121
|
+
).length;
|
|
122
|
+
if (meteredCount === 1) continue;
|
|
123
|
+
ctx.addIssue({
|
|
124
|
+
code: z.ZodIssueCode.custom,
|
|
125
|
+
path: ["prices"],
|
|
126
|
+
message: `Subscription prices for ${currency} must have exactly one metered traffic price`
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
var createProductSchema = z.object({
|
|
131
|
+
type: z.literal("store_item"),
|
|
132
|
+
name: z.string().min(1),
|
|
133
|
+
description: z.string().nullable().optional(),
|
|
134
|
+
active: z.boolean().optional(),
|
|
135
|
+
sortOrder: z.number().int().optional(),
|
|
136
|
+
metadata: productMetadataSchema,
|
|
137
|
+
prices: z.array(productPriceSchema).min(1)
|
|
138
|
+
}).superRefine((input, ctx) => validateTrafficMeteredPricePairs(input.prices, ctx));
|
|
139
|
+
var updateProductSchema = z.object({
|
|
140
|
+
type: z.literal("store_item").optional(),
|
|
141
|
+
name: z.string().min(1).optional(),
|
|
142
|
+
description: z.string().nullable().optional(),
|
|
143
|
+
active: z.boolean().optional(),
|
|
144
|
+
sortOrder: z.number().int().optional(),
|
|
145
|
+
metadata: productMetadataSchema.optional(),
|
|
146
|
+
prices: z.array(productPriceSchema).min(1).optional()
|
|
147
|
+
}).superRefine((input, ctx) => validateTrafficMeteredPricePairs(input.prices, ctx));
|
|
148
|
+
var productListQuerySchema = paginationQuerySchema.extend({
|
|
149
|
+
type: z.literal("store_item").optional(),
|
|
150
|
+
status: z.enum(["active", "inactive"]).optional()
|
|
151
|
+
});
|
|
152
|
+
var commerceStoreSchema = z.object({
|
|
153
|
+
id: z.string(),
|
|
154
|
+
type: z.enum(["cloud", "instance"]),
|
|
155
|
+
name: z.string(),
|
|
156
|
+
ownerAccountId: z.string().nullable(),
|
|
157
|
+
boundLicenseId: z.string().nullable(),
|
|
158
|
+
status: z.enum(["active", "disabled"]),
|
|
159
|
+
createdAt: z.string(),
|
|
160
|
+
updatedAt: z.string()
|
|
161
|
+
});
|
|
162
|
+
var commerceProductSchema = z.object({
|
|
163
|
+
id: z.string(),
|
|
164
|
+
storeId: z.string(),
|
|
165
|
+
type: z.literal("store_item"),
|
|
166
|
+
name: z.string(),
|
|
167
|
+
description: z.string().nullable(),
|
|
168
|
+
active: z.boolean(),
|
|
169
|
+
sortOrder: z.number().int(),
|
|
170
|
+
metadata: productMetadataSchema,
|
|
171
|
+
prices: z.array(productPriceSchema),
|
|
172
|
+
createdAt: z.string(),
|
|
173
|
+
updatedAt: z.string()
|
|
174
|
+
});
|
|
175
|
+
var productListResponseSchema = pageSchema(commerceProductSchema);
|
|
176
|
+
var storeListResponseSchema = pageSchema(commerceStoreSchema);
|
|
177
|
+
var orderItemSchema = z.object({
|
|
178
|
+
productId: z.string().min(1),
|
|
179
|
+
priceId: z.string().min(1).optional(),
|
|
180
|
+
quantity: z.number().int().positive().optional().default(1)
|
|
181
|
+
});
|
|
182
|
+
var createOrderSchema = z.object({
|
|
183
|
+
items: z.array(orderItemSchema).min(1),
|
|
184
|
+
currency: z.string().min(1),
|
|
185
|
+
target: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
186
|
+
deliveryCallbackUrl: z.string().url().optional(),
|
|
187
|
+
idempotencyKey: z.string().nullable().optional()
|
|
188
|
+
});
|
|
189
|
+
var orderListQuerySchema = paginationQuerySchema.extend({
|
|
190
|
+
paymentStatus: z.enum(["unpaid", "pending", "paid", "failed", "refunded", "canceled"]).optional(),
|
|
191
|
+
fulfillmentStatus: z.enum(["pending", "fulfilled", "failed", "canceled"]).optional(),
|
|
192
|
+
customerId: z.string().min(1).optional()
|
|
193
|
+
});
|
|
194
|
+
var commerceOrderItemSchema = z.object({
|
|
195
|
+
id: z.string(),
|
|
196
|
+
orderId: z.string(),
|
|
197
|
+
productId: z.string(),
|
|
198
|
+
productType: z.string(),
|
|
199
|
+
name: z.string(),
|
|
200
|
+
description: z.string().nullable(),
|
|
201
|
+
quantity: z.number().int(),
|
|
202
|
+
unitAmount: z.number().int(),
|
|
203
|
+
totalAmount: z.number().int(),
|
|
204
|
+
fulfillmentPayload: z.record(z.string(), z.unknown())
|
|
205
|
+
});
|
|
206
|
+
var commercePaymentSchema = z.object({
|
|
207
|
+
id: z.string(),
|
|
208
|
+
orderId: z.string(),
|
|
209
|
+
provider: z.enum(["stripe", "gift_card", "wallet"]),
|
|
210
|
+
amount: z.number().int(),
|
|
211
|
+
currency: z.string(),
|
|
212
|
+
status: z.enum(["pending", "paid", "failed", "refunded", "canceled"]),
|
|
213
|
+
providerSessionId: z.string().nullable(),
|
|
214
|
+
providerPaymentIntentId: z.string().nullable(),
|
|
215
|
+
createdAt: z.string(),
|
|
216
|
+
paidAt: z.string().nullable()
|
|
217
|
+
});
|
|
218
|
+
var commerceOrderSchema = z.object({
|
|
219
|
+
id: z.string(),
|
|
220
|
+
storeId: z.string(),
|
|
221
|
+
buyerAccountId: z.string().nullable(),
|
|
222
|
+
target: z.record(z.string(), z.unknown()).nullable(),
|
|
223
|
+
status: z.enum(["pending", "paid", "fulfilled", "failed", "canceled", "refunded"]),
|
|
224
|
+
paymentStatus: z.enum(["unpaid", "pending", "paid", "failed", "refunded", "canceled"]),
|
|
225
|
+
fulfillmentStatus: z.enum(["pending", "fulfilled", "failed", "canceled"]),
|
|
226
|
+
subtotalAmount: z.number().int(),
|
|
227
|
+
discountAmount: z.number().int(),
|
|
228
|
+
totalAmount: z.number().int(),
|
|
229
|
+
currency: z.string(),
|
|
230
|
+
items: z.array(commerceOrderItemSchema),
|
|
231
|
+
payments: z.array(commercePaymentSchema).optional(),
|
|
232
|
+
createdAt: z.string(),
|
|
233
|
+
paidAt: z.string().nullable(),
|
|
234
|
+
fulfilledAt: z.string().nullable(),
|
|
235
|
+
canceledAt: z.string().nullable()
|
|
236
|
+
});
|
|
237
|
+
var orderListResponseSchema = pageSchema(commerceOrderSchema);
|
|
238
|
+
var paymentSchema = z.object({
|
|
239
|
+
successUrl: z.string().optional(),
|
|
240
|
+
cancelUrl: z.string().optional()
|
|
241
|
+
}).strict();
|
|
242
|
+
var paymentCreateResponseSchema = z.discriminatedUnion("status", [
|
|
243
|
+
z.object({
|
|
244
|
+
status: z.literal("pending"),
|
|
245
|
+
paymentId: z.string(),
|
|
246
|
+
orderId: z.string(),
|
|
247
|
+
url: z.string(),
|
|
248
|
+
reused: z.boolean().optional()
|
|
249
|
+
}),
|
|
250
|
+
z.object({
|
|
251
|
+
status: z.literal("paid"),
|
|
252
|
+
paymentId: z.string().optional(),
|
|
253
|
+
orderId: z.string(),
|
|
254
|
+
url: z.string().nullable(),
|
|
255
|
+
reused: z.boolean().optional()
|
|
256
|
+
})
|
|
257
|
+
]);
|
|
258
|
+
var billingPortalSessionSchema = z.object({
|
|
259
|
+
customerId: z.string().min(1),
|
|
260
|
+
returnUrl: z.string().url()
|
|
261
|
+
}).strict();
|
|
262
|
+
var billingPortalSessionResponseSchema = z.object({
|
|
263
|
+
url: z.string(),
|
|
264
|
+
stripeSubscriptionId: z.string()
|
|
265
|
+
});
|
|
266
|
+
var orderPatchSchema = z.object({
|
|
267
|
+
status: z.enum(["canceled"])
|
|
268
|
+
});
|
|
269
|
+
var giftCardCreateSchema = z.object({
|
|
270
|
+
amount: z.number().int().positive(),
|
|
271
|
+
currency: z.string().min(1),
|
|
272
|
+
expiresAt: z.string().optional().nullable(),
|
|
273
|
+
campaignId: z.string().optional().nullable(),
|
|
274
|
+
count: z.number().int().min(1).max(100).optional().default(1)
|
|
275
|
+
});
|
|
276
|
+
var giftCardCampaignCreateSchema = z.object({
|
|
277
|
+
name: z.string().trim().min(1),
|
|
278
|
+
startsAt: z.string().optional().nullable(),
|
|
279
|
+
expiresAt: z.string().optional().nullable()
|
|
280
|
+
});
|
|
281
|
+
var giftCardPatchSchema = z.object({
|
|
282
|
+
disabled: z.boolean().optional(),
|
|
283
|
+
revoked: z.literal(true).optional()
|
|
284
|
+
});
|
|
285
|
+
var giftCardListQuerySchema = paginationQuerySchema.extend({
|
|
286
|
+
status: z.enum(["active", "redeemed", "disabled", "expired", "revoked"]).optional(),
|
|
287
|
+
campaignId: z.string().optional()
|
|
288
|
+
});
|
|
289
|
+
var giftCardCampaignListQuerySchema = paginationQuerySchema.extend({
|
|
290
|
+
status: z.enum(["active", "disabled", "ended"]).optional()
|
|
291
|
+
});
|
|
292
|
+
var storeGiftCardSchema = z.object({
|
|
293
|
+
id: z.string(),
|
|
294
|
+
storeId: z.string(),
|
|
295
|
+
campaignId: z.string().nullable(),
|
|
296
|
+
code: z.string().nullable(),
|
|
297
|
+
codeLast4: z.string(),
|
|
298
|
+
amount: z.number().int(),
|
|
299
|
+
currency: z.string(),
|
|
300
|
+
status: z.enum(["active", "redeemed", "disabled", "expired", "revoked"]),
|
|
301
|
+
expiresAt: z.string().nullable(),
|
|
302
|
+
createdAt: z.string(),
|
|
303
|
+
updatedAt: z.string(),
|
|
304
|
+
disabledAt: z.string().nullable(),
|
|
305
|
+
revokedAt: z.string().nullable(),
|
|
306
|
+
createdByAdmin: z.string()
|
|
307
|
+
});
|
|
308
|
+
var giftCardCampaignSchema = z.object({
|
|
309
|
+
id: z.string(),
|
|
310
|
+
storeId: z.string(),
|
|
311
|
+
name: z.string(),
|
|
312
|
+
status: z.enum(["active", "disabled", "ended"]),
|
|
313
|
+
startsAt: z.string().nullable(),
|
|
314
|
+
expiresAt: z.string().nullable(),
|
|
315
|
+
createdByAdmin: z.string(),
|
|
316
|
+
createdAt: z.string(),
|
|
317
|
+
updatedAt: z.string()
|
|
318
|
+
});
|
|
319
|
+
var giftCardListResponseSchema = pageSchema(storeGiftCardSchema);
|
|
320
|
+
var giftCardCampaignListResponseSchema = pageSchema(giftCardCampaignSchema);
|
|
321
|
+
var usageEventCreateSchema = z.object({
|
|
322
|
+
resource: z.literal("traffic_egress"),
|
|
323
|
+
quantity: z.number().int().positive().optional(),
|
|
324
|
+
bytes: z.number().int().positive().optional(),
|
|
325
|
+
idempotencyKey: z.string().trim().min(1).max(200).optional(),
|
|
326
|
+
eventId: z.string().trim().min(1).max(200).optional(),
|
|
327
|
+
customerId: z.string().trim().min(1)
|
|
328
|
+
}).strict().refine((value) => value.quantity !== void 0 || value.bytes !== void 0, "quantity_required").refine((value) => value.idempotencyKey !== void 0 || value.eventId !== void 0, "idempotency_key_required");
|
|
329
|
+
var accountUsagePeriodSchema = z.string().regex(/^\d{4}-(0[1-9]|1[0-2])$/);
|
|
330
|
+
var accountUsageQuerySchema = z.object({
|
|
331
|
+
customerId: z.string().trim().min(1)
|
|
332
|
+
}).strict();
|
|
333
|
+
var usageResourceSummarySchema = z.object({
|
|
334
|
+
used: z.number().int(),
|
|
335
|
+
included: z.number().int(),
|
|
336
|
+
overageBytes: z.number().int(),
|
|
337
|
+
overageGb: z.number()
|
|
338
|
+
});
|
|
339
|
+
var usageSummarySchema = z.object({
|
|
340
|
+
period: z.string(),
|
|
341
|
+
resources: z.object({
|
|
342
|
+
traffic_egress: usageResourceSummarySchema
|
|
343
|
+
}),
|
|
344
|
+
nextReset: z.string()
|
|
345
|
+
});
|
|
346
|
+
var usageEventCreateResponseSchema = z.object({
|
|
347
|
+
resource: z.literal("traffic_egress"),
|
|
348
|
+
quantity: z.number().int(),
|
|
349
|
+
duplicate: z.boolean()
|
|
350
|
+
});
|
|
351
|
+
var walletRedemptionSchema = z.object({
|
|
352
|
+
codes: z.array(z.string().trim().min(1)).min(1).max(10)
|
|
353
|
+
});
|
|
354
|
+
var walletBalanceSchema = z.object({
|
|
355
|
+
id: z.string(),
|
|
356
|
+
walletId: z.string().nullable(),
|
|
357
|
+
storeId: z.string(),
|
|
358
|
+
customerId: z.string().nullable(),
|
|
359
|
+
currency: z.string(),
|
|
360
|
+
availableAmount: z.number().int(),
|
|
361
|
+
pendingAmount: z.number().int(),
|
|
362
|
+
stripeCustomerId: z.string().nullable(),
|
|
363
|
+
updatedAt: z.string()
|
|
364
|
+
});
|
|
365
|
+
var walletLedgerEntrySchema = z.object({
|
|
366
|
+
id: z.string(),
|
|
367
|
+
walletId: z.string().nullable(),
|
|
368
|
+
storeId: z.string(),
|
|
369
|
+
customerId: z.string().nullable(),
|
|
370
|
+
currency: z.string(),
|
|
371
|
+
amount: z.number().int(),
|
|
372
|
+
direction: z.enum(["credit", "debit"]),
|
|
373
|
+
status: z.enum(["posted", "pending", "released", "refunded"]),
|
|
374
|
+
sourceType: z.enum(["gift_card_redemption", "order_payment", "stripe_invoice", "adjustment", "refund"]),
|
|
375
|
+
sourceId: z.string().nullable(),
|
|
376
|
+
orderId: z.string().nullable(),
|
|
377
|
+
paymentId: z.string().nullable(),
|
|
378
|
+
stripeCustomerBalanceTransactionId: z.string().nullable(),
|
|
379
|
+
createdAt: z.string()
|
|
380
|
+
});
|
|
381
|
+
var walletBalanceListResponseSchema = pageSchema(walletBalanceSchema);
|
|
382
|
+
var walletLedgerResponseSchema = pageSchema(walletLedgerEntrySchema);
|
|
383
|
+
var walletRedemptionResponseSchema = z.object({
|
|
384
|
+
redeemedAmount: z.number().int(),
|
|
385
|
+
currency: z.string().nullable(),
|
|
386
|
+
failures: z.array(z.object({ code: z.string(), error: z.string() }))
|
|
387
|
+
});
|
|
388
|
+
var accountWalletResponseSchema = pageSchema(walletLedgerEntrySchema).extend({
|
|
389
|
+
balances: z.array(walletBalanceSchema)
|
|
390
|
+
});
|
|
391
|
+
var accountBillingQuerySchema = paginationQuerySchema.extend({
|
|
392
|
+
ledgerLimit: z.coerce.number().int().min(1).max(100).optional().default(25),
|
|
393
|
+
ledgerOffset: z.coerce.number().int().min(0).optional().default(0)
|
|
394
|
+
});
|
|
395
|
+
var accountOverviewResponseSchema = z.object({
|
|
396
|
+
activeLicenses: z.number().int(),
|
|
397
|
+
membershipTier: z.enum(["none", "silver", "gold", "premier"]),
|
|
398
|
+
latestBillingDate: z.string().nullable()
|
|
399
|
+
});
|
|
400
|
+
var membershipStripeChannelSchema = z.object({
|
|
401
|
+
status: z.string(),
|
|
402
|
+
billingInterval: z.string().nullable(),
|
|
403
|
+
renewsAt: z.string().nullable(),
|
|
404
|
+
cancelAtPeriodEnd: z.boolean()
|
|
405
|
+
});
|
|
406
|
+
var accountMembershipResponseSchema = z.object({
|
|
407
|
+
state: z.enum(["inactive", "active", "renewal_due", "expired"]),
|
|
408
|
+
tier: z.enum(["none", "silver", "gold", "premier"]),
|
|
409
|
+
membershipStatus: z.enum(["inactive", "active", "expired"]),
|
|
410
|
+
expiresAt: z.string().nullable(),
|
|
411
|
+
cumulativeMonths: z.number().int(),
|
|
412
|
+
proIncluded: z.boolean(),
|
|
413
|
+
primaryAction: z.enum(["subscribe", "renew", "manage"]),
|
|
414
|
+
stripeSubscription: membershipStripeChannelSchema.nullable(),
|
|
415
|
+
channel: z.enum(["stripe", "gift"])
|
|
416
|
+
});
|
|
417
|
+
var billingRecordItemSchema = z.object({
|
|
418
|
+
name: z.string(),
|
|
419
|
+
productType: z.string(),
|
|
420
|
+
quantity: z.number().int(),
|
|
421
|
+
deliverable: z.record(z.string(), z.unknown()),
|
|
422
|
+
recurring: z.boolean()
|
|
423
|
+
});
|
|
424
|
+
var billingRecordSchema = z.object({
|
|
425
|
+
id: z.string(),
|
|
426
|
+
title: z.string(),
|
|
427
|
+
kind: z.enum(["store_item", "store_subscription", "mixed_order"]),
|
|
428
|
+
items: z.array(billingRecordItemSchema),
|
|
429
|
+
orderStatus: z.enum(["pending", "paid", "fulfilled", "failed", "canceled", "refunded"]),
|
|
430
|
+
paymentStatus: z.enum(["unpaid", "pending", "paid", "failed", "refunded", "canceled"]),
|
|
431
|
+
fulfillmentStatus: z.enum(["pending", "fulfilled", "failed", "canceled"]),
|
|
432
|
+
amountLabel: z.string().nullable(),
|
|
433
|
+
occurredAt: z.string(),
|
|
434
|
+
paidAt: z.string().nullable(),
|
|
435
|
+
fulfilledAt: z.string().nullable()
|
|
436
|
+
});
|
|
437
|
+
var billingSummarySchema = z.object({
|
|
438
|
+
totalRecords: z.number().int(),
|
|
439
|
+
stripeRecords: z.number().int(),
|
|
440
|
+
walletBalanceAmount: z.number().int(),
|
|
441
|
+
walletCurrency: z.string().nullable(),
|
|
442
|
+
latestAt: z.string().nullable()
|
|
443
|
+
});
|
|
444
|
+
var accountBillingResponseSchema = z.object({
|
|
445
|
+
summary: billingSummarySchema,
|
|
446
|
+
walletBalances: z.array(walletBalanceSchema),
|
|
447
|
+
walletLedger: pageSchema(walletLedgerEntrySchema),
|
|
448
|
+
items: z.array(billingRecordSchema),
|
|
449
|
+
total: z.number().int(),
|
|
450
|
+
limit: z.number().int(),
|
|
451
|
+
offset: z.number().int()
|
|
452
|
+
});
|
|
453
|
+
var storePatchSchema = z.object({
|
|
454
|
+
name: z.string().min(1).optional(),
|
|
455
|
+
status: z.enum(["active", "disabled"]).optional()
|
|
456
|
+
});
|
|
457
|
+
var adminUserPatchSchema = z.object({
|
|
458
|
+
role: z.enum(["user", "admin"]).optional(),
|
|
459
|
+
membershipTier: z.enum(["none", "silver", "gold", "premier"]).optional(),
|
|
460
|
+
membershipStatus: z.enum(["active", "inactive", "expired"]).optional()
|
|
461
|
+
}).refine((value) => Object.keys(value).length > 0, { message: "at least one field is required" });
|
|
462
|
+
var adminUserListQuerySchema = paginationQuerySchema.extend({
|
|
463
|
+
search: z.string().trim().optional(),
|
|
464
|
+
membershipTier: z.enum(["none", "silver", "gold", "premier"]).optional()
|
|
465
|
+
});
|
|
466
|
+
var adminUserSchema = z.object({
|
|
467
|
+
id: z.string(),
|
|
468
|
+
name: z.string(),
|
|
469
|
+
email: z.string(),
|
|
470
|
+
emailVerified: z.boolean(),
|
|
471
|
+
image: z.string().nullable(),
|
|
472
|
+
createdAt: z.string(),
|
|
473
|
+
updatedAt: z.string(),
|
|
474
|
+
role: z.enum(["user", "admin"]),
|
|
475
|
+
membershipTier: z.enum(["none", "silver", "gold", "premier"]),
|
|
476
|
+
membershipStatus: z.enum(["active", "inactive", "expired"])
|
|
477
|
+
});
|
|
478
|
+
var adminUserListResponseSchema = pageSchema(adminUserSchema);
|
|
479
|
+
var boundLicenseSchema = z.object({
|
|
480
|
+
id: z.string(),
|
|
481
|
+
name: z.string(),
|
|
482
|
+
url: z.string(),
|
|
483
|
+
version: z.string().nullable(),
|
|
484
|
+
plan: z.string(),
|
|
485
|
+
lastSeenAt: z.string().nullable()
|
|
486
|
+
});
|
|
487
|
+
var licenseListResponseSchema = pageSchema(boundLicenseSchema);
|
|
488
|
+
var licenseAssertionSchema = z.object({
|
|
489
|
+
type: z.literal("zpan.license"),
|
|
490
|
+
issuer: z.string(),
|
|
491
|
+
subject: z.string(),
|
|
492
|
+
accountId: z.string(),
|
|
493
|
+
instanceId: z.string(),
|
|
494
|
+
storeId: z.string(),
|
|
495
|
+
edition: z.literal("pro"),
|
|
496
|
+
authorizedHosts: z.array(z.string()),
|
|
497
|
+
licenseValidUntil: z.number().int(),
|
|
498
|
+
issuedAt: z.number().int(),
|
|
499
|
+
notBefore: z.number().int(),
|
|
500
|
+
expiresAt: z.number().int()
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
export {
|
|
504
|
+
paginationQuerySchema,
|
|
505
|
+
pageSchema,
|
|
506
|
+
createPairingSchema,
|
|
507
|
+
pairingCreateResponseSchema,
|
|
508
|
+
pairingPreviewSchema,
|
|
509
|
+
pairingPollResponseSchema,
|
|
510
|
+
pairingActionSchema,
|
|
511
|
+
pairingActionResponseSchema,
|
|
512
|
+
entitlementRefreshResponseSchema,
|
|
513
|
+
productPriceSchema,
|
|
514
|
+
deliverableSchema,
|
|
515
|
+
productMetadataSchema,
|
|
516
|
+
createProductSchema,
|
|
517
|
+
updateProductSchema,
|
|
518
|
+
productListQuerySchema,
|
|
519
|
+
commerceStoreSchema,
|
|
520
|
+
commerceProductSchema,
|
|
521
|
+
productListResponseSchema,
|
|
522
|
+
storeListResponseSchema,
|
|
523
|
+
createOrderSchema,
|
|
524
|
+
orderListQuerySchema,
|
|
525
|
+
commerceOrderItemSchema,
|
|
526
|
+
commercePaymentSchema,
|
|
527
|
+
commerceOrderSchema,
|
|
528
|
+
orderListResponseSchema,
|
|
529
|
+
paymentSchema,
|
|
530
|
+
paymentCreateResponseSchema,
|
|
531
|
+
billingPortalSessionSchema,
|
|
532
|
+
billingPortalSessionResponseSchema,
|
|
533
|
+
orderPatchSchema,
|
|
534
|
+
giftCardCreateSchema,
|
|
535
|
+
giftCardCampaignCreateSchema,
|
|
536
|
+
giftCardPatchSchema,
|
|
537
|
+
giftCardListQuerySchema,
|
|
538
|
+
giftCardCampaignListQuerySchema,
|
|
539
|
+
storeGiftCardSchema,
|
|
540
|
+
giftCardCampaignSchema,
|
|
541
|
+
giftCardListResponseSchema,
|
|
542
|
+
giftCardCampaignListResponseSchema,
|
|
543
|
+
usageEventCreateSchema,
|
|
544
|
+
accountUsagePeriodSchema,
|
|
545
|
+
accountUsageQuerySchema,
|
|
546
|
+
usageResourceSummarySchema,
|
|
547
|
+
usageSummarySchema,
|
|
548
|
+
usageEventCreateResponseSchema,
|
|
549
|
+
walletRedemptionSchema,
|
|
550
|
+
walletBalanceSchema,
|
|
551
|
+
walletLedgerEntrySchema,
|
|
552
|
+
walletBalanceListResponseSchema,
|
|
553
|
+
walletLedgerResponseSchema,
|
|
554
|
+
walletRedemptionResponseSchema,
|
|
555
|
+
accountWalletResponseSchema,
|
|
556
|
+
accountBillingQuerySchema,
|
|
557
|
+
accountOverviewResponseSchema,
|
|
558
|
+
membershipStripeChannelSchema,
|
|
559
|
+
accountMembershipResponseSchema,
|
|
560
|
+
billingRecordItemSchema,
|
|
561
|
+
billingRecordSchema,
|
|
562
|
+
billingSummarySchema,
|
|
563
|
+
accountBillingResponseSchema,
|
|
564
|
+
storePatchSchema,
|
|
565
|
+
adminUserPatchSchema,
|
|
566
|
+
adminUserListQuerySchema,
|
|
567
|
+
adminUserSchema,
|
|
568
|
+
adminUserListResponseSchema,
|
|
569
|
+
boundLicenseSchema,
|
|
570
|
+
licenseListResponseSchema,
|
|
571
|
+
licenseAssertionSchema
|
|
572
|
+
};
|