@replohq/canopy-sdk 0.12.0 → 0.13.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.
Files changed (135) hide show
  1. package/_vendor/replo-utils/lib/errors.d.ts +83 -0
  2. package/_vendor/replo-utils/lib/fonts.mjs +2 -40
  3. package/_vendor/replo-utils/lib/json.mjs +1 -1
  4. package/_vendor/replo-utils/lib/misc.mjs +2 -2
  5. package/_vendor/schemas/agentTools/customIntegrations/loaders/levanta.d.ts +49 -0
  6. package/_vendor/schemas/agentTools/customIntegrations/loaders/levanta.mjs +36 -0
  7. package/_vendor/schemas/agentTools/customIntegrations/loaders/product.d.ts +340 -0
  8. package/_vendor/schemas/agentTools/customIntegrations/loaders/product.mjs +51 -0
  9. package/_vendor/schemas/agentTools/customIntegrations/loaders/yotpo.d.ts +37 -0
  10. package/_vendor/schemas/agentTools/customIntegrations/loaders/yotpo.mjs +37 -0
  11. package/{cart/cart-schema.js → _vendor/schemas/cart.mjs} +17 -26
  12. package/_vendor/schemas/designLibrary.d.ts +4 -4
  13. package/_vendor/schemas/errors.d.ts +438 -0
  14. package/_vendor/schemas/errors.mjs +932 -0
  15. package/_vendor/schemas/generated/errors.d.ts +61 -0
  16. package/_vendor/schemas/generated/selectMode.d.ts +102 -0
  17. package/{loaders/loader-keys.d.ts → _vendor/schemas/loaderKeys.d.ts} +4 -4
  18. package/{loaders/loader-keys.js → _vendor/schemas/loaderKeys.mjs} +7 -8
  19. package/_vendor/schemas/objectType.d.ts +1038 -0
  20. package/_vendor/schemas/objectType.mjs +2 -0
  21. package/_vendor/schemas/registry.d.ts +539 -0
  22. package/_vendor/schemas/sandboxFiles.d.ts +36 -0
  23. package/_vendor/schemas/savedStyles.d.ts +2 -2
  24. package/_vendor/schemas/selectMode.d.ts +471 -0
  25. package/_vendor/schemas/selectMode.mjs +120 -4
  26. package/_vendor/schemas/sellingPlan.d.ts +60 -0
  27. package/_vendor/schemas/sellingPlan.mjs +1 -0
  28. package/cart/buy-now-action.js +3 -3
  29. package/cart/buy-now-action.js.map +2 -2
  30. package/cart/cart-provider.js +2 -2
  31. package/cart/cart-provider.js.map +2 -2
  32. package/cart/cart-types.d.ts +2 -1
  33. package/cart/cart-types.js.map +2 -2
  34. package/cart/hooks/use-add-to-cart.js +1 -1
  35. package/cart/hooks/use-add-to-cart.js.map +2 -2
  36. package/cart/hooks/use-buy-now.js +2 -2
  37. package/cart/hooks/use-buy-now.js.map +2 -2
  38. package/cart/utils/variant-to-cart-line.d.ts +1 -2
  39. package/cart/utils/variant-to-cart-line.js.map +1 -1
  40. package/chunk-4XLTENDR.mjs +33 -0
  41. package/chunk-A7EUNWRQ.mjs +765 -0
  42. package/{chunk-ME5W2TJM.mjs → chunk-OCB5XQYL.mjs} +2 -2
  43. package/chunk-QFYIXADC.mjs +42 -0
  44. package/editor/LinkInterceptor.js +4 -0
  45. package/editor/LinkInterceptor.js.map +2 -2
  46. package/editor/select-mode/EditorSelection.js +74 -1
  47. package/editor/select-mode/EditorSelection.js.map +2 -2
  48. package/editor/select-mode/descriptor/elementDescriptor.d.ts +13 -2
  49. package/editor/select-mode/descriptor/elementDescriptor.js +19 -31
  50. package/editor/select-mode/descriptor/elementDescriptor.js.map +2 -2
  51. package/editor/select-mode/descriptor/styleExtraction.d.ts +3 -0
  52. package/editor/select-mode/descriptor/styleExtraction.js +271 -0
  53. package/editor/select-mode/descriptor/styleExtraction.js.map +7 -0
  54. package/editor/select-mode/displayModeStore.d.ts +10 -0
  55. package/editor/select-mode/displayModeStore.js +47 -0
  56. package/editor/select-mode/displayModeStore.js.map +7 -0
  57. package/editor/select-mode/fast-refresh-relay.d.ts +3 -0
  58. package/editor/select-mode/fast-refresh-relay.js +35 -0
  59. package/editor/select-mode/fast-refresh-relay.js.map +7 -0
  60. package/editor/select-mode/fiber.d.ts +17 -0
  61. package/editor/select-mode/fiber.js +103 -34
  62. package/editor/select-mode/fiber.js.map +2 -2
  63. package/editor/select-mode/hooks/useEditModeStateMachine.d.ts +20 -0
  64. package/editor/select-mode/hooks/useEditModeStateMachine.js +226 -0
  65. package/editor/select-mode/hooks/useEditModeStateMachine.js.map +7 -0
  66. package/editor/select-mode/hooks/useOptimisticOverrides.d.ts +20 -0
  67. package/editor/select-mode/hooks/useOptimisticOverrides.js +284 -0
  68. package/editor/select-mode/hooks/useOptimisticOverrides.js.map +7 -0
  69. package/editor/select-mode/hooks/useParentMessaging.d.ts +17 -2
  70. package/editor/select-mode/hooks/useParentMessaging.js +66 -1
  71. package/editor/select-mode/hooks/useParentMessaging.js.map +2 -2
  72. package/editor/select-mode/hooks/useSelectModeController.js +5 -6
  73. package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
  74. package/editor/select-mode/hooks/useSelectionHover.js +16 -1
  75. package/editor/select-mode/hooks/useSelectionHover.js.map +2 -2
  76. package/editor/select-mode/hooks/useSelectionInteractions.d.ts +7 -2
  77. package/editor/select-mode/hooks/useSelectionInteractions.js +57 -18
  78. package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
  79. package/editor/select-mode/hooks/useSiblingResolution.d.ts +6 -0
  80. package/editor/select-mode/hooks/useSiblingResolution.js +59 -0
  81. package/editor/select-mode/hooks/useSiblingResolution.js.map +7 -0
  82. package/editor/select-mode/inlineTextMarks.d.ts +6 -0
  83. package/editor/select-mode/inlineTextMarks.js +25 -0
  84. package/editor/select-mode/inlineTextMarks.js.map +7 -0
  85. package/editor/select-mode/interactions/selectionGeometry.js +4 -0
  86. package/editor/select-mode/interactions/selectionGeometry.js.map +2 -2
  87. package/editor/select-mode/selectionFrame.d.ts +5 -0
  88. package/editor/select-mode/selectionFrame.js +25 -1
  89. package/editor/select-mode/selectionFrame.js.map +2 -2
  90. package/editor/select-mode/symbolicate.js +32 -10
  91. package/editor/select-mode/symbolicate.js.map +2 -2
  92. package/editor/select-mode/tiptapInlineEditor.d.ts +23 -0
  93. package/editor/select-mode/tiptapInlineEditor.js +120 -0
  94. package/editor/select-mode/tiptapInlineEditor.js.map +7 -0
  95. package/gateways/canopy-api.d.ts +3 -3
  96. package/gateways/canopy-api.js +3 -3
  97. package/gateways/canopy-api.js.map +2 -2
  98. package/loaders/collection-loader.d.ts +1 -1
  99. package/loaders/collection-loader.js +1 -1
  100. package/loaders/collection-loader.js.map +2 -2
  101. package/loaders/collection-products-loader.d.ts +1 -1
  102. package/loaders/collection-products-loader.js +1 -1
  103. package/loaders/collection-products-loader.js.map +2 -2
  104. package/loaders/invoke-loader.d.ts +2 -2
  105. package/loaders/invoke-loader.js +2 -2
  106. package/loaders/invoke-loader.js.map +2 -2
  107. package/loaders/levanta-product-loader.d.ts +1 -1
  108. package/loaders/levanta-product-loader.js +1 -1
  109. package/loaders/levanta-product-loader.js.map +2 -2
  110. package/loaders/okendo-reviews-loader.js +1 -1
  111. package/loaders/okendo-reviews-loader.js.map +2 -2
  112. package/loaders/prefetch-loaders.d.ts +1 -1
  113. package/loaders/prefetch-loaders.js.map +1 -1
  114. package/loaders/product-loader.d.ts +1 -1
  115. package/loaders/product-loader.js +1 -1
  116. package/loaders/product-loader.js.map +2 -2
  117. package/loaders/rebuy-recommendations-loader.js +1 -1
  118. package/loaders/rebuy-recommendations-loader.js.map +2 -2
  119. package/loaders/yotpo-review-aggregate-loader.d.ts +1 -1
  120. package/loaders/yotpo-review-aggregate-loader.js +1 -1
  121. package/loaders/yotpo-review-aggregate-loader.js.map +2 -2
  122. package/loaders/yotpo-reviews-loader.d.ts +1 -1
  123. package/loaders/yotpo-reviews-loader.js +1 -1
  124. package/loaders/yotpo-reviews-loader.js.map +2 -2
  125. package/package.json +9 -1
  126. package/cart/cart-schema.js.map +0 -7
  127. package/lib/canopy-error.d.ts +0 -25
  128. package/lib/canopy-error.js +0 -24
  129. package/lib/canopy-error.js.map +0 -7
  130. package/loaders/loader-keys.js.map +0 -7
  131. package/loaders/loader-schemas.d.ts +0 -755
  132. package/loaders/loader-schemas.js +0 -257
  133. package/loaders/loader-schemas.js.map +0 -7
  134. package/{cart/cart-schema.d.ts → _vendor/schemas/cart.d.ts} +0 -0
  135. package/{chunk-NCKKAFF7.mjs → chunk-ILGEM42C.mjs} +7 -7
@@ -144,20 +144,42 @@ function applyResolved({
144
144
  };
145
145
  }
146
146
  async function symbolicateSelectedElement(selectedElement) {
147
- const sourceLocation = selectedElement.sourceLocation;
148
- if (!sourceLocation || !isLikelyCompiledLocation(sourceLocation)) {
147
+ const targets = [];
148
+ const fiberChain = selectedElement.fiberChain.map((entry) => ({ ...entry }));
149
+ for (const entry of fiberChain) {
150
+ if (isLikelyCompiledLocation(entry.sourceLocation)) {
151
+ targets.push({
152
+ location: entry.sourceLocation,
153
+ apply: (next) => {
154
+ entry.sourceLocation = next;
155
+ }
156
+ });
157
+ }
158
+ }
159
+ let sourceLocation = selectedElement.sourceLocation;
160
+ if (sourceLocation && isLikelyCompiledLocation(sourceLocation)) {
161
+ const captured = sourceLocation;
162
+ targets.push({
163
+ location: captured,
164
+ apply: (next) => {
165
+ sourceLocation = next;
166
+ }
167
+ });
168
+ }
169
+ if (targets.length === 0) {
149
170
  return selectedElement;
150
171
  }
151
- const resolved = await symbolicateFrames([toNextStackFrame(sourceLocation)]);
152
- const frame = extractResolvedFrame(resolved[0] ?? null);
153
- const nextLocation = applyResolved({ original: sourceLocation, frame });
154
- console.log("[selectMode] symbolicate: resolved", {
155
- before: sourceLocation.filePath,
156
- after: nextLocation.filePath
157
- });
172
+ const resolved = await symbolicateFrames(
173
+ targets.map((target) => toNextStackFrame(target.location))
174
+ );
175
+ for (const [index, target] of targets.entries()) {
176
+ const frame = extractResolvedFrame(resolved[index] ?? null);
177
+ target.apply(applyResolved({ original: target.location, frame }));
178
+ }
158
179
  return {
159
180
  ...selectedElement,
160
- sourceLocation: nextLocation
181
+ sourceLocation,
182
+ fiberChain
161
183
  };
162
184
  }
163
185
  async function symbolicateSelectedElements(elements) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../editor/select-mode/symbolicate.ts"],
4
- "sourcesContent": ["import type {\n SelectedElement,\n SelectModeSourceLocation,\n} from \"schemas/generated/selectMode\";\n\n/**\n * Runtime source-attribution for React 19 + Next.js Turbopack.\n *\n * React 19 removed `fiber._debugSource`; the only per-element source pointer\n * left is `fiber._debugStack`, whose `.stack` references compiled SSR/client\n * chunks. We POST those compiled frames to Next.js's dev-only\n * `/__nextjs_original-stack-frames` endpoint, which symbolicates them through\n * Turbopack's in-memory source maps \u2014 the same mechanism the Next error\n * overlay uses (see `next/dist/server/dev/middleware-turbopack.js`).\n */\n\ntype NextStackFrame = {\n file: string | null;\n methodName: string | null;\n arguments: string[];\n // Next.js's `/__nextjs_original-stack-frames` reads these as `line1`/`column1`\n // (1-based) in the request body \u2014 same field names it uses in the response.\n // Sending `lineNumber`/`column` is silently dropped on the server side.\n line1: number | null;\n column1: number | null;\n};\n\ntype ResolvedFrame = {\n file: string | null;\n line1?: number | null;\n column1?: number | null;\n methodName?: string | null;\n ignored?: boolean;\n arguments?: string[];\n};\n\ntype OriginalStackFrameResponse = {\n originalStackFrame: ResolvedFrame | null;\n originalCodeFrame: string | null;\n};\n\ntype SettledResponseEntry =\n | { status: \"fulfilled\"; value: OriginalStackFrameResponse }\n | { status: \"rejected\"; reason: string };\n\nconst SYMBOLICATE_ENDPOINT = \"/__nextjs_original-stack-frames\";\n\nfunction isLikelyCompiledLocation(\n location: SelectModeSourceLocation | undefined,\n): boolean {\n if (!location) {\n return false;\n }\n const filePath = location.filePath;\n return (\n filePath.includes(\".next\") ||\n filePath.includes(\"/chunks/\") ||\n filePath.includes(\"webpack-internal:\") ||\n filePath.includes(\"turbopack:\") ||\n filePath.endsWith(\".js\") ||\n filePath.startsWith(\"about:\")\n );\n}\n\n// React 19 fibers for server-rendered (RSC) elements carry a `_debugStack`\n// whose top frame points at an SSR chunk. The endpoint resolves those\n// against the server bundler context; client chunks go through the client\n// bundler context. Mis-routing returns the compiled chunk unchanged.\nfunction isServerChunk(filePath: string): boolean {\n return (\n filePath.startsWith(\"about://React/Server\") ||\n filePath.includes(\"/server/chunks/\") ||\n filePath.includes(\".next-dev/dev/server/\") ||\n filePath.includes(\".next/server/\")\n );\n}\n\n// Matches the `/_next/static/...` tail of a browser chunk URL's pathname.\n// Capture group 1 is the `/static/...` segment that lives under the dist dir\n// on disk. Mirrors `regexNextStatic` in\n// `next/dist/server/lib/parse-stack.js`.\nconst NEXT_STATIC_PATH_PATTERN = /\\/_next(\\/static\\/.+)/;\n\n// Absolute path to the dev dist dir (e.g.\n// `/workspace/dev/website/.next-dev/dev`). Next.js define-injects this into\n// dev client bundles (see the `__NEXT_DIST_DIR` define in\n// `next/dist/build/define-env.ts`); because canopy-sdk is transpiled into the\n// host Next app, the replacement reaches this reference too. Outside a Next\n// dev client build the value is absent, so we bail and leave the URL as-is.\nfunction getNextDistDir(): string | null {\n try {\n const distDir = process.env.__NEXT_DIST_DIR;\n return typeof distDir === \"string\" && distDir.length > 0 ? distDir : null;\n } catch {\n return null;\n }\n}\n\n// Turbopack's `/__nextjs_original-stack-frames` backend only resolves source\n// maps for `file://` (or bare filesystem) paths \u2014 it rejects browser chunk\n// URLs (`https://host/_next/static/chunks/X.js`) with \"Unknown url scheme\",\n// which is why client-component frames never symbolicated in the sandbox\n// (everything is served over https) even though it worked for RSC frames that\n// already carry filesystem paths. Rewrite the URL to the on-disk dist path the\n// same way Next's own server-side stack parser does, so the endpoint can map\n// it back to the user's `.tsx`.\nfunction rewriteBrowserChunkUrlToDistPath(filePath: string): string {\n if (!/^https?:\\/\\//.test(filePath)) {\n return filePath;\n }\n const distDir = getNextDistDir();\n if (!distDir) {\n return filePath;\n }\n let url: URL;\n try {\n url = new URL(filePath);\n } catch {\n return filePath;\n }\n const staticPathMatch = NEXT_STATIC_PATH_PATTERN.exec(url.pathname);\n if (!staticPathMatch?.[1]) {\n return filePath;\n }\n const normalizedDistDir = distDir.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\");\n return `file://${normalizedDistDir}${staticPathMatch[1]}${url.search}`;\n}\n\n// React 19's `_debugStack.stack` for RSC components wraps the SSR chunk URL\n// in an `about://React/Server/` prefix and appends a `?<digits>` cache-buster.\n// Turbopack's source-map lookup matches against the bare chunk URL; with\n// either decoration in place it returns the compiled chunk unchanged. Client\n// components instead carry a plain browser chunk URL, which Turbopack rejects\n// outright unless rewritten to its on-disk `file://` path.\nfunction normalizeFilePathForSymbolicator(filePath: string): string {\n let normalized = filePath;\n if (normalized.startsWith(\"about://React/Server/\")) {\n normalized = normalized.slice(\"about://React/Server/\".length);\n }\n normalized = normalized.replace(/\\?\\d+$/, \"\");\n return rewriteBrowserChunkUrlToDistPath(normalized);\n}\n\nfunction toNextStackFrame(location: SelectModeSourceLocation): NextStackFrame {\n return {\n file: normalizeFilePathForSymbolicator(location.filePath),\n methodName: location.componentName ?? null,\n arguments: [],\n line1: location.lineNumber,\n column1: location.columnNumber ?? null,\n };\n}\n\nfunction extractResolvedFrame(\n entry: SettledResponseEntry | null,\n): ResolvedFrame | null {\n if (!entry || entry.status !== \"fulfilled\") {\n return null;\n }\n return entry.value?.originalStackFrame ?? null;\n}\n\nasync function postFrames({\n frames,\n isServer,\n}: {\n frames: NextStackFrame[];\n isServer: boolean;\n}): Promise<(SettledResponseEntry | null)[]> {\n if (frames.length === 0) {\n return [];\n }\n try {\n const response = await fetch(SYMBOLICATE_ENDPOINT, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n frames,\n isServer,\n isEdgeServer: false,\n isAppDirectory: true,\n }),\n });\n if (!response.ok) {\n console.log(\"[selectMode] symbolicate: endpoint returned non-OK status\", {\n status: response.status,\n isServer,\n });\n return frames.map(() => null);\n }\n const parsed: unknown = await response.json();\n if (Array.isArray(parsed)) {\n // Promise.allSettled-shaped entries; see\n // node_modules/next/dist/server/dev/middleware-turbopack.js.\n // Legacy cast - the runtime shape isn't exported as a type.\n // eslint-disable-next-line replo/no-as-cast\n return parsed as (SettledResponseEntry | null)[];\n }\n return frames.map(() => null);\n } catch (error) {\n console.log(\"[selectMode] symbolicate: fetch failed\", {\n isServer,\n error,\n });\n return frames.map(() => null);\n }\n}\n\nasync function symbolicateFrames(\n frames: NextStackFrame[],\n): Promise<(SettledResponseEntry | null)[]> {\n const serverIndices: number[] = [];\n const clientIndices: number[] = [];\n for (const [index, frame] of frames.entries()) {\n if (frame.file && isServerChunk(frame.file)) {\n serverIndices.push(index);\n } else {\n clientIndices.push(index);\n }\n }\n\n const [serverResults, clientResults] = await Promise.all([\n postFrames({\n frames: serverIndices.map((index) => frames[index]!),\n isServer: true,\n }),\n postFrames({\n frames: clientIndices.map((index) => frames[index]!),\n isServer: false,\n }),\n ]);\n\n const merged: (SettledResponseEntry | null)[] = frames.map(() => null);\n for (const [position, index] of serverIndices.entries()) {\n merged[index] = serverResults[position] ?? null;\n }\n for (const [position, index] of clientIndices.entries()) {\n merged[index] = clientResults[position] ?? null;\n }\n return merged;\n}\n\nfunction applyResolved({\n original,\n frame,\n}: {\n original: SelectModeSourceLocation;\n frame: ResolvedFrame | null;\n}): SelectModeSourceLocation {\n if (!frame || !frame.file || frame.line1 == null) {\n return original;\n }\n return {\n filePath: frame.file,\n lineNumber: frame.line1,\n columnNumber: frame.column1 ?? undefined,\n componentName: original.componentName,\n };\n}\n\nexport async function symbolicateSelectedElement(\n selectedElement: SelectedElement,\n): Promise<SelectedElement> {\n const sourceLocation = selectedElement.sourceLocation;\n if (!sourceLocation || !isLikelyCompiledLocation(sourceLocation)) {\n return selectedElement;\n }\n\n const resolved = await symbolicateFrames([toNextStackFrame(sourceLocation)]);\n const frame = extractResolvedFrame(resolved[0] ?? null);\n const nextLocation = applyResolved({ original: sourceLocation, frame });\n\n console.log(\"[selectMode] symbolicate: resolved\", {\n before: sourceLocation.filePath,\n after: nextLocation.filePath,\n });\n\n return {\n ...selectedElement,\n sourceLocation: nextLocation,\n };\n}\n\nexport async function symbolicateSelectedElements(\n elements: SelectedElement[],\n): Promise<SelectedElement[]> {\n return Prom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,kBAAkB,CAAC,yBAAyB,cAAc,GAAG;AAChE,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,MAAM,kBAAkB,CAAC,iBAAiB,cAAc,CAAC,CAAC;AAC3E,QAAM,QAAQ,qBAAqB,SAAS,CAAC,KAAK,IAAI;AACtD,QAAM,eAAe,cAAc,EAAE,UAAU,gBAAgB,MAAM,CAAC;AAEtE,UAAQ,IAAI,sCAAsC;AAAA,IAChD,QAAQ,eAAe;AAAA,IACvB,OAAO,aAAa;AAAA,EACtB,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH,gBAAgB;AAAA,EAClB;AACF;AAEA,eAAsB,4BACpB,UAC4B;AAC5B,SAAO,QAAQ,IAAI,SAAS,IAAI,0BAA0B,CAAC;AAC7D;",
4
+ "sourcesContent": ["import type {\n SelectedElement,\n SelectModeFiberChainEntry,\n SelectModeSourceLocation,\n} from \"schemas/generated/selectMode\";\n\n/**\n * Runtime source-attribution for React 19 + Next.js Turbopack.\n *\n * React 19 removed `fiber._debugSource`; the only per-element source pointer\n * left is `fiber._debugStack`, whose `.stack` references compiled SSR/client\n * chunks. We POST those compiled frames to Next.js's dev-only\n * `/__nextjs_original-stack-frames` endpoint, which symbolicates them through\n * Turbopack's in-memory source maps \u2014 the same mechanism the Next error\n * overlay uses (see `next/dist/server/dev/middleware-turbopack.js`).\n */\n\ntype NextStackFrame = {\n file: string | null;\n methodName: string | null;\n arguments: string[];\n // Next.js's `/__nextjs_original-stack-frames` reads these as `line1`/`column1`\n // (1-based) in the request body \u2014 same field names it uses in the response.\n // Sending `lineNumber`/`column` is silently dropped on the server side.\n line1: number | null;\n column1: number | null;\n};\n\ntype ResolvedFrame = {\n file: string | null;\n line1?: number | null;\n column1?: number | null;\n methodName?: string | null;\n ignored?: boolean;\n arguments?: string[];\n};\n\ntype OriginalStackFrameResponse = {\n originalStackFrame: ResolvedFrame | null;\n originalCodeFrame: string | null;\n};\n\ntype SettledResponseEntry =\n | { status: \"fulfilled\"; value: OriginalStackFrameResponse }\n | { status: \"rejected\"; reason: string };\n\nconst SYMBOLICATE_ENDPOINT = \"/__nextjs_original-stack-frames\";\n\nfunction isLikelyCompiledLocation(\n location: SelectModeSourceLocation | undefined,\n): boolean {\n if (!location) {\n return false;\n }\n const filePath = location.filePath;\n return (\n filePath.includes(\".next\") ||\n filePath.includes(\"/chunks/\") ||\n filePath.includes(\"webpack-internal:\") ||\n filePath.includes(\"turbopack:\") ||\n filePath.endsWith(\".js\") ||\n filePath.startsWith(\"about:\")\n );\n}\n\n// React 19 fibers for server-rendered (RSC) elements carry a `_debugStack`\n// whose top frame points at an SSR chunk (e.g. `about://React/Server/file://\n// .../.next-dev/.../server/chunks/ssr/*.js`). The endpoint resolves those\n// against the server bundler context; client chunks go through the client\n// bundler context. Mis-routing returns the compiled chunk unchanged.\nfunction isServerChunk(filePath: string): boolean {\n return (\n filePath.startsWith(\"about://React/Server\") ||\n filePath.includes(\"/server/chunks/\") ||\n filePath.includes(\".next-dev/dev/server/\") ||\n filePath.includes(\".next/server/\")\n );\n}\n\n// Matches the `/_next/static/...` tail of a browser chunk URL's pathname.\n// Capture group 1 is the `/static/...` segment that lives under the dist dir\n// on disk. Mirrors `regexNextStatic` in\n// `next/dist/server/lib/parse-stack.js`.\nconst NEXT_STATIC_PATH_PATTERN = /\\/_next(\\/static\\/.+)/;\n\n// Absolute path to the dev dist dir (e.g.\n// `/workspace/dev/website/.next-dev/dev`). Next.js define-injects this into\n// dev client bundles (see the `__NEXT_DIST_DIR` define in\n// `next/dist/build/define-env.ts`); because canopy-sdk is transpiled into the\n// host Next app, the replacement reaches this reference too. Outside a Next\n// dev client build the value is absent, so we bail and leave the URL as-is.\nfunction getNextDistDir(): string | null {\n try {\n const distDir = process.env.__NEXT_DIST_DIR;\n return typeof distDir === \"string\" && distDir.length > 0 ? distDir : null;\n } catch {\n return null;\n }\n}\n\n// Turbopack's `/__nextjs_original-stack-frames` backend only resolves source\n// maps for `file://` (or bare filesystem) paths \u2014 it rejects browser chunk\n// URLs (`https://host/_next/static/chunks/X.js`) with \"Unknown url scheme\",\n// which is why client-component frames never symbolicated in the sandbox\n// (everything is served over https) even though it worked for RSC frames that\n// already carry filesystem paths. Rewrite the URL to the on-disk dist path the\n// same way Next's own server-side stack parser does, so the endpoint can map\n// it back to the user's `.tsx`.\nfunction rewriteBrowserChunkUrlToDistPath(filePath: string): string {\n if (!/^https?:\\/\\//.test(filePath)) {\n return filePath;\n }\n const distDir = getNextDistDir();\n if (!distDir) {\n return filePath;\n }\n let url: URL;\n try {\n url = new URL(filePath);\n } catch {\n return filePath;\n }\n const staticPathMatch = NEXT_STATIC_PATH_PATTERN.exec(url.pathname);\n if (!staticPathMatch?.[1]) {\n return filePath;\n }\n const normalizedDistDir = distDir.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\");\n return `file://${normalizedDistDir}${staticPathMatch[1]}${url.search}`;\n}\n\n// React 19's `_debugStack.stack` for RSC components wraps the SSR chunk URL\n// in an `about://React/Server/` prefix and appends a `?<digits>` cache-buster\n// (e.g. `about://React/Server/file:///.../[root-of-the-server]__abc._.js?21`).\n// Turbopack's source-map lookup matches against the bare chunk URL; with\n// either decoration in place it returns the compiled chunk unchanged. Client\n// components instead carry a plain browser chunk URL, which Turbopack rejects\n// outright unless rewritten to its on-disk `file://` path.\nfunction normalizeFilePathForSymbolicator(filePath: string): string {\n let normalized = filePath;\n if (normalized.startsWith(\"about://React/Server/\")) {\n normalized = normalized.slice(\"about://React/Server/\".length);\n }\n normalized = normalized.replace(/\\?\\d+$/, \"\");\n return rewriteBrowserChunkUrlToDistPath(normalized);\n}\n\nfunction toNextStackFrame(location: SelectModeSourceLocation): NextStackFrame {\n return {\n file: normalizeFilePathForSymbolicator(location.filePath),\n methodName: location.componentName ?? null,\n arguments: [],\n line1: location.lineNumber,\n column1: location.columnNumber ?? null,\n };\n}\n\nfunction extractResolvedFrame(\n entry: SettledResponseEntry | null,\n): ResolvedFrame | null {\n if (!entry || entry.status !== \"fulfilled\") {\n return null;\n }\n return entry.value?.originalStackFrame ?? null;\n}\n\nasync function postFrames({\n frames,\n isServer,\n}: {\n frames: NextStackFrame[];\n isServer: boolean;\n}): Promise<(SettledResponseEntry | null)[]> {\n if (frames.length === 0) {\n return [];\n }\n try {\n const response = await fetch(SYMBOLICATE_ENDPOINT, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n frames,\n isServer,\n isEdgeServer: false,\n isAppDirectory: true,\n }),\n });\n if (!response.ok) {\n console.log(\"[selectMode] symbolicate: endpoint returned non-OK status\", {\n status: response.status,\n isServer,\n });\n return frames.map(() => null);\n }\n const parsed: unknown = await response.json();\n if (Array.isArray(parsed)) {\n // Promise.allSettled-shaped entries; see\n // node_modules/next/dist/server/dev/middleware-turbopack.js.\n // Legacy cast - the runtime shape isn't exported as a type.\n // eslint-disable-next-line replo/no-as-cast\n return parsed as (SettledResponseEntry | null)[];\n }\n return frames.map(() => null);\n } catch (error) {\n console.log(\"[selectMode] symbolicate: fetch failed\", {\n isServer,\n error,\n });\n return frames.map(() => null);\n }\n}\n\nasync function symbolicateFrames(\n frames: NextStackFrame[],\n): Promise<(SettledResponseEntry | null)[]> {\n const serverIndices: number[] = [];\n const clientIndices: number[] = [];\n for (const [index, frame] of frames.entries()) {\n if (frame.file && isServerChunk(frame.file)) {\n serverIndices.push(index);\n } else {\n clientIndices.push(index);\n }\n }\n\n const [serverResults, clientResults] = await Promise.all([\n postFrames({\n frames: serverIndices.map((index) => frames[index]!),\n isServer: true,\n }),\n postFrames({\n frames: clientIndices.map((index) => frames[index]!),\n isServer: false,\n }),\n ]);\n\n const merged: (SettledResponseEntry | null)[] = frames.map(() => null);\n for (const [position, index] of serverIndices.entries()) {\n merged[index] = serverResults[position] ?? null;\n }\n for (const [position, index] of clientIndices.entries()) {\n merged[index] = clientResults[position] ?? null;\n }\n return merged;\n}\n\nfunction applyResolved({\n original,\n frame,\n}: {\n original: SelectModeSourceLocation;\n frame: ResolvedFrame | null;\n}): SelectModeSourceLocation {\n if (!frame || !frame.file || frame.line1 == null) {\n return original;\n }\n return {\n filePath: frame.file,\n lineNumber: frame.line1,\n columnNumber: frame.column1 ?? undefined,\n componentName: original.componentName,\n };\n}\n\nexport async function symbolicateSelectedElement(\n selectedElement: SelectedElement,\n): Promise<SelectedElement> {\n const targets: {\n location: SelectModeSourceLocation;\n apply: (next: SelectModeSourceLocation) => void;\n }[] = [];\n\n const fiberChain: SelectModeFiberChainEntry[] =\n selectedElement.fiberChain.map((entry) => ({ ...entry }));\n for (const entry of fiberChain) {\n if (isLikelyCompiledLocation(entry.sourceLocation)) {\n targets.push({\n location: entry.sourceLocation,\n apply: (next) => {\n entry.sourceLocation = next;\n },\n });\n }\n }\n\n let sourceLocation = selectedElement.sourceLocation;\n if (sourceLocation && isLikelyCompiledLocation(sourceLocation)) {\n const captured = sourceLocation;\n targets.push({\n location: captured,\n apply: (next) => {\n sourceLocation = next;\n },\n });\n }\n\n if (targets.length === 0) {\n return selectedElement;\n }\n\n const resolved = await symbolicateFrames(\n targets.map((target) => toNextStackFrame(target.location)),\n );\n\n for (const [index, target] of targets.entries()) {\n const frame = extractResolvedFrame(resolved[index] ?? null);\n target.apply(applyResolved({ original: target.location, frame }));\n }\n\n return {\n ...selectedElement,\n sourceLocation,\n fiberChain,\n };\n}\n\nexport async function symbolicateSelectedElements(\n elements: SelectedElement[],\n): Promise<SelectedElement[]> {\n return Promise.all(elements.map(symbolicateSelectedElement));\n}\n"],
5
+ "mappings": "AA8CA,MAAM,uBAAuB;AAE7B,SAAS,yBACP,UACS;AACT,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,QAAM,WAAW,SAAS;AAC1B,SACE,SAAS,SAAS,OAAO,KACzB,SAAS,SAAS,UAAU,KAC5B,SAAS,SAAS,mBAAmB,KACrC,SAAS,SAAS,YAAY,KAC9B,SAAS,SAAS,KAAK,KACvB,SAAS,WAAW,QAAQ;AAEhC;AAOA,SAAS,cA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UAAM,WAAW;AACjB,YAAQ,KAAK;AAAA,MACX,UAAU;AAAA,MACV,OAAO,CAAC,SAAS;AACf,yBAAiB;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,MAAM;AAAA,IACrB,QAAQ,IAAI,CAAC,WAAW,iBAAiB,OAAO,QAAQ,CAAC;AAAA,EAC3D;AAEA,aAAW,CAAC,OAAO,MAAM,KAAK,QAAQ,QAAQ,GAAG;AAC/C,UAAM,QAAQ,qBAAqB,SAAS,KAAK,KAAK,IAAI;AAC1D,WAAO,MAAM,cAAc,EAAE,UAAU,OAAO,UAAU,MAAM,CAAC,CAAC;AAAA,EAClE;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;AAEA,eAAsB,4BACpB,UAC4B;AAC5B,SAAO,QAAQ,IAAI,SAAS,IAAI,0BAA0B,CAAC;AAC7D;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,23 @@
1
+ import type { JSONContent } from "@tiptap/core";
2
+ import type { SelectModeFormatCommand } from "../../_vendor/schemas/generated/selectMode";
3
+ export type InlineTiptapEditor = {
4
+ focus: () => void;
5
+ focusAndSelectAll: () => void;
6
+ destroy: () => void;
7
+ getHTML: () => string;
8
+ getJSON: () => JSONContent;
9
+ runFormatCommand: (command: SelectModeFormatCommand) => void;
10
+ };
11
+ export declare function createInlineTiptapEditor({ element, content, onCommit, onEscape, onBlur, onSelectionUpdate, }: {
12
+ element: HTMLElement;
13
+ content: string;
14
+ onCommit: () => void;
15
+ onEscape: () => void;
16
+ onBlur: () => void;
17
+ onSelectionUpdate: (activeMarks: {
18
+ bold: boolean;
19
+ italic: boolean;
20
+ underline: boolean;
21
+ strike: boolean;
22
+ }) => void;
23
+ }): InlineTiptapEditor;
@@ -0,0 +1,120 @@
1
+ import { Editor, Mark } from "@tiptap/core";
2
+ import Bold from "@tiptap/extension-bold";
3
+ import Document from "@tiptap/extension-document";
4
+ import Italic from "@tiptap/extension-italic";
5
+ import Strike from "@tiptap/extension-strike";
6
+ import Text from "@tiptap/extension-text";
7
+ import Underline from "@tiptap/extension-underline";
8
+ const InlineDocument = Document.extend({
9
+ content: "inline*"
10
+ });
11
+ const InlineLink = Mark.create({
12
+ name: "link",
13
+ inclusive: false,
14
+ addAttributes() {
15
+ return {
16
+ class: { default: null },
17
+ href: { default: null },
18
+ rel: { default: null },
19
+ target: { default: null }
20
+ };
21
+ },
22
+ parseHTML() {
23
+ return [{ tag: "a[href]" }];
24
+ },
25
+ renderHTML({ HTMLAttributes }) {
26
+ return ["a", HTMLAttributes, 0];
27
+ }
28
+ });
29
+ function createInlineTiptapEditor({
30
+ element,
31
+ content,
32
+ onCommit,
33
+ onEscape,
34
+ onBlur,
35
+ onSelectionUpdate
36
+ }) {
37
+ const originalAttributes = Array.from(
38
+ element.attributes,
39
+ ({ name, value }) => ({
40
+ name,
41
+ value
42
+ })
43
+ );
44
+ element.replaceChildren();
45
+ const mount = {
46
+ mount: element
47
+ };
48
+ const editor = new Editor({
49
+ element: mount,
50
+ content,
51
+ extensions: [
52
+ InlineDocument,
53
+ Text,
54
+ Bold,
55
+ Italic,
56
+ Underline,
57
+ Strike,
58
+ InlineLink
59
+ ],
60
+ editorProps: {
61
+ // Drop the browser's default focus ring on the contenteditable — the
62
+ // select-mode selection frame already indicates the edit target.
63
+ attributes: { style: "outline: none;" },
64
+ handleKeyDown: (_view, event) => {
65
+ if (event.key === "Enter" && (event.shiftKey || event.metaKey || event.ctrlKey)) {
66
+ event.preventDefault();
67
+ onCommit();
68
+ return true;
69
+ }
70
+ if (event.key === "Escape") {
71
+ event.preventDefault();
72
+ onEscape();
73
+ return true;
74
+ }
75
+ return false;
76
+ }
77
+ },
78
+ onSelectionUpdate: ({ editor: activeEditor }) => {
79
+ onSelectionUpdate({
80
+ bold: activeEditor.isActive("bold"),
81
+ italic: activeEditor.isActive("italic"),
82
+ underline: activeEditor.isActive("underline"),
83
+ strike: activeEditor.isActive("strike")
84
+ });
85
+ },
86
+ onBlur: () => {
87
+ onBlur();
88
+ }
89
+ });
90
+ return {
91
+ focus: () => editor.commands.focus(),
92
+ // Focus the editor with the full text block selected so the user can type
93
+ // to replace it immediately (or arrow/click to drop the selection).
94
+ focusAndSelectAll: () => editor.chain().focus().selectAll().run(),
95
+ destroy: () => {
96
+ editor.destroy();
97
+ for (const attribute of Array.from(element.attributes)) {
98
+ element.removeAttribute(attribute.name);
99
+ }
100
+ for (const { name, value } of originalAttributes) {
101
+ element.setAttribute(name, value);
102
+ }
103
+ },
104
+ getHTML: () => editor.getHTML(),
105
+ getJSON: () => editor.getJSON(),
106
+ runFormatCommand: (command) => {
107
+ const commandRunners = {
108
+ toggleBold: () => editor.chain().focus().toggleBold().run(),
109
+ toggleItalic: () => editor.chain().focus().toggleItalic().run(),
110
+ toggleUnderline: () => editor.chain().focus().toggleUnderline().run(),
111
+ toggleStrike: () => editor.chain().focus().toggleStrike().run()
112
+ };
113
+ commandRunners[command]();
114
+ }
115
+ };
116
+ }
117
+ export {
118
+ createInlineTiptapEditor
119
+ };
120
+ //# sourceMappingURL=tiptapInlineEditor.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../editor/select-mode/tiptapInlineEditor.ts"],
4
+ "sourcesContent": ["import type { JSONContent } from \"@tiptap/core\";\nimport type { SelectModeFormatCommand } from \"schemas/generated/selectMode\";\n\nimport { Editor, Mark } from \"@tiptap/core\";\nimport Bold from \"@tiptap/extension-bold\";\nimport Document from \"@tiptap/extension-document\";\nimport Italic from \"@tiptap/extension-italic\";\nimport Strike from \"@tiptap/extension-strike\";\nimport Text from \"@tiptap/extension-text\";\nimport Underline from \"@tiptap/extension-underline\";\n\nconst InlineDocument = Document.extend({\n content: \"inline*\",\n});\n\nconst InlineLink = Mark.create({\n name: \"link\",\n inclusive: false,\n addAttributes() {\n return {\n class: { default: null },\n href: { default: null },\n rel: { default: null },\n target: { default: null },\n };\n },\n parseHTML() {\n return [{ tag: \"a[href]\" }];\n },\n renderHTML({ HTMLAttributes }) {\n return [\"a\", HTMLAttributes, 0];\n },\n});\n\nexport type InlineTiptapEditor = {\n focus: () => void;\n focusAndSelectAll: () => void;\n destroy: () => void;\n getHTML: () => string;\n getJSON: () => JSONContent;\n runFormatCommand: (command: SelectModeFormatCommand) => void;\n};\n\nexport function createInlineTiptapEditor({\n element,\n content,\n onCommit,\n onEscape,\n onBlur,\n onSelectionUpdate,\n}: {\n element: HTMLElement;\n content: string;\n onCommit: () => void;\n onEscape: () => void;\n onBlur: () => void;\n onSelectionUpdate: (activeMarks: {\n bold: boolean;\n italic: boolean;\n underline: boolean;\n strike: boolean;\n }) => void;\n}): InlineTiptapEditor {\n const originalAttributes = Array.from(\n element.attributes,\n ({ name, value }) => ({\n name,\n value,\n }),\n );\n // ProseMirror *appends* its contenteditable to the mount node rather than\n // replacing it, so the element's original text node would survive as a\n // sibling and render a duplicate copy. The editor's initial content comes\n // from the `content` option below (not the element's DOM), and the caller\n // keeps the original HTML for revert, so emptying the node here is safe.\n element.replaceChildren();\n const mount = {\n mount: element,\n } as unknown as Element; /* eslint-disable-line replo/no-as-cast -- NOTE (Noah Gilmore, 2026-07-16): ProseMirror accepts this documented direct-mount shape at runtime, but Tiptap v2's Editor option incorrectly narrows it to Element. */\n const editor = new Editor({\n element: mount,\n content,\n extensions: [\n InlineDocument,\n Text,\n Bold,\n Italic,\n Underline,\n Strike,\n InlineLink,\n ],\n editorProps: {\n // Drop the browser's default focus ring on the contenteditable \u2014 the\n // select-mode selection frame already indicates the edit target.\n attributes: { style: \"outline: none;\" },\n handleKeyDown: (_view, event) => {\n // Commit on Shift-Enter or Cmd/Ctrl-Enter; a bare Enter inserts a line\n // break as usual.\n if (\n event.key === \"Enter\" &&\n (event.shiftKey || event.metaKey || event.ctrlKey)\n ) {\n event.preventDefault();\n onCommit();\n return true;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n onEscape();\n return true;\n }\n return false;\n },\n },\n onSelectionUpdate: ({ editor: activeEditor }) => {\n onSelectionUpdate({\n bold: activeEditor.isActive(\"bold\"),\n italic: activeEditor.isActive(\"italic\"),\n underline: activeEditor.isActive(\"underline\"),\n strike: activeEditor.isActive(\"strike\"),\n });\n },\n onBlur: () => {\n onBlur();\n },\n });\n\n return {\n focus: () => editor.commands.focus(),\n // Focus the editor with the full text block selected so the user can type\n // to replace it immediately (or arrow/click to drop the selection).\n focusAndSelectAll: () => editor.chain().focus().selectAll().run(),\n destroy: () => {\n editor.destroy();\n for (const attribute of Array.from(element.attributes)) {\n element.removeAttribute(attribute.name);\n }\n for (const { name, value } of originalAttributes) {\n element.setAttribute(name, value);\n }\n },\n getHTML: () => editor.getHTML(),\n getJSON: () => editor.getJSON(),\n runFormatCommand: (command) => {\n const commandRunners: Record<SelectModeFormatCommand, () => void> = {\n toggleBold: () => editor.chain().focus().toggleBold().run(),\n toggleItalic: () => editor.chain().focus().toggleItalic().run(),\n toggleUnderline: () => editor.chain().focus().toggleUnderline().run(),\n toggleStrike: () => editor.chain().focus().toggleStrike().run(),\n };\n commandRunners[command]();\n },\n };\n}\n"],
5
+ "mappings": "AAGA,SAAS,QAAQ,YAAY;AAC7B,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,YAAY;AACnB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,eAAe;AAEtB,MAAM,iBAAiB,SAAS,OAAO;AAAA,EACrC,SAAS;AACX,CAAC;AAED,MAAM,aAAa,KAAK,OAAO;AAAA,EAC7B,MAAM;AAAA,EACN,WAAW;AAAA,EACX,gBAAgB;AACd,WAAO;AAAA,MACL,OAAO,EAAE,SAAS,KAAK;AAAA,MACvB,MAAM,EAAE,SAAS,KAAK;AAAA,MACtB,KAAK,EAAE,SAAS,KAAK;AAAA,MACrB,QAAQ,EAAE,SAAS,KAAK;AAAA,IAC1B;AAAA,EACF;AAAA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,MAAM;AACZ,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,OAAO,MAAM,OAAO,SAAS,MAAM;AAAA;AAAA;AAAA,IAGnC,mBAAmB,MAAM,OAAO,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI;AAAA,IAChE,SAAS,MAAM;AACb,aAAO,QAAQ;AACf,iBAAW,aAAa,MAAM,KAAK,QAAQ,UAAU,GAAG;AACtD,gBAAQ,gBAAgB,UAAU,IAAI;AAAA,MACxC;AACA,iBAAW,EAAE,MAAM,MAAM,KAAK,oBAAoB;AAChD,gBAAQ,aAAa,MAAM,KAAK;AAAA,MAClC;AAAA,IACF;AAAA,IACA,SAAS,MAAM,OAAO,QAAQ;AAAA,IAC9B,SAAS,MAAM,OAAO,QAAQ;AAAA,IAC9B,kBAAkB,CAAC,YAAY;AAC7B,YAAM,iBAA8D;AAAA,QAClE,YAAY,MAAM,OAAO,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI;AAAA,QAC1D,cAAc,MAAM,OAAO,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI;AAAA,QAC9D,iBAAiB,MAAM,OAAO,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI;AAAA,QACpE,cAAc,MAAM,OAAO,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI;AAAA,MAChE;AACA,qBAAe,OAAO,EAAE;AAAA,IAC1B;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,12 +1,12 @@
1
- import type { Cart } from "../cart/cart-schema";
2
- import { CanopyError } from "../lib/canopy-error";
1
+ import type { Cart } from "../_vendor/schemas/cart";
2
+ import { ReploError } from "../_vendor/schemas/errors";
3
3
  type CanopyApiGatewayErrorConfig = {
4
4
  message: string;
5
5
  statusCode?: number;
6
6
  cause?: unknown;
7
7
  additionalData?: Record<string, unknown>;
8
8
  };
9
- export declare class CanopyApiGatewayError extends CanopyError {
9
+ export declare class CanopyApiGatewayError extends ReploError {
10
10
  statusCode: number;
11
11
  constructor(config: CanopyApiGatewayErrorConfig);
12
12
  }
@@ -1,9 +1,9 @@
1
+ import { cartSchema } from "../_vendor/schemas/cart.mjs";
2
+ import { ReploError } from "../_vendor/schemas/errors.mjs";
1
3
  import { z } from "zod";
2
- import { cartSchema } from "../cart/cart-schema";
3
4
  import { getEnv } from "../env";
4
- import { CanopyError } from "../lib/canopy-error";
5
5
  import { buildBaseUrl } from "../lib/url-utils";
6
- class CanopyApiGatewayError extends CanopyError {
6
+ class CanopyApiGatewayError extends ReploError {
7
7
  statusCode;
8
8
  constructor(config) {
9
9
  const resolvedStatusCode = config.statusCode ?? 500;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../gateways/canopy-api.ts"],
4
- "sourcesContent": ["import type { Cart } from \"../cart/cart-schema\";\n\nimport { z } from \"zod\";\n\nimport { cartSchema } from \"../cart/cart-schema\";\nimport { getEnv } from \"../env\";\nimport { CanopyError } from \"../lib/canopy-error\";\nimport { buildBaseUrl } from \"../lib/url-utils\";\n\ntype CanopyApiGatewayErrorConfig = {\n message: string;\n statusCode?: number;\n cause?: unknown;\n additionalData?: Record<string, unknown>;\n};\n\nexport class CanopyApiGatewayError extends CanopyError {\n statusCode: number;\n\n constructor(config: CanopyApiGatewayErrorConfig) {\n const resolvedStatusCode = config.statusCode ?? 500;\n super({\n message: config.message,\n cause: config.cause,\n additionalData: {\n ...config.additionalData,\n statusCode: resolvedStatusCode,\n },\n });\n this.statusCode = resolvedStatusCode;\n }\n}\n\nexport function isCanopyApiGatewayError(\n error: unknown,\n): error is CanopyApiGatewayError {\n return error instanceof CanopyApiGatewayError;\n}\n\nclass UnknownCanopyApiError extends CanopyApiGatewayError {\n constructor(config: Omit<CanopyApiGatewayErrorConfig, \"statusCode\">) {\n super({ ...config, statusCode: 502 });\n }\n}\n\nconst loaderInvokeResponseSchema = z.object({\n data: z.unknown(),\n meta: z\n .object({\n cache: z.object({\n hit: z.boolean(),\n ttlSeconds: z.number(),\n }),\n })\n .optional(),\n});\n\nclass CanopyApiGateway {\n private apiHost: string;\n private baseUrl: string;\n constructor(apiHost: string) {\n this.apiHost = apiHost;\n this.baseUrl = buildBaseUrl(apiHost);\n }\n\n private static readonly REQUEST_TIMEOUT_MILLISECONDS = 10_000;\n\n static async setup() {\n const env = await getEnv();\n\n return new CanopyApiGateway(env.CANOPY_API_HOST);\n }\n\n private async _post(url: string, body: unknown) {\n const abortController = new AbortController();\n const timeoutId = setTimeout(() => {\n abortController.abort();\n }, CanopyApiGateway.REQUEST_TIMEOUT_MILLISECONDS);\n\n try {\n return await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: abortController.signal,\n });\n } catch (error) {\n let message = `Failed to POST to canopy-api at ${url}: ${error}`;\n if (process.env.NODE_ENV !== \"production\") {\n message += `\\n\\napiHost: ${this.apiHost}\\nIf you're running locally, make sure the canopy-api cloudflare worker is running. You may need to restart the dev server.`;\n }\n throw new UnknownCanopyApiError({ message, cause: error });\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n private async _get(url: string) {\n const abortController = new AbortController();\n const timeoutId = setTimeout(() => {\n abortController.abort();\n }, CanopyApiGateway.REQUEST_TIMEOUT_MILLISECONDS);\n\n try {\n return await fetch(url, { signal: abortController.signal });\n } catch (error) {\n let message = `Failed to GET from canopy-api at ${url}: ${error}`;\n if (process.env.NODE_ENV !== \"production\") {\n message += `\\n\\napiHost: ${this.apiHost}\\nIf you're running locally, make sure the canopy-api cloudflare worker is running. You may need to restart the dev server.`;\n }\n throw new UnknownCanopyApiError({ message, cause: error });\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n async invokeLoader({\n loaderKey,\n args,\n }: {\n loaderKey: string;\n args: Record<string, unknown>;\n }) {\n const env = await getEnv();\n const response = await this._post(`${this.baseUrl}/api/v1/loaders/invoke`, {\n projectId: env.PROJECT_ID,\n loaderKey,\n args,\n });\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => \"\");\n throw new CanopyApiGatewayError({\n message: `Failed to invoke loader ${loaderKey}: ${response.status} ${response.statusText}${errorBody ? ` \u2014 ${errorBody}` : \"\"}`,\n statusCode: response.status,\n });\n }\n\n return loaderInvokeResponseSchema.parse(await response.json());\n }\n\n // ---------------------------------------------------------------------------\n // Cart operations (canopy-api-backed ExternalCart)\n // ---------------------------------------------------------------------------\n\n private async _cartPost(\n path: string,\n body: Record<string, unknown>,\n ): Promise<Cart> {\n const env = await getEnv();\n const authSecret = env.CART_AUTH_SECRET;\n const url = `${this.baseUrl}/api/v1/cart${path}`;\n\n const abortController = new AbortController();\n const timeoutId = setTimeout(() => {\n abortController.abort();\n }, CanopyApiGateway.REQUEST_TIMEOUT_MILLISECONDS);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(authSecret ? { \"X-Replo-Resolver-Auth\": authSecret } : {}),\n },\n body: JSON.stringify({ ...body, projectId: env.PROJECT_ID }),\n signal: abortController.signal,\n });\n } catch (error) {\n throw new UnknownCanopyApiError({\n message: `Failed to POST cart operation to ${url}: ${error}`,\n cause: error,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new CanopyApiGatewayError({\n message: `Cart operation ${path} failed: ${response.status} ${response.statusText} \u2014 ${text}`,\n statusCode: response.status,\n });\n }\n\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const json = (await response.json()) as { data: unknown };\n return cartSchema.parse(json.data);\n }\n\n async cartGet({ cartId }: { cartId: string }): Promise<Cart | null> {\n try {\n return await this._cartPost(\"/get\", { cartId });\n } catch (error) {\n if (error instanceof CanopyApiGatewayError && error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n async cartCreate(options?: {\n lines?: {\n merchandiseId: string;\n quantity: number;\n attributes?: { key: string; value: string }[];\n sellingPlanId?: string | null;\n }[];\n discountCodes?: string[];\n }): Promise<Cart> {\n return this._cartPost(\"/create\", {\n lines: options?.lines,\n discountCodes: options?.discountCodes,\n });\n }\n\n async cartAddLines({\n cartId,\n lines,\n }: {\n cartId: string;\n lines: {\n merchandiseId: string;\n quantity: number;\n attributes?: { key: string; value: string }[];\n sellingPlanId?: string | null;\n }[];\n }): Promise<Cart> {\n return this._cartPost(\"/add-lines\", { cartId, lines });\n }\n\n async cartUpdateLines({\n cartId,\n lines,\n }: {\n cartId: string;\n lines: {\n lineId: string;\n quantity: number;\n attributes?: { key: string; value: string }[];\n sellingPlanId?: string | null;\n }[];\n }): Promise<Cart> {\n return this._cartPost(\"/update-lines\", { cartId, lines });\n }\n\n async cartRemoveLines({\n cartId,\n lineIds,\n }: {\n cartId: string;\n lineIds: string[];\n }): Promise<Cart> {\n return this._cartPost(\"/remove-lines\", { cartId, lineIds });\n }\n\n async cartUpdateDiscountCodes({\n cartId,\n discountCodes,\n }: {\n cartId: string;\n discountCodes: string[];\n }): Promise<Cart> {\n return this._cartPost(\"/update-discount-codes\", { cartId, discountCodes });\n }\n}\n\nexport async function getCanopyApiGateway() {\n return CanopyApiGateway.setup();\n}\n"],
5
- "mappings": "AAEA,SAAS,SAAS;AAElB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAStB,MAAM,8BAA8B,YAAY;AAAA,EACrD;AAAA,EAEA,YAAY,QAAqC;AAC/C,UAAM,qBAAqB,OAAO,cAAc;AAChD,UAAM;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,OAAO,OAAO;AAAA,MACd,gBAAgB;AAAA,QACd,GAAG,OAAO;AAAA,QACV,YAAY;AAAA,MACd;AAAA,IACF,CAAC;AACD,SAAK,aAAa;AAAA,EACpB;AACF;AAEO,SAAS,wBACd,OACgC;AAChC,SAAO,iBAAiB;AAC1B;AAEA,MAAM,8BAA8B,sBAAsB;AAAA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AAAA,MAChB,eAAe,SAAS;AAAA,IAC1B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,EACF,GAQkB;AAChB,WAAO,KAAK,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC;AAAA,EACvD;AAAA,EAEA,MAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,EACF,GAQkB;AAChB,WAAO,KAAK,UAAU,iBAAiB,EAAE,QAAQ,MAAM,CAAC;AAAA,EAC1D;AAAA,EAEA,MAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,EACF,GAGkB;AAChB,WAAO,KAAK,UAAU,iBAAiB,EAAE,QAAQ,QAAQ,CAAC;AAAA,EAC5D;AAAA,EAEA,MAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,GAGkB;AAChB,WAAO,KAAK,UAAU,0BAA0B,EAAE,QAAQ,cAAc,CAAC;AAAA,EAC3E;AACF;AAEA,eAAsB,sBAAsB;AAC1C,SAAO,iBAAiB,MAAM;AAChC;",
4
+ "sourcesContent": ["import type { Cart } from \"schemas/cart\";\n\nimport { cartSchema } from \"schemas/cart\";\nimport { ReploError } from \"schemas/errors\";\nimport { z } from \"zod\";\n\nimport { getEnv } from \"../env\";\nimport { buildBaseUrl } from \"../lib/url-utils\";\n\ntype CanopyApiGatewayErrorConfig = {\n message: string;\n statusCode?: number;\n cause?: unknown;\n additionalData?: Record<string, unknown>;\n};\n\nexport class CanopyApiGatewayError extends ReploError {\n statusCode: number;\n\n constructor(config: CanopyApiGatewayErrorConfig) {\n const resolvedStatusCode = config.statusCode ?? 500;\n super({\n message: config.message,\n cause: config.cause,\n additionalData: {\n ...config.additionalData,\n statusCode: resolvedStatusCode,\n },\n });\n this.statusCode = resolvedStatusCode;\n }\n}\n\nexport function isCanopyApiGatewayError(\n error: unknown,\n): error is CanopyApiGatewayError {\n return error instanceof CanopyApiGatewayError;\n}\n\nclass UnknownCanopyApiError extends CanopyApiGatewayError {\n constructor(config: Omit<CanopyApiGatewayErrorConfig, \"statusCode\">) {\n super({ ...config, statusCode: 502 });\n }\n}\n\nconst loaderInvokeResponseSchema = z.object({\n data: z.unknown(),\n meta: z\n .object({\n cache: z.object({\n hit: z.boolean(),\n ttlSeconds: z.number(),\n }),\n })\n .optional(),\n});\n\nclass CanopyApiGateway {\n private apiHost: string;\n private baseUrl: string;\n constructor(apiHost: string) {\n this.apiHost = apiHost;\n this.baseUrl = buildBaseUrl(apiHost);\n }\n\n private static readonly REQUEST_TIMEOUT_MILLISECONDS = 10_000;\n\n static async setup() {\n const env = await getEnv();\n\n return new CanopyApiGateway(env.CANOPY_API_HOST);\n }\n\n private async _post(url: string, body: unknown) {\n const abortController = new AbortController();\n const timeoutId = setTimeout(() => {\n abortController.abort();\n }, CanopyApiGateway.REQUEST_TIMEOUT_MILLISECONDS);\n\n try {\n return await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: abortController.signal,\n });\n } catch (error) {\n let message = `Failed to POST to canopy-api at ${url}: ${error}`;\n if (process.env.NODE_ENV !== \"production\") {\n message += `\\n\\napiHost: ${this.apiHost}\\nIf you're running locally, make sure the canopy-api cloudflare worker is running. You may need to restart the dev server.`;\n }\n throw new UnknownCanopyApiError({ message, cause: error });\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n private async _get(url: string) {\n const abortController = new AbortController();\n const timeoutId = setTimeout(() => {\n abortController.abort();\n }, CanopyApiGateway.REQUEST_TIMEOUT_MILLISECONDS);\n\n try {\n return await fetch(url, { signal: abortController.signal });\n } catch (error) {\n let message = `Failed to GET from canopy-api at ${url}: ${error}`;\n if (process.env.NODE_ENV !== \"production\") {\n message += `\\n\\napiHost: ${this.apiHost}\\nIf you're running locally, make sure the canopy-api cloudflare worker is running. You may need to restart the dev server.`;\n }\n throw new UnknownCanopyApiError({ message, cause: error });\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n async invokeLoader({\n loaderKey,\n args,\n }: {\n loaderKey: string;\n args: Record<string, unknown>;\n }) {\n const env = await getEnv();\n const response = await this._post(`${this.baseUrl}/api/v1/loaders/invoke`, {\n projectId: env.PROJECT_ID,\n loaderKey,\n args,\n });\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => \"\");\n throw new CanopyApiGatewayError({\n message: `Failed to invoke loader ${loaderKey}: ${response.status} ${response.statusText}${errorBody ? ` \u2014 ${errorBody}` : \"\"}`,\n statusCode: response.status,\n });\n }\n\n return loaderInvokeResponseSchema.parse(await response.json());\n }\n\n // ---------------------------------------------------------------------------\n // Cart operations (canopy-api-backed ExternalCart)\n // ---------------------------------------------------------------------------\n\n private async _cartPost(\n path: string,\n body: Record<string, unknown>,\n ): Promise<Cart> {\n const env = await getEnv();\n const authSecret = env.CART_AUTH_SECRET;\n const url = `${this.baseUrl}/api/v1/cart${path}`;\n\n const abortController = new AbortController();\n const timeoutId = setTimeout(() => {\n abortController.abort();\n }, CanopyApiGateway.REQUEST_TIMEOUT_MILLISECONDS);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(authSecret ? { \"X-Replo-Resolver-Auth\": authSecret } : {}),\n },\n body: JSON.stringify({ ...body, projectId: env.PROJECT_ID }),\n signal: abortController.signal,\n });\n } catch (error) {\n throw new UnknownCanopyApiError({\n message: `Failed to POST cart operation to ${url}: ${error}`,\n cause: error,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new CanopyApiGatewayError({\n message: `Cart operation ${path} failed: ${response.status} ${response.statusText} \u2014 ${text}`,\n statusCode: response.status,\n });\n }\n\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const json = (await response.json()) as { data: unknown };\n return cartSchema.parse(json.data);\n }\n\n async cartGet({ cartId }: { cartId: string }): Promise<Cart | null> {\n try {\n return await this._cartPost(\"/get\", { cartId });\n } catch (error) {\n if (error instanceof CanopyApiGatewayError && error.statusCode === 404) {\n return null;\n }\n throw error;\n }\n }\n\n async cartCreate(options?: {\n lines?: {\n merchandiseId: string;\n quantity: number;\n attributes?: { key: string; value: string }[];\n sellingPlanId?: string | null;\n }[];\n discountCodes?: string[];\n }): Promise<Cart> {\n return this._cartPost(\"/create\", {\n lines: options?.lines,\n discountCodes: options?.discountCodes,\n });\n }\n\n async cartAddLines({\n cartId,\n lines,\n }: {\n cartId: string;\n lines: {\n merchandiseId: string;\n quantity: number;\n attributes?: { key: string; value: string }[];\n sellingPlanId?: string | null;\n }[];\n }): Promise<Cart> {\n return this._cartPost(\"/add-lines\", { cartId, lines });\n }\n\n async cartUpdateLines({\n cartId,\n lines,\n }: {\n cartId: string;\n lines: {\n lineId: string;\n quantity: number;\n attributes?: { key: string; value: string }[];\n sellingPlanId?: string | null;\n }[];\n }): Promise<Cart> {\n return this._cartPost(\"/update-lines\", { cartId, lines });\n }\n\n async cartRemoveLines({\n cartId,\n lineIds,\n }: {\n cartId: string;\n lineIds: string[];\n }): Promise<Cart> {\n return this._cartPost(\"/remove-lines\", { cartId, lineIds });\n }\n\n async cartUpdateDiscountCodes({\n cartId,\n discountCodes,\n }: {\n cartId: string;\n discountCodes: string[];\n }): Promise<Cart> {\n return this._cartPost(\"/update-discount-codes\", { cartId, discountCodes });\n }\n}\n\nexport async function getCanopyApiGateway() {\n return CanopyApiGateway.setup();\n}\n"],
5
+ "mappings": "AAEA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,SAAS;AAElB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAStB,MAAM,8BAA8B,WAAW;AAAA,EACpD;AAAA,EAEA,YAAY,QAAqC;AAC/C,UAAM,qBAAqB,OAAO,cAAc;AAChD,UAAM;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,OAAO,OAAO;AAAA,MACd,gBAAgB;AAAA,QACd,GAAG,OAAO;AAAA,QACV,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eAAe,KAAK;AACtE,eAAO;AAAA,MACT;AACA,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAQC;AAChB,WAAO,KAAK,UAAU,WAAW;AAAA,MAC/B,OAAO,SAAS;AAAA,MAChB,eAAe,SAAS;AAAA,IAC1B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,EACF,GAQkB;AAChB,WAAO,KAAK,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC;AAAA,EACvD;AAAA,EAEA,MAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,EACF,GAQkB;AAChB,WAAO,KAAK,UAAU,iBAAiB,EAAE,QAAQ,MAAM,CAAC;AAAA,EAC1D;AAAA,EAEA,MAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,EACF,GAGkB;AAChB,WAAO,KAAK,UAAU,iBAAiB,EAAE,QAAQ,QAAQ,CAAC;AAAA,EAC5D;AAAA,EAEA,MAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,GAGkB;AAChB,WAAO,KAAK,UAAU,0BAA0B,EAAE,QAAQ,cAAc,CAAC;AAAA,EAC3E;AACF;AAEA,eAAsB,sBAAsB;AAC1C,SAAO,iBAAiB,MAAM;AAChC;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { FullCollection } from "./loader-schemas";
2
+ import type { FullCollection } from "../_vendor/schemas/agentTools/customIntegrations/loaders/product";
3
3
  type CollectionLoaderProps = {
4
4
  loaderKey: string;
5
5
  handle?: string;
@@ -2,9 +2,9 @@
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { Suspense } from "react";
4
4
  import { useSuspenseQuery } from "@tanstack/react-query";
5
+ import { fullCollectionSchema } from "../_vendor/schemas/agentTools/customIntegrations/loaders/product.mjs";
5
6
  import { invokeLoader } from "./invoke-loader";
6
7
  import { LoaderErrorBoundary } from "./loader-error-boundary";
7
- import { fullCollectionSchema } from "./loader-schemas";
8
8
  function CollectionLoaderInner({
9
9
  loaderKey,
10
10
  handle,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../loaders/collection-loader.tsx"],
4
- "sourcesContent": ["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type { FullCollection } from \"./loader-schemas\";\n\nimport { Suspense } from \"react\";\n\nimport { useSuspenseQuery } from \"@tanstack/react-query\";\n\nimport { invokeLoader } from \"./invoke-loader\";\nimport { LoaderErrorBoundary } from \"./loader-error-boundary\";\nimport { fullCollectionSchema } from \"./loader-schemas\";\n\ntype CollectionLoaderProps = {\n loaderKey: string;\n handle?: string;\n collectionGid?: string;\n children: (data: FullCollection) => ReactNode;\n fallback?: ReactNode;\n};\n\nfunction CollectionLoaderInner({\n loaderKey,\n handle,\n collectionGid,\n children,\n}: Omit<CollectionLoaderProps, \"fallback\">) {\n const queryResult = useSuspenseQuery({\n queryKey: [loaderKey, { handle, collectionGid }],\n queryFn: async () => {\n const loadedData = await invokeLoader({\n loaderKey,\n args: { handle, collectionGid },\n });\n return fullCollectionSchema.parse(loadedData);\n },\n });\n\n return <>{children(queryResult.data)}</>;\n}\n\nexport function CollectionLoader({\n loaderKey,\n handle,\n collectionGid,\n children,\n fallback,\n}: CollectionLoaderProps) {\n return (\n <LoaderErrorBoundary\n fallback={fallback ?? null}\n resetKey={`${loaderKey}:${handle ?? \"\"}:${collectionGid ?? \"\"}`}\n >\n <Suspense fallback={fallback ?? null}>\n <CollectionLoaderInner\n loaderKey={loaderKey}\n handle={handle}\n collectionGid={collectionGid}\n >\n {children}\n </CollectionLoaderInner>\n </Suspense>\n </LoaderErrorBoundary>\n );\n}\n"],
5
- "mappings": ";AAsCS;AAjCT,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AAEjC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AAUrC,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,cAAc,iBAAiB;AAAA,IACnC,UAAU,CAAC,WAAW,EAAE,QAAQ,cAAc,CAAC;AAAA,IAC/C,SAAS,YAAY;AACnB,YAAM,aAAa,MAAM,aAAa;AAAA,QACpC;AAAA,QACA,MAAM,EAAE,QAAQ,cAAc;AAAA,MAChC,CAAC;AACD,aAAO,qBAAqB,MAAM,UAAU;AAAA,IAC9C;AAAA,EACF,CAAC;AAED,SAAO,gCAAG,mBAAS,YAAY,IAAI,GAAE;AACvC;AAEO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA0B;AACxB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,YAAY;AAAA,MACtB,UAAU,GAAG,SAAS,IAAI,UAAU,EAAE,IAAI,iBAAiB,EAAE;AAAA,MAE7D,8BAAC,YAAS,UAAU,YAAY,MAC9B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type { FullCollection } from \"schemas/agentTools/customIntegrations/loaders/product\";\n\nimport { Suspense } from \"react\";\n\nimport { useSuspenseQuery } from \"@tanstack/react-query\";\nimport { fullCollectionSchema } from \"schemas/agentTools/customIntegrations/loaders/product\";\n\nimport { invokeLoader } from \"./invoke-loader\";\nimport { LoaderErrorBoundary } from \"./loader-error-boundary\";\n\ntype CollectionLoaderProps = {\n loaderKey: string;\n handle?: string;\n collectionGid?: string;\n children: (data: FullCollection) => ReactNode;\n fallback?: ReactNode;\n};\n\nfunction CollectionLoaderInner({\n loaderKey,\n handle,\n collectionGid,\n children,\n}: Omit<CollectionLoaderProps, \"fallback\">) {\n const queryResult = useSuspenseQuery({\n queryKey: [loaderKey, { handle, collectionGid }],\n queryFn: async () => {\n const loadedData = await invokeLoader({\n loaderKey,\n args: { handle, collectionGid },\n });\n return fullCollectionSchema.parse(loadedData);\n },\n });\n\n return <>{children(queryResult.data)}</>;\n}\n\nexport function CollectionLoader({\n loaderKey,\n handle,\n collectionGid,\n children,\n fallback,\n}: CollectionLoaderProps) {\n return (\n <LoaderErrorBoundary\n fallback={fallback ?? null}\n resetKey={`${loaderKey}:${handle ?? \"\"}:${collectionGid ?? \"\"}`}\n >\n <Suspense fallback={fallback ?? null}>\n <CollectionLoaderInner\n loaderKey={loaderKey}\n handle={handle}\n collectionGid={collectionGid}\n >\n {children}\n </CollectionLoaderInner>\n </Suspense>\n </LoaderErrorBoundary>\n );\n}\n"],
5
+ "mappings": ";AAsCS;AAjCT,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAErC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AAUpC,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,cAAc,iBAAiB;AAAA,IACnC,UAAU,CAAC,WAAW,EAAE,QAAQ,cAAc,CAAC;AAAA,IAC/C,SAAS,YAAY;AACnB,YAAM,aAAa,MAAM,aAAa;AAAA,QACpC;AAAA,QACA,MAAM,EAAE,QAAQ,cAAc;AAAA,MAChC,CAAC;AACD,aAAO,qBAAqB,MAAM,UAAU;AAAA,IAC9C;AAAA,EACF,CAAC;AAED,SAAO,gCAAG,mBAAS,YAAY,IAAI,GAAE;AACvC;AAEO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA0B;AACxB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,YAAY;AAAA,MACtB,UAAU,GAAG,SAAS,IAAI,UAAU,EAAE,IAAI,iBAAiB,EAAE;AAAA,MAE7D,8BAAC,YAAS,UAAU,YAAY,MAC9B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { PaginatedProducts } from "./loader-schemas";
2
+ import type { PaginatedProducts } from "../_vendor/schemas/agentTools/customIntegrations/loaders/product";
3
3
  type CollectionProductsLoaderProps = {
4
4
  loaderKey: string;
5
5
  collectionGid: string;
@@ -2,9 +2,9 @@
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { Suspense } from "react";
4
4
  import { useSuspenseQuery } from "@tanstack/react-query";
5
+ import { paginatedProductsSchema } from "../_vendor/schemas/agentTools/customIntegrations/loaders/product.mjs";
5
6
  import { invokeLoader } from "./invoke-loader";
6
7
  import { LoaderErrorBoundary } from "./loader-error-boundary";
7
- import { paginatedProductsSchema } from "./loader-schemas";
8
8
  function CollectionProductsLoaderInner({
9
9
  loaderKey,
10
10
  collectionGid,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../loaders/collection-products-loader.tsx"],
4
- "sourcesContent": ["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type { PaginatedProducts } from \"./loader-schemas\";\n\nimport { Suspense } from \"react\";\n\nimport { useSuspenseQuery } from \"@tanstack/react-query\";\n\nimport { invokeLoader } from \"./invoke-loader\";\nimport { LoaderErrorBoundary } from \"./loader-error-boundary\";\nimport { paginatedProductsSchema } from \"./loader-schemas\";\n\ntype CollectionProductsLoaderProps = {\n loaderKey: string;\n collectionGid: string;\n first?: number;\n after?: string;\n children: (data: PaginatedProducts) => ReactNode;\n fallback?: ReactNode;\n};\n\nfunction CollectionProductsLoaderInner({\n loaderKey,\n collectionGid,\n first,\n after,\n children,\n}: Omit<CollectionProductsLoaderProps, \"fallback\">) {\n const queryResult = useSuspenseQuery({\n queryKey: [loaderKey, { collectionGid, first, after }],\n queryFn: async () => {\n const loadedData = await invokeLoader({\n loaderKey,\n args: { collectionGid, first, after },\n });\n return paginatedProductsSchema.parse(loadedData);\n },\n });\n\n return <>{children(queryResult.data)}</>;\n}\n\nexport function CollectionProductsLoader({\n loaderKey,\n collectionGid,\n first,\n after,\n children,\n fallback,\n}: CollectionProductsLoaderProps) {\n return (\n <LoaderErrorBoundary\n fallback={fallback ?? null}\n resetKey={`${loaderKey}:${collectionGid}:${first ?? \"\"}:${after ?? \"\"}`}\n >\n <Suspense fallback={fallback ?? null}>\n <CollectionProductsLoaderInner\n loaderKey={loaderKey}\n collectionGid={collectionGid}\n first={first}\n after={after}\n >\n {children}\n </CollectionProductsLoaderInner>\n </Suspense>\n </LoaderErrorBoundary>\n );\n}\n"],
5
- "mappings": ";AAwCS;AAnCT,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AAEjC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AAWxC,SAAS,8BAA8B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAoD;AAClD,QAAM,cAAc,iBAAiB;AAAA,IACnC,UAAU,CAAC,WAAW,EAAE,eAAe,OAAO,MAAM,CAAC;AAAA,IACrD,SAAS,YAAY;AACnB,YAAM,aAAa,MAAM,aAAa;AAAA,QACpC;AAAA,QACA,MAAM,EAAE,eAAe,OAAO,MAAM;AAAA,MACtC,CAAC;AACD,aAAO,wBAAwB,MAAM,UAAU;AAAA,IACjD;AAAA,EACF,CAAC;AAED,SAAO,gCAAG,mBAAS,YAAY,IAAI,GAAE;AACvC;AAEO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkC;AAChC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,YAAY;AAAA,MACtB,UAAU,GAAG,SAAS,IAAI,aAAa,IAAI,SAAS,EAAE,IAAI,SAAS,EAAE;AAAA,MAErE,8BAAC,YAAS,UAAU,YAAY,MAC9B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type { PaginatedProducts } from \"schemas/agentTools/customIntegrations/loaders/product\";\n\nimport { Suspense } from \"react\";\n\nimport { useSuspenseQuery } from \"@tanstack/react-query\";\nimport { paginatedProductsSchema } from \"schemas/agentTools/customIntegrations/loaders/product\";\n\nimport { invokeLoader } from \"./invoke-loader\";\nimport { LoaderErrorBoundary } from \"./loader-error-boundary\";\n\ntype CollectionProductsLoaderProps = {\n loaderKey: string;\n collectionGid: string;\n first?: number;\n after?: string;\n children: (data: PaginatedProducts) => ReactNode;\n fallback?: ReactNode;\n};\n\nfunction CollectionProductsLoaderInner({\n loaderKey,\n collectionGid,\n first,\n after,\n children,\n}: Omit<CollectionProductsLoaderProps, \"fallback\">) {\n const queryResult = useSuspenseQuery({\n queryKey: [loaderKey, { collectionGid, first, after }],\n queryFn: async () => {\n const loadedData = await invokeLoader({\n loaderKey,\n args: { collectionGid, first, after },\n });\n return paginatedProductsSchema.parse(loadedData);\n },\n });\n\n return <>{children(queryResult.data)}</>;\n}\n\nexport function CollectionProductsLoader({\n loaderKey,\n collectionGid,\n first,\n after,\n children,\n fallback,\n}: CollectionProductsLoaderProps) {\n return (\n <LoaderErrorBoundary\n fallback={fallback ?? null}\n resetKey={`${loaderKey}:${collectionGid}:${first ?? \"\"}:${after ?? \"\"}`}\n >\n <Suspense fallback={fallback ?? null}>\n <CollectionProductsLoaderInner\n loaderKey={loaderKey}\n collectionGid={collectionGid}\n first={first}\n after={after}\n >\n {children}\n </CollectionProductsLoaderInner>\n </Suspense>\n </LoaderErrorBoundary>\n );\n}\n"],
5
+ "mappings": ";AAwCS;AAnCT,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AAExC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AAWpC,SAAS,8BAA8B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAoD;AAClD,QAAM,cAAc,iBAAiB;AAAA,IACnC,UAAU,CAAC,WAAW,EAAE,eAAe,OAAO,MAAM,CAAC;AAAA,IACrD,SAAS,YAAY;AACnB,YAAM,aAAa,MAAM,aAAa;AAAA,QACpC;AAAA,QACA,MAAM,EAAE,eAAe,OAAO,MAAM;AAAA,MACtC,CAAC;AACD,aAAO,wBAAwB,MAAM,UAAU;AAAA,IACjD;AAAA,EACF,CAAC;AAED,SAAO,gCAAG,mBAAS,YAAY,IAAI,GAAE;AACvC;AAEO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkC;AAChC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,YAAY;AAAA,MACtB,UAAU,GAAG,SAAS,IAAI,aAAa,IAAI,SAAS,EAAE,IAAI,SAAS,EAAE;AAAA,MAErE,8BAAC,YAAS,UAAU,YAAY,MAC9B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
- import { CanopyError } from "../lib/canopy-error";
1
+ import { ReploError } from "../_vendor/schemas/errors";
2
2
  /** Scoped error for loader invocation failures. */
3
- export declare class LoaderInvokeError extends CanopyError {
3
+ export declare class LoaderInvokeError extends ReploError {
4
4
  }
5
5
  export declare function isLoaderInvokeError(error: unknown): error is LoaderInvokeError;
6
6
  /**
@@ -1,5 +1,5 @@
1
- import { CanopyError } from "../lib/canopy-error";
2
- class LoaderInvokeError extends CanopyError {
1
+ import { ReploError } from "../_vendor/schemas/errors.mjs";
2
+ class LoaderInvokeError extends ReploError {
3
3
  }
4
4
  function isLoaderInvokeError(error) {
5
5
  return error instanceof LoaderInvokeError;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../loaders/invoke-loader.ts"],
4
- "sourcesContent": ["import { CanopyError } from \"../lib/canopy-error\";\n\n/** Scoped error for loader invocation failures. */\nexport class LoaderInvokeError extends CanopyError {}\n\nexport function isLoaderInvokeError(\n error: unknown,\n): error is LoaderInvokeError {\n return error instanceof LoaderInvokeError;\n}\n\n/**\n * Invokes a data loader. During SSR, calls the canopy-api gateway directly.\n * In the browser, dynamically imports a server action so React 19 never sees\n * the \"use server\" reference during render.\n */\nexport async function invokeLoader({\n loaderKey,\n args,\n}: {\n loaderKey: string;\n args: Record<string, unknown>;\n}) {\n try {\n if (typeof window === \"undefined\") {\n const { getCanopyApiGateway } = await import(\"../gateways/canopy-api\");\n const gateway = await getCanopyApiGateway();\n const response = await gateway.invokeLoader({ loaderKey, args });\n return response.data;\n }\n\n const { invokeLoaderAction } = await import(\"./invoke-loader-action\");\n return await invokeLoaderAction({ loaderKey, args });\n } catch (error) {\n if (error instanceof LoaderInvokeError) {\n throw error;\n }\n throw new LoaderInvokeError({\n message: `Loader ${loaderKey} failed: ${error instanceof Error ? error.message : String(error)}`,\n cause: error,\n additionalData: { loaderKey },\n });\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB;AAGrB,MAAM,0BAA0B,YAAY;AAAC;AAE7C,SAAS,oBACd,OAC4B;AAC5B,SAAO,iBAAiB;AAC1B;AAOA,eAAsB,aAAa;AAAA,EACjC;AAAA,EACA;AACF,GAGG;AACD,MAAI;AACF,QAAI,OAAO,WAAW,aAAa;AACjC,YAAM,EAAE,oBAAoB,IAAI,MAAM,OAAO,wBAAwB;AACrE,YAAM,UAAU,MAAM,oBAAoB;AAC1C,YAAM,WAAW,MAAM,QAAQ,aAAa,EAAE,WAAW,KAAK,CAAC;AAC/D,aAAO,SAAS;AAAA,IAClB;AAEA,UAAM,EAAE,mBAAmB,IAAI,MAAM,OAAO,wBAAwB;AACpE,WAAO,MAAM,mBAAmB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD,SAAS,OAAO;AACd,QAAI,iBAAiB,mBAAmB;AACtC,YAAM;AAAA,IACR;AACA,UAAM,IAAI,kBAAkB;AAAA,MAC1B,SAAS,UAAU,SAAS,YAAY,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MAC9F,OAAO;AAAA,MACP,gBAAgB,EAAE,UAAU;AAAA,IAC9B,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import { ReploError } from \"schemas/errors\";\n\n/** Scoped error for loader invocation failures. */\nexport class LoaderInvokeError extends ReploError {}\n\nexport function isLoaderInvokeError(\n error: unknown,\n): error is LoaderInvokeError {\n return error instanceof LoaderInvokeError;\n}\n\n/**\n * Invokes a data loader. During SSR, calls the canopy-api gateway directly.\n * In the browser, dynamically imports a server action so React 19 never sees\n * the \"use server\" reference during render.\n */\nexport async function invokeLoader({\n loaderKey,\n args,\n}: {\n loaderKey: string;\n args: Record<string, unknown>;\n}) {\n try {\n if (typeof window === \"undefined\") {\n const { getCanopyApiGateway } = await import(\"../gateways/canopy-api\");\n const gateway = await getCanopyApiGateway();\n const response = await gateway.invokeLoader({ loaderKey, args });\n return response.data;\n }\n\n const { invokeLoaderAction } = await import(\"./invoke-loader-action\");\n return await invokeLoaderAction({ loaderKey, args });\n } catch (error) {\n if (error instanceof LoaderInvokeError) {\n throw error;\n }\n throw new LoaderInvokeError({\n message: `Loader ${loaderKey} failed: ${error instanceof Error ? error.message : String(error)}`,\n cause: error,\n additionalData: { loaderKey },\n });\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAGpB,MAAM,0BAA0B,WAAW;AAAC;AAE5C,SAAS,oBACd,OAC4B;AAC5B,SAAO,iBAAiB;AAC1B;AAOA,eAAsB,aAAa;AAAA,EACjC;AAAA,EACA;AACF,GAGG;AACD,MAAI;AACF,QAAI,OAAO,WAAW,aAAa;AACjC,YAAM,EAAE,oBAAoB,IAAI,MAAM,OAAO,wBAAwB;AACrE,YAAM,UAAU,MAAM,oBAAoB;AAC1C,YAAM,WAAW,MAAM,QAAQ,aAAa,EAAE,WAAW,KAAK,CAAC;AAC/D,aAAO,SAAS;AAAA,IAClB;AAEA,UAAM,EAAE,mBAAmB,IAAI,MAAM,OAAO,wBAAwB;AACpE,WAAO,MAAM,mBAAmB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD,SAAS,OAAO;AACd,QAAI,iBAAiB,mBAAmB;AACtC,YAAM;AAAA,IACR;AACA,UAAM,IAAI,kBAAkB;AAAA,MAC1B,SAAS,UAAU,SAAS,YAAY,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MAC9F,OAAO;AAAA,MACP,gBAAgB,EAAE,UAAU;AAAA,IAC9B,CAAC;AAAA,EACH;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { LevantaProductFull } from "./loader-schemas";
2
+ import type { LevantaProductFull } from "../_vendor/schemas/agentTools/customIntegrations/loaders/levanta";
3
3
  type LevantaProductLoaderProps = {
4
4
  loaderKey: string;
5
5
  asin: string;
@@ -2,9 +2,9 @@
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { Suspense } from "react";
4
4
  import { useSuspenseQuery } from "@tanstack/react-query";
5
+ import { levantaProductFullSchema } from "../_vendor/schemas/agentTools/customIntegrations/loaders/levanta.mjs";
5
6
  import { invokeLoader } from "./invoke-loader";
6
7
  import { LoaderErrorBoundary } from "./loader-error-boundary";
7
- import { levantaProductFullSchema } from "./loader-schemas";
8
8
  function LevantaProductLoaderInner({
9
9
  loaderKey,
10
10
  asin,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../loaders/levanta-product-loader.tsx"],
4
- "sourcesContent": ["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type { LevantaProductFull } from \"./loader-schemas\";\n\nimport { Suspense } from \"react\";\n\nimport { useSuspenseQuery } from \"@tanstack/react-query\";\n\nimport { invokeLoader } from \"./invoke-loader\";\nimport { LoaderErrorBoundary } from \"./loader-error-boundary\";\nimport { levantaProductFullSchema } from \"./loader-schemas\";\n\ntype LevantaProductLoaderProps = {\n loaderKey: string;\n asin: string;\n marketplace?: string;\n children: (data: LevantaProductFull) => ReactNode;\n fallback?: ReactNode;\n};\n\nfunction LevantaProductLoaderInner({\n loaderKey,\n asin,\n marketplace,\n children,\n}: Omit<LevantaProductLoaderProps, \"fallback\">) {\n const queryResult = useSuspenseQuery({\n queryKey: [loaderKey, { asin, marketplace }],\n queryFn: async () => {\n const loadedData = await invokeLoader({\n loaderKey,\n args: { asin, marketplace },\n });\n return levantaProductFullSchema.parse(loadedData);\n },\n });\n\n return <>{children(queryResult.data)}</>;\n}\n\nexport function LevantaProductLoader({\n loaderKey,\n asin,\n marketplace,\n children,\n fallback,\n}: LevantaProductLoaderProps) {\n return (\n <LoaderErrorBoundary\n fallback={fallback ?? null}\n resetKey={`${loaderKey}:${asin}:${marketplace ?? \"\"}`}\n >\n <Suspense fallback={fallback ?? null}>\n <LevantaProductLoaderInner\n loaderKey={loaderKey}\n asin={asin}\n marketplace={marketplace}\n >\n {children}\n </LevantaProductLoaderInner>\n </Suspense>\n </LoaderErrorBoundary>\n );\n}\n"],
5
- "mappings": ";AAsCS;AAjCT,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AAEjC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,gCAAgC;AAUzC,SAAS,0BAA0B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAgD;AAC9C,QAAM,cAAc,iBAAiB;AAAA,IACnC,UAAU,CAAC,WAAW,EAAE,MAAM,YAAY,CAAC;AAAA,IAC3C,SAAS,YAAY;AACnB,YAAM,aAAa,MAAM,aAAa;AAAA,QACpC;AAAA,QACA,MAAM,EAAE,MAAM,YAAY;AAAA,MAC5B,CAAC;AACD,aAAO,yBAAyB,MAAM,UAAU;AAAA,IAClD;AAAA,EACF,CAAC;AAED,SAAO,gCAAG,mBAAS,YAAY,IAAI,GAAE;AACvC;AAEO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,YAAY;AAAA,MACtB,UAAU,GAAG,SAAS,IAAI,IAAI,IAAI,eAAe,EAAE;AAAA,MAEnD,8BAAC,YAAS,UAAU,YAAY,MAC9B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type { LevantaProductFull } from \"schemas/agentTools/customIntegrations/loaders/levanta\";\n\nimport { Suspense } from \"react\";\n\nimport { useSuspenseQuery } from \"@tanstack/react-query\";\nimport { levantaProductFullSchema } from \"schemas/agentTools/customIntegrations/loaders/levanta\";\n\nimport { invokeLoader } from \"./invoke-loader\";\nimport { LoaderErrorBoundary } from \"./loader-error-boundary\";\n\ntype LevantaProductLoaderProps = {\n loaderKey: string;\n asin: string;\n marketplace?: string;\n children: (data: LevantaProductFull) => ReactNode;\n fallback?: ReactNode;\n};\n\nfunction LevantaProductLoaderInner({\n loaderKey,\n asin,\n marketplace,\n children,\n}: Omit<LevantaProductLoaderProps, \"fallback\">) {\n const queryResult = useSuspenseQuery({\n queryKey: [loaderKey, { asin, marketplace }],\n queryFn: async () => {\n const loadedData = await invokeLoader({\n loaderKey,\n args: { asin, marketplace },\n });\n return levantaProductFullSchema.parse(loadedData);\n },\n });\n\n return <>{children(queryResult.data)}</>;\n}\n\nexport function LevantaProductLoader({\n loaderKey,\n asin,\n marketplace,\n children,\n fallback,\n}: LevantaProductLoaderProps) {\n return (\n <LoaderErrorBoundary\n fallback={fallback ?? null}\n resetKey={`${loaderKey}:${asin}:${marketplace ?? \"\"}`}\n >\n <Suspense fallback={fallback ?? null}>\n <LevantaProductLoaderInner\n loaderKey={loaderKey}\n asin={asin}\n marketplace={marketplace}\n >\n {children}\n </LevantaProductLoaderInner>\n </Suspense>\n </LoaderErrorBoundary>\n );\n}\n"],
5
+ "mappings": ";AAsCS;AAjCT,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AACjC,SAAS,gCAAgC;AAEzC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AAUpC,SAAS,0BAA0B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAgD;AAC9C,QAAM,cAAc,iBAAiB;AAAA,IACnC,UAAU,CAAC,WAAW,EAAE,MAAM,YAAY,CAAC;AAAA,IAC3C,SAAS,YAAY;AACnB,YAAM,aAAa,MAAM,aAAa;AAAA,QACpC;AAAA,QACA,MAAM,EAAE,MAAM,YAAY;AAAA,MAC5B,CAAC;AACD,aAAO,yBAAyB,MAAM,UAAU;AAAA,IAClD;AAAA,EACF,CAAC;AAED,SAAO,gCAAG,mBAAS,YAAY,IAAI,GAAE;AACvC;AAEO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,YAAY;AAAA,MACtB,UAAU,GAAG,SAAS,IAAI,IAAI,IAAI,eAAe,EAAE;AAAA,MAEnD,8BAAC,YAAS,UAAU,YAAY,MAC9B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -2,10 +2,10 @@
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { Suspense } from "react";
4
4
  import { useSuspenseQuery } from "@tanstack/react-query";
5
+ import { okendoReviewSchema } from "../_vendor/schemas/objectType.mjs";
5
6
  import { z } from "zod";
6
7
  import { invokeLoader } from "./invoke-loader";
7
8
  import { LoaderErrorBoundary } from "./loader-error-boundary";
8
- import { okendoReviewSchema } from "./loader-schemas";
9
9
  const okendoReviewsOutputSchema = z.object({
10
10
  reviews: z.array(okendoReviewSchema)
11
11
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../loaders/okendo-reviews-loader.tsx"],
4
- "sourcesContent": ["\"use client\";\n\nimport type { ReactNode } from \"react\";\n\nimport { Suspense } from \"react\";\n\nimport { useSuspenseQuery } from \"@tanstack/react-query\";\nimport { z } from \"zod\";\n\nimport { invokeLoader } from \"./invoke-loader\";\nimport { LoaderErrorBoundary } from \"./loader-error-boundary\";\nimport { okendoReviewSchema } from \"./loader-schemas\";\n\nconst okendoReviewsOutputSchema = z.object({\n reviews: z.array(okendoReviewSchema),\n});\n\ntype OkendoReviewsData = z.infer<typeof okendoReviewsOutputSchema>;\n\ntype OkendoReviewsLoaderProps = {\n loaderKey: string;\n shopifyProductId: string;\n children: (data: OkendoReviewsData) => ReactNode;\n fallback?: ReactNode;\n};\n\nfunction OkendoReviewsLoaderInner({\n loaderKey,\n shopifyProductId,\n children,\n}: Omit<OkendoReviewsLoaderProps, \"fallback\">) {\n const queryResult = useSuspenseQuery({\n queryKey: [loaderKey, { shopifyProductId }],\n queryFn: async () => {\n const loadedData = await invokeLoader({\n loaderKey,\n args: { shopifyProductId },\n });\n return okendoReviewsOutputSchema.parse(loadedData);\n },\n });\n\n return <>{children(queryResult.data)}</>;\n}\n\nexport function OkendoReviewsLoader({\n loaderKey,\n shopifyProductId,\n children,\n fallback,\n}: OkendoReviewsLoaderProps) {\n return (\n <LoaderErrorBoundary\n fallback={fallback ?? null}\n resetKey={`${loaderKey}:${shopifyProductId}`}\n >\n <Suspense fallback={fallback ?? null}>\n <OkendoReviewsLoaderInner\n loaderKey={loaderKey}\n shopifyProductId={shopifyProductId}\n >\n {children}\n </OkendoReviewsLoaderInner>\n </Suspense>\n </LoaderErrorBoundary>\n );\n}\n"],
5
- "mappings": ";AA0CS;AAtCT,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AACjC,SAAS,SAAS;AAElB,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AAEnC,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,SAAS,EAAE,MAAM,kBAAkB;AACrC,CAAC;AAWD,SAAS,yBAAyB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,GAA+C;AAC7C,QAAM,cAAc,iBAAiB;AAAA,IACnC,UAAU,CAAC,WAAW,EAAE,iBAAiB,CAAC;AAAA,IAC1C,SAAS,YAAY;AACnB,YAAM,aAAa,MAAM,aAAa;AAAA,QACpC;AAAA,QACA,MAAM,EAAE,iBAAiB;AAAA,MAC3B,CAAC;AACD,aAAO,0BAA0B,MAAM,UAAU;AAAA,IACnD;AAAA,EACF,CAAC;AAED,SAAO,gCAAG,mBAAS,YAAY,IAAI,GAAE;AACvC;AAEO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,YAAY;AAAA,MACtB,UAAU,GAAG,SAAS,IAAI,gBAAgB;AAAA,MAE1C,8BAAC,YAAS,UAAU,YAAY,MAC9B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\";\n\nimport type { ReactNode } from \"react\";\n\nimport { Suspense } from \"react\";\n\nimport { useSuspenseQuery } from \"@tanstack/react-query\";\nimport { okendoReviewSchema } from \"schemas/objectType\";\nimport { z } from \"zod\";\n\nimport { invokeLoader } from \"./invoke-loader\";\nimport { LoaderErrorBoundary } from \"./loader-error-boundary\";\n\nconst okendoReviewsOutputSchema = z.object({\n reviews: z.array(okendoReviewSchema),\n});\n\ntype OkendoReviewsData = z.infer<typeof okendoReviewsOutputSchema>;\n\ntype OkendoReviewsLoaderProps = {\n loaderKey: string;\n shopifyProductId: string;\n children: (data: OkendoReviewsData) => ReactNode;\n fallback?: ReactNode;\n};\n\nfunction OkendoReviewsLoaderInner({\n loaderKey,\n shopifyProductId,\n children,\n}: Omit<OkendoReviewsLoaderProps, \"fallback\">) {\n const queryResult = useSuspenseQuery({\n queryKey: [loaderKey, { shopifyProductId }],\n queryFn: async () => {\n const loadedData = await invokeLoader({\n loaderKey,\n args: { shopifyProductId },\n });\n return okendoReviewsOutputSchema.parse(loadedData);\n },\n });\n\n return <>{children(queryResult.data)}</>;\n}\n\nexport function OkendoReviewsLoader({\n loaderKey,\n shopifyProductId,\n children,\n fallback,\n}: OkendoReviewsLoaderProps) {\n return (\n <LoaderErrorBoundary\n fallback={fallback ?? null}\n resetKey={`${loaderKey}:${shopifyProductId}`}\n >\n <Suspense fallback={fallback ?? null}>\n <OkendoReviewsLoaderInner\n loaderKey={loaderKey}\n shopifyProductId={shopifyProductId}\n >\n {children}\n </OkendoReviewsLoaderInner>\n </Suspense>\n </LoaderErrorBoundary>\n );\n}\n"],
5
+ "mappings": ";AA0CS;AAtCT,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,SAAS;AAElB,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AAEpC,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,SAAS,EAAE,MAAM,kBAAkB;AACrC,CAAC;AAWD,SAAS,yBAAyB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,GAA+C;AAC7C,QAAM,cAAc,iBAAiB;AAAA,IACnC,UAAU,CAAC,WAAW,EAAE,iBAAiB,CAAC;AAAA,IAC1C,SAAS,YAAY;AACnB,YAAM,aAAa,MAAM,aAAa;AAAA,QACpC;AAAA,QACA,MAAM,EAAE,iBAAiB;AAAA,MAC3B,CAAC;AACD,aAAO,0BAA0B,MAAM,UAAU;AAAA,IACnD;AAAA,EACF,CAAC;AAED,SAAO,gCAAG,mBAAS,YAAY,IAAI,GAAE;AACvC;AAEO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,YAAY;AAAA,MACtB,UAAU,GAAG,SAAS,IAAI,gBAAgB;AAAA,MAE1C,8BAAC,YAAS,UAAU,YAAY,MAC9B;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -14,7 +14,7 @@ type PrefetchLoaderConfig = {
14
14
  * convention used by all loader components.
15
15
  *
16
16
  * Usage:
17
- * import { DATA_LOADER_KEYS } from "canopy-sdk/loaders/loader-keys";
17
+ * import { DATA_LOADER_KEYS } from "canopy-sdk/_vendor/schemas/loaderKeys";
18
18
  *
19
19
  * <PrefetchedLoaders
20
20
  * queries={[