@replohq/canopy-sdk 3.0.6 → 3.0.7
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/_vendor/replo-utils/lib/crypto.d.ts +8 -0
- package/_vendor/replo-utils/lib/fonts.mjs +2 -3
- package/_vendor/replo-utils/lib/geometry.mjs +0 -2
- package/_vendor/replo-utils/lib/json.d.ts +0 -4
- package/_vendor/replo-utils/lib/json.mjs +1 -4
- package/_vendor/replo-utils/lib/misc.mjs +2 -4
- package/_vendor/replo-utils/lib/posthogReplay.mjs +0 -2
- package/_vendor/replo-utils/lib/string.d.ts +0 -12
- package/_vendor/replo-utils/lib/url.d.ts +10 -3
- package/_vendor/replo-utils/lib/url.mjs +3 -4
- package/_vendor/replo-utils/react/use-iframe-rpc-channel.mjs +0 -1
- package/_vendor/schemas/agentBillingFeatureType.d.ts +1 -0
- package/_vendor/schemas/comments.d.ts +932 -0
- package/_vendor/schemas/designLibrary.d.ts +1 -1
- package/_vendor/schemas/designLibrary.mjs +72 -73
- package/_vendor/schemas/errors.d.ts +36 -45
- package/_vendor/schemas/generated/comments.d.ts +244 -0
- package/_vendor/schemas/generated/consent.d.ts +43 -2
- package/_vendor/schemas/generated/errors.d.ts +1 -0
- package/_vendor/schemas/generated/selectMode.d.ts +3 -1
- package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +43 -0
- package/_vendor/schemas/iframeRpcChannel.d.ts +13 -1
- package/_vendor/schemas/iframeRpcChannel.mjs +167 -8
- package/_vendor/schemas/loaderKeys.mjs +0 -2
- package/_vendor/schemas/{money.d.ts → moneyFormat.d.ts} +11 -9
- package/_vendor/schemas/moneyFormat.mjs +119 -0
- package/_vendor/schemas/pageAnnotations.d.ts +1 -1
- package/_vendor/schemas/pageAnnotations.mjs +1 -2
- package/_vendor/schemas/reploError.d.ts +43 -0
- package/_vendor/schemas/routing/match.mjs +0 -1
- package/_vendor/schemas/routing/rules.d.ts +2 -2
- package/_vendor/schemas/routing/rules.mjs +5 -8
- package/_vendor/schemas/savedStyles.d.ts +1 -1
- package/_vendor/schemas/selectMode.d.ts +117 -4
- package/_vendor/schemas/selectMode.mjs +4 -6
- package/_vendor/schemas/selectModeIframeRpc.d.ts +373 -1
- package/_vendor/schemas/selectModeIframeRpc.mjs +77 -9
- package/chunk-B7XDEXPL.mjs +19 -0
- package/chunk-CJIK4NVP.mjs +547 -0
- package/chunk-DINTPZM2.mjs +71 -0
- package/{chunk-AKZNN7F2.mjs → chunk-IQCJXNJU.mjs} +1 -1
- package/{chunk-EXI4VDHP.mjs → chunk-PQEA6P4V.mjs} +20 -3
- package/{chunk-DINXH6YP.mjs → chunk-YGLYUC6R.mjs} +18 -7
- package/money.d.ts +1 -1
- package/package.json +2 -2
- package/_vendor/replo-utils/lib/object.d.ts +0 -31
- package/_vendor/schemas/money.mjs +0 -1937
- package/chunk-HGXQNZW7.mjs +0 -38
- package/chunk-ILGEM42C.mjs +0 -21
- package/chunk-RLFL66ST.mjs +0 -242
- package/chunk-UJCSKKID.mjs +0 -23
- package/chunk-VUXOGD76.mjs +0 -206
- /package/{chunk-FNTGY7I5.mjs → chunk-JELVREEB.mjs} +0 -0
|
@@ -9,6 +9,49 @@ export type IframeRuntimeBuildMetadata = {
|
|
|
9
9
|
branch: string | null;
|
|
10
10
|
commit: string | null;
|
|
11
11
|
builtAt: string | null;
|
|
12
|
+
capabilities?: string[];
|
|
13
|
+
};
|
|
14
|
+
export type SectionCanvasSection = {
|
|
15
|
+
index: number;
|
|
16
|
+
startLine: number;
|
|
17
|
+
endLine: number;
|
|
18
|
+
label: string;
|
|
19
|
+
isLocked: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type SectionCanvasState = {
|
|
22
|
+
pageFilePath: string;
|
|
23
|
+
sections: SectionCanvasSection[];
|
|
24
|
+
previewScale: number;
|
|
25
|
+
isDisabled: boolean;
|
|
26
|
+
insertingAt?: number | null;
|
|
27
|
+
occludedInsets?: {
|
|
28
|
+
left: number;
|
|
29
|
+
right: number;
|
|
30
|
+
} | null;
|
|
31
|
+
};
|
|
32
|
+
export type SectionCanvasRequest = {
|
|
33
|
+
type: "insert";
|
|
34
|
+
at: number;
|
|
35
|
+
} | {
|
|
36
|
+
type: "move";
|
|
37
|
+
moveId: string;
|
|
38
|
+
index: number;
|
|
39
|
+
to: number;
|
|
40
|
+
} | {
|
|
41
|
+
type: "remove";
|
|
42
|
+
index: number;
|
|
43
|
+
} | {
|
|
44
|
+
type: "undo";
|
|
45
|
+
} | {
|
|
46
|
+
type: "redo";
|
|
47
|
+
} | {
|
|
48
|
+
type: "cancelInsert";
|
|
49
|
+
};
|
|
50
|
+
export type SectionCanvasLayoutEntry = {
|
|
51
|
+
index: number;
|
|
52
|
+
startLine: number;
|
|
53
|
+
endLine: number;
|
|
54
|
+
rect: SelectModeBoundingRect;
|
|
12
55
|
};
|
|
13
56
|
export type SelectModeParentMessage = {
|
|
14
57
|
method: "expandToSection";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from "zod";
|
|
2
2
|
export type IframeRpcChannelMethodConfig = Record<string, {
|
|
3
3
|
inputSchema: z.ZodType;
|
|
4
4
|
outputSchema: z.ZodType;
|
|
@@ -50,6 +50,11 @@ type SubscriberWindow = {
|
|
|
50
50
|
type TargetIframeWindow = {
|
|
51
51
|
postMessage: (message: unknown, targetOrigin: string) => void;
|
|
52
52
|
};
|
|
53
|
+
export type IframeRpcVersionMismatch = {
|
|
54
|
+
channelIdentifier: string;
|
|
55
|
+
ownVersion: number;
|
|
56
|
+
peerVersion: number;
|
|
57
|
+
};
|
|
53
58
|
type IframeRpcChannelOptions<OutgoingMethods extends IframeRpcChannelMethodConfig, IncomingMethods extends IframeRpcChannelMethodConfig> = {
|
|
54
59
|
subscriberWindow: SubscriberWindow;
|
|
55
60
|
channelIdentifier: string;
|
|
@@ -60,6 +65,13 @@ type IframeRpcChannelOptions<OutgoingMethods extends IframeRpcChannelMethodConfi
|
|
|
60
65
|
outgoingMethods: OutgoingMethods;
|
|
61
66
|
incomingMethods: IncomingMethods;
|
|
62
67
|
handlers: IframeRpcChannelHandlers<IncomingMethods, OutgoingMethods>;
|
|
68
|
+
/**
|
|
69
|
+
* Called for every message from the expected peer on another version of
|
|
70
|
+
* this channel. The message itself is dropped: neither side can parse the
|
|
71
|
+
* other's protocol, so recovering (e.g. reloading the older side) is the
|
|
72
|
+
* caller's job.
|
|
73
|
+
*/
|
|
74
|
+
onPeerVersionMismatch?: (mismatch: IframeRpcVersionMismatch) => void;
|
|
63
75
|
};
|
|
64
76
|
export type IframeRpcChannel<OutgoingMethods extends IframeRpcChannelMethodConfig = IframeRpcChannelMethodConfig> = {
|
|
65
77
|
subscribe: () => () => void;
|
|
@@ -1,15 +1,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isNullish } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '
|
|
5
|
-
import '../../chunk-UJCSKKID.mjs';
|
|
6
|
-
import { z } from 'zod';
|
|
1
|
+
import { randomUUID, ReploError } from '../../chunk-DINTPZM2.mjs';
|
|
2
|
+
import { isNullish } from '../../chunk-PQEA6P4V.mjs';
|
|
3
|
+
import '../../chunk-JELVREEB.mjs';
|
|
4
|
+
import * as z from 'zod';
|
|
7
5
|
|
|
8
6
|
var defaultLogger = {
|
|
9
7
|
info: console.log,
|
|
10
8
|
debug: console.debug,
|
|
11
9
|
error: console.error
|
|
12
10
|
};
|
|
11
|
+
|
|
12
|
+
var FEATURE_TYPES = [
|
|
13
|
+
"credits",
|
|
14
|
+
"shopifyThemeBuilder.publishedElements",
|
|
15
|
+
"sites",
|
|
16
|
+
"shopifyThemeBuilder.projects"
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
var errorUserFacingDetailsMessageSchema = z.object({
|
|
20
|
+
type: z.enum([
|
|
21
|
+
"toast",
|
|
22
|
+
"fullPageModal",
|
|
23
|
+
"shopifyStorePassword",
|
|
24
|
+
"billing.addPublishedElements",
|
|
25
|
+
"billing.addShopifyThemeProject",
|
|
26
|
+
"billing.addReploSite",
|
|
27
|
+
"agentBilling.shopifyThemeBuilder.publishedElements.exceeded",
|
|
28
|
+
"agentBilling.shopifyThemeBuilder.projects.exceeded",
|
|
29
|
+
"agentBilling.sites.exceeded",
|
|
30
|
+
"agentBilling.credits.exceeded",
|
|
31
|
+
"agentBilling.upgradeRequired"
|
|
32
|
+
]),
|
|
33
|
+
message: z.string(),
|
|
34
|
+
isRecoverable: z.boolean().optional(),
|
|
35
|
+
detail: z.array(z.string()).or(z.string()).optional(),
|
|
36
|
+
key: z.string(),
|
|
37
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
38
|
+
usage: z.object({
|
|
39
|
+
current: z.number(),
|
|
40
|
+
maximum: z.number()
|
|
41
|
+
}).optional(),
|
|
42
|
+
plan: z.string().optional(),
|
|
43
|
+
featureType: z.enum(FEATURE_TYPES).optional().catch(void 0),
|
|
44
|
+
callToAction: z.discriminatedUnion("type", [
|
|
45
|
+
z.object({ type: z.literal("reload") }),
|
|
46
|
+
z.object({ type: z.literal("installApp") }),
|
|
47
|
+
z.object({ type: z.literal("goToHomepage") }),
|
|
48
|
+
z.object({ type: z.literal("navigateToProjectEditor") }),
|
|
49
|
+
z.object({ type: z.literal("closeModal") }),
|
|
50
|
+
z.object({
|
|
51
|
+
type: z.literal("navigateToLink"),
|
|
52
|
+
link: z.discriminatedUnion("type", [
|
|
53
|
+
z.object({ type: z.literal("errors.wrongJsonExtension") }),
|
|
54
|
+
z.object({ type: z.literal("errors.chunkingError") }),
|
|
55
|
+
z.object({ type: z.literal("errors.indexBackupError") }),
|
|
56
|
+
z.object({
|
|
57
|
+
type: z.literal("errors.shopifyIntegrationAlreadyAssigned")
|
|
58
|
+
}),
|
|
59
|
+
z.object({
|
|
60
|
+
type: z.literal("errors.shopifyIntegrationMissingAccessScopes"),
|
|
61
|
+
url: z.string()
|
|
62
|
+
}),
|
|
63
|
+
z.object({
|
|
64
|
+
type: z.literal("customLink"),
|
|
65
|
+
url: z.string()
|
|
66
|
+
}),
|
|
67
|
+
z.object({
|
|
68
|
+
type: z.literal(
|
|
69
|
+
"errors.projectConnectedToBillingIntegrationForShopifyWorkspace"
|
|
70
|
+
)
|
|
71
|
+
}),
|
|
72
|
+
z.object({ type: z.literal("errors.themeAssetSizeLimitExceeded") }),
|
|
73
|
+
z.object({ type: z.literal("errors.themeTotalSizeLimitExceeded") }),
|
|
74
|
+
z.object({
|
|
75
|
+
type: z.literal("errors.pageMetafieldDefinitionsChanged")
|
|
76
|
+
}),
|
|
77
|
+
z.object({ type: z.literal("settings.billing") })
|
|
78
|
+
])
|
|
79
|
+
})
|
|
80
|
+
]).optional()
|
|
81
|
+
}).describe("ErrorUserFacingDetailsWithMessage");
|
|
82
|
+
z.discriminatedUnion("type", [
|
|
83
|
+
errorUserFacingDetailsMessageSchema,
|
|
84
|
+
z.object({
|
|
85
|
+
type: z.literal("uncommon_none"),
|
|
86
|
+
key: z.string(),
|
|
87
|
+
usage: z.object({
|
|
88
|
+
current: z.number(),
|
|
89
|
+
maximum: z.number()
|
|
90
|
+
}).optional(),
|
|
91
|
+
message: z.string().optional(),
|
|
92
|
+
isRecoverable: z.boolean().optional(),
|
|
93
|
+
detail: z.array(z.string()).or(z.string()).optional()
|
|
94
|
+
})
|
|
95
|
+
]).describe("ErrorUserFacingDetails");
|
|
96
|
+
var IframeRpcChannelError = class extends ReploError {
|
|
97
|
+
};
|
|
98
|
+
var IframeRpcChannelTimeoutError = class extends IframeRpcChannelError {
|
|
99
|
+
constructor({ method, timeoutMs }) {
|
|
100
|
+
super({
|
|
101
|
+
message: `RPC method '${method}' timed out after ${timeoutMs}ms`,
|
|
102
|
+
additionalData: { method, timeoutMs }
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var IframeRpcChannelTargetUnavailableError = class extends IframeRpcChannelError {
|
|
107
|
+
constructor({
|
|
108
|
+
callType,
|
|
109
|
+
method
|
|
110
|
+
}) {
|
|
111
|
+
super({
|
|
112
|
+
message: method ? `RPC target window was unavailable for '${method}'` : "RPC target window was unavailable for a response",
|
|
113
|
+
additionalData: { callType, method }
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var IframeRpcChannelRemoteError = class extends IframeRpcChannelError {
|
|
118
|
+
constructor({ method, message }) {
|
|
119
|
+
super({
|
|
120
|
+
message: `RPC method '${method}' failed: ${message}`,
|
|
121
|
+
additionalData: { method }
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var IframeRpcChannelUnsubscribedError = class extends IframeRpcChannelError {
|
|
126
|
+
constructor({ method }) {
|
|
127
|
+
super({
|
|
128
|
+
message: `RPC was unsubscribed while '${method}' was pending`,
|
|
129
|
+
additionalData: { method }
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var IframeRpcChannelUnknownMethodError = class extends IframeRpcChannelError {
|
|
134
|
+
constructor({ method }) {
|
|
135
|
+
super({
|
|
136
|
+
message: `Unknown RPC method '${method}'`,
|
|
137
|
+
additionalData: { method }
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var IframeRpcChannelConfigurationError = class extends IframeRpcChannelError {
|
|
142
|
+
constructor({ message }) {
|
|
143
|
+
super({ message });
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var IframeRpcChannelInvalidInputError = class extends IframeRpcChannelError {
|
|
147
|
+
constructor({ method, cause }) {
|
|
148
|
+
super({
|
|
149
|
+
message: `Invalid RPC input for '${method}': ${cause.message}`,
|
|
150
|
+
cause,
|
|
151
|
+
additionalData: { method }
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
13
156
|
var iframeRpcCallResultSchema = z.discriminatedUnion("type", [
|
|
14
157
|
z.object({
|
|
15
158
|
type: z.literal("success"),
|
|
@@ -97,7 +240,8 @@ function createIframeRpcChannel(options) {
|
|
|
97
240
|
isExpectedMessage,
|
|
98
241
|
outgoingMethods,
|
|
99
242
|
incomingMethods,
|
|
100
|
-
handlers
|
|
243
|
+
handlers,
|
|
244
|
+
onPeerVersionMismatch
|
|
101
245
|
} = options;
|
|
102
246
|
const pendingRequests = /* @__PURE__ */ new Map();
|
|
103
247
|
let subscriberCount = 0;
|
|
@@ -225,12 +369,18 @@ function createIframeRpcChannel(options) {
|
|
|
225
369
|
const handleMessage = (event) => {
|
|
226
370
|
const parsedMetadata = z.object({
|
|
227
371
|
channelIdentifier: z.literal(channelIdentifier),
|
|
228
|
-
version: z.
|
|
372
|
+
version: z.number()
|
|
229
373
|
}).safeParse(event.data);
|
|
230
374
|
if (!parsedMetadata.success) {
|
|
231
375
|
return;
|
|
232
376
|
}
|
|
233
377
|
if (!isExpectedMessage(event)) {
|
|
378
|
+
const isSiblingFrame = typeof document !== "undefined" && Array.from(document.querySelectorAll("iframe")).some((frame) => {
|
|
379
|
+
return event.source !== null && frame.contentWindow === event.source;
|
|
380
|
+
});
|
|
381
|
+
if (isSiblingFrame) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
234
384
|
defaultLogger.error("[iframeRpcChannel] Dropping unexpected message", {
|
|
235
385
|
channelIdentifier,
|
|
236
386
|
version,
|
|
@@ -239,6 +389,15 @@ function createIframeRpcChannel(options) {
|
|
|
239
389
|
});
|
|
240
390
|
return;
|
|
241
391
|
}
|
|
392
|
+
const peerVersion = parsedMetadata.data.version;
|
|
393
|
+
if (peerVersion !== version) {
|
|
394
|
+
onPeerVersionMismatch?.({
|
|
395
|
+
channelIdentifier,
|
|
396
|
+
ownVersion: version,
|
|
397
|
+
peerVersion
|
|
398
|
+
});
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
242
401
|
const parsedCall = iframeRpcCallSchema.safeParse(event.data);
|
|
243
402
|
if (!parsedCall.success) {
|
|
244
403
|
return;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import '../../chunk-UJCSKKID.mjs';
|
|
2
|
-
|
|
3
1
|
var migrationCommand = `pnpm add @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove canopy-sdk
|
|
4
2
|
(if package.json lists "@replohq/canopy-sdk" instead of the "canopy-sdk" alias, run: pnpm remove @replohq/canopy-sdk)`;
|
|
5
3
|
var providerComposition = `import { ReploProvider } from "@replohq/sdk/providers/replo-provider";
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReploError } from "./errors";
|
|
1
|
+
import { ReploError } from "./reploError";
|
|
3
2
|
export declare class InvalidAmountError extends ReploError {
|
|
4
3
|
}
|
|
5
4
|
export declare class UnsupportedCurrencyError extends ReploError {
|
|
6
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* True for currencies where Stripe deliberately differs from ISO — e.g. ISO
|
|
8
|
+
* calls IQD/LYD 3-decimal and ISK/UGX 0-decimal, but Stripe treats all four as
|
|
9
|
+
* 2-decimal (and MGA/MRU are ÷5, not decimal at all). Check it before sending
|
|
10
|
+
* minor units to Stripe, so a wrong-exponent amount can never be charged. When
|
|
11
|
+
* we launch one of these for Replo checkout, add a Stripe-verified override.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stripeExponentDiffersFromIso(currencyCode: string): boolean;
|
|
14
|
+
export declare function assertStripeExponentMatchesIso(currencyCode: string): void;
|
|
7
15
|
/**
|
|
8
16
|
* Converts a decimal major-unit amount (e.g. "19.99", 19.99) into integer
|
|
9
|
-
* minor units (1999) using the currency's
|
|
17
|
+
* minor units (1999) using the currency's ISO-4217 exponent. Half-away-from-zero
|
|
10
18
|
* rounding for the non-negative amounts this domain uses (prices, totals),
|
|
11
19
|
* matching Stripe. Throws on non-numeric input.
|
|
12
20
|
*/
|
|
@@ -52,9 +60,3 @@ export declare function formatAmount({ amount, currencyCode, locale, }: {
|
|
|
52
60
|
currencyCode: string;
|
|
53
61
|
locale?: string;
|
|
54
62
|
}): string;
|
|
55
|
-
export declare const amountSchema: z.ZodNumber;
|
|
56
|
-
/** An amount in minor units paired with its ISO 4217 currency code. */
|
|
57
|
-
export declare const amountWithCurrencyCodeSchema: z.ZodObject<{
|
|
58
|
-
amount: z.ZodNumber;
|
|
59
|
-
currencyCode: z.ZodString;
|
|
60
|
-
}, z.core.$strip>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ReploError } from '../../chunk-DINTPZM2.mjs';
|
|
2
|
+
|
|
3
|
+
var InvalidAmountError = class extends ReploError {
|
|
4
|
+
};
|
|
5
|
+
var UnsupportedCurrencyError = class extends ReploError {
|
|
6
|
+
};
|
|
7
|
+
var STRIPE_EXPONENT_MISMATCH_CURRENCIES = /* @__PURE__ */ new Set([
|
|
8
|
+
"ISK",
|
|
9
|
+
"UGX",
|
|
10
|
+
"IQD",
|
|
11
|
+
"LYD",
|
|
12
|
+
"MGA",
|
|
13
|
+
"MRU"
|
|
14
|
+
]);
|
|
15
|
+
function stripeExponentDiffersFromIso(currencyCode) {
|
|
16
|
+
return STRIPE_EXPONENT_MISMATCH_CURRENCIES.has(currencyCode.toUpperCase());
|
|
17
|
+
}
|
|
18
|
+
function assertStripeExponentMatchesIso(currencyCode) {
|
|
19
|
+
if (stripeExponentDiffersFromIso(currencyCode)) {
|
|
20
|
+
throw new UnsupportedCurrencyError({
|
|
21
|
+
message: "Currency's ISO minor-unit exponent differs from Stripe's; not supported",
|
|
22
|
+
additionalData: { currencyCode: currencyCode.toUpperCase() }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
var NON_TWO_DIGIT_MINOR_UNIT_EXPONENTS = {
|
|
27
|
+
BIF: 0,
|
|
28
|
+
CLP: 0,
|
|
29
|
+
DJF: 0,
|
|
30
|
+
GNF: 0,
|
|
31
|
+
ISK: 0,
|
|
32
|
+
JPY: 0,
|
|
33
|
+
KMF: 0,
|
|
34
|
+
KRW: 0,
|
|
35
|
+
PYG: 0,
|
|
36
|
+
RWF: 0,
|
|
37
|
+
UGX: 0,
|
|
38
|
+
UYI: 0,
|
|
39
|
+
VND: 0,
|
|
40
|
+
VUV: 0,
|
|
41
|
+
XAF: 0,
|
|
42
|
+
XAG: 0,
|
|
43
|
+
XAU: 0,
|
|
44
|
+
XBA: 0,
|
|
45
|
+
XBB: 0,
|
|
46
|
+
XBC: 0,
|
|
47
|
+
XBD: 0,
|
|
48
|
+
XDR: 0,
|
|
49
|
+
XOF: 0,
|
|
50
|
+
XPD: 0,
|
|
51
|
+
XPF: 0,
|
|
52
|
+
XPT: 0,
|
|
53
|
+
XSU: 0,
|
|
54
|
+
XTS: 0,
|
|
55
|
+
XUA: 0,
|
|
56
|
+
XXX: 0,
|
|
57
|
+
BHD: 3,
|
|
58
|
+
IQD: 3,
|
|
59
|
+
JOD: 3,
|
|
60
|
+
KWD: 3,
|
|
61
|
+
LYD: 3,
|
|
62
|
+
OMR: 3,
|
|
63
|
+
TND: 3,
|
|
64
|
+
CLF: 4,
|
|
65
|
+
UYW: 4
|
|
66
|
+
};
|
|
67
|
+
function currencyMinorUnitExponent(currencyCode) {
|
|
68
|
+
return NON_TWO_DIGIT_MINOR_UNIT_EXPONENTS[currencyCode.toUpperCase()] ?? 2;
|
|
69
|
+
}
|
|
70
|
+
function fromMajorUnitsToMinorUnits({
|
|
71
|
+
amount,
|
|
72
|
+
currencyCode
|
|
73
|
+
}) {
|
|
74
|
+
const majorUnits = typeof amount === "string" && amount.trim() === "" ? Number.NaN : Number(amount);
|
|
75
|
+
if (!Number.isFinite(majorUnits)) {
|
|
76
|
+
throw new InvalidAmountError({
|
|
77
|
+
message: "Money amount is not a finite number",
|
|
78
|
+
additionalData: { amount, currencyCode }
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const scaled = majorUnits * 10 ** currencyMinorUnitExponent(currencyCode);
|
|
82
|
+
return Math.round(Number(scaled.toPrecision(15)));
|
|
83
|
+
}
|
|
84
|
+
function parseDecimalToMinorUnits({
|
|
85
|
+
value,
|
|
86
|
+
currencyCode
|
|
87
|
+
}) {
|
|
88
|
+
const trimmed = value?.trim();
|
|
89
|
+
if (!trimmed || !Number.isFinite(Number(trimmed))) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return fromMajorUnitsToMinorUnits({ amount: trimmed, currencyCode });
|
|
93
|
+
}
|
|
94
|
+
function fromMinorUnitsToMajorUnits({
|
|
95
|
+
amount,
|
|
96
|
+
currencyCode
|
|
97
|
+
}) {
|
|
98
|
+
return amount / 10 ** currencyMinorUnitExponent(currencyCode);
|
|
99
|
+
}
|
|
100
|
+
function fromMinorUnitsToMajorUnitsString({
|
|
101
|
+
amount,
|
|
102
|
+
currencyCode
|
|
103
|
+
}) {
|
|
104
|
+
return fromMinorUnitsToMajorUnits({ amount, currencyCode }).toFixed(
|
|
105
|
+
currencyMinorUnitExponent(currencyCode)
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
function formatAmount({
|
|
109
|
+
amount,
|
|
110
|
+
currencyCode,
|
|
111
|
+
locale
|
|
112
|
+
}) {
|
|
113
|
+
return new Intl.NumberFormat(locale ?? "en-US", {
|
|
114
|
+
style: "currency",
|
|
115
|
+
currency: currencyCode.toUpperCase()
|
|
116
|
+
}).format(fromMinorUnitsToMajorUnits({ amount, currencyCode }));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { InvalidAmountError, UnsupportedCurrencyError, assertStripeExponentMatchesIso, formatAmount, fromMajorUnitsToMinorUnits, fromMinorUnitsToMajorUnits, fromMinorUnitsToMajorUnitsString, parseDecimalToMinorUnits, stripeExponentDiffersFromIso };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config to use for any standard error we throw in Replo
|
|
3
|
+
*/
|
|
4
|
+
export type ReploErrorConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* Message of the error, used only internally. If not provided, defaults to
|
|
7
|
+
* the error's class name
|
|
8
|
+
*/
|
|
9
|
+
message?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Any additional data about the error, e.g. ids of content that was trying
|
|
12
|
+
* to be accessed, contextual variables, etc. This is included when the error
|
|
13
|
+
* is logged to Sentry, etc
|
|
14
|
+
*/
|
|
15
|
+
additionalData?: Record<string, unknown>;
|
|
16
|
+
/** Meta details for error reporting */
|
|
17
|
+
errorReportingDetails?: {
|
|
18
|
+
/**
|
|
19
|
+
* If true, tells Sentry that it should group this error differently when
|
|
20
|
+
* it happens on different endpoints ("transactions" in Sentry are endpoints)
|
|
21
|
+
*/
|
|
22
|
+
includeTransactionInFingerprint?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* If provided, these get added to the Sentry fingerprint for this error. Useful
|
|
25
|
+
* for when you want to modify the grouping of an error, especially for reusing
|
|
26
|
+
* errors in different places.
|
|
27
|
+
*/
|
|
28
|
+
customFingerprint?: string[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Original cause of the error (useful for if you need to catch and re-throw errors
|
|
32
|
+
* with more context). Will be reported in stacktraces, sentry, etc.
|
|
33
|
+
*/
|
|
34
|
+
cause?: unknown;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Base error that all errors in Replo inherit from
|
|
38
|
+
*/
|
|
39
|
+
export declare abstract class ReploError extends Error {
|
|
40
|
+
config: ReploErrorConfig;
|
|
41
|
+
id: string;
|
|
42
|
+
constructor(config: ReploErrorConfig);
|
|
43
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReploError } from "../
|
|
2
|
-
import
|
|
1
|
+
import { ReploError } from "../reploError";
|
|
2
|
+
import * as z from "zod";
|
|
3
3
|
export declare class RedirectRuleValidationError extends ReploError {
|
|
4
4
|
}
|
|
5
5
|
export declare const redirectStatusSchema: z.ZodUnion<readonly [z.ZodLiteral<301>, z.ZodLiteral<302>, z.ZodLiteral<307>, z.ZodLiteral<308>]>;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { getParamSegment, getRouteParams, hasRouteParam, matchSource } from '../../../chunk-VPEVERWE.mjs';
|
|
2
|
-
import { parseUrl } from '../../../chunk-
|
|
3
|
-
import '../../../chunk-
|
|
4
|
-
import { ReploError } from '../../../chunk-
|
|
5
|
-
import '../../../chunk-
|
|
6
|
-
import '
|
|
7
|
-
import '../../../chunk-FNTGY7I5.mjs';
|
|
8
|
-
import '../../../chunk-UJCSKKID.mjs';
|
|
9
|
-
import { z } from 'zod';
|
|
2
|
+
import { parseUrl } from '../../../chunk-YGLYUC6R.mjs';
|
|
3
|
+
import '../../../chunk-IQCJXNJU.mjs';
|
|
4
|
+
import { ReploError } from '../../../chunk-DINTPZM2.mjs';
|
|
5
|
+
import '../../../chunk-JELVREEB.mjs';
|
|
6
|
+
import * as z from 'zod';
|
|
10
7
|
|
|
11
8
|
var RedirectRuleValidationError = class extends ReploError {
|
|
12
9
|
};
|