zitejs 0.9.113 → 0.9.114

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.
@@ -0,0 +1,5 @@
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 +1,25 @@
1
+ /**
2
+ * `npx zitejs bundle` — Bundle endpoint files for cloudflare-lambda deployment.
3
+ *
4
+ * Replaces the legacy `scripts/bundle-endpoints.js` from zitejs-starter.
5
+ * Reads endpoints from src/api/*.ts, resolves SDK imports via .zite/backend.ts
6
+ * (monorepo) or src/__zite__/integrations.ts (legacy), and outputs bundled ESM
7
+ * code suitable for the cloudflare-lambda worker runtime.
8
+ *
9
+ * Usage:
10
+ * npx zitejs bundle # bundle all endpoints
11
+ * npx zitejs bundle --app admin-panel # bundle endpoints for a specific app
12
+ * npx zitejs bundle --script <path> # bundle a one-off script
13
+ *
14
+ * Output: JSON to stdout
15
+ * { bundledEndpoints: Record<string, string>, endpointErrors?: Record<string, string> }
16
+ * or for --script: { bundledCode: string } or { error: string }
17
+ *
18
+ * Dependencies (add to zitejs package.json):
19
+ * "esbuild": "^0.25.0"
20
+ * "@babel/parser": "^7.26.0"
21
+ */
22
+ import * as esbuild from 'esbuild';
23
+ export declare const UNSUPPORTED_IN_WORKERD: Set<string>;
24
+ export declare const BASE_BUILD_OPTIONS: esbuild.BuildOptions;
1
25
  export declare function runBundle(): Promise<void>;
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.BASE_BUILD_OPTIONS = exports.UNSUPPORTED_IN_WORKERD = void 0;
36
37
  exports.runBundle = runBundle;
37
38
  /**
38
39
  * `npx zitejs bundle` — Bundle endpoint files for cloudflare-lambda deployment.
@@ -59,14 +60,21 @@ const esbuild = __importStar(require("esbuild"));
59
60
  const path = __importStar(require("path"));
60
61
  const fs = __importStar(require("fs"));
61
62
  const parser_1 = require("@babel/parser");
62
- const _NODE_BUILTIN_NAMES = [
63
- 'http', 'https', 'http2', 'stream', 'buffer', 'util', 'events', 'crypto',
64
- 'path', 'fs', 'url', 'querystring', 'zlib', 'net', 'tls', 'os', 'assert',
65
- 'process', 'child_process', 'cluster', 'dgram', 'dns', 'inspector', 'module',
66
- 'perf_hooks', 'readline', 'repl', 'string_decoder', 'timers', 'tty', 'v8',
67
- 'vm', 'worker_threads', 'async_hooks', 'trace_events', 'punycode',
68
- ];
69
- const NODE_BUILTINS = _NODE_BUILTIN_NAMES.flatMap(m => [m, `node:${m}`]);
63
+ const node_module_1 = require("node:module");
64
+ // workerd's `nodejs_compat` does not provide these. Left external they bundle
65
+ // fine and then kill the worker at load time with `No such module`; excluded,
66
+ // esbuild fails the one endpoint with a resolvable error instead. Pinned by
67
+ // apps/cloudflare-lambda tests/sdk-compat/node-builtin-support.test.ts.
68
+ exports.UNSUPPORTED_IN_WORKERD = new Set([
69
+ 'child_process', 'dgram', 'inspector', 'inspector/promises', 'perf_hooks',
70
+ 'readline', 'readline/promises', 'repl', 'tty', 'v8', 'worker_threads',
71
+ ]);
72
+ // External, not bundled: the worker supplies them. Sourced from Node because
73
+ // the hand-written list covered 36 of 68, so a dependency reaching for a name
74
+ // we forgot (`constants`, `fs/promises`) failed the whole endpoint.
75
+ const NODE_BUILTINS = node_module_1.builtinModules
76
+ .filter(m => !m.startsWith('_') && !exports.UNSUPPORTED_IN_WORKERD.has(m))
77
+ .flatMap(m => [m, `node:${m}`]);
70
78
  const PREBUNDLED_LIBS = {
71
79
  '@zite/endpoints-runtime-sdk': '__zite-runtime__.js',
72
80
  'zod': '__zod__.js',
@@ -87,7 +95,7 @@ const PREBUNDLED_LIBS = {
87
95
  '@google/generative-ai': '__gemini__.js',
88
96
  '@elevenlabs/elevenlabs-js': '__elevenlabs__.js',
89
97
  };
90
- const BASE_BUILD_OPTIONS = {
98
+ exports.BASE_BUILD_OPTIONS = {
91
99
  bundle: true,
92
100
  write: false,
93
101
  format: 'esm',
@@ -392,7 +400,7 @@ async function bundleEndpointsImpl(baseDir, endpointNames) {
392
400
  const wrapperCode = generateEndpointWrapper(name, usedImports, sdkExportKinds, sdkSource);
393
401
  try {
394
402
  const result = await esbuild.build({
395
- ...BASE_BUILD_OPTIONS,
403
+ ...exports.BASE_BUILD_OPTIONS,
396
404
  stdin: {
397
405
  contents: wrapperCode,
398
406
  resolveDir: `${baseDir}/src`,
@@ -462,7 +470,7 @@ globalThis.__endpoint = endpoint;
462
470
  `;
463
471
  try {
464
472
  const result = await esbuild.build({
465
- ...BASE_BUILD_OPTIONS,
473
+ ...exports.BASE_BUILD_OPTIONS,
466
474
  stdin: {
467
475
  contents: dispatcherCode,
468
476
  resolveDir: `${baseDir}/src`,
@@ -542,7 +550,7 @@ ${bodySection}
542
550
  }`;
543
551
  try {
544
552
  const result = await esbuild.build({
545
- ...BASE_BUILD_OPTIONS,
553
+ ...exports.BASE_BUILD_OPTIONS,
546
554
  stdin: {
547
555
  contents: wrappedScript,
548
556
  loader: 'ts',
@@ -0,0 +1,5 @@
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; } });
@@ -0,0 +1,2 @@
1
+ export { createCaller } from '../caller/index.js';
2
+ export type { EndpointConfig } from '../caller/index.js';
@@ -0,0 +1 @@
1
+ export { createCaller } from '../caller/index.js';
@@ -1 +1,25 @@
1
+ /**
2
+ * `npx zitejs bundle` — Bundle endpoint files for cloudflare-lambda deployment.
3
+ *
4
+ * Replaces the legacy `scripts/bundle-endpoints.js` from zitejs-starter.
5
+ * Reads endpoints from src/api/*.ts, resolves SDK imports via .zite/backend.ts
6
+ * (monorepo) or src/__zite__/integrations.ts (legacy), and outputs bundled ESM
7
+ * code suitable for the cloudflare-lambda worker runtime.
8
+ *
9
+ * Usage:
10
+ * npx zitejs bundle # bundle all endpoints
11
+ * npx zitejs bundle --app admin-panel # bundle endpoints for a specific app
12
+ * npx zitejs bundle --script <path> # bundle a one-off script
13
+ *
14
+ * Output: JSON to stdout
15
+ * { bundledEndpoints: Record<string, string>, endpointErrors?: Record<string, string> }
16
+ * or for --script: { bundledCode: string } or { error: string }
17
+ *
18
+ * Dependencies (add to zitejs package.json):
19
+ * "esbuild": "^0.25.0"
20
+ * "@babel/parser": "^7.26.0"
21
+ */
22
+ import * as esbuild from 'esbuild';
23
+ export declare const UNSUPPORTED_IN_WORKERD: Set<string>;
24
+ export declare const BASE_BUILD_OPTIONS: esbuild.BuildOptions;
1
25
  export declare function runBundle(): Promise<void>;
@@ -23,14 +23,21 @@ import * as esbuild from 'esbuild';
23
23
  import * as path from 'path';
24
24
  import * as fs from 'fs';
25
25
  import { parse } from '@babel/parser';
26
- const _NODE_BUILTIN_NAMES = [
27
- 'http', 'https', 'http2', 'stream', 'buffer', 'util', 'events', 'crypto',
28
- 'path', 'fs', 'url', 'querystring', 'zlib', 'net', 'tls', 'os', 'assert',
29
- 'process', 'child_process', 'cluster', 'dgram', 'dns', 'inspector', 'module',
30
- 'perf_hooks', 'readline', 'repl', 'string_decoder', 'timers', 'tty', 'v8',
31
- 'vm', 'worker_threads', 'async_hooks', 'trace_events', 'punycode',
32
- ];
33
- const NODE_BUILTINS = _NODE_BUILTIN_NAMES.flatMap(m => [m, `node:${m}`]);
26
+ import { builtinModules } from 'node:module';
27
+ // workerd's `nodejs_compat` does not provide these. Left external they bundle
28
+ // fine and then kill the worker at load time with `No such module`; excluded,
29
+ // esbuild fails the one endpoint with a resolvable error instead. Pinned by
30
+ // apps/cloudflare-lambda tests/sdk-compat/node-builtin-support.test.ts.
31
+ export const UNSUPPORTED_IN_WORKERD = new Set([
32
+ 'child_process', 'dgram', 'inspector', 'inspector/promises', 'perf_hooks',
33
+ 'readline', 'readline/promises', 'repl', 'tty', 'v8', 'worker_threads',
34
+ ]);
35
+ // External, not bundled: the worker supplies them. Sourced from Node because
36
+ // the hand-written list covered 36 of 68, so a dependency reaching for a name
37
+ // we forgot (`constants`, `fs/promises`) failed the whole endpoint.
38
+ const NODE_BUILTINS = builtinModules
39
+ .filter(m => !m.startsWith('_') && !UNSUPPORTED_IN_WORKERD.has(m))
40
+ .flatMap(m => [m, `node:${m}`]);
34
41
  const PREBUNDLED_LIBS = {
35
42
  '@zite/endpoints-runtime-sdk': '__zite-runtime__.js',
36
43
  'zod': '__zod__.js',
@@ -51,7 +58,7 @@ const PREBUNDLED_LIBS = {
51
58
  '@google/generative-ai': '__gemini__.js',
52
59
  '@elevenlabs/elevenlabs-js': '__elevenlabs__.js',
53
60
  };
54
- const BASE_BUILD_OPTIONS = {
61
+ export const BASE_BUILD_OPTIONS = {
55
62
  bundle: true,
56
63
  write: false,
57
64
  format: 'esm',
package/dist/esm/cli.js CHANGED
File without changes
@@ -0,0 +1,2 @@
1
+ export { createTableClient } from '../runtime/index.js';
2
+ export type { TableClient } from '../runtime/index.js';
@@ -0,0 +1 @@
1
+ export { createTableClient } from '../runtime/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.113",
3
+ "version": "0.9.114",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",