@01.software/cli 0.15.0 → 0.16.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/dist/index.js +269 -188
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -900,6 +900,9 @@ var tenantFeatureProgressResponseSchema = z.object({
|
|
|
900
900
|
planBlocked: z.array(z.string()),
|
|
901
901
|
closureAdded: z.array(z.string())
|
|
902
902
|
}).strict(),
|
|
903
|
+
config: z.object({
|
|
904
|
+
fulfillmentMode: z.enum(["shipping", "none"])
|
|
905
|
+
}).strict(),
|
|
903
906
|
summary: z.object({
|
|
904
907
|
complete: z.number().int().nonnegative(),
|
|
905
908
|
total: z.number().int().nonnegative(),
|
|
@@ -951,7 +954,7 @@ var collectionSchemaResponseSchema = z.object({
|
|
|
951
954
|
}).strict();
|
|
952
955
|
|
|
953
956
|
// ../contracts/src/ecommerce/index.ts
|
|
954
|
-
import { z as
|
|
957
|
+
import { z as z4 } from "zod";
|
|
955
958
|
|
|
956
959
|
// ../contracts/src/ecommerce/product-upsert.ts
|
|
957
960
|
import { z as z2 } from "zod";
|
|
@@ -977,6 +980,10 @@ var productFieldShape = {
|
|
|
977
980
|
publishedAt: z2.string().optional().nullable(),
|
|
978
981
|
categories: z2.array(IdSchema).optional(),
|
|
979
982
|
tags: z2.array(IdSchema).optional(),
|
|
983
|
+
seo: z2.object({
|
|
984
|
+
title: z2.string().optional().nullable(),
|
|
985
|
+
description: z2.string().optional().nullable()
|
|
986
|
+
}).optional().nullable(),
|
|
980
987
|
metadata: z2.unknown().optional()
|
|
981
988
|
};
|
|
982
989
|
var PRODUCT_UPSERT_PRODUCT_FIELDS = Object.keys(
|
|
@@ -1102,44 +1109,86 @@ var ProductUpsertSchema = ProductUpsertObjectSchema.superRefine(
|
|
|
1102
1109
|
}
|
|
1103
1110
|
);
|
|
1104
1111
|
|
|
1112
|
+
// ../contracts/src/ecommerce/checkout.ts
|
|
1113
|
+
import { z as z3 } from "zod";
|
|
1114
|
+
var providerSlugSchema = z3.string().trim().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/, "pgProvider must be lowercase slug");
|
|
1115
|
+
var CheckoutShippingAddressSchema = z3.object({
|
|
1116
|
+
recipientName: z3.string().min(1),
|
|
1117
|
+
phone: z3.string().min(1),
|
|
1118
|
+
postalCode: z3.string().min(1),
|
|
1119
|
+
address: z3.string().min(1),
|
|
1120
|
+
detailAddress: z3.string().min(1),
|
|
1121
|
+
deliveryMessage: z3.string().optional()
|
|
1122
|
+
});
|
|
1123
|
+
var CheckoutCustomerSnapshotSchema = z3.object({
|
|
1124
|
+
name: z3.string().optional(),
|
|
1125
|
+
email: z3.string().email("Invalid email format"),
|
|
1126
|
+
phone: z3.string().optional()
|
|
1127
|
+
});
|
|
1128
|
+
var CheckoutRequestSchema = z3.object({
|
|
1129
|
+
cartId: z3.union([z3.string(), z3.number()]).transform(String),
|
|
1130
|
+
cartToken: z3.string().min(1).optional(),
|
|
1131
|
+
pgPaymentId: z3.string().min(1).optional(),
|
|
1132
|
+
pgProvider: providerSlugSchema.optional(),
|
|
1133
|
+
orderNumber: z3.string().min(1, "orderNumber is required"),
|
|
1134
|
+
customerSnapshot: CheckoutCustomerSnapshotSchema,
|
|
1135
|
+
shippingAddress: CheckoutShippingAddressSchema.optional(),
|
|
1136
|
+
discountCode: z3.string().optional()
|
|
1137
|
+
}).superRefine((data, ctx) => {
|
|
1138
|
+
if (data.pgPaymentId && !data.pgProvider) {
|
|
1139
|
+
ctx.addIssue({
|
|
1140
|
+
code: z3.ZodIssueCode.custom,
|
|
1141
|
+
path: ["pgProvider"],
|
|
1142
|
+
message: "pgProvider is required when pgPaymentId is provided"
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
if (data.pgProvider && !data.pgPaymentId) {
|
|
1146
|
+
ctx.addIssue({
|
|
1147
|
+
code: z3.ZodIssueCode.custom,
|
|
1148
|
+
path: ["pgPaymentId"],
|
|
1149
|
+
message: "pgPaymentId is required when pgProvider is provided"
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
|
|
1105
1154
|
// ../contracts/src/ecommerce/index.ts
|
|
1106
|
-
var transactionStatusSchema =
|
|
1155
|
+
var transactionStatusSchema = z4.enum([
|
|
1107
1156
|
"pending",
|
|
1108
1157
|
"paid",
|
|
1109
1158
|
"failed",
|
|
1110
1159
|
"canceled",
|
|
1111
1160
|
"refunded"
|
|
1112
1161
|
]);
|
|
1113
|
-
var financialStatusSchema =
|
|
1162
|
+
var financialStatusSchema = z4.enum([
|
|
1114
1163
|
"pending",
|
|
1115
1164
|
"paid",
|
|
1116
1165
|
"canceled",
|
|
1117
1166
|
"partially_refunded",
|
|
1118
1167
|
"refunded"
|
|
1119
1168
|
]);
|
|
1120
|
-
var orderDisplayFinancialStatusSchema =
|
|
1169
|
+
var orderDisplayFinancialStatusSchema = z4.enum([
|
|
1121
1170
|
"pending",
|
|
1122
1171
|
"paid",
|
|
1123
1172
|
"partially_refunded",
|
|
1124
1173
|
"refunded",
|
|
1125
1174
|
"voided"
|
|
1126
1175
|
]);
|
|
1127
|
-
var confirmationStatusSchema =
|
|
1128
|
-
var fulfillmentOrderStatusSchema =
|
|
1176
|
+
var confirmationStatusSchema = z4.enum(["unconfirmed", "confirmed"]);
|
|
1177
|
+
var fulfillmentOrderStatusSchema = z4.enum([
|
|
1129
1178
|
"open",
|
|
1130
1179
|
"in_progress",
|
|
1131
1180
|
"on_hold",
|
|
1132
1181
|
"canceled",
|
|
1133
1182
|
"closed"
|
|
1134
1183
|
]);
|
|
1135
|
-
var shipmentStatusSchema =
|
|
1184
|
+
var shipmentStatusSchema = z4.enum([
|
|
1136
1185
|
"pending",
|
|
1137
1186
|
"shipped",
|
|
1138
1187
|
"delivered",
|
|
1139
1188
|
"canceled",
|
|
1140
1189
|
"failed"
|
|
1141
1190
|
]);
|
|
1142
|
-
var orderDisplayFulfillmentStatusSchema =
|
|
1191
|
+
var orderDisplayFulfillmentStatusSchema = z4.enum([
|
|
1143
1192
|
"unfulfilled",
|
|
1144
1193
|
"in_progress",
|
|
1145
1194
|
"on_hold",
|
|
@@ -1148,13 +1197,13 @@ var orderDisplayFulfillmentStatusSchema = z3.enum([
|
|
|
1148
1197
|
"fulfilled",
|
|
1149
1198
|
"canceled"
|
|
1150
1199
|
]);
|
|
1151
|
-
var orderReturnStatusSchema =
|
|
1200
|
+
var orderReturnStatusSchema = z4.enum([
|
|
1152
1201
|
"no_return",
|
|
1153
1202
|
"return_requested",
|
|
1154
1203
|
"in_progress",
|
|
1155
1204
|
"returned"
|
|
1156
1205
|
]);
|
|
1157
|
-
var orderStatusSchema =
|
|
1206
|
+
var orderStatusSchema = z4.enum([
|
|
1158
1207
|
"pending",
|
|
1159
1208
|
"paid",
|
|
1160
1209
|
"canceled",
|
|
@@ -1167,81 +1216,97 @@ var orderStatusSchema = z3.enum([
|
|
|
1167
1216
|
"return_processing",
|
|
1168
1217
|
"returned"
|
|
1169
1218
|
]);
|
|
1170
|
-
var entityIdSchema =
|
|
1171
|
-
var createOrderItemSchema =
|
|
1219
|
+
var entityIdSchema = z4.union([z4.string().min(1), z4.number()]).transform(String);
|
|
1220
|
+
var createOrderItemSchema = z4.object({
|
|
1172
1221
|
// `product` and `option` are storefront-optional: the create-order
|
|
1173
1222
|
// endpoint derives the product from the variant's parent and snapshots
|
|
1174
1223
|
// option selection from the variant.
|
|
1175
1224
|
product: entityIdSchema.optional(),
|
|
1176
1225
|
variant: entityIdSchema,
|
|
1177
1226
|
option: entityIdSchema.optional(),
|
|
1178
|
-
quantity:
|
|
1179
|
-
unitPrice:
|
|
1180
|
-
totalPrice:
|
|
1227
|
+
quantity: z4.number().int().positive("quantity must be a positive integer"),
|
|
1228
|
+
unitPrice: z4.number().optional(),
|
|
1229
|
+
totalPrice: z4.number().optional()
|
|
1181
1230
|
}).strict();
|
|
1182
|
-
var
|
|
1183
|
-
|
|
1184
|
-
|
|
1231
|
+
var providerSlugSchema2 = z4.string().trim().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/, "pgProvider must be lowercase slug");
|
|
1232
|
+
var createOrderSchema = z4.object({
|
|
1233
|
+
pgPaymentId: z4.string().min(1).optional(),
|
|
1234
|
+
pgProvider: providerSlugSchema2.optional(),
|
|
1235
|
+
orderNumber: z4.string().min(1, "orderNumber is required"),
|
|
1185
1236
|
customer: entityIdSchema.optional(),
|
|
1186
|
-
customerSnapshot:
|
|
1187
|
-
name:
|
|
1188
|
-
email:
|
|
1189
|
-
phone:
|
|
1237
|
+
customerSnapshot: z4.object({
|
|
1238
|
+
name: z4.string().optional(),
|
|
1239
|
+
email: z4.string().email("Invalid email format"),
|
|
1240
|
+
phone: z4.string().optional()
|
|
1190
1241
|
}).strict(),
|
|
1191
|
-
shippingAddress:
|
|
1192
|
-
postalCode:
|
|
1193
|
-
address:
|
|
1194
|
-
detailAddress:
|
|
1195
|
-
deliveryMessage:
|
|
1196
|
-
recipientName:
|
|
1197
|
-
phone:
|
|
1242
|
+
shippingAddress: z4.object({
|
|
1243
|
+
postalCode: z4.string().optional(),
|
|
1244
|
+
address: z4.string().optional(),
|
|
1245
|
+
detailAddress: z4.string().optional(),
|
|
1246
|
+
deliveryMessage: z4.string().optional(),
|
|
1247
|
+
recipientName: z4.string().optional(),
|
|
1248
|
+
phone: z4.string().optional()
|
|
1198
1249
|
}).strict().optional(),
|
|
1199
|
-
orderItems:
|
|
1200
|
-
totalAmount:
|
|
1201
|
-
shippingAmount:
|
|
1202
|
-
discountCode:
|
|
1203
|
-
}).strict()
|
|
1204
|
-
|
|
1205
|
-
|
|
1250
|
+
orderItems: z4.array(createOrderItemSchema).min(1, "At least one order item is required").max(100, "Maximum 100 items per order"),
|
|
1251
|
+
totalAmount: z4.number().nonnegative("totalAmount must be non-negative"),
|
|
1252
|
+
shippingAmount: z4.number().min(0).optional(),
|
|
1253
|
+
discountCode: z4.string().optional()
|
|
1254
|
+
}).strict().superRefine((data, ctx) => {
|
|
1255
|
+
if (data.pgPaymentId && !data.pgProvider) {
|
|
1256
|
+
ctx.addIssue({
|
|
1257
|
+
code: z4.ZodIssueCode.custom,
|
|
1258
|
+
path: ["pgProvider"],
|
|
1259
|
+
message: "pgProvider is required when pgPaymentId is provided"
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
if (data.pgProvider && !data.pgPaymentId) {
|
|
1263
|
+
ctx.addIssue({
|
|
1264
|
+
code: z4.ZodIssueCode.custom,
|
|
1265
|
+
path: ["pgPaymentId"],
|
|
1266
|
+
message: "pgPaymentId is required when pgProvider is provided"
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
var updateTransactionSchema = z4.object({
|
|
1271
|
+
pgPaymentId: z4.string().min(1, "pgPaymentId is required").describe("PG payment ID (required)"),
|
|
1206
1272
|
status: transactionStatusSchema.describe(
|
|
1207
1273
|
"New transaction status (required)"
|
|
1208
1274
|
),
|
|
1209
|
-
paymentMethod:
|
|
1210
|
-
receiptUrl:
|
|
1211
|
-
paymentKey:
|
|
1212
|
-
amount:
|
|
1275
|
+
paymentMethod: z4.string().optional().describe("Payment method (optional)"),
|
|
1276
|
+
receiptUrl: z4.string().optional().describe("Receipt URL (optional)"),
|
|
1277
|
+
paymentKey: z4.string().min(1).optional().describe("Provider payment key for verified paid confirmation"),
|
|
1278
|
+
amount: z4.number().int().positive().optional().describe("Provider-confirmed amount for verified paid confirmation")
|
|
1213
1279
|
}).strict();
|
|
1214
|
-
var
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
pgProvider: providerSlugSchema.describe(
|
|
1280
|
+
var confirmPaymentSchema = z4.object({
|
|
1281
|
+
orderNumber: z4.string().min(1).optional(),
|
|
1282
|
+
pgPaymentId: z4.string().min(1, "pgPaymentId is required").describe("Provider payment identifier stored on the transaction"),
|
|
1283
|
+
pgProvider: providerSlugSchema2.describe(
|
|
1219
1284
|
"Payment provider slug, e.g. toss, portone, stripe"
|
|
1220
1285
|
),
|
|
1221
|
-
pgOrderId:
|
|
1222
|
-
amount:
|
|
1223
|
-
currency:
|
|
1224
|
-
paymentMethod:
|
|
1225
|
-
receiptUrl:
|
|
1226
|
-
approvedAt:
|
|
1227
|
-
providerStatus:
|
|
1228
|
-
providerEventId:
|
|
1229
|
-
confirmationSource:
|
|
1286
|
+
pgOrderId: z4.string().min(1).optional(),
|
|
1287
|
+
amount: z4.number().int().nonnegative("amount must be non-negative").describe("Provider-confirmed amount in minor units"),
|
|
1288
|
+
currency: z4.string().min(1).optional(),
|
|
1289
|
+
paymentMethod: z4.string().optional(),
|
|
1290
|
+
receiptUrl: z4.string().url().optional(),
|
|
1291
|
+
approvedAt: z4.string().optional(),
|
|
1292
|
+
providerStatus: z4.string().optional(),
|
|
1293
|
+
providerEventId: z4.string().min(1).optional(),
|
|
1294
|
+
confirmationSource: z4.enum([
|
|
1230
1295
|
"provider_webhook",
|
|
1231
1296
|
"provider_lookup",
|
|
1232
1297
|
"provider_api_confirm",
|
|
1233
1298
|
"manual_server"
|
|
1234
1299
|
]).optional(),
|
|
1235
|
-
paymentKey:
|
|
1300
|
+
paymentKey: z4.string().min(1).optional().describe(
|
|
1236
1301
|
"Optional provider payment key from the client confirm handshake; stored for BFF/provider refund workflows (also accepted as metadata.tossPaymentKey). Local cancel does not read this field."
|
|
1237
1302
|
),
|
|
1238
|
-
metadata:
|
|
1303
|
+
metadata: z4.record(z4.string(), z4.unknown()).optional()
|
|
1239
1304
|
}).strict();
|
|
1240
|
-
var confirmPaymentResponseSchema =
|
|
1241
|
-
orderId:
|
|
1242
|
-
transactionId:
|
|
1243
|
-
status:
|
|
1244
|
-
alreadyConfirmed:
|
|
1305
|
+
var confirmPaymentResponseSchema = z4.object({
|
|
1306
|
+
orderId: z4.string().min(1),
|
|
1307
|
+
transactionId: z4.string().min(1),
|
|
1308
|
+
status: z4.literal("paid"),
|
|
1309
|
+
alreadyConfirmed: z4.boolean().optional()
|
|
1245
1310
|
}).strict();
|
|
1246
1311
|
var RETURN_REASON_CODES = [
|
|
1247
1312
|
"change_of_mind",
|
|
@@ -1250,42 +1315,51 @@ var RETURN_REASON_CODES = [
|
|
|
1250
1315
|
"damaged",
|
|
1251
1316
|
"other"
|
|
1252
1317
|
];
|
|
1253
|
-
var returnReasonSchema =
|
|
1254
|
-
var
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1318
|
+
var returnReasonSchema = z4.enum(RETURN_REASON_CODES);
|
|
1319
|
+
var RETURN_REJECTION_REASON_CODES = [
|
|
1320
|
+
"window_expired",
|
|
1321
|
+
"used_or_damaged",
|
|
1322
|
+
"non_returnable",
|
|
1323
|
+
"other"
|
|
1324
|
+
];
|
|
1325
|
+
var returnRejectionReasonCodeSchema = z4.enum(
|
|
1326
|
+
RETURN_REJECTION_REASON_CODES
|
|
1327
|
+
);
|
|
1328
|
+
var restockActionSchema = z4.enum(["return_to_stock", "discard"]);
|
|
1329
|
+
var returnWithRefundItemSchema = z4.object({
|
|
1330
|
+
orderItem: z4.union([z4.string().min(1), z4.number()]).transform(String),
|
|
1331
|
+
quantity: z4.number().int().positive("quantity must be a positive integer"),
|
|
1258
1332
|
restockAction: restockActionSchema.default("return_to_stock"),
|
|
1259
|
-
restockingFee:
|
|
1333
|
+
restockingFee: z4.number().min(0, "restockingFee must be non-negative").optional().describe("Restocking fee charged for this line (ADR 0005 \xA7Gap 1)")
|
|
1260
1334
|
}).strict();
|
|
1261
|
-
var returnWithRefundSchema =
|
|
1262
|
-
orderNumber:
|
|
1335
|
+
var returnWithRefundSchema = z4.object({
|
|
1336
|
+
orderNumber: z4.string().min(1, "orderNumber is required").describe("Order number (required)"),
|
|
1263
1337
|
reason: returnReasonSchema.optional().describe("Return reason (optional)"),
|
|
1264
|
-
reasonDetail:
|
|
1265
|
-
returnItems:
|
|
1266
|
-
refundAmount:
|
|
1267
|
-
returnShippingFee:
|
|
1338
|
+
reasonDetail: z4.string().optional().describe("Detailed reason text (optional)"),
|
|
1339
|
+
returnItems: z4.array(returnWithRefundItemSchema).min(1, "At least one return item is required").max(100, "Too many return items").describe("Array of products to return (required)"),
|
|
1340
|
+
refundAmount: z4.number().min(0, "refundAmount must be non-negative").describe("Refund amount (required, min 0)"),
|
|
1341
|
+
returnShippingFee: z4.number().min(0, "returnShippingFee must be non-negative").optional().describe(
|
|
1268
1342
|
"Return shipping fee charged to the customer (ADR 0005 \xA7Gap 1)"
|
|
1269
1343
|
),
|
|
1270
|
-
initialShippingRefundAmount:
|
|
1271
|
-
initialShippingRefundOverrideNote:
|
|
1344
|
+
initialShippingRefundAmount: z4.number().min(0, "initialShippingRefundAmount must be non-negative").optional().describe("Initial order shipping amount refunded to the customer"),
|
|
1345
|
+
initialShippingRefundOverrideNote: z4.string().min(1).optional().describe(
|
|
1272
1346
|
"Operator audit note required when overriding policy suggestion"
|
|
1273
1347
|
),
|
|
1274
|
-
pgPaymentId:
|
|
1275
|
-
paymentKey:
|
|
1276
|
-
refundReceiptUrl:
|
|
1348
|
+
pgPaymentId: z4.string().min(1, "pgPaymentId is required").describe("PG payment ID for refund (required)"),
|
|
1349
|
+
paymentKey: z4.string().min(1).optional().describe("Provider payment key for verified refund"),
|
|
1350
|
+
refundReceiptUrl: z4.string().optional().describe("Refund receipt URL (optional)")
|
|
1277
1351
|
}).strict();
|
|
1278
|
-
var createReturnSchema =
|
|
1279
|
-
orderNumber:
|
|
1352
|
+
var createReturnSchema = z4.object({
|
|
1353
|
+
orderNumber: z4.string().min(1, "orderNumber is required").describe("Order number (required)"),
|
|
1280
1354
|
reason: returnReasonSchema.optional().describe("Return reason (optional)"),
|
|
1281
|
-
reasonDetail:
|
|
1282
|
-
returnItems:
|
|
1283
|
-
refundAmount:
|
|
1355
|
+
reasonDetail: z4.string().optional().describe("Detailed reason text (optional)"),
|
|
1356
|
+
returnItems: z4.array(returnWithRefundItemSchema).min(1, "At least one return item is required").max(100, "Too many return items").describe("Array of products to return (required)"),
|
|
1357
|
+
refundAmount: z4.number().min(0, "refundAmount must be non-negative").describe(
|
|
1284
1358
|
"Line refund amount before initial shipping refund (required, min 0)"
|
|
1285
1359
|
),
|
|
1286
|
-
returnShippingFee:
|
|
1287
|
-
initialShippingRefundAmount:
|
|
1288
|
-
initialShippingRefundOverrideNote:
|
|
1360
|
+
returnShippingFee: z4.number().min(0, "returnShippingFee must be non-negative").optional().describe("Return shipping fee charged to the customer"),
|
|
1361
|
+
initialShippingRefundAmount: z4.number().min(0, "initialShippingRefundAmount must be non-negative").optional().describe("Initial order shipping amount refunded to the customer"),
|
|
1362
|
+
initialShippingRefundOverrideNote: z4.string().min(1).optional().describe(
|
|
1289
1363
|
"Operator audit note required when overriding policy suggestion"
|
|
1290
1364
|
)
|
|
1291
1365
|
}).strict();
|
|
@@ -1297,54 +1371,54 @@ var CANCEL_REASON_CODES = [
|
|
|
1297
1371
|
"staff",
|
|
1298
1372
|
"other"
|
|
1299
1373
|
];
|
|
1300
|
-
var cancelReasonCodeSchema =
|
|
1374
|
+
var cancelReasonCodeSchema = z4.enum(CANCEL_REASON_CODES);
|
|
1301
1375
|
var FORCE_RESOLUTION_REASON_CODES = [
|
|
1302
1376
|
"staff_error",
|
|
1303
1377
|
"wrong_fulfillment",
|
|
1304
1378
|
"other"
|
|
1305
1379
|
];
|
|
1306
|
-
var forceResolutionReasonCodeSchema =
|
|
1380
|
+
var forceResolutionReasonCodeSchema = z4.enum(
|
|
1307
1381
|
FORCE_RESOLUTION_REASON_CODES
|
|
1308
1382
|
);
|
|
1309
|
-
var idempotencyKeySchema =
|
|
1383
|
+
var idempotencyKeySchema = z4.string().trim().min(1, "idempotencyKey is required").max(255, "idempotencyKey must be 255 characters or fewer").regex(
|
|
1310
1384
|
/^[\x21-\x7E]+$/,
|
|
1311
1385
|
"idempotencyKey must contain only printable header-safe characters"
|
|
1312
1386
|
);
|
|
1313
|
-
var cancelOrderSchema =
|
|
1314
|
-
orderNumber:
|
|
1387
|
+
var cancelOrderSchema = z4.object({
|
|
1388
|
+
orderNumber: z4.string().min(1, "orderNumber is required").describe("Order number to cancel"),
|
|
1315
1389
|
reasonCode: cancelReasonCodeSchema.default("other").describe("Operator-selected cancel reason code"),
|
|
1316
|
-
reasonDetail:
|
|
1390
|
+
reasonDetail: z4.string().trim().max(2e3, "reasonDetail must be 2000 characters or fewer").optional().describe("Internal cancellation detail stored on the order")
|
|
1317
1391
|
}).strict();
|
|
1318
1392
|
var cancelOrderResponseBaseSchema = {
|
|
1319
|
-
orderId:
|
|
1393
|
+
orderId: z4.string().min(1)
|
|
1320
1394
|
};
|
|
1321
1395
|
var unpaidLocalCancelCommittedResponseFields = {
|
|
1322
|
-
refundedAmount:
|
|
1323
|
-
providerRefunded:
|
|
1396
|
+
refundedAmount: z4.literal(0),
|
|
1397
|
+
providerRefunded: z4.literal(false)
|
|
1324
1398
|
};
|
|
1325
1399
|
var paidLocalCancelCommittedResponseFields = {
|
|
1326
|
-
transactionId:
|
|
1327
|
-
refundedAmount:
|
|
1328
|
-
providerRefunded:
|
|
1329
|
-
refundPending:
|
|
1400
|
+
transactionId: z4.string().min(1),
|
|
1401
|
+
refundedAmount: z4.literal(0),
|
|
1402
|
+
providerRefunded: z4.literal(false),
|
|
1403
|
+
refundPending: z4.literal(true)
|
|
1330
1404
|
};
|
|
1331
1405
|
var legacyProviderRefundResponseFields = {
|
|
1332
|
-
transactionId:
|
|
1333
|
-
refundedAmount:
|
|
1334
|
-
refundSeq:
|
|
1335
|
-
providerRefunded:
|
|
1406
|
+
transactionId: z4.string().min(1),
|
|
1407
|
+
refundedAmount: z4.number().int().positive(),
|
|
1408
|
+
refundSeq: z4.number().int().positive(),
|
|
1409
|
+
providerRefunded: z4.literal(true)
|
|
1336
1410
|
};
|
|
1337
1411
|
var alreadyCanceledResponseFields = {
|
|
1338
|
-
refundedAmount:
|
|
1339
|
-
providerRefunded:
|
|
1412
|
+
refundedAmount: z4.number().int().nonnegative(),
|
|
1413
|
+
providerRefunded: z4.literal(false)
|
|
1340
1414
|
};
|
|
1341
1415
|
var alreadyCanceledRefundPendingResponseFields = {
|
|
1342
|
-
transactionId:
|
|
1343
|
-
refundedAmount:
|
|
1344
|
-
providerRefunded:
|
|
1345
|
-
refundPending:
|
|
1416
|
+
transactionId: z4.string().min(1),
|
|
1417
|
+
refundedAmount: z4.number().int().nonnegative(),
|
|
1418
|
+
providerRefunded: z4.literal(false),
|
|
1419
|
+
refundPending: z4.literal(true)
|
|
1346
1420
|
};
|
|
1347
|
-
var cancelOrderReconciliationStatusSchema =
|
|
1421
|
+
var cancelOrderReconciliationStatusSchema = z4.enum([
|
|
1348
1422
|
"paid",
|
|
1349
1423
|
"preparing",
|
|
1350
1424
|
"shipped",
|
|
@@ -1355,132 +1429,133 @@ var cancelOrderReconciliationStatusSchema = z3.enum([
|
|
|
1355
1429
|
"returned",
|
|
1356
1430
|
"refunded"
|
|
1357
1431
|
]);
|
|
1358
|
-
var cancelOrderResponseSchema =
|
|
1359
|
-
|
|
1432
|
+
var cancelOrderResponseSchema = z4.union([
|
|
1433
|
+
z4.object({
|
|
1360
1434
|
...cancelOrderResponseBaseSchema,
|
|
1361
1435
|
...paidLocalCancelCommittedResponseFields,
|
|
1362
|
-
status:
|
|
1363
|
-
cancelCommitted:
|
|
1436
|
+
status: z4.literal("canceled"),
|
|
1437
|
+
cancelCommitted: z4.literal(true)
|
|
1364
1438
|
}).strict(),
|
|
1365
|
-
|
|
1439
|
+
z4.object({
|
|
1366
1440
|
...cancelOrderResponseBaseSchema,
|
|
1367
1441
|
...unpaidLocalCancelCommittedResponseFields,
|
|
1368
|
-
status:
|
|
1369
|
-
cancelCommitted:
|
|
1442
|
+
status: z4.literal("canceled"),
|
|
1443
|
+
cancelCommitted: z4.literal(true)
|
|
1370
1444
|
}).strict(),
|
|
1371
|
-
|
|
1445
|
+
z4.object({
|
|
1372
1446
|
...cancelOrderResponseBaseSchema,
|
|
1373
1447
|
...alreadyCanceledResponseFields,
|
|
1374
|
-
status:
|
|
1375
|
-
cancelCommitted:
|
|
1376
|
-
alreadyCanceled:
|
|
1448
|
+
status: z4.literal("canceled"),
|
|
1449
|
+
cancelCommitted: z4.literal(false),
|
|
1450
|
+
alreadyCanceled: z4.literal(true)
|
|
1377
1451
|
}).strict(),
|
|
1378
|
-
|
|
1452
|
+
z4.object({
|
|
1379
1453
|
...cancelOrderResponseBaseSchema,
|
|
1380
1454
|
...alreadyCanceledRefundPendingResponseFields,
|
|
1381
|
-
status:
|
|
1382
|
-
cancelCommitted:
|
|
1383
|
-
alreadyCanceled:
|
|
1455
|
+
status: z4.literal("canceled"),
|
|
1456
|
+
cancelCommitted: z4.literal(false),
|
|
1457
|
+
alreadyCanceled: z4.literal(true)
|
|
1384
1458
|
}).strict(),
|
|
1385
|
-
|
|
1459
|
+
z4.object({
|
|
1386
1460
|
...cancelOrderResponseBaseSchema,
|
|
1387
1461
|
...legacyProviderRefundResponseFields,
|
|
1388
1462
|
status: cancelOrderReconciliationStatusSchema,
|
|
1389
|
-
cancelCommitted:
|
|
1390
|
-
reconciliationRequired:
|
|
1463
|
+
cancelCommitted: z4.literal(false),
|
|
1464
|
+
reconciliationRequired: z4.literal(true)
|
|
1391
1465
|
}).strict()
|
|
1392
1466
|
]);
|
|
1393
|
-
var resolveCancelRefundOutcomeSchema =
|
|
1394
|
-
var resolveCancelRefundSchema =
|
|
1395
|
-
orderNumber:
|
|
1467
|
+
var resolveCancelRefundOutcomeSchema = z4.enum(["succeeded", "failed"]);
|
|
1468
|
+
var resolveCancelRefundSchema = z4.object({
|
|
1469
|
+
orderNumber: z4.string().min(1, "orderNumber is required").describe("Order number whose pending cancel refund is being resolved"),
|
|
1396
1470
|
idempotencyKey: idempotencyKeySchema.describe(
|
|
1397
1471
|
"Stable key for this PG refund result report"
|
|
1398
1472
|
),
|
|
1399
1473
|
outcome: resolveCancelRefundOutcomeSchema.describe(
|
|
1400
1474
|
"PG refund result reported by the storefront or BFF"
|
|
1401
1475
|
),
|
|
1402
|
-
refundedAmount:
|
|
1403
|
-
pgProvider:
|
|
1476
|
+
refundedAmount: z4.number().int("refundedAmount must be an integer minor-unit amount").nonnegative("refundedAmount must be nonnegative"),
|
|
1477
|
+
pgProvider: z4.string().trim().min(1, "pgProvider is required").regex(
|
|
1404
1478
|
/^[a-z0-9][a-z0-9_-]*$/,
|
|
1405
1479
|
"pgProvider must be a lowercase provider slug"
|
|
1406
1480
|
),
|
|
1407
|
-
pgRefundId:
|
|
1481
|
+
pgRefundId: z4.string().trim().min(1).optional()
|
|
1408
1482
|
}).strict().superRefine((value, ctx) => {
|
|
1409
1483
|
if (value.outcome === "succeeded" && value.refundedAmount <= 0) {
|
|
1410
1484
|
ctx.addIssue({
|
|
1411
|
-
code:
|
|
1485
|
+
code: z4.ZodIssueCode.custom,
|
|
1412
1486
|
path: ["refundedAmount"],
|
|
1413
1487
|
message: "refundedAmount must be positive when outcome is succeeded"
|
|
1414
1488
|
});
|
|
1415
1489
|
}
|
|
1416
1490
|
if (value.outcome === "succeeded" && !value.pgRefundId) {
|
|
1417
1491
|
ctx.addIssue({
|
|
1418
|
-
code:
|
|
1492
|
+
code: z4.ZodIssueCode.custom,
|
|
1419
1493
|
path: ["pgRefundId"],
|
|
1420
1494
|
message: "pgRefundId is required when outcome is succeeded"
|
|
1421
1495
|
});
|
|
1422
1496
|
}
|
|
1423
1497
|
if (value.outcome === "failed" && value.refundedAmount !== 0) {
|
|
1424
1498
|
ctx.addIssue({
|
|
1425
|
-
code:
|
|
1499
|
+
code: z4.ZodIssueCode.custom,
|
|
1426
1500
|
path: ["refundedAmount"],
|
|
1427
1501
|
message: "refundedAmount must be 0 when outcome is failed"
|
|
1428
1502
|
});
|
|
1429
1503
|
}
|
|
1430
1504
|
});
|
|
1431
|
-
var resolveCancelRefundResponseSchema =
|
|
1432
|
-
|
|
1433
|
-
orderId:
|
|
1434
|
-
transactionId:
|
|
1435
|
-
refundTransactionId:
|
|
1436
|
-
refundedAmount:
|
|
1437
|
-
refundStatus:
|
|
1438
|
-
transactionStatus:
|
|
1505
|
+
var resolveCancelRefundResponseSchema = z4.union([
|
|
1506
|
+
z4.object({
|
|
1507
|
+
orderId: z4.string().min(1),
|
|
1508
|
+
transactionId: z4.string().min(1),
|
|
1509
|
+
refundTransactionId: z4.string().min(1),
|
|
1510
|
+
refundedAmount: z4.number().int().positive(),
|
|
1511
|
+
refundStatus: z4.literal("succeeded"),
|
|
1512
|
+
transactionStatus: z4.literal("refunded")
|
|
1439
1513
|
}).strict(),
|
|
1440
|
-
|
|
1441
|
-
orderId:
|
|
1442
|
-
transactionId:
|
|
1443
|
-
refundTransactionId:
|
|
1444
|
-
refundedAmount:
|
|
1445
|
-
refundStatus:
|
|
1446
|
-
transactionStatus:
|
|
1514
|
+
z4.object({
|
|
1515
|
+
orderId: z4.string().min(1),
|
|
1516
|
+
transactionId: z4.string().min(1),
|
|
1517
|
+
refundTransactionId: z4.string().min(1),
|
|
1518
|
+
refundedAmount: z4.literal(0),
|
|
1519
|
+
refundStatus: z4.literal("failed"),
|
|
1520
|
+
transactionStatus: z4.literal("paid")
|
|
1447
1521
|
}).strict()
|
|
1448
1522
|
]);
|
|
1449
1523
|
|
|
1450
1524
|
// src/commands/order.ts
|
|
1451
|
-
import { z as
|
|
1452
|
-
var idSchema =
|
|
1453
|
-
var customerSnapshotSchema =
|
|
1454
|
-
email:
|
|
1455
|
-
name:
|
|
1456
|
-
phone:
|
|
1525
|
+
import { z as z5 } from "zod";
|
|
1526
|
+
var idSchema = z5.union([z5.string().min(1), z5.number()]).transform(String);
|
|
1527
|
+
var customerSnapshotSchema = z5.object({
|
|
1528
|
+
email: z5.string().email("Invalid email format"),
|
|
1529
|
+
name: z5.string().optional(),
|
|
1530
|
+
phone: z5.string().optional()
|
|
1457
1531
|
}).strict();
|
|
1458
|
-
var orderStatusSchema2 =
|
|
1459
|
-
var fulfillmentStatusSchema =
|
|
1460
|
-
var updateFulfillmentSchema =
|
|
1532
|
+
var orderStatusSchema2 = z5.enum(["confirmed"]);
|
|
1533
|
+
var fulfillmentStatusSchema = z5.enum(["shipped", "delivered", "failed"]);
|
|
1534
|
+
var updateFulfillmentSchema = z5.object({
|
|
1461
1535
|
fulfillmentId: idSchema,
|
|
1462
1536
|
status: fulfillmentStatusSchema.optional(),
|
|
1463
|
-
carrier:
|
|
1464
|
-
trackingNumber:
|
|
1537
|
+
carrier: z5.string().min(1).optional(),
|
|
1538
|
+
trackingNumber: z5.string().min(1).optional()
|
|
1465
1539
|
}).refine(
|
|
1466
1540
|
(value) => value.status !== void 0 || value.carrier !== void 0 || value.trackingNumber !== void 0,
|
|
1467
1541
|
{
|
|
1468
1542
|
message: "status, carrier, or trackingNumber is required"
|
|
1469
1543
|
}
|
|
1470
1544
|
);
|
|
1471
|
-
var fulfillmentItemsSchema =
|
|
1472
|
-
|
|
1545
|
+
var fulfillmentItemsSchema = z5.array(
|
|
1546
|
+
z5.object({
|
|
1473
1547
|
orderItem: idSchema,
|
|
1474
|
-
quantity:
|
|
1548
|
+
quantity: z5.number().int().positive("quantity must be a positive integer")
|
|
1475
1549
|
}).strict()
|
|
1476
1550
|
).min(1, "At least one fulfillment item is required").max(100, "Maximum 100 items per fulfillment");
|
|
1477
1551
|
function registerOrderCommands(program2, getClient2, getFormat2) {
|
|
1478
1552
|
const order = program2.command("order").description("Order management");
|
|
1479
|
-
order.command("create").description("Create a new order").option("--payment-id <id>", "Payment ID").requiredOption("--order-number <num>", "Order number").requiredOption("--email <email>", "Customer email").option("--customer <id>", "Customer ID").option("--name <name>", "Customer name").option("--phone <phone>", "Customer phone").requiredOption("--shipping-address <json>", "Shipping address (JSON)").requiredOption("--products <json>", "Order products array (JSON)").requiredOption("--total-amount <n>", "Total amount", parseFloat).option("--shipping-amount <n>", "Shipping amount", parseFloat).option("--discount-code <code>", "Discount code").option("--dry-run", "Validate inputs without executing").action(async (opts) => {
|
|
1553
|
+
order.command("create").description("Create a new order").option("--payment-id <id>", "Payment ID").option("--provider <slug>", "Payment provider slug").requiredOption("--order-number <num>", "Order number").requiredOption("--email <email>", "Customer email").option("--customer <id>", "Customer ID").option("--name <name>", "Customer name").option("--phone <phone>", "Customer phone").requiredOption("--shipping-address <json>", "Shipping address (JSON)").requiredOption("--products <json>", "Order products array (JSON)").requiredOption("--total-amount <n>", "Total amount", parseFloat).option("--shipping-amount <n>", "Shipping amount", parseFloat).option("--discount-code <code>", "Discount code").option("--dry-run", "Validate inputs without executing").action(async (opts) => {
|
|
1480
1554
|
try {
|
|
1481
|
-
const
|
|
1555
|
+
const parsed = parseWithSchema(
|
|
1482
1556
|
{
|
|
1483
|
-
pgPaymentId: opts.paymentId,
|
|
1557
|
+
...opts.paymentId ? { pgPaymentId: opts.paymentId } : {},
|
|
1558
|
+
...opts.provider ? { pgProvider: opts.provider } : {},
|
|
1484
1559
|
orderNumber: opts.orderNumber,
|
|
1485
1560
|
customerSnapshot: {
|
|
1486
1561
|
email: opts.email,
|
|
@@ -1500,6 +1575,8 @@ function registerOrderCommands(program2, getClient2, getFormat2) {
|
|
|
1500
1575
|
"order",
|
|
1501
1576
|
createOrderSchema
|
|
1502
1577
|
);
|
|
1578
|
+
const { pgPaymentId, pgProvider, ...orderData } = parsed;
|
|
1579
|
+
const data = pgPaymentId ? { ...orderData, pgPaymentId, pgProvider } : orderData;
|
|
1503
1580
|
if (opts.dryRun) {
|
|
1504
1581
|
printResult(
|
|
1505
1582
|
{ dryRun: true, valid: true, action: "order create", data },
|
|
@@ -1576,19 +1653,26 @@ function registerOrderCommands(program2, getClient2, getFormat2) {
|
|
|
1576
1653
|
exitWithError(e);
|
|
1577
1654
|
}
|
|
1578
1655
|
});
|
|
1579
|
-
order.command("checkout").description("Convert a cart to an order").requiredOption("--cart-id <id>", "Cart ID").option("--payment-id <id>", "Payment ID (optional for free orders)").requiredOption("--order-number <num>", "Order number").requiredOption("--customer <json>", "Customer snapshot (JSON)").option("--dry-run", "Validate inputs without executing").action(async (opts) => {
|
|
1656
|
+
order.command("checkout").description("Convert a cart to an order").requiredOption("--cart-id <id>", "Cart ID").option("--payment-id <id>", "Payment ID (optional for free orders)").option("--provider <slug>", "Payment provider slug").requiredOption("--order-number <num>", "Order number").requiredOption("--customer <json>", "Customer snapshot (JSON)").option("--dry-run", "Validate inputs without executing").action(async (opts) => {
|
|
1580
1657
|
try {
|
|
1581
1658
|
const customerSnapshot = parseWithSchema(
|
|
1582
1659
|
parseJson(opts.customer, "customer"),
|
|
1583
1660
|
"customer",
|
|
1584
1661
|
customerSnapshotSchema
|
|
1585
1662
|
);
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1663
|
+
const parsed = parseWithSchema(
|
|
1664
|
+
{
|
|
1665
|
+
cartId: opts.cartId,
|
|
1666
|
+
...opts.paymentId ? { pgPaymentId: opts.paymentId } : {},
|
|
1667
|
+
...opts.provider ? { pgProvider: opts.provider } : {},
|
|
1668
|
+
orderNumber: opts.orderNumber,
|
|
1669
|
+
customerSnapshot
|
|
1670
|
+
},
|
|
1671
|
+
"checkout",
|
|
1672
|
+
CheckoutRequestSchema
|
|
1673
|
+
);
|
|
1674
|
+
const { pgPaymentId, pgProvider, ...checkoutData } = parsed;
|
|
1675
|
+
const data = pgPaymentId ? { ...checkoutData, pgPaymentId, pgProvider } : checkoutData;
|
|
1592
1676
|
if (opts.dryRun) {
|
|
1593
1677
|
printResult(
|
|
1594
1678
|
{ dryRun: true, valid: true, action: "order checkout", data },
|
|
@@ -1597,10 +1681,7 @@ function registerOrderCommands(program2, getClient2, getFormat2) {
|
|
|
1597
1681
|
return;
|
|
1598
1682
|
}
|
|
1599
1683
|
const client = getClient2();
|
|
1600
|
-
const result = await client.commerce.orders.checkout(
|
|
1601
|
-
...data,
|
|
1602
|
-
customerSnapshot
|
|
1603
|
-
});
|
|
1684
|
+
const result = await client.commerce.orders.checkout(data);
|
|
1604
1685
|
printResult(result, getFormat2());
|
|
1605
1686
|
} catch (e) {
|
|
1606
1687
|
exitWithError(e);
|
|
@@ -1689,8 +1770,8 @@ function registerOrderCommands(program2, getClient2, getFormat2) {
|
|
|
1689
1770
|
}
|
|
1690
1771
|
|
|
1691
1772
|
// src/commands/return.ts
|
|
1692
|
-
import { z as
|
|
1693
|
-
var returnStatusSchema =
|
|
1773
|
+
import { z as z6 } from "zod";
|
|
1774
|
+
var returnStatusSchema = z6.enum([
|
|
1694
1775
|
"processing",
|
|
1695
1776
|
"approved",
|
|
1696
1777
|
"rejected",
|
|
@@ -1982,14 +2063,14 @@ function registerStockCommands(program2, getClient2, getFormat2) {
|
|
|
1982
2063
|
}
|
|
1983
2064
|
|
|
1984
2065
|
// src/commands/transaction.ts
|
|
1985
|
-
import { z as
|
|
1986
|
-
var transactionAmountSchema =
|
|
1987
|
-
amount:
|
|
2066
|
+
import { z as z7 } from "zod";
|
|
2067
|
+
var transactionAmountSchema = z7.object({
|
|
2068
|
+
amount: z7.string().regex(/^[1-9]\d*$/, "amount must be a positive integer").transform(Number)
|
|
1988
2069
|
});
|
|
1989
|
-
var confirmPaymentAmountSchema =
|
|
1990
|
-
amount:
|
|
2070
|
+
var confirmPaymentAmountSchema = z7.object({
|
|
2071
|
+
amount: z7.string().regex(/^(0|[1-9]\d*)$/, "amount must be a non-negative integer").transform(Number)
|
|
1991
2072
|
});
|
|
1992
|
-
var idempotencyKeyOptionSchema =
|
|
2073
|
+
var idempotencyKeyOptionSchema = z7.object({
|
|
1993
2074
|
idempotencyKey: idempotencyKeySchema
|
|
1994
2075
|
});
|
|
1995
2076
|
function parseTransactionAmount(value) {
|