@jay-framework/wix-deploy 0.20.0 → 0.22.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.
@@ -66,6 +66,41 @@ class WixDataArtifactStore {
66
66
  return this.cacheDir;
67
67
  }
68
68
  // ========================================================================
69
+ // Eager loading (cold start)
70
+ // ========================================================================
71
+ async loadEagerFiles() {
72
+ console.log(
73
+ `[WixDataArtifactStore] Loading eager files v${this.version} from "${this.collectionId}"...`
74
+ );
75
+ let totalLoaded = 0;
76
+ let hasMore = true;
77
+ let offset = 0;
78
+ const limit = 50;
79
+ while (hasMore) {
80
+ const result = await this.dataClient.items.query(this.collectionId).eq("category", "eager").eq("version", this.version).skip(offset).limit(limit).find();
81
+ for (const item of result.items) {
82
+ this.writeToCache(item.path, item.content);
83
+ totalLoaded++;
84
+ }
85
+ hasMore = result.items.length === limit;
86
+ offset += limit;
87
+ }
88
+ console.log(`[WixDataArtifactStore] Loaded ${totalLoaded} eager files`);
89
+ }
90
+ // ========================================================================
91
+ // Lazy page file loading
92
+ // ========================================================================
93
+ async ensurePageFiles(preRenderedPath) {
94
+ const dir = path.dirname(preRenderedPath);
95
+ const base = preRenderedPath.replace(/\.jay-html$/, "");
96
+ const filesToEnsure = [
97
+ path.join(dir, "page-parts.json"),
98
+ `${base}.cache.json`,
99
+ `${base}.server-element.js`
100
+ ];
101
+ await Promise.all(filesToEnsure.map((f) => this.ensureFile(f)));
102
+ }
103
+ // ========================================================================
69
104
  // Writes (for upload-backend and renderer)
70
105
  // ========================================================================
71
106
  async writeFile(relativePath, content, category) {
@@ -132,22 +167,26 @@ class WixDataArtifactStore {
132
167
  }
133
168
  async fetchFromCollection(relativePath) {
134
169
  const id = makeItemId(this.version, relativePath);
135
- const t0 = Date.now();
136
- const item = await this.dataClient.items.get(
137
- this.collectionId,
138
- id
139
- );
140
- const t1 = Date.now();
141
- if (!item?.content) {
142
- throw new Error(
143
- `File not found in data collection: v${this.version}/${relativePath} (id: ${id})`
170
+ try {
171
+ const item = await this.dataClient.items.get(
172
+ this.collectionId,
173
+ id
144
174
  );
175
+ if (item?.content) {
176
+ this.writeToCache(relativePath, item.content);
177
+ return item.content;
178
+ }
179
+ } catch {
145
180
  }
146
- this.writeToCache(relativePath, item.content);
147
- console.log(
148
- `[WixDataArtifactStore] Fetched v${this.version}/${relativePath} (${t1 - t0}ms)`
181
+ const result = await this.dataClient.items.query(this.collectionId).eq("path", relativePath).eq("version", this.version).limit(1).find();
182
+ if (result.items.length > 0) {
183
+ const item = result.items[0];
184
+ this.writeToCache(relativePath, item.content);
185
+ return item.content;
186
+ }
187
+ throw new Error(
188
+ `File not found in data collection: v${this.version}/${relativePath} (id: ${id})`
149
189
  );
150
- return item.content;
151
190
  }
152
191
  writeToCache(relativePath, content) {
153
192
  const fullPath = path.join(this.cacheDir, relativePath);
package/dist/index.d.ts CHANGED
@@ -52,6 +52,8 @@ declare class WixDataArtifactStore implements ArtifactStore {
52
52
  loadModule(modulePath: string, _local?: boolean): Promise<any>;
53
53
  getAssetPath(relativePath: string): string;
54
54
  getBuildDir(): string;
55
+ loadEagerFiles(): Promise<void>;
56
+ ensurePageFiles(preRenderedPath: string): Promise<void>;
55
57
  writeFile(relativePath: string, content: string, category: 'eager' | 'lazy'): Promise<void>;
56
58
  writeFiles(files: Array<{
57
59
  path: string;
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import path from "node:path";
18
18
  import crypto from "node:crypto";
19
19
  import yaml from "js-yaml";
20
20
  import { getService } from "@jay-framework/stack-server-runtime";
21
- import { items } from "@wix/data";
21
+ import { collections, items } from "@wix/data";
22
22
  const DEFAULT_COLLECTION_ID = "jay-backend-files";
23
23
  const DEFAULT_CACHE_DIR = "/tmp/jay-backend";
24
24
  function getDeployVersion(metadata) {
@@ -30,7 +30,6 @@ function getDeployVersion(metadata) {
30
30
  const DEFAULT_EXCLUDE_PLUGINS = ["aiditor", "ui-kit", "wix-deploy"];
31
31
  function scanPagePartsFiles(dir, fs2, path2) {
32
32
  const results = [];
33
- if (!fs2.existsSync(dir)) return results;
34
33
  for (const entry of fs2.readdirSync(dir, { withFileTypes: true })) {
35
34
  const fullPath = path2.join(dir, entry.name);
36
35
  if (entry.isDirectory()) {
@@ -409,7 +408,11 @@ const buildEntry = makeCliCommand("build-entry").withServices(CONSOLE_CONTEXT).w
409
408
  "prettier",
410
409
  "vite",
411
410
  "lightningcss",
412
- "fsevents"
411
+ "fsevents",
412
+ "@types/js-yaml",
413
+ "@wix/sdk-runtime",
414
+ "yaml",
415
+ "js-beautify"
413
416
  ];
414
417
  const stubFilter = new RegExp(
415
418
  "^(" + stubs.map((s) => s.replace(/[/.]/g, "\\$&")).join("|") + ")$"
@@ -7202,6 +7205,7 @@ const deployBaas = makeCliCommand("deploy-baas").withServices(CONSOLE_CONTEXT).w
7202
7205
  const completedDeployment = completeData.appDeployment || {};
7203
7206
  const deploymentId = appDeployment?.id;
7204
7207
  const deploymentBaseUrl = completedDeployment.deploymentBaseUrl || appDeployment?.deploymentBaseUrl || "";
7208
+ ctx.log(`Deployment uploaded. Base URL: ${deploymentBaseUrl}`);
7205
7209
  let appVersion = 0;
7206
7210
  try {
7207
7211
  const { data: versionData } = await httpClient2.request(
@@ -7372,19 +7376,42 @@ async function setupWixDeploy(ctx) {
7372
7376
  }
7373
7377
  }
7374
7378
  let collectionOk = false;
7375
- try {
7376
- const wixClient = getService(WIX_CLIENT_SERVICE);
7377
- if (wixClient) {
7378
- const dataClient = wixClient.use({ items });
7379
+ const wixClient = getService(WIX_CLIENT_SERVICE);
7380
+ if (wixClient) {
7381
+ const dataClient = wixClient.use({ items, collections });
7382
+ try {
7379
7383
  await dataClient.items.query(DEFAULT_COLLECTION_ID).limit(1).find();
7380
7384
  collectionOk = true;
7385
+ } catch {
7386
+ try {
7387
+ await dataClient.collections.createDataCollection({
7388
+ _id: DEFAULT_COLLECTION_ID,
7389
+ displayName: "Jay Backend Files",
7390
+ fields: [
7391
+ { key: "path", type: "TEXT" },
7392
+ { key: "content", type: "TEXT" },
7393
+ { key: "fileType", type: "TEXT" },
7394
+ { key: "sizeBytes", type: "NUMBER" },
7395
+ { key: "category", type: "TEXT" },
7396
+ { key: "version", type: "TEXT" }
7397
+ ],
7398
+ permissions: {
7399
+ insert: "ADMIN",
7400
+ update: "ADMIN",
7401
+ remove: "ADMIN",
7402
+ read: "ADMIN"
7403
+ }
7404
+ });
7405
+ collectionOk = true;
7406
+ configCreated.push("collection");
7407
+ } catch (createErr) {
7408
+ return {
7409
+ status: "error",
7410
+ configCreated,
7411
+ message: `Failed to create data collection "${DEFAULT_COLLECTION_ID}": ${createErr instanceof Error ? createErr.message : createErr}`
7412
+ };
7413
+ }
7381
7414
  }
7382
- } catch {
7383
- return {
7384
- status: "needs-config",
7385
- configCreated,
7386
- message: `Data collection "${DEFAULT_COLLECTION_ID}" not found. Create it in the Wix dashboard with fields: path (text), content (text), fileType (text), sizeBytes (number), category (text), version (text)`
7387
- };
7388
7415
  }
7389
7416
  return {
7390
7417
  status: "configured",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-deploy",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "description": "Wix BaaS deployment adapter for Jay Framework — WixDataArtifactStore and entry builder",
6
6
  "license": "Apache-2.0",
@@ -16,7 +16,8 @@
16
16
  "./package.json": "./package.json"
17
17
  },
18
18
  "scripts": {
19
- "build": "npm run clean && npm run build:server && npm run build:types",
19
+ "build": "npm run clean && npm run build:server && npm run build:types && npm run validate",
20
+ "validate": "jay-stack-cli validate-plugin",
20
21
  "build:server": "vite build --ssr",
21
22
  "build:types": "tsup lib/index.ts --dts-only --format esm",
22
23
  "build:check-types": "tsc",
@@ -25,10 +26,10 @@
25
26
  "test": ":"
26
27
  },
27
28
  "dependencies": {
28
- "@jay-framework/fullstack-component": "^0.20.0",
29
- "@jay-framework/production-server": "^0.20.0",
30
- "@jay-framework/stack-server-runtime": "^0.20.0",
31
- "@jay-framework/wix-server-client": "^0.20.0",
29
+ "@jay-framework/fullstack-component": "^0.22.0",
30
+ "@jay-framework/production-server": "^0.22.0",
31
+ "@jay-framework/stack-server-runtime": "^0.22.0",
32
+ "@jay-framework/wix-server-client": "^0.22.0",
32
33
  "@wix/data": "^1.0.433",
33
34
  "@wix/sdk": "^1.21.5",
34
35
  "esbuild": "^0.21.0",
package/plugin.yaml CHANGED
@@ -1,7 +1,6 @@
1
1
  name: wix-deploy
2
2
 
3
- setup:
4
- handler: setupWixDeploy
3
+ setup: setupWixDeploy
5
4
 
6
5
  commands:
7
6
  - name: deploy