@modainteract/moda-interact-shared 5.2.0 → 5.4.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.
@@ -36,6 +36,68 @@ declare function matchesSubset(schema: SubsetSchema, value: unknown): boolean;
36
36
  declare function compileSubset(schema: SubsetSchema, mode: "input" | "details"): z.ZodCustom<Record<string, Json>, Record<string, Json>>;
37
37
 
38
38
  declare const ToolNameSchema: z.ZodString;
39
+ declare const CommerceExecutionPurposeSchema: z.ZodLiteral<"INITIAL_RECOVERY_OUTREACH">;
40
+ declare const CommercePurposeProfileSchema: z.ZodPipe<z.ZodObject<{
41
+ purpose: z.ZodLiteral<"INITIAL_RECOVERY_OUTREACH">;
42
+ featureId: z.ZodString;
43
+ releaseId: z.ZodString;
44
+ behaviourPrompt: z.ZodString;
45
+ capabilities: z.ZodArray<z.ZodObject<{
46
+ capabilityId: z.ZodString;
47
+ toolId: z.ZodString;
48
+ revisionId: z.ZodString;
49
+ name: z.ZodString;
50
+ position: z.ZodNumber;
51
+ inputSchema: z.ZodCustom<SubsetSchema, SubsetSchema>;
52
+ outputSchema: z.ZodCustom<SubsetSchema, SubsetSchema>;
53
+ }, z.core.$strict>>;
54
+ }, z.core.$strict>, z.ZodTransform<{
55
+ purpose: "INITIAL_RECOVERY_OUTREACH";
56
+ featureId: string;
57
+ releaseId: string;
58
+ behaviourPrompt: string;
59
+ capabilities: {
60
+ capabilityId: string;
61
+ toolId: string;
62
+ revisionId: string;
63
+ name: string;
64
+ position: number;
65
+ inputSchema: SubsetSchema;
66
+ outputSchema: SubsetSchema;
67
+ }[];
68
+ }, {
69
+ purpose: "INITIAL_RECOVERY_OUTREACH";
70
+ featureId: string;
71
+ releaseId: string;
72
+ behaviourPrompt: string;
73
+ capabilities: {
74
+ capabilityId: string;
75
+ toolId: string;
76
+ revisionId: string;
77
+ name: string;
78
+ position: number;
79
+ inputSchema: SubsetSchema;
80
+ outputSchema: SubsetSchema;
81
+ }[];
82
+ }>>;
83
+ /** New outreach callers must resolve a present validated snapshot; legacy conversation parsing remains optional. */
84
+ declare function requireCommercePurposeProfile(raw: unknown): {
85
+ purpose: "INITIAL_RECOVERY_OUTREACH";
86
+ featureId: string;
87
+ releaseId: string;
88
+ behaviourPrompt: string;
89
+ capabilities: {
90
+ capabilityId: string;
91
+ toolId: string;
92
+ revisionId: string;
93
+ name: string;
94
+ position: number;
95
+ inputSchema: SubsetSchema;
96
+ outputSchema: SubsetSchema;
97
+ }[];
98
+ };
99
+ type CommerceExecutionPurpose = z.infer<typeof CommerceExecutionPurposeSchema>;
100
+ type CommercePurposeProfile = z.infer<typeof CommercePurposeProfileSchema>;
39
101
  declare const PublishedGrantedToolSchema: z.ZodObject<{
40
102
  toolId: z.ZodString;
41
103
  toolRevisionId: z.ZodString;
@@ -687,6 +749,49 @@ declare const CommerceConversationGrantSchema: z.ZodObject<{
687
749
  initialInboundVersion: z.ZodNumber;
688
750
  releaseId: z.ZodString;
689
751
  selectedCapabilityKeys: z.ZodArray<z.ZodString>;
752
+ purposeProfile: z.ZodOptional<z.ZodPipe<z.ZodObject<{
753
+ purpose: z.ZodLiteral<"INITIAL_RECOVERY_OUTREACH">;
754
+ featureId: z.ZodString;
755
+ releaseId: z.ZodString;
756
+ behaviourPrompt: z.ZodString;
757
+ capabilities: z.ZodArray<z.ZodObject<{
758
+ capabilityId: z.ZodString;
759
+ toolId: z.ZodString;
760
+ revisionId: z.ZodString;
761
+ name: z.ZodString;
762
+ position: z.ZodNumber;
763
+ inputSchema: z.ZodCustom<SubsetSchema, SubsetSchema>;
764
+ outputSchema: z.ZodCustom<SubsetSchema, SubsetSchema>;
765
+ }, z.core.$strict>>;
766
+ }, z.core.$strict>, z.ZodTransform<{
767
+ purpose: "INITIAL_RECOVERY_OUTREACH";
768
+ featureId: string;
769
+ releaseId: string;
770
+ behaviourPrompt: string;
771
+ capabilities: {
772
+ capabilityId: string;
773
+ toolId: string;
774
+ revisionId: string;
775
+ name: string;
776
+ position: number;
777
+ inputSchema: SubsetSchema;
778
+ outputSchema: SubsetSchema;
779
+ }[];
780
+ }, {
781
+ purpose: "INITIAL_RECOVERY_OUTREACH";
782
+ featureId: string;
783
+ releaseId: string;
784
+ behaviourPrompt: string;
785
+ capabilities: {
786
+ capabilityId: string;
787
+ toolId: string;
788
+ revisionId: string;
789
+ name: string;
790
+ position: number;
791
+ inputSchema: SubsetSchema;
792
+ outputSchema: SubsetSchema;
793
+ }[];
794
+ }>>>;
690
795
  grantedTools: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
691
796
  toolId: z.ZodString;
692
797
  toolRevisionId: z.ZodString;
@@ -747,6 +852,49 @@ declare const CommerceManifestSchema: z.ZodObject<{
747
852
  description: z.ZodString;
748
853
  inputSchema: z.ZodCustom<SubsetSchema, SubsetSchema>;
749
854
  }, z.core.$strict>>>;
855
+ purposeProfile: z.ZodOptional<z.ZodPipe<z.ZodObject<{
856
+ purpose: z.ZodLiteral<"INITIAL_RECOVERY_OUTREACH">;
857
+ featureId: z.ZodString;
858
+ releaseId: z.ZodString;
859
+ behaviourPrompt: z.ZodString;
860
+ capabilities: z.ZodArray<z.ZodObject<{
861
+ capabilityId: z.ZodString;
862
+ toolId: z.ZodString;
863
+ revisionId: z.ZodString;
864
+ name: z.ZodString;
865
+ position: z.ZodNumber;
866
+ inputSchema: z.ZodCustom<SubsetSchema, SubsetSchema>;
867
+ outputSchema: z.ZodCustom<SubsetSchema, SubsetSchema>;
868
+ }, z.core.$strict>>;
869
+ }, z.core.$strict>, z.ZodTransform<{
870
+ purpose: "INITIAL_RECOVERY_OUTREACH";
871
+ featureId: string;
872
+ releaseId: string;
873
+ behaviourPrompt: string;
874
+ capabilities: {
875
+ capabilityId: string;
876
+ toolId: string;
877
+ revisionId: string;
878
+ name: string;
879
+ position: number;
880
+ inputSchema: SubsetSchema;
881
+ outputSchema: SubsetSchema;
882
+ }[];
883
+ }, {
884
+ purpose: "INITIAL_RECOVERY_OUTREACH";
885
+ featureId: string;
886
+ releaseId: string;
887
+ behaviourPrompt: string;
888
+ capabilities: {
889
+ capabilityId: string;
890
+ toolId: string;
891
+ revisionId: string;
892
+ name: string;
893
+ position: number;
894
+ inputSchema: SubsetSchema;
895
+ outputSchema: SubsetSchema;
896
+ }[];
897
+ }>>>;
750
898
  grantedTools: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
751
899
  toolId: z.ZodString;
752
900
  toolRevisionId: z.ZodString;
@@ -2039,4 +2187,4 @@ declare function verifyResponseContract(definition: unknown, hash: string, diges
2039
2187
  /** JSON Schema branches retain the immutable envelope; only ANSWER details vary. */
2040
2188
  declare function finalResponseToolSchema(definition: CommerceResponseContract): Json;
2041
2189
 
2042
- export { type CommerceResponseDisposition as $, CommerceDiscountDetailsSchema as A, CommerceErrorCodeSchema as B, type CommerceTurnIdentity as C, type Digest as D, type CommerceEvidence as E, CommerceEvidenceSchema as F, type GrantedTool as G, CommerceExecuteAssertionSchema as H, CommerceExecutionSchema as I, CommerceFinalResponseSchema as J, CommerceManifestSchema as K, CommerceOfferSchema as L, type CommerceOptionalLookupUnavailable as M, CommerceOptionalLookupUnavailableSchema as N, type CommerceProductRecommendationSelection as O, type PublishedToolDescriptor as P, CommerceProductRecommendationSelectionSchema as Q, type CommerceProductSaleEvidence as R, type SubsetSchema as S, type ToolDescriptor as T, CommerceProductSaleEvidenceSchema as U, CommerceProductSchema as V, CommerceProposalSchema as W, CommerceReleaseIdentitySchema as X, CommerceResolveAssertionSchema as Y, type CommerceResponseContract as Z, CommerceResponseContractSchema as _, type CommerceConversationGrant as a, CommerceResponseDispositionSchema as a0, type CommerceShippingInformation as a1, type CommerceShippingInformationInput as a2, CommerceShippingInformationInputSchema as a3, CommerceShippingInformationSchema as a4, CommerceToolDefinitionSchema as a5, type CommerceToolDraftDefinition as a6, CommerceToolDraftDefinitionSchema as a7, CommerceToolIdentitySchema as a8, CommerceToolInputs as a9, finalResponseSchema as aA, finalResponseToolSchema as aB, isBuiltInTool as aC, jsonBytes as aD, mapToolArguments as aE, matchesSubset as aF, productBelongsToDomain as aG, responseContractCanonicalJson as aH, safeName as aI, safePath as aJ, toolHashInput as aK, validateDefinitionForPublication as aL, validateDefinitionVersion as aM, validateSubset as aN, verifyResponseContract as aO, CommerceToolOutputs as aa, CommerceToolResultSchema as ab, CommerceToolRevisionIdentitySchema as ac, CommerceTurnIdentitySchema as ad, DetailsSchemaSchema as ae, EMPTY_RESPONSE_CONTRACT as af, type ExternalHttpExecution as ag, ExternalHttpExecutionSchema as ah, GrantedToolSchema as ai, GrantedToolsSchema as aj, InputSchemaSchema as ak, type Json as al, MONEY_PATTERN as am, POLICY_OPERATIONS as an, POLICY_OPERATION_DESCRIPTORS as ao, type PublishedGrantedTool as ap, PublishedGrantedToolSchema as aq, PublishedToolDescriptorSchema as ar, ReferralReasonSchema as as, ResponseTemplateSchema as at, ToolDescriptorSchema as au, ToolNameSchema as av, canonicalJson as aw, commerceToolResultSchema as ax, compileSubset as ay, definitionToMcpDescriptor as az, type CommerceManifest as b, type CommerceToolResult as c, type CommerceFinalResponse as d, type CommerceBuiltInToolDescriptor as e, type CommerceToolDefinition as f, type CommerceBuiltInToolGrant as g, CommerceAlternativeSchema as h, type CommerceAnswerPresentationSelection as i, CommerceAnswerPresentationSelectionSchema as j, CommerceAssertionSchema as k, CommerceBasketSchema as l, CommerceBuiltInToolDescriptorSchema as m, CommerceBuiltInToolGrantSchema as n, CommerceBuiltInToolNameSchema as o, type CommerceCategoryCandidate as p, CommerceCategoryCandidateSchema as q, type CommerceCategoryResolution as r, CommerceCategoryResolutionSchema as s, CommerceConversationGrantSchema as t, type CommerceDefinitionCompiler as u, type CommerceDiscountCombinationFacts as v, CommerceDiscountCombinationFactsSchema as w, type CommerceDiscountConditionFacts as x, CommerceDiscountConditionFactsSchema as y, type CommerceDiscountDetails as z };
2190
+ export { CommerceReleaseIdentitySchema as $, type CommerceDiscountDetails as A, CommerceDiscountDetailsSchema as B, type CommerceExecutionPurpose as C, type Digest as D, CommerceErrorCodeSchema as E, type CommerceEvidence as F, type GrantedTool as G, CommerceEvidenceSchema as H, CommerceExecuteAssertionSchema as I, CommerceExecutionPurposeSchema as J, CommerceExecutionSchema as K, CommerceFinalResponseSchema as L, CommerceManifestSchema as M, CommerceOfferSchema as N, type CommerceOptionalLookupUnavailable as O, type PublishedToolDescriptor as P, CommerceOptionalLookupUnavailableSchema as Q, type CommerceProductRecommendationSelection as R, type SubsetSchema as S, type ToolDescriptor as T, CommerceProductRecommendationSelectionSchema as U, type CommerceProductSaleEvidence as V, CommerceProductSaleEvidenceSchema as W, CommerceProductSchema as X, CommerceProposalSchema as Y, type CommercePurposeProfile as Z, CommercePurposeProfileSchema as _, type CommerceTurnIdentity as a, CommerceResolveAssertionSchema as a0, type CommerceResponseContract as a1, CommerceResponseContractSchema as a2, type CommerceResponseDisposition as a3, CommerceResponseDispositionSchema as a4, type CommerceShippingInformation as a5, type CommerceShippingInformationInput as a6, CommerceShippingInformationInputSchema as a7, CommerceShippingInformationSchema as a8, CommerceToolDefinitionSchema as a9, canonicalJson as aA, commerceToolResultSchema as aB, compileSubset as aC, definitionToMcpDescriptor as aD, finalResponseSchema as aE, finalResponseToolSchema as aF, isBuiltInTool as aG, jsonBytes as aH, mapToolArguments as aI, matchesSubset as aJ, productBelongsToDomain as aK, requireCommercePurposeProfile as aL, responseContractCanonicalJson as aM, safeName as aN, safePath as aO, toolHashInput as aP, validateDefinitionForPublication as aQ, validateDefinitionVersion as aR, validateSubset as aS, verifyResponseContract as aT, type CommerceToolDraftDefinition as aa, CommerceToolDraftDefinitionSchema as ab, CommerceToolIdentitySchema as ac, CommerceToolInputs as ad, CommerceToolOutputs as ae, CommerceToolResultSchema as af, CommerceToolRevisionIdentitySchema as ag, CommerceTurnIdentitySchema as ah, DetailsSchemaSchema as ai, EMPTY_RESPONSE_CONTRACT as aj, type ExternalHttpExecution as ak, ExternalHttpExecutionSchema as al, GrantedToolSchema as am, GrantedToolsSchema as an, InputSchemaSchema as ao, type Json as ap, MONEY_PATTERN as aq, POLICY_OPERATIONS as ar, POLICY_OPERATION_DESCRIPTORS as as, type PublishedGrantedTool as at, PublishedGrantedToolSchema as au, PublishedToolDescriptorSchema as av, ReferralReasonSchema as aw, ResponseTemplateSchema as ax, ToolDescriptorSchema as ay, ToolNameSchema as az, type CommerceConversationGrant as b, type CommerceManifest as c, type CommerceToolResult as d, type CommerceFinalResponse as e, type CommerceBuiltInToolDescriptor as f, type CommerceToolDefinition as g, type CommerceBuiltInToolGrant as h, CommerceAlternativeSchema as i, type CommerceAnswerPresentationSelection as j, CommerceAnswerPresentationSelectionSchema as k, CommerceAssertionSchema as l, CommerceBasketSchema as m, CommerceBuiltInToolDescriptorSchema as n, CommerceBuiltInToolGrantSchema as o, CommerceBuiltInToolNameSchema as p, type CommerceCategoryCandidate as q, CommerceCategoryCandidateSchema as r, type CommerceCategoryResolution as s, CommerceCategoryResolutionSchema as t, CommerceConversationGrantSchema as u, type CommerceDefinitionCompiler as v, type CommerceDiscountCombinationFacts as w, CommerceDiscountCombinationFactsSchema as x, type CommerceDiscountConditionFacts as y, CommerceDiscountConditionFactsSchema as z };
@@ -389,9 +389,9 @@ declare const ShopifyCheckoutCreatedEventV2Schema: z.ZodObject<{
389
389
  internationalContext: z.ZodOptional<z.ZodObject<{
390
390
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
391
391
  languageSource: z.ZodNullable<z.ZodEnum<{
392
- shopify: "shopify";
393
392
  "customer-explicit": "customer-explicit";
394
393
  detected: "detected";
394
+ shopify: "shopify";
395
395
  "merchant-default": "merchant-default";
396
396
  "platform-default": "platform-default";
397
397
  }>>;
@@ -426,9 +426,9 @@ declare const ShopifyCartActivityEventV2Schema: z.ZodObject<{
426
426
  internationalContext: z.ZodOptional<z.ZodObject<{
427
427
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
428
428
  languageSource: z.ZodNullable<z.ZodEnum<{
429
- shopify: "shopify";
430
429
  "customer-explicit": "customer-explicit";
431
430
  detected: "detected";
431
+ shopify: "shopify";
432
432
  "merchant-default": "merchant-default";
433
433
  "platform-default": "platform-default";
434
434
  }>>;
@@ -461,9 +461,9 @@ declare const ShopifyCheckoutUpdatedEventV2Schema: z.ZodObject<{
461
461
  internationalContext: z.ZodOptional<z.ZodObject<{
462
462
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
463
463
  languageSource: z.ZodNullable<z.ZodEnum<{
464
- shopify: "shopify";
465
464
  "customer-explicit": "customer-explicit";
466
465
  detected: "detected";
466
+ shopify: "shopify";
467
467
  "merchant-default": "merchant-default";
468
468
  "platform-default": "platform-default";
469
469
  }>>;
@@ -495,9 +495,9 @@ declare const ShopifyOrderCompletedEventV2Schema: z.ZodObject<{
495
495
  internationalContext: z.ZodOptional<z.ZodObject<{
496
496
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
497
497
  languageSource: z.ZodNullable<z.ZodEnum<{
498
- shopify: "shopify";
499
498
  "customer-explicit": "customer-explicit";
500
499
  detected: "detected";
500
+ shopify: "shopify";
501
501
  "merchant-default": "merchant-default";
502
502
  "platform-default": "platform-default";
503
503
  }>>;
@@ -532,9 +532,9 @@ declare const ShopifyRecoveryEventV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject
532
532
  internationalContext: z.ZodOptional<z.ZodObject<{
533
533
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
534
534
  languageSource: z.ZodNullable<z.ZodEnum<{
535
- shopify: "shopify";
536
535
  "customer-explicit": "customer-explicit";
537
536
  detected: "detected";
537
+ shopify: "shopify";
538
538
  "merchant-default": "merchant-default";
539
539
  "platform-default": "platform-default";
540
540
  }>>;
@@ -565,9 +565,9 @@ declare const ShopifyRecoveryEventV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject
565
565
  internationalContext: z.ZodOptional<z.ZodObject<{
566
566
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
567
567
  languageSource: z.ZodNullable<z.ZodEnum<{
568
- shopify: "shopify";
569
568
  "customer-explicit": "customer-explicit";
570
569
  detected: "detected";
570
+ shopify: "shopify";
571
571
  "merchant-default": "merchant-default";
572
572
  "platform-default": "platform-default";
573
573
  }>>;
@@ -600,9 +600,9 @@ declare const ShopifyRecoveryEventV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject
600
600
  internationalContext: z.ZodOptional<z.ZodObject<{
601
601
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
602
602
  languageSource: z.ZodNullable<z.ZodEnum<{
603
- shopify: "shopify";
604
603
  "customer-explicit": "customer-explicit";
605
604
  detected: "detected";
605
+ shopify: "shopify";
606
606
  "merchant-default": "merchant-default";
607
607
  "platform-default": "platform-default";
608
608
  }>>;
@@ -632,9 +632,9 @@ declare const ShopifyRecoveryEventV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject
632
632
  internationalContext: z.ZodOptional<z.ZodObject<{
633
633
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
634
634
  languageSource: z.ZodNullable<z.ZodEnum<{
635
- shopify: "shopify";
636
635
  "customer-explicit": "customer-explicit";
637
636
  detected: "detected";
637
+ shopify: "shopify";
638
638
  "merchant-default": "merchant-default";
639
639
  "platform-default": "platform-default";
640
640
  }>>;
@@ -677,7 +677,7 @@ declare function safeParseShopifyRecoveryEventV2(input: unknown): z.ZodSafeParse
677
677
  };
678
678
  internationalContext?: {
679
679
  languageTag: string | null;
680
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
680
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
681
681
  countryCode: string | null;
682
682
  currencyCode: string | null;
683
683
  timeZone: string | null;
@@ -704,7 +704,7 @@ declare function safeParseShopifyRecoveryEventV2(input: unknown): z.ZodSafeParse
704
704
  };
705
705
  internationalContext?: {
706
706
  languageTag: string | null;
707
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
707
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
708
708
  countryCode: string | null;
709
709
  currencyCode: string | null;
710
710
  timeZone: string | null;
@@ -730,7 +730,7 @@ declare function safeParseShopifyRecoveryEventV2(input: unknown): z.ZodSafeParse
730
730
  };
731
731
  internationalContext?: {
732
732
  languageTag: string | null;
733
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
733
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
734
734
  countryCode: string | null;
735
735
  currencyCode: string | null;
736
736
  timeZone: string | null;
@@ -759,7 +759,7 @@ declare function safeParseShopifyRecoveryEventV2(input: unknown): z.ZodSafeParse
759
759
  };
760
760
  internationalContext?: {
761
761
  languageTag: string | null;
762
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
762
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
763
763
  countryCode: string | null;
764
764
  currencyCode: string | null;
765
765
  timeZone: string | null;
@@ -803,9 +803,9 @@ declare const ShopifyCheckoutUpdatedEventV3Schema: z.ZodObject<{
803
803
  internationalContext: z.ZodOptional<z.ZodObject<{
804
804
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
805
805
  languageSource: z.ZodNullable<z.ZodEnum<{
806
- shopify: "shopify";
807
806
  "customer-explicit": "customer-explicit";
808
807
  detected: "detected";
808
+ shopify: "shopify";
809
809
  "merchant-default": "merchant-default";
810
810
  "platform-default": "platform-default";
811
811
  }>>;
@@ -841,9 +841,9 @@ declare const ShopifyRecoveryEventSchema: z.ZodUnion<readonly [z.ZodDiscriminate
841
841
  internationalContext: z.ZodOptional<z.ZodObject<{
842
842
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
843
843
  languageSource: z.ZodNullable<z.ZodEnum<{
844
- shopify: "shopify";
845
844
  "customer-explicit": "customer-explicit";
846
845
  detected: "detected";
846
+ shopify: "shopify";
847
847
  "merchant-default": "merchant-default";
848
848
  "platform-default": "platform-default";
849
849
  }>>;
@@ -874,9 +874,9 @@ declare const ShopifyRecoveryEventSchema: z.ZodUnion<readonly [z.ZodDiscriminate
874
874
  internationalContext: z.ZodOptional<z.ZodObject<{
875
875
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
876
876
  languageSource: z.ZodNullable<z.ZodEnum<{
877
- shopify: "shopify";
878
877
  "customer-explicit": "customer-explicit";
879
878
  detected: "detected";
879
+ shopify: "shopify";
880
880
  "merchant-default": "merchant-default";
881
881
  "platform-default": "platform-default";
882
882
  }>>;
@@ -909,9 +909,9 @@ declare const ShopifyRecoveryEventSchema: z.ZodUnion<readonly [z.ZodDiscriminate
909
909
  internationalContext: z.ZodOptional<z.ZodObject<{
910
910
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
911
911
  languageSource: z.ZodNullable<z.ZodEnum<{
912
- shopify: "shopify";
913
912
  "customer-explicit": "customer-explicit";
914
913
  detected: "detected";
914
+ shopify: "shopify";
915
915
  "merchant-default": "merchant-default";
916
916
  "platform-default": "platform-default";
917
917
  }>>;
@@ -941,9 +941,9 @@ declare const ShopifyRecoveryEventSchema: z.ZodUnion<readonly [z.ZodDiscriminate
941
941
  internationalContext: z.ZodOptional<z.ZodObject<{
942
942
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
943
943
  languageSource: z.ZodNullable<z.ZodEnum<{
944
- shopify: "shopify";
945
944
  "customer-explicit": "customer-explicit";
946
945
  detected: "detected";
946
+ shopify: "shopify";
947
947
  "merchant-default": "merchant-default";
948
948
  "platform-default": "platform-default";
949
949
  }>>;
@@ -976,9 +976,9 @@ declare const ShopifyRecoveryEventSchema: z.ZodUnion<readonly [z.ZodDiscriminate
976
976
  internationalContext: z.ZodOptional<z.ZodObject<{
977
977
  languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
978
978
  languageSource: z.ZodNullable<z.ZodEnum<{
979
- shopify: "shopify";
980
979
  "customer-explicit": "customer-explicit";
981
980
  detected: "detected";
981
+ shopify: "shopify";
982
982
  "merchant-default": "merchant-default";
983
983
  "platform-default": "platform-default";
984
984
  }>>;
@@ -1020,7 +1020,7 @@ declare function safeParseShopifyRecoveryEvent(input: unknown): z.ZodSafeParseRe
1020
1020
  };
1021
1021
  internationalContext?: {
1022
1022
  languageTag: string | null;
1023
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
1023
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
1024
1024
  countryCode: string | null;
1025
1025
  currencyCode: string | null;
1026
1026
  timeZone: string | null;
@@ -1047,7 +1047,7 @@ declare function safeParseShopifyRecoveryEvent(input: unknown): z.ZodSafeParseRe
1047
1047
  };
1048
1048
  internationalContext?: {
1049
1049
  languageTag: string | null;
1050
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
1050
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
1051
1051
  countryCode: string | null;
1052
1052
  currencyCode: string | null;
1053
1053
  timeZone: string | null;
@@ -1073,7 +1073,7 @@ declare function safeParseShopifyRecoveryEvent(input: unknown): z.ZodSafeParseRe
1073
1073
  };
1074
1074
  internationalContext?: {
1075
1075
  languageTag: string | null;
1076
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
1076
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
1077
1077
  countryCode: string | null;
1078
1078
  currencyCode: string | null;
1079
1079
  timeZone: string | null;
@@ -1102,7 +1102,7 @@ declare function safeParseShopifyRecoveryEvent(input: unknown): z.ZodSafeParseRe
1102
1102
  };
1103
1103
  internationalContext?: {
1104
1104
  languageTag: string | null;
1105
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
1105
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
1106
1106
  countryCode: string | null;
1107
1107
  currencyCode: string | null;
1108
1108
  timeZone: string | null;
@@ -1131,7 +1131,7 @@ declare function safeParseShopifyRecoveryEvent(input: unknown): z.ZodSafeParseRe
1131
1131
  };
1132
1132
  internationalContext?: {
1133
1133
  languageTag: string | null;
1134
- languageSource: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
1134
+ languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
1135
1135
  countryCode: string | null;
1136
1136
  currencyCode: string | null;
1137
1137
  timeZone: string | null;
@@ -3,6 +3,16 @@ import { C as CredentialKeyring } from '../keyring-BLXjNChq.js';
3
3
  import 'zod';
4
4
 
5
5
  type ShopifyOfflineTokenErrorCode = "SESSION_MISSING" | "SESSION_IDENTITY_CONFLICT" | "INVALID_SESSION" | "REFRESH_TOKEN_EXPIRED" | "OAUTH_CONFIG_UNAVAILABLE" | "LOCK_TIMEOUT" | "CANCELLED" | "DEADLINE" | "REFRESH_REJECTED" | "REFRESH_RESPONSE_INVALID" | "REFRESH_OUTCOME_UNKNOWN" | "PERSISTENCE_UNAVAILABLE";
6
+ /** Bounded refresh lifecycle metadata. Never includes provider credentials or errors. */
7
+ type ShopifyOfflineRefreshEvent = Readonly<{
8
+ event: "shopify.offline_refresh.started" | "shopify.offline_refresh.committed" | "shopify.offline_refresh.failed";
9
+ operationId: string;
10
+ shopId: string | null;
11
+ source: "SHARED" | "SDK";
12
+ durationMs: number;
13
+ outcome: "STARTED" | "COMMITTED" | "REJECTED" | "UNKNOWN" | "CANCELLED" | "UNAVAILABLE";
14
+ reasonCode: ShopifyOfflineTokenErrorCode | null;
15
+ }>;
6
16
  declare class ShopifyOfflineTokenError extends Error {
7
17
  readonly code: ShopifyOfflineTokenErrorCode;
8
18
  readonly retryable: boolean;
@@ -243,6 +253,7 @@ declare function createShopifyOfflineTokenProvider(input: Readonly<{
243
253
  }>>;
244
254
  fetch: typeof fetch;
245
255
  now?: () => number;
256
+ onEvent?: (event: ShopifyOfflineRefreshEvent) => void;
246
257
  }>): ShopifyOfflineTokenProvider;
247
258
 
248
259
  declare const CONFIGURATION_KEY: "shopify.oauth";
@@ -311,4 +322,4 @@ declare function createShopifyDiscountSyncJobId(event: {
311
322
  */
312
323
  declare function createShopifyWhatsAppConsentSyncJobId(input: ShopifyWhatsAppConsentSyncJobV1): string;
313
324
 
314
- export { type LockedSessionContext, type OfflineCredentialSnapshot, type SdkInstallationSessionContext, ShopifyOAuthConfigurationError, type ShopifyOAuthConfigurationErrorCode, type ShopifyOAuthConfigurationPrisma, type ShopifyOAuthConfigurationRow, type ShopifyOAuthCredentials, type ShopifyOfflineBigIntFilter, type ShopifyOfflineBooleanFilter, type ShopifyOfflineDatabase, type ShopifyOfflineDateFilter, type ShopifyOfflineNullableBooleanFilter, type ShopifyOfflineNullableStringFilter, type ShopifyOfflineSessionCreateData, type ShopifyOfflineSessionData, type ShopifyOfflineSessionDelegate, type ShopifyOfflineSessionRecord, type ShopifyOfflineSessionScalarWhere, type ShopifyOfflineSessionSelect, type ShopifyOfflineSessionUniqueWhere, type ShopifyOfflineSessionWhere, type ShopifyOfflineShopRecord, type ShopifyOfflineStringFilter, ShopifyOfflineTokenError, type ShopifyOfflineTokenErrorCode, type ShopifyOfflineTokenProvider, type ShopifyOfflineTransaction, createPendingRecoveryCandidateJobId, createShopifyCheckoutJobId, createShopifyDiscountSyncJobId, createShopifyOfflineTokenProvider, createShopifyOrderJobId, createShopifyWebhookJobId, createShopifyWhatsAppConsentSyncJobId, readShopifyOAuthConfiguration };
325
+ export { type LockedSessionContext, type OfflineCredentialSnapshot, type SdkInstallationSessionContext, ShopifyOAuthConfigurationError, type ShopifyOAuthConfigurationErrorCode, type ShopifyOAuthConfigurationPrisma, type ShopifyOAuthConfigurationRow, type ShopifyOAuthCredentials, type ShopifyOfflineBigIntFilter, type ShopifyOfflineBooleanFilter, type ShopifyOfflineDatabase, type ShopifyOfflineDateFilter, type ShopifyOfflineNullableBooleanFilter, type ShopifyOfflineNullableStringFilter, type ShopifyOfflineRefreshEvent, type ShopifyOfflineSessionCreateData, type ShopifyOfflineSessionData, type ShopifyOfflineSessionDelegate, type ShopifyOfflineSessionRecord, type ShopifyOfflineSessionScalarWhere, type ShopifyOfflineSessionSelect, type ShopifyOfflineSessionUniqueWhere, type ShopifyOfflineSessionWhere, type ShopifyOfflineShopRecord, type ShopifyOfflineStringFilter, ShopifyOfflineTokenError, type ShopifyOfflineTokenErrorCode, type ShopifyOfflineTokenProvider, type ShopifyOfflineTransaction, createPendingRecoveryCandidateJobId, createShopifyCheckoutJobId, createShopifyDiscountSyncJobId, createShopifyOfflineTokenProvider, createShopifyOrderJobId, createShopifyWebhookJobId, createShopifyWhatsAppConsentSyncJobId, readShopifyOAuthConfiguration };
@@ -13,6 +13,8 @@ import { createHash } from "crypto";
13
13
 
14
14
  // src/shopify/offline-token-provider.ts
15
15
  import { Buffer } from "buffer";
16
+ import { randomUUID } from "crypto";
17
+ import { performance } from "perf_hooks";
16
18
  var ERROR_MESSAGES = {
17
19
  SESSION_MISSING: "Shopify offline session is unavailable.",
18
20
  SESSION_IDENTITY_CONFLICT: "Shopify offline session identity is inconsistent.",
@@ -141,6 +143,12 @@ function snapshot(row, shopId, shop) {
141
143
  }
142
144
  function createShopifyOfflineTokenProvider(input) {
143
145
  const now = input.now ?? Date.now;
146
+ function notify(event) {
147
+ try {
148
+ void Promise.resolve(input.onEvent?.(Object.freeze(event))).catch(() => void 0);
149
+ } catch {
150
+ }
151
+ }
144
152
  async function resolveShop(shopId, deadline) {
145
153
  deadline.check();
146
154
  if (typeof shopId !== "string" || !shopId.trim()) fail("SESSION_MISSING");
@@ -201,12 +209,25 @@ function createShopifyOfflineTokenProvider(input) {
201
209
  }
202
210
  async function getSession(shopId, options) {
203
211
  const deadline = createDeadline(options?.signal);
212
+ let attempt;
213
+ const outcome = { remoteSucceeded: false };
214
+ function emit(event, result, reasonCode) {
215
+ if (!attempt) return;
216
+ notify({
217
+ event,
218
+ operationId: attempt.operationId,
219
+ shopId: attempt.shopId,
220
+ source: "SHARED",
221
+ durationMs: Math.min(6e4, Math.max(0, Math.round(performance.now() - attempt.startedAt))),
222
+ outcome: result,
223
+ reasonCode
224
+ });
225
+ }
204
226
  try {
205
227
  deadline.check();
206
228
  const shop = await resolveShop(shopId, deadline);
207
229
  deadline.check();
208
- const outcome = { remoteSucceeded: false };
209
- return await runLocked(shop, shopId, deadline, async (context) => {
230
+ const result = await runLocked(shop, shopId, deadline, async (context) => {
210
231
  let row = await context.transaction.session.findUnique({ where: { id: context.sessionId }, select: SESSION_SELECT });
211
232
  if (!row) fail("SESSION_IDENTITY_CONFLICT");
212
233
  const currentTime = now();
@@ -235,6 +256,8 @@ function createShopifyOfflineTokenProvider(input) {
235
256
  let response;
236
257
  try {
237
258
  const form = new URLSearchParams({ client_id: credentials.apiKey, client_secret: credentials.apiSecret, grant_type: "refresh_token", refresh_token: row.refreshToken });
259
+ attempt = { operationId: randomUUID(), shopId: context.shopId, startedAt: performance.now() };
260
+ emit("shopify.offline_refresh.started", "STARTED", null);
238
261
  response = await input.fetch(`https://${context.shop}/admin/oauth/access_token`, {
239
262
  method: "POST",
240
263
  redirect: "error",
@@ -294,9 +317,20 @@ function createShopifyOfflineTokenProvider(input) {
294
317
  outcome.remoteSucceeded = true;
295
318
  return snapshot(row, shopId, context.shop);
296
319
  }, outcome);
320
+ emit("shopify.offline_refresh.committed", "COMMITTED", null);
321
+ return result;
297
322
  } catch (error) {
298
- deadline.check();
299
- throw error;
323
+ let failure = error;
324
+ try {
325
+ deadline.check();
326
+ } catch (deadlineError) {
327
+ failure = deadlineError;
328
+ }
329
+ const code = failure instanceof ShopifyOfflineTokenError ? failure.code : "PERSISTENCE_UNAVAILABLE";
330
+ const ambiguous = outcome.remoteSucceeded && code !== "REFRESH_REJECTED" && code !== "CANCELLED";
331
+ const reason = ambiguous ? "REFRESH_OUTCOME_UNKNOWN" : code;
332
+ emit("shopify.offline_refresh.failed", reason === "REFRESH_REJECTED" ? "REJECTED" : reason === "CANCELLED" ? "CANCELLED" : reason === "REFRESH_OUTCOME_UNKNOWN" ? "UNKNOWN" : "UNAVAILABLE", reason);
333
+ throw failure;
300
334
  } finally {
301
335
  deadline.dispose();
302
336
  }