@palettelab/sdk 0.1.18 → 0.1.20

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/README.md CHANGED
@@ -497,3 +497,5 @@ The npm package ships compiled CommonJS, ESM, and TypeScript declarations from `
497
497
 
498
498
  - `@palettelab/cli` provides the `pltt` command for scaffolding, local dev, validation, packaging, and publishing.
499
499
  - `palette-sdk` is the Python backend SDK for FastAPI plugin routes, permissions, tools, DB helpers, RLS, and test helpers.
500
+
501
+ The returned `saved` object also includes snake_case aliases (`object_path`, `file_url`, `content_type`, `upload_id`) so browser and Python backend upload handlers can share response-normalization code.
package/dist/index.d.mts CHANGED
@@ -153,11 +153,15 @@ type StorageUploadOptions = {
153
153
  };
154
154
  type StorageUploadResult = {
155
155
  uploadId: string;
156
+ upload_id: string;
156
157
  mode: "gcs_resumable" | "local_resumable" | string;
157
158
  bucket: string;
158
159
  objectPath: string;
160
+ object_path: string;
159
161
  fileUrl: string;
162
+ file_url: string;
160
163
  contentType: string;
164
+ content_type: string;
161
165
  size: number;
162
166
  };
163
167
  declare function uploadToSignedUrl(uploadUrl: string, file: Blob, contentType?: string): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -153,11 +153,15 @@ type StorageUploadOptions = {
153
153
  };
154
154
  type StorageUploadResult = {
155
155
  uploadId: string;
156
+ upload_id: string;
156
157
  mode: "gcs_resumable" | "local_resumable" | string;
157
158
  bucket: string;
158
159
  objectPath: string;
160
+ object_path: string;
159
161
  fileUrl: string;
162
+ file_url: string;
160
163
  contentType: string;
164
+ content_type: string;
161
165
  size: number;
162
166
  };
163
167
  declare function uploadToSignedUrl(uploadUrl: string, file: Blob, contentType?: string): Promise<void>;
package/dist/index.js CHANGED
@@ -568,11 +568,15 @@ var StorageClient = class {
568
568
  clearStoredSession(pluginId, fingerprint);
569
569
  return {
570
570
  uploadId: session.upload_id,
571
+ upload_id: session.upload_id,
571
572
  mode: session.mode,
572
573
  bucket: session.bucket,
573
574
  objectPath: session.object_path,
575
+ object_path: session.object_path,
574
576
  fileUrl: session.file_url,
577
+ file_url: session.file_url,
575
578
  contentType: session.content_type,
579
+ content_type: session.content_type,
576
580
  size: session.size
577
581
  };
578
582
  }
@@ -837,6 +841,21 @@ function currentSearchParams() {
837
841
  if (typeof window === "undefined") return new URLSearchParams();
838
842
  return new URLSearchParams(window.location.search);
839
843
  }
844
+ function preserveCurrentPreviewParams(path, pluginId) {
845
+ if (typeof window === "undefined" || !pluginId || /^https?:\/\//i.test(path)) return path;
846
+ const currentParams = new URLSearchParams(window.location.search);
847
+ const previewPublishId = currentParams.get("preview_publish_id");
848
+ const previewToken = currentParams.get("preview_token");
849
+ if (!previewPublishId || !previewToken) return path;
850
+ const [beforeHash, hash = ""] = path.split("#", 2);
851
+ const [pathname, query = ""] = beforeHash.split("?", 2);
852
+ if (pathname !== `/apps/${pluginId}` && !pathname.startsWith(`/apps/${pluginId}/`)) return path;
853
+ const params = new URLSearchParams(query);
854
+ params.set("preview_publish_id", previewPublishId);
855
+ params.set("preview_token", previewToken);
856
+ const serialized = params.toString();
857
+ return `${pathname}${serialized ? `?${serialized}` : ""}${hash ? `#${hash}` : ""}`;
858
+ }
840
859
  var PaletteRouteErrorBoundary = class extends import_react4.Component {
841
860
  constructor() {
842
861
  super(...arguments);
@@ -914,8 +933,9 @@ function PaletteAppRouter({
914
933
  const currentPath = typeof window === "undefined" ? "" : window.location.pathname;
915
934
  const inPalettePath = platform.pluginId && (currentPath.startsWith(`/apps/${platform.pluginId}`) || platform.routePath !== void 0);
916
935
  const osPath = inPalettePath && platform.pluginId ? `/apps/${platform.pluginId}${pathname === "/" ? "" : pathname}${queryPart ? `?${queryPart}` : ""}` : next;
917
- if (replace && typeof window !== "undefined") window.history.replaceState(null, "", osPath);
918
- else platform.navigate(osPath);
936
+ const preservedOsPath = preserveCurrentPreviewParams(osPath, platform.pluginId);
937
+ if (replace && typeof window !== "undefined") window.history.replaceState(null, "", preservedOsPath);
938
+ else platform.navigate(preservedOsPath);
919
939
  }, [platform]);
920
940
  const state = (0, import_react4.useMemo)(() => ({
921
941
  pathname: location.pathname,
package/dist/index.mjs CHANGED
@@ -500,11 +500,15 @@ var StorageClient = class {
500
500
  clearStoredSession(pluginId, fingerprint);
501
501
  return {
502
502
  uploadId: session.upload_id,
503
+ upload_id: session.upload_id,
503
504
  mode: session.mode,
504
505
  bucket: session.bucket,
505
506
  objectPath: session.object_path,
507
+ object_path: session.object_path,
506
508
  fileUrl: session.file_url,
509
+ file_url: session.file_url,
507
510
  contentType: session.content_type,
511
+ content_type: session.content_type,
508
512
  size: session.size
509
513
  };
510
514
  }
@@ -778,6 +782,21 @@ function currentSearchParams() {
778
782
  if (typeof window === "undefined") return new URLSearchParams();
779
783
  return new URLSearchParams(window.location.search);
780
784
  }
785
+ function preserveCurrentPreviewParams(path, pluginId) {
786
+ if (typeof window === "undefined" || !pluginId || /^https?:\/\//i.test(path)) return path;
787
+ const currentParams = new URLSearchParams(window.location.search);
788
+ const previewPublishId = currentParams.get("preview_publish_id");
789
+ const previewToken = currentParams.get("preview_token");
790
+ if (!previewPublishId || !previewToken) return path;
791
+ const [beforeHash, hash = ""] = path.split("#", 2);
792
+ const [pathname, query = ""] = beforeHash.split("?", 2);
793
+ if (pathname !== `/apps/${pluginId}` && !pathname.startsWith(`/apps/${pluginId}/`)) return path;
794
+ const params = new URLSearchParams(query);
795
+ params.set("preview_publish_id", previewPublishId);
796
+ params.set("preview_token", previewToken);
797
+ const serialized = params.toString();
798
+ return `${pathname}${serialized ? `?${serialized}` : ""}${hash ? `#${hash}` : ""}`;
799
+ }
781
800
  var PaletteRouteErrorBoundary = class extends Component {
782
801
  constructor() {
783
802
  super(...arguments);
@@ -855,8 +874,9 @@ function PaletteAppRouter({
855
874
  const currentPath = typeof window === "undefined" ? "" : window.location.pathname;
856
875
  const inPalettePath = platform.pluginId && (currentPath.startsWith(`/apps/${platform.pluginId}`) || platform.routePath !== void 0);
857
876
  const osPath = inPalettePath && platform.pluginId ? `/apps/${platform.pluginId}${pathname === "/" ? "" : pathname}${queryPart ? `?${queryPart}` : ""}` : next;
858
- if (replace && typeof window !== "undefined") window.history.replaceState(null, "", osPath);
859
- else platform.navigate(osPath);
877
+ const preservedOsPath = preserveCurrentPreviewParams(osPath, platform.pluginId);
878
+ if (replace && typeof window !== "undefined") window.history.replaceState(null, "", preservedOsPath);
879
+ else platform.navigate(preservedOsPath);
860
880
  }, [platform]);
861
881
  const state = useMemo(() => ({
862
882
  pathname: location.pathname,
@@ -103,6 +103,21 @@ function currentSearchParams() {
103
103
  if (typeof window === "undefined") return new URLSearchParams();
104
104
  return new URLSearchParams(window.location.search);
105
105
  }
106
+ function preserveCurrentPreviewParams(path, pluginId) {
107
+ if (typeof window === "undefined" || !pluginId || /^https?:\/\//i.test(path)) return path;
108
+ const currentParams = new URLSearchParams(window.location.search);
109
+ const previewPublishId = currentParams.get("preview_publish_id");
110
+ const previewToken = currentParams.get("preview_token");
111
+ if (!previewPublishId || !previewToken) return path;
112
+ const [beforeHash, hash = ""] = path.split("#", 2);
113
+ const [pathname, query = ""] = beforeHash.split("?", 2);
114
+ if (pathname !== `/apps/${pluginId}` && !pathname.startsWith(`/apps/${pluginId}/`)) return path;
115
+ const params = new URLSearchParams(query);
116
+ params.set("preview_publish_id", previewPublishId);
117
+ params.set("preview_token", previewToken);
118
+ const serialized = params.toString();
119
+ return `${pathname}${serialized ? `?${serialized}` : ""}${hash ? `#${hash}` : ""}`;
120
+ }
106
121
  var PaletteRouteErrorBoundary = class extends import_react2.Component {
107
122
  constructor() {
108
123
  super(...arguments);
@@ -180,8 +195,9 @@ function PaletteAppRouter({
180
195
  const currentPath = typeof window === "undefined" ? "" : window.location.pathname;
181
196
  const inPalettePath = platform.pluginId && (currentPath.startsWith(`/apps/${platform.pluginId}`) || platform.routePath !== void 0);
182
197
  const osPath = inPalettePath && platform.pluginId ? `/apps/${platform.pluginId}${pathname === "/" ? "" : pathname}${queryPart ? `?${queryPart}` : ""}` : next;
183
- if (replace && typeof window !== "undefined") window.history.replaceState(null, "", osPath);
184
- else platform.navigate(osPath);
198
+ const preservedOsPath = preserveCurrentPreviewParams(osPath, platform.pluginId);
199
+ if (replace && typeof window !== "undefined") window.history.replaceState(null, "", preservedOsPath);
200
+ else platform.navigate(preservedOsPath);
185
201
  }, [platform]);
186
202
  const state = (0, import_react2.useMemo)(() => ({
187
203
  pathname: location.pathname,
@@ -82,6 +82,21 @@ function currentSearchParams() {
82
82
  if (typeof window === "undefined") return new URLSearchParams();
83
83
  return new URLSearchParams(window.location.search);
84
84
  }
85
+ function preserveCurrentPreviewParams(path, pluginId) {
86
+ if (typeof window === "undefined" || !pluginId || /^https?:\/\//i.test(path)) return path;
87
+ const currentParams = new URLSearchParams(window.location.search);
88
+ const previewPublishId = currentParams.get("preview_publish_id");
89
+ const previewToken = currentParams.get("preview_token");
90
+ if (!previewPublishId || !previewToken) return path;
91
+ const [beforeHash, hash = ""] = path.split("#", 2);
92
+ const [pathname, query = ""] = beforeHash.split("?", 2);
93
+ if (pathname !== `/apps/${pluginId}` && !pathname.startsWith(`/apps/${pluginId}/`)) return path;
94
+ const params = new URLSearchParams(query);
95
+ params.set("preview_publish_id", previewPublishId);
96
+ params.set("preview_token", previewToken);
97
+ const serialized = params.toString();
98
+ return `${pathname}${serialized ? `?${serialized}` : ""}${hash ? `#${hash}` : ""}`;
99
+ }
85
100
  var PaletteRouteErrorBoundary = class extends Component {
86
101
  constructor() {
87
102
  super(...arguments);
@@ -159,8 +174,9 @@ function PaletteAppRouter({
159
174
  const currentPath = typeof window === "undefined" ? "" : window.location.pathname;
160
175
  const inPalettePath = platform.pluginId && (currentPath.startsWith(`/apps/${platform.pluginId}`) || platform.routePath !== void 0);
161
176
  const osPath = inPalettePath && platform.pluginId ? `/apps/${platform.pluginId}${pathname === "/" ? "" : pathname}${queryPart ? `?${queryPart}` : ""}` : next;
162
- if (replace && typeof window !== "undefined") window.history.replaceState(null, "", osPath);
163
- else platform.navigate(osPath);
177
+ const preservedOsPath = preserveCurrentPreviewParams(osPath, platform.pluginId);
178
+ if (replace && typeof window !== "undefined") window.history.replaceState(null, "", preservedOsPath);
179
+ else platform.navigate(preservedOsPath);
164
180
  }, [platform]);
165
181
  const state = useMemo(() => ({
166
182
  pathname: location.pathname,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palettelab/sdk",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Palette Platform SDK for building plugins and apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",