@hartl-services/medusa-contracts 1.4.0 → 1.6.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/README.md CHANGED
@@ -28,6 +28,7 @@ Consumer subpaths:
28
28
  - `@hartl-services/medusa-contracts/types/plugin-features-store`
29
29
  - `@hartl-services/medusa-contracts/types/plugin-features-admin`
30
30
  - `@hartl-services/medusa-contracts/types/tax-compliance-store`
31
+ - `@hartl-services/medusa-contracts/types/order-assistant`
31
32
  - `@hartl-services/medusa-contracts/schemas/affiliate`
32
33
  - `@hartl-services/medusa-contracts/schemas/batch-management`
33
34
  - `@hartl-services/medusa-contracts/schemas/documents`
@@ -39,6 +40,7 @@ Consumer subpaths:
39
40
  - `@hartl-services/medusa-contracts/schemas/checkout`
40
41
  - `@hartl-services/medusa-contracts/schemas/plugin-features`
41
42
  - `@hartl-services/medusa-contracts/schemas/tax-compliance`
43
+ - `@hartl-services/medusa-contracts/schemas/order-assistant`
42
44
  - `@hartl-services/medusa-contracts/paths/affiliate`
43
45
  - `@hartl-services/medusa-contracts/paths/batch-management`
44
46
  - `@hartl-services/medusa-contracts/paths/documents`
@@ -49,6 +51,7 @@ Consumer subpaths:
49
51
  - `@hartl-services/medusa-contracts/paths/checkout`
50
52
  - `@hartl-services/medusa-contracts/paths/plugin-features`
51
53
  - `@hartl-services/medusa-contracts/paths/tax-compliance`
54
+ - `@hartl-services/medusa-contracts/paths/order-assistant`
52
55
 
53
56
  Server-only event subpaths (see "Server-only event contracts" below):
54
57
 
@@ -70,6 +73,12 @@ Packing-list DTOs are exported only from `types/documents-admin`. Use
70
73
  `packingListsPaths` from `paths/documents` with the consuming Admin's configured
71
74
  Medusa SDK; there is deliberately no packing-list Store contract or client.
72
75
 
76
+ The order assistant (`order-assistant`) is not a JSON REST route: `paths` holds
77
+ the MCP endpoint (`/mcp`), `schemas` the input and output schemas of its four
78
+ tools, the tool names and the order metadata keys the assistant writes, and
79
+ `types` their inferred types. A storefront never calls it; the consumer is an
80
+ MCP client (an AI chatbot) and the base's own tests.
81
+
73
82
  File Gateway responses are binary and have no JSON response DTO. Public paths
74
83
  come from `paths/files`. Private gateway URLs are opaque, signed server results
75
84
  and must not be assembled by a consumer.
@@ -119,6 +119,22 @@ export declare const AffiliateCouponLabelsResponseSchema: z.ZodObject<{
119
119
  discount_percentage: z.ZodNumber;
120
120
  }, z.core.$strip>>;
121
121
  }, z.core.$strip>;
122
+ export declare const ConsignmentNonSaleReasonSchema: z.ZodEnum<{
123
+ expired: "expired";
124
+ damaged: "damaged";
125
+ returned: "returned";
126
+ correction: "correction";
127
+ }>;
128
+ /** A part of a line's not-sold shortage with its reason. */
129
+ export declare const ConsignmentNonSaleQuantitySchema: z.ZodObject<{
130
+ reason: z.ZodEnum<{
131
+ expired: "expired";
132
+ damaged: "damaged";
133
+ returned: "returned";
134
+ correction: "correction";
135
+ }>;
136
+ quantity: z.ZodNumber;
137
+ }, z.core.$strip>;
122
138
  export declare const SubmitConsignmentReportSchema: z.ZodObject<{
123
139
  period_start: z.ZodString;
124
140
  submission_idempotency_key: z.ZodString;
@@ -126,6 +142,15 @@ export declare const SubmitConsignmentReportSchema: z.ZodObject<{
126
142
  inventory_item_id: z.ZodString;
127
143
  batch_id: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
128
144
  counted_quantity: z.ZodNumber;
145
+ non_sale_quantities: z.ZodOptional<z.ZodArray<z.ZodObject<{
146
+ reason: z.ZodEnum<{
147
+ expired: "expired";
148
+ damaged: "damaged";
149
+ returned: "returned";
150
+ correction: "correction";
151
+ }>;
152
+ quantity: z.ZodNumber;
153
+ }, z.core.$strip>>>;
129
154
  }, z.core.$strip>>;
130
155
  }, z.core.$strip>;
131
156
  export declare const SubmitExistingConsignmentReportSchema: z.ZodObject<{
@@ -134,6 +159,15 @@ export declare const SubmitExistingConsignmentReportSchema: z.ZodObject<{
134
159
  inventory_item_id: z.ZodString;
135
160
  batch_id: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
136
161
  counted_quantity: z.ZodNumber;
162
+ non_sale_quantities: z.ZodOptional<z.ZodArray<z.ZodObject<{
163
+ reason: z.ZodEnum<{
164
+ expired: "expired";
165
+ damaged: "damaged";
166
+ returned: "returned";
167
+ correction: "correction";
168
+ }>;
169
+ quantity: z.ZodNumber;
170
+ }, z.core.$strip>>>;
137
171
  }, z.core.$strip>>;
138
172
  }, z.core.$strip>;
139
173
  type ResolvedPartnerPortalDateRange = {
@@ -412,6 +446,15 @@ export declare const StoreConsignmentReportLineSchema: z.ZodObject<{
412
446
  confirmed_sale_quantity: z.ZodNumber;
413
447
  requires_admin_clarification: z.ZodBoolean;
414
448
  non_sale_reason: z.ZodNullable<z.ZodString>;
449
+ non_sale_quantities: z.ZodArray<z.ZodObject<{
450
+ reason: z.ZodEnum<{
451
+ expired: "expired";
452
+ damaged: "damaged";
453
+ returned: "returned";
454
+ correction: "correction";
455
+ }>;
456
+ quantity: z.ZodNumber;
457
+ }, z.core.$strip>>;
415
458
  resolved_unit_price: z.ZodNullable<z.ZodNumber>;
416
459
  discounted_line_total: z.ZodNullable<z.ZodNumber>;
417
460
  currency_code: z.ZodNullable<z.ZodString>;
@@ -444,6 +487,15 @@ export declare const StoreConsignmentReportSchema: z.ZodObject<{
444
487
  confirmed_sale_quantity: z.ZodNumber;
445
488
  requires_admin_clarification: z.ZodBoolean;
446
489
  non_sale_reason: z.ZodNullable<z.ZodString>;
490
+ non_sale_quantities: z.ZodArray<z.ZodObject<{
491
+ reason: z.ZodEnum<{
492
+ expired: "expired";
493
+ damaged: "damaged";
494
+ returned: "returned";
495
+ correction: "correction";
496
+ }>;
497
+ quantity: z.ZodNumber;
498
+ }, z.core.$strip>>;
447
499
  resolved_unit_price: z.ZodNullable<z.ZodNumber>;
448
500
  discounted_line_total: z.ZodNullable<z.ZodNumber>;
449
501
  currency_code: z.ZodNullable<z.ZodString>;
@@ -478,6 +530,15 @@ export declare const SubmitConsignmentReportResponseSchema: z.ZodObject<{
478
530
  confirmed_sale_quantity: z.ZodNumber;
479
531
  requires_admin_clarification: z.ZodBoolean;
480
532
  non_sale_reason: z.ZodNullable<z.ZodString>;
533
+ non_sale_quantities: z.ZodArray<z.ZodObject<{
534
+ reason: z.ZodEnum<{
535
+ expired: "expired";
536
+ damaged: "damaged";
537
+ returned: "returned";
538
+ correction: "correction";
539
+ }>;
540
+ quantity: z.ZodNumber;
541
+ }, z.core.$strip>>;
481
542
  resolved_unit_price: z.ZodNullable<z.ZodNumber>;
482
543
  discounted_line_total: z.ZodNullable<z.ZodNumber>;
483
544
  currency_code: z.ZodNullable<z.ZodString>;
@@ -516,6 +577,15 @@ export declare const ListConsignmentReportsResponseSchema: z.ZodObject<{
516
577
  confirmed_sale_quantity: z.ZodNumber;
517
578
  requires_admin_clarification: z.ZodBoolean;
518
579
  non_sale_reason: z.ZodNullable<z.ZodString>;
580
+ non_sale_quantities: z.ZodArray<z.ZodObject<{
581
+ reason: z.ZodEnum<{
582
+ expired: "expired";
583
+ damaged: "damaged";
584
+ returned: "returned";
585
+ correction: "correction";
586
+ }>;
587
+ quantity: z.ZodNumber;
588
+ }, z.core.$strip>>;
519
589
  resolved_unit_price: z.ZodNullable<z.ZodNumber>;
520
590
  discounted_line_total: z.ZodNullable<z.ZodNumber>;
521
591
  currency_code: z.ZodNullable<z.ZodString>;
@@ -857,22 +927,6 @@ export declare const TransferConsignmentStockSchema: z.ZodObject<{
857
927
  quantity: z.ZodNumber;
858
928
  }, z.core.$strip>>;
859
929
  }, z.core.$strip>;
860
- export declare const ConsignmentNonSaleReasonSchema: z.ZodEnum<{
861
- expired: "expired";
862
- damaged: "damaged";
863
- returned: "returned";
864
- correction: "correction";
865
- }>;
866
- /** A part of a line's not-sold shortage with its reason. */
867
- export declare const ConsignmentNonSaleQuantitySchema: z.ZodObject<{
868
- reason: z.ZodEnum<{
869
- expired: "expired";
870
- damaged: "damaged";
871
- returned: "returned";
872
- correction: "correction";
873
- }>;
874
- quantity: z.ZodNumber;
875
- }, z.core.$strip>;
876
930
  export declare const ApproveConsignmentReportSchema: z.ZodObject<{
877
931
  expected_version: z.ZodOptional<z.ZodNumber>;
878
932
  confirmed_lines: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubmitConsignmentReportResponseSchema = exports.StoreConsignmentReportSchema = exports.StoreConsignmentReportLineSchema = exports.GetConsignmentInventoryResponseSchema = exports.StoreConsignmentInventoryLineSchema = exports.ConsignmentLineLabelsSchema = exports.ApplyOwnOrderPromotionResponseSchema = exports.GetOwnOrderDiscountResponseSchema = exports.GetAffiliateCartReferralResponseSchema = exports.ApplyAffiliateCouponResponseSchema = exports.CaptureAffiliateReferralResponseSchema = exports.StoreAffiliateReferralSchema = exports.ResolveAffiliateReferralResponseSchema = exports.SubmitAffiliateApplicationResponseSchema = exports.StoreAffiliateApplicationSchema = exports.StoreAffiliateSlugSchema = exports.StoreAffiliateSchema = exports.UpdatePartnerPortalSlugSchema = exports.CreatePartnerPortalSlugSchema = exports.PartnerPortalEmptyQuerySchema = exports.PartnerPortalCommissionsQuerySchema = exports.PartnerPortalDateRangeQuerySchema = exports.createPartnerPortalDateRangeQuerySchema = exports.SubmitExistingConsignmentReportSchema = exports.SubmitConsignmentReportSchema = exports.AffiliateCouponLabelsResponseSchema = exports.AffiliateCouponLabelSchema = exports.ResolveAffiliateCouponLabelsPayloadSchema = exports.ApplyAffiliateCouponSchema = exports.CaptureAffiliateReferralSchema = exports.ApplyOwnOrderPromotionSchema = exports.ResolveReferralQuerySchema = exports.SubmitAffiliateApplicationSchema = exports.CalendarMonthSchema = exports.CalendarDateSchema = exports.CommissionEntryTypeSchema = exports.AffiliateReferralResultStatusSchema = exports.AffiliateCartReferralRecordStatusSchema = exports.AffiliateCouponOriginSchema = exports.AffiliateCouponWireStatusSchema = exports.AffiliateCouponProvisioningStatusSchema = exports.AffiliateCouponLifecycleStatusSchema = exports.AffiliateReferralSignalSourceSchema = exports.AffiliateReferralOverwritePolicySchema = exports.PersistedAffiliateCustomerAssignmentModeSchema = exports.AffiliateCustomerAssignmentModeSchema = exports.AssignmentSourceSchema = exports.AffiliateApplicationStatusSchema = exports.AffiliateStatusSchema = exports.WireDateSchema = void 0;
4
- exports.CommissionEntrySchema = exports.CustomerAffiliateAssignmentSchema = exports.AffiliateApplicationSchema = exports.AffiliateApplicationCompanyVerificationSchema = exports.AffiliateSchema = exports.AffiliateCustomerSummarySchema = exports.AffiliateSlugSchema = exports.ListConsignmentReportsQuerySchema = exports.AffiliateDistributionReportQuerySchema = exports.UpdateAffiliateProgramSettingsSchema = exports.ReportDetailQuerySchema = exports.ReportDateRangeQuerySchema = exports.RequestConsignmentReminderSchema = exports.CorrectConsignmentReportSchema = exports.RejectConsignmentReportSchema = exports.ApproveConsignmentReportSchema = exports.ConsignmentNonSaleQuantitySchema = exports.ConsignmentNonSaleReasonSchema = exports.TransferConsignmentStockSchema = exports.EnableAffiliateDistributionSchema = exports.SetCustomerAffiliateAssignmentSchema = exports.SetOrderAffiliateAttributionSchema = exports.UpdateAffiliateSlugSchema = exports.CreateAffiliateSlugSchema = exports.UpdateAffiliateSchema = exports.CreateAffiliateSchema = exports.ListAffiliatesQuerySchema = exports.RejectAffiliateApplicationSchema = exports.ApproveAffiliateApplicationSchema = exports.ListAffiliateApplicationsQuerySchema = exports.OwnOrderDiscountQuerySchema = exports.PaginationQuerySchema = exports.RotateAdminAffiliateCouponCodeSchema = exports.CreateAdminAffiliateCouponCodeSchema = exports.ListAdminAffiliateCouponCodesQuerySchema = exports.RotateStoreAffiliateCouponCodeSchema = exports.CreateStoreAffiliateCouponCodeSchema = exports.ListStoreAffiliateCouponCodesQuerySchema = exports.GetAffiliatePortalCommissionsResponseSchema = exports.StoreAffiliatePortalCommissionSchema = exports.GetAffiliatePortalDashboardResponseSchema = exports.PortalCurrencyTotalsSchema = exports.UpdatePartnerPortalSlugResponseSchema = exports.CreatePartnerPortalSlugResponseSchema = exports.ListPartnerPortalSlugsResponseSchema = exports.StoreAffiliatePortalContextResponseSchema = exports.StoreAffiliatePortalSlugSchema = exports.StoreAffiliatePortalAffiliateSchema = exports.StoreAffiliatePortalApplicationSchema = exports.ListConsignmentReportsResponseSchema = void 0;
3
+ exports.StoreConsignmentReportLineSchema = exports.GetConsignmentInventoryResponseSchema = exports.StoreConsignmentInventoryLineSchema = exports.ConsignmentLineLabelsSchema = exports.ApplyOwnOrderPromotionResponseSchema = exports.GetOwnOrderDiscountResponseSchema = exports.GetAffiliateCartReferralResponseSchema = exports.ApplyAffiliateCouponResponseSchema = exports.CaptureAffiliateReferralResponseSchema = exports.StoreAffiliateReferralSchema = exports.ResolveAffiliateReferralResponseSchema = exports.SubmitAffiliateApplicationResponseSchema = exports.StoreAffiliateApplicationSchema = exports.StoreAffiliateSlugSchema = exports.StoreAffiliateSchema = exports.UpdatePartnerPortalSlugSchema = exports.CreatePartnerPortalSlugSchema = exports.PartnerPortalEmptyQuerySchema = exports.PartnerPortalCommissionsQuerySchema = exports.PartnerPortalDateRangeQuerySchema = exports.createPartnerPortalDateRangeQuerySchema = exports.SubmitExistingConsignmentReportSchema = exports.SubmitConsignmentReportSchema = exports.ConsignmentNonSaleQuantitySchema = exports.ConsignmentNonSaleReasonSchema = exports.AffiliateCouponLabelsResponseSchema = exports.AffiliateCouponLabelSchema = exports.ResolveAffiliateCouponLabelsPayloadSchema = exports.ApplyAffiliateCouponSchema = exports.CaptureAffiliateReferralSchema = exports.ApplyOwnOrderPromotionSchema = exports.ResolveReferralQuerySchema = exports.SubmitAffiliateApplicationSchema = exports.CalendarMonthSchema = exports.CalendarDateSchema = exports.CommissionEntryTypeSchema = exports.AffiliateReferralResultStatusSchema = exports.AffiliateCartReferralRecordStatusSchema = exports.AffiliateCouponOriginSchema = exports.AffiliateCouponWireStatusSchema = exports.AffiliateCouponProvisioningStatusSchema = exports.AffiliateCouponLifecycleStatusSchema = exports.AffiliateReferralSignalSourceSchema = exports.AffiliateReferralOverwritePolicySchema = exports.PersistedAffiliateCustomerAssignmentModeSchema = exports.AffiliateCustomerAssignmentModeSchema = exports.AssignmentSourceSchema = exports.AffiliateApplicationStatusSchema = exports.AffiliateStatusSchema = exports.WireDateSchema = void 0;
4
+ exports.CommissionEntrySchema = exports.CustomerAffiliateAssignmentSchema = exports.AffiliateApplicationSchema = exports.AffiliateApplicationCompanyVerificationSchema = exports.AffiliateSchema = exports.AffiliateCustomerSummarySchema = exports.AffiliateSlugSchema = exports.ListConsignmentReportsQuerySchema = exports.AffiliateDistributionReportQuerySchema = exports.UpdateAffiliateProgramSettingsSchema = exports.ReportDetailQuerySchema = exports.ReportDateRangeQuerySchema = exports.RequestConsignmentReminderSchema = exports.CorrectConsignmentReportSchema = exports.RejectConsignmentReportSchema = exports.ApproveConsignmentReportSchema = exports.TransferConsignmentStockSchema = exports.EnableAffiliateDistributionSchema = exports.SetCustomerAffiliateAssignmentSchema = exports.SetOrderAffiliateAttributionSchema = exports.UpdateAffiliateSlugSchema = exports.CreateAffiliateSlugSchema = exports.UpdateAffiliateSchema = exports.CreateAffiliateSchema = exports.ListAffiliatesQuerySchema = exports.RejectAffiliateApplicationSchema = exports.ApproveAffiliateApplicationSchema = exports.ListAffiliateApplicationsQuerySchema = exports.OwnOrderDiscountQuerySchema = exports.PaginationQuerySchema = exports.RotateAdminAffiliateCouponCodeSchema = exports.CreateAdminAffiliateCouponCodeSchema = exports.ListAdminAffiliateCouponCodesQuerySchema = exports.RotateStoreAffiliateCouponCodeSchema = exports.CreateStoreAffiliateCouponCodeSchema = exports.ListStoreAffiliateCouponCodesQuerySchema = exports.GetAffiliatePortalCommissionsResponseSchema = exports.StoreAffiliatePortalCommissionSchema = exports.GetAffiliatePortalDashboardResponseSchema = exports.PortalCurrencyTotalsSchema = exports.UpdatePartnerPortalSlugResponseSchema = exports.CreatePartnerPortalSlugResponseSchema = exports.ListPartnerPortalSlugsResponseSchema = exports.StoreAffiliatePortalContextResponseSchema = exports.StoreAffiliatePortalSlugSchema = exports.StoreAffiliatePortalAffiliateSchema = exports.StoreAffiliatePortalApplicationSchema = exports.ListConsignmentReportsResponseSchema = exports.SubmitConsignmentReportResponseSchema = exports.StoreConsignmentReportSchema = void 0;
5
5
  exports.CorrectConsignmentReportResponseSchema = exports.RejectConsignmentReportResponseSchema = exports.ApproveConsignmentReportResponseSchema = exports.AdminConsignmentReportResponseSchema = exports.ListAdminConsignmentReportsResponseSchema = exports.AdminConsignmentReportSchema = exports.AdminConsignmentReportCorrectionSchema = exports.AdminConsignmentReportLineSchema = exports.RequestConsignmentReminderResponseSchema = exports.ConsignmentTransferResponseSchema = exports.ConsignmentTransferSchema = exports.AffiliateDistributionResponseSchema = exports.AffiliateDistributionSettingsSchema = exports.AffiliateDistributionReportsResponseSchema = exports.AffiliateDistributionReportItemSchema = exports.AffiliateDistributionCurrencyTotalSchema = exports.AffiliateProgramSettingsResponseSchema = exports.AffiliateProgramSettingsSchema = exports.AffiliateReportDetailResponseSchema = exports.AffiliateReportEntrySchema = exports.AffiliateReportTotalsSchema = exports.AffiliateReportOverviewResponseSchema = exports.AffiliateReportOverviewItemSchema = exports.OrderAffiliateAttributionResponseSchema = exports.AffiliateOrderAttributionSchema = exports.CustomerAffiliateAssignmentResponseSchema = exports.ReconcileAdminAffiliateCouponCodeResponseSchema = exports.RotateAdminAffiliateCouponCodeResponseSchema = exports.AdminAffiliateCouponCodeResponseSchema = exports.ListAdminAffiliateCouponCodesResponseSchema = exports.RotateStoreAffiliateCouponCodeResponseSchema = exports.StoreAffiliateCouponCodeResponseSchema = exports.ListStoreAffiliateCouponCodesResponseSchema = exports.AppliedAffiliateCouponSnapshotSchema = exports.AdminAffiliateCouponCodeSchema = exports.StoreAffiliateCouponCodeSchema = exports.ListAffiliateSlugsResponseSchema = exports.AffiliateSlugResponseSchema = exports.AffiliateResponseSchema = exports.ListAffiliatesResponseSchema = exports.ApproveAffiliateApplicationResponseSchema = exports.AffiliateApplicationResponseSchema = exports.ListAffiliateApplicationsResponseSchema = void 0;
6
6
  const zod_1 = require("@medusajs/framework/zod");
7
7
  const primitives_1 = require("../shared/primitives");
@@ -158,10 +158,30 @@ exports.AffiliateCouponLabelSchema = zod_1.z.object({
158
158
  exports.AffiliateCouponLabelsResponseSchema = zod_1.z.object({
159
159
  labels: zod_1.z.array(exports.AffiliateCouponLabelSchema),
160
160
  });
161
+ exports.ConsignmentNonSaleReasonSchema = zod_1.z.enum([
162
+ "damaged",
163
+ "expired",
164
+ "returned",
165
+ "correction",
166
+ ]);
167
+ /** A part of a line's not-sold shortage with its reason. */
168
+ exports.ConsignmentNonSaleQuantitySchema = zod_1.z.object({
169
+ reason: exports.ConsignmentNonSaleReasonSchema,
170
+ quantity: zod_1.z.number().int().positive(),
171
+ });
161
172
  const ConsignmentCountSchema = zod_1.z.object({
162
173
  inventory_item_id: zod_1.z.string().trim().min(1),
163
174
  batch_id: zod_1.z.string().trim().min(1).nullable().optional().default(null),
164
175
  counted_quantity: zod_1.z.number().int().min(0),
176
+ /**
177
+ * The affiliate's split of the line's shortage (expected minus counted):
178
+ * the not-sold part by reason; the rest counts as sold. Empty or missing
179
+ * means the whole shortage was sold. Only allowed with a shortage.
180
+ */
181
+ non_sale_quantities: zod_1.z
182
+ .array(exports.ConsignmentNonSaleQuantitySchema)
183
+ .max(20)
184
+ .optional(),
165
185
  });
166
186
  exports.SubmitConsignmentReportSchema = zod_1.z.object({
167
187
  period_start: exports.CalendarMonthSchema,
@@ -339,6 +359,8 @@ exports.StoreConsignmentReportLineSchema = zod_1.z
339
359
  confirmed_sale_quantity: zod_1.z.number(),
340
360
  requires_admin_clarification: zod_1.z.boolean(),
341
361
  non_sale_reason: zod_1.z.string().nullable(),
362
+ /** Not-sold shortage by reason; empty when everything missing was sold. */
363
+ non_sale_quantities: zod_1.z.array(exports.ConsignmentNonSaleQuantitySchema),
342
364
  resolved_unit_price: zod_1.z.number().nullable(),
343
365
  discounted_line_total: zod_1.z.number().nullable(),
344
366
  currency_code: zod_1.z.string().nullable(),
@@ -627,17 +649,6 @@ exports.TransferConsignmentStockSchema = zod_1.z.object({
627
649
  .min(1)
628
650
  .max(100),
629
651
  });
630
- exports.ConsignmentNonSaleReasonSchema = zod_1.z.enum([
631
- "damaged",
632
- "expired",
633
- "returned",
634
- "correction",
635
- ]);
636
- /** A part of a line's not-sold shortage with its reason. */
637
- exports.ConsignmentNonSaleQuantitySchema = zod_1.z.object({
638
- reason: exports.ConsignmentNonSaleReasonSchema,
639
- quantity: zod_1.z.number().int().positive(),
640
- });
641
652
  exports.ApproveConsignmentReportSchema = zod_1.z.object({
642
653
  expected_version: zod_1.z.number().int().positive().optional(),
643
654
  confirmed_lines: zod_1.z
@@ -40,6 +40,7 @@ export declare const EmailSafeStatusCodeSchema: z.ZodEnum<{
40
40
  connection_failed: "connection_failed";
41
41
  invalid_content: "invalid_content";
42
42
  lease_expired: "lease_expired";
43
+ no_recipient: "no_recipient";
43
44
  not_configured: "not_configured";
44
45
  notifications_disabled: "notifications_disabled";
45
46
  outcome_unknown: "outcome_unknown";
@@ -179,6 +180,7 @@ export declare const AdminEmailMessageSchema: z.ZodObject<{
179
180
  connection_failed: "connection_failed";
180
181
  invalid_content: "invalid_content";
181
182
  lease_expired: "lease_expired";
183
+ no_recipient: "no_recipient";
182
184
  not_configured: "not_configured";
183
185
  notifications_disabled: "notifications_disabled";
184
186
  outcome_unknown: "outcome_unknown";
@@ -217,6 +219,7 @@ export declare const AdminEmailAttemptSchema: z.ZodObject<{
217
219
  connection_failed: "connection_failed";
218
220
  invalid_content: "invalid_content";
219
221
  lease_expired: "lease_expired";
222
+ no_recipient: "no_recipient";
220
223
  not_configured: "not_configured";
221
224
  notifications_disabled: "notifications_disabled";
222
225
  outcome_unknown: "outcome_unknown";
@@ -312,6 +315,7 @@ export declare const ListAdminEmailMessagesResponseSchema: z.ZodObject<{
312
315
  connection_failed: "connection_failed";
313
316
  invalid_content: "invalid_content";
314
317
  lease_expired: "lease_expired";
318
+ no_recipient: "no_recipient";
315
319
  not_configured: "not_configured";
316
320
  notifications_disabled: "notifications_disabled";
317
321
  outcome_unknown: "outcome_unknown";
@@ -382,6 +386,7 @@ export declare const GetAdminEmailMessageResponseSchema: z.ZodObject<{
382
386
  connection_failed: "connection_failed";
383
387
  invalid_content: "invalid_content";
384
388
  lease_expired: "lease_expired";
389
+ no_recipient: "no_recipient";
385
390
  not_configured: "not_configured";
386
391
  notifications_disabled: "notifications_disabled";
387
392
  outcome_unknown: "outcome_unknown";
@@ -420,6 +425,7 @@ export declare const GetAdminEmailMessageResponseSchema: z.ZodObject<{
420
425
  connection_failed: "connection_failed";
421
426
  invalid_content: "invalid_content";
422
427
  lease_expired: "lease_expired";
428
+ no_recipient: "no_recipient";
423
429
  not_configured: "not_configured";
424
430
  notifications_disabled: "notifications_disabled";
425
431
  outcome_unknown: "outcome_unknown";
@@ -486,6 +492,7 @@ export declare const ResendAdminEmailMessageResponseSchema: z.ZodObject<{
486
492
  connection_failed: "connection_failed";
487
493
  invalid_content: "invalid_content";
488
494
  lease_expired: "lease_expired";
495
+ no_recipient: "no_recipient";
489
496
  not_configured: "not_configured";
490
497
  notifications_disabled: "notifications_disabled";
491
498
  outcome_unknown: "outcome_unknown";
@@ -44,6 +44,7 @@ exports.EmailSafeStatusCodeSchema = zod_1.z.enum([
44
44
  "connection_failed",
45
45
  "invalid_content",
46
46
  "lease_expired",
47
+ "no_recipient",
47
48
  "not_configured",
48
49
  "notifications_disabled",
49
50
  "outcome_unknown",
@@ -153,10 +153,30 @@ export const AffiliateCouponLabelSchema = z.object({
153
153
  export const AffiliateCouponLabelsResponseSchema = z.object({
154
154
  labels: z.array(AffiliateCouponLabelSchema),
155
155
  });
156
+ export const ConsignmentNonSaleReasonSchema = z.enum([
157
+ "damaged",
158
+ "expired",
159
+ "returned",
160
+ "correction",
161
+ ]);
162
+ /** A part of a line's not-sold shortage with its reason. */
163
+ export const ConsignmentNonSaleQuantitySchema = z.object({
164
+ reason: ConsignmentNonSaleReasonSchema,
165
+ quantity: z.number().int().positive(),
166
+ });
156
167
  const ConsignmentCountSchema = z.object({
157
168
  inventory_item_id: z.string().trim().min(1),
158
169
  batch_id: z.string().trim().min(1).nullable().optional().default(null),
159
170
  counted_quantity: z.number().int().min(0),
171
+ /**
172
+ * The affiliate's split of the line's shortage (expected minus counted):
173
+ * the not-sold part by reason; the rest counts as sold. Empty or missing
174
+ * means the whole shortage was sold. Only allowed with a shortage.
175
+ */
176
+ non_sale_quantities: z
177
+ .array(ConsignmentNonSaleQuantitySchema)
178
+ .max(20)
179
+ .optional(),
160
180
  });
161
181
  export const SubmitConsignmentReportSchema = z.object({
162
182
  period_start: CalendarMonthSchema,
@@ -333,6 +353,8 @@ export const StoreConsignmentReportLineSchema = z
333
353
  confirmed_sale_quantity: z.number(),
334
354
  requires_admin_clarification: z.boolean(),
335
355
  non_sale_reason: z.string().nullable(),
356
+ /** Not-sold shortage by reason; empty when everything missing was sold. */
357
+ non_sale_quantities: z.array(ConsignmentNonSaleQuantitySchema),
336
358
  resolved_unit_price: z.number().nullable(),
337
359
  discounted_line_total: z.number().nullable(),
338
360
  currency_code: z.string().nullable(),
@@ -621,17 +643,6 @@ export const TransferConsignmentStockSchema = z.object({
621
643
  .min(1)
622
644
  .max(100),
623
645
  });
624
- export const ConsignmentNonSaleReasonSchema = z.enum([
625
- "damaged",
626
- "expired",
627
- "returned",
628
- "correction",
629
- ]);
630
- /** A part of a line's not-sold shortage with its reason. */
631
- export const ConsignmentNonSaleQuantitySchema = z.object({
632
- reason: ConsignmentNonSaleReasonSchema,
633
- quantity: z.number().int().positive(),
634
- });
635
646
  export const ApproveConsignmentReportSchema = z.object({
636
647
  expected_version: z.number().int().positive().optional(),
637
648
  confirmed_lines: z
@@ -41,6 +41,7 @@ export const EmailSafeStatusCodeSchema = z.enum([
41
41
  "connection_failed",
42
42
  "invalid_content",
43
43
  "lease_expired",
44
+ "no_recipient",
44
45
  "not_configured",
45
46
  "notifications_disabled",
46
47
  "outcome_unknown",
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The shop's MCP endpoint for the order assistant (Streamable HTTP,
3
+ * stateless). Outside `/admin` and `/store`: it authenticates on its own.
4
+ */
5
+ export const orderAssistantPaths = {
6
+ mcp: "/mcp",
7
+ };
@@ -0,0 +1,183 @@
1
+ import { z } from "@medusajs/framework/zod";
2
+ import { NonEmptyStringSchema } from "../shared/primitives.mjs";
3
+ /** Plugin key and container key of the order assistant in the base. */
4
+ export const ORDER_ASSISTANT_PLUGIN_KEY = "order_assistant";
5
+ /** Tool names as the MCP client sees them. */
6
+ export const ORDER_ASSISTANT_TOOLS = {
7
+ searchCustomers: "kunden_suchen",
8
+ searchProducts: "produkte_suchen",
9
+ listShippingOptions: "versandarten_auflisten",
10
+ createDraftOrder: "bestellentwurf_anlegen",
11
+ };
12
+ /** How the order reached the shop; stored in the order metadata. */
13
+ export const OrderAssistantSourceSchema = z.enum(["fax", "telefon"]);
14
+ /** Order metadata keys the assistant writes. */
15
+ export const ORDER_ASSISTANT_METADATA = {
16
+ source: "order_source",
17
+ note: "order_note",
18
+ };
19
+ export const ORDER_ASSISTANT_LIMITS = {
20
+ customers: 10,
21
+ variants: 20,
22
+ items: 50,
23
+ noteLength: 2000,
24
+ };
25
+ const CountryCodeSchema = z
26
+ .string()
27
+ .trim()
28
+ .toLowerCase()
29
+ .regex(/^[a-z]{2}$/)
30
+ .describe("Land als ISO-3166-1-alpha-2-Code, z. B. at oder de.");
31
+ const OptionalTextSchema = z.string().trim().min(1).max(255).optional();
32
+ export const OrderAssistantAddressSchema = z
33
+ .object({
34
+ first_name: NonEmptyStringSchema.max(255),
35
+ last_name: NonEmptyStringSchema.max(255),
36
+ company: OptionalTextSchema.describe("Firma oder Praxis, falls angegeben."),
37
+ address_1: NonEmptyStringSchema.max(255).describe("Straße und Hausnummer."),
38
+ address_2: OptionalTextSchema.describe("Adresszusatz."),
39
+ postal_code: NonEmptyStringSchema.max(20),
40
+ city: NonEmptyStringSchema.max(255),
41
+ country_code: CountryCodeSchema,
42
+ phone: OptionalTextSchema,
43
+ })
44
+ .strict();
45
+ export const SearchCustomersInputSchema = z
46
+ .object({
47
+ query: OptionalTextSchema.describe("Name, Firma, Telefonnummer oder E-Mail-Adresse (auch Teile davon)."),
48
+ postal_code: OptionalTextSchema.describe("PLZ einer Adresse der Person."),
49
+ city: OptionalTextSchema.describe("Ort einer Adresse der Person."),
50
+ })
51
+ .strict()
52
+ .refine((value) => Boolean(value.query ?? value.postal_code ?? value.city), { message: "Mindestens ein Suchfeld ist nötig." });
53
+ export const OrderAssistantCustomerAddressSchema = z.object({
54
+ first_name: z.string().nullable(),
55
+ last_name: z.string().nullable(),
56
+ company: z.string().nullable(),
57
+ address_1: z.string().nullable(),
58
+ address_2: z.string().nullable(),
59
+ postal_code: z.string().nullable(),
60
+ city: z.string().nullable(),
61
+ country_code: z.string().nullable(),
62
+ phone: z.string().nullable(),
63
+ });
64
+ export const OrderAssistantCustomerSchema = z.object({
65
+ id: z.string(),
66
+ first_name: z.string().nullable(),
67
+ last_name: z.string().nullable(),
68
+ company_name: z.string().nullable(),
69
+ email: z.string().nullable(),
70
+ phone: z.string().nullable(),
71
+ /** Registered shop account (true) or a customer record without login. */
72
+ has_account: z.boolean(),
73
+ addresses: z.array(OrderAssistantCustomerAddressSchema),
74
+ });
75
+ export const SearchCustomersOutputSchema = z.object({
76
+ customers: z.array(OrderAssistantCustomerSchema),
77
+ });
78
+ export const SearchProductsInputSchema = z
79
+ .object({
80
+ query: NonEmptyStringSchema.max(255).describe("Produktname oder Artikelnummer (auch Teile davon)."),
81
+ country_code: CountryCodeSchema.describe("Lieferland als ISO-Code; bestimmt Preis und Währung."),
82
+ })
83
+ .strict();
84
+ export const OrderAssistantVariantSchema = z.object({
85
+ variant_id: z.string(),
86
+ product_title: z.string(),
87
+ variant_title: z.string().nullable(),
88
+ sku: z.string().nullable(),
89
+ /** Price per unit in major currency units (33.5 = 33,50); null without a price. */
90
+ unit_price: z.number().nullable(),
91
+ currency_code: z.string(),
92
+ /** Available quantity; null when the variant's stock is not managed. */
93
+ available_quantity: z.number().nullable(),
94
+ /** False when the variant cannot be ordered (no price or no stock). */
95
+ orderable: z.boolean(),
96
+ });
97
+ export const SearchProductsOutputSchema = z.object({
98
+ variants: z.array(OrderAssistantVariantSchema),
99
+ });
100
+ export const ListShippingOptionsInputSchema = z
101
+ .object({
102
+ country_code: CountryCodeSchema.describe("Lieferland als ISO-Code."),
103
+ })
104
+ .strict();
105
+ export const OrderAssistantShippingOptionSchema = z.object({
106
+ id: z.string(),
107
+ name: z.string(),
108
+ /** Flat price in major currency units; null when none is set for the currency. */
109
+ amount: z.number().nullable(),
110
+ currency_code: z.string(),
111
+ });
112
+ export const ListShippingOptionsOutputSchema = z.object({
113
+ shipping_options: z.array(OrderAssistantShippingOptionSchema),
114
+ });
115
+ export const OrderAssistantNewCustomerSchema = z
116
+ .object({
117
+ first_name: NonEmptyStringSchema.max(255),
118
+ last_name: NonEmptyStringSchema.max(255),
119
+ company_name: OptionalTextSchema,
120
+ email: z
121
+ .string()
122
+ .trim()
123
+ .toLowerCase()
124
+ .email()
125
+ .max(255)
126
+ .optional()
127
+ .describe("Nur angeben, wenn eine E-Mail-Adresse bekannt ist."),
128
+ phone: OptionalTextSchema,
129
+ })
130
+ .strict();
131
+ export const CreateDraftOrderInputSchema = z
132
+ .object({
133
+ customer_id: z
134
+ .string()
135
+ .trim()
136
+ .min(1)
137
+ .optional()
138
+ .describe("ID einer bestehenden Kund:in aus kunden_suchen."),
139
+ new_customer: OrderAssistantNewCustomerSchema.optional().describe("Neue Kund:in ohne Konto; nur wenn kunden_suchen niemanden findet."),
140
+ shipping_address: OrderAssistantAddressSchema,
141
+ billing_address: OrderAssistantAddressSchema.optional().describe("Rechnungsadresse; ohne Angabe gilt die Lieferadresse."),
142
+ items: z
143
+ .array(z
144
+ .object({
145
+ variant_id: NonEmptyStringSchema.describe("ID der Variante aus produkte_suchen."),
146
+ quantity: z.number().int().positive().max(9999),
147
+ })
148
+ .strict())
149
+ .min(1)
150
+ .max(ORDER_ASSISTANT_LIMITS.items),
151
+ shipping_option_id: NonEmptyStringSchema.describe("ID der Versandart aus versandarten_auflisten."),
152
+ source: OrderAssistantSourceSchema.describe("Wie die Bestellung eingegangen ist."),
153
+ note: z
154
+ .string()
155
+ .trim()
156
+ .min(1)
157
+ .max(ORDER_ASSISTANT_LIMITS.noteLength)
158
+ .optional()
159
+ .describe("Interne Notiz, z. B. Unklarheiten auf dem Fax."),
160
+ })
161
+ .strict()
162
+ .refine((value) => Boolean(value.customer_id) !== Boolean(value.new_customer), { message: "Genau eines von customer_id und new_customer ist nötig." });
163
+ export const OrderAssistantDraftItemSchema = z.object({
164
+ title: z.string(),
165
+ sku: z.string().nullable(),
166
+ quantity: z.number(),
167
+ unit_price: z.number(),
168
+ total: z.number(),
169
+ });
170
+ export const CreateDraftOrderOutputSchema = z.object({
171
+ draft_order_id: z.string(),
172
+ display_id: z.number().nullable(),
173
+ customer_id: z.string(),
174
+ /** True when the assistant created the customer record for this draft. */
175
+ customer_created: z.boolean(),
176
+ currency_code: z.string(),
177
+ items: z.array(OrderAssistantDraftItemSchema),
178
+ shipping_total: z.number(),
179
+ tax_total: z.number(),
180
+ total: z.number(),
181
+ /** Path of the draft in the Admin, relative to the backend URL. */
182
+ admin_path: z.string(),
183
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The shop's MCP endpoint for the order assistant (Streamable HTTP,
3
+ * stateless). Outside `/admin` and `/store`: it authenticates on its own.
4
+ */
5
+ export declare const orderAssistantPaths: {
6
+ readonly mcp: "/mcp";
7
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.orderAssistantPaths = void 0;
4
+ /**
5
+ * The shop's MCP endpoint for the order assistant (Streamable HTTP,
6
+ * stateless). Outside `/admin` and `/store`: it authenticates on its own.
7
+ */
8
+ exports.orderAssistantPaths = {
9
+ mcp: "/mcp",
10
+ };
@@ -0,0 +1,213 @@
1
+ import { z } from "@medusajs/framework/zod";
2
+ /** Plugin key and container key of the order assistant in the base. */
3
+ export declare const ORDER_ASSISTANT_PLUGIN_KEY = "order_assistant";
4
+ /** Tool names as the MCP client sees them. */
5
+ export declare const ORDER_ASSISTANT_TOOLS: {
6
+ readonly searchCustomers: "kunden_suchen";
7
+ readonly searchProducts: "produkte_suchen";
8
+ readonly listShippingOptions: "versandarten_auflisten";
9
+ readonly createDraftOrder: "bestellentwurf_anlegen";
10
+ };
11
+ export type OrderAssistantToolName = (typeof ORDER_ASSISTANT_TOOLS)[keyof typeof ORDER_ASSISTANT_TOOLS];
12
+ /** How the order reached the shop; stored in the order metadata. */
13
+ export declare const OrderAssistantSourceSchema: z.ZodEnum<{
14
+ fax: "fax";
15
+ telefon: "telefon";
16
+ }>;
17
+ /** Order metadata keys the assistant writes. */
18
+ export declare const ORDER_ASSISTANT_METADATA: {
19
+ readonly source: "order_source";
20
+ readonly note: "order_note";
21
+ };
22
+ export declare const ORDER_ASSISTANT_LIMITS: {
23
+ readonly customers: 10;
24
+ readonly variants: 20;
25
+ readonly items: 50;
26
+ readonly noteLength: 2000;
27
+ };
28
+ export declare const OrderAssistantAddressSchema: z.ZodObject<{
29
+ first_name: z.ZodString;
30
+ last_name: z.ZodString;
31
+ company: z.ZodOptional<z.ZodString>;
32
+ address_1: z.ZodString;
33
+ address_2: z.ZodOptional<z.ZodString>;
34
+ postal_code: z.ZodString;
35
+ city: z.ZodString;
36
+ country_code: z.ZodString;
37
+ phone: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strict>;
39
+ export declare const SearchCustomersInputSchema: z.ZodObject<{
40
+ query: z.ZodOptional<z.ZodString>;
41
+ postal_code: z.ZodOptional<z.ZodString>;
42
+ city: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strict>;
44
+ export declare const OrderAssistantCustomerAddressSchema: z.ZodObject<{
45
+ first_name: z.ZodNullable<z.ZodString>;
46
+ last_name: z.ZodNullable<z.ZodString>;
47
+ company: z.ZodNullable<z.ZodString>;
48
+ address_1: z.ZodNullable<z.ZodString>;
49
+ address_2: z.ZodNullable<z.ZodString>;
50
+ postal_code: z.ZodNullable<z.ZodString>;
51
+ city: z.ZodNullable<z.ZodString>;
52
+ country_code: z.ZodNullable<z.ZodString>;
53
+ phone: z.ZodNullable<z.ZodString>;
54
+ }, z.core.$strip>;
55
+ export declare const OrderAssistantCustomerSchema: z.ZodObject<{
56
+ id: z.ZodString;
57
+ first_name: z.ZodNullable<z.ZodString>;
58
+ last_name: z.ZodNullable<z.ZodString>;
59
+ company_name: z.ZodNullable<z.ZodString>;
60
+ email: z.ZodNullable<z.ZodString>;
61
+ phone: z.ZodNullable<z.ZodString>;
62
+ has_account: z.ZodBoolean;
63
+ addresses: z.ZodArray<z.ZodObject<{
64
+ first_name: z.ZodNullable<z.ZodString>;
65
+ last_name: z.ZodNullable<z.ZodString>;
66
+ company: z.ZodNullable<z.ZodString>;
67
+ address_1: z.ZodNullable<z.ZodString>;
68
+ address_2: z.ZodNullable<z.ZodString>;
69
+ postal_code: z.ZodNullable<z.ZodString>;
70
+ city: z.ZodNullable<z.ZodString>;
71
+ country_code: z.ZodNullable<z.ZodString>;
72
+ phone: z.ZodNullable<z.ZodString>;
73
+ }, z.core.$strip>>;
74
+ }, z.core.$strip>;
75
+ export declare const SearchCustomersOutputSchema: z.ZodObject<{
76
+ customers: z.ZodArray<z.ZodObject<{
77
+ id: z.ZodString;
78
+ first_name: z.ZodNullable<z.ZodString>;
79
+ last_name: z.ZodNullable<z.ZodString>;
80
+ company_name: z.ZodNullable<z.ZodString>;
81
+ email: z.ZodNullable<z.ZodString>;
82
+ phone: z.ZodNullable<z.ZodString>;
83
+ has_account: z.ZodBoolean;
84
+ addresses: z.ZodArray<z.ZodObject<{
85
+ first_name: z.ZodNullable<z.ZodString>;
86
+ last_name: z.ZodNullable<z.ZodString>;
87
+ company: z.ZodNullable<z.ZodString>;
88
+ address_1: z.ZodNullable<z.ZodString>;
89
+ address_2: z.ZodNullable<z.ZodString>;
90
+ postal_code: z.ZodNullable<z.ZodString>;
91
+ city: z.ZodNullable<z.ZodString>;
92
+ country_code: z.ZodNullable<z.ZodString>;
93
+ phone: z.ZodNullable<z.ZodString>;
94
+ }, z.core.$strip>>;
95
+ }, z.core.$strip>>;
96
+ }, z.core.$strip>;
97
+ export declare const SearchProductsInputSchema: z.ZodObject<{
98
+ query: z.ZodString;
99
+ country_code: z.ZodString;
100
+ }, z.core.$strict>;
101
+ export declare const OrderAssistantVariantSchema: z.ZodObject<{
102
+ variant_id: z.ZodString;
103
+ product_title: z.ZodString;
104
+ variant_title: z.ZodNullable<z.ZodString>;
105
+ sku: z.ZodNullable<z.ZodString>;
106
+ unit_price: z.ZodNullable<z.ZodNumber>;
107
+ currency_code: z.ZodString;
108
+ available_quantity: z.ZodNullable<z.ZodNumber>;
109
+ orderable: z.ZodBoolean;
110
+ }, z.core.$strip>;
111
+ export declare const SearchProductsOutputSchema: z.ZodObject<{
112
+ variants: z.ZodArray<z.ZodObject<{
113
+ variant_id: z.ZodString;
114
+ product_title: z.ZodString;
115
+ variant_title: z.ZodNullable<z.ZodString>;
116
+ sku: z.ZodNullable<z.ZodString>;
117
+ unit_price: z.ZodNullable<z.ZodNumber>;
118
+ currency_code: z.ZodString;
119
+ available_quantity: z.ZodNullable<z.ZodNumber>;
120
+ orderable: z.ZodBoolean;
121
+ }, z.core.$strip>>;
122
+ }, z.core.$strip>;
123
+ export declare const ListShippingOptionsInputSchema: z.ZodObject<{
124
+ country_code: z.ZodString;
125
+ }, z.core.$strict>;
126
+ export declare const OrderAssistantShippingOptionSchema: z.ZodObject<{
127
+ id: z.ZodString;
128
+ name: z.ZodString;
129
+ amount: z.ZodNullable<z.ZodNumber>;
130
+ currency_code: z.ZodString;
131
+ }, z.core.$strip>;
132
+ export declare const ListShippingOptionsOutputSchema: z.ZodObject<{
133
+ shipping_options: z.ZodArray<z.ZodObject<{
134
+ id: z.ZodString;
135
+ name: z.ZodString;
136
+ amount: z.ZodNullable<z.ZodNumber>;
137
+ currency_code: z.ZodString;
138
+ }, z.core.$strip>>;
139
+ }, z.core.$strip>;
140
+ export declare const OrderAssistantNewCustomerSchema: z.ZodObject<{
141
+ first_name: z.ZodString;
142
+ last_name: z.ZodString;
143
+ company_name: z.ZodOptional<z.ZodString>;
144
+ email: z.ZodOptional<z.ZodString>;
145
+ phone: z.ZodOptional<z.ZodString>;
146
+ }, z.core.$strict>;
147
+ export declare const CreateDraftOrderInputSchema: z.ZodObject<{
148
+ customer_id: z.ZodOptional<z.ZodString>;
149
+ new_customer: z.ZodOptional<z.ZodObject<{
150
+ first_name: z.ZodString;
151
+ last_name: z.ZodString;
152
+ company_name: z.ZodOptional<z.ZodString>;
153
+ email: z.ZodOptional<z.ZodString>;
154
+ phone: z.ZodOptional<z.ZodString>;
155
+ }, z.core.$strict>>;
156
+ shipping_address: z.ZodObject<{
157
+ first_name: z.ZodString;
158
+ last_name: z.ZodString;
159
+ company: z.ZodOptional<z.ZodString>;
160
+ address_1: z.ZodString;
161
+ address_2: z.ZodOptional<z.ZodString>;
162
+ postal_code: z.ZodString;
163
+ city: z.ZodString;
164
+ country_code: z.ZodString;
165
+ phone: z.ZodOptional<z.ZodString>;
166
+ }, z.core.$strict>;
167
+ billing_address: z.ZodOptional<z.ZodObject<{
168
+ first_name: z.ZodString;
169
+ last_name: z.ZodString;
170
+ company: z.ZodOptional<z.ZodString>;
171
+ address_1: z.ZodString;
172
+ address_2: z.ZodOptional<z.ZodString>;
173
+ postal_code: z.ZodString;
174
+ city: z.ZodString;
175
+ country_code: z.ZodString;
176
+ phone: z.ZodOptional<z.ZodString>;
177
+ }, z.core.$strict>>;
178
+ items: z.ZodArray<z.ZodObject<{
179
+ variant_id: z.ZodString;
180
+ quantity: z.ZodNumber;
181
+ }, z.core.$strict>>;
182
+ shipping_option_id: z.ZodString;
183
+ source: z.ZodEnum<{
184
+ fax: "fax";
185
+ telefon: "telefon";
186
+ }>;
187
+ note: z.ZodOptional<z.ZodString>;
188
+ }, z.core.$strict>;
189
+ export declare const OrderAssistantDraftItemSchema: z.ZodObject<{
190
+ title: z.ZodString;
191
+ sku: z.ZodNullable<z.ZodString>;
192
+ quantity: z.ZodNumber;
193
+ unit_price: z.ZodNumber;
194
+ total: z.ZodNumber;
195
+ }, z.core.$strip>;
196
+ export declare const CreateDraftOrderOutputSchema: z.ZodObject<{
197
+ draft_order_id: z.ZodString;
198
+ display_id: z.ZodNullable<z.ZodNumber>;
199
+ customer_id: z.ZodString;
200
+ customer_created: z.ZodBoolean;
201
+ currency_code: z.ZodString;
202
+ items: z.ZodArray<z.ZodObject<{
203
+ title: z.ZodString;
204
+ sku: z.ZodNullable<z.ZodString>;
205
+ quantity: z.ZodNumber;
206
+ unit_price: z.ZodNumber;
207
+ total: z.ZodNumber;
208
+ }, z.core.$strip>>;
209
+ shipping_total: z.ZodNumber;
210
+ tax_total: z.ZodNumber;
211
+ total: z.ZodNumber;
212
+ admin_path: z.ZodString;
213
+ }, z.core.$strip>;
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateDraftOrderOutputSchema = exports.OrderAssistantDraftItemSchema = exports.CreateDraftOrderInputSchema = exports.OrderAssistantNewCustomerSchema = exports.ListShippingOptionsOutputSchema = exports.OrderAssistantShippingOptionSchema = exports.ListShippingOptionsInputSchema = exports.SearchProductsOutputSchema = exports.OrderAssistantVariantSchema = exports.SearchProductsInputSchema = exports.SearchCustomersOutputSchema = exports.OrderAssistantCustomerSchema = exports.OrderAssistantCustomerAddressSchema = exports.SearchCustomersInputSchema = exports.OrderAssistantAddressSchema = exports.ORDER_ASSISTANT_LIMITS = exports.ORDER_ASSISTANT_METADATA = exports.OrderAssistantSourceSchema = exports.ORDER_ASSISTANT_TOOLS = exports.ORDER_ASSISTANT_PLUGIN_KEY = void 0;
4
+ const zod_1 = require("@medusajs/framework/zod");
5
+ const primitives_1 = require("../shared/primitives");
6
+ /** Plugin key and container key of the order assistant in the base. */
7
+ exports.ORDER_ASSISTANT_PLUGIN_KEY = "order_assistant";
8
+ /** Tool names as the MCP client sees them. */
9
+ exports.ORDER_ASSISTANT_TOOLS = {
10
+ searchCustomers: "kunden_suchen",
11
+ searchProducts: "produkte_suchen",
12
+ listShippingOptions: "versandarten_auflisten",
13
+ createDraftOrder: "bestellentwurf_anlegen",
14
+ };
15
+ /** How the order reached the shop; stored in the order metadata. */
16
+ exports.OrderAssistantSourceSchema = zod_1.z.enum(["fax", "telefon"]);
17
+ /** Order metadata keys the assistant writes. */
18
+ exports.ORDER_ASSISTANT_METADATA = {
19
+ source: "order_source",
20
+ note: "order_note",
21
+ };
22
+ exports.ORDER_ASSISTANT_LIMITS = {
23
+ customers: 10,
24
+ variants: 20,
25
+ items: 50,
26
+ noteLength: 2000,
27
+ };
28
+ const CountryCodeSchema = zod_1.z
29
+ .string()
30
+ .trim()
31
+ .toLowerCase()
32
+ .regex(/^[a-z]{2}$/)
33
+ .describe("Land als ISO-3166-1-alpha-2-Code, z. B. at oder de.");
34
+ const OptionalTextSchema = zod_1.z.string().trim().min(1).max(255).optional();
35
+ exports.OrderAssistantAddressSchema = zod_1.z
36
+ .object({
37
+ first_name: primitives_1.NonEmptyStringSchema.max(255),
38
+ last_name: primitives_1.NonEmptyStringSchema.max(255),
39
+ company: OptionalTextSchema.describe("Firma oder Praxis, falls angegeben."),
40
+ address_1: primitives_1.NonEmptyStringSchema.max(255).describe("Straße und Hausnummer."),
41
+ address_2: OptionalTextSchema.describe("Adresszusatz."),
42
+ postal_code: primitives_1.NonEmptyStringSchema.max(20),
43
+ city: primitives_1.NonEmptyStringSchema.max(255),
44
+ country_code: CountryCodeSchema,
45
+ phone: OptionalTextSchema,
46
+ })
47
+ .strict();
48
+ exports.SearchCustomersInputSchema = zod_1.z
49
+ .object({
50
+ query: OptionalTextSchema.describe("Name, Firma, Telefonnummer oder E-Mail-Adresse (auch Teile davon)."),
51
+ postal_code: OptionalTextSchema.describe("PLZ einer Adresse der Person."),
52
+ city: OptionalTextSchema.describe("Ort einer Adresse der Person."),
53
+ })
54
+ .strict()
55
+ .refine((value) => Boolean(value.query ?? value.postal_code ?? value.city), { message: "Mindestens ein Suchfeld ist nötig." });
56
+ exports.OrderAssistantCustomerAddressSchema = zod_1.z.object({
57
+ first_name: zod_1.z.string().nullable(),
58
+ last_name: zod_1.z.string().nullable(),
59
+ company: zod_1.z.string().nullable(),
60
+ address_1: zod_1.z.string().nullable(),
61
+ address_2: zod_1.z.string().nullable(),
62
+ postal_code: zod_1.z.string().nullable(),
63
+ city: zod_1.z.string().nullable(),
64
+ country_code: zod_1.z.string().nullable(),
65
+ phone: zod_1.z.string().nullable(),
66
+ });
67
+ exports.OrderAssistantCustomerSchema = zod_1.z.object({
68
+ id: zod_1.z.string(),
69
+ first_name: zod_1.z.string().nullable(),
70
+ last_name: zod_1.z.string().nullable(),
71
+ company_name: zod_1.z.string().nullable(),
72
+ email: zod_1.z.string().nullable(),
73
+ phone: zod_1.z.string().nullable(),
74
+ /** Registered shop account (true) or a customer record without login. */
75
+ has_account: zod_1.z.boolean(),
76
+ addresses: zod_1.z.array(exports.OrderAssistantCustomerAddressSchema),
77
+ });
78
+ exports.SearchCustomersOutputSchema = zod_1.z.object({
79
+ customers: zod_1.z.array(exports.OrderAssistantCustomerSchema),
80
+ });
81
+ exports.SearchProductsInputSchema = zod_1.z
82
+ .object({
83
+ query: primitives_1.NonEmptyStringSchema.max(255).describe("Produktname oder Artikelnummer (auch Teile davon)."),
84
+ country_code: CountryCodeSchema.describe("Lieferland als ISO-Code; bestimmt Preis und Währung."),
85
+ })
86
+ .strict();
87
+ exports.OrderAssistantVariantSchema = zod_1.z.object({
88
+ variant_id: zod_1.z.string(),
89
+ product_title: zod_1.z.string(),
90
+ variant_title: zod_1.z.string().nullable(),
91
+ sku: zod_1.z.string().nullable(),
92
+ /** Price per unit in major currency units (33.5 = 33,50); null without a price. */
93
+ unit_price: zod_1.z.number().nullable(),
94
+ currency_code: zod_1.z.string(),
95
+ /** Available quantity; null when the variant's stock is not managed. */
96
+ available_quantity: zod_1.z.number().nullable(),
97
+ /** False when the variant cannot be ordered (no price or no stock). */
98
+ orderable: zod_1.z.boolean(),
99
+ });
100
+ exports.SearchProductsOutputSchema = zod_1.z.object({
101
+ variants: zod_1.z.array(exports.OrderAssistantVariantSchema),
102
+ });
103
+ exports.ListShippingOptionsInputSchema = zod_1.z
104
+ .object({
105
+ country_code: CountryCodeSchema.describe("Lieferland als ISO-Code."),
106
+ })
107
+ .strict();
108
+ exports.OrderAssistantShippingOptionSchema = zod_1.z.object({
109
+ id: zod_1.z.string(),
110
+ name: zod_1.z.string(),
111
+ /** Flat price in major currency units; null when none is set for the currency. */
112
+ amount: zod_1.z.number().nullable(),
113
+ currency_code: zod_1.z.string(),
114
+ });
115
+ exports.ListShippingOptionsOutputSchema = zod_1.z.object({
116
+ shipping_options: zod_1.z.array(exports.OrderAssistantShippingOptionSchema),
117
+ });
118
+ exports.OrderAssistantNewCustomerSchema = zod_1.z
119
+ .object({
120
+ first_name: primitives_1.NonEmptyStringSchema.max(255),
121
+ last_name: primitives_1.NonEmptyStringSchema.max(255),
122
+ company_name: OptionalTextSchema,
123
+ email: zod_1.z
124
+ .string()
125
+ .trim()
126
+ .toLowerCase()
127
+ .email()
128
+ .max(255)
129
+ .optional()
130
+ .describe("Nur angeben, wenn eine E-Mail-Adresse bekannt ist."),
131
+ phone: OptionalTextSchema,
132
+ })
133
+ .strict();
134
+ exports.CreateDraftOrderInputSchema = zod_1.z
135
+ .object({
136
+ customer_id: zod_1.z
137
+ .string()
138
+ .trim()
139
+ .min(1)
140
+ .optional()
141
+ .describe("ID einer bestehenden Kund:in aus kunden_suchen."),
142
+ new_customer: exports.OrderAssistantNewCustomerSchema.optional().describe("Neue Kund:in ohne Konto; nur wenn kunden_suchen niemanden findet."),
143
+ shipping_address: exports.OrderAssistantAddressSchema,
144
+ billing_address: exports.OrderAssistantAddressSchema.optional().describe("Rechnungsadresse; ohne Angabe gilt die Lieferadresse."),
145
+ items: zod_1.z
146
+ .array(zod_1.z
147
+ .object({
148
+ variant_id: primitives_1.NonEmptyStringSchema.describe("ID der Variante aus produkte_suchen."),
149
+ quantity: zod_1.z.number().int().positive().max(9999),
150
+ })
151
+ .strict())
152
+ .min(1)
153
+ .max(exports.ORDER_ASSISTANT_LIMITS.items),
154
+ shipping_option_id: primitives_1.NonEmptyStringSchema.describe("ID der Versandart aus versandarten_auflisten."),
155
+ source: exports.OrderAssistantSourceSchema.describe("Wie die Bestellung eingegangen ist."),
156
+ note: zod_1.z
157
+ .string()
158
+ .trim()
159
+ .min(1)
160
+ .max(exports.ORDER_ASSISTANT_LIMITS.noteLength)
161
+ .optional()
162
+ .describe("Interne Notiz, z. B. Unklarheiten auf dem Fax."),
163
+ })
164
+ .strict()
165
+ .refine((value) => Boolean(value.customer_id) !== Boolean(value.new_customer), { message: "Genau eines von customer_id und new_customer ist nötig." });
166
+ exports.OrderAssistantDraftItemSchema = zod_1.z.object({
167
+ title: zod_1.z.string(),
168
+ sku: zod_1.z.string().nullable(),
169
+ quantity: zod_1.z.number(),
170
+ unit_price: zod_1.z.number(),
171
+ total: zod_1.z.number(),
172
+ });
173
+ exports.CreateDraftOrderOutputSchema = zod_1.z.object({
174
+ draft_order_id: zod_1.z.string(),
175
+ display_id: zod_1.z.number().nullable(),
176
+ customer_id: zod_1.z.string(),
177
+ /** True when the assistant created the customer record for this draft. */
178
+ customer_created: zod_1.z.boolean(),
179
+ currency_code: zod_1.z.string(),
180
+ items: zod_1.z.array(exports.OrderAssistantDraftItemSchema),
181
+ shipping_total: zod_1.z.number(),
182
+ tax_total: zod_1.z.number(),
183
+ total: zod_1.z.number(),
184
+ /** Path of the draft in the Admin, relative to the backend URL. */
185
+ admin_path: zod_1.z.string(),
186
+ });
@@ -0,0 +1,15 @@
1
+ import type { z } from "@medusajs/framework/zod";
2
+ import type { CreateDraftOrderInputSchema, CreateDraftOrderOutputSchema, ListShippingOptionsInputSchema, ListShippingOptionsOutputSchema, OrderAssistantAddressSchema, OrderAssistantCustomerSchema, OrderAssistantShippingOptionSchema, OrderAssistantSourceSchema, OrderAssistantVariantSchema, SearchCustomersInputSchema, SearchCustomersOutputSchema, SearchProductsInputSchema, SearchProductsOutputSchema } from "./schemas";
3
+ export type OrderAssistantSource = z.infer<typeof OrderAssistantSourceSchema>;
4
+ export type OrderAssistantAddress = z.infer<typeof OrderAssistantAddressSchema>;
5
+ export type OrderAssistantCustomer = z.infer<typeof OrderAssistantCustomerSchema>;
6
+ export type OrderAssistantVariant = z.infer<typeof OrderAssistantVariantSchema>;
7
+ export type OrderAssistantShippingOption = z.infer<typeof OrderAssistantShippingOptionSchema>;
8
+ export type SearchCustomersInput = z.infer<typeof SearchCustomersInputSchema>;
9
+ export type SearchCustomersOutput = z.infer<typeof SearchCustomersOutputSchema>;
10
+ export type SearchProductsInput = z.infer<typeof SearchProductsInputSchema>;
11
+ export type SearchProductsOutput = z.infer<typeof SearchProductsOutputSchema>;
12
+ export type ListShippingOptionsInput = z.infer<typeof ListShippingOptionsInputSchema>;
13
+ export type ListShippingOptionsOutput = z.infer<typeof ListShippingOptionsOutputSchema>;
14
+ export type CreateDraftOrderInput = z.infer<typeof CreateDraftOrderInputSchema>;
15
+ export type CreateDraftOrderOutput = z.infer<typeof CreateDraftOrderOutputSchema>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hartl-services/medusa-contracts",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -51,6 +51,11 @@
51
51
  "import": "./dist/esm/documents/admin-types.mjs",
52
52
  "require": "./dist/documents/admin-types.js"
53
53
  },
54
+ "./types/order-assistant": {
55
+ "types": "./dist/order-assistant/types.d.ts",
56
+ "import": "./dist/esm/order-assistant/types.mjs",
57
+ "require": "./dist/order-assistant/types.js"
58
+ },
54
59
  "./types/files": {
55
60
  "types": "./dist/files/types.d.ts",
56
61
  "import": "./dist/esm/files/types.mjs",
@@ -106,6 +111,11 @@
106
111
  "import": "./dist/esm/documents/schemas.mjs",
107
112
  "require": "./dist/documents/schemas.js"
108
113
  },
114
+ "./schemas/order-assistant": {
115
+ "types": "./dist/order-assistant/schemas.d.ts",
116
+ "import": "./dist/esm/order-assistant/schemas.mjs",
117
+ "require": "./dist/order-assistant/schemas.js"
118
+ },
109
119
  "./schemas/files": {
110
120
  "types": "./dist/files/schemas.d.ts",
111
121
  "import": "./dist/esm/files/schemas.mjs",
@@ -161,6 +171,11 @@
161
171
  "import": "./dist/esm/documents/paths.mjs",
162
172
  "require": "./dist/documents/paths.js"
163
173
  },
174
+ "./paths/order-assistant": {
175
+ "types": "./dist/order-assistant/paths.d.ts",
176
+ "import": "./dist/esm/order-assistant/paths.mjs",
177
+ "require": "./dist/order-assistant/paths.js"
178
+ },
164
179
  "./paths/files": {
165
180
  "types": "./dist/files/paths.d.ts",
166
181
  "import": "./dist/esm/files/paths.mjs",