@replohq/canopy-sdk 0.20.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_vendor/replo-utils/lib/crypto.d.ts +30 -0
- package/_vendor/replo-utils/lib/errors.d.ts +83 -0
- package/_vendor/replo-utils/lib/json.mjs +1 -1
- package/_vendor/replo-utils/lib/misc.mjs +2 -2
- package/_vendor/schemas/errors.d.ts +438 -0
- package/_vendor/schemas/generated/errors.d.ts +61 -0
- package/_vendor/schemas/money.d.ts +55 -0
- package/_vendor/schemas/money.mjs +193 -0
- package/_vendor/schemas/selectMode.mjs +2 -2
- package/analytics/analytics-sink.d.ts +6 -0
- package/cart/cart-provider.js +18 -4
- package/cart/cart-provider.js.map +2 -2
- package/cart/cart-types.d.ts +2 -0
- package/cart/cart-types.js.map +2 -2
- package/cart/gateways/cart-constants.d.ts +1 -1
- package/cart/gateways/cart-constants.js +1 -1
- package/cart/gateways/cart-constants.js.map +2 -2
- package/cart/gateways/default-cart-gateway.js +1 -1
- package/cart/gateways/default-cart-gateway.js.map +2 -2
- package/cart/hooks/use-add-to-cart.js +6 -2
- package/cart/hooks/use-add-to-cart.js.map +2 -2
- package/cart/utils/cart-utils.d.ts +0 -4
- package/cart/utils/cart-utils.js +0 -8
- package/cart/utils/cart-utils.js.map +2 -2
- package/cart/utils/variant-to-cart-line.js +22 -5
- package/cart/utils/variant-to-cart-line.js.map +2 -2
- package/{chunk-ME5W2TJM.mjs → chunk-UWHM3FKU.mjs} +1 -1
- package/hooks/use-formatted-price.d.ts +1 -1
- package/hooks/use-formatted-price.js +7 -6
- package/hooks/use-formatted-price.js.map +2 -2
- package/money.d.ts +9 -0
- package/money.js +13 -0
- package/money.js.map +7 -0
- package/package.json +2 -1
- package/{chunk-NCKKAFF7.mjs → chunk-ILGEM42C.mjs} +7 -7
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Crypto helpers shared across runtime targets (Cloudflare Workers, Node
|
|
3
|
+
* 19+, browsers). Built on `crypto.subtle` so the same implementation runs
|
|
4
|
+
* inside Workers without a Node-only `node:crypto` import.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bytesToBase64Url(bytes: Uint8Array): string;
|
|
7
|
+
export declare function base64UrlToBytes(input: string): Uint8Array;
|
|
8
|
+
export declare function randomBase64Url(byteLength: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Prefer this over the global `crypto.randomUUID()`, which is secure-context-only
|
|
11
|
+
* and therefore undefined over plain `http://`. `uuid`'s v4 is backed by
|
|
12
|
+
* `crypto.getRandomValues`, which carries no such restriction.
|
|
13
|
+
*/
|
|
14
|
+
export declare function randomUUID(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the SHA-256 of `input` as a 64-char lowercase hex string.
|
|
17
|
+
*
|
|
18
|
+
* Used for storing opaque secrets (e.g. public API tokens) where we want
|
|
19
|
+
* constant-length hex output suitable for a `VARCHAR(64)` column with a
|
|
20
|
+
* unique index.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sha256Hex(input: string): Promise<string>;
|
|
23
|
+
export declare function constantTimeEqual({ left, right, }: {
|
|
24
|
+
left: Uint8Array;
|
|
25
|
+
right: Uint8Array;
|
|
26
|
+
}): boolean;
|
|
27
|
+
export declare function getHmacSha256Hex({ rawBody, signingKey, }: {
|
|
28
|
+
rawBody: string;
|
|
29
|
+
signingKey: string;
|
|
30
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
type ValueOfType<ObjectType> = ObjectType[keyof ObjectType];
|
|
2
|
+
/**
|
|
3
|
+
* Mostly taken from
|
|
4
|
+
* https://gist.githubusercontent.com/scokmen/f813c904ef79022e84ab2409574d1b45/raw/cd8709a2fccb005bb53e9bfb2461e07d40b4e8d8/HttpStatusCode.ts
|
|
5
|
+
*/
|
|
6
|
+
export declare const HTTP_STATUS_CODES: {
|
|
7
|
+
readonly CONTINUE: 100;
|
|
8
|
+
readonly SWITCHING_PROTOCOLS: 101;
|
|
9
|
+
readonly PROCESSING: 102;
|
|
10
|
+
readonly OK: 200;
|
|
11
|
+
readonly CREATED: 201;
|
|
12
|
+
readonly ACCEPTED: 202;
|
|
13
|
+
readonly NON_AUTHORITATIVE_INFORMATION: 203;
|
|
14
|
+
readonly NO_CONTENT: 204;
|
|
15
|
+
readonly RESET_CONTENT: 205;
|
|
16
|
+
readonly PARTIAL_CONTENT: 206;
|
|
17
|
+
readonly MULTI_STATUS: 207;
|
|
18
|
+
readonly ALREADY_REPORTED: 208;
|
|
19
|
+
readonly IM_USED: 226;
|
|
20
|
+
readonly MULTIPLE_CHOICES: 300;
|
|
21
|
+
readonly MOVED_PERMANENTLY: 301;
|
|
22
|
+
readonly FOUND: 302;
|
|
23
|
+
readonly SEE_OTHER: 303;
|
|
24
|
+
readonly NOT_MODIFIED: 304;
|
|
25
|
+
readonly USE_PROXY: 305;
|
|
26
|
+
readonly SWITCH_PROXY: 306;
|
|
27
|
+
readonly TEMPORARY_REDIRECT: 307;
|
|
28
|
+
readonly PERMANENT_REDIRECT: 308;
|
|
29
|
+
readonly BAD_REQUEST: 400;
|
|
30
|
+
readonly UNAUTHORIZED: 401;
|
|
31
|
+
readonly PAYMENT_REQUIRED: 402;
|
|
32
|
+
readonly FORBIDDEN: 403;
|
|
33
|
+
readonly NOT_FOUND: 404;
|
|
34
|
+
readonly METHOD_NOT_ALLOWED: 405;
|
|
35
|
+
readonly NOT_ACCEPTABLE: 406;
|
|
36
|
+
readonly PROXY_AUTHENTICATION_REQUIRED: 407;
|
|
37
|
+
readonly REQUEST_TIMEOUT: 408;
|
|
38
|
+
readonly CONFLICT: 409;
|
|
39
|
+
readonly GONE: 410;
|
|
40
|
+
readonly LENGTH_REQUIRED: 411;
|
|
41
|
+
readonly PRECONDITION_FAILED: 412;
|
|
42
|
+
readonly PAYLOAD_TOO_LARGE: 413;
|
|
43
|
+
readonly URI_TOO_LONG: 414;
|
|
44
|
+
readonly UNSUPPORTED_MEDIA_TYPE: 415;
|
|
45
|
+
readonly RANGE_NOT_SATISFIABLE: 416;
|
|
46
|
+
readonly EXPECTATION_FAILED: 417;
|
|
47
|
+
readonly I_AM_A_TEAPOT: 418;
|
|
48
|
+
readonly MISDIRECTED_REQUEST: 421;
|
|
49
|
+
readonly UNPROCESSABLE_ENTITY: 422;
|
|
50
|
+
readonly LOCKED: 423;
|
|
51
|
+
readonly FAILED_DEPENDENCY: 424;
|
|
52
|
+
readonly UPGRADE_REQUIRED: 426;
|
|
53
|
+
readonly PRECONDITION_REQUIRED: 428;
|
|
54
|
+
readonly TOO_MANY_REQUESTS: 429;
|
|
55
|
+
readonly REQUEST_HEADER_FIELDS_TOO_LARGE: 431;
|
|
56
|
+
readonly UNAVAILABLE_FOR_LEGAL_REASONS: 451;
|
|
57
|
+
readonly INTERNAL_SERVER_ERROR: 500;
|
|
58
|
+
readonly NOT_IMPLEMENTED: 501;
|
|
59
|
+
readonly BAD_GATEWAY: 502;
|
|
60
|
+
readonly SERVICE_UNAVAILABLE: 503;
|
|
61
|
+
readonly GATEWAY_TIMEOUT: 504;
|
|
62
|
+
readonly HTTP_VERSION_NOT_SUPPORTED: 505;
|
|
63
|
+
readonly VARIANT_ALSO_NEGOTIATES: 506;
|
|
64
|
+
readonly INSUFFICIENT_STORAGE: 507;
|
|
65
|
+
readonly LOOP_DETECTED: 508;
|
|
66
|
+
readonly NOT_EXTENDED: 510;
|
|
67
|
+
readonly NETWORK_AUTHENTICATION_REQUIRED: 511;
|
|
68
|
+
readonly UPSTREAM_WEBSERVER_ERROR: 520;
|
|
69
|
+
};
|
|
70
|
+
export type HttpStatusCode = ValueOfType<typeof HTTP_STATUS_CODES>;
|
|
71
|
+
/**
|
|
72
|
+
* Checks if an error message indicates a network error (e.g., connectivity issues,
|
|
73
|
+
* request timeouts, DNS failures). These errors typically don't need to be tracked
|
|
74
|
+
* in error monitoring systems like Sentry since they're user-side connectivity issues.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isNetworkErrorMessage(message: string): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Extracts a human-readable message from an unknown caught value. If the value
|
|
79
|
+
* is an Error, returns its message; otherwise falls back to the provided
|
|
80
|
+
* fallback string or `String(error)`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getErrorMessage(error: unknown, fallback?: string): string;
|
|
83
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isFunction_default as isFunction, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, warning } from '../../../chunk-
|
|
2
|
-
export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-
|
|
1
|
+
export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isFunction_default as isFunction, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, warning } from '../../../chunk-UWHM3FKU.mjs';
|
|
2
|
+
export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-ILGEM42C.mjs';
|
|
3
3
|
import '../../../chunk-FNTGY7I5.mjs';
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import type { ErrorUserFacingDetails, ErrorUserFacingDetailsWithMessage } from "./generated/errors";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Config to use for any standard error we throw in Replo
|
|
5
|
+
*/
|
|
6
|
+
export type ReploErrorConfig = {
|
|
7
|
+
/**
|
|
8
|
+
* Message of the error, used only internally. If not provided, defaults to
|
|
9
|
+
* the error's class name
|
|
10
|
+
*/
|
|
11
|
+
message?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Any additional data about the error, e.g. ids of content that was trying
|
|
14
|
+
* to be accessed, contextual variables, etc. This is included when the error
|
|
15
|
+
* is logged to Sentry, etc
|
|
16
|
+
*/
|
|
17
|
+
additionalData?: Record<string, unknown>;
|
|
18
|
+
/** Meta details for error reporting */
|
|
19
|
+
errorReportingDetails?: {
|
|
20
|
+
/**
|
|
21
|
+
* If true, tells Sentry that it should group this error differently when
|
|
22
|
+
* it happens on different endpoints ("transactions" in Sentry are endpoints)
|
|
23
|
+
*/
|
|
24
|
+
includeTransactionInFingerprint?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* If provided, these get added to the Sentry fingerprint for this error. Useful
|
|
27
|
+
* for when you want to modify the grouping of an error, especially for reusing
|
|
28
|
+
* errors in different places.
|
|
29
|
+
*/
|
|
30
|
+
customFingerprint?: string[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Original cause of the error (useful for if you need to catch and re-throw errors
|
|
34
|
+
* with more context). Will be reported in stacktraces, sentry, etc.
|
|
35
|
+
*/
|
|
36
|
+
cause?: unknown;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Base error that all errors in Replo inherit from
|
|
40
|
+
*/
|
|
41
|
+
export declare abstract class ReploError extends Error {
|
|
42
|
+
config: ReploErrorConfig;
|
|
43
|
+
id: string;
|
|
44
|
+
constructor(config: ReploErrorConfig);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Wraps an error so `async-retry` stops immediately instead of scheduling
|
|
48
|
+
* another attempt: the library rejects with any thrown error carrying a truthy
|
|
49
|
+
* `bail` property. Preserves the underlying error's message and keeps it as the
|
|
50
|
+
* cause so callers still surface the real failure.
|
|
51
|
+
*/
|
|
52
|
+
export declare class AsyncRetryBailError extends ReploError {
|
|
53
|
+
readonly bail = true;
|
|
54
|
+
constructor(cause: unknown);
|
|
55
|
+
}
|
|
56
|
+
export type AuthErrorType = "unauthenticated" | "unauthorized" | "notFound";
|
|
57
|
+
export type ReploAuthenticationErrorConfig = {
|
|
58
|
+
message: string;
|
|
59
|
+
type: AuthErrorType;
|
|
60
|
+
userFacingDetails?: ErrorUserFacingDetailsWithMessage;
|
|
61
|
+
additionalData?: ReploErrorConfig["additionalData"];
|
|
62
|
+
};
|
|
63
|
+
export declare class ReploAuthenticationError extends ReploError {
|
|
64
|
+
type: AuthErrorType;
|
|
65
|
+
userFacingDetails?: ErrorUserFacingDetailsWithMessage;
|
|
66
|
+
constructor(config: ReploAuthenticationErrorConfig);
|
|
67
|
+
getHttpStatusCode(): 401 | 403 | 404;
|
|
68
|
+
getTRPCErrorCode(): "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Error which automatically makes all Replo services respond with a specific
|
|
72
|
+
* HTTP status code when caught. Should only be thrown from routes, makes it
|
|
73
|
+
* easier to provide a standardized way of implementing user-facing messages
|
|
74
|
+
*/
|
|
75
|
+
export declare class ReploHTTPError extends ReploError {
|
|
76
|
+
userFacingDetails: ErrorUserFacingDetails;
|
|
77
|
+
statusCode: number;
|
|
78
|
+
details?: object;
|
|
79
|
+
constructor(config: ReploErrorConfig & {
|
|
80
|
+
statusCode: number;
|
|
81
|
+
userFacingDetails: ErrorUserFacingDetails;
|
|
82
|
+
details?: object;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Error used to represent an HTTP error that should be surfaced as such. This
|
|
87
|
+
* should be thrown when we want to pass the error through without changing the
|
|
88
|
+
* status code and without providing any user facing details (because this route
|
|
89
|
+
* is not serving the client e.g. when we're calling Mirror through the
|
|
90
|
+
* Publisher)
|
|
91
|
+
*/
|
|
92
|
+
export declare class ReploRawHTTPError extends ReploError {
|
|
93
|
+
statusCode: number;
|
|
94
|
+
errorType: string;
|
|
95
|
+
data?: object;
|
|
96
|
+
constructor(config: {
|
|
97
|
+
statusCode: number;
|
|
98
|
+
message: string;
|
|
99
|
+
errorType: string;
|
|
100
|
+
data?: object;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Error which is automatically mapped to a status code response wherever it's
|
|
105
|
+
* thrown. Errors which are thrown from many different places where we want to
|
|
106
|
+
* always respond in the same way should inherit this, e.g. an error thrown for
|
|
107
|
+
* any Shopify call when the user has uninstalled the app.
|
|
108
|
+
*
|
|
109
|
+
* Inheriting from this should be uncommon, for most errors we want to inherit
|
|
110
|
+
* from ReploError and catch/map them to ReploHTTPErrors in our routes. For the
|
|
111
|
+
* uncommon cases where we want to globally map errors this reduces boilerplate.
|
|
112
|
+
*
|
|
113
|
+
* Globally mapped errors are never reported to Sentry or logged.
|
|
114
|
+
*/
|
|
115
|
+
export declare class Uncommon_GloballyMappedError extends ReploError {
|
|
116
|
+
userFacingDetails: ErrorUserFacingDetails;
|
|
117
|
+
statusCode: number;
|
|
118
|
+
constructor(config: ReploErrorConfig & {
|
|
119
|
+
statusCode: number;
|
|
120
|
+
userFacingDetails: ErrorUserFacingDetails;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export declare class ReploValidationError extends ReploError {
|
|
124
|
+
constructor(message: string);
|
|
125
|
+
}
|
|
126
|
+
export declare class UnexpectedMutationError extends ReploError {
|
|
127
|
+
constructor();
|
|
128
|
+
}
|
|
129
|
+
export declare class UnexpectedRawGraphqlClientError extends ReploError {
|
|
130
|
+
originalError: unknown;
|
|
131
|
+
errors: unknown[];
|
|
132
|
+
data: unknown;
|
|
133
|
+
constructor(opts: {
|
|
134
|
+
originalError: unknown;
|
|
135
|
+
errors: unknown[];
|
|
136
|
+
data: unknown;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
export declare const DEFAULT_ERROR_MESSAGE_CONFIG: {
|
|
140
|
+
header: string;
|
|
141
|
+
message: string;
|
|
142
|
+
isFullPage: boolean;
|
|
143
|
+
};
|
|
144
|
+
export type ErrorDetails = {
|
|
145
|
+
header: string;
|
|
146
|
+
subheader?: string;
|
|
147
|
+
message?: string | string[] | React.ReactNode;
|
|
148
|
+
messageDetail?: string;
|
|
149
|
+
isRecoverable?: boolean;
|
|
150
|
+
isFullPage?: boolean;
|
|
151
|
+
usage?: {
|
|
152
|
+
current: number;
|
|
153
|
+
maximum: number;
|
|
154
|
+
};
|
|
155
|
+
callToAction?: {
|
|
156
|
+
type: "installApp";
|
|
157
|
+
} | {
|
|
158
|
+
type: "callback";
|
|
159
|
+
name: string;
|
|
160
|
+
onClick(): void;
|
|
161
|
+
} | {
|
|
162
|
+
type: "link";
|
|
163
|
+
name: string;
|
|
164
|
+
to: string;
|
|
165
|
+
target?: string;
|
|
166
|
+
} | {
|
|
167
|
+
type: "closeModal";
|
|
168
|
+
name: string;
|
|
169
|
+
} | {
|
|
170
|
+
type: "navigate";
|
|
171
|
+
location: {
|
|
172
|
+
type: "integrationHub";
|
|
173
|
+
} | {
|
|
174
|
+
type: "home";
|
|
175
|
+
} | {
|
|
176
|
+
type: "workspace";
|
|
177
|
+
workspaceId: string;
|
|
178
|
+
workspaceName: string;
|
|
179
|
+
};
|
|
180
|
+
} | {
|
|
181
|
+
type: "custom";
|
|
182
|
+
callToActionType: ErrorUserFacingDetailsWithMessage["callToAction"];
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Map of error keys to custom user-facing details. Should ONLY be used
|
|
187
|
+
* in cases where we want to override the default behavior of ErrorUserFacingDetails
|
|
188
|
+
* from the backend.
|
|
189
|
+
*
|
|
190
|
+
* TODO (Noah, 2024-01-15): Clean up these custom configs, all of them
|
|
191
|
+
* are only used by Django (and 'base' can be moved directly into the reducer function)
|
|
192
|
+
*/
|
|
193
|
+
export declare const CUSTOM_ERROR_KEY_TO_PROPS: {
|
|
194
|
+
"shopifyArticle.failedToPublish": () => {
|
|
195
|
+
header: string;
|
|
196
|
+
message: string;
|
|
197
|
+
};
|
|
198
|
+
"shopifySection.failedToPublish": () => {
|
|
199
|
+
header: string;
|
|
200
|
+
message: string;
|
|
201
|
+
};
|
|
202
|
+
"page.failedToPublish": () => {
|
|
203
|
+
header: string;
|
|
204
|
+
message: string;
|
|
205
|
+
};
|
|
206
|
+
"shopifyProductTemplate.failedToPublish": () => {
|
|
207
|
+
header: string;
|
|
208
|
+
message: string;
|
|
209
|
+
};
|
|
210
|
+
"element.failedToPublish": () => {
|
|
211
|
+
header: string;
|
|
212
|
+
message: string;
|
|
213
|
+
};
|
|
214
|
+
"element.failedToUpdate": () => {
|
|
215
|
+
header: string;
|
|
216
|
+
message: string;
|
|
217
|
+
};
|
|
218
|
+
"store.billingPlan.alreadyExist": () => {
|
|
219
|
+
header: string;
|
|
220
|
+
message: string;
|
|
221
|
+
};
|
|
222
|
+
"error.assets.unsupportedFileType": ({ serverMessage }: {
|
|
223
|
+
type: string;
|
|
224
|
+
serverMessage?: string;
|
|
225
|
+
endpoint: string | null;
|
|
226
|
+
}) => {
|
|
227
|
+
header: string;
|
|
228
|
+
message: string;
|
|
229
|
+
};
|
|
230
|
+
"error.assets.fileTooLarge": () => {
|
|
231
|
+
header: string;
|
|
232
|
+
message: string;
|
|
233
|
+
};
|
|
234
|
+
"error.files.fileTooLarge": () => {
|
|
235
|
+
header: string;
|
|
236
|
+
message: string;
|
|
237
|
+
};
|
|
238
|
+
base: () => {
|
|
239
|
+
header: string;
|
|
240
|
+
message: string;
|
|
241
|
+
isFullPage: boolean;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
export declare function extractErrorId(error: unknown): string | undefined;
|
|
245
|
+
export declare function addErrorIdIfNeeded(error: unknown): void;
|
|
246
|
+
export declare const errorUserFacingDetailsMessageSchema: z.ZodObject<{
|
|
247
|
+
type: z.ZodEnum<{
|
|
248
|
+
toast: "toast";
|
|
249
|
+
fullPageModal: "fullPageModal";
|
|
250
|
+
shopifyStorePassword: "shopifyStorePassword";
|
|
251
|
+
"billing.addPublishedElements": "billing.addPublishedElements";
|
|
252
|
+
"billing.addShopifyThemeProject": "billing.addShopifyThemeProject";
|
|
253
|
+
"billing.addReploSite": "billing.addReploSite";
|
|
254
|
+
"agentBilling.shopifyThemeBuilder.publishedElements.exceeded": "agentBilling.shopifyThemeBuilder.publishedElements.exceeded";
|
|
255
|
+
"agentBilling.shopifyThemeBuilder.projects.exceeded": "agentBilling.shopifyThemeBuilder.projects.exceeded";
|
|
256
|
+
"agentBilling.sites.exceeded": "agentBilling.sites.exceeded";
|
|
257
|
+
"agentBilling.credits.exceeded": "agentBilling.credits.exceeded";
|
|
258
|
+
"agentBilling.upgradeRequired": "agentBilling.upgradeRequired";
|
|
259
|
+
}>;
|
|
260
|
+
message: z.ZodString;
|
|
261
|
+
isRecoverable: z.ZodOptional<z.ZodBoolean>;
|
|
262
|
+
detail: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodString]>>;
|
|
263
|
+
key: z.ZodString;
|
|
264
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
265
|
+
current: z.ZodNumber;
|
|
266
|
+
maximum: z.ZodNumber;
|
|
267
|
+
}, z.core.$strip>>;
|
|
268
|
+
plan: z.ZodOptional<z.ZodString>;
|
|
269
|
+
callToAction: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
270
|
+
type: z.ZodLiteral<"reload">;
|
|
271
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
272
|
+
type: z.ZodLiteral<"installApp">;
|
|
273
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
274
|
+
type: z.ZodLiteral<"goToHomepage">;
|
|
275
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
276
|
+
type: z.ZodLiteral<"navigateToProjectEditor">;
|
|
277
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
278
|
+
type: z.ZodLiteral<"closeModal">;
|
|
279
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
280
|
+
type: z.ZodLiteral<"navigateToLink">;
|
|
281
|
+
link: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
282
|
+
type: z.ZodLiteral<"errors.wrongJsonExtension">;
|
|
283
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
284
|
+
type: z.ZodLiteral<"errors.chunkingError">;
|
|
285
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
286
|
+
type: z.ZodLiteral<"errors.indexBackupError">;
|
|
287
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
288
|
+
type: z.ZodLiteral<"errors.shopifyIntegrationAlreadyAssigned">;
|
|
289
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
290
|
+
type: z.ZodLiteral<"errors.shopifyIntegrationMissingAccessScopes">;
|
|
291
|
+
url: z.ZodString;
|
|
292
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
293
|
+
type: z.ZodLiteral<"customLink">;
|
|
294
|
+
url: z.ZodString;
|
|
295
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
296
|
+
type: z.ZodLiteral<"errors.projectConnectedToBillingIntegrationForShopifyWorkspace">;
|
|
297
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
298
|
+
type: z.ZodLiteral<"errors.themeAssetSizeLimitExceeded">;
|
|
299
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
300
|
+
type: z.ZodLiteral<"errors.themeTotalSizeLimitExceeded">;
|
|
301
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
302
|
+
type: z.ZodLiteral<"errors.pageMetafieldDefinitionsChanged">;
|
|
303
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
304
|
+
type: z.ZodLiteral<"settings.billing">;
|
|
305
|
+
}, z.core.$strip>], "type">;
|
|
306
|
+
}, z.core.$strip>], "type">>;
|
|
307
|
+
}, z.core.$strip>;
|
|
308
|
+
/**
|
|
309
|
+
* Schema for user-facing details which the frontend uses to show toasts, modals, etc
|
|
310
|
+
* when an error is thrown from the backend
|
|
311
|
+
*/
|
|
312
|
+
export declare const errorUserFacingDetailsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
313
|
+
type: z.ZodEnum<{
|
|
314
|
+
toast: "toast";
|
|
315
|
+
fullPageModal: "fullPageModal";
|
|
316
|
+
shopifyStorePassword: "shopifyStorePassword";
|
|
317
|
+
"billing.addPublishedElements": "billing.addPublishedElements";
|
|
318
|
+
"billing.addShopifyThemeProject": "billing.addShopifyThemeProject";
|
|
319
|
+
"billing.addReploSite": "billing.addReploSite";
|
|
320
|
+
"agentBilling.shopifyThemeBuilder.publishedElements.exceeded": "agentBilling.shopifyThemeBuilder.publishedElements.exceeded";
|
|
321
|
+
"agentBilling.shopifyThemeBuilder.projects.exceeded": "agentBilling.shopifyThemeBuilder.projects.exceeded";
|
|
322
|
+
"agentBilling.sites.exceeded": "agentBilling.sites.exceeded";
|
|
323
|
+
"agentBilling.credits.exceeded": "agentBilling.credits.exceeded";
|
|
324
|
+
"agentBilling.upgradeRequired": "agentBilling.upgradeRequired";
|
|
325
|
+
}>;
|
|
326
|
+
message: z.ZodString;
|
|
327
|
+
isRecoverable: z.ZodOptional<z.ZodBoolean>;
|
|
328
|
+
detail: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodString]>>;
|
|
329
|
+
key: z.ZodString;
|
|
330
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
331
|
+
current: z.ZodNumber;
|
|
332
|
+
maximum: z.ZodNumber;
|
|
333
|
+
}, z.core.$strip>>;
|
|
334
|
+
plan: z.ZodOptional<z.ZodString>;
|
|
335
|
+
callToAction: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
336
|
+
type: z.ZodLiteral<"reload">;
|
|
337
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
338
|
+
type: z.ZodLiteral<"installApp">;
|
|
339
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
340
|
+
type: z.ZodLiteral<"goToHomepage">;
|
|
341
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
342
|
+
type: z.ZodLiteral<"navigateToProjectEditor">;
|
|
343
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
344
|
+
type: z.ZodLiteral<"closeModal">;
|
|
345
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
346
|
+
type: z.ZodLiteral<"navigateToLink">;
|
|
347
|
+
link: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
348
|
+
type: z.ZodLiteral<"errors.wrongJsonExtension">;
|
|
349
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
350
|
+
type: z.ZodLiteral<"errors.chunkingError">;
|
|
351
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
352
|
+
type: z.ZodLiteral<"errors.indexBackupError">;
|
|
353
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
354
|
+
type: z.ZodLiteral<"errors.shopifyIntegrationAlreadyAssigned">;
|
|
355
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
356
|
+
type: z.ZodLiteral<"errors.shopifyIntegrationMissingAccessScopes">;
|
|
357
|
+
url: z.ZodString;
|
|
358
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
359
|
+
type: z.ZodLiteral<"customLink">;
|
|
360
|
+
url: z.ZodString;
|
|
361
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
362
|
+
type: z.ZodLiteral<"errors.projectConnectedToBillingIntegrationForShopifyWorkspace">;
|
|
363
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
364
|
+
type: z.ZodLiteral<"errors.themeAssetSizeLimitExceeded">;
|
|
365
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
366
|
+
type: z.ZodLiteral<"errors.themeTotalSizeLimitExceeded">;
|
|
367
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
368
|
+
type: z.ZodLiteral<"errors.pageMetafieldDefinitionsChanged">;
|
|
369
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
370
|
+
type: z.ZodLiteral<"settings.billing">;
|
|
371
|
+
}, z.core.$strip>], "type">;
|
|
372
|
+
}, z.core.$strip>], "type">>;
|
|
373
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
374
|
+
type: z.ZodLiteral<"uncommon_none">;
|
|
375
|
+
key: z.ZodString;
|
|
376
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
377
|
+
current: z.ZodNumber;
|
|
378
|
+
maximum: z.ZodNumber;
|
|
379
|
+
}, z.core.$strip>>;
|
|
380
|
+
message: z.ZodOptional<z.ZodString>;
|
|
381
|
+
isRecoverable: z.ZodOptional<z.ZodBoolean>;
|
|
382
|
+
detail: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodString]>>;
|
|
383
|
+
}, z.core.$strip>], "type">;
|
|
384
|
+
export declare const extractErrorTrackingEventDetails: (error: unknown, transaction: string | undefined, tags?: Record<string, string>) => {
|
|
385
|
+
fingerprint: string[];
|
|
386
|
+
extra: {
|
|
387
|
+
zodIssues: z.core.$ZodIssue[];
|
|
388
|
+
cause?: undefined;
|
|
389
|
+
};
|
|
390
|
+
tags: {
|
|
391
|
+
errorId?: string | undefined;
|
|
392
|
+
};
|
|
393
|
+
} | {
|
|
394
|
+
fingerprint: string[];
|
|
395
|
+
extra: Record<string, unknown> | undefined;
|
|
396
|
+
tags: {
|
|
397
|
+
errorId: string;
|
|
398
|
+
};
|
|
399
|
+
} | {
|
|
400
|
+
extra: {
|
|
401
|
+
cause: unknown;
|
|
402
|
+
zodIssues?: undefined;
|
|
403
|
+
};
|
|
404
|
+
tags: {
|
|
405
|
+
errorId?: string | undefined;
|
|
406
|
+
};
|
|
407
|
+
fingerprint?: undefined;
|
|
408
|
+
} | {
|
|
409
|
+
tags: {
|
|
410
|
+
errorId?: string | undefined;
|
|
411
|
+
};
|
|
412
|
+
fingerprint?: undefined;
|
|
413
|
+
extra?: undefined;
|
|
414
|
+
} | null;
|
|
415
|
+
export declare const shouldReportErrorToSentry: (error: Error) => boolean;
|
|
416
|
+
export declare class CloudflareAgentCoordinatorRpcError extends ReploError {
|
|
417
|
+
constructor(error: unknown);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Errors thrown by the postMessage RPC layer between bedrock miniapp iframes
|
|
421
|
+
* and their agent-ui parent (see `packages/schemas/miniappRpc.ts` for the
|
|
422
|
+
* protocol). Both sides reject pending request promises with these so
|
|
423
|
+
* `instanceof` checks work regardless of which side surfaced the failure.
|
|
424
|
+
*/
|
|
425
|
+
export declare abstract class MiniappRpcError extends ReploError {
|
|
426
|
+
}
|
|
427
|
+
/** Pending request exceeded `RPC_TIMEOUT_MS` without a response. */
|
|
428
|
+
export declare class MiniappRpcTimeoutError extends MiniappRpcError {
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Other side posted a `kind: "error"` envelope; `config.message` carries the
|
|
432
|
+
* remote-supplied detail.
|
|
433
|
+
*/
|
|
434
|
+
export declare class MiniappRpcRemoteError extends MiniappRpcError {
|
|
435
|
+
}
|
|
436
|
+
/** Parent-side hook unmounted while a request was in flight. */
|
|
437
|
+
export declare class MiniappRpcUnmountedError extends MiniappRpcError {
|
|
438
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type ErrorUserFacingDetailsWithMessage = {
|
|
2
|
+
type: "toast" | "fullPageModal" | "shopifyStorePassword" | "billing.addPublishedElements" | "billing.addShopifyThemeProject" | "billing.addReploSite" | "agentBilling.shopifyThemeBuilder.publishedElements.exceeded" | "agentBilling.shopifyThemeBuilder.projects.exceeded" | "agentBilling.sites.exceeded" | "agentBilling.credits.exceeded" | "agentBilling.upgradeRequired";
|
|
3
|
+
message: string;
|
|
4
|
+
isRecoverable?: boolean;
|
|
5
|
+
detail?: string[] | string;
|
|
6
|
+
key: string;
|
|
7
|
+
usage?: {
|
|
8
|
+
current: number;
|
|
9
|
+
maximum: number;
|
|
10
|
+
};
|
|
11
|
+
plan?: string;
|
|
12
|
+
callToAction?: {
|
|
13
|
+
type: "reload";
|
|
14
|
+
} | {
|
|
15
|
+
type: "installApp";
|
|
16
|
+
} | {
|
|
17
|
+
type: "goToHomepage";
|
|
18
|
+
} | {
|
|
19
|
+
type: "navigateToProjectEditor";
|
|
20
|
+
} | {
|
|
21
|
+
type: "closeModal";
|
|
22
|
+
} | {
|
|
23
|
+
type: "navigateToLink";
|
|
24
|
+
link: {
|
|
25
|
+
type: "errors.wrongJsonExtension";
|
|
26
|
+
} | {
|
|
27
|
+
type: "errors.chunkingError";
|
|
28
|
+
} | {
|
|
29
|
+
type: "errors.indexBackupError";
|
|
30
|
+
} | {
|
|
31
|
+
type: "errors.shopifyIntegrationAlreadyAssigned";
|
|
32
|
+
} | {
|
|
33
|
+
type: "errors.shopifyIntegrationMissingAccessScopes";
|
|
34
|
+
url: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: "customLink";
|
|
37
|
+
url: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "errors.projectConnectedToBillingIntegrationForShopifyWorkspace";
|
|
40
|
+
} | {
|
|
41
|
+
type: "errors.themeAssetSizeLimitExceeded";
|
|
42
|
+
} | {
|
|
43
|
+
type: "errors.themeTotalSizeLimitExceeded";
|
|
44
|
+
} | {
|
|
45
|
+
type: "errors.pageMetafieldDefinitionsChanged";
|
|
46
|
+
} | {
|
|
47
|
+
type: "settings.billing";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export type ErrorUserFacingDetails = ErrorUserFacingDetailsWithMessage | {
|
|
52
|
+
type: "uncommon_none";
|
|
53
|
+
key: string;
|
|
54
|
+
usage?: {
|
|
55
|
+
current: number;
|
|
56
|
+
maximum: number;
|
|
57
|
+
};
|
|
58
|
+
message?: string;
|
|
59
|
+
isRecoverable?: boolean;
|
|
60
|
+
detail?: string[] | string;
|
|
61
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ReploError } from "./errors";
|
|
3
|
+
export declare class InvalidAmountError extends ReploError {
|
|
4
|
+
}
|
|
5
|
+
export declare class UnsupportedCurrencyError extends ReploError {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Converts a decimal major-unit amount (e.g. "19.99", 19.99) into integer
|
|
9
|
+
* minor units (1999) using the currency's Stripe exponent. Half-away-from-zero
|
|
10
|
+
* rounding for the non-negative amounts this domain uses (prices, totals),
|
|
11
|
+
* matching Stripe. Throws on non-numeric input.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fromMajorUnitsToMinorUnits({ amount, currencyCode, }: {
|
|
14
|
+
amount: number | string;
|
|
15
|
+
currencyCode: string;
|
|
16
|
+
}): number;
|
|
17
|
+
/**
|
|
18
|
+
* NOTE (Max, 2026-08-03): safe companion to fromMajorUnitsToMinorUnits for
|
|
19
|
+
* possibly-blank or user/CSV/provider-entered decimal strings — returns null
|
|
20
|
+
* for blank or non-numeric input instead of throwing. Callers with a
|
|
21
|
+
* source-specific cleaning or validation policy sanitize first, then convert
|
|
22
|
+
* here, so every "decimal string → minor units" path shares one converter.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseDecimalToMinorUnits({ value, currencyCode, }: {
|
|
25
|
+
value: string | null;
|
|
26
|
+
currencyCode: string;
|
|
27
|
+
}): number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Converts integer minor units (1999) back into a decimal major-unit number
|
|
30
|
+
* (19.99). Only for true decimal boundaries: display, analytics events, and
|
|
31
|
+
* third-party APIs that speak major units.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fromMinorUnitsToMajorUnits({ amount, currencyCode, }: {
|
|
34
|
+
amount: number;
|
|
35
|
+
currencyCode: string;
|
|
36
|
+
}): number;
|
|
37
|
+
/**
|
|
38
|
+
* Renders integer minor units as a plain decimal string for providers that
|
|
39
|
+
* speak decimal money (e.g. Printful retail_price): 1999 -> "19.99" (USD),
|
|
40
|
+
* "1999" (JPY), "1.999" (KWD).
|
|
41
|
+
*/
|
|
42
|
+
export declare function fromMinorUnitsToMajorUnitsString({ amount, currencyCode, }: {
|
|
43
|
+
amount: number;
|
|
44
|
+
currencyCode: string;
|
|
45
|
+
}): string;
|
|
46
|
+
/**
|
|
47
|
+
* Formats integer minor units for display, e.g. 1999 -> "$19.99" (USD),
|
|
48
|
+
* "¥1,999" (JPY).
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatAmount({ amount, currencyCode, locale, }: {
|
|
51
|
+
amount: number;
|
|
52
|
+
currencyCode: string;
|
|
53
|
+
locale?: string;
|
|
54
|
+
}): string;
|
|
55
|
+
export declare const amountSchema: z.ZodNumber;
|