@modainteract/moda-interact-shared 0.7.1 → 0.7.3
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 +86 -0
- package/dist/billing.js +39 -0
- package/dist/billing.js.map +1 -0
- package/dist/chunk-WVVP7IUY.js +117 -0
- package/dist/chunk-WVVP7IUY.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +36 -0
- package/dist/internationalization.d.ts +2 -2
- package/dist/merchant-communications.d.ts +6 -6
- package/dist/shopify/index.d.ts +12 -12
- package/dist/testing/node.d.ts +127 -0
- package/dist/testing/node.js +296 -0
- package/dist/testing/node.js.map +1 -0
- package/package.json +11 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const ARCH007_BILLING_CONTRACT_SCHEMA_VERSION: 1;
|
|
4
|
+
declare const WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION: 1;
|
|
5
|
+
declare const BILLING_PLAN_KINDS: readonly ["FREE", "PAID_METERED"];
|
|
6
|
+
declare const BillingPlanKindSchema: z.ZodEnum<{
|
|
7
|
+
FREE: "FREE";
|
|
8
|
+
PAID_METERED: "PAID_METERED";
|
|
9
|
+
}>;
|
|
10
|
+
type BillingPlanKind = z.infer<typeof BillingPlanKindSchema>;
|
|
11
|
+
declare const BILLING_USAGE_METRICS: readonly ["RECOVERY_CONVERSATION", "OUTBOUND_AUTOMATED_MESSAGE", "DELIVERED_WHATSAPP_MESSAGE"];
|
|
12
|
+
declare const BillingUsageMetricSchema: z.ZodEnum<{
|
|
13
|
+
RECOVERY_CONVERSATION: "RECOVERY_CONVERSATION";
|
|
14
|
+
OUTBOUND_AUTOMATED_MESSAGE: "OUTBOUND_AUTOMATED_MESSAGE";
|
|
15
|
+
DELIVERED_WHATSAPP_MESSAGE: "DELIVERED_WHATSAPP_MESSAGE";
|
|
16
|
+
}>;
|
|
17
|
+
type BillingUsageMetric = z.infer<typeof BillingUsageMetricSchema>;
|
|
18
|
+
declare const BILLING_SYSTEM_MESSAGE_CODES: {
|
|
19
|
+
readonly FREE_ALLOWANCE_WARNING: "BILLING_FREE_ALLOWANCE_WARNING";
|
|
20
|
+
readonly FREE_ALLOWANCE_EXHAUSTED: "BILLING_FREE_ALLOWANCE_EXHAUSTED";
|
|
21
|
+
readonly PLAN_UPGRADED: "BILLING_PLAN_UPGRADED";
|
|
22
|
+
readonly PLAN_DOWNGRADE_SCHEDULED: "BILLING_PLAN_DOWNGRADE_SCHEDULED";
|
|
23
|
+
readonly SUBSCRIPTION_ENDED: "BILLING_SUBSCRIPTION_ENDED";
|
|
24
|
+
readonly SAFETY_LIMIT_REACHED: "BILLING_SAFETY_LIMIT_REACHED";
|
|
25
|
+
};
|
|
26
|
+
declare const BillingSystemMessageCodeSchema: z.ZodEnum<{
|
|
27
|
+
BILLING_FREE_ALLOWANCE_WARNING: "BILLING_FREE_ALLOWANCE_WARNING";
|
|
28
|
+
BILLING_FREE_ALLOWANCE_EXHAUSTED: "BILLING_FREE_ALLOWANCE_EXHAUSTED";
|
|
29
|
+
BILLING_PLAN_UPGRADED: "BILLING_PLAN_UPGRADED";
|
|
30
|
+
BILLING_PLAN_DOWNGRADE_SCHEDULED: "BILLING_PLAN_DOWNGRADE_SCHEDULED";
|
|
31
|
+
BILLING_SUBSCRIPTION_ENDED: "BILLING_SUBSCRIPTION_ENDED";
|
|
32
|
+
BILLING_SAFETY_LIMIT_REACHED: "BILLING_SAFETY_LIMIT_REACHED";
|
|
33
|
+
}>;
|
|
34
|
+
type BillingSystemMessageCode = z.infer<typeof BillingSystemMessageCodeSchema>;
|
|
35
|
+
declare const WHATSAPP_PROVIDER_STATUSES: readonly ["SENT", "DELIVERED", "READ", "FAILED"];
|
|
36
|
+
declare const WhatsAppProviderStatusSchema: z.ZodEnum<{
|
|
37
|
+
SENT: "SENT";
|
|
38
|
+
DELIVERED: "DELIVERED";
|
|
39
|
+
READ: "READ";
|
|
40
|
+
FAILED: "FAILED";
|
|
41
|
+
}>;
|
|
42
|
+
type WhatsAppProviderStatus = z.infer<typeof WhatsAppProviderStatusSchema>;
|
|
43
|
+
declare const WhatsAppProviderPricingMetadataSchema: z.ZodObject<{
|
|
44
|
+
billable: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
category: z.ZodOptional<z.ZodString>;
|
|
46
|
+
model: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
type WhatsAppProviderPricingMetadata = z.infer<typeof WhatsAppProviderPricingMetadataSchema>;
|
|
49
|
+
declare const NormalizedWhatsAppStatusSchema: z.ZodObject<{
|
|
50
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
51
|
+
shopId: z.ZodString;
|
|
52
|
+
providerAccountId: z.ZodString;
|
|
53
|
+
providerMessageId: z.ZodString;
|
|
54
|
+
status: z.ZodEnum<{
|
|
55
|
+
SENT: "SENT";
|
|
56
|
+
DELIVERED: "DELIVERED";
|
|
57
|
+
READ: "READ";
|
|
58
|
+
FAILED: "FAILED";
|
|
59
|
+
}>;
|
|
60
|
+
occurredAt: z.ZodISODateTime;
|
|
61
|
+
pricing: z.ZodOptional<z.ZodObject<{
|
|
62
|
+
billable: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
category: z.ZodOptional<z.ZodString>;
|
|
64
|
+
model: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
type NormalizedWhatsAppStatus = z.infer<typeof NormalizedWhatsAppStatusSchema>;
|
|
68
|
+
declare function parseNormalizedWhatsAppStatus(input: unknown): NormalizedWhatsAppStatus;
|
|
69
|
+
declare function safeParseNormalizedWhatsAppStatus(input: unknown): z.ZodSafeParseResult<{
|
|
70
|
+
schemaVersion: 1;
|
|
71
|
+
shopId: string;
|
|
72
|
+
providerAccountId: string;
|
|
73
|
+
providerMessageId: string;
|
|
74
|
+
status: "SENT" | "DELIVERED" | "READ" | "FAILED";
|
|
75
|
+
occurredAt: string;
|
|
76
|
+
pricing?: {
|
|
77
|
+
billable?: boolean | undefined;
|
|
78
|
+
category?: string | undefined;
|
|
79
|
+
model?: string | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
declare function createMerchantBillingSystemSourceKey(shopId: string, code: BillingSystemMessageCode, eventIdentity: string, version?: number): string;
|
|
83
|
+
declare function createRecoveryIdempotencyKey(shopId: string, recoveryId: string): string;
|
|
84
|
+
declare function createShopifyUsageIdempotencyKey(shopId: string, usageEventId: string): string;
|
|
85
|
+
|
|
86
|
+
export { ARCH007_BILLING_CONTRACT_SCHEMA_VERSION, BILLING_PLAN_KINDS, BILLING_SYSTEM_MESSAGE_CODES, BILLING_USAGE_METRICS, type BillingPlanKind, BillingPlanKindSchema, type BillingSystemMessageCode, BillingSystemMessageCodeSchema, type BillingUsageMetric, BillingUsageMetricSchema, type NormalizedWhatsAppStatus, NormalizedWhatsAppStatusSchema, WHATSAPP_PROVIDER_STATUSES, WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION, type WhatsAppProviderPricingMetadata, WhatsAppProviderPricingMetadataSchema, type WhatsAppProviderStatus, WhatsAppProviderStatusSchema, createMerchantBillingSystemSourceKey, createRecoveryIdempotencyKey, createShopifyUsageIdempotencyKey, parseNormalizedWhatsAppStatus, safeParseNormalizedWhatsAppStatus };
|
package/dist/billing.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ARCH007_BILLING_CONTRACT_SCHEMA_VERSION,
|
|
3
|
+
BILLING_PLAN_KINDS,
|
|
4
|
+
BILLING_SYSTEM_MESSAGE_CODES,
|
|
5
|
+
BILLING_USAGE_METRICS,
|
|
6
|
+
BillingPlanKindSchema,
|
|
7
|
+
BillingSystemMessageCodeSchema,
|
|
8
|
+
BillingUsageMetricSchema,
|
|
9
|
+
NormalizedWhatsAppStatusSchema,
|
|
10
|
+
WHATSAPP_PROVIDER_STATUSES,
|
|
11
|
+
WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION,
|
|
12
|
+
WhatsAppProviderPricingMetadataSchema,
|
|
13
|
+
WhatsAppProviderStatusSchema,
|
|
14
|
+
createMerchantBillingSystemSourceKey,
|
|
15
|
+
createRecoveryIdempotencyKey,
|
|
16
|
+
createShopifyUsageIdempotencyKey,
|
|
17
|
+
parseNormalizedWhatsAppStatus,
|
|
18
|
+
safeParseNormalizedWhatsAppStatus
|
|
19
|
+
} from "./chunk-WVVP7IUY.js";
|
|
20
|
+
export {
|
|
21
|
+
ARCH007_BILLING_CONTRACT_SCHEMA_VERSION,
|
|
22
|
+
BILLING_PLAN_KINDS,
|
|
23
|
+
BILLING_SYSTEM_MESSAGE_CODES,
|
|
24
|
+
BILLING_USAGE_METRICS,
|
|
25
|
+
BillingPlanKindSchema,
|
|
26
|
+
BillingSystemMessageCodeSchema,
|
|
27
|
+
BillingUsageMetricSchema,
|
|
28
|
+
NormalizedWhatsAppStatusSchema,
|
|
29
|
+
WHATSAPP_PROVIDER_STATUSES,
|
|
30
|
+
WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION,
|
|
31
|
+
WhatsAppProviderPricingMetadataSchema,
|
|
32
|
+
WhatsAppProviderStatusSchema,
|
|
33
|
+
createMerchantBillingSystemSourceKey,
|
|
34
|
+
createRecoveryIdempotencyKey,
|
|
35
|
+
createShopifyUsageIdempotencyKey,
|
|
36
|
+
parseNormalizedWhatsAppStatus,
|
|
37
|
+
safeParseNormalizedWhatsAppStatus
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// src/billing.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var ARCH007_BILLING_CONTRACT_SCHEMA_VERSION = 1;
|
|
4
|
+
var WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION = 1;
|
|
5
|
+
var BILLING_PLAN_KINDS = ["FREE", "PAID_METERED"];
|
|
6
|
+
var BillingPlanKindSchema = z.enum(BILLING_PLAN_KINDS);
|
|
7
|
+
var BILLING_USAGE_METRICS = [
|
|
8
|
+
"RECOVERY_CONVERSATION",
|
|
9
|
+
"OUTBOUND_AUTOMATED_MESSAGE",
|
|
10
|
+
"DELIVERED_WHATSAPP_MESSAGE"
|
|
11
|
+
];
|
|
12
|
+
var BillingUsageMetricSchema = z.enum(BILLING_USAGE_METRICS);
|
|
13
|
+
var BILLING_SYSTEM_MESSAGE_CODES = {
|
|
14
|
+
FREE_ALLOWANCE_WARNING: "BILLING_FREE_ALLOWANCE_WARNING",
|
|
15
|
+
FREE_ALLOWANCE_EXHAUSTED: "BILLING_FREE_ALLOWANCE_EXHAUSTED",
|
|
16
|
+
PLAN_UPGRADED: "BILLING_PLAN_UPGRADED",
|
|
17
|
+
PLAN_DOWNGRADE_SCHEDULED: "BILLING_PLAN_DOWNGRADE_SCHEDULED",
|
|
18
|
+
SUBSCRIPTION_ENDED: "BILLING_SUBSCRIPTION_ENDED",
|
|
19
|
+
SAFETY_LIMIT_REACHED: "BILLING_SAFETY_LIMIT_REACHED"
|
|
20
|
+
};
|
|
21
|
+
var BILLING_SYSTEM_MESSAGE_CODE_VALUES = [
|
|
22
|
+
BILLING_SYSTEM_MESSAGE_CODES.FREE_ALLOWANCE_WARNING,
|
|
23
|
+
BILLING_SYSTEM_MESSAGE_CODES.FREE_ALLOWANCE_EXHAUSTED,
|
|
24
|
+
BILLING_SYSTEM_MESSAGE_CODES.PLAN_UPGRADED,
|
|
25
|
+
BILLING_SYSTEM_MESSAGE_CODES.PLAN_DOWNGRADE_SCHEDULED,
|
|
26
|
+
BILLING_SYSTEM_MESSAGE_CODES.SUBSCRIPTION_ENDED,
|
|
27
|
+
BILLING_SYSTEM_MESSAGE_CODES.SAFETY_LIMIT_REACHED
|
|
28
|
+
];
|
|
29
|
+
var BillingSystemMessageCodeSchema = z.enum(BILLING_SYSTEM_MESSAGE_CODE_VALUES);
|
|
30
|
+
var WHATSAPP_PROVIDER_STATUSES = [
|
|
31
|
+
"SENT",
|
|
32
|
+
"DELIVERED",
|
|
33
|
+
"READ",
|
|
34
|
+
"FAILED"
|
|
35
|
+
];
|
|
36
|
+
var WhatsAppProviderStatusSchema = z.enum(WHATSAPP_PROVIDER_STATUSES);
|
|
37
|
+
var MAX_ID_LENGTH = 128;
|
|
38
|
+
var MAX_SHORT_TEXT_LENGTH = 128;
|
|
39
|
+
var WhatsAppProviderPricingMetadataSchema = z.object({
|
|
40
|
+
billable: z.boolean().optional(),
|
|
41
|
+
category: z.string().trim().min(1).max(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
42
|
+
model: z.string().trim().min(1).max(MAX_SHORT_TEXT_LENGTH).optional()
|
|
43
|
+
}).strict().refine((value) => Object.keys(value).length > 0, "pricing metadata must not be empty");
|
|
44
|
+
var NormalizedWhatsAppStatusSchema = z.object({
|
|
45
|
+
schemaVersion: z.literal(WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION),
|
|
46
|
+
shopId: z.string().trim().min(1).max(MAX_ID_LENGTH),
|
|
47
|
+
providerAccountId: z.string().trim().min(1).max(MAX_ID_LENGTH),
|
|
48
|
+
providerMessageId: z.string().trim().min(1).max(MAX_ID_LENGTH),
|
|
49
|
+
status: WhatsAppProviderStatusSchema,
|
|
50
|
+
occurredAt: z.iso.datetime({ offset: true }),
|
|
51
|
+
pricing: WhatsAppProviderPricingMetadataSchema.optional()
|
|
52
|
+
}).strict();
|
|
53
|
+
function parseNormalizedWhatsAppStatus(input) {
|
|
54
|
+
return NormalizedWhatsAppStatusSchema.parse(input);
|
|
55
|
+
}
|
|
56
|
+
function safeParseNormalizedWhatsAppStatus(input) {
|
|
57
|
+
return NormalizedWhatsAppStatusSchema.safeParse(input);
|
|
58
|
+
}
|
|
59
|
+
function assertKeyPart(name, value) {
|
|
60
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
61
|
+
throw new Error(`${name} must be a non-empty string`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function fnv1a64(value) {
|
|
65
|
+
let hash = 0xcbf29ce484222325n;
|
|
66
|
+
for (const character of value) {
|
|
67
|
+
hash ^= BigInt(character.codePointAt(0) ?? 0);
|
|
68
|
+
hash = BigInt.asUintN(64, hash * 0x100000001b3n);
|
|
69
|
+
}
|
|
70
|
+
return hash.toString(16).padStart(16, "0");
|
|
71
|
+
}
|
|
72
|
+
function boundedKey(prefix, parts, maxLength) {
|
|
73
|
+
const canonical = parts.map((part) => part.trim()).join(":");
|
|
74
|
+
const readable = `${prefix}:${canonical}`;
|
|
75
|
+
if (readable.length <= maxLength) return readable;
|
|
76
|
+
return `${prefix}:h${fnv1a64(canonical)}`;
|
|
77
|
+
}
|
|
78
|
+
function createMerchantBillingSystemSourceKey(shopId, code, eventIdentity, version = 1) {
|
|
79
|
+
assertKeyPart("shopId", shopId);
|
|
80
|
+
assertKeyPart("code", code);
|
|
81
|
+
assertKeyPart("eventIdentity", eventIdentity);
|
|
82
|
+
if (!Number.isInteger(version) || version < 1) {
|
|
83
|
+
throw new Error("version must be a positive integer");
|
|
84
|
+
}
|
|
85
|
+
return boundedKey("billing-system", [shopId, code, eventIdentity, String(version)], 255);
|
|
86
|
+
}
|
|
87
|
+
function createRecoveryIdempotencyKey(shopId, recoveryId) {
|
|
88
|
+
assertKeyPart("shopId", shopId);
|
|
89
|
+
assertKeyPart("recoveryId", recoveryId);
|
|
90
|
+
return boundedKey("recovery", [shopId, recoveryId], 255);
|
|
91
|
+
}
|
|
92
|
+
function createShopifyUsageIdempotencyKey(shopId, usageEventId) {
|
|
93
|
+
assertKeyPart("shopId", shopId);
|
|
94
|
+
assertKeyPart("usageEventId", usageEventId);
|
|
95
|
+
return boundedKey("shopify", [shopId, usageEventId], 64);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
ARCH007_BILLING_CONTRACT_SCHEMA_VERSION,
|
|
100
|
+
WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION,
|
|
101
|
+
BILLING_PLAN_KINDS,
|
|
102
|
+
BillingPlanKindSchema,
|
|
103
|
+
BILLING_USAGE_METRICS,
|
|
104
|
+
BillingUsageMetricSchema,
|
|
105
|
+
BILLING_SYSTEM_MESSAGE_CODES,
|
|
106
|
+
BillingSystemMessageCodeSchema,
|
|
107
|
+
WHATSAPP_PROVIDER_STATUSES,
|
|
108
|
+
WhatsAppProviderStatusSchema,
|
|
109
|
+
WhatsAppProviderPricingMetadataSchema,
|
|
110
|
+
NormalizedWhatsAppStatusSchema,
|
|
111
|
+
parseNormalizedWhatsAppStatus,
|
|
112
|
+
safeParseNormalizedWhatsAppStatus,
|
|
113
|
+
createMerchantBillingSystemSourceKey,
|
|
114
|
+
createRecoveryIdempotencyKey,
|
|
115
|
+
createShopifyUsageIdempotencyKey
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=chunk-WVVP7IUY.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 = 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;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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O,KAAK,SAAS,EAAE,EAAE,SAAS,IAAI,GAAG;AAC3C;AAEA,SAAS,WAAW,QAAgB,OAAiB,WAA2B;AAC9E,QAAM,YAAY,MAAM,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EAAE,KAAK,GAAG;AAC3D,QAAM,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.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { CatalogueValidationOptions, CountryCode, CountryCodeSchema, CurrencyCode, CurrencyCodeSchema, IcuMessageCatalogue, IcuMessageValues, InternationalContext, InternationalContextSchema, InternationalizationRuntime, InternationalizationRuntimeOptions, LanguageSource, LanguageSourceSchema, LanguageTag, LanguageTagSchema, TimeZoneId, TimeZoneIdSchema, canonicaliseLanguageTag, createInternationalizationRuntime, mergeInternationalContext, normalizeCountryCode, normalizeCurrencyCode, normalizeTimeZone, resolveLocaleDirection, validateIcuCatalogue } from './internationalization.js';
|
|
2
|
+
export { ARCH007_BILLING_CONTRACT_SCHEMA_VERSION, BILLING_PLAN_KINDS, BILLING_SYSTEM_MESSAGE_CODES, BILLING_USAGE_METRICS, BillingPlanKind, BillingPlanKindSchema, BillingSystemMessageCode, BillingSystemMessageCodeSchema, BillingUsageMetric, BillingUsageMetricSchema, NormalizedWhatsAppStatus, NormalizedWhatsAppStatusSchema, WHATSAPP_PROVIDER_STATUSES, WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION, WhatsAppProviderPricingMetadata, WhatsAppProviderPricingMetadataSchema, WhatsAppProviderStatus, WhatsAppProviderStatusSchema, createMerchantBillingSystemSourceKey, createRecoveryIdempotencyKey, createShopifyUsageIdempotencyKey, parseNormalizedWhatsAppStatus, safeParseNormalizedWhatsAppStatus } from './billing.js';
|
|
2
3
|
export { AuthoredSupportBodySchema, MERCHANT_COMMUNICATIONS_JOB_NAMES, MERCHANT_COMMUNICATIONS_QUEUE_NAME, MERCHANT_COMMUNICATIONS_SCHEMA_VERSION, MerchantMessageTranslationContract, MerchantMessageTranslationContractSchema, MerchantMessageTranslationStatus, MerchantMessageTranslationStatusSchema, MerchantSupportMessageContract, MerchantSupportMessageContractSchema, MerchantSupportMessageKind, MerchantSupportMessageKindSchema, MerchantSupportMessageState, MerchantSupportMessageStateSchema, MerchantTranslationBatchContract, MerchantTranslationBatchContractSchema, MerchantTranslationBatchStatus, MerchantTranslationBatchStatusSchema, MerchantTranslationDirection, MerchantTranslationDirectionSchema, MerchantTranslationReconciliationRequestContract, MerchantTranslationReconciliationRequestContractSchema, MerchantTranslationReconciliationScope, MerchantTranslationReconciliationScopeSchema, MerchantTranslationReconciliationStatus, MerchantTranslationReconciliationStatusSchema, PLATFORM_SUPPORT_LANGUAGE_TAG, TranslatedSupportBodySchema, TranslationBatchPollJob, TranslationBatchPollJobSchema, TranslationBatchResultsJob, TranslationBatchResultsJobSchema, TranslationBatchSubmitJob, TranslationBatchSubmitJobSchema, TranslationDispatchJob, TranslationDispatchJobSchema, TranslationReconcileJob, TranslationReconcileJobSchema, countUnicodeGraphemes, requiresMerchantTranslation } from './merchant-communications.js';
|
|
3
4
|
export { CheckoutCreatedPayloadV2, CheckoutCreatedPayloadV2Schema, CheckoutObservedPayload, CheckoutObservedPayloadSchema, CheckoutUpdatedPayloadV2, CheckoutUpdatedPayloadV2Schema, MAX_LINE_ITEMS, MAX_URL_LENGTH, OrderCompletedPayload, OrderCompletedPayloadSchema, OrderCompletedPayloadV2, OrderCompletedPayloadV2Schema, SHOPIFY_COMMERCE_EVENT_SCHEMA_VERSION, SHOPIFY_COMMERCE_EVENT_SCHEMA_VERSION_V1, SHOPIFY_COMMERCE_EVENT_SCHEMA_VERSION_V2, SHOPIFY_COMMERCE_EVENT_TYPES, SHOPIFY_RECOVERY_EVENT_TYPES_V2, SHOPIFY_WEBHOOK_OUTBOX_DESTINATIONS, SHOPIFY_WEBHOOK_QUEUE_CONTRACTS, ShopifyCartActivityEventV2, ShopifyCartActivityEventV2Schema, ShopifyCartActivityPayloadV2, ShopifyCartActivityPayloadV2Schema, ShopifyCheckoutCreatedEventV2, ShopifyCheckoutCreatedEventV2Schema, ShopifyCheckoutLineItem, ShopifyCheckoutLineItemSchema, ShopifyCheckoutLineItemsSchema, ShopifyCheckoutObservedEvent, ShopifyCheckoutObservedEventSchema, ShopifyCheckoutUpdatedEventV2, ShopifyCheckoutUpdatedEventV2Schema, ShopifyCommerceEvent, ShopifyCommerceEventSchema, ShopifyCommerceEventType, ShopifyCustomerReference, ShopifyCustomerReferenceSchema, ShopifyMoney, ShopifyMoneySchema, ShopifyOrderCompletedEvent, ShopifyOrderCompletedEventSchema, ShopifyOrderCompletedEventV2, ShopifyOrderCompletedEventV2Schema, ShopifyRecoveryEventTypeV2, ShopifyRecoveryEventV2, ShopifyRecoveryEventV2Schema, ShopifyTenant, ShopifyTenantSchema, createShopifyCartActivityOrderingKey, createShopifyCommerceOrderingKey, createShopifyOrderCorrelationOrderingKey, createShopifyOrderOrderingKey, createShopifyPendingRecoveryOrderingKey, isCartActivityEventV2, isCheckoutCreatedEventV2, isCheckoutObservedEvent, isCheckoutUpdatedEventV2, isOrderCompletedEvent, isOrderCompletedEventV2, parseShopifyCommerceEvent, parseShopifyRecoveryEventV2, safeParseShopifyCommerceEvent, safeParseShopifyRecoveryEventV2 } from './shopify/index.js';
|
|
4
5
|
import 'zod';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ARCH007_BILLING_CONTRACT_SCHEMA_VERSION,
|
|
3
|
+
BILLING_PLAN_KINDS,
|
|
4
|
+
BILLING_SYSTEM_MESSAGE_CODES,
|
|
5
|
+
BILLING_USAGE_METRICS,
|
|
6
|
+
BillingPlanKindSchema,
|
|
7
|
+
BillingSystemMessageCodeSchema,
|
|
8
|
+
BillingUsageMetricSchema,
|
|
9
|
+
NormalizedWhatsAppStatusSchema,
|
|
10
|
+
WHATSAPP_PROVIDER_STATUSES,
|
|
11
|
+
WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION,
|
|
12
|
+
WhatsAppProviderPricingMetadataSchema,
|
|
13
|
+
WhatsAppProviderStatusSchema,
|
|
14
|
+
createMerchantBillingSystemSourceKey,
|
|
15
|
+
createRecoveryIdempotencyKey,
|
|
16
|
+
createShopifyUsageIdempotencyKey,
|
|
17
|
+
parseNormalizedWhatsAppStatus,
|
|
18
|
+
safeParseNormalizedWhatsAppStatus
|
|
19
|
+
} from "./chunk-WVVP7IUY.js";
|
|
1
20
|
import {
|
|
2
21
|
AuthoredSupportBodySchema,
|
|
3
22
|
MERCHANT_COMMUNICATIONS_JOB_NAMES,
|
|
@@ -86,7 +105,14 @@ import {
|
|
|
86
105
|
validateIcuCatalogue
|
|
87
106
|
} from "./chunk-B6Y3QQLI.js";
|
|
88
107
|
export {
|
|
108
|
+
ARCH007_BILLING_CONTRACT_SCHEMA_VERSION,
|
|
89
109
|
AuthoredSupportBodySchema,
|
|
110
|
+
BILLING_PLAN_KINDS,
|
|
111
|
+
BILLING_SYSTEM_MESSAGE_CODES,
|
|
112
|
+
BILLING_USAGE_METRICS,
|
|
113
|
+
BillingPlanKindSchema,
|
|
114
|
+
BillingSystemMessageCodeSchema,
|
|
115
|
+
BillingUsageMetricSchema,
|
|
90
116
|
CheckoutCreatedPayloadV2Schema,
|
|
91
117
|
CheckoutObservedPayloadSchema,
|
|
92
118
|
CheckoutUpdatedPayloadV2Schema,
|
|
@@ -111,6 +137,7 @@ export {
|
|
|
111
137
|
MerchantTranslationReconciliationRequestContractSchema,
|
|
112
138
|
MerchantTranslationReconciliationScopeSchema,
|
|
113
139
|
MerchantTranslationReconciliationStatusSchema,
|
|
140
|
+
NormalizedWhatsAppStatusSchema,
|
|
114
141
|
OrderCompletedPayloadSchema,
|
|
115
142
|
OrderCompletedPayloadV2Schema,
|
|
116
143
|
PLATFORM_SUPPORT_LANGUAGE_TAG,
|
|
@@ -142,14 +169,21 @@ export {
|
|
|
142
169
|
TranslationBatchSubmitJobSchema,
|
|
143
170
|
TranslationDispatchJobSchema,
|
|
144
171
|
TranslationReconcileJobSchema,
|
|
172
|
+
WHATSAPP_PROVIDER_STATUSES,
|
|
173
|
+
WHATSAPP_PROVIDER_STATUS_SCHEMA_VERSION,
|
|
174
|
+
WhatsAppProviderPricingMetadataSchema,
|
|
175
|
+
WhatsAppProviderStatusSchema,
|
|
145
176
|
canonicaliseLanguageTag,
|
|
146
177
|
countUnicodeGraphemes,
|
|
147
178
|
createInternationalizationRuntime,
|
|
179
|
+
createMerchantBillingSystemSourceKey,
|
|
180
|
+
createRecoveryIdempotencyKey,
|
|
148
181
|
createShopifyCartActivityOrderingKey,
|
|
149
182
|
createShopifyCommerceOrderingKey,
|
|
150
183
|
createShopifyOrderCorrelationOrderingKey,
|
|
151
184
|
createShopifyOrderOrderingKey,
|
|
152
185
|
createShopifyPendingRecoveryOrderingKey,
|
|
186
|
+
createShopifyUsageIdempotencyKey,
|
|
153
187
|
isCartActivityEventV2,
|
|
154
188
|
isCheckoutCreatedEventV2,
|
|
155
189
|
isCheckoutObservedEvent,
|
|
@@ -160,10 +194,12 @@ export {
|
|
|
160
194
|
normalizeCountryCode,
|
|
161
195
|
normalizeCurrencyCode,
|
|
162
196
|
normalizeTimeZone,
|
|
197
|
+
parseNormalizedWhatsAppStatus,
|
|
163
198
|
parseShopifyCommerceEvent,
|
|
164
199
|
parseShopifyRecoveryEventV2,
|
|
165
200
|
requiresMerchantTranslation,
|
|
166
201
|
resolveLocaleDirection,
|
|
202
|
+
safeParseNormalizedWhatsAppStatus,
|
|
167
203
|
safeParseShopifyCommerceEvent,
|
|
168
204
|
safeParseShopifyRecoveryEventV2,
|
|
169
205
|
validateIcuCatalogue
|
|
@@ -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";
|
|
5
6
|
"customer-explicit": "customer-explicit";
|
|
6
7
|
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";
|
|
23
24
|
"customer-explicit": "customer-explicit";
|
|
24
25
|
detected: "detected";
|
|
25
|
-
shopify: "shopify";
|
|
26
26
|
"merchant-default": "merchant-default";
|
|
27
27
|
"platform-default": "platform-default";
|
|
28
28
|
}>>;
|
|
@@ -9,9 +9,9 @@ declare const MerchantSupportMessageKindSchema: z.ZodEnum<{
|
|
|
9
9
|
MERCHANT: "MERCHANT";
|
|
10
10
|
}>;
|
|
11
11
|
declare const MerchantSupportMessageStateSchema: z.ZodEnum<{
|
|
12
|
+
FAILED: "FAILED";
|
|
12
13
|
PROCESSING: "PROCESSING";
|
|
13
14
|
AVAILABLE: "AVAILABLE";
|
|
14
|
-
FAILED: "FAILED";
|
|
15
15
|
}>;
|
|
16
16
|
declare const MerchantTranslationDirectionSchema: z.ZodEnum<{
|
|
17
17
|
MERCHANT_TO_ADMIN: "MERCHANT_TO_ADMIN";
|
|
@@ -19,8 +19,8 @@ declare const MerchantTranslationDirectionSchema: z.ZodEnum<{
|
|
|
19
19
|
SYSTEM_TO_MERCHANT: "SYSTEM_TO_MERCHANT";
|
|
20
20
|
}>;
|
|
21
21
|
declare const MerchantMessageTranslationStatusSchema: z.ZodEnum<{
|
|
22
|
-
AVAILABLE: "AVAILABLE";
|
|
23
22
|
FAILED: "FAILED";
|
|
23
|
+
AVAILABLE: "AVAILABLE";
|
|
24
24
|
PENDING: "PENDING";
|
|
25
25
|
}>;
|
|
26
26
|
declare const MerchantTranslationBatchStatusSchema: z.ZodEnum<{
|
|
@@ -39,8 +39,8 @@ declare const MerchantTranslationReconciliationScopeSchema: z.ZodEnum<{
|
|
|
39
39
|
FAILED_TRANSLATIONS: "FAILED_TRANSLATIONS";
|
|
40
40
|
}>;
|
|
41
41
|
declare const MerchantTranslationReconciliationStatusSchema: z.ZodEnum<{
|
|
42
|
-
PROCESSING: "PROCESSING";
|
|
43
42
|
FAILED: "FAILED";
|
|
43
|
+
PROCESSING: "PROCESSING";
|
|
44
44
|
PENDING: "PENDING";
|
|
45
45
|
COMPLETED: "COMPLETED";
|
|
46
46
|
}>;
|
|
@@ -61,9 +61,9 @@ declare const MerchantSupportMessageContractSchema: z.ZodObject<{
|
|
|
61
61
|
MERCHANT: "MERCHANT";
|
|
62
62
|
}>;
|
|
63
63
|
state: z.ZodEnum<{
|
|
64
|
+
FAILED: "FAILED";
|
|
64
65
|
PROCESSING: "PROCESSING";
|
|
65
66
|
AVAILABLE: "AVAILABLE";
|
|
66
|
-
FAILED: "FAILED";
|
|
67
67
|
}>;
|
|
68
68
|
originalBody: z.ZodString;
|
|
69
69
|
sourceLanguageTag: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -78,8 +78,8 @@ declare const MerchantMessageTranslationContractSchema: z.ZodObject<{
|
|
|
78
78
|
sourceLanguageTag: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
79
79
|
targetLanguageTag: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
80
80
|
status: z.ZodEnum<{
|
|
81
|
-
AVAILABLE: "AVAILABLE";
|
|
82
81
|
FAILED: "FAILED";
|
|
82
|
+
AVAILABLE: "AVAILABLE";
|
|
83
83
|
PENDING: "PENDING";
|
|
84
84
|
}>;
|
|
85
85
|
translatedBody: z.ZodNullable<z.ZodString>;
|
|
@@ -110,8 +110,8 @@ declare const MerchantTranslationReconciliationRequestContractSchema: z.ZodObjec
|
|
|
110
110
|
}>;
|
|
111
111
|
translationId: z.ZodNullable<z.ZodString>;
|
|
112
112
|
status: z.ZodEnum<{
|
|
113
|
-
PROCESSING: "PROCESSING";
|
|
114
113
|
FAILED: "FAILED";
|
|
114
|
+
PROCESSING: "PROCESSING";
|
|
115
115
|
PENDING: "PENDING";
|
|
116
116
|
COMPLETED: "COMPLETED";
|
|
117
117
|
}>;
|
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";
|
|
387
388
|
"customer-explicit": "customer-explicit";
|
|
388
389
|
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";
|
|
424
425
|
"customer-explicit": "customer-explicit";
|
|
425
426
|
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";
|
|
459
460
|
"customer-explicit": "customer-explicit";
|
|
460
461
|
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";
|
|
493
494
|
"customer-explicit": "customer-explicit";
|
|
494
495
|
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";
|
|
530
531
|
"customer-explicit": "customer-explicit";
|
|
531
532
|
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";
|
|
563
564
|
"customer-explicit": "customer-explicit";
|
|
564
565
|
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";
|
|
598
599
|
"customer-explicit": "customer-explicit";
|
|
599
600
|
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";
|
|
630
631
|
"customer-explicit": "customer-explicit";
|
|
631
632
|
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: "shopify" | "customer-explicit" | "detected" | "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: "shopify" | "customer-explicit" | "detected" | "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: "shopify" | "customer-explicit" | "detected" | "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: "shopify" | "customer-explicit" | "detected" | "merchant-default" | "platform-default" | null;
|
|
758
758
|
countryCode: string | null;
|
|
759
759
|
currencyCode: string | null;
|
|
760
760
|
timeZone: string | null;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
declare const DEFAULT_POSTGRES_IMAGE = "postgres:17.6-alpine";
|
|
2
|
+
declare const DEFAULT_REDIS_IMAGE = "redis:7.4.2-alpine";
|
|
3
|
+
declare const DEFAULT_HOST = "127.0.0.1";
|
|
4
|
+
declare const DEFAULT_POSTGRES_STARTUP_TIMEOUT_MS = 30000;
|
|
5
|
+
declare const DEFAULT_REDIS_STARTUP_TIMEOUT_MS = 15000;
|
|
6
|
+
declare const DEFAULT_POLL_INTERVAL_MS = 200;
|
|
7
|
+
declare const DEFAULT_COMMAND_TIMEOUT_MS = 120000;
|
|
8
|
+
declare const DEFAULT_DOCKER_COMMAND_TIMEOUT_MS = 30000;
|
|
9
|
+
type CommandResult = {
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
};
|
|
13
|
+
type CommandOptions = {
|
|
14
|
+
cwd?: string;
|
|
15
|
+
env?: NodeJS.ProcessEnv;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
killSignal?: NodeJS.Signals;
|
|
18
|
+
};
|
|
19
|
+
type CommandRunner = (command: string, args: readonly string[], options?: CommandOptions) => Promise<CommandResult>;
|
|
20
|
+
type DockerRunner = (args: readonly string[], options?: CommandOptions) => Promise<CommandResult>;
|
|
21
|
+
type DisposableEnvironment = {
|
|
22
|
+
DATABASE_URL: string;
|
|
23
|
+
TEST_DATABASE_URL: string;
|
|
24
|
+
REDIS_URL: string;
|
|
25
|
+
TEST_REDIS_URL: string;
|
|
26
|
+
};
|
|
27
|
+
type PostgresConnectionDetails = {
|
|
28
|
+
host: string;
|
|
29
|
+
port: number;
|
|
30
|
+
database: string;
|
|
31
|
+
user: string;
|
|
32
|
+
password: string;
|
|
33
|
+
databaseUrl: string;
|
|
34
|
+
containerName: string;
|
|
35
|
+
};
|
|
36
|
+
type RedisConnectionDetails = {
|
|
37
|
+
host: string;
|
|
38
|
+
port: number;
|
|
39
|
+
url: string;
|
|
40
|
+
containerName: string;
|
|
41
|
+
};
|
|
42
|
+
type EphemeralPostgresOptions = {
|
|
43
|
+
image?: string;
|
|
44
|
+
host?: string;
|
|
45
|
+
database?: string;
|
|
46
|
+
user?: string;
|
|
47
|
+
password?: string;
|
|
48
|
+
containerName?: string;
|
|
49
|
+
startupTimeoutMs?: number;
|
|
50
|
+
pollIntervalMs?: number;
|
|
51
|
+
dockerBinary?: string;
|
|
52
|
+
runDocker?: DockerRunner;
|
|
53
|
+
};
|
|
54
|
+
type EphemeralRedisOptions = {
|
|
55
|
+
image?: string;
|
|
56
|
+
host?: string;
|
|
57
|
+
containerName?: string;
|
|
58
|
+
startupTimeoutMs?: number;
|
|
59
|
+
pollIntervalMs?: number;
|
|
60
|
+
dockerBinary?: string;
|
|
61
|
+
runDocker?: DockerRunner;
|
|
62
|
+
};
|
|
63
|
+
type MigrationDeployOptions = {
|
|
64
|
+
databaseUrl: string;
|
|
65
|
+
prismaSchemaPath: string;
|
|
66
|
+
cwd?: string;
|
|
67
|
+
prismaBinary?: string;
|
|
68
|
+
runCommand?: CommandRunner;
|
|
69
|
+
};
|
|
70
|
+
type DisposableIntegrationInfrastructureOptions = {
|
|
71
|
+
prismaSchemaPath: string;
|
|
72
|
+
cwd?: string;
|
|
73
|
+
prismaBinary?: string;
|
|
74
|
+
postgres?: EphemeralPostgresOptions;
|
|
75
|
+
redis?: EphemeralRedisOptions;
|
|
76
|
+
runCommand?: CommandRunner;
|
|
77
|
+
deployMigrations?: (options: MigrationDeployOptions) => Promise<void>;
|
|
78
|
+
};
|
|
79
|
+
type DisposableIntegrationInfrastructure = {
|
|
80
|
+
postgres: PostgresConnectionDetails;
|
|
81
|
+
redis: RedisConnectionDetails;
|
|
82
|
+
databaseUrl: string;
|
|
83
|
+
redisUrl: string;
|
|
84
|
+
environment: DisposableEnvironment;
|
|
85
|
+
};
|
|
86
|
+
type DisposableIntegrationCallback<T> = (infrastructure: DisposableIntegrationInfrastructure) => Promise<T> | T;
|
|
87
|
+
declare function createCommandRunner(binary?: string): CommandRunner;
|
|
88
|
+
declare function createDockerRunner(dockerBinary?: string): DockerRunner;
|
|
89
|
+
declare class EphemeralPostgres {
|
|
90
|
+
private readonly image;
|
|
91
|
+
private readonly host;
|
|
92
|
+
private readonly database;
|
|
93
|
+
private readonly user;
|
|
94
|
+
private readonly password;
|
|
95
|
+
private readonly containerName;
|
|
96
|
+
private readonly startupTimeoutMs;
|
|
97
|
+
private readonly pollIntervalMs;
|
|
98
|
+
private readonly runDocker;
|
|
99
|
+
private port;
|
|
100
|
+
private started;
|
|
101
|
+
constructor(options?: EphemeralPostgresOptions);
|
|
102
|
+
get databaseUrl(): string;
|
|
103
|
+
get connectionDetails(): PostgresConnectionDetails;
|
|
104
|
+
start(): Promise<PostgresConnectionDetails>;
|
|
105
|
+
waitForReady(): Promise<void>;
|
|
106
|
+
cleanup(): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
declare class EphemeralRedis {
|
|
109
|
+
private readonly image;
|
|
110
|
+
private readonly host;
|
|
111
|
+
private readonly containerName;
|
|
112
|
+
private readonly startupTimeoutMs;
|
|
113
|
+
private readonly pollIntervalMs;
|
|
114
|
+
private readonly runDocker;
|
|
115
|
+
private port;
|
|
116
|
+
private started;
|
|
117
|
+
constructor(options?: EphemeralRedisOptions);
|
|
118
|
+
get url(): string;
|
|
119
|
+
get connectionDetails(): RedisConnectionDetails;
|
|
120
|
+
start(): Promise<RedisConnectionDetails>;
|
|
121
|
+
waitForReady(): Promise<void>;
|
|
122
|
+
cleanup(): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
declare function deployPrismaMigrations(options: MigrationDeployOptions): Promise<void>;
|
|
125
|
+
declare function withDisposableIntegrationInfrastructure<T>(options: DisposableIntegrationInfrastructureOptions, callback: DisposableIntegrationCallback<T>): Promise<T>;
|
|
126
|
+
|
|
127
|
+
export { type CommandOptions, type CommandResult, type CommandRunner, DEFAULT_COMMAND_TIMEOUT_MS, DEFAULT_DOCKER_COMMAND_TIMEOUT_MS, DEFAULT_HOST, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POSTGRES_IMAGE, DEFAULT_POSTGRES_STARTUP_TIMEOUT_MS, DEFAULT_REDIS_IMAGE, DEFAULT_REDIS_STARTUP_TIMEOUT_MS, type DisposableEnvironment, type DisposableIntegrationCallback, type DisposableIntegrationInfrastructure, type DisposableIntegrationInfrastructureOptions, type DockerRunner, EphemeralPostgres, type EphemeralPostgresOptions, EphemeralRedis, type EphemeralRedisOptions, type MigrationDeployOptions, type PostgresConnectionDetails, type RedisConnectionDetails, createCommandRunner, createDockerRunner, deployPrismaMigrations, withDisposableIntegrationInfrastructure };
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
// src/testing/node.ts
|
|
2
|
+
import { execFile } from "child_process";
|
|
3
|
+
import { promisify } from "util";
|
|
4
|
+
import { randomUUID } from "crypto";
|
|
5
|
+
var execFileAsync = promisify(execFile);
|
|
6
|
+
var DEFAULT_POSTGRES_IMAGE = "postgres:17.6-alpine";
|
|
7
|
+
var DEFAULT_REDIS_IMAGE = "redis:7.4.2-alpine";
|
|
8
|
+
var DEFAULT_HOST = "127.0.0.1";
|
|
9
|
+
var DEFAULT_POSTGRES_STARTUP_TIMEOUT_MS = 3e4;
|
|
10
|
+
var DEFAULT_REDIS_STARTUP_TIMEOUT_MS = 15e3;
|
|
11
|
+
var DEFAULT_POLL_INTERVAL_MS = 200;
|
|
12
|
+
var DEFAULT_COMMAND_TIMEOUT_MS = 12e4;
|
|
13
|
+
var DEFAULT_DOCKER_COMMAND_TIMEOUT_MS = 3e4;
|
|
14
|
+
function createCommandRunner(binary = "") {
|
|
15
|
+
return async (command, args, options = {}) => {
|
|
16
|
+
const executable = binary || command;
|
|
17
|
+
const commandArgs = binary ? [command, ...args] : args;
|
|
18
|
+
const result = await execFileAsync(executable, commandArgs, {
|
|
19
|
+
encoding: "utf8",
|
|
20
|
+
maxBuffer: 1024 * 1024,
|
|
21
|
+
timeout: DEFAULT_COMMAND_TIMEOUT_MS,
|
|
22
|
+
...options
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
stdout: result.stdout.trim(),
|
|
26
|
+
stderr: result.stderr.trim()
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function createDockerRunner(dockerBinary = "docker") {
|
|
31
|
+
const runCommand = createCommandRunner();
|
|
32
|
+
return (args, options = {}) => runCommand(dockerBinary, args, {
|
|
33
|
+
...options,
|
|
34
|
+
timeout: options.timeout ?? DEFAULT_DOCKER_COMMAND_TIMEOUT_MS
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function parseMappedPort(output, serviceName) {
|
|
38
|
+
const match = output.match(/:(\d+)\s*$/m);
|
|
39
|
+
if (!match) {
|
|
40
|
+
throw new Error(`Docker did not return a mapped ${serviceName} port: ${output}`);
|
|
41
|
+
}
|
|
42
|
+
return Number(match[1]);
|
|
43
|
+
}
|
|
44
|
+
function sleep(milliseconds) {
|
|
45
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
46
|
+
}
|
|
47
|
+
function createSuffix() {
|
|
48
|
+
return randomUUID().replaceAll("-", "");
|
|
49
|
+
}
|
|
50
|
+
function requireStarted(value, serviceName) {
|
|
51
|
+
if (value === null) {
|
|
52
|
+
throw new Error(`Ephemeral ${serviceName} has not been started`);
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
var EphemeralPostgres = class {
|
|
57
|
+
image;
|
|
58
|
+
host;
|
|
59
|
+
database;
|
|
60
|
+
user;
|
|
61
|
+
password;
|
|
62
|
+
containerName;
|
|
63
|
+
startupTimeoutMs;
|
|
64
|
+
pollIntervalMs;
|
|
65
|
+
runDocker;
|
|
66
|
+
port = null;
|
|
67
|
+
started = false;
|
|
68
|
+
constructor(options = {}) {
|
|
69
|
+
const suffix = createSuffix();
|
|
70
|
+
this.image = options.image ?? DEFAULT_POSTGRES_IMAGE;
|
|
71
|
+
this.host = options.host ?? DEFAULT_HOST;
|
|
72
|
+
this.database = options.database ?? `moda_test_${suffix.slice(0, 12)}`;
|
|
73
|
+
this.user = options.user ?? `moda_test_${suffix.slice(0, 12)}`;
|
|
74
|
+
this.password = options.password ?? `test_${suffix}`;
|
|
75
|
+
this.containerName = options.containerName ?? `moda-test-postgres-${suffix}`;
|
|
76
|
+
this.startupTimeoutMs = options.startupTimeoutMs ?? DEFAULT_POSTGRES_STARTUP_TIMEOUT_MS;
|
|
77
|
+
this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
78
|
+
this.runDocker = options.runDocker ?? createDockerRunner(options.dockerBinary);
|
|
79
|
+
}
|
|
80
|
+
get databaseUrl() {
|
|
81
|
+
const port = requireStarted(this.port, "PostgreSQL");
|
|
82
|
+
return `postgresql://${this.user}:${this.password}@${this.host}:${port}/${this.database}`;
|
|
83
|
+
}
|
|
84
|
+
get connectionDetails() {
|
|
85
|
+
return {
|
|
86
|
+
host: this.host,
|
|
87
|
+
port: requireStarted(this.port, "PostgreSQL"),
|
|
88
|
+
database: this.database,
|
|
89
|
+
user: this.user,
|
|
90
|
+
password: this.password,
|
|
91
|
+
databaseUrl: this.databaseUrl,
|
|
92
|
+
containerName: this.containerName
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async start() {
|
|
96
|
+
if (this.started) return this.connectionDetails;
|
|
97
|
+
try {
|
|
98
|
+
await this.runDocker([
|
|
99
|
+
"run",
|
|
100
|
+
"--detach",
|
|
101
|
+
"--name",
|
|
102
|
+
this.containerName,
|
|
103
|
+
"--env",
|
|
104
|
+
`POSTGRES_DB=${this.database}`,
|
|
105
|
+
"--env",
|
|
106
|
+
`POSTGRES_USER=${this.user}`,
|
|
107
|
+
"--env",
|
|
108
|
+
`POSTGRES_PASSWORD=${this.password}`,
|
|
109
|
+
"--publish",
|
|
110
|
+
"0:5432",
|
|
111
|
+
this.image
|
|
112
|
+
]);
|
|
113
|
+
const portResult = await this.runDocker(["port", this.containerName, "5432/tcp"]);
|
|
114
|
+
this.port = parseMappedPort(portResult.stdout, "PostgreSQL");
|
|
115
|
+
await this.waitForReady();
|
|
116
|
+
this.started = true;
|
|
117
|
+
return this.connectionDetails;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
await this.cleanup();
|
|
120
|
+
throw new Error(
|
|
121
|
+
`Unable to start ephemeral PostgreSQL (${this.image}): ${errorMessage(error)}`,
|
|
122
|
+
{ cause: error }
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async waitForReady() {
|
|
127
|
+
const deadline = Date.now() + this.startupTimeoutMs;
|
|
128
|
+
let lastError;
|
|
129
|
+
while (Date.now() < deadline) {
|
|
130
|
+
try {
|
|
131
|
+
const result = await this.runDocker([
|
|
132
|
+
"exec",
|
|
133
|
+
this.containerName,
|
|
134
|
+
"pg_isready",
|
|
135
|
+
"--username",
|
|
136
|
+
this.user,
|
|
137
|
+
"--dbname",
|
|
138
|
+
this.database
|
|
139
|
+
]);
|
|
140
|
+
if (/accepting connections/i.test(result.stdout)) return;
|
|
141
|
+
lastError = new Error(`Unexpected PostgreSQL readiness response: ${result.stdout}`);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
lastError = error;
|
|
144
|
+
}
|
|
145
|
+
await sleep(Math.min(this.pollIntervalMs, Math.max(0, deadline - Date.now())));
|
|
146
|
+
}
|
|
147
|
+
throw new Error(
|
|
148
|
+
`PostgreSQL readiness timed out after ${this.startupTimeoutMs}ms${lastError ? `: ${errorMessage(lastError)}` : ""}`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
async cleanup() {
|
|
152
|
+
this.port = null;
|
|
153
|
+
this.started = false;
|
|
154
|
+
await this.runDocker(["rm", "--force", "--volumes", this.containerName]).catch(() => void 0);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var EphemeralRedis = class {
|
|
158
|
+
image;
|
|
159
|
+
host;
|
|
160
|
+
containerName;
|
|
161
|
+
startupTimeoutMs;
|
|
162
|
+
pollIntervalMs;
|
|
163
|
+
runDocker;
|
|
164
|
+
port = null;
|
|
165
|
+
started = false;
|
|
166
|
+
constructor(options = {}) {
|
|
167
|
+
const suffix = createSuffix();
|
|
168
|
+
this.image = options.image ?? DEFAULT_REDIS_IMAGE;
|
|
169
|
+
this.host = options.host ?? DEFAULT_HOST;
|
|
170
|
+
this.containerName = options.containerName ?? `moda-test-redis-${suffix}`;
|
|
171
|
+
this.startupTimeoutMs = options.startupTimeoutMs ?? DEFAULT_REDIS_STARTUP_TIMEOUT_MS;
|
|
172
|
+
this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
173
|
+
this.runDocker = options.runDocker ?? createDockerRunner(options.dockerBinary);
|
|
174
|
+
}
|
|
175
|
+
get url() {
|
|
176
|
+
const port = requireStarted(this.port, "Redis");
|
|
177
|
+
return `redis://${this.host}:${port}`;
|
|
178
|
+
}
|
|
179
|
+
get connectionDetails() {
|
|
180
|
+
return {
|
|
181
|
+
host: this.host,
|
|
182
|
+
port: requireStarted(this.port, "Redis"),
|
|
183
|
+
url: this.url,
|
|
184
|
+
containerName: this.containerName
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
async start() {
|
|
188
|
+
if (this.started) return this.connectionDetails;
|
|
189
|
+
try {
|
|
190
|
+
await this.runDocker([
|
|
191
|
+
"run",
|
|
192
|
+
"--detach",
|
|
193
|
+
"--name",
|
|
194
|
+
this.containerName,
|
|
195
|
+
"--publish",
|
|
196
|
+
"0:6379",
|
|
197
|
+
this.image
|
|
198
|
+
]);
|
|
199
|
+
const portResult = await this.runDocker(["port", this.containerName, "6379/tcp"]);
|
|
200
|
+
this.port = parseMappedPort(portResult.stdout, "Redis");
|
|
201
|
+
await this.waitForReady();
|
|
202
|
+
this.started = true;
|
|
203
|
+
return this.connectionDetails;
|
|
204
|
+
} catch (error) {
|
|
205
|
+
await this.cleanup();
|
|
206
|
+
throw new Error(
|
|
207
|
+
`Unable to start ephemeral Redis (${this.image}): ${errorMessage(error)}`,
|
|
208
|
+
{ cause: error }
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async waitForReady() {
|
|
213
|
+
const deadline = Date.now() + this.startupTimeoutMs;
|
|
214
|
+
let lastError;
|
|
215
|
+
while (Date.now() < deadline) {
|
|
216
|
+
try {
|
|
217
|
+
const result = await this.runDocker(["exec", this.containerName, "redis-cli", "ping"]);
|
|
218
|
+
if (result.stdout === "PONG") return;
|
|
219
|
+
lastError = new Error(`Unexpected Redis readiness response: ${result.stdout}`);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
lastError = error;
|
|
222
|
+
}
|
|
223
|
+
await sleep(Math.min(this.pollIntervalMs, Math.max(0, deadline - Date.now())));
|
|
224
|
+
}
|
|
225
|
+
throw new Error(
|
|
226
|
+
`Redis readiness timed out after ${this.startupTimeoutMs}ms${lastError ? `: ${errorMessage(lastError)}` : ""}`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
async cleanup() {
|
|
230
|
+
this.port = null;
|
|
231
|
+
this.started = false;
|
|
232
|
+
await this.runDocker(["rm", "--force", "--volumes", this.containerName]).catch(() => void 0);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
async function deployPrismaMigrations(options) {
|
|
236
|
+
const runCommand = options.runCommand ?? createCommandRunner();
|
|
237
|
+
await runCommand(
|
|
238
|
+
options.prismaBinary ?? "prisma",
|
|
239
|
+
["migrate", "deploy", "--schema", options.prismaSchemaPath],
|
|
240
|
+
{
|
|
241
|
+
cwd: options.cwd,
|
|
242
|
+
env: { ...process.env, DATABASE_URL: options.databaseUrl }
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
async function withDisposableIntegrationInfrastructure(options, callback) {
|
|
247
|
+
const postgres = new EphemeralPostgres(options.postgres);
|
|
248
|
+
const redis = new EphemeralRedis(options.redis);
|
|
249
|
+
try {
|
|
250
|
+
const postgresDetails = await postgres.start();
|
|
251
|
+
const redisDetails = await redis.start();
|
|
252
|
+
const environment = {
|
|
253
|
+
DATABASE_URL: postgresDetails.databaseUrl,
|
|
254
|
+
TEST_DATABASE_URL: postgresDetails.databaseUrl,
|
|
255
|
+
REDIS_URL: redisDetails.url,
|
|
256
|
+
TEST_REDIS_URL: redisDetails.url
|
|
257
|
+
};
|
|
258
|
+
const deployMigrations = options.deployMigrations ?? deployPrismaMigrations;
|
|
259
|
+
await deployMigrations({
|
|
260
|
+
databaseUrl: postgresDetails.databaseUrl,
|
|
261
|
+
prismaSchemaPath: options.prismaSchemaPath,
|
|
262
|
+
cwd: options.cwd,
|
|
263
|
+
prismaBinary: options.prismaBinary,
|
|
264
|
+
runCommand: options.runCommand
|
|
265
|
+
});
|
|
266
|
+
return await callback({
|
|
267
|
+
postgres: postgresDetails,
|
|
268
|
+
redis: redisDetails,
|
|
269
|
+
databaseUrl: postgresDetails.databaseUrl,
|
|
270
|
+
redisUrl: redisDetails.url,
|
|
271
|
+
environment
|
|
272
|
+
});
|
|
273
|
+
} finally {
|
|
274
|
+
await Promise.all([postgres.cleanup(), redis.cleanup()]);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function errorMessage(error) {
|
|
278
|
+
return error instanceof Error ? error.message : String(error);
|
|
279
|
+
}
|
|
280
|
+
export {
|
|
281
|
+
DEFAULT_COMMAND_TIMEOUT_MS,
|
|
282
|
+
DEFAULT_DOCKER_COMMAND_TIMEOUT_MS,
|
|
283
|
+
DEFAULT_HOST,
|
|
284
|
+
DEFAULT_POLL_INTERVAL_MS,
|
|
285
|
+
DEFAULT_POSTGRES_IMAGE,
|
|
286
|
+
DEFAULT_POSTGRES_STARTUP_TIMEOUT_MS,
|
|
287
|
+
DEFAULT_REDIS_IMAGE,
|
|
288
|
+
DEFAULT_REDIS_STARTUP_TIMEOUT_MS,
|
|
289
|
+
EphemeralPostgres,
|
|
290
|
+
EphemeralRedis,
|
|
291
|
+
createCommandRunner,
|
|
292
|
+
createDockerRunner,
|
|
293
|
+
deployPrismaMigrations,
|
|
294
|
+
withDisposableIntegrationInfrastructure
|
|
295
|
+
};
|
|
296
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/testing/node.ts"],"sourcesContent":["import { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { randomUUID } from \"node:crypto\";\n\nconst execFileAsync = promisify(execFile);\n\nexport const DEFAULT_POSTGRES_IMAGE = \"postgres:17.6-alpine\";\nexport const DEFAULT_REDIS_IMAGE = \"redis:7.4.2-alpine\";\nexport const DEFAULT_HOST = \"127.0.0.1\";\nexport const DEFAULT_POSTGRES_STARTUP_TIMEOUT_MS = 30_000;\nexport const DEFAULT_REDIS_STARTUP_TIMEOUT_MS = 15_000;\nexport const DEFAULT_POLL_INTERVAL_MS = 200;\nexport const DEFAULT_COMMAND_TIMEOUT_MS = 120_000;\nexport const DEFAULT_DOCKER_COMMAND_TIMEOUT_MS = 30_000;\n\nexport type CommandResult = {\n stdout: string;\n stderr: string;\n};\n\nexport type CommandOptions = {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n timeout?: number;\n killSignal?: NodeJS.Signals;\n};\n\nexport type CommandRunner = (\n command: string,\n args: readonly string[],\n options?: CommandOptions,\n) => Promise<CommandResult>;\n\nexport type DockerRunner = (\n args: readonly string[],\n options?: CommandOptions,\n) => Promise<CommandResult>;\n\nexport type DisposableEnvironment = {\n DATABASE_URL: string;\n TEST_DATABASE_URL: string;\n REDIS_URL: string;\n TEST_REDIS_URL: string;\n};\n\nexport type PostgresConnectionDetails = {\n host: string;\n port: number;\n database: string;\n user: string;\n password: string;\n databaseUrl: string;\n containerName: string;\n};\n\nexport type RedisConnectionDetails = {\n host: string;\n port: number;\n url: string;\n containerName: string;\n};\n\nexport type EphemeralPostgresOptions = {\n image?: string;\n host?: string;\n database?: string;\n user?: string;\n password?: string;\n containerName?: string;\n startupTimeoutMs?: number;\n pollIntervalMs?: number;\n dockerBinary?: string;\n runDocker?: DockerRunner;\n};\n\nexport type EphemeralRedisOptions = {\n image?: string;\n host?: string;\n containerName?: string;\n startupTimeoutMs?: number;\n pollIntervalMs?: number;\n dockerBinary?: string;\n runDocker?: DockerRunner;\n};\n\nexport type MigrationDeployOptions = {\n databaseUrl: string;\n prismaSchemaPath: string;\n cwd?: string;\n prismaBinary?: string;\n runCommand?: CommandRunner;\n};\n\nexport type DisposableIntegrationInfrastructureOptions = {\n prismaSchemaPath: string;\n cwd?: string;\n prismaBinary?: string;\n postgres?: EphemeralPostgresOptions;\n redis?: EphemeralRedisOptions;\n runCommand?: CommandRunner;\n deployMigrations?: (options: MigrationDeployOptions) => Promise<void>;\n};\n\nexport type DisposableIntegrationInfrastructure = {\n postgres: PostgresConnectionDetails;\n redis: RedisConnectionDetails;\n databaseUrl: string;\n redisUrl: string;\n environment: DisposableEnvironment;\n};\n\nexport type DisposableIntegrationCallback<T> = (\n infrastructure: DisposableIntegrationInfrastructure,\n) => Promise<T> | T;\n\nexport function createCommandRunner(binary = \"\"): CommandRunner {\n return async (command, args, options = {}) => {\n const executable = binary || command;\n const commandArgs = binary ? [command, ...args] : args;\n const result = await execFileAsync(executable, commandArgs, {\n encoding: \"utf8\",\n maxBuffer: 1024 * 1024,\n timeout: DEFAULT_COMMAND_TIMEOUT_MS,\n ...options,\n });\n return {\n stdout: result.stdout.trim(),\n stderr: result.stderr.trim(),\n };\n };\n}\n\nexport function createDockerRunner(dockerBinary = \"docker\"): DockerRunner {\n const runCommand = createCommandRunner();\n return (args, options = {}) =>\n runCommand(dockerBinary, args, {\n ...options,\n timeout: options.timeout ?? DEFAULT_DOCKER_COMMAND_TIMEOUT_MS,\n });\n}\n\nfunction parseMappedPort(output: string, serviceName: string): number {\n const match = output.match(/:(\\d+)\\s*$/m);\n if (!match) {\n throw new Error(`Docker did not return a mapped ${serviceName} port: ${output}`);\n }\n return Number(match[1]);\n}\n\nfunction sleep(milliseconds: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, milliseconds));\n}\n\nfunction createSuffix(): string {\n return randomUUID().replaceAll(\"-\", \"\");\n}\n\nfunction requireStarted<T>(value: T | null, serviceName: string): T {\n if (value === null) {\n throw new Error(`Ephemeral ${serviceName} has not been started`);\n }\n return value;\n}\n\nexport class EphemeralPostgres {\n private readonly image: string;\n private readonly host: string;\n private readonly database: string;\n private readonly user: string;\n private readonly password: string;\n private readonly containerName: string;\n private readonly startupTimeoutMs: number;\n private readonly pollIntervalMs: number;\n private readonly runDocker: DockerRunner;\n private port: number | null = null;\n private started = false;\n\n constructor(options: EphemeralPostgresOptions = {}) {\n const suffix = createSuffix();\n this.image = options.image ?? DEFAULT_POSTGRES_IMAGE;\n this.host = options.host ?? DEFAULT_HOST;\n this.database = options.database ?? `moda_test_${suffix.slice(0, 12)}`;\n this.user = options.user ?? `moda_test_${suffix.slice(0, 12)}`;\n this.password = options.password ?? `test_${suffix}`;\n this.containerName = options.containerName ?? `moda-test-postgres-${suffix}`;\n this.startupTimeoutMs = options.startupTimeoutMs ?? DEFAULT_POSTGRES_STARTUP_TIMEOUT_MS;\n this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n this.runDocker = options.runDocker ?? createDockerRunner(options.dockerBinary);\n }\n\n get databaseUrl(): string {\n const port = requireStarted(this.port, \"PostgreSQL\");\n return `postgresql://${this.user}:${this.password}@${this.host}:${port}/${this.database}`;\n }\n\n get connectionDetails(): PostgresConnectionDetails {\n return {\n host: this.host,\n port: requireStarted(this.port, \"PostgreSQL\"),\n database: this.database,\n user: this.user,\n password: this.password,\n databaseUrl: this.databaseUrl,\n containerName: this.containerName,\n };\n }\n\n async start(): Promise<PostgresConnectionDetails> {\n if (this.started) return this.connectionDetails;\n\n try {\n await this.runDocker([\n \"run\",\n \"--detach\",\n \"--name\",\n this.containerName,\n \"--env\",\n `POSTGRES_DB=${this.database}`,\n \"--env\",\n `POSTGRES_USER=${this.user}`,\n \"--env\",\n `POSTGRES_PASSWORD=${this.password}`,\n \"--publish\",\n \"0:5432\",\n this.image,\n ]);\n const portResult = await this.runDocker([\"port\", this.containerName, \"5432/tcp\"]);\n this.port = parseMappedPort(portResult.stdout, \"PostgreSQL\");\n await this.waitForReady();\n this.started = true;\n return this.connectionDetails;\n } catch (error) {\n await this.cleanup();\n throw new Error(\n `Unable to start ephemeral PostgreSQL (${this.image}): ${errorMessage(error)}`,\n { cause: error },\n );\n }\n }\n\n async waitForReady(): Promise<void> {\n const deadline = Date.now() + this.startupTimeoutMs;\n let lastError: unknown;\n\n while (Date.now() < deadline) {\n try {\n const result = await this.runDocker([\n \"exec\",\n this.containerName,\n \"pg_isready\",\n \"--username\",\n this.user,\n \"--dbname\",\n this.database,\n ]);\n if (/accepting connections/i.test(result.stdout)) return;\n lastError = new Error(`Unexpected PostgreSQL readiness response: ${result.stdout}`);\n } catch (error) {\n lastError = error;\n }\n await sleep(Math.min(this.pollIntervalMs, Math.max(0, deadline - Date.now())));\n }\n\n throw new Error(\n `PostgreSQL readiness timed out after ${this.startupTimeoutMs}ms${lastError ? `: ${errorMessage(lastError)}` : \"\"}`,\n );\n }\n\n async cleanup(): Promise<void> {\n this.port = null;\n this.started = false;\n await this.runDocker([\"rm\", \"--force\", \"--volumes\", this.containerName]).catch(() => undefined);\n }\n}\n\nexport class EphemeralRedis {\n private readonly image: string;\n private readonly host: string;\n private readonly containerName: string;\n private readonly startupTimeoutMs: number;\n private readonly pollIntervalMs: number;\n private readonly runDocker: DockerRunner;\n private port: number | null = null;\n private started = false;\n\n constructor(options: EphemeralRedisOptions = {}) {\n const suffix = createSuffix();\n this.image = options.image ?? DEFAULT_REDIS_IMAGE;\n this.host = options.host ?? DEFAULT_HOST;\n this.containerName = options.containerName ?? `moda-test-redis-${suffix}`;\n this.startupTimeoutMs = options.startupTimeoutMs ?? DEFAULT_REDIS_STARTUP_TIMEOUT_MS;\n this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n this.runDocker = options.runDocker ?? createDockerRunner(options.dockerBinary);\n }\n\n get url(): string {\n const port = requireStarted(this.port, \"Redis\");\n return `redis://${this.host}:${port}`;\n }\n\n get connectionDetails(): RedisConnectionDetails {\n return {\n host: this.host,\n port: requireStarted(this.port, \"Redis\"),\n url: this.url,\n containerName: this.containerName,\n };\n }\n\n async start(): Promise<RedisConnectionDetails> {\n if (this.started) return this.connectionDetails;\n\n try {\n await this.runDocker([\n \"run\",\n \"--detach\",\n \"--name\",\n this.containerName,\n \"--publish\",\n \"0:6379\",\n this.image,\n ]);\n const portResult = await this.runDocker([\"port\", this.containerName, \"6379/tcp\"]);\n this.port = parseMappedPort(portResult.stdout, \"Redis\");\n await this.waitForReady();\n this.started = true;\n return this.connectionDetails;\n } catch (error) {\n await this.cleanup();\n throw new Error(\n `Unable to start ephemeral Redis (${this.image}): ${errorMessage(error)}`,\n { cause: error },\n );\n }\n }\n\n async waitForReady(): Promise<void> {\n const deadline = Date.now() + this.startupTimeoutMs;\n let lastError: unknown;\n\n while (Date.now() < deadline) {\n try {\n const result = await this.runDocker([\"exec\", this.containerName, \"redis-cli\", \"ping\"]);\n if (result.stdout === \"PONG\") return;\n lastError = new Error(`Unexpected Redis readiness response: ${result.stdout}`);\n } catch (error) {\n lastError = error;\n }\n await sleep(Math.min(this.pollIntervalMs, Math.max(0, deadline - Date.now())));\n }\n\n throw new Error(\n `Redis readiness timed out after ${this.startupTimeoutMs}ms${lastError ? `: ${errorMessage(lastError)}` : \"\"}`,\n );\n }\n\n async cleanup(): Promise<void> {\n this.port = null;\n this.started = false;\n await this.runDocker([\"rm\", \"--force\", \"--volumes\", this.containerName]).catch(() => undefined);\n }\n}\n\nexport async function deployPrismaMigrations(options: MigrationDeployOptions): Promise<void> {\n const runCommand = options.runCommand ?? createCommandRunner();\n await runCommand(\n options.prismaBinary ?? \"prisma\",\n [\"migrate\", \"deploy\", \"--schema\", options.prismaSchemaPath],\n {\n cwd: options.cwd,\n env: { ...process.env, DATABASE_URL: options.databaseUrl },\n },\n );\n}\n\nexport async function withDisposableIntegrationInfrastructure<T>(\n options: DisposableIntegrationInfrastructureOptions,\n callback: DisposableIntegrationCallback<T>,\n): Promise<T> {\n const postgres = new EphemeralPostgres(options.postgres);\n const redis = new EphemeralRedis(options.redis);\n\n try {\n const postgresDetails = await postgres.start();\n const redisDetails = await redis.start();\n const environment: DisposableEnvironment = {\n DATABASE_URL: postgresDetails.databaseUrl,\n TEST_DATABASE_URL: postgresDetails.databaseUrl,\n REDIS_URL: redisDetails.url,\n TEST_REDIS_URL: redisDetails.url,\n };\n const deployMigrations = options.deployMigrations ?? deployPrismaMigrations;\n await deployMigrations({\n databaseUrl: postgresDetails.databaseUrl,\n prismaSchemaPath: options.prismaSchemaPath,\n cwd: options.cwd,\n prismaBinary: options.prismaBinary,\n runCommand: options.runCommand,\n });\n return await callback({\n postgres: postgresDetails,\n redis: redisDetails,\n databaseUrl: postgresDetails.databaseUrl,\n redisUrl: redisDetails.url,\n environment,\n });\n } finally {\n await Promise.all([postgres.cleanup(), redis.cleanup()]);\n }\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}"],"mappings":";AAA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AU,YAAY,QAAQ,gBAAgB;AAAA,IAC1D;AAAA,MACE,KAAK,QAAQ;AAAA,MACb,KAAK,EAAE,GAAG,QAAQ,KAAK,cAAc,QAAQ,YAAY;AAAA,IAC3D;AAAA,EACF;AACF;AAEA,eAAsB,wCACpB,SACA,UACY;AACZ,QAAM,WAAW,IAAI,kBAAkB,QAAQ,QAAQ;AACvD,QAAM,QAAQ,IAAI,eAAe,QAAQ,KAAK;AAE9C,MAAI;AACF,UAAM,kBAAkB,MAAM,SAAS,MAAM;AAC7C,UAAM,eAAe,MAAM,MAAM,MAAM;AACvC,UAAM,cAAqC;AAAA,MACzC,cAAc,gBAAgB;AAAA,MAC9B,mBAAmB,gBAAgB;AAAA,MACnC,WAAW,aAAa;AAAA,MACxB,gBAAgB,aAAa;AAAA,IAC/B;AACA,UAAM,mBAAmB,QAAQ,oBAAoB;AACrD,UAAM,iBAAiB;AAAA,MACrB,aAAa,gBAAgB;AAAA,MAC7B,kBAAkB,QAAQ;AAAA,MAC1B,KAAK,QAAQ;AAAA,MACb,cAAc,QAAQ;AAAA,MACtB,YAAY,QAAQ;AAAA,IACtB,CAAC;AACD,WAAO,MAAM,SAAS;AAAA,MACpB,UAAU;AAAA,MACV,OAAO;AAAA,MACP,aAAa,gBAAgB;AAAA,MAC7B,UAAU,aAAa;AAAA,MACvB;AAAA,IACF,CAAC;AAAA,EACH,UAAE;AACA,UAAM,QAAQ,IAAI,CAAC,SAAS,QAAQ,GAAG,MAAM,QAAQ,CAAC,CAAC;AAAA,EACzD;AACF;AAEA,SAAS,aAAa,OAAwB;AAC5C,SAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modainteract/moda-interact-shared",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./dist/internationalization.d.ts",
|
|
17
17
|
"import": "./dist/internationalization.js"
|
|
18
18
|
},
|
|
19
|
+
"./billing": {
|
|
20
|
+
"types": "./dist/billing.d.ts",
|
|
21
|
+
"import": "./dist/billing.js"
|
|
22
|
+
},
|
|
19
23
|
"./merchant-communications": {
|
|
20
24
|
"types": "./dist/merchant-communications.d.ts",
|
|
21
25
|
"import": "./dist/merchant-communications.js"
|
|
@@ -24,6 +28,10 @@
|
|
|
24
28
|
"types": "./dist/merchant-communications/node.d.ts",
|
|
25
29
|
"import": "./dist/merchant-communications/node.js"
|
|
26
30
|
},
|
|
31
|
+
"./testing/node": {
|
|
32
|
+
"types": "./dist/testing/node.d.ts",
|
|
33
|
+
"import": "./dist/testing/node.js"
|
|
34
|
+
},
|
|
27
35
|
"./shopify": {
|
|
28
36
|
"types": "./dist/shopify/index.d.ts",
|
|
29
37
|
"import": "./dist/shopify/index.js"
|
|
@@ -66,6 +74,8 @@
|
|
|
66
74
|
"test": "tsx --test \"src/**/*.test.ts\"",
|
|
67
75
|
"validate:internationalization-entrypoint": "npm run build && node scripts/validate-internationalization-entrypoint.mjs",
|
|
68
76
|
"validate:merchant-communications-node": "npm run build && node scripts/validate-merchant-communications-node.mjs",
|
|
77
|
+
"validate:testing-node": "npm run build && node scripts/validate-testing-node.mjs",
|
|
78
|
+
"validate:testing-node-live": "npm run build && node scripts/validate-testing-node-live.mjs",
|
|
69
79
|
"prepack": "npm run build"
|
|
70
80
|
},
|
|
71
81
|
"dependencies": {
|