zpan-cloud-sdk 1.0.0 → 1.0.2
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 +203 -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/dist/schemas.js
CHANGED
|
@@ -1,58 +1,140 @@
|
|
|
1
1
|
import {
|
|
2
2
|
accountBillingQuerySchema,
|
|
3
|
+
accountBillingResponseSchema,
|
|
4
|
+
accountMembershipResponseSchema,
|
|
5
|
+
accountOverviewResponseSchema,
|
|
3
6
|
accountUsagePeriodSchema,
|
|
4
7
|
accountUsageQuerySchema,
|
|
8
|
+
accountWalletResponseSchema,
|
|
5
9
|
adminUserListQuerySchema,
|
|
10
|
+
adminUserListResponseSchema,
|
|
6
11
|
adminUserPatchSchema,
|
|
12
|
+
adminUserSchema,
|
|
13
|
+
billingPortalSessionResponseSchema,
|
|
7
14
|
billingPortalSessionSchema,
|
|
15
|
+
billingRecordItemSchema,
|
|
16
|
+
billingRecordSchema,
|
|
17
|
+
billingSummarySchema,
|
|
18
|
+
boundLicenseSchema,
|
|
19
|
+
commerceOrderItemSchema,
|
|
20
|
+
commerceOrderSchema,
|
|
21
|
+
commercePaymentSchema,
|
|
22
|
+
commerceProductSchema,
|
|
23
|
+
commerceStoreSchema,
|
|
8
24
|
createOrderSchema,
|
|
9
25
|
createPairingSchema,
|
|
10
26
|
createProductSchema,
|
|
11
27
|
deliverableSchema,
|
|
28
|
+
entitlementRefreshResponseSchema,
|
|
12
29
|
giftCardCampaignCreateSchema,
|
|
13
30
|
giftCardCampaignListQuerySchema,
|
|
31
|
+
giftCardCampaignListResponseSchema,
|
|
32
|
+
giftCardCampaignSchema,
|
|
14
33
|
giftCardCreateSchema,
|
|
15
34
|
giftCardListQuerySchema,
|
|
35
|
+
giftCardListResponseSchema,
|
|
16
36
|
giftCardPatchSchema,
|
|
37
|
+
licenseAssertionSchema,
|
|
38
|
+
licenseListResponseSchema,
|
|
39
|
+
membershipStripeChannelSchema,
|
|
17
40
|
orderListQuerySchema,
|
|
41
|
+
orderListResponseSchema,
|
|
18
42
|
orderPatchSchema,
|
|
43
|
+
pageSchema,
|
|
19
44
|
paginationQuerySchema,
|
|
45
|
+
pairingActionResponseSchema,
|
|
20
46
|
pairingActionSchema,
|
|
47
|
+
pairingCreateResponseSchema,
|
|
48
|
+
pairingPollResponseSchema,
|
|
49
|
+
pairingPreviewSchema,
|
|
50
|
+
paymentCreateResponseSchema,
|
|
21
51
|
paymentSchema,
|
|
22
52
|
productListQuerySchema,
|
|
53
|
+
productListResponseSchema,
|
|
23
54
|
productMetadataSchema,
|
|
24
55
|
productPriceSchema,
|
|
56
|
+
storeGiftCardSchema,
|
|
57
|
+
storeListResponseSchema,
|
|
25
58
|
storePatchSchema,
|
|
26
59
|
updateProductSchema,
|
|
60
|
+
usageEventCreateResponseSchema,
|
|
27
61
|
usageEventCreateSchema,
|
|
62
|
+
usageResourceSummarySchema,
|
|
63
|
+
usageSummarySchema,
|
|
64
|
+
walletBalanceListResponseSchema,
|
|
65
|
+
walletBalanceSchema,
|
|
66
|
+
walletLedgerEntrySchema,
|
|
67
|
+
walletLedgerResponseSchema,
|
|
68
|
+
walletRedemptionResponseSchema,
|
|
28
69
|
walletRedemptionSchema
|
|
29
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-YQNXMZK4.js";
|
|
30
71
|
export {
|
|
31
72
|
accountBillingQuerySchema,
|
|
73
|
+
accountBillingResponseSchema,
|
|
74
|
+
accountMembershipResponseSchema,
|
|
75
|
+
accountOverviewResponseSchema,
|
|
32
76
|
accountUsagePeriodSchema,
|
|
33
77
|
accountUsageQuerySchema,
|
|
78
|
+
accountWalletResponseSchema,
|
|
34
79
|
adminUserListQuerySchema,
|
|
80
|
+
adminUserListResponseSchema,
|
|
35
81
|
adminUserPatchSchema,
|
|
82
|
+
adminUserSchema,
|
|
83
|
+
billingPortalSessionResponseSchema,
|
|
36
84
|
billingPortalSessionSchema,
|
|
85
|
+
billingRecordItemSchema,
|
|
86
|
+
billingRecordSchema,
|
|
87
|
+
billingSummarySchema,
|
|
88
|
+
boundLicenseSchema,
|
|
89
|
+
commerceOrderItemSchema,
|
|
90
|
+
commerceOrderSchema,
|
|
91
|
+
commercePaymentSchema,
|
|
92
|
+
commerceProductSchema,
|
|
93
|
+
commerceStoreSchema,
|
|
37
94
|
createOrderSchema,
|
|
38
95
|
createPairingSchema,
|
|
39
96
|
createProductSchema,
|
|
40
97
|
deliverableSchema,
|
|
98
|
+
entitlementRefreshResponseSchema,
|
|
41
99
|
giftCardCampaignCreateSchema,
|
|
42
100
|
giftCardCampaignListQuerySchema,
|
|
101
|
+
giftCardCampaignListResponseSchema,
|
|
102
|
+
giftCardCampaignSchema,
|
|
43
103
|
giftCardCreateSchema,
|
|
44
104
|
giftCardListQuerySchema,
|
|
105
|
+
giftCardListResponseSchema,
|
|
45
106
|
giftCardPatchSchema,
|
|
107
|
+
licenseAssertionSchema,
|
|
108
|
+
licenseListResponseSchema,
|
|
109
|
+
membershipStripeChannelSchema,
|
|
46
110
|
orderListQuerySchema,
|
|
111
|
+
orderListResponseSchema,
|
|
47
112
|
orderPatchSchema,
|
|
113
|
+
pageSchema,
|
|
48
114
|
paginationQuerySchema,
|
|
115
|
+
pairingActionResponseSchema,
|
|
49
116
|
pairingActionSchema,
|
|
117
|
+
pairingCreateResponseSchema,
|
|
118
|
+
pairingPollResponseSchema,
|
|
119
|
+
pairingPreviewSchema,
|
|
120
|
+
paymentCreateResponseSchema,
|
|
50
121
|
paymentSchema,
|
|
51
122
|
productListQuerySchema,
|
|
123
|
+
productListResponseSchema,
|
|
52
124
|
productMetadataSchema,
|
|
53
125
|
productPriceSchema,
|
|
126
|
+
storeGiftCardSchema,
|
|
127
|
+
storeListResponseSchema,
|
|
54
128
|
storePatchSchema,
|
|
55
129
|
updateProductSchema,
|
|
130
|
+
usageEventCreateResponseSchema,
|
|
56
131
|
usageEventCreateSchema,
|
|
132
|
+
usageResourceSummarySchema,
|
|
133
|
+
usageSummarySchema,
|
|
134
|
+
walletBalanceListResponseSchema,
|
|
135
|
+
walletBalanceSchema,
|
|
136
|
+
walletLedgerEntrySchema,
|
|
137
|
+
walletLedgerResponseSchema,
|
|
138
|
+
walletRedemptionResponseSchema,
|
|
57
139
|
walletRedemptionSchema
|
|
58
140
|
};
|
package/package.json
CHANGED
package/dist/chunk-VMYIHGPC.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
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 createPairingSchema = z.object({
|
|
8
|
-
instanceId: z.string().min(1).max(255),
|
|
9
|
-
instanceName: z.string().min(1).max(255),
|
|
10
|
-
instanceHost: z.string().min(1).max(512)
|
|
11
|
-
});
|
|
12
|
-
var pairingActionSchema = z.object({
|
|
13
|
-
action: z.enum(["approve", "deny"])
|
|
14
|
-
});
|
|
15
|
-
var productPriceSchema = z.object({
|
|
16
|
-
id: z.string().min(1).optional(),
|
|
17
|
-
currency: z.string().min(1),
|
|
18
|
-
amount: z.number().int().positive(),
|
|
19
|
-
lookupKey: z.string().min(1).nullable().optional(),
|
|
20
|
-
nickname: z.string().nullable().optional(),
|
|
21
|
-
recurring: z.object({
|
|
22
|
-
interval: z.enum(["day", "week", "month", "year"]),
|
|
23
|
-
intervalCount: z.number().int().positive(),
|
|
24
|
-
usageType: z.enum(["licensed", "metered"]).optional()
|
|
25
|
-
}).nullable().optional(),
|
|
26
|
-
metadata: z.record(z.string(), z.string()).optional()
|
|
27
|
-
});
|
|
28
|
-
var deliverableSchema = z.record(z.string(), z.unknown());
|
|
29
|
-
var productMetadataSchema = z.object({
|
|
30
|
-
deliverable: deliverableSchema
|
|
31
|
-
});
|
|
32
|
-
function isTrafficMeteredPrice(price) {
|
|
33
|
-
return price.recurring?.usageType === "metered" && price.metadata?.usageResource === "traffic_egress";
|
|
34
|
-
}
|
|
35
|
-
function validateTrafficMeteredPricePairs(prices, ctx) {
|
|
36
|
-
if (!prices) return;
|
|
37
|
-
for (const [index, price] of prices.entries()) {
|
|
38
|
-
if (price.recurring && (price.recurring.interval !== "month" || price.recurring.intervalCount !== 1)) {
|
|
39
|
-
ctx.addIssue({
|
|
40
|
-
code: z.ZodIssueCode.custom,
|
|
41
|
-
path: ["prices", index, "recurring"],
|
|
42
|
-
message: "Subscription prices must bill monthly"
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
if (price.recurring?.usageType === "metered" && price.metadata?.usageResource !== "traffic_egress") {
|
|
46
|
-
ctx.addIssue({
|
|
47
|
-
code: z.ZodIssueCode.custom,
|
|
48
|
-
path: ["prices", index],
|
|
49
|
-
message: "Metered traffic prices must set usageResource to traffic_egress"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (price.metadata?.usageResource === "traffic_egress" && price.recurring?.usageType !== "metered") {
|
|
53
|
-
ctx.addIssue({
|
|
54
|
-
code: z.ZodIssueCode.custom,
|
|
55
|
-
path: ["prices", index],
|
|
56
|
-
message: "Traffic overage prices must use metered billing"
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const recurringPrices = prices.filter((price) => price.recurring);
|
|
61
|
-
const currencies = new Set(recurringPrices.map((price) => price.currency));
|
|
62
|
-
for (const currency of currencies) {
|
|
63
|
-
const monthlyCount = recurringPrices.filter(
|
|
64
|
-
(price) => price.currency === currency && !isTrafficMeteredPrice(price)
|
|
65
|
-
).length;
|
|
66
|
-
if (monthlyCount !== 1) {
|
|
67
|
-
ctx.addIssue({
|
|
68
|
-
code: z.ZodIssueCode.custom,
|
|
69
|
-
path: ["prices"],
|
|
70
|
-
message: `Subscription prices for ${currency} must have exactly one monthly price`
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
const meteredCount = recurringPrices.filter(
|
|
74
|
-
(price) => price.currency === currency && isTrafficMeteredPrice(price)
|
|
75
|
-
).length;
|
|
76
|
-
if (meteredCount === 1) continue;
|
|
77
|
-
ctx.addIssue({
|
|
78
|
-
code: z.ZodIssueCode.custom,
|
|
79
|
-
path: ["prices"],
|
|
80
|
-
message: `Subscription prices for ${currency} must have exactly one metered traffic price`
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
var createProductSchema = z.object({
|
|
85
|
-
type: z.literal("store_item"),
|
|
86
|
-
name: z.string().min(1),
|
|
87
|
-
description: z.string().nullable().optional(),
|
|
88
|
-
active: z.boolean().optional(),
|
|
89
|
-
sortOrder: z.number().int().optional(),
|
|
90
|
-
metadata: productMetadataSchema,
|
|
91
|
-
prices: z.array(productPriceSchema).min(1)
|
|
92
|
-
}).superRefine((input, ctx) => validateTrafficMeteredPricePairs(input.prices, ctx));
|
|
93
|
-
var updateProductSchema = z.object({
|
|
94
|
-
type: z.literal("store_item").optional(),
|
|
95
|
-
name: z.string().min(1).optional(),
|
|
96
|
-
description: z.string().nullable().optional(),
|
|
97
|
-
active: z.boolean().optional(),
|
|
98
|
-
sortOrder: z.number().int().optional(),
|
|
99
|
-
metadata: productMetadataSchema.optional(),
|
|
100
|
-
prices: z.array(productPriceSchema).min(1).optional()
|
|
101
|
-
}).superRefine((input, ctx) => validateTrafficMeteredPricePairs(input.prices, ctx));
|
|
102
|
-
var productListQuerySchema = paginationQuerySchema.extend({
|
|
103
|
-
type: z.literal("store_item").optional(),
|
|
104
|
-
status: z.enum(["active", "inactive"]).optional()
|
|
105
|
-
});
|
|
106
|
-
var orderItemSchema = z.object({
|
|
107
|
-
productId: z.string().min(1),
|
|
108
|
-
priceId: z.string().min(1).optional(),
|
|
109
|
-
quantity: z.number().int().positive().optional().default(1)
|
|
110
|
-
});
|
|
111
|
-
var createOrderSchema = z.object({
|
|
112
|
-
items: z.array(orderItemSchema).min(1),
|
|
113
|
-
currency: z.string().min(1),
|
|
114
|
-
target: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
115
|
-
deliveryCallbackUrl: z.string().url().optional(),
|
|
116
|
-
idempotencyKey: z.string().nullable().optional()
|
|
117
|
-
});
|
|
118
|
-
var orderListQuerySchema = paginationQuerySchema.extend({
|
|
119
|
-
paymentStatus: z.enum(["unpaid", "pending", "paid", "failed", "refunded", "canceled"]).optional(),
|
|
120
|
-
fulfillmentStatus: z.enum(["pending", "fulfilled", "failed", "canceled"]).optional(),
|
|
121
|
-
customerId: z.string().min(1).optional()
|
|
122
|
-
});
|
|
123
|
-
var paymentSchema = z.object({
|
|
124
|
-
successUrl: z.string().optional(),
|
|
125
|
-
cancelUrl: z.string().optional()
|
|
126
|
-
}).strict();
|
|
127
|
-
var billingPortalSessionSchema = z.object({
|
|
128
|
-
customerId: z.string().min(1),
|
|
129
|
-
returnUrl: z.string().url()
|
|
130
|
-
}).strict();
|
|
131
|
-
var orderPatchSchema = z.object({
|
|
132
|
-
status: z.enum(["canceled"])
|
|
133
|
-
});
|
|
134
|
-
var giftCardCreateSchema = z.object({
|
|
135
|
-
amount: z.number().int().positive(),
|
|
136
|
-
currency: z.string().min(1),
|
|
137
|
-
expiresAt: z.string().optional().nullable(),
|
|
138
|
-
campaignId: z.string().optional().nullable(),
|
|
139
|
-
count: z.number().int().min(1).max(100).optional().default(1)
|
|
140
|
-
});
|
|
141
|
-
var giftCardCampaignCreateSchema = z.object({
|
|
142
|
-
name: z.string().trim().min(1),
|
|
143
|
-
startsAt: z.string().optional().nullable(),
|
|
144
|
-
expiresAt: z.string().optional().nullable()
|
|
145
|
-
});
|
|
146
|
-
var giftCardPatchSchema = z.object({
|
|
147
|
-
disabled: z.boolean().optional(),
|
|
148
|
-
revoked: z.literal(true).optional()
|
|
149
|
-
});
|
|
150
|
-
var giftCardListQuerySchema = paginationQuerySchema.extend({
|
|
151
|
-
status: z.enum(["active", "redeemed", "disabled", "expired", "revoked"]).optional(),
|
|
152
|
-
campaignId: z.string().optional()
|
|
153
|
-
});
|
|
154
|
-
var giftCardCampaignListQuerySchema = paginationQuerySchema.extend({
|
|
155
|
-
status: z.enum(["active", "disabled", "ended"]).optional()
|
|
156
|
-
});
|
|
157
|
-
var usageEventCreateSchema = z.object({
|
|
158
|
-
resource: z.literal("traffic_egress"),
|
|
159
|
-
quantity: z.number().int().positive().optional(),
|
|
160
|
-
bytes: z.number().int().positive().optional(),
|
|
161
|
-
idempotencyKey: z.string().trim().min(1).max(200).optional(),
|
|
162
|
-
eventId: z.string().trim().min(1).max(200).optional(),
|
|
163
|
-
customerId: z.string().trim().min(1)
|
|
164
|
-
}).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");
|
|
165
|
-
var accountUsagePeriodSchema = z.string().regex(/^\d{4}-(0[1-9]|1[0-2])$/);
|
|
166
|
-
var accountUsageQuerySchema = z.object({
|
|
167
|
-
customerId: z.string().trim().min(1)
|
|
168
|
-
}).strict();
|
|
169
|
-
var walletRedemptionSchema = z.object({
|
|
170
|
-
codes: z.array(z.string().trim().min(1)).min(1).max(10)
|
|
171
|
-
});
|
|
172
|
-
var accountBillingQuerySchema = paginationQuerySchema.extend({
|
|
173
|
-
ledgerLimit: z.coerce.number().int().min(1).max(100).optional().default(25),
|
|
174
|
-
ledgerOffset: z.coerce.number().int().min(0).optional().default(0)
|
|
175
|
-
});
|
|
176
|
-
var storePatchSchema = z.object({
|
|
177
|
-
name: z.string().min(1).optional(),
|
|
178
|
-
status: z.enum(["active", "disabled"]).optional()
|
|
179
|
-
});
|
|
180
|
-
var adminUserPatchSchema = z.object({
|
|
181
|
-
role: z.enum(["user", "admin"]).optional(),
|
|
182
|
-
membershipTier: z.enum(["none", "silver", "gold", "premier"]).optional(),
|
|
183
|
-
membershipStatus: z.enum(["active", "inactive", "expired"]).optional()
|
|
184
|
-
}).refine((value) => Object.keys(value).length > 0, { message: "at least one field is required" });
|
|
185
|
-
var adminUserListQuerySchema = paginationQuerySchema.extend({
|
|
186
|
-
search: z.string().trim().optional(),
|
|
187
|
-
membershipTier: z.enum(["none", "silver", "gold", "premier"]).optional()
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
export {
|
|
191
|
-
paginationQuerySchema,
|
|
192
|
-
createPairingSchema,
|
|
193
|
-
pairingActionSchema,
|
|
194
|
-
productPriceSchema,
|
|
195
|
-
deliverableSchema,
|
|
196
|
-
productMetadataSchema,
|
|
197
|
-
createProductSchema,
|
|
198
|
-
updateProductSchema,
|
|
199
|
-
productListQuerySchema,
|
|
200
|
-
createOrderSchema,
|
|
201
|
-
orderListQuerySchema,
|
|
202
|
-
paymentSchema,
|
|
203
|
-
billingPortalSessionSchema,
|
|
204
|
-
orderPatchSchema,
|
|
205
|
-
giftCardCreateSchema,
|
|
206
|
-
giftCardCampaignCreateSchema,
|
|
207
|
-
giftCardPatchSchema,
|
|
208
|
-
giftCardListQuerySchema,
|
|
209
|
-
giftCardCampaignListQuerySchema,
|
|
210
|
-
usageEventCreateSchema,
|
|
211
|
-
accountUsagePeriodSchema,
|
|
212
|
-
accountUsageQuerySchema,
|
|
213
|
-
walletRedemptionSchema,
|
|
214
|
-
accountBillingQuerySchema,
|
|
215
|
-
storePatchSchema,
|
|
216
|
-
adminUserPatchSchema,
|
|
217
|
-
adminUserListQuerySchema
|
|
218
|
-
};
|