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