@replohq/canopy-sdk 2.0.0 → 2.2.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/log.d.ts +11 -0
- package/_vendor/replo-utils/lib/misc.mjs +1 -1
- package/_vendor/replo-utils/react/use-iframe-rpc-channel.d.ts +14 -0
- package/_vendor/replo-utils/react/use-iframe-rpc-channel.mjs +14 -0
- package/_vendor/schemas/errors.d.ts +36 -15
- package/_vendor/schemas/generated/selectMode.d.ts +0 -85
- package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +100 -0
- package/_vendor/schemas/generated/selectModeIframeRpc.mjs +1 -0
- package/_vendor/schemas/iframeRpcChannel.d.ts +82 -0
- package/_vendor/schemas/iframeRpcChannel.mjs +361 -0
- package/_vendor/schemas/money.mjs +2 -113
- package/_vendor/schemas/selectMode.d.ts +0 -496
- package/_vendor/schemas/selectMode.mjs +3 -312
- package/_vendor/schemas/selectModeIframeRpc.d.ts +900 -0
- package/_vendor/schemas/selectModeIframeRpc.mjs +225 -0
- package/cart/buy-now-action.js +4 -4
- package/cart/buy-now-action.js.map +2 -2
- package/chunk-7GWIUERW.mjs +197 -0
- package/{chunk-UWHM3FKU.mjs → chunk-H36NDYLG.mjs} +3 -3
- package/chunk-OFU2QEDR.mjs +163 -0
- package/editor/annotations/annotationController.js +1 -1
- package/editor/annotations/annotationController.js.map +2 -2
- package/editor/select-mode/EditorSelection.js +3 -15
- package/editor/select-mode/EditorSelection.js.map +2 -2
- package/editor/select-mode/fast-refresh-relay.js +2 -4
- package/editor/select-mode/fast-refresh-relay.js.map +2 -2
- package/editor/select-mode/hooks/useEditModeStateMachine.d.ts +0 -4
- package/editor/select-mode/hooks/useEditModeStateMachine.js +76 -67
- package/editor/select-mode/hooks/useEditModeStateMachine.js.map +2 -2
- package/editor/select-mode/hooks/useParentMessaging.d.ts +6 -10
- package/editor/select-mode/hooks/useParentMessaging.js +43 -68
- package/editor/select-mode/hooks/useParentMessaging.js.map +2 -2
- package/editor/select-mode/hooks/useSelectModeController.js +5 -8
- package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionHover.js +4 -7
- package/editor/select-mode/hooks/useSelectionHover.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionInteractions.js +14 -31
- package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionScrollSync.js +11 -18
- package/editor/select-mode/hooks/useSelectionScrollSync.js.map +2 -2
- package/editor/select-mode/iframeRpcChannel.d.ts +356 -0
- package/editor/select-mode/iframeRpcChannel.js +92 -0
- package/editor/select-mode/iframeRpcChannel.js.map +7 -0
- package/lib/canopy-error.js +1 -1
- package/lib/canopy-error.js.map +2 -2
- package/orders/order-status-schema.d.ts +161 -0
- package/orders/order-status-schema.js +83 -0
- package/orders/order-status-schema.js.map +7 -0
- package/orders/order-status.d.ts +11 -0
- package/orders/order-status.js +41 -0
- package/orders/order-status.js.map +7 -0
- package/package.json +9 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { selectModeFormatCommandSchema, selectModeOptimisticUpdatePayloadSchema, selectModeSelectionTypeSchema, displayModeSchema, selectModeTiptapActiveMarksSchema, selectModeBoundingRectSchema, selectableDataSchema, selectModeSelectionRectSchema, selectModeClickPositionSchema, selectedElementSchema } from '../../chunk-7GWIUERW.mjs';
|
|
2
|
+
import '../../chunk-VKO7P3ED.mjs';
|
|
3
|
+
import '../../chunk-H36NDYLG.mjs';
|
|
4
|
+
import '../../chunk-ILGEM42C.mjs';
|
|
5
|
+
import '../../chunk-FNTGY7I5.mjs';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
var SELECT_MODE_IFRAME_RPC_CHANNEL_ID = "replo:select-mode-iframe-rpc";
|
|
9
|
+
var SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION = 1;
|
|
10
|
+
var websiteBuilderToCanopyMethodConfig = {
|
|
11
|
+
symbolicateSelectedElement: {
|
|
12
|
+
inputSchema: selectedElementSchema,
|
|
13
|
+
outputSchema: selectedElementSchema,
|
|
14
|
+
timeoutMs: 1500
|
|
15
|
+
},
|
|
16
|
+
setDisplayMode: {
|
|
17
|
+
inputSchema: z.object({ displayMode: displayModeSchema }),
|
|
18
|
+
outputSchema: z.void()
|
|
19
|
+
},
|
|
20
|
+
// Declarative push of the parent's current selection type into the
|
|
21
|
+
// canopy iframe. Transitioning to `none` is canopy's signal to hide
|
|
22
|
+
// its in-iframe selection frame and drop any in-progress drag —
|
|
23
|
+
// there's no separate "clear" message because selection state always
|
|
24
|
+
// flows through agentUiState.
|
|
25
|
+
setSelectionType: {
|
|
26
|
+
inputSchema: z.object({ selectionType: selectModeSelectionTypeSchema }),
|
|
27
|
+
outputSchema: z.void()
|
|
28
|
+
},
|
|
29
|
+
applyOptimisticUpdate: {
|
|
30
|
+
inputSchema: z.object({
|
|
31
|
+
editId: z.string(),
|
|
32
|
+
payload: selectModeOptimisticUpdatePayloadSchema,
|
|
33
|
+
targetSelector: z.string(),
|
|
34
|
+
targetMode: z.enum(["primary", "group"])
|
|
35
|
+
}),
|
|
36
|
+
outputSchema: z.void()
|
|
37
|
+
},
|
|
38
|
+
markCommitted: {
|
|
39
|
+
inputSchema: z.object({
|
|
40
|
+
editId: z.string(),
|
|
41
|
+
sessionId: z.string()
|
|
42
|
+
}),
|
|
43
|
+
outputSchema: z.void()
|
|
44
|
+
},
|
|
45
|
+
resolveSessionOverrides: {
|
|
46
|
+
inputSchema: z.object({
|
|
47
|
+
sessionId: z.string(),
|
|
48
|
+
outcome: z.enum(["persisted", "failed"])
|
|
49
|
+
}),
|
|
50
|
+
outputSchema: z.void()
|
|
51
|
+
},
|
|
52
|
+
revertOverride: {
|
|
53
|
+
inputSchema: z.object({
|
|
54
|
+
editId: z.string()
|
|
55
|
+
}),
|
|
56
|
+
outputSchema: z.void()
|
|
57
|
+
},
|
|
58
|
+
enterEditMode: {
|
|
59
|
+
inputSchema: z.undefined(),
|
|
60
|
+
outputSchema: z.void()
|
|
61
|
+
},
|
|
62
|
+
exitEditMode: {
|
|
63
|
+
inputSchema: z.undefined(),
|
|
64
|
+
outputSchema: z.void()
|
|
65
|
+
},
|
|
66
|
+
formatCommand: {
|
|
67
|
+
inputSchema: z.object({
|
|
68
|
+
command: selectModeFormatCommandSchema
|
|
69
|
+
}),
|
|
70
|
+
outputSchema: z.void()
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var canopyToWebsiteBuilderMethodConfig = {
|
|
74
|
+
requestInlineTextEdit: {
|
|
75
|
+
inputSchema: z.object({
|
|
76
|
+
editId: z.string(),
|
|
77
|
+
element: selectedElementSchema
|
|
78
|
+
}),
|
|
79
|
+
outputSchema: z.object({ allowed: z.boolean() }),
|
|
80
|
+
timeoutMs: 5e3
|
|
81
|
+
},
|
|
82
|
+
iframeReady: {
|
|
83
|
+
inputSchema: z.undefined(),
|
|
84
|
+
outputSchema: z.void()
|
|
85
|
+
},
|
|
86
|
+
elementSelected: {
|
|
87
|
+
inputSchema: z.object({
|
|
88
|
+
data: selectableDataSchema
|
|
89
|
+
}),
|
|
90
|
+
outputSchema: z.void()
|
|
91
|
+
},
|
|
92
|
+
hoverElement: {
|
|
93
|
+
inputSchema: z.object({
|
|
94
|
+
rect: selectModeBoundingRectSchema.nullable()
|
|
95
|
+
}),
|
|
96
|
+
outputSchema: z.void()
|
|
97
|
+
},
|
|
98
|
+
selectedElementRectUpdate: {
|
|
99
|
+
inputSchema: z.object({
|
|
100
|
+
rect: selectModeBoundingRectSchema,
|
|
101
|
+
clickPosition: selectModeClickPositionSchema
|
|
102
|
+
}),
|
|
103
|
+
outputSchema: z.void()
|
|
104
|
+
},
|
|
105
|
+
selectedAreaRectUpdate: {
|
|
106
|
+
inputSchema: z.object({
|
|
107
|
+
rect: selectModeBoundingRectSchema
|
|
108
|
+
}),
|
|
109
|
+
outputSchema: z.void()
|
|
110
|
+
},
|
|
111
|
+
dragRectUpdated: {
|
|
112
|
+
inputSchema: z.object({
|
|
113
|
+
dragRect: selectModeBoundingRectSchema.nullable(),
|
|
114
|
+
selectionRects: z.array(selectModeSelectionRectSchema)
|
|
115
|
+
}),
|
|
116
|
+
outputSchema: z.void()
|
|
117
|
+
},
|
|
118
|
+
areaSelected: {
|
|
119
|
+
inputSchema: z.object({
|
|
120
|
+
rect: selectModeBoundingRectSchema,
|
|
121
|
+
items: z.array(selectableDataSchema)
|
|
122
|
+
}),
|
|
123
|
+
outputSchema: z.void()
|
|
124
|
+
},
|
|
125
|
+
textCommitted: {
|
|
126
|
+
inputSchema: z.object({
|
|
127
|
+
editId: z.string(),
|
|
128
|
+
html: z.string(),
|
|
129
|
+
json: z.record(z.string(), z.unknown()),
|
|
130
|
+
originalInnerHTML: z.string()
|
|
131
|
+
}),
|
|
132
|
+
outputSchema: z.void()
|
|
133
|
+
},
|
|
134
|
+
editorStateUpdate: {
|
|
135
|
+
inputSchema: z.object({
|
|
136
|
+
activeMarks: selectModeTiptapActiveMarksSchema,
|
|
137
|
+
// Whether an inline text edit is currently open. Lets the parent show the
|
|
138
|
+
// inline formatting controls (and live mark state) only while editing.
|
|
139
|
+
isEditing: z.boolean()
|
|
140
|
+
}),
|
|
141
|
+
outputSchema: z.void()
|
|
142
|
+
},
|
|
143
|
+
fastRefreshComplete: {
|
|
144
|
+
inputSchema: z.undefined(),
|
|
145
|
+
outputSchema: z.void()
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
var selectModeParentMessageSchema = z.discriminatedUnion("method", [
|
|
149
|
+
z.object({
|
|
150
|
+
method: z.literal("setDisplayMode"),
|
|
151
|
+
data: websiteBuilderToCanopyMethodConfig.setDisplayMode.inputSchema
|
|
152
|
+
}),
|
|
153
|
+
z.object({
|
|
154
|
+
method: z.literal("setSelectionType"),
|
|
155
|
+
data: websiteBuilderToCanopyMethodConfig.setSelectionType.inputSchema
|
|
156
|
+
}),
|
|
157
|
+
z.object({
|
|
158
|
+
method: z.literal("applyOptimisticUpdate"),
|
|
159
|
+
data: websiteBuilderToCanopyMethodConfig.applyOptimisticUpdate.inputSchema
|
|
160
|
+
}),
|
|
161
|
+
z.object({
|
|
162
|
+
method: z.literal("markCommitted"),
|
|
163
|
+
data: websiteBuilderToCanopyMethodConfig.markCommitted.inputSchema
|
|
164
|
+
}),
|
|
165
|
+
z.object({
|
|
166
|
+
method: z.literal("resolveSessionOverrides"),
|
|
167
|
+
data: websiteBuilderToCanopyMethodConfig.resolveSessionOverrides.inputSchema
|
|
168
|
+
}),
|
|
169
|
+
z.object({
|
|
170
|
+
method: z.literal("revertOverride"),
|
|
171
|
+
data: websiteBuilderToCanopyMethodConfig.revertOverride.inputSchema
|
|
172
|
+
}),
|
|
173
|
+
z.object({
|
|
174
|
+
method: z.literal("enterEditMode")
|
|
175
|
+
}),
|
|
176
|
+
z.object({
|
|
177
|
+
method: z.literal("exitEditMode")
|
|
178
|
+
}),
|
|
179
|
+
z.object({
|
|
180
|
+
method: z.literal("formatCommand"),
|
|
181
|
+
data: websiteBuilderToCanopyMethodConfig.formatCommand.inputSchema
|
|
182
|
+
})
|
|
183
|
+
]).describe("SelectModeParentMessage");
|
|
184
|
+
var selectModeIframeMessageSchema = z.discriminatedUnion("method", [
|
|
185
|
+
z.object({
|
|
186
|
+
method: z.literal("iframeReady")
|
|
187
|
+
}),
|
|
188
|
+
z.object({
|
|
189
|
+
method: z.literal("elementSelected"),
|
|
190
|
+
data: canopyToWebsiteBuilderMethodConfig.elementSelected.inputSchema
|
|
191
|
+
}),
|
|
192
|
+
z.object({
|
|
193
|
+
method: z.literal("hoverElement"),
|
|
194
|
+
data: canopyToWebsiteBuilderMethodConfig.hoverElement.inputSchema
|
|
195
|
+
}),
|
|
196
|
+
z.object({
|
|
197
|
+
method: z.literal("selectedElementRectUpdate"),
|
|
198
|
+
data: canopyToWebsiteBuilderMethodConfig.selectedElementRectUpdate.inputSchema
|
|
199
|
+
}),
|
|
200
|
+
z.object({
|
|
201
|
+
method: z.literal("selectedAreaRectUpdate"),
|
|
202
|
+
data: canopyToWebsiteBuilderMethodConfig.selectedAreaRectUpdate.inputSchema
|
|
203
|
+
}),
|
|
204
|
+
z.object({
|
|
205
|
+
method: z.literal("dragRectUpdated"),
|
|
206
|
+
data: canopyToWebsiteBuilderMethodConfig.dragRectUpdated.inputSchema
|
|
207
|
+
}),
|
|
208
|
+
z.object({
|
|
209
|
+
method: z.literal("areaSelected"),
|
|
210
|
+
data: canopyToWebsiteBuilderMethodConfig.areaSelected.inputSchema
|
|
211
|
+
}),
|
|
212
|
+
z.object({
|
|
213
|
+
method: z.literal("textCommitted"),
|
|
214
|
+
data: canopyToWebsiteBuilderMethodConfig.textCommitted.inputSchema
|
|
215
|
+
}),
|
|
216
|
+
z.object({
|
|
217
|
+
method: z.literal("editorStateUpdate"),
|
|
218
|
+
data: canopyToWebsiteBuilderMethodConfig.editorStateUpdate.inputSchema
|
|
219
|
+
}),
|
|
220
|
+
z.object({
|
|
221
|
+
method: z.literal("fastRefreshComplete")
|
|
222
|
+
})
|
|
223
|
+
]).describe("SelectModeIframeMessage");
|
|
224
|
+
|
|
225
|
+
export { SELECT_MODE_IFRAME_RPC_CHANNEL_ID, SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION, canopyToWebsiteBuilderMethodConfig, selectModeIframeMessageSchema, selectModeParentMessageSchema, websiteBuilderToCanopyMethodConfig };
|
package/cart/buy-now-action.js
CHANGED
|
@@ -46,7 +46,6 @@ async function buyNowAction(input) {
|
|
|
46
46
|
})();
|
|
47
47
|
const safePageUrl = isSameOrigin ? pageUrl : origin;
|
|
48
48
|
const cancelUrl = safePageUrl;
|
|
49
|
-
const returnUrl = safePageUrl;
|
|
50
49
|
const temporaryCartId = uuidv4();
|
|
51
50
|
const body = {
|
|
52
51
|
cartId: temporaryCartId,
|
|
@@ -56,9 +55,10 @@ async function buyNowAction(input) {
|
|
|
56
55
|
properties: line.properties
|
|
57
56
|
})),
|
|
58
57
|
projectId: env.PROJECT_ID,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
// canopy appends session_id={CHECKOUT_SESSION_ID} at session creation;
|
|
59
|
+
// the success route resolves it into the order status page.
|
|
60
|
+
successUrl: `${origin}/checkout/success`,
|
|
61
|
+
cancelUrl
|
|
62
62
|
};
|
|
63
63
|
const canopyApiUrl = `${buildBaseUrl(env.CANOPY_API_HOST)}/api/v1/stripe-checkout/create-session`;
|
|
64
64
|
const response = await fetch(canopyApiUrl, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../cart/buy-now-action.ts"],
|
|
4
|
-
"sourcesContent": ["\"use server\";\n\nimport type { CartLineAttribute } from \"./cart-types\";\n\nimport { headers } from \"next/headers\";\n\nimport { v4 as uuidv4 } from \"uuid\";\nimport { z } from \"zod\";\n\nimport { getEnv } from \"../env\";\nimport { CanopyError } from \"../lib/canopy-error\";\nimport { getCheckoutProvider } from \"../lib/integration-utils\";\nimport { buildBaseUrl } from \"../lib/url-utils\";\nimport { createCartAction } from \"./cart-actions\";\nimport { REPLO_ATTRIBUTION_PROPERTY } from \"./cart-types\";\n\nclass BuyNowError extends CanopyError {}\nclass BuyNowCartCreationError extends CanopyError {}\n\n/**\n * Server action that handles the full buy-now flow:\n * 1. For Shopify: creates a cart via the canopy-api-backed gateway, returns checkoutUrl.\n * 2. For Stripe: creates a Stripe checkout session via canopy-api, returns session URL.\n *\n * Variant IDs are expected to already be Storefront GIDs (from data loader output).\n * No internal\u2192external ID mapping is needed.\n */\nexport async function buyNowAction(input: {\n lineItems: {\n variantId: string;\n quantity: number;\n sellingPlanId: string | null;\n properties: CartLineAttribute[];\n }[];\n discountCodes: string[];\n pageUrl: string;\n}): Promise<{ redirectUrl: string }> {\n const { lineItems, discountCodes, pageUrl } = input;\n\n const headersList = await headers();\n const host = headersList.get(\"host\");\n if (!host) {\n throw new BuyNowError({ message: \"Missing host header\" });\n }\n const forwardedProto = headersList.get(\"x-forwarded-proto\");\n const protocol = forwardedProto?.split(\",\")[0]?.trim() ?? \"https\";\n const origin = `${protocol}://${host}`;\n\n const checkoutProvider = await getCheckoutProvider();\n\n const cartLines = lineItems.map((item) => {\n const hasReploAttribution = item.properties.some(\n (prop) => prop.key === REPLO_ATTRIBUTION_PROPERTY.key,\n );\n const properties = hasReploAttribution\n ? item.properties\n : [REPLO_ATTRIBUTION_PROPERTY, ...item.properties];\n\n return {\n id: item.variantId,\n quantity: item.quantity,\n sellingPlanId: item.sellingPlanId,\n properties,\n };\n });\n\n if (checkoutProvider === \"stripe\") {\n const env = await getEnv();\n const isSameOrigin = (() => {\n try {\n return Boolean(pageUrl) && new URL(pageUrl).origin === origin;\n } catch {\n return false;\n }\n })();\n const safePageUrl = isSameOrigin ? pageUrl : origin;\n const cancelUrl = safePageUrl;\n const
|
|
5
|
-
"mappings": ";AAIA,SAAS,eAAe;AAExB,SAAS,MAAM,cAAc;AAC7B,SAAS,SAAS;AAElB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,kCAAkC;AAE3C,MAAM,oBAAoB,YAAY;AAAC;AACvC,MAAM,gCAAgC,YAAY;AAAC;AAUnD,eAAsB,aAAa,OASE;AACnC,QAAM,EAAE,WAAW,eAAe,QAAQ,IAAI;AAE9C,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,OAAO,YAAY,IAAI,MAAM;AACnC,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,YAAY,EAAE,SAAS,sBAAsB,CAAC;AAAA,EAC1D;AACA,QAAM,iBAAiB,YAAY,IAAI,mBAAmB;AAC1D,QAAM,WAAW,gBAAgB,MAAM,GAAG,EAAE,CAAC,GAAG,KAAK,KAAK;AAC1D,QAAM,SAAS,GAAG,QAAQ,MAAM,IAAI;AAEpC,QAAM,mBAAmB,MAAM,oBAAoB;AAEnD,QAAM,YAAY,UAAU,IAAI,CAAC,SAAS;AACxC,UAAM,sBAAsB,KAAK,WAAW;AAAA,MAC1C,CAAC,SAAS,KAAK,QAAQ,2BAA2B;AAAA,IACpD;AACA,UAAM,aAAa,sBACf,KAAK,aACL,CAAC,4BAA4B,GAAG,KAAK,UAAU;AAEnD,WAAO;AAAA,MACL,IAAI,KAAK;AAAA,MACT,UAAU,KAAK;AAAA,MACf,eAAe,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,qBAAqB,UAAU;AACjC,UAAM,MAAM,MAAM,OAAO;AACzB,UAAM,gBAAgB,MAAM;AAC1B,UAAI;AACF,eAAO,QAAQ,OAAO,KAAK,IAAI,IAAI,OAAO,EAAE,WAAW;AAAA,MACzD,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF,GAAG;AACH,UAAM,cAAc,eAAe,UAAU;AAC7C,UAAM,YAAY;AAClB,UAAM,
|
|
4
|
+
"sourcesContent": ["\"use server\";\n\nimport type { CartLineAttribute } from \"./cart-types\";\n\nimport { headers } from \"next/headers\";\n\nimport { v4 as uuidv4 } from \"uuid\";\nimport { z } from \"zod\";\n\nimport { getEnv } from \"../env\";\nimport { CanopyError } from \"../lib/canopy-error\";\nimport { getCheckoutProvider } from \"../lib/integration-utils\";\nimport { buildBaseUrl } from \"../lib/url-utils\";\nimport { createCartAction } from \"./cart-actions\";\nimport { REPLO_ATTRIBUTION_PROPERTY } from \"./cart-types\";\n\nclass BuyNowError extends CanopyError {}\nclass BuyNowCartCreationError extends CanopyError {}\n\n/**\n * Server action that handles the full buy-now flow:\n * 1. For Shopify: creates a cart via the canopy-api-backed gateway, returns checkoutUrl.\n * 2. For Stripe: creates a Stripe checkout session via canopy-api, returns session URL.\n *\n * Variant IDs are expected to already be Storefront GIDs (from data loader output).\n * No internal\u2192external ID mapping is needed.\n */\nexport async function buyNowAction(input: {\n lineItems: {\n variantId: string;\n quantity: number;\n sellingPlanId: string | null;\n properties: CartLineAttribute[];\n }[];\n discountCodes: string[];\n pageUrl: string;\n}): Promise<{ redirectUrl: string }> {\n const { lineItems, discountCodes, pageUrl } = input;\n\n const headersList = await headers();\n const host = headersList.get(\"host\");\n if (!host) {\n throw new BuyNowError({ message: \"Missing host header\" });\n }\n const forwardedProto = headersList.get(\"x-forwarded-proto\");\n const protocol = forwardedProto?.split(\",\")[0]?.trim() ?? \"https\";\n const origin = `${protocol}://${host}`;\n\n const checkoutProvider = await getCheckoutProvider();\n\n const cartLines = lineItems.map((item) => {\n const hasReploAttribution = item.properties.some(\n (prop) => prop.key === REPLO_ATTRIBUTION_PROPERTY.key,\n );\n const properties = hasReploAttribution\n ? item.properties\n : [REPLO_ATTRIBUTION_PROPERTY, ...item.properties];\n\n return {\n id: item.variantId,\n quantity: item.quantity,\n sellingPlanId: item.sellingPlanId,\n properties,\n };\n });\n\n if (checkoutProvider === \"stripe\") {\n const env = await getEnv();\n const isSameOrigin = (() => {\n try {\n return Boolean(pageUrl) && new URL(pageUrl).origin === origin;\n } catch {\n return false;\n }\n })();\n const safePageUrl = isSameOrigin ? pageUrl : origin;\n const cancelUrl = safePageUrl;\n const temporaryCartId = uuidv4();\n\n const body = {\n cartId: temporaryCartId,\n lines: cartLines.map((line) => ({\n variantId: line.id,\n quantity: line.quantity,\n properties: line.properties,\n })),\n projectId: env.PROJECT_ID,\n // canopy appends session_id={CHECKOUT_SESSION_ID} at session creation;\n // the success route resolves it into the order status page.\n successUrl: `${origin}/checkout/success`,\n cancelUrl,\n };\n\n const canopyApiUrl = `${buildBaseUrl(env.CANOPY_API_HOST)}/api/v1/stripe-checkout/create-session`;\n const response = await fetch(canopyApiUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n throw new BuyNowCartCreationError({\n message: \"Failed to create Stripe checkout session for buy now\",\n additionalData: {\n status: response.status,\n statusText: response.statusText,\n },\n });\n }\n\n const data = z.object({ url: z.string() }).safeParse(await response.json());\n if (!data.success) {\n throw new BuyNowCartCreationError({\n message: \"Stripe checkout session response missing redirect URL\",\n cause: data.error,\n });\n }\n return { redirectUrl: data.data.url };\n }\n\n // Shopify and other integrations: create cart via canopy-api-backed gateway\n const cart = await createCartAction({\n lines: cartLines,\n skipStoringCart: true,\n discountCodes: discountCodes.length > 0 ? discountCodes : undefined,\n });\n\n if (!cart?.checkoutUrl) {\n throw new BuyNowCartCreationError({\n message: \"Failed to create cart or get checkout URL\",\n additionalData: { lineItems, discountCodes },\n });\n }\n\n const checkoutUrl = new URL(cart.checkoutUrl, origin);\n return { redirectUrl: checkoutUrl.toString() };\n}\n"],
|
|
5
|
+
"mappings": ";AAIA,SAAS,eAAe;AAExB,SAAS,MAAM,cAAc;AAC7B,SAAS,SAAS;AAElB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,kCAAkC;AAE3C,MAAM,oBAAoB,YAAY;AAAC;AACvC,MAAM,gCAAgC,YAAY;AAAC;AAUnD,eAAsB,aAAa,OASE;AACnC,QAAM,EAAE,WAAW,eAAe,QAAQ,IAAI;AAE9C,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,OAAO,YAAY,IAAI,MAAM;AACnC,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,YAAY,EAAE,SAAS,sBAAsB,CAAC;AAAA,EAC1D;AACA,QAAM,iBAAiB,YAAY,IAAI,mBAAmB;AAC1D,QAAM,WAAW,gBAAgB,MAAM,GAAG,EAAE,CAAC,GAAG,KAAK,KAAK;AAC1D,QAAM,SAAS,GAAG,QAAQ,MAAM,IAAI;AAEpC,QAAM,mBAAmB,MAAM,oBAAoB;AAEnD,QAAM,YAAY,UAAU,IAAI,CAAC,SAAS;AACxC,UAAM,sBAAsB,KAAK,WAAW;AAAA,MAC1C,CAAC,SAAS,KAAK,QAAQ,2BAA2B;AAAA,IACpD;AACA,UAAM,aAAa,sBACf,KAAK,aACL,CAAC,4BAA4B,GAAG,KAAK,UAAU;AAEnD,WAAO;AAAA,MACL,IAAI,KAAK;AAAA,MACT,UAAU,KAAK;AAAA,MACf,eAAe,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,qBAAqB,UAAU;AACjC,UAAM,MAAM,MAAM,OAAO;AACzB,UAAM,gBAAgB,MAAM;AAC1B,UAAI;AACF,eAAO,QAAQ,OAAO,KAAK,IAAI,IAAI,OAAO,EAAE,WAAW;AAAA,MACzD,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF,GAAG;AACH,UAAM,cAAc,eAAe,UAAU;AAC7C,UAAM,YAAY;AAClB,UAAM,kBAAkB,OAAO;AAE/B,UAAM,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,OAAO,UAAU,IAAI,CAAC,UAAU;AAAA,QAC9B,WAAW,KAAK;AAAA,QAChB,UAAU,KAAK;AAAA,QACf,YAAY,KAAK;AAAA,MACnB,EAAE;AAAA,MACF,WAAW,IAAI;AAAA;AAAA;AAAA,MAGf,YAAY,GAAG,MAAM;AAAA,MACrB;AAAA,IACF;AAEA,UAAM,eAAe,GAAG,aAAa,IAAI,eAAe,CAAC;AACzD,UAAM,WAAW,MAAM,MAAM,cAAc;AAAA,MACzC,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,wBAAwB;AAAA,QAChC,SAAS;AAAA,QACT,gBAAgB;AAAA,UACd,QAAQ,SAAS;AAAA,UACjB,YAAY,SAAS;AAAA,QACvB;AAAA,MACF,CAAC;AAAA,IACH;AAEA,UAAM,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,MAAM,SAAS,KAAK,CAAC;AAC1E,QAAI,CAAC,KAAK,SAAS;AACjB,YAAM,IAAI,wBAAwB;AAAA,QAChC,SAAS;AAAA,QACT,OAAO,KAAK;AAAA,MACd,CAAC;AAAA,IACH;AACA,WAAO,EAAE,aAAa,KAAK,KAAK,IAAI;AAAA,EACtC;AAGA,QAAM,OAAO,MAAM,iBAAiB;AAAA,IAClC,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,eAAe,cAAc,SAAS,IAAI,gBAAgB;AAAA,EAC5D,CAAC;AAED,MAAI,CAAC,MAAM,aAAa;AACtB,UAAM,IAAI,wBAAwB;AAAA,MAChC,SAAS;AAAA,MACT,gBAAgB,EAAE,WAAW,cAAc;AAAA,IAC7C,CAAC;AAAA,EACH;AAEA,QAAM,cAAc,IAAI,IAAI,KAAK,aAAa,MAAM;AACpD,SAAO,EAAE,aAAa,YAAY,SAAS,EAAE;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { parseJsonOrNull } from './chunk-VKO7P3ED.mjs';
|
|
2
|
+
import { exhaustiveSwitch } from './chunk-H36NDYLG.mjs';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
// ../replo-utils/lib/parse.ts
|
|
6
|
+
function parseSchemaOrNull(value, schema) {
|
|
7
|
+
const parseResult = schema.safeParse(value);
|
|
8
|
+
return parseResult.success ? parseResult.data : null;
|
|
9
|
+
}
|
|
10
|
+
var SELECT_MODE_SELECTABLE_ATTRIBUTE = "data-replo-selectable";
|
|
11
|
+
var SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE = "data-replo-selectable-payload";
|
|
12
|
+
var displayModeSchema = z.enum(["browse", "selection"]).describe("DisplayMode");
|
|
13
|
+
var selectModeInlineTextStatusSchema = z.enum(["editable", "dynamic"]).nullable().describe("SelectModeInlineTextStatus");
|
|
14
|
+
var selectModeTextMetricsSchema = z.object({
|
|
15
|
+
tightWidth: z.number(),
|
|
16
|
+
lineCount: z.number(),
|
|
17
|
+
lineHeight: z.number()
|
|
18
|
+
}).describe("SelectModeTextMetrics");
|
|
19
|
+
var selectModeClickPositionSchema = z.object({
|
|
20
|
+
x: z.number(),
|
|
21
|
+
y: z.number()
|
|
22
|
+
}).describe("SelectModeClickPosition");
|
|
23
|
+
var selectModeSourceLocationSchema = z.object({
|
|
24
|
+
filePath: z.string(),
|
|
25
|
+
lineNumber: z.number(),
|
|
26
|
+
columnNumber: z.number().optional(),
|
|
27
|
+
componentName: z.string().optional()
|
|
28
|
+
}).describe("SelectModeSourceLocation");
|
|
29
|
+
var selectModeFiberChainEntrySchema = z.object({
|
|
30
|
+
sourceLocation: selectModeSourceLocationSchema,
|
|
31
|
+
tagName: z.string().optional(),
|
|
32
|
+
componentName: z.string().optional(),
|
|
33
|
+
props: z.record(z.string(), z.unknown()).optional()
|
|
34
|
+
}).describe("SelectModeFiberChainEntry");
|
|
35
|
+
var selectModeBoundingRectSchema = z.object({
|
|
36
|
+
x: z.number(),
|
|
37
|
+
y: z.number(),
|
|
38
|
+
left: z.number(),
|
|
39
|
+
top: z.number(),
|
|
40
|
+
right: z.number(),
|
|
41
|
+
bottom: z.number(),
|
|
42
|
+
width: z.number(),
|
|
43
|
+
height: z.number()
|
|
44
|
+
}).describe("SelectModeBoundingRect");
|
|
45
|
+
var selectModeSelectionRectSchema = z.object({
|
|
46
|
+
id: z.string(),
|
|
47
|
+
rect: selectModeBoundingRectSchema
|
|
48
|
+
}).describe("SelectModeSelectionRect");
|
|
49
|
+
var selectModeStyleAtRuleSchema = z.object({
|
|
50
|
+
type: z.string(),
|
|
51
|
+
text: z.string()
|
|
52
|
+
}).describe("SelectModeStyleAtRule");
|
|
53
|
+
var selectModeStyleVariantSchema = z.object({
|
|
54
|
+
atRules: z.array(selectModeStyleAtRuleSchema),
|
|
55
|
+
pseudo: z.string().nullable()
|
|
56
|
+
}).describe("SelectModeStyleVariant");
|
|
57
|
+
var selectModeDefinedStyleSchema = z.object({
|
|
58
|
+
property: z.string(),
|
|
59
|
+
variant: selectModeStyleVariantSchema.nullable(),
|
|
60
|
+
className: z.string().nullable(),
|
|
61
|
+
raw: z.string(),
|
|
62
|
+
resolved: z.string()
|
|
63
|
+
}).describe("SelectModeDefinedStyle");
|
|
64
|
+
function transformRect({
|
|
65
|
+
rect,
|
|
66
|
+
offset
|
|
67
|
+
}) {
|
|
68
|
+
return {
|
|
69
|
+
x: rect.x + offset.left,
|
|
70
|
+
y: rect.y + offset.top,
|
|
71
|
+
left: rect.left + offset.left,
|
|
72
|
+
right: rect.right + offset.left,
|
|
73
|
+
top: rect.top + offset.top,
|
|
74
|
+
bottom: rect.bottom + offset.top,
|
|
75
|
+
width: rect.width,
|
|
76
|
+
height: rect.height
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function transformPoint({
|
|
80
|
+
point,
|
|
81
|
+
offset
|
|
82
|
+
}) {
|
|
83
|
+
return {
|
|
84
|
+
x: point.x + offset.left,
|
|
85
|
+
y: point.y + offset.top
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function getIframeOffset(iframe) {
|
|
89
|
+
if (!iframe) {
|
|
90
|
+
return { left: 0, top: 0 };
|
|
91
|
+
}
|
|
92
|
+
const iframeRect = iframe.getBoundingClientRect();
|
|
93
|
+
return { left: iframeRect.left, top: iframeRect.top };
|
|
94
|
+
}
|
|
95
|
+
var selectedElementSchema = z.object({
|
|
96
|
+
kind: z.literal("react-element"),
|
|
97
|
+
selector: z.string(),
|
|
98
|
+
tagName: z.string(),
|
|
99
|
+
elementType: z.string(),
|
|
100
|
+
textContent: z.string().nullable(),
|
|
101
|
+
rect: selectModeBoundingRectSchema,
|
|
102
|
+
textMetrics: selectModeTextMetricsSchema.nullable(),
|
|
103
|
+
outerHTML: z.string(),
|
|
104
|
+
definedStyles: z.array(selectModeDefinedStyleSchema).default([]),
|
|
105
|
+
inheritedStyles: z.record(z.string(), z.string()).default({}),
|
|
106
|
+
clickPosition: selectModeClickPositionSchema,
|
|
107
|
+
sourceLocation: selectModeSourceLocationSchema.optional(),
|
|
108
|
+
fiberChain: z.array(selectModeFiberChainEntrySchema).default([]),
|
|
109
|
+
siblingSelectors: z.array(z.string()).default([])
|
|
110
|
+
}).describe("SelectedElement");
|
|
111
|
+
var selectablePlanDataSchema = z.object({
|
|
112
|
+
kind: z.literal("plan"),
|
|
113
|
+
planId: z.string(),
|
|
114
|
+
label: z.string(),
|
|
115
|
+
rect: selectModeBoundingRectSchema
|
|
116
|
+
}).describe("SelectablePlanData");
|
|
117
|
+
var selectablePlanPayloadSchema = selectablePlanDataSchema.omit({ rect: true }).describe("SelectablePlanPayload");
|
|
118
|
+
var selectableDataPayloadSchema = z.discriminatedUnion("kind", [selectablePlanPayloadSchema]).describe("SelectableDataPayload");
|
|
119
|
+
var selectableDataSchema = z.discriminatedUnion("kind", [selectedElementSchema, selectablePlanDataSchema]).describe("SelectableData");
|
|
120
|
+
function transformSelectableData({
|
|
121
|
+
data,
|
|
122
|
+
offset
|
|
123
|
+
}) {
|
|
124
|
+
return exhaustiveSwitch(
|
|
125
|
+
data,
|
|
126
|
+
"kind"
|
|
127
|
+
)({
|
|
128
|
+
"react-element": (element) => ({
|
|
129
|
+
...element,
|
|
130
|
+
rect: transformRect({ rect: element.rect, offset }),
|
|
131
|
+
clickPosition: transformPoint({
|
|
132
|
+
point: element.clickPosition,
|
|
133
|
+
offset
|
|
134
|
+
})
|
|
135
|
+
}),
|
|
136
|
+
plan: (plan) => ({
|
|
137
|
+
...plan,
|
|
138
|
+
rect: transformRect({ rect: plan.rect, offset })
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function readSelectablePayload(rawPayload) {
|
|
143
|
+
if (!rawPayload) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const parsedPayload = parseJsonOrNull(rawPayload);
|
|
147
|
+
if (!parsedPayload) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return parseSchemaOrNull(parsedPayload, selectableDataPayloadSchema);
|
|
151
|
+
}
|
|
152
|
+
var selectModeOptimisticUpdatePayloadSchema = z.discriminatedUnion("kind", [
|
|
153
|
+
z.object({
|
|
154
|
+
kind: z.literal("css"),
|
|
155
|
+
property: z.string(),
|
|
156
|
+
value: z.string().nullable()
|
|
157
|
+
}),
|
|
158
|
+
z.object({
|
|
159
|
+
kind: z.literal("content"),
|
|
160
|
+
innerHTML: z.string()
|
|
161
|
+
}),
|
|
162
|
+
z.object({
|
|
163
|
+
kind: z.literal("attribute"),
|
|
164
|
+
name: z.string(),
|
|
165
|
+
value: z.string()
|
|
166
|
+
})
|
|
167
|
+
]).describe("SelectModeOptimisticUpdatePayload");
|
|
168
|
+
var selectModeTiptapActiveMarksSchema = z.object({
|
|
169
|
+
bold: z.boolean(),
|
|
170
|
+
italic: z.boolean(),
|
|
171
|
+
underline: z.boolean(),
|
|
172
|
+
strike: z.boolean()
|
|
173
|
+
}).describe("SelectModeTiptapActiveMarks");
|
|
174
|
+
var selectModeFormatCommandSchema = z.enum(["toggleBold", "toggleItalic", "toggleUnderline", "toggleStrike"]).describe("SelectModeFormatCommand");
|
|
175
|
+
var selectModeSelectionTypeSchema = z.enum(["none", "element", "area", "drag"]).describe("SelectModeSelectionType");
|
|
176
|
+
var selectModeSelectionSchema = z.discriminatedUnion("type", [
|
|
177
|
+
z.object({ type: z.literal("none") }),
|
|
178
|
+
z.object({
|
|
179
|
+
type: z.literal("element"),
|
|
180
|
+
data: selectableDataSchema
|
|
181
|
+
}),
|
|
182
|
+
z.object({
|
|
183
|
+
type: z.literal("area"),
|
|
184
|
+
rect: selectModeBoundingRectSchema,
|
|
185
|
+
items: z.array(selectableDataSchema)
|
|
186
|
+
}),
|
|
187
|
+
z.object({
|
|
188
|
+
type: z.literal("drag"),
|
|
189
|
+
dragRect: selectModeBoundingRectSchema,
|
|
190
|
+
// Bounding boxes of the selectables the drag currently intersects,
|
|
191
|
+
// rendered as lighter highlights so the user can see what the drag
|
|
192
|
+
// will capture before they release.
|
|
193
|
+
selectionRects: z.array(selectModeSelectionRectSchema)
|
|
194
|
+
})
|
|
195
|
+
]).describe("SelectModeSelection");
|
|
196
|
+
|
|
197
|
+
export { SELECT_MODE_SELECTABLE_ATTRIBUTE, SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE, displayModeSchema, getIframeOffset, readSelectablePayload, selectModeBoundingRectSchema, selectModeClickPositionSchema, selectModeDefinedStyleSchema, selectModeFiberChainEntrySchema, selectModeFormatCommandSchema, selectModeInlineTextStatusSchema, selectModeOptimisticUpdatePayloadSchema, selectModeSelectionRectSchema, selectModeSelectionSchema, selectModeSelectionTypeSchema, selectModeSourceLocationSchema, selectModeStyleAtRuleSchema, selectModeStyleVariantSchema, selectModeTextMetricsSchema, selectModeTiptapActiveMarksSchema, selectableDataPayloadSchema, selectableDataSchema, selectablePlanDataSchema, selectablePlanPayloadSchema, selectedElementSchema, transformPoint, transformRect, transformSelectableData };
|
|
@@ -1404,10 +1404,10 @@ var mergeWith_default = mergeWith;
|
|
|
1404
1404
|
|
|
1405
1405
|
// ../replo-utils/lib/misc.ts
|
|
1406
1406
|
function isNotNullish(value) {
|
|
1407
|
-
return value
|
|
1407
|
+
return value !== null && value !== void 0;
|
|
1408
1408
|
}
|
|
1409
1409
|
function isNullish(value) {
|
|
1410
|
-
return value
|
|
1410
|
+
return value === null || value === void 0;
|
|
1411
1411
|
}
|
|
1412
1412
|
function getFromRecordOrNull(record, key) {
|
|
1413
1413
|
return key ? record?.[key] ?? null : null;
|
|
@@ -1481,7 +1481,7 @@ function hasOwnProperty12(obj, prop) {
|
|
|
1481
1481
|
return obj?.hasOwnProperty(prop) || false;
|
|
1482
1482
|
}
|
|
1483
1483
|
function coerceNumberToString(value) {
|
|
1484
|
-
if (value
|
|
1484
|
+
if (isNotNullish(value)) {
|
|
1485
1485
|
return String(value);
|
|
1486
1486
|
}
|
|
1487
1487
|
return value;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { v4 } from 'uuid';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
// ../replo-utils/lib/crypto.ts
|
|
5
|
+
function randomUUID() {
|
|
6
|
+
return v4();
|
|
7
|
+
}
|
|
8
|
+
var ReploError = class _ReploError extends Error {
|
|
9
|
+
config;
|
|
10
|
+
id;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
super(config.message);
|
|
13
|
+
this.message = config.message ?? this.constructor.name;
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.id = randomUUID();
|
|
16
|
+
const cause = config.cause;
|
|
17
|
+
if (cause) {
|
|
18
|
+
this.cause = cause;
|
|
19
|
+
if (cause instanceof _ReploError) {
|
|
20
|
+
this.config.additionalData = {
|
|
21
|
+
...this.config.additionalData,
|
|
22
|
+
...cause.config.additionalData
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var errorUserFacingDetailsMessageSchema = z.object({
|
|
29
|
+
type: z.enum([
|
|
30
|
+
"toast",
|
|
31
|
+
"fullPageModal",
|
|
32
|
+
"shopifyStorePassword",
|
|
33
|
+
"billing.addPublishedElements",
|
|
34
|
+
"billing.addShopifyThemeProject",
|
|
35
|
+
"billing.addReploSite",
|
|
36
|
+
// Agent Billing ONLY
|
|
37
|
+
"agentBilling.shopifyThemeBuilder.publishedElements.exceeded",
|
|
38
|
+
"agentBilling.shopifyThemeBuilder.projects.exceeded",
|
|
39
|
+
"agentBilling.sites.exceeded",
|
|
40
|
+
"agentBilling.credits.exceeded",
|
|
41
|
+
"agentBilling.upgradeRequired"
|
|
42
|
+
]),
|
|
43
|
+
message: z.string(),
|
|
44
|
+
isRecoverable: z.boolean().optional(),
|
|
45
|
+
// NOTE (Matt 2024-03-22): We support detail being an array of strings
|
|
46
|
+
// in FullPageModal only.
|
|
47
|
+
detail: z.array(z.string()).or(z.string()).optional(),
|
|
48
|
+
key: z.string(),
|
|
49
|
+
usage: z.object({
|
|
50
|
+
current: z.number(),
|
|
51
|
+
maximum: z.number()
|
|
52
|
+
}).optional(),
|
|
53
|
+
plan: z.string().optional(),
|
|
54
|
+
callToAction: z.discriminatedUnion("type", [
|
|
55
|
+
z.object({ type: z.literal("reload") }),
|
|
56
|
+
z.object({ type: z.literal("installApp") }),
|
|
57
|
+
z.object({ type: z.literal("goToHomepage") }),
|
|
58
|
+
z.object({ type: z.literal("navigateToProjectEditor") }),
|
|
59
|
+
z.object({ type: z.literal("closeModal") }),
|
|
60
|
+
z.object({
|
|
61
|
+
type: z.literal("navigateToLink"),
|
|
62
|
+
link: z.discriminatedUnion("type", [
|
|
63
|
+
z.object({ type: z.literal("errors.wrongJsonExtension") }),
|
|
64
|
+
z.object({ type: z.literal("errors.chunkingError") }),
|
|
65
|
+
z.object({ type: z.literal("errors.indexBackupError") }),
|
|
66
|
+
z.object({
|
|
67
|
+
type: z.literal("errors.shopifyIntegrationAlreadyAssigned")
|
|
68
|
+
}),
|
|
69
|
+
z.object({
|
|
70
|
+
type: z.literal("errors.shopifyIntegrationMissingAccessScopes"),
|
|
71
|
+
url: z.string()
|
|
72
|
+
}),
|
|
73
|
+
z.object({
|
|
74
|
+
type: z.literal("customLink"),
|
|
75
|
+
url: z.string()
|
|
76
|
+
}),
|
|
77
|
+
z.object({
|
|
78
|
+
type: z.literal(
|
|
79
|
+
"errors.projectConnectedToBillingIntegrationForShopifyWorkspace"
|
|
80
|
+
)
|
|
81
|
+
}),
|
|
82
|
+
z.object({ type: z.literal("errors.themeAssetSizeLimitExceeded") }),
|
|
83
|
+
z.object({ type: z.literal("errors.themeTotalSizeLimitExceeded") }),
|
|
84
|
+
z.object({
|
|
85
|
+
type: z.literal("errors.pageMetafieldDefinitionsChanged")
|
|
86
|
+
}),
|
|
87
|
+
z.object({ type: z.literal("settings.billing") })
|
|
88
|
+
])
|
|
89
|
+
})
|
|
90
|
+
]).optional()
|
|
91
|
+
}).describe("ErrorUserFacingDetailsWithMessage");
|
|
92
|
+
z.discriminatedUnion("type", [
|
|
93
|
+
/**
|
|
94
|
+
* Normal errors, show error UI depending on the type
|
|
95
|
+
*/
|
|
96
|
+
errorUserFacingDetailsMessageSchema,
|
|
97
|
+
/**
|
|
98
|
+
* Errors which should be ignored by the frontend. This is uncommon, usually
|
|
99
|
+
* you want to show an error in the UI, and if you don't want to then you catch
|
|
100
|
+
* the error in your route.
|
|
101
|
+
*/
|
|
102
|
+
z.object({
|
|
103
|
+
type: z.literal("uncommon_none"),
|
|
104
|
+
key: z.string(),
|
|
105
|
+
usage: z.object({
|
|
106
|
+
current: z.number(),
|
|
107
|
+
maximum: z.number()
|
|
108
|
+
}).optional(),
|
|
109
|
+
message: z.string().optional(),
|
|
110
|
+
isRecoverable: z.boolean().optional(),
|
|
111
|
+
detail: z.array(z.string()).or(z.string()).optional()
|
|
112
|
+
})
|
|
113
|
+
]).describe("ErrorUserFacingDetails");
|
|
114
|
+
var IframeRpcChannelError = class extends ReploError {
|
|
115
|
+
};
|
|
116
|
+
var IframeRpcChannelTimeoutError = class extends IframeRpcChannelError {
|
|
117
|
+
constructor({ method, timeoutMs }) {
|
|
118
|
+
super({
|
|
119
|
+
message: `RPC method '${method}' timed out after ${timeoutMs}ms`,
|
|
120
|
+
additionalData: { method, timeoutMs }
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
var IframeRpcChannelRemoteError = class extends IframeRpcChannelError {
|
|
125
|
+
constructor({ method, message }) {
|
|
126
|
+
super({
|
|
127
|
+
message: `RPC method '${method}' failed: ${message}`,
|
|
128
|
+
additionalData: { method }
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var IframeRpcChannelUnsubscribedError = class extends IframeRpcChannelError {
|
|
133
|
+
constructor({ method }) {
|
|
134
|
+
super({
|
|
135
|
+
message: `RPC was unsubscribed while '${method}' was pending`,
|
|
136
|
+
additionalData: { method }
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var IframeRpcChannelUnknownMethodError = class extends IframeRpcChannelError {
|
|
141
|
+
constructor({ method }) {
|
|
142
|
+
super({
|
|
143
|
+
message: `Unknown RPC method '${method}'`,
|
|
144
|
+
additionalData: { method }
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
var IframeRpcChannelConfigurationError = class extends IframeRpcChannelError {
|
|
149
|
+
constructor({ message }) {
|
|
150
|
+
super({ message });
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var IframeRpcChannelInvalidInputError = class extends IframeRpcChannelError {
|
|
154
|
+
constructor({ method, cause }) {
|
|
155
|
+
super({
|
|
156
|
+
message: `Invalid RPC input for '${method}': ${cause.message}`,
|
|
157
|
+
cause,
|
|
158
|
+
additionalData: { method }
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export { IframeRpcChannelConfigurationError, IframeRpcChannelInvalidInputError, IframeRpcChannelRemoteError, IframeRpcChannelTimeoutError, IframeRpcChannelUnknownMethodError, IframeRpcChannelUnsubscribedError, ReploError, randomUUID };
|