@01.software/cli 0.11.2 → 0.13.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
@@ -808,79 +808,511 @@ function registerCrudCommands(program2, getClient2, getFormat2) {
808
808
  });
809
809
  }
810
810
 
811
- // src/commands/order.ts
811
+ // ../contracts/src/tenant/index.ts
812
812
  import { z } from "zod";
813
- var idSchema = z.union([z.string().min(1), z.number()]).transform(String);
814
- var customerSnapshotSchema = z.object({
815
- email: z.string().email("Invalid email format"),
816
- name: z.string().optional(),
817
- phone: z.string().optional()
813
+ var tenantFieldConfigStateSchema = z.object({
814
+ hiddenFields: z.array(z.string()),
815
+ isHidden: z.boolean()
816
+ }).strict();
817
+ var tenantContextQuerySchema = z.object({
818
+ counts: z.literal("true").optional()
819
+ }).strict();
820
+ var tenantContextToolInputSchema = z.object({
821
+ includeCounts: z.boolean().optional().default(false).describe(
822
+ "Include per-collection document counts and config status (bypasses cache, slower)"
823
+ )
824
+ }).strict();
825
+ var tenantContextResponseSchema = z.object({
826
+ tenant: z.object({
827
+ id: z.string(),
828
+ name: z.string(),
829
+ plan: z.string(),
830
+ planSource: z.string().optional(),
831
+ authoritative: z.boolean().optional(),
832
+ capabilityVersion: z.string().optional()
833
+ }).strict(),
834
+ features: z.array(z.string()),
835
+ collections: z.object({
836
+ active: z.array(z.string()),
837
+ inactive: z.array(z.string())
838
+ }).strict(),
839
+ fieldConfigs: z.record(z.string(), tenantFieldConfigStateSchema),
840
+ counts: z.record(z.string(), z.number()).optional(),
841
+ config: z.object({
842
+ webhookConfigured: z.boolean()
843
+ }).strict().optional()
844
+ }).strict();
845
+ var tenantFeatureProgressFeatureSchema = z.enum(["ecommerce"]);
846
+ var tenantFeatureProgressInputSchema = z.object({
847
+ feature: tenantFeatureProgressFeatureSchema.describe(
848
+ "Feature to inspect for tenant implementation readiness"
849
+ ),
850
+ includeEvidence: z.boolean().optional().default(false).describe("Include sanitized counts and static surface evidence")
851
+ }).strict();
852
+ var tenantFeatureProgressStatusSchema = z.enum([
853
+ "ready",
854
+ "attention",
855
+ "blocked"
856
+ ]);
857
+ var tenantFeatureProgressItemStateSchema = z.enum([
858
+ "complete",
859
+ "incomplete",
860
+ "blocked",
861
+ "attention",
862
+ "optional",
863
+ "unknown",
864
+ "manual",
865
+ "not-applicable"
866
+ ]);
867
+ var tenantFeatureProgressSeveritySchema = z.enum([
868
+ "required",
869
+ "recommended",
870
+ "optional"
871
+ ]);
872
+ var tenantFeatureProgressEvidenceValueSchema = z.union([
873
+ z.string(),
874
+ z.number(),
875
+ z.boolean(),
876
+ z.null()
877
+ ]);
878
+ var tenantFeatureProgressItemSchema = z.object({
879
+ id: z.string(),
880
+ title: z.string(),
881
+ state: tenantFeatureProgressItemStateSchema,
882
+ severity: tenantFeatureProgressSeveritySchema,
883
+ summary: z.string(),
884
+ evidence: z.record(z.string(), tenantFeatureProgressEvidenceValueSchema).optional()
885
+ }).strict();
886
+ var tenantFeatureProgressGroupSchema = z.object({
887
+ id: z.string(),
888
+ title: z.string(),
889
+ summary: z.string().optional(),
890
+ items: z.array(tenantFeatureProgressItemSchema)
891
+ }).strict();
892
+ var tenantFeatureProgressResponseSchema = z.object({
893
+ schemaVersion: z.literal(1),
894
+ feature: tenantFeatureProgressFeatureSchema,
895
+ status: tenantFeatureProgressStatusSchema,
896
+ generatedAt: z.string(),
897
+ tenant: z.object({
898
+ id: z.string(),
899
+ name: z.string(),
900
+ plan: z.string()
901
+ }).strict(),
902
+ capability: z.object({
903
+ effectiveFeatures: z.array(z.string()),
904
+ planBlocked: z.array(z.string()),
905
+ closureAdded: z.array(z.string())
906
+ }).strict(),
907
+ summary: z.object({
908
+ complete: z.number().int().nonnegative(),
909
+ total: z.number().int().nonnegative(),
910
+ blocking: z.number().int().nonnegative(),
911
+ manual: z.number().int().nonnegative(),
912
+ unknown: z.number().int().nonnegative()
913
+ }).strict(),
914
+ groups: z.array(tenantFeatureProgressGroupSchema)
915
+ }).strict();
916
+ var COLLECTION_SCHEMA_CONTRACT_VERSION = 1;
917
+ var collectionSchemaEndpointParamsSchema = z.object({
918
+ collectionSlug: z.string().min(1, "collectionSlug is required")
818
919
  }).strict();
819
- var shippingAddressSchema = z.object({
820
- postalCode: z.string().optional(),
821
- address: z.string().optional(),
822
- detailAddress: z.string().optional(),
823
- deliveryMessage: z.string().optional(),
824
- recipientName: z.string().optional(),
825
- phone: z.string().optional()
920
+ var collectionFieldOptionSchema = z.object({
921
+ label: z.string(),
922
+ value: z.string()
826
923
  }).strict();
827
- var orderItemSchema = z.object({
828
- product: idSchema,
829
- variant: idSchema,
830
- option: idSchema,
831
- quantity: z.number().int().positive("quantity must be a positive integer"),
832
- unitPrice: z.number().optional(),
833
- totalPrice: z.number().optional()
924
+ var collectionFieldSchema = z.lazy(
925
+ () => z.object({
926
+ name: z.string(),
927
+ path: z.string(),
928
+ type: z.string(),
929
+ required: z.literal(true).optional(),
930
+ unique: z.literal(true).optional(),
931
+ hasMany: z.literal(true).optional(),
932
+ relationTo: z.union([z.string(), z.array(z.string())]).optional(),
933
+ options: z.array(collectionFieldOptionSchema).optional(),
934
+ hidden: z.literal(true).optional(),
935
+ systemManaged: z.literal(true).optional(),
936
+ writable: z.boolean().optional(),
937
+ fields: z.array(collectionFieldSchema).optional()
938
+ }).strict()
939
+ );
940
+ var collectionSchemaResponseSchema = z.object({
941
+ contractVersion: z.literal(COLLECTION_SCHEMA_CONTRACT_VERSION),
942
+ mode: z.literal("effective"),
943
+ collection: z.object({
944
+ slug: z.string(),
945
+ timestamps: z.boolean(),
946
+ alwaysActive: z.boolean(),
947
+ feature: z.string().nullable(),
948
+ systemFields: z.array(z.string()),
949
+ visibility: z.object({
950
+ collectionHidden: z.boolean(),
951
+ hiddenFields: z.array(z.string())
952
+ }).strict(),
953
+ fields: z.array(collectionFieldSchema)
954
+ }).strict()
834
955
  }).strict();
835
- var orderItemsSchema = z.array(orderItemSchema).min(1, "At least one order item is required").max(100, "Maximum 100 items per order");
836
- var orderStatusSchema = z.enum([
956
+
957
+ // ../contracts/src/ecommerce/index.ts
958
+ import { z as z2 } from "zod";
959
+ var transactionStatusSchema = z2.enum([
960
+ "pending",
961
+ "paid",
962
+ "failed",
963
+ "canceled"
964
+ ]);
965
+ var financialStatusSchema = z2.enum([
966
+ "pending",
967
+ "paid",
968
+ "failed",
969
+ "canceled",
970
+ "partially_refunded",
971
+ "refunded"
972
+ ]);
973
+ var confirmationStatusSchema = z2.enum(["unconfirmed", "confirmed"]);
974
+ var fulfillmentOrderStatusSchema = z2.enum([
975
+ "open",
976
+ "in_progress",
977
+ "on_hold",
978
+ "canceled",
979
+ "closed"
980
+ ]);
981
+ var shipmentStatusSchema = z2.enum([
982
+ "pending",
983
+ "shipped",
984
+ "delivered",
985
+ "canceled",
986
+ "failed"
987
+ ]);
988
+ var orderStatusSchema = z2.enum([
837
989
  "pending",
838
990
  "paid",
839
991
  "failed",
840
992
  "canceled",
993
+ "refunded",
994
+ "preparing",
995
+ "shipped",
996
+ "delivered",
997
+ "confirmed",
998
+ "return_requested",
999
+ "return_processing",
1000
+ "returned"
1001
+ ]);
1002
+ var entityIdSchema = z2.union([z2.string().min(1), z2.number()]).transform(String);
1003
+ var createOrderItemSchema = z2.object({
1004
+ product: entityIdSchema,
1005
+ variant: entityIdSchema,
1006
+ option: entityIdSchema,
1007
+ quantity: z2.number().int().positive("quantity must be a positive integer"),
1008
+ unitPrice: z2.number().optional(),
1009
+ totalPrice: z2.number().optional()
1010
+ }).strict();
1011
+ var createOrderSchema = z2.object({
1012
+ pgPaymentId: z2.string().min(1).optional(),
1013
+ orderNumber: z2.string().min(1, "orderNumber is required"),
1014
+ customer: entityIdSchema.optional(),
1015
+ customerSnapshot: z2.object({
1016
+ name: z2.string().optional(),
1017
+ email: z2.string().email("Invalid email format"),
1018
+ phone: z2.string().optional()
1019
+ }).strict(),
1020
+ shippingAddress: z2.object({
1021
+ postalCode: z2.string().optional(),
1022
+ address: z2.string().optional(),
1023
+ detailAddress: z2.string().optional(),
1024
+ deliveryMessage: z2.string().optional(),
1025
+ recipientName: z2.string().optional(),
1026
+ phone: z2.string().optional()
1027
+ }).strict(),
1028
+ orderItems: z2.array(createOrderItemSchema).min(1, "At least one order item is required").max(100, "Maximum 100 items per order"),
1029
+ totalAmount: z2.number().nonnegative("totalAmount must be non-negative"),
1030
+ shippingAmount: z2.number().min(0).optional(),
1031
+ discountCode: z2.string().optional()
1032
+ }).strict();
1033
+ var updateTransactionSchema = z2.object({
1034
+ pgPaymentId: z2.string().min(1, "pgPaymentId is required").describe("PG payment ID (required)"),
1035
+ status: transactionStatusSchema.describe(
1036
+ "New transaction status (required)"
1037
+ ),
1038
+ paymentMethod: z2.string().optional().describe("Payment method (optional)"),
1039
+ receiptUrl: z2.string().optional().describe("Receipt URL (optional)"),
1040
+ paymentKey: z2.string().min(1).optional().describe("Provider payment key for verified paid confirmation"),
1041
+ amount: z2.number().int().positive().optional().describe("Provider-confirmed amount for verified paid confirmation")
1042
+ }).strict();
1043
+ var providerSlugSchema = z2.string().trim().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/, "pgProvider must be lowercase slug");
1044
+ var confirmPaymentSchema = z2.object({
1045
+ orderNumber: z2.string().min(1).optional(),
1046
+ pgPaymentId: z2.string().min(1, "pgPaymentId is required").describe("Provider payment identifier stored on the transaction"),
1047
+ pgProvider: providerSlugSchema.describe(
1048
+ "Payment provider slug, e.g. toss, portone, stripe"
1049
+ ),
1050
+ pgOrderId: z2.string().min(1).optional(),
1051
+ amount: z2.number().int().nonnegative("amount must be non-negative").describe("Provider-confirmed amount in minor units"),
1052
+ currency: z2.string().min(1).optional(),
1053
+ paymentMethod: z2.string().optional(),
1054
+ receiptUrl: z2.string().url().optional(),
1055
+ approvedAt: z2.string().optional(),
1056
+ providerStatus: z2.string().optional(),
1057
+ providerEventId: z2.string().min(1).optional(),
1058
+ confirmationSource: z2.enum([
1059
+ "provider_webhook",
1060
+ "provider_lookup",
1061
+ "provider_api_confirm",
1062
+ "manual_server"
1063
+ ]).optional(),
1064
+ paymentKey: z2.string().min(1).optional().describe(
1065
+ "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."
1066
+ ),
1067
+ metadata: z2.record(z2.string(), z2.unknown()).optional()
1068
+ }).strict();
1069
+ var returnReasonSchema = z2.enum([
1070
+ "change_of_mind",
1071
+ "defective",
1072
+ "wrong_delivery",
1073
+ "damaged",
1074
+ "other"
1075
+ ]);
1076
+ var restockActionSchema = z2.enum(["return_to_stock", "discard"]);
1077
+ var returnWithRefundItemSchema = z2.object({
1078
+ orderItem: z2.union([z2.string().min(1), z2.number()]).transform(String),
1079
+ quantity: z2.number().int().positive("quantity must be a positive integer"),
1080
+ restockAction: restockActionSchema.default("return_to_stock"),
1081
+ restockingFee: z2.number().min(0, "restockingFee must be non-negative").optional().describe("Restocking fee charged for this line (ADR 0005 \xA7Gap 1)")
1082
+ }).strict();
1083
+ var returnWithRefundSchema = z2.object({
1084
+ orderNumber: z2.string().min(1, "orderNumber is required").describe("Order number (required)"),
1085
+ reason: returnReasonSchema.optional().describe("Return reason (optional)"),
1086
+ reasonDetail: z2.string().optional().describe("Detailed reason text (optional)"),
1087
+ returnItems: z2.array(returnWithRefundItemSchema).min(1, "At least one return item is required").max(100, "Too many return items").describe("Array of products to return (required)"),
1088
+ refundAmount: z2.number().min(0, "refundAmount must be non-negative").describe("Refund amount (required, min 0)"),
1089
+ returnShippingFee: z2.number().min(0, "returnShippingFee must be non-negative").optional().describe(
1090
+ "Return shipping fee charged to the customer (ADR 0005 \xA7Gap 1)"
1091
+ ),
1092
+ initialShippingRefundAmount: z2.number().min(0, "initialShippingRefundAmount must be non-negative").optional().describe("Initial order shipping amount refunded to the customer"),
1093
+ initialShippingRefundOverrideNote: z2.string().min(1).optional().describe(
1094
+ "Operator audit note required when overriding policy suggestion"
1095
+ ),
1096
+ pgPaymentId: z2.string().min(1, "pgPaymentId is required").describe("PG payment ID for refund (required)"),
1097
+ paymentKey: z2.string().min(1).optional().describe("Provider payment key for verified refund"),
1098
+ refundReceiptUrl: z2.string().optional().describe("Refund receipt URL (optional)")
1099
+ }).strict();
1100
+ var createReturnSchema = z2.object({
1101
+ orderNumber: z2.string().min(1, "orderNumber is required").describe("Order number (required)"),
1102
+ reason: returnReasonSchema.optional().describe("Return reason (optional)"),
1103
+ reasonDetail: z2.string().optional().describe("Detailed reason text (optional)"),
1104
+ returnItems: z2.array(returnWithRefundItemSchema).min(1, "At least one return item is required").max(100, "Too many return items").describe("Array of products to return (required)"),
1105
+ refundAmount: z2.number().min(0, "refundAmount must be non-negative").describe(
1106
+ "Line refund amount before initial shipping refund (required, min 0)"
1107
+ ),
1108
+ returnShippingFee: z2.number().min(0, "returnShippingFee must be non-negative").optional().describe("Return shipping fee charged to the customer"),
1109
+ initialShippingRefundAmount: z2.number().min(0, "initialShippingRefundAmount must be non-negative").optional().describe("Initial order shipping amount refunded to the customer"),
1110
+ initialShippingRefundOverrideNote: z2.string().min(1).optional().describe(
1111
+ "Operator audit note required when overriding policy suggestion"
1112
+ )
1113
+ }).strict();
1114
+ var cancelReasonCodeSchema = z2.enum([
1115
+ "customer",
1116
+ "inventory",
1117
+ "fraud",
1118
+ "declined",
1119
+ "staff",
1120
+ "other"
1121
+ ]);
1122
+ var idempotencyKeySchema = z2.string().trim().min(1, "idempotencyKey is required").max(255, "idempotencyKey must be 255 characters or fewer").regex(
1123
+ /^[\x21-\x7E]+$/,
1124
+ "idempotencyKey must contain only printable header-safe characters"
1125
+ );
1126
+ var cancelOrderSchema = z2.object({
1127
+ orderNumber: z2.string().min(1, "orderNumber is required").describe("Order number to cancel"),
1128
+ reasonCode: cancelReasonCodeSchema.default("other").describe("Operator-selected cancel reason code"),
1129
+ reasonDetail: z2.string().trim().max(2e3, "reasonDetail must be 2000 characters or fewer").optional().describe("Internal cancellation detail stored on the order")
1130
+ }).strict();
1131
+ var cancelOrderResponseBaseSchema = {
1132
+ orderId: z2.string().min(1)
1133
+ };
1134
+ var unpaidLocalCancelCommittedResponseFields = {
1135
+ refundedAmount: z2.literal(0),
1136
+ providerRefunded: z2.literal(false)
1137
+ };
1138
+ var paidLocalCancelCommittedResponseFields = {
1139
+ transactionId: z2.string().min(1),
1140
+ refundedAmount: z2.literal(0),
1141
+ providerRefunded: z2.literal(false),
1142
+ refundPending: z2.literal(true)
1143
+ };
1144
+ var legacyProviderRefundResponseFields = {
1145
+ transactionId: z2.string().min(1),
1146
+ refundedAmount: z2.number().int().positive(),
1147
+ refundSeq: z2.number().int().positive(),
1148
+ providerRefunded: z2.literal(true)
1149
+ };
1150
+ var alreadyCanceledResponseFields = {
1151
+ refundedAmount: z2.number().int().nonnegative(),
1152
+ providerRefunded: z2.literal(false)
1153
+ };
1154
+ var alreadyCanceledRefundPendingResponseFields = {
1155
+ transactionId: z2.string().min(1),
1156
+ refundedAmount: z2.number().int().nonnegative(),
1157
+ providerRefunded: z2.literal(false),
1158
+ refundPending: z2.literal(true)
1159
+ };
1160
+ var cancelOrderReconciliationStatusSchema = z2.enum([
1161
+ "paid",
841
1162
  "preparing",
842
1163
  "shipped",
843
1164
  "delivered",
844
- "confirmed"
1165
+ "confirmed",
1166
+ "return_requested",
1167
+ "return_processing",
1168
+ "returned",
1169
+ "refunded"
1170
+ ]);
1171
+ var cancelOrderResponseSchema = z2.union([
1172
+ z2.object({
1173
+ ...cancelOrderResponseBaseSchema,
1174
+ ...paidLocalCancelCommittedResponseFields,
1175
+ status: z2.literal("canceled"),
1176
+ cancelCommitted: z2.literal(true)
1177
+ }).strict(),
1178
+ z2.object({
1179
+ ...cancelOrderResponseBaseSchema,
1180
+ ...unpaidLocalCancelCommittedResponseFields,
1181
+ status: z2.literal("canceled"),
1182
+ cancelCommitted: z2.literal(true)
1183
+ }).strict(),
1184
+ z2.object({
1185
+ ...cancelOrderResponseBaseSchema,
1186
+ ...alreadyCanceledResponseFields,
1187
+ status: z2.literal("canceled"),
1188
+ cancelCommitted: z2.literal(false),
1189
+ alreadyCanceled: z2.literal(true)
1190
+ }).strict(),
1191
+ z2.object({
1192
+ ...cancelOrderResponseBaseSchema,
1193
+ ...alreadyCanceledRefundPendingResponseFields,
1194
+ status: z2.literal("canceled"),
1195
+ cancelCommitted: z2.literal(false),
1196
+ alreadyCanceled: z2.literal(true)
1197
+ }).strict(),
1198
+ z2.object({
1199
+ ...cancelOrderResponseBaseSchema,
1200
+ ...legacyProviderRefundResponseFields,
1201
+ status: cancelOrderReconciliationStatusSchema,
1202
+ cancelCommitted: z2.literal(false),
1203
+ reconciliationRequired: z2.literal(true)
1204
+ }).strict()
1205
+ ]);
1206
+ var resolveCancelRefundOutcomeSchema = z2.enum(["succeeded", "failed"]);
1207
+ var resolveCancelRefundSchema = z2.object({
1208
+ orderNumber: z2.string().min(1, "orderNumber is required").describe("Order number whose pending cancel refund is being resolved"),
1209
+ idempotencyKey: idempotencyKeySchema.describe(
1210
+ "Stable key for this PG refund result report"
1211
+ ),
1212
+ outcome: resolveCancelRefundOutcomeSchema.describe(
1213
+ "PG refund result reported by the storefront or BFF"
1214
+ ),
1215
+ refundedAmount: z2.number().int("refundedAmount must be an integer minor-unit amount").nonnegative("refundedAmount must be nonnegative"),
1216
+ pgProvider: z2.string().trim().min(1, "pgProvider is required").regex(
1217
+ /^[a-z0-9][a-z0-9_-]*$/,
1218
+ "pgProvider must be a lowercase provider slug"
1219
+ ),
1220
+ pgRefundId: z2.string().trim().min(1).optional()
1221
+ }).strict().superRefine((value, ctx) => {
1222
+ if (value.outcome === "succeeded" && value.refundedAmount <= 0) {
1223
+ ctx.addIssue({
1224
+ code: z2.ZodIssueCode.custom,
1225
+ path: ["refundedAmount"],
1226
+ message: "refundedAmount must be positive when outcome is succeeded"
1227
+ });
1228
+ }
1229
+ if (value.outcome === "succeeded" && !value.pgRefundId) {
1230
+ ctx.addIssue({
1231
+ code: z2.ZodIssueCode.custom,
1232
+ path: ["pgRefundId"],
1233
+ message: "pgRefundId is required when outcome is succeeded"
1234
+ });
1235
+ }
1236
+ if (value.outcome === "failed" && value.refundedAmount !== 0) {
1237
+ ctx.addIssue({
1238
+ code: z2.ZodIssueCode.custom,
1239
+ path: ["refundedAmount"],
1240
+ message: "refundedAmount must be 0 when outcome is failed"
1241
+ });
1242
+ }
1243
+ });
1244
+ var resolveCancelRefundResponseSchema = z2.union([
1245
+ z2.object({
1246
+ orderId: z2.string().min(1),
1247
+ transactionId: z2.string().min(1),
1248
+ refundTransactionId: z2.string().min(1),
1249
+ refundedAmount: z2.number().int().positive(),
1250
+ refundStatus: z2.literal("succeeded"),
1251
+ transactionStatus: z2.literal("refunded")
1252
+ }).strict(),
1253
+ z2.object({
1254
+ orderId: z2.string().min(1),
1255
+ transactionId: z2.string().min(1),
1256
+ refundTransactionId: z2.string().min(1),
1257
+ refundedAmount: z2.literal(0),
1258
+ refundStatus: z2.literal("failed"),
1259
+ transactionStatus: z2.literal("paid")
1260
+ }).strict()
845
1261
  ]);
846
- var fulfillmentItemsSchema = z.array(
847
- z.object({
1262
+
1263
+ // src/commands/order.ts
1264
+ import { z as z3 } from "zod";
1265
+ var idSchema = z3.union([z3.string().min(1), z3.number()]).transform(String);
1266
+ var customerSnapshotSchema = z3.object({
1267
+ email: z3.string().email("Invalid email format"),
1268
+ name: z3.string().optional(),
1269
+ phone: z3.string().optional()
1270
+ }).strict();
1271
+ var orderStatusSchema2 = z3.enum(["confirmed"]);
1272
+ var fulfillmentStatusSchema = z3.enum(["shipped", "delivered", "failed"]);
1273
+ var updateFulfillmentSchema = z3.object({
1274
+ fulfillmentId: idSchema,
1275
+ status: fulfillmentStatusSchema.optional(),
1276
+ carrier: z3.string().min(1).optional(),
1277
+ trackingNumber: z3.string().min(1).optional()
1278
+ }).refine(
1279
+ (value) => value.status !== void 0 || value.carrier !== void 0 || value.trackingNumber !== void 0,
1280
+ {
1281
+ message: "status, carrier, or trackingNumber is required"
1282
+ }
1283
+ );
1284
+ var fulfillmentItemsSchema = z3.array(
1285
+ z3.object({
848
1286
  orderItem: idSchema,
849
- quantity: z.number().int().positive("quantity must be a positive integer")
1287
+ quantity: z3.number().int().positive("quantity must be a positive integer")
850
1288
  }).strict()
851
1289
  ).min(1, "At least one fulfillment item is required").max(100, "Maximum 100 items per fulfillment");
852
1290
  function registerOrderCommands(program2, getClient2, getFormat2) {
853
1291
  const order = program2.command("order").description("Order management");
854
- 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("--dry-run", "Validate inputs without executing").action(async (opts) => {
1292
+ 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) => {
855
1293
  try {
856
- const shippingAddress = parseWithSchema(
857
- parseJson(opts.shippingAddress, "shipping-address"),
858
- "shipping-address",
859
- shippingAddressSchema
860
- );
861
- const orderItems = parseWithSchema(
862
- parseJsonArray(opts.products, "products"),
863
- "products",
864
- orderItemsSchema
865
- );
866
- const totalAmount = parseWithSchema(
867
- opts.totalAmount,
868
- "total-amount",
869
- z.number().nonnegative("totalAmount must be non-negative")
870
- );
871
- const data = {
872
- pgPaymentId: opts.paymentId,
873
- orderNumber: opts.orderNumber,
874
- customerSnapshot: {
875
- email: opts.email,
876
- name: opts.name,
877
- phone: opts.phone
1294
+ const data = parseWithSchema(
1295
+ {
1296
+ pgPaymentId: opts.paymentId,
1297
+ orderNumber: opts.orderNumber,
1298
+ customerSnapshot: {
1299
+ email: opts.email,
1300
+ name: opts.name,
1301
+ phone: opts.phone
1302
+ },
1303
+ customer: opts.customer,
1304
+ shippingAddress: parseJson(
1305
+ opts.shippingAddress,
1306
+ "shipping-address"
1307
+ ),
1308
+ orderItems: parseJsonArray(opts.products, "products"),
1309
+ totalAmount: opts.totalAmount,
1310
+ shippingAmount: opts.shippingAmount,
1311
+ discountCode: opts.discountCode
878
1312
  },
879
- customer: opts.customer,
880
- shippingAddress,
881
- orderItems,
882
- totalAmount
883
- };
1313
+ "order",
1314
+ createOrderSchema
1315
+ );
884
1316
  if (opts.dryRun) {
885
1317
  printResult(
886
1318
  { dryRun: true, valid: true, action: "order create", data },
@@ -889,10 +1321,7 @@ function registerOrderCommands(program2, getClient2, getFormat2) {
889
1321
  return;
890
1322
  }
891
1323
  const client = getClient2();
892
- const result = await client.commerce.orders.create({
893
- ...data,
894
- orderItems
895
- });
1324
+ const result = await client.commerce.orders.create(data);
896
1325
  printResult(result, getFormat2());
897
1326
  } catch (e) {
898
1327
  exitWithError(e);
@@ -901,16 +1330,22 @@ function registerOrderCommands(program2, getClient2, getFormat2) {
901
1330
  order.command("get <orderNumber>").description("Get an order by order number").action(async (orderNumber) => {
902
1331
  try {
903
1332
  const client = getClient2();
904
- const { docs: [order2] } = await client.collections.from("orders").find({ where: { orderNumber: { equals: orderNumber } }, limit: 1, depth: 1 });
1333
+ const {
1334
+ docs: [order2]
1335
+ } = await client.collections.from("orders").find({
1336
+ where: { orderNumber: { equals: orderNumber } },
1337
+ limit: 1,
1338
+ depth: 1
1339
+ });
905
1340
  if (!order2) throw new Error("Order not found");
906
1341
  printResult(order2, getFormat2());
907
1342
  } catch (e) {
908
1343
  exitWithError(e);
909
1344
  }
910
1345
  });
911
- order.command("update <orderNumber>").description("Update order status").requiredOption("--status <status>", "New status").option("--dry-run", "Validate inputs without executing").action(async (orderNumber, opts) => {
1346
+ order.command("update <orderNumber>").description("Confirm a delivered order purchase").requiredOption("--status <status>", "New status (confirmed only)").option("--dry-run", "Validate inputs without executing").action(async (orderNumber, opts) => {
912
1347
  try {
913
- const status = parseWithSchema(opts.status, "status", orderStatusSchema);
1348
+ const status = parseWithSchema(opts.status, "status", orderStatusSchema2);
914
1349
  const data = { orderNumber, status };
915
1350
  if (opts.dryRun) {
916
1351
  printResult(
@@ -956,18 +1391,35 @@ function registerOrderCommands(program2, getClient2, getFormat2) {
956
1391
  exitWithError(e);
957
1392
  }
958
1393
  });
959
- order.command("fulfill <orderNumber>").description("Create a fulfillment for an order").requiredOption("--items <json>", "Fulfillment items array (JSON)").option("--carrier <name>", "Shipping carrier").option("--tracking-number <num>", "Tracking number").option("--dry-run", "Validate inputs without executing").action(async (orderNumber, opts) => {
1394
+ order.command("prepare <orderNumber>").description("Move paid order fulfillment work to preparation").option("--dry-run", "Validate inputs without executing").action(async (orderNumber, opts) => {
1395
+ try {
1396
+ const data = { orderNumber };
1397
+ if (opts.dryRun) {
1398
+ printResult(
1399
+ { dryRun: true, valid: true, action: "order prepare", data },
1400
+ getFormat2()
1401
+ );
1402
+ return;
1403
+ }
1404
+ const client = getClient2();
1405
+ const result = await client.commerce.orders.prepareFulfillmentOrder(data);
1406
+ printResult(result, getFormat2());
1407
+ } catch (e) {
1408
+ exitWithError(e);
1409
+ }
1410
+ });
1411
+ order.command("fulfill <orderNumber>").description("Create a shipment for a prepared order").option("--items <json>", "Fulfillment items array (JSON)").option("--carrier <name>", "Shipping carrier").option("--tracking-number <num>", "Tracking number").option("--dry-run", "Validate inputs without executing").action(async (orderNumber, opts) => {
960
1412
  try {
961
- const items = parseWithSchema(
1413
+ const items = opts.items ? parseWithSchema(
962
1414
  parseJsonArray(opts.items, "items"),
963
1415
  "items",
964
1416
  fulfillmentItemsSchema
965
- );
1417
+ ) : void 0;
966
1418
  const data = {
967
1419
  orderNumber,
968
- items,
969
- carrier: opts.carrier,
970
- trackingNumber: opts.trackingNumber
1420
+ ...opts.carrier ? { carrier: opts.carrier } : {},
1421
+ ...opts.trackingNumber ? { trackingNumber: opts.trackingNumber } : {},
1422
+ ...items ? { items } : {}
971
1423
  };
972
1424
  if (opts.dryRun) {
973
1425
  printResult(
@@ -979,62 +1431,88 @@ function registerOrderCommands(program2, getClient2, getFormat2) {
979
1431
  const client = getClient2();
980
1432
  const result = await client.commerce.orders.createFulfillment({
981
1433
  ...data,
982
- items
1434
+ ...items ? {
1435
+ items
1436
+ } : {}
983
1437
  });
984
1438
  printResult(result, getFormat2());
985
1439
  } catch (e) {
986
1440
  exitWithError(e);
987
1441
  }
988
1442
  });
1443
+ order.command("update-fulfillment <fulfillmentId>").description("Update shipment status or tracking information").option("--status <status>", "Shipment status (shipped, delivered, failed)").option("--carrier <name>", "Shipping carrier").option("--tracking-number <num>", "Tracking number").option("--dry-run", "Validate inputs without executing").action(async (fulfillmentId, opts) => {
1444
+ try {
1445
+ const data = parseWithSchema(
1446
+ {
1447
+ fulfillmentId,
1448
+ ...opts.status ? { status: opts.status } : {},
1449
+ ...opts.carrier ? { carrier: opts.carrier } : {},
1450
+ ...opts.trackingNumber ? { trackingNumber: opts.trackingNumber } : {}
1451
+ },
1452
+ "fulfillment",
1453
+ updateFulfillmentSchema
1454
+ );
1455
+ if (opts.dryRun) {
1456
+ printResult(
1457
+ {
1458
+ dryRun: true,
1459
+ valid: true,
1460
+ action: "order update-fulfillment",
1461
+ data
1462
+ },
1463
+ getFormat2()
1464
+ );
1465
+ return;
1466
+ }
1467
+ const client = getClient2();
1468
+ const result = await client.commerce.orders.updateFulfillment(data);
1469
+ printResult(result, getFormat2());
1470
+ } catch (e) {
1471
+ exitWithError(e);
1472
+ }
1473
+ });
989
1474
  }
990
1475
 
991
1476
  // src/commands/return.ts
992
- import { z as z2 } from "zod";
993
- var idSchema2 = z2.union([z2.string().min(1), z2.number()]).transform(String);
994
- var returnReasonSchema = z2.enum(["change_of_mind", "defective", "wrong_delivery", "damaged", "other"]).optional();
995
- var returnItemsSchema = z2.array(
996
- z2.object({
997
- orderItem: idSchema2,
998
- quantity: z2.number().int().positive("quantity must be a positive integer"),
999
- restockAction: z2.enum(["return_to_stock", "discard"]).default("return_to_stock")
1000
- }).strict()
1001
- ).min(1, "At least one return item is required").max(100, "Too many return items");
1002
- var returnStatusSchema = z2.enum([
1477
+ import { z as z4 } from "zod";
1478
+ var returnStatusSchema = z4.enum([
1003
1479
  "processing",
1004
1480
  "approved",
1005
1481
  "rejected",
1006
1482
  "completed"
1007
1483
  ]);
1008
- var refundAmountSchema = z2.number().nonnegative("refundAmount must be non-negative");
1009
1484
  function registerReturnCommands(program2, getClient2, getFormat2) {
1010
1485
  const ret = program2.command("return").description("Return management");
1011
1486
  ret.command("create <orderNumber>").description("Create a return request").requiredOption("--products <json>", "Return products array (JSON)").requiredOption("--refund-amount <n>", "Refund amount", parseFloat).option(
1487
+ "--return-shipping-fee <n>",
1488
+ "Return shipping fee charged to the customer",
1489
+ parseFloat
1490
+ ).option(
1491
+ "--initial-shipping-refund-amount <n>",
1492
+ "Initial order shipping refund amount",
1493
+ parseFloat
1494
+ ).option(
1495
+ "--initial-shipping-refund-note <text>",
1496
+ "Audit note for manual initial shipping refund override"
1497
+ ).option(
1012
1498
  "--reason <reason>",
1013
1499
  "Return reason (change_of_mind, defective, wrong_delivery, damaged, other)"
1014
1500
  ).option("--reason-detail <text>", "Detailed reason").option("--dry-run", "Validate inputs without executing").action(async (orderNumber, opts) => {
1015
1501
  try {
1016
- const returnItems = parseWithSchema(
1017
- parseJsonArray(opts.products, "products"),
1018
- "products",
1019
- returnItemsSchema
1020
- );
1021
- const refundAmount = parseWithSchema(
1022
- opts.refundAmount,
1023
- "refund-amount",
1024
- refundAmountSchema
1025
- );
1026
- const reason = parseWithSchema(
1027
- opts.reason,
1028
- "reason",
1029
- returnReasonSchema
1502
+ const data = parseWithSchema(
1503
+ {
1504
+ orderNumber,
1505
+ returnItems: parseJsonArray(opts.products, "products"),
1506
+ refundAmount: opts.refundAmount,
1507
+ returnShippingFee: opts.returnShippingFee,
1508
+ reason: opts.reason,
1509
+ reasonDetail: opts.reasonDetail,
1510
+ initialShippingRefundAmount: opts.initialShippingRefundAmount,
1511
+ initialShippingRefundOverrideNote: opts.initialShippingRefundNote
1512
+ },
1513
+ "return",
1514
+ createReturnSchema
1030
1515
  );
1031
- const data = {
1032
- orderNumber,
1033
- returnItems,
1034
- refundAmount,
1035
- reason,
1036
- reasonDetail: opts.reasonDetail
1037
- };
1038
1516
  if (opts.dryRun) {
1039
1517
  printResult(
1040
1518
  { dryRun: true, valid: true, action: "return create", data },
@@ -1045,7 +1523,7 @@ function registerReturnCommands(program2, getClient2, getFormat2) {
1045
1523
  const client = getClient2();
1046
1524
  const result = await client.commerce.orders.createReturn({
1047
1525
  ...data,
1048
- returnItems
1526
+ returnItems: data.returnItems
1049
1527
  });
1050
1528
  printResult(result, getFormat2());
1051
1529
  } catch (e) {
@@ -1057,7 +1535,11 @@ function registerReturnCommands(program2, getClient2, getFormat2) {
1057
1535
  "New status (processing, approved, rejected, completed)"
1058
1536
  ).option("--dry-run", "Validate inputs without executing").action(async (returnId, opts) => {
1059
1537
  try {
1060
- const status = parseWithSchema(opts.status, "status", returnStatusSchema);
1538
+ const status = parseWithSchema(
1539
+ opts.status,
1540
+ "status",
1541
+ returnStatusSchema
1542
+ );
1061
1543
  const data = { returnId, status };
1062
1544
  if (opts.dryRun) {
1063
1545
  printResult(
@@ -1073,32 +1555,36 @@ function registerReturnCommands(program2, getClient2, getFormat2) {
1073
1555
  exitWithError(e);
1074
1556
  }
1075
1557
  });
1076
- ret.command("refund <orderNumber>").description("Return with refund").requiredOption("--products <json>", "Return products array (JSON)").requiredOption("--refund-amount <n>", "Refund amount", parseFloat).requiredOption("--payment-id <id>", "Payment ID").option("--reason <reason>", "Return reason").option("--reason-detail <text>", "Detailed reason").option("--refund-receipt-url <url>", "Refund receipt URL").option("--dry-run", "Validate inputs without executing").action(async (orderNumber, opts) => {
1558
+ ret.command("refund <orderNumber>").description("Return with refund").requiredOption("--products <json>", "Return products array (JSON)").requiredOption("--refund-amount <n>", "Refund amount", parseFloat).requiredOption("--payment-id <id>", "Payment ID").option(
1559
+ "--return-shipping-fee <n>",
1560
+ "Return shipping fee charged to the customer",
1561
+ parseFloat
1562
+ ).option(
1563
+ "--initial-shipping-refund-amount <n>",
1564
+ "Initial order shipping refund amount",
1565
+ parseFloat
1566
+ ).option(
1567
+ "--initial-shipping-refund-note <text>",
1568
+ "Audit note for manual initial shipping refund override"
1569
+ ).option("--reason <reason>", "Return reason").option("--reason-detail <text>", "Detailed reason").option("--refund-receipt-url <url>", "Refund receipt URL").option("--payment-key <key>", "Provider payment key").option("--dry-run", "Validate inputs without executing").action(async (orderNumber, opts) => {
1077
1570
  try {
1078
- const returnItems = parseWithSchema(
1079
- parseJsonArray(opts.products, "products"),
1080
- "products",
1081
- returnItemsSchema
1082
- );
1083
- const refundAmount = parseWithSchema(
1084
- opts.refundAmount,
1085
- "refund-amount",
1086
- refundAmountSchema
1087
- );
1088
- const reason = parseWithSchema(
1089
- opts.reason,
1090
- "reason",
1091
- returnReasonSchema
1571
+ const data = parseWithSchema(
1572
+ {
1573
+ orderNumber,
1574
+ returnItems: parseJsonArray(opts.products, "products"),
1575
+ refundAmount: opts.refundAmount,
1576
+ returnShippingFee: opts.returnShippingFee,
1577
+ pgPaymentId: opts.paymentId,
1578
+ reason: opts.reason,
1579
+ reasonDetail: opts.reasonDetail,
1580
+ refundReceiptUrl: opts.refundReceiptUrl,
1581
+ paymentKey: opts.paymentKey,
1582
+ initialShippingRefundAmount: opts.initialShippingRefundAmount,
1583
+ initialShippingRefundOverrideNote: opts.initialShippingRefundNote
1584
+ },
1585
+ "return",
1586
+ returnWithRefundSchema
1092
1587
  );
1093
- const data = {
1094
- orderNumber,
1095
- returnItems,
1096
- refundAmount,
1097
- pgPaymentId: opts.paymentId,
1098
- reason,
1099
- reasonDetail: opts.reasonDetail,
1100
- refundReceiptUrl: opts.refundReceiptUrl
1101
- };
1102
1588
  if (opts.dryRun) {
1103
1589
  printResult(
1104
1590
  { dryRun: true, valid: true, action: "return refund", data },
@@ -1109,7 +1595,7 @@ function registerReturnCommands(program2, getClient2, getFormat2) {
1109
1595
  const client = getClient2();
1110
1596
  const result = await client.commerce.orders.returnWithRefund({
1111
1597
  ...data,
1112
- returnItems
1598
+ returnItems: data.returnItems
1113
1599
  });
1114
1600
  printResult(result, getFormat2());
1115
1601
  } catch (e) {
@@ -1211,19 +1697,33 @@ function registerStockCommands(program2, getClient2, getFormat2) {
1211
1697
  }
1212
1698
 
1213
1699
  // src/commands/transaction.ts
1700
+ import { z as z5 } from "zod";
1701
+ var transactionAmountSchema = z5.object({
1702
+ amount: z5.string().regex(/^[1-9]\d*$/, "amount must be a positive integer").transform(Number)
1703
+ });
1704
+ function parseTransactionAmount(value) {
1705
+ if (value === void 0) return void 0;
1706
+ return parseWithSchema({ amount: value }, "amount", transactionAmountSchema).amount;
1707
+ }
1214
1708
  function registerTransactionCommands(program2, getClient2, getFormat2) {
1215
1709
  const tx = program2.command("transaction").description("Transaction management");
1216
1710
  tx.command("update").description("Update transaction status").requiredOption("--payment-id <id>", "Payment ID").requiredOption(
1217
1711
  "--status <status>",
1218
1712
  "New status (pending, paid, failed, canceled)"
1219
- ).requiredOption("--payment-method <method>", "Payment method").requiredOption("--receipt-url <url>", "Receipt URL").option("--dry-run", "Validate inputs without executing").action(async (opts) => {
1713
+ ).option("--payment-method <method>", "Payment method").option("--receipt-url <url>", "Receipt URL").option("--payment-key <key>", "Provider payment key").option("--amount <n>", "Provider-confirmed amount").option("--dry-run", "Validate inputs without executing").action(async (opts) => {
1220
1714
  try {
1221
- const data = {
1222
- pgPaymentId: opts.paymentId,
1223
- status: opts.status,
1224
- paymentMethod: opts.paymentMethod,
1225
- receiptUrl: opts.receiptUrl
1226
- };
1715
+ const data = parseWithSchema(
1716
+ {
1717
+ pgPaymentId: opts.paymentId,
1718
+ status: opts.status,
1719
+ paymentMethod: opts.paymentMethod,
1720
+ receiptUrl: opts.receiptUrl,
1721
+ paymentKey: opts.paymentKey,
1722
+ amount: parseTransactionAmount(opts.amount)
1723
+ },
1724
+ "transaction",
1725
+ updateTransactionSchema
1726
+ );
1227
1727
  if (opts.dryRun) {
1228
1728
  printResult(
1229
1729
  { dryRun: true, valid: true, action: "transaction update", data },
@@ -1572,152 +2072,6 @@ function registerSchemaCommands(program2, getClient2, getFormat2) {
1572
2072
  });
1573
2073
  }
1574
2074
 
1575
- // ../contracts/src/tenant/index.ts
1576
- import { z as z3 } from "zod";
1577
- var tenantFieldConfigStateSchema = z3.object({
1578
- hiddenFields: z3.array(z3.string()),
1579
- isHidden: z3.boolean()
1580
- }).strict();
1581
- var tenantContextQuerySchema = z3.object({
1582
- counts: z3.literal("true").optional()
1583
- }).strict();
1584
- var tenantContextToolInputSchema = z3.object({
1585
- includeCounts: z3.boolean().optional().default(false).describe(
1586
- "Include per-collection document counts and config status (bypasses cache, slower)"
1587
- )
1588
- }).strict();
1589
- var tenantContextResponseSchema = z3.object({
1590
- tenant: z3.object({
1591
- id: z3.string(),
1592
- name: z3.string(),
1593
- plan: z3.string(),
1594
- planSource: z3.string().optional(),
1595
- authoritative: z3.boolean().optional(),
1596
- capabilityVersion: z3.string().optional()
1597
- }).strict(),
1598
- features: z3.array(z3.string()),
1599
- collections: z3.object({
1600
- active: z3.array(z3.string()),
1601
- inactive: z3.array(z3.string())
1602
- }).strict(),
1603
- fieldConfigs: z3.record(z3.string(), tenantFieldConfigStateSchema),
1604
- counts: z3.record(z3.string(), z3.number()).optional(),
1605
- config: z3.object({
1606
- webhookConfigured: z3.boolean()
1607
- }).strict().optional()
1608
- }).strict();
1609
- var tenantFeatureProgressFeatureSchema = z3.enum(["ecommerce"]);
1610
- var tenantFeatureProgressInputSchema = z3.object({
1611
- feature: tenantFeatureProgressFeatureSchema.describe(
1612
- "Feature to inspect for tenant implementation readiness"
1613
- ),
1614
- includeEvidence: z3.boolean().optional().default(false).describe("Include sanitized counts and static surface evidence")
1615
- }).strict();
1616
- var tenantFeatureProgressStatusSchema = z3.enum([
1617
- "ready",
1618
- "attention",
1619
- "blocked"
1620
- ]);
1621
- var tenantFeatureProgressItemStateSchema = z3.enum([
1622
- "complete",
1623
- "incomplete",
1624
- "blocked",
1625
- "attention",
1626
- "optional",
1627
- "unknown",
1628
- "manual",
1629
- "not-applicable"
1630
- ]);
1631
- var tenantFeatureProgressSeveritySchema = z3.enum([
1632
- "required",
1633
- "recommended",
1634
- "optional"
1635
- ]);
1636
- var tenantFeatureProgressEvidenceValueSchema = z3.union([
1637
- z3.string(),
1638
- z3.number(),
1639
- z3.boolean(),
1640
- z3.null()
1641
- ]);
1642
- var tenantFeatureProgressItemSchema = z3.object({
1643
- id: z3.string(),
1644
- title: z3.string(),
1645
- state: tenantFeatureProgressItemStateSchema,
1646
- severity: tenantFeatureProgressSeveritySchema,
1647
- summary: z3.string(),
1648
- evidence: z3.record(z3.string(), tenantFeatureProgressEvidenceValueSchema).optional()
1649
- }).strict();
1650
- var tenantFeatureProgressGroupSchema = z3.object({
1651
- id: z3.string(),
1652
- title: z3.string(),
1653
- summary: z3.string().optional(),
1654
- items: z3.array(tenantFeatureProgressItemSchema)
1655
- }).strict();
1656
- var tenantFeatureProgressResponseSchema = z3.object({
1657
- schemaVersion: z3.literal(1),
1658
- feature: tenantFeatureProgressFeatureSchema,
1659
- status: tenantFeatureProgressStatusSchema,
1660
- generatedAt: z3.string(),
1661
- tenant: z3.object({
1662
- id: z3.string(),
1663
- name: z3.string(),
1664
- plan: z3.string()
1665
- }).strict(),
1666
- capability: z3.object({
1667
- effectiveFeatures: z3.array(z3.string()),
1668
- planBlocked: z3.array(z3.string()),
1669
- closureAdded: z3.array(z3.string())
1670
- }).strict(),
1671
- summary: z3.object({
1672
- complete: z3.number().int().nonnegative(),
1673
- total: z3.number().int().nonnegative(),
1674
- blocking: z3.number().int().nonnegative(),
1675
- manual: z3.number().int().nonnegative(),
1676
- unknown: z3.number().int().nonnegative()
1677
- }).strict(),
1678
- groups: z3.array(tenantFeatureProgressGroupSchema)
1679
- }).strict();
1680
- var COLLECTION_SCHEMA_CONTRACT_VERSION = 1;
1681
- var collectionSchemaEndpointParamsSchema = z3.object({
1682
- collectionSlug: z3.string().min(1, "collectionSlug is required")
1683
- }).strict();
1684
- var collectionFieldOptionSchema = z3.object({
1685
- label: z3.string(),
1686
- value: z3.string()
1687
- }).strict();
1688
- var collectionFieldSchema = z3.lazy(
1689
- () => z3.object({
1690
- name: z3.string(),
1691
- path: z3.string(),
1692
- type: z3.string(),
1693
- required: z3.literal(true).optional(),
1694
- unique: z3.literal(true).optional(),
1695
- hasMany: z3.literal(true).optional(),
1696
- relationTo: z3.union([z3.string(), z3.array(z3.string())]).optional(),
1697
- options: z3.array(collectionFieldOptionSchema).optional(),
1698
- hidden: z3.literal(true).optional(),
1699
- systemManaged: z3.literal(true).optional(),
1700
- writable: z3.boolean().optional(),
1701
- fields: z3.array(collectionFieldSchema).optional()
1702
- }).strict()
1703
- );
1704
- var collectionSchemaResponseSchema = z3.object({
1705
- contractVersion: z3.literal(COLLECTION_SCHEMA_CONTRACT_VERSION),
1706
- mode: z3.literal("effective"),
1707
- collection: z3.object({
1708
- slug: z3.string(),
1709
- timestamps: z3.boolean(),
1710
- alwaysActive: z3.boolean(),
1711
- feature: z3.string().nullable(),
1712
- systemFields: z3.array(z3.string()),
1713
- visibility: z3.object({
1714
- collectionHidden: z3.boolean(),
1715
- hiddenFields: z3.array(z3.string())
1716
- }).strict(),
1717
- fields: z3.array(collectionFieldSchema)
1718
- }).strict()
1719
- }).strict();
1720
-
1721
2075
  // src/commands/feature.ts
1722
2076
  function flattenProgress(progress) {
1723
2077
  return progress.groups.flatMap(