zitejs 0.9.35 → 0.9.37

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.
@@ -383,7 +383,9 @@ async function bundleEndpointsImpl(baseDir, endpointNames) {
383
383
  }
384
384
  async function bundleOneOffScriptImpl(scriptPath, sdkPath) {
385
385
  const rawScript = fs.readFileSync(scriptPath, 'utf-8');
386
- const plugin = createAliasPlugin({ sdkPath });
386
+ // baseDir (the app dir — callers cd in before `--script`) lets the alias
387
+ // plugin resolve zitejs/db & zitejs/backend to the generated .zite/ files.
388
+ const plugin = createAliasPlugin({ baseDir: process.cwd(), sdkPath });
387
389
  let importSection = '';
388
390
  let bodySection = rawScript;
389
391
  try {
@@ -404,7 +406,14 @@ async function bundleOneOffScriptImpl(scriptPath, sdkPath) {
404
406
  }
405
407
  }
406
408
  catch { }
407
- const wrappedScript = `${importSection}
409
+ // Initialize the worker runtime (sets globalThis.__wrapSdkCall) like the
410
+ // endpoint wrapper does — otherwise createTableClient/createSqlClient from
411
+ // zitejs/db throw "Zite SDK runtime not initialized" at the worker.
412
+ const runtimeInit = `import { __wrapSdkCall, initRuntime } from '@zite/endpoints-runtime-sdk';
413
+ globalThis.__wrapSdkCall = __wrapSdkCall;
414
+ initRuntime();`;
415
+ const wrappedScript = `${runtimeInit}
416
+ ${importSection}
408
417
  export async function execute() {
409
418
  ${bodySection}
410
419
  }`;
@@ -347,7 +347,9 @@ async function bundleEndpointsImpl(baseDir, endpointNames) {
347
347
  }
348
348
  async function bundleOneOffScriptImpl(scriptPath, sdkPath) {
349
349
  const rawScript = fs.readFileSync(scriptPath, 'utf-8');
350
- const plugin = createAliasPlugin({ sdkPath });
350
+ // baseDir (the app dir — callers cd in before `--script`) lets the alias
351
+ // plugin resolve zitejs/db & zitejs/backend to the generated .zite/ files.
352
+ const plugin = createAliasPlugin({ baseDir: process.cwd(), sdkPath });
351
353
  let importSection = '';
352
354
  let bodySection = rawScript;
353
355
  try {
@@ -368,7 +370,14 @@ async function bundleOneOffScriptImpl(scriptPath, sdkPath) {
368
370
  }
369
371
  }
370
372
  catch { }
371
- const wrappedScript = `${importSection}
373
+ // Initialize the worker runtime (sets globalThis.__wrapSdkCall) like the
374
+ // endpoint wrapper does — otherwise createTableClient/createSqlClient from
375
+ // zitejs/db throw "Zite SDK runtime not initialized" at the worker.
376
+ const runtimeInit = `import { __wrapSdkCall, initRuntime } from '@zite/endpoints-runtime-sdk';
377
+ globalThis.__wrapSdkCall = __wrapSdkCall;
378
+ initRuntime();`;
379
+ const wrappedScript = `${runtimeInit}
380
+ ${importSection}
372
381
  export async function execute() {
373
382
  ${bodySection}
374
383
  }`;
package/dist/esm/cli.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.35",
3
+ "version": "0.9.37",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/runtime/index.js",
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCaller = void 0;
4
- var index_js_1 = require("../caller/index.js");
5
- Object.defineProperty(exports, "createCaller", { enumerable: true, get: function () { return index_js_1.createCaller; } });
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTableClient = void 0;
4
- var index_js_1 = require("../runtime/index.js");
5
- Object.defineProperty(exports, "createTableClient", { enumerable: true, get: function () { return index_js_1.createTableClient; } });
@@ -1,2 +0,0 @@
1
- export { createCaller } from '../caller/index.js';
2
- export type { EndpointConfig } from '../caller/index.js';
@@ -1 +0,0 @@
1
- export { createCaller } from '../caller/index.js';
@@ -1,2 +0,0 @@
1
- export { createTableClient } from '../runtime/index.js';
2
- export type { TableClient } from '../runtime/index.js';
@@ -1 +0,0 @@
1
- export { createTableClient } from '../runtime/index.js';