@modainteract/moda-interact-shared 0.7.3 → 0.8.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/billing.d.ts +7 -6
- package/dist/billing.js +1 -1
- package/dist/{chunk-WVVP7IUY.js → chunk-RFTEH4ER.js} +5 -4
- package/dist/chunk-RFTEH4ER.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/internationalization.d.ts +2 -2
- package/dist/shopify/index.d.ts +12 -12
- package/package.json +1 -1
- package/dist/chunk-WVVP7IUY.js.map +0 -1
package/dist/billing.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
declare const ARCH007_BILLING_CONTRACT_SCHEMA_VERSION: 1;
|
|
4
|
-
declare const WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION:
|
|
4
|
+
declare const WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION: 2;
|
|
5
5
|
declare const BILLING_PLAN_KINDS: readonly ["FREE", "PAID_METERED"];
|
|
6
6
|
declare const BillingPlanKindSchema: z.ZodEnum<{
|
|
7
7
|
FREE: "FREE";
|
|
8
8
|
PAID_METERED: "PAID_METERED";
|
|
9
9
|
}>;
|
|
10
10
|
type BillingPlanKind = z.infer<typeof BillingPlanKindSchema>;
|
|
11
|
-
declare const BILLING_USAGE_METRICS: readonly ["RECOVERY_CONVERSATION", "OUTBOUND_AUTOMATED_MESSAGE", "DELIVERED_WHATSAPP_MESSAGE"];
|
|
11
|
+
declare const BILLING_USAGE_METRICS: readonly ["RECOVERY_CONVERSATION", "OUTBOUND_AUTOMATED_MESSAGE", "DELIVERED_WHATSAPP_MESSAGE", "RECOVERY_CREDIT_PACK_PURCHASE"];
|
|
12
12
|
declare const BillingUsageMetricSchema: z.ZodEnum<{
|
|
13
13
|
RECOVERY_CONVERSATION: "RECOVERY_CONVERSATION";
|
|
14
14
|
OUTBOUND_AUTOMATED_MESSAGE: "OUTBOUND_AUTOMATED_MESSAGE";
|
|
15
15
|
DELIVERED_WHATSAPP_MESSAGE: "DELIVERED_WHATSAPP_MESSAGE";
|
|
16
|
+
RECOVERY_CREDIT_PACK_PURCHASE: "RECOVERY_CREDIT_PACK_PURCHASE";
|
|
16
17
|
}>;
|
|
17
18
|
type BillingUsageMetric = z.infer<typeof BillingUsageMetricSchema>;
|
|
18
19
|
declare const BILLING_SYSTEM_MESSAGE_CODES: {
|
|
@@ -47,9 +48,9 @@ declare const WhatsAppProviderPricingMetadataSchema: z.ZodObject<{
|
|
|
47
48
|
}, z.core.$strict>;
|
|
48
49
|
type WhatsAppProviderPricingMetadata = z.infer<typeof WhatsAppProviderPricingMetadataSchema>;
|
|
49
50
|
declare const NormalizedWhatsAppStatusSchema: z.ZodObject<{
|
|
50
|
-
schemaVersion: z.ZodLiteral<
|
|
51
|
-
shopId: z.ZodString;
|
|
51
|
+
schemaVersion: z.ZodLiteral<2>;
|
|
52
52
|
providerAccountId: z.ZodString;
|
|
53
|
+
providerPhoneNumberId: z.ZodString;
|
|
53
54
|
providerMessageId: z.ZodString;
|
|
54
55
|
status: z.ZodEnum<{
|
|
55
56
|
SENT: "SENT";
|
|
@@ -67,9 +68,9 @@ declare const NormalizedWhatsAppStatusSchema: z.ZodObject<{
|
|
|
67
68
|
type NormalizedWhatsAppStatus = z.infer<typeof NormalizedWhatsAppStatusSchema>;
|
|
68
69
|
declare function parseNormalizedWhatsAppStatus(input: unknown): NormalizedWhatsAppStatus;
|
|
69
70
|
declare function safeParseNormalizedWhatsAppStatus(input: unknown): z.ZodSafeParseResult<{
|
|
70
|
-
schemaVersion:
|
|
71
|
-
shopId: string;
|
|
71
|
+
schemaVersion: 2;
|
|
72
72
|
providerAccountId: string;
|
|
73
|
+
providerPhoneNumberId: string;
|
|
73
74
|
providerMessageId: string;
|
|
74
75
|
status: "SENT" | "DELIVERED" | "READ" | "FAILED";
|
|
75
76
|
occurredAt: string;
|
package/dist/billing.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
createShopifyUsageIdempotencyKey,
|
|
17
17
|
parseNormalizedWhatsAppStatus,
|
|
18
18
|
safeParseNormalizedWhatsAppStatus
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RFTEH4ER.js";
|
|
20
20
|
export {
|
|
21
21
|
ARCH007_BILLING_CONTRACT_SCHEMA_VERSION,
|
|
22
22
|
BILLING_PLAN_KINDS,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// src/billing.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
var ARCH007_BILLING_CONTRACT_SCHEMA_VERSION = 1;
|
|
4
|
-
var WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION =
|
|
4
|
+
var WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION = 2;
|
|
5
5
|
var BILLING_PLAN_KINDS = ["FREE", "PAID_METERED"];
|
|
6
6
|
var BillingPlanKindSchema = z.enum(BILLING_PLAN_KINDS);
|
|
7
7
|
var BILLING_USAGE_METRICS = [
|
|
8
8
|
"RECOVERY_CONVERSATION",
|
|
9
9
|
"OUTBOUND_AUTOMATED_MESSAGE",
|
|
10
|
-
"DELIVERED_WHATSAPP_MESSAGE"
|
|
10
|
+
"DELIVERED_WHATSAPP_MESSAGE",
|
|
11
|
+
"RECOVERY_CREDIT_PACK_PURCHASE"
|
|
11
12
|
];
|
|
12
13
|
var BillingUsageMetricSchema = z.enum(BILLING_USAGE_METRICS);
|
|
13
14
|
var BILLING_SYSTEM_MESSAGE_CODES = {
|
|
@@ -43,8 +44,8 @@ var WhatsAppProviderPricingMetadataSchema = z.object({
|
|
|
43
44
|
}).strict().refine((value) => Object.keys(value).length > 0, "pricing metadata must not be empty");
|
|
44
45
|
var NormalizedWhatsAppStatusSchema = z.object({
|
|
45
46
|
schemaVersion: z.literal(WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION),
|
|
46
|
-
shopId: z.string().trim().min(1).max(MAX_ID_LENGTH),
|
|
47
47
|
providerAccountId: z.string().trim().min(1).max(MAX_ID_LENGTH),
|
|
48
|
+
providerPhoneNumberId: z.string().trim().min(1).max(MAX_ID_LENGTH),
|
|
48
49
|
providerMessageId: z.string().trim().min(1).max(MAX_ID_LENGTH),
|
|
49
50
|
status: WhatsAppProviderStatusSchema,
|
|
50
51
|
occurredAt: z.iso.datetime({ offset: true }),
|
|
@@ -114,4 +115,4 @@ export {
|
|
|
114
115
|
createRecoveryIdempotencyKey,
|
|
115
116
|
createShopifyUsageIdempotencyKey
|
|
116
117
|
};
|
|
117
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-RFTEH4ER.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/billing.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const ARCH007_BILLING_CONTRACT_SCHEMA_VERSION = 1 as const;\nexport const WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION = 2 as const;\n\nexport const BILLING_PLAN_KINDS = [\"FREE\", \"PAID_METERED\"] as const;\nexport const BillingPlanKindSchema = z.enum(BILLING_PLAN_KINDS);\nexport type BillingPlanKind = z.infer<typeof BillingPlanKindSchema>;\n\nexport const BILLING_USAGE_METRICS = [\n \"RECOVERY_CONVERSATION\",\n \"OUTBOUND_AUTOMATED_MESSAGE\",\n \"DELIVERED_WHATSAPP_MESSAGE\",\n \"RECOVERY_CREDIT_PACK_PURCHASE\",\n] as const;\nexport const BillingUsageMetricSchema = z.enum(BILLING_USAGE_METRICS);\nexport type BillingUsageMetric = z.infer<typeof BillingUsageMetricSchema>;\n\nexport const BILLING_SYSTEM_MESSAGE_CODES = {\n FREE_ALLOWANCE_WARNING: \"BILLING_FREE_ALLOWANCE_WARNING\",\n FREE_ALLOWANCE_EXHAUSTED: \"BILLING_FREE_ALLOWANCE_EXHAUSTED\",\n PLAN_UPGRADED: \"BILLING_PLAN_UPGRADED\",\n PLAN_DOWNGRADE_SCHEDULED: \"BILLING_PLAN_DOWNGRADE_SCHEDULED\",\n SUBSCRIPTION_ENDED: \"BILLING_SUBSCRIPTION_ENDED\",\n SAFETY_LIMIT_REACHED: \"BILLING_SAFETY_LIMIT_REACHED\",\n} as const;\n\nconst BILLING_SYSTEM_MESSAGE_CODE_VALUES = [\n BILLING_SYSTEM_MESSAGE_CODES.FREE_ALLOWANCE_WARNING,\n BILLING_SYSTEM_MESSAGE_CODES.FREE_ALLOWANCE_EXHAUSTED,\n BILLING_SYSTEM_MESSAGE_CODES.PLAN_UPGRADED,\n BILLING_SYSTEM_MESSAGE_CODES.PLAN_DOWNGRADE_SCHEDULED,\n BILLING_SYSTEM_MESSAGE_CODES.SUBSCRIPTION_ENDED,\n BILLING_SYSTEM_MESSAGE_CODES.SAFETY_LIMIT_REACHED,\n] as const;\n\nexport const BillingSystemMessageCodeSchema = z.enum(BILLING_SYSTEM_MESSAGE_CODE_VALUES);\nexport type BillingSystemMessageCode = z.infer<typeof BillingSystemMessageCodeSchema>;\n\nexport const WHATSAPP_PROVIDER_STATUSES = [\n \"SENT\",\n \"DELIVERED\",\n \"READ\",\n \"FAILED\",\n] as const;\nexport const WhatsAppProviderStatusSchema = z.enum(WHATSAPP_PROVIDER_STATUSES);\nexport type WhatsAppProviderStatus = z.infer<typeof WhatsAppProviderStatusSchema>;\n\nconst MAX_ID_LENGTH = 128;\nconst MAX_SHORT_TEXT_LENGTH = 128;\n\nexport const WhatsAppProviderPricingMetadataSchema = z\n .object({\n billable: z.boolean().optional(),\n category: z.string().trim().min(1).max(MAX_SHORT_TEXT_LENGTH).optional(),\n model: z.string().trim().min(1).max(MAX_SHORT_TEXT_LENGTH).optional(),\n })\n .strict()\n .refine((value) => Object.keys(value).length > 0, \"pricing metadata must not be empty\");\n\nexport type WhatsAppProviderPricingMetadata = z.infer<\n typeof WhatsAppProviderPricingMetadataSchema\n>;\n\nexport const NormalizedWhatsAppStatusSchema = z\n .object({\n schemaVersion: z.literal(WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION),\n providerAccountId: z.string().trim().min(1).max(MAX_ID_LENGTH),\n providerPhoneNumberId: z.string().trim().min(1).max(MAX_ID_LENGTH),\n providerMessageId: z.string().trim().min(1).max(MAX_ID_LENGTH),\n status: WhatsAppProviderStatusSchema,\n occurredAt: z.iso.datetime({ offset: true }),\n pricing: WhatsAppProviderPricingMetadataSchema.optional(),\n })\n .strict();\n\nexport type NormalizedWhatsAppStatus = z.infer<typeof NormalizedWhatsAppStatusSchema>;\n\nexport function parseNormalizedWhatsAppStatus(input: unknown): NormalizedWhatsAppStatus {\n return NormalizedWhatsAppStatusSchema.parse(input);\n}\n\nexport function safeParseNormalizedWhatsAppStatus(input: unknown) {\n return NormalizedWhatsAppStatusSchema.safeParse(input);\n}\n\nfunction assertKeyPart(name: string, value: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new Error(`${name} must be a non-empty string`);\n }\n}\n\nfunction fnv1a64(value: string): string {\n let hash = 0xcbf29ce484222325n;\n for (const character of value) {\n hash ^= BigInt(character.codePointAt(0) ?? 0);\n hash = BigInt.asUintN(64, hash * 0x100000001b3n);\n }\n return hash.toString(16).padStart(16, \"0\");\n}\n\nfunction boundedKey(prefix: string, parts: string[], maxLength: number): string {\n const canonical = parts.map((part) => part.trim()).join(\":\");\n const readable = `${prefix}:${canonical}`;\n if (readable.length <= maxLength) return readable;\n return `${prefix}:h${fnv1a64(canonical)}`;\n}\n\nexport function createMerchantBillingSystemSourceKey(\n shopId: string,\n code: BillingSystemMessageCode,\n eventIdentity: string,\n version = 1,\n): string {\n assertKeyPart(\"shopId\", shopId);\n assertKeyPart(\"code\", code);\n assertKeyPart(\"eventIdentity\", eventIdentity);\n if (!Number.isInteger(version) || version < 1) {\n throw new Error(\"version must be a positive integer\");\n }\n return boundedKey(\"billing-system\", [shopId, code, eventIdentity, String(version)], 255);\n}\n\nexport function createRecoveryIdempotencyKey(shopId: string, recoveryId: string): string {\n assertKeyPart(\"shopId\", shopId);\n assertKeyPart(\"recoveryId\", recoveryId);\n return boundedKey(\"recovery\", [shopId, recoveryId], 255);\n}\n\nexport function createShopifyUsageIdempotencyKey(\n shopId: string,\n usageEventId: string,\n): string {\n assertKeyPart(\"shopId\", shopId);\n assertKeyPart(\"usageEventId\", usageEventId);\n return boundedKey(\"shopify\", [shopId, usageEventId], 64);\n}"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,0CAA0C;AAChD,IAAM,0CAA0C;AAEhD,IAAM,qBAAqB,CAAC,QAAQ,cAAc;AAClD,IAAM,wBAAwB,EAAE,KAAK,kBAAkB;AAGvD,IAAM,wBAAwB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACO,IAAM,2BAA2B,EAAE,KAAK,qBAAqB;AAG7D,IAAM,+BAA+B;AAAA,EAC1C,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,EAC1B,eAAe;AAAA,EACf,0BAA0B;AAAA,EAC1B,oBAAoB;AAAA,EACpB,sBAAsB;AACxB;AAEA,IAAM,qCAAqC;AAAA,EACzC,6BAA6B;AAAA,EAC7B,6BAA6B;AAAA,EAC7B,6BAA6B;AAAA,EAC7B,6BAA6B;AAAA,EAC7B,6BAA6B;AAAA,EAC7B,6BAA6B;AAC/B;AAEO,IAAM,iCAAiC,EAAE,KAAK,kCAAkC;AAGhF,IAAM,6BAA6B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACO,IAAM,+BAA+B,EAAE,KAAK,0BAA0B;AAG7E,IAAM,gBAAgB;AACtB,IAAM,wBAAwB;AAEvB,IAAM,wCAAwC,EAClD,OAAO;AAAA,EACN,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,qBAAqB,EAAE,SAAS;AAAA,EACvE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC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WAAW,GAAG,MAAM,IAAI,SAAS;AACvC,MAAI,SAAS,UAAU,UAAW,QAAO;AACzC,SAAO,GAAG,MAAM,KAAK,QAAQ,SAAS,CAAC;AACzC;AAEO,SAAS,qCACd,QACA,MACA,eACA,UAAU,GACF;AACR,gBAAc,UAAU,MAAM;AAC9B,gBAAc,QAAQ,IAAI;AAC1B,gBAAc,iBAAiB,aAAa;AAC5C,MAAI,CAAC,OAAO,UAAU,OAAO,KAAK,UAAU,GAAG;AAC7C,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AACA,SAAO,WAAW,kBAAkB,CAAC,QAAQ,MAAM,eAAe,OAAO,OAAO,CAAC,GAAG,GAAG;AACzF;AAEO,SAAS,6BAA6B,QAAgB,YAA4B;AACvF,gBAAc,UAAU,MAAM;AAC9B,gBAAc,cAAc,UAAU;AACtC,SAAO,WAAW,YAAY,CAAC,QAAQ,UAAU,GAAG,GAAG;AACzD;AAEO,SAAS,iCACd,QACA,cACQ;AACR,gBAAc,UAAU,MAAM;AAC9B,gBAAc,gBAAgB,YAAY;AAC1C,SAAO,WAAW,WAAW,CAAC,QAAQ,YAAY,GAAG,EAAE;AACzD;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
createShopifyUsageIdempotencyKey,
|
|
17
17
|
parseNormalizedWhatsAppStatus,
|
|
18
18
|
safeParseNormalizedWhatsAppStatus
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RFTEH4ER.js";
|
|
20
20
|
import {
|
|
21
21
|
AuthoredSupportBodySchema,
|
|
22
22
|
MERCHANT_COMMUNICATIONS_JOB_NAMES,
|
|
@@ -2,9 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import { PrimitiveType } from 'intl-messageformat';
|
|
3
3
|
|
|
4
4
|
declare const LanguageSourceSchema: z.ZodEnum<{
|
|
5
|
-
shopify: "shopify";
|
|
6
5
|
"customer-explicit": "customer-explicit";
|
|
7
6
|
detected: "detected";
|
|
7
|
+
shopify: "shopify";
|
|
8
8
|
"merchant-default": "merchant-default";
|
|
9
9
|
"platform-default": "platform-default";
|
|
10
10
|
}>;
|
|
@@ -20,9 +20,9 @@ declare const TimeZoneIdSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, st
|
|
|
20
20
|
declare const InternationalContextSchema: z.ZodObject<{
|
|
21
21
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
22
22
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
23
|
-
shopify: "shopify";
|
|
24
23
|
"customer-explicit": "customer-explicit";
|
|
25
24
|
detected: "detected";
|
|
25
|
+
shopify: "shopify";
|
|
26
26
|
"merchant-default": "merchant-default";
|
|
27
27
|
"platform-default": "platform-default";
|
|
28
28
|
}>>;
|
package/dist/shopify/index.d.ts
CHANGED
|
@@ -384,9 +384,9 @@ declare const ShopifyCheckoutCreatedEventV2Schema: z.ZodObject<{
|
|
|
384
384
|
internationalContext: z.ZodOptional<z.ZodObject<{
|
|
385
385
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
386
386
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
387
|
-
shopify: "shopify";
|
|
388
387
|
"customer-explicit": "customer-explicit";
|
|
389
388
|
detected: "detected";
|
|
389
|
+
shopify: "shopify";
|
|
390
390
|
"merchant-default": "merchant-default";
|
|
391
391
|
"platform-default": "platform-default";
|
|
392
392
|
}>>;
|
|
@@ -421,9 +421,9 @@ declare const ShopifyCartActivityEventV2Schema: z.ZodObject<{
|
|
|
421
421
|
internationalContext: z.ZodOptional<z.ZodObject<{
|
|
422
422
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
423
423
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
424
|
-
shopify: "shopify";
|
|
425
424
|
"customer-explicit": "customer-explicit";
|
|
426
425
|
detected: "detected";
|
|
426
|
+
shopify: "shopify";
|
|
427
427
|
"merchant-default": "merchant-default";
|
|
428
428
|
"platform-default": "platform-default";
|
|
429
429
|
}>>;
|
|
@@ -456,9 +456,9 @@ declare const ShopifyCheckoutUpdatedEventV2Schema: z.ZodObject<{
|
|
|
456
456
|
internationalContext: z.ZodOptional<z.ZodObject<{
|
|
457
457
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
458
458
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
459
|
-
shopify: "shopify";
|
|
460
459
|
"customer-explicit": "customer-explicit";
|
|
461
460
|
detected: "detected";
|
|
461
|
+
shopify: "shopify";
|
|
462
462
|
"merchant-default": "merchant-default";
|
|
463
463
|
"platform-default": "platform-default";
|
|
464
464
|
}>>;
|
|
@@ -490,9 +490,9 @@ declare const ShopifyOrderCompletedEventV2Schema: z.ZodObject<{
|
|
|
490
490
|
internationalContext: z.ZodOptional<z.ZodObject<{
|
|
491
491
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
492
492
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
493
|
-
shopify: "shopify";
|
|
494
493
|
"customer-explicit": "customer-explicit";
|
|
495
494
|
detected: "detected";
|
|
495
|
+
shopify: "shopify";
|
|
496
496
|
"merchant-default": "merchant-default";
|
|
497
497
|
"platform-default": "platform-default";
|
|
498
498
|
}>>;
|
|
@@ -527,9 +527,9 @@ declare const ShopifyRecoveryEventV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
527
527
|
internationalContext: z.ZodOptional<z.ZodObject<{
|
|
528
528
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
529
529
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
530
|
-
shopify: "shopify";
|
|
531
530
|
"customer-explicit": "customer-explicit";
|
|
532
531
|
detected: "detected";
|
|
532
|
+
shopify: "shopify";
|
|
533
533
|
"merchant-default": "merchant-default";
|
|
534
534
|
"platform-default": "platform-default";
|
|
535
535
|
}>>;
|
|
@@ -560,9 +560,9 @@ declare const ShopifyRecoveryEventV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
560
560
|
internationalContext: z.ZodOptional<z.ZodObject<{
|
|
561
561
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
562
562
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
563
|
-
shopify: "shopify";
|
|
564
563
|
"customer-explicit": "customer-explicit";
|
|
565
564
|
detected: "detected";
|
|
565
|
+
shopify: "shopify";
|
|
566
566
|
"merchant-default": "merchant-default";
|
|
567
567
|
"platform-default": "platform-default";
|
|
568
568
|
}>>;
|
|
@@ -595,9 +595,9 @@ declare const ShopifyRecoveryEventV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
595
595
|
internationalContext: z.ZodOptional<z.ZodObject<{
|
|
596
596
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
597
597
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
598
|
-
shopify: "shopify";
|
|
599
598
|
"customer-explicit": "customer-explicit";
|
|
600
599
|
detected: "detected";
|
|
600
|
+
shopify: "shopify";
|
|
601
601
|
"merchant-default": "merchant-default";
|
|
602
602
|
"platform-default": "platform-default";
|
|
603
603
|
}>>;
|
|
@@ -627,9 +627,9 @@ declare const ShopifyRecoveryEventV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
627
627
|
internationalContext: z.ZodOptional<z.ZodObject<{
|
|
628
628
|
languageTag: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
629
629
|
languageSource: z.ZodNullable<z.ZodEnum<{
|
|
630
|
-
shopify: "shopify";
|
|
631
630
|
"customer-explicit": "customer-explicit";
|
|
632
631
|
detected: "detected";
|
|
632
|
+
shopify: "shopify";
|
|
633
633
|
"merchant-default": "merchant-default";
|
|
634
634
|
"platform-default": "platform-default";
|
|
635
635
|
}>>;
|
|
@@ -672,7 +672,7 @@ declare function safeParseShopifyRecoveryEventV2(input: unknown): z.ZodSafeParse
|
|
|
672
672
|
};
|
|
673
673
|
internationalContext?: {
|
|
674
674
|
languageTag: string | null;
|
|
675
|
-
languageSource: "
|
|
675
|
+
languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
|
|
676
676
|
countryCode: string | null;
|
|
677
677
|
currencyCode: string | null;
|
|
678
678
|
timeZone: string | null;
|
|
@@ -699,7 +699,7 @@ declare function safeParseShopifyRecoveryEventV2(input: unknown): z.ZodSafeParse
|
|
|
699
699
|
};
|
|
700
700
|
internationalContext?: {
|
|
701
701
|
languageTag: string | null;
|
|
702
|
-
languageSource: "
|
|
702
|
+
languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
|
|
703
703
|
countryCode: string | null;
|
|
704
704
|
currencyCode: string | null;
|
|
705
705
|
timeZone: string | null;
|
|
@@ -725,7 +725,7 @@ declare function safeParseShopifyRecoveryEventV2(input: unknown): z.ZodSafeParse
|
|
|
725
725
|
};
|
|
726
726
|
internationalContext?: {
|
|
727
727
|
languageTag: string | null;
|
|
728
|
-
languageSource: "
|
|
728
|
+
languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
|
|
729
729
|
countryCode: string | null;
|
|
730
730
|
currencyCode: string | null;
|
|
731
731
|
timeZone: string | null;
|
|
@@ -754,7 +754,7 @@ declare function safeParseShopifyRecoveryEventV2(input: unknown): z.ZodSafeParse
|
|
|
754
754
|
};
|
|
755
755
|
internationalContext?: {
|
|
756
756
|
languageTag: string | null;
|
|
757
|
-
languageSource: "
|
|
757
|
+
languageSource: "customer-explicit" | "detected" | "shopify" | "merchant-default" | "platform-default" | null;
|
|
758
758
|
countryCode: string | null;
|
|
759
759
|
currencyCode: string | null;
|
|
760
760
|
timeZone: string | null;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/billing.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const ARCH007_BILLING_CONTRACT_SCHEMA_VERSION = 1 as const;\nexport const WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION = 1 as const;\n\nexport const BILLING_PLAN_KINDS = [\"FREE\", \"PAID_METERED\"] as const;\nexport const BillingPlanKindSchema = z.enum(BILLING_PLAN_KINDS);\nexport type BillingPlanKind = z.infer<typeof BillingPlanKindSchema>;\n\nexport const BILLING_USAGE_METRICS = [\n \"RECOVERY_CONVERSATION\",\n \"OUTBOUND_AUTOMATED_MESSAGE\",\n \"DELIVERED_WHATSAPP_MESSAGE\",\n] as const;\nexport const BillingUsageMetricSchema = z.enum(BILLING_USAGE_METRICS);\nexport type BillingUsageMetric = z.infer<typeof BillingUsageMetricSchema>;\n\nexport const BILLING_SYSTEM_MESSAGE_CODES = {\n FREE_ALLOWANCE_WARNING: \"BILLING_FREE_ALLOWANCE_WARNING\",\n FREE_ALLOWANCE_EXHAUSTED: \"BILLING_FREE_ALLOWANCE_EXHAUSTED\",\n PLAN_UPGRADED: \"BILLING_PLAN_UPGRADED\",\n PLAN_DOWNGRADE_SCHEDULED: \"BILLING_PLAN_DOWNGRADE_SCHEDULED\",\n SUBSCRIPTION_ENDED: \"BILLING_SUBSCRIPTION_ENDED\",\n SAFETY_LIMIT_REACHED: \"BILLING_SAFETY_LIMIT_REACHED\",\n} as const;\n\nconst BILLING_SYSTEM_MESSAGE_CODE_VALUES = [\n BILLING_SYSTEM_MESSAGE_CODES.FREE_ALLOWANCE_WARNING,\n BILLING_SYSTEM_MESSAGE_CODES.FREE_ALLOWANCE_EXHAUSTED,\n BILLING_SYSTEM_MESSAGE_CODES.PLAN_UPGRADED,\n BILLING_SYSTEM_MESSAGE_CODES.PLAN_DOWNGRADE_SCHEDULED,\n BILLING_SYSTEM_MESSAGE_CODES.SUBSCRIPTION_ENDED,\n BILLING_SYSTEM_MESSAGE_CODES.SAFETY_LIMIT_REACHED,\n] as const;\n\nexport const BillingSystemMessageCodeSchema = z.enum(BILLING_SYSTEM_MESSAGE_CODE_VALUES);\nexport type BillingSystemMessageCode = z.infer<typeof BillingSystemMessageCodeSchema>;\n\nexport const WHATSAPP_PROVIDER_STATUSES = [\n \"SENT\",\n \"DELIVERED\",\n \"READ\",\n \"FAILED\",\n] as const;\nexport const WhatsAppProviderStatusSchema = z.enum(WHATSAPP_PROVIDER_STATUSES);\nexport type WhatsAppProviderStatus = z.infer<typeof WhatsAppProviderStatusSchema>;\n\nconst MAX_ID_LENGTH = 128;\nconst MAX_SHORT_TEXT_LENGTH = 128;\n\nexport const WhatsAppProviderPricingMetadataSchema = z\n .object({\n billable: z.boolean().optional(),\n category: z.string().trim().min(1).max(MAX_SHORT_TEXT_LENGTH).optional(),\n model: z.string().trim().min(1).max(MAX_SHORT_TEXT_LENGTH).optional(),\n })\n .strict()\n .refine((value) => Object.keys(value).length > 0, \"pricing metadata must not be empty\");\n\nexport type WhatsAppProviderPricingMetadata = z.infer<\n typeof WhatsAppProviderPricingMetadataSchema\n>;\n\nexport const NormalizedWhatsAppStatusSchema = z\n .object({\n schemaVersion: z.literal(WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION),\n shopId: z.string().trim().min(1).max(MAX_ID_LENGTH),\n providerAccountId: z.string().trim().min(1).max(MAX_ID_LENGTH),\n providerMessageId: z.string().trim().min(1).max(MAX_ID_LENGTH),\n status: WhatsAppProviderStatusSchema,\n occurredAt: z.iso.datetime({ offset: true }),\n pricing: WhatsAppProviderPricingMetadataSchema.optional(),\n })\n .strict();\n\nexport type NormalizedWhatsAppStatus = z.infer<typeof NormalizedWhatsAppStatusSchema>;\n\nexport function parseNormalizedWhatsAppStatus(input: unknown): NormalizedWhatsAppStatus {\n return NormalizedWhatsAppStatusSchema.parse(input);\n}\n\nexport function safeParseNormalizedWhatsAppStatus(input: unknown) {\n return NormalizedWhatsAppStatusSchema.safeParse(input);\n}\n\nfunction assertKeyPart(name: string, value: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new Error(`${name} must be a non-empty string`);\n }\n}\n\nfunction fnv1a64(value: string): string {\n let hash = 0xcbf29ce484222325n;\n for (const character of value) {\n hash ^= BigInt(character.codePointAt(0) ?? 0);\n hash = BigInt.asUintN(64, hash * 0x100000001b3n);\n }\n return hash.toString(16).padStart(16, \"0\");\n}\n\nfunction boundedKey(prefix: string, parts: string[], maxLength: number): string {\n const canonical = parts.map((part) => part.trim()).join(\":\");\n const readable = `${prefix}:${canonical}`;\n if (readable.length <= maxLength) return readable;\n return `${prefix}:h${fnv1a64(canonical)}`;\n}\n\nexport function createMerchantBillingSystemSourceKey(\n shopId: string,\n code: BillingSystemMessageCode,\n eventIdentity: string,\n version = 1,\n): string {\n assertKeyPart(\"shopId\", shopId);\n assertKeyPart(\"code\", code);\n assertKeyPart(\"eventIdentity\", eventIdentity);\n if (!Number.isInteger(version) || version < 1) {\n throw new Error(\"version must be a positive integer\");\n }\n return boundedKey(\"billing-system\", [shopId, code, eventIdentity, String(version)], 255);\n}\n\nexport function createRecoveryIdempotencyKey(shopId: string, recoveryId: string): string {\n assertKeyPart(\"shopId\", shopId);\n assertKeyPart(\"recoveryId\", recoveryId);\n return boundedKey(\"recovery\", [shopId, recoveryId], 255);\n}\n\nexport function createShopifyUsageIdempotencyKey(\n shopId: string,\n usageEventId: string,\n): string {\n assertKeyPart(\"shopId\", shopId);\n assertKeyPart(\"usageEventId\", usageEventId);\n return boundedKey(\"shopify\", [shopId, usageEventId], 64);\n}"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,0CAA0C;AAChD,IAAM,0CAA0C;AAEhD,IAAM,qBAAqB,CAAC,QAAQ,cAAc;AAClD,IAAM,wBAAwB,EAAE,KAAK,kBAAkB;AAGvD,IAAM,wBAAwB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAC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