zitejs 0.10.3 → 0.10.5
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/dist/cjs/dev/index.js +55 -0
- package/dist/cjs/meta/index.d.ts +11 -0
- package/dist/cjs/meta/index.js +14 -0
- package/dist/cjs/start/build/entries.d.ts +5 -8
- package/dist/cjs/start/build/entries.js +25 -32
- package/dist/cjs/start/build/roleIds.d.ts +1 -0
- package/dist/cjs/start/build/roleIds.js +3 -2
- package/dist/cjs/start/types.d.ts +2 -7
- package/dist/esm/dev/index.js +22 -0
- package/dist/esm/meta/index.d.ts +11 -0
- package/dist/esm/meta/index.js +10 -0
- package/dist/esm/start/build/entries.d.ts +5 -8
- package/dist/esm/start/build/entries.js +24 -31
- package/dist/esm/start/build/roleIds.d.ts +1 -0
- package/dist/esm/start/build/roleIds.js +1 -1
- package/dist/esm/start/build/vite.d.ts +1 -1
- package/dist/esm/start/build/vite.js +27 -16
- package/dist/esm/start/entries/node/server.d.ts +3 -0
- package/dist/esm/start/entries/node/server.js +9 -0
- package/dist/esm/start/entries/worker/server.d.ts +3 -0
- package/dist/esm/start/entries/worker/server.js +7 -0
- package/dist/esm/start/types.d.ts +2 -7
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/package.json +6 -1
- package/tsconfig/start.json +1 -1
package/dist/cjs/dev/index.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.projectRuntimeHasIntegrationsClient = projectRuntimeHasIntegrationsClient;
|
|
4
37
|
exports.runGenerate = runGenerate;
|
|
@@ -218,9 +251,31 @@ async function runGenerate() {
|
|
|
218
251
|
regenerateAppAirtableSdk(app);
|
|
219
252
|
regenerateAppIntegrationsIndex(app);
|
|
220
253
|
(0, entries_js_1.regenerateStartEntries)(app);
|
|
254
|
+
await regenerateStartRouteTree(app);
|
|
221
255
|
}
|
|
222
256
|
console.log('Done!');
|
|
223
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* As `zitejs check` writes it, after the entries: the tree's footer types the
|
|
260
|
+
* start instance only once `.zite/start.ts` is there. Without this, a check run
|
|
261
|
+
* straight with tsgo after generate reads the routes as last built.
|
|
262
|
+
*/
|
|
263
|
+
async function regenerateStartRouteTree(app) {
|
|
264
|
+
if (!(0, entries_js_1.isStartAppDir)(app.path))
|
|
265
|
+
return;
|
|
266
|
+
const tree = (0, path_1.join)(app.path, 'src/routeTree.gen.ts');
|
|
267
|
+
const read = () => ((0, fs_2.existsSync)(tree) ? (0, fs_2.readFileSync)(tree, 'utf-8') : '');
|
|
268
|
+
try {
|
|
269
|
+
const before = read();
|
|
270
|
+
const { regenerateRouteTree } = await Promise.resolve().then(() => __importStar(require('../check/start/routeTree.js')));
|
|
271
|
+
await regenerateRouteTree(app.path);
|
|
272
|
+
if (read() !== before)
|
|
273
|
+
console.log(`Wrote ${tree}`);
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
console.warn(`Route tree generation failed for ${app.path}:`, err instanceof Error ? err.message : err);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
224
279
|
async function runDev() {
|
|
225
280
|
const env = process.env.ZITE_ENV ?? 'production';
|
|
226
281
|
console.log(`zitejs dev — environment: ${env}`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ZiteWorkspace = {
|
|
2
|
+
workspaceHomeUrl: string;
|
|
3
|
+
editorUrl: string;
|
|
4
|
+
appPublicIdentifier: string;
|
|
5
|
+
projectPublicIdentifier: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class ZiteMeta {
|
|
8
|
+
/** Workspace home + this app's editor URL for *this* clone. */
|
|
9
|
+
static getWorkspace(): Promise<ZiteWorkspace>;
|
|
10
|
+
}
|
|
11
|
+
export declare const Meta: typeof ZiteMeta;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Meta = exports.ZiteMeta = void 0;
|
|
4
|
+
const reservedIds_js_1 = require("../internal/reservedIds.js");
|
|
5
|
+
const sdkCall_js_1 = require("../internal/sdkCall.js");
|
|
6
|
+
const META_SDK_INTEGRATION_ID = reservedIds_js_1.RESERVED_INTEGRATION_IDS.meta;
|
|
7
|
+
class ZiteMeta {
|
|
8
|
+
/** Workspace home + this app's editor URL for *this* clone. */
|
|
9
|
+
static getWorkspace() {
|
|
10
|
+
return (0, sdkCall_js_1.getSdkCall)()(META_SDK_INTEGRATION_ID, 'ZiteMeta', 'getWorkspace', {});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ZiteMeta = ZiteMeta;
|
|
14
|
+
exports.Meta = ZiteMeta;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { type SourceDir } from '../../sourceRoots.js';
|
|
2
|
-
export declare const START_SERVER_ENTRY = ".zite/server.ts";
|
|
3
2
|
export declare const START_INSTANCE_ENTRY = ".zite/start.ts";
|
|
4
|
-
export type StartTarget = 'cloudflare' | 'node';
|
|
5
|
-
/**
|
|
6
|
-
* The server entry every Start app builds with. Platform-owned: regenerated,
|
|
7
|
-
* never edited. On Workers it's an entrypoint, so the host can hand each fetch
|
|
8
|
-
* its props; on Node, a plain fetch handler.
|
|
9
|
-
*/
|
|
10
|
-
export declare const renderStartServerEntry: (target?: StartTarget) => string;
|
|
11
3
|
/** The start instance: the platform's middleware, then the app's own `src/start.ts` when it has one. */
|
|
12
4
|
export declare const renderStartInstance: (hasAppStart: boolean) => string;
|
|
13
5
|
export declare const hasAppStart: (appDir: string) => boolean;
|
|
@@ -20,6 +12,11 @@ export declare const workspaceHasStartApps: () => boolean;
|
|
|
20
12
|
* `dev` all write them. Returns the ones that changed.
|
|
21
13
|
*/
|
|
22
14
|
export declare function writeStartFiles(appDir: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Where an app's role ids are typed: beside the zite.permissions.json they come from, so a workspace's apps share one
|
|
17
|
+
* file. Without one, the workspace root; a single app is its own.
|
|
18
|
+
*/
|
|
19
|
+
export declare const rolesDirOf: (appDir: string) => string;
|
|
23
20
|
export declare function regenerateStartEntries(app: SourceDir): void;
|
|
24
21
|
/**
|
|
25
22
|
* App modules that mention createAutomation or createProviderTrigger: what the workflow registry imports. Describe
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderWorkflowModules = exports.workspaceHasStartApps = exports.isStartAppDir = exports.writeIfChanged = exports.hasAppStart = exports.renderStartInstance = exports.
|
|
3
|
+
exports.renderWorkflowModules = exports.rolesDirOf = exports.workspaceHasStartApps = exports.isStartAppDir = exports.writeIfChanged = exports.hasAppStart = exports.renderStartInstance = exports.START_INSTANCE_ENTRY = void 0;
|
|
4
4
|
exports.writeStartFiles = writeStartFiles;
|
|
5
5
|
exports.regenerateStartEntries = regenerateStartEntries;
|
|
6
6
|
exports.workflowFiles = workflowFiles;
|
|
@@ -8,34 +8,8 @@ const node_fs_1 = require("node:fs");
|
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
9
|
const sourceRoots_js_1 = require("../../sourceRoots.js");
|
|
10
10
|
const roleIds_js_1 = require("./roleIds.js");
|
|
11
|
-
exports.START_SERVER_ENTRY = '.zite/server.ts';
|
|
12
11
|
exports.START_INSTANCE_ENTRY = '.zite/start.ts';
|
|
13
12
|
const APP_START_FILES = ['src/start.ts', 'src/start.tsx'];
|
|
14
|
-
/**
|
|
15
|
-
* The server entry every Start app builds with. Platform-owned: regenerated,
|
|
16
|
-
* never edited. On Workers it's an entrypoint, so the host can hand each fetch
|
|
17
|
-
* its props; on Node, a plain fetch handler.
|
|
18
|
-
*/
|
|
19
|
-
const renderStartServerEntry = (target = 'cloudflare') => target === 'cloudflare'
|
|
20
|
-
? `// Generated by zitejs for TanStack Start apps. The platform owns this file.
|
|
21
|
-
// First, so an SDK client an app module builds as it loads gets zitejs's fetch.
|
|
22
|
-
import 'zitejs/start/fetch';
|
|
23
|
-
import handler from '@tanstack/react-start/server-entry';
|
|
24
|
-
import { createZiteWorker } from 'zitejs/start/worker';
|
|
25
|
-
import { getRouter } from '../src/router';
|
|
26
|
-
|
|
27
|
-
export default createZiteWorker({ handler, getRouter });
|
|
28
|
-
`
|
|
29
|
-
: `// Generated by zitejs for TanStack Start apps. The platform owns this file.
|
|
30
|
-
// First, so an SDK client an app module builds as it loads gets zitejs's fetch.
|
|
31
|
-
import 'zitejs/start/fetch';
|
|
32
|
-
import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
|
|
33
|
-
import { createZiteFetch } from 'zitejs/start/server';
|
|
34
|
-
import { getRouter } from '../src/router';
|
|
35
|
-
|
|
36
|
-
export default createServerEntry({ fetch: createZiteFetch({ handler, getRouter }) });
|
|
37
|
-
`;
|
|
38
|
-
exports.renderStartServerEntry = renderStartServerEntry;
|
|
39
13
|
const START_INSTANCE_HEADER = `// Generated by zitejs for TanStack Start apps. The platform owns this file.
|
|
40
14
|
// TanStack's start-instance file, the only place Start 1.169 registers global middleware. Generated so the platform's
|
|
41
15
|
// CSRF check and run log can't be dropped; the app's own src/start.ts composes after them.
|
|
@@ -99,13 +73,32 @@ exports.workspaceHasStartApps = workspaceHasStartApps;
|
|
|
99
73
|
* `dev` all write them. Returns the ones that changed.
|
|
100
74
|
*/
|
|
101
75
|
function writeStartFiles(appDir) {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
76
|
+
const rolesDir = (0, exports.rolesDirOf)(appDir);
|
|
77
|
+
return [
|
|
78
|
+
...((0, exports.writeIfChanged)(appDir, exports.START_INSTANCE_ENTRY, (0, exports.renderStartInstance)((0, exports.hasAppStart)(appDir)))
|
|
79
|
+
? [exports.START_INSTANCE_ENTRY]
|
|
80
|
+
: []),
|
|
81
|
+
...((0, exports.writeIfChanged)(rolesDir, roleIds_js_1.START_ROLES_FILE, (0, roleIds_js_1.renderRoleIds)((0, roleIds_js_1.workspaceRoleIds)(appDir)))
|
|
82
|
+
? [(0, node_path_1.relative)(appDir, (0, node_path_1.join)(rolesDir, roleIds_js_1.START_ROLES_FILE))]
|
|
83
|
+
: []),
|
|
106
84
|
];
|
|
107
|
-
return files.flatMap(([file, content]) => (0, exports.writeIfChanged)(appDir, file, content) ? [file] : []);
|
|
108
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Where an app's role ids are typed: beside the zite.permissions.json they come from, so a workspace's apps share one
|
|
88
|
+
* file. Without one, the workspace root; a single app is its own.
|
|
89
|
+
*/
|
|
90
|
+
const rolesDirOf = (appDir) => {
|
|
91
|
+
const permissions = (0, roleIds_js_1.findPermissionsFile)(appDir);
|
|
92
|
+
if (permissions)
|
|
93
|
+
return (0, node_path_1.dirname)(permissions);
|
|
94
|
+
for (let at = (0, node_path_1.resolve)(appDir);; at = (0, node_path_1.dirname)(at)) {
|
|
95
|
+
if (readConfig(at)?.project !== undefined)
|
|
96
|
+
return at;
|
|
97
|
+
if ((0, node_path_1.dirname)(at) === at)
|
|
98
|
+
return (0, node_path_1.resolve)(appDir);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.rolesDirOf = rolesDirOf;
|
|
109
102
|
function regenerateStartEntries(app) {
|
|
110
103
|
if (!isStartApp(app))
|
|
111
104
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const START_ROLES_FILE = ".zite/roles.d.ts";
|
|
2
2
|
/** The roles every workspace has without defining them, as the platform names them. */
|
|
3
3
|
export declare const BUILTIN_ROLE_IDS: readonly ["builtin:all-team-members", "builtin:all-users"];
|
|
4
|
+
export declare const findPermissionsFile: (appDir: string) => string | undefined;
|
|
4
5
|
/**
|
|
5
6
|
* The built-ins, then the roles the nearest `zite.permissions.json` defines. None at all when there's no readable
|
|
6
7
|
* file, so role ids stay plain strings: a missing or broken file would otherwise type every role the app names as a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderRoleIds = exports.workspaceRoleIds = exports.BUILTIN_ROLE_IDS = exports.START_ROLES_FILE = void 0;
|
|
3
|
+
exports.renderRoleIds = exports.workspaceRoleIds = exports.findPermissionsFile = exports.BUILTIN_ROLE_IDS = exports.START_ROLES_FILE = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
exports.START_ROLES_FILE = '.zite/roles.d.ts';
|
|
@@ -20,6 +20,7 @@ const findPermissionsFile = (appDir) => {
|
|
|
20
20
|
return undefined;
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
+
exports.findPermissionsFile = findPermissionsFile;
|
|
23
24
|
// Undefined for a file that isn't a permissions file: its roles can't be known.
|
|
24
25
|
const definedRoleIds = (file) => {
|
|
25
26
|
try {
|
|
@@ -41,7 +42,7 @@ const definedRoleIds = (file) => {
|
|
|
41
42
|
* typo, and the nearest id that compiles is a built-in that admits everyone.
|
|
42
43
|
*/
|
|
43
44
|
const workspaceRoleIds = (appDir) => {
|
|
44
|
-
const file = findPermissionsFile(appDir);
|
|
45
|
+
const file = (0, exports.findPermissionsFile)(appDir);
|
|
45
46
|
const defined = file ? definedRoleIds(file) : undefined;
|
|
46
47
|
return defined ? [...new Set([...exports.BUILTIN_ROLE_IDS, ...defined])] : [];
|
|
47
48
|
};
|
|
@@ -2,6 +2,7 @@ import type { StepEventStatus, StepSuspension } from '../steps/index.js';
|
|
|
2
2
|
import type { AiUsageRecord } from './platform/aiUsage.js';
|
|
3
3
|
import type { AirtableCache } from './platform/airtable/cache.js';
|
|
4
4
|
import type { InvokeKind } from './protocol.js';
|
|
5
|
+
import type { ZiteWorkspace } from '../meta/index.js';
|
|
5
6
|
export type Role = {
|
|
6
7
|
id: string;
|
|
7
8
|
name: string;
|
|
@@ -238,13 +239,7 @@ export type SiteHead = {
|
|
|
238
239
|
/** An installable app's, served at `/manifest.webmanifest`. */
|
|
239
240
|
manifest?: WebManifest;
|
|
240
241
|
};
|
|
241
|
-
|
|
242
|
-
export type ZiteWorkspace = {
|
|
243
|
-
workspaceHomeUrl: string;
|
|
244
|
-
editorUrl: string;
|
|
245
|
-
appPublicIdentifier: string;
|
|
246
|
-
projectPublicIdentifier: string;
|
|
247
|
-
};
|
|
242
|
+
export type { ZiteWorkspace };
|
|
248
243
|
/** A marketplace demo's listing, which the platform's runtime shows the visitor. */
|
|
249
244
|
export type DemoListing = {
|
|
250
245
|
listingSlug: string;
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -213,9 +213,31 @@ export async function runGenerate() {
|
|
|
213
213
|
regenerateAppAirtableSdk(app);
|
|
214
214
|
regenerateAppIntegrationsIndex(app);
|
|
215
215
|
regenerateStartEntries(app);
|
|
216
|
+
await regenerateStartRouteTree(app);
|
|
216
217
|
}
|
|
217
218
|
console.log('Done!');
|
|
218
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* As `zitejs check` writes it, after the entries: the tree's footer types the
|
|
222
|
+
* start instance only once `.zite/start.ts` is there. Without this, a check run
|
|
223
|
+
* straight with tsgo after generate reads the routes as last built.
|
|
224
|
+
*/
|
|
225
|
+
async function regenerateStartRouteTree(app) {
|
|
226
|
+
if (!isStartAppDir(app.path))
|
|
227
|
+
return;
|
|
228
|
+
const tree = join(app.path, 'src/routeTree.gen.ts');
|
|
229
|
+
const read = () => (existsSync(tree) ? readFileSync(tree, 'utf-8') : '');
|
|
230
|
+
try {
|
|
231
|
+
const before = read();
|
|
232
|
+
const { regenerateRouteTree } = await import('../check/start/routeTree.js');
|
|
233
|
+
await regenerateRouteTree(app.path);
|
|
234
|
+
if (read() !== before)
|
|
235
|
+
console.log(`Wrote ${tree}`);
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
console.warn(`Route tree generation failed for ${app.path}:`, err instanceof Error ? err.message : err);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
219
241
|
export async function runDev() {
|
|
220
242
|
const env = process.env.ZITE_ENV ?? 'production';
|
|
221
243
|
console.log(`zitejs dev — environment: ${env}`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ZiteWorkspace = {
|
|
2
|
+
workspaceHomeUrl: string;
|
|
3
|
+
editorUrl: string;
|
|
4
|
+
appPublicIdentifier: string;
|
|
5
|
+
projectPublicIdentifier: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class ZiteMeta {
|
|
8
|
+
/** Workspace home + this app's editor URL for *this* clone. */
|
|
9
|
+
static getWorkspace(): Promise<ZiteWorkspace>;
|
|
10
|
+
}
|
|
11
|
+
export declare const Meta: typeof ZiteMeta;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RESERVED_INTEGRATION_IDS } from '../internal/reservedIds.js';
|
|
2
|
+
import { getSdkCall } from '../internal/sdkCall.js';
|
|
3
|
+
const META_SDK_INTEGRATION_ID = RESERVED_INTEGRATION_IDS.meta;
|
|
4
|
+
export class ZiteMeta {
|
|
5
|
+
/** Workspace home + this app's editor URL for *this* clone. */
|
|
6
|
+
static getWorkspace() {
|
|
7
|
+
return getSdkCall()(META_SDK_INTEGRATION_ID, 'ZiteMeta', 'getWorkspace', {});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const Meta = ZiteMeta;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { type SourceDir } from '../../sourceRoots.js';
|
|
2
|
-
export declare const START_SERVER_ENTRY = ".zite/server.ts";
|
|
3
2
|
export declare const START_INSTANCE_ENTRY = ".zite/start.ts";
|
|
4
|
-
export type StartTarget = 'cloudflare' | 'node';
|
|
5
|
-
/**
|
|
6
|
-
* The server entry every Start app builds with. Platform-owned: regenerated,
|
|
7
|
-
* never edited. On Workers it's an entrypoint, so the host can hand each fetch
|
|
8
|
-
* its props; on Node, a plain fetch handler.
|
|
9
|
-
*/
|
|
10
|
-
export declare const renderStartServerEntry: (target?: StartTarget) => string;
|
|
11
3
|
/** The start instance: the platform's middleware, then the app's own `src/start.ts` when it has one. */
|
|
12
4
|
export declare const renderStartInstance: (hasAppStart: boolean) => string;
|
|
13
5
|
export declare const hasAppStart: (appDir: string) => boolean;
|
|
@@ -20,6 +12,11 @@ export declare const workspaceHasStartApps: () => boolean;
|
|
|
20
12
|
* `dev` all write them. Returns the ones that changed.
|
|
21
13
|
*/
|
|
22
14
|
export declare function writeStartFiles(appDir: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Where an app's role ids are typed: beside the zite.permissions.json they come from, so a workspace's apps share one
|
|
17
|
+
* file. Without one, the workspace root; a single app is its own.
|
|
18
|
+
*/
|
|
19
|
+
export declare const rolesDirOf: (appDir: string) => string;
|
|
23
20
|
export declare function regenerateStartEntries(app: SourceDir): void;
|
|
24
21
|
/**
|
|
25
22
|
* App modules that mention createAutomation or createProviderTrigger: what the workflow registry imports. Describe
|
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import { dirname, join, relative, resolve } from 'node:path';
|
|
3
3
|
import { listSourceDirs } from '../../sourceRoots.js';
|
|
4
|
-
import { renderRoleIds, START_ROLES_FILE, workspaceRoleIds, } from './roleIds.js';
|
|
5
|
-
export const START_SERVER_ENTRY = '.zite/server.ts';
|
|
4
|
+
import { findPermissionsFile, renderRoleIds, START_ROLES_FILE, workspaceRoleIds, } from './roleIds.js';
|
|
6
5
|
export const START_INSTANCE_ENTRY = '.zite/start.ts';
|
|
7
6
|
const APP_START_FILES = ['src/start.ts', 'src/start.tsx'];
|
|
8
|
-
/**
|
|
9
|
-
* The server entry every Start app builds with. Platform-owned: regenerated,
|
|
10
|
-
* never edited. On Workers it's an entrypoint, so the host can hand each fetch
|
|
11
|
-
* its props; on Node, a plain fetch handler.
|
|
12
|
-
*/
|
|
13
|
-
export const renderStartServerEntry = (target = 'cloudflare') => target === 'cloudflare'
|
|
14
|
-
? `// Generated by zitejs for TanStack Start apps. The platform owns this file.
|
|
15
|
-
// First, so an SDK client an app module builds as it loads gets zitejs's fetch.
|
|
16
|
-
import 'zitejs/start/fetch';
|
|
17
|
-
import handler from '@tanstack/react-start/server-entry';
|
|
18
|
-
import { createZiteWorker } from 'zitejs/start/worker';
|
|
19
|
-
import { getRouter } from '../src/router';
|
|
20
|
-
|
|
21
|
-
export default createZiteWorker({ handler, getRouter });
|
|
22
|
-
`
|
|
23
|
-
: `// Generated by zitejs for TanStack Start apps. The platform owns this file.
|
|
24
|
-
// First, so an SDK client an app module builds as it loads gets zitejs's fetch.
|
|
25
|
-
import 'zitejs/start/fetch';
|
|
26
|
-
import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
|
|
27
|
-
import { createZiteFetch } from 'zitejs/start/server';
|
|
28
|
-
import { getRouter } from '../src/router';
|
|
29
|
-
|
|
30
|
-
export default createServerEntry({ fetch: createZiteFetch({ handler, getRouter }) });
|
|
31
|
-
`;
|
|
32
7
|
const START_INSTANCE_HEADER = `// Generated by zitejs for TanStack Start apps. The platform owns this file.
|
|
33
8
|
// TanStack's start-instance file, the only place Start 1.169 registers global middleware. Generated so the platform's
|
|
34
9
|
// CSRF check and run log can't be dropped; the app's own src/start.ts composes after them.
|
|
@@ -87,13 +62,31 @@ export const workspaceHasStartApps = () => listSourceDirs().some(isStartApp);
|
|
|
87
62
|
* `dev` all write them. Returns the ones that changed.
|
|
88
63
|
*/
|
|
89
64
|
export function writeStartFiles(appDir) {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
65
|
+
const rolesDir = rolesDirOf(appDir);
|
|
66
|
+
return [
|
|
67
|
+
...(writeIfChanged(appDir, START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir)))
|
|
68
|
+
? [START_INSTANCE_ENTRY]
|
|
69
|
+
: []),
|
|
70
|
+
...(writeIfChanged(rolesDir, START_ROLES_FILE, renderRoleIds(workspaceRoleIds(appDir)))
|
|
71
|
+
? [relative(appDir, join(rolesDir, START_ROLES_FILE))]
|
|
72
|
+
: []),
|
|
94
73
|
];
|
|
95
|
-
return files.flatMap(([file, content]) => writeIfChanged(appDir, file, content) ? [file] : []);
|
|
96
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Where an app's role ids are typed: beside the zite.permissions.json they come from, so a workspace's apps share one
|
|
77
|
+
* file. Without one, the workspace root; a single app is its own.
|
|
78
|
+
*/
|
|
79
|
+
export const rolesDirOf = (appDir) => {
|
|
80
|
+
const permissions = findPermissionsFile(appDir);
|
|
81
|
+
if (permissions)
|
|
82
|
+
return dirname(permissions);
|
|
83
|
+
for (let at = resolve(appDir);; at = dirname(at)) {
|
|
84
|
+
if (readConfig(at)?.project !== undefined)
|
|
85
|
+
return at;
|
|
86
|
+
if (dirname(at) === at)
|
|
87
|
+
return resolve(appDir);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
97
90
|
export function regenerateStartEntries(app) {
|
|
98
91
|
if (!isStartApp(app))
|
|
99
92
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const START_ROLES_FILE = ".zite/roles.d.ts";
|
|
2
2
|
/** The roles every workspace has without defining them, as the platform names them. */
|
|
3
3
|
export declare const BUILTIN_ROLE_IDS: readonly ["builtin:all-team-members", "builtin:all-users"];
|
|
4
|
+
export declare const findPermissionsFile: (appDir: string) => string | undefined;
|
|
4
5
|
/**
|
|
5
6
|
* The built-ins, then the roles the nearest `zite.permissions.json` defines. None at all when there's no readable
|
|
6
7
|
* file, so role ids stay plain strings: a missing or broken file would otherwise type every role the app names as a
|
|
@@ -8,7 +8,7 @@ export const BUILTIN_ROLE_IDS = [
|
|
|
8
8
|
];
|
|
9
9
|
const PERMISSIONS_FILE = 'zite.permissions.json';
|
|
10
10
|
// The workspace root's in a monorepo, above apps/<dir>/.
|
|
11
|
-
const findPermissionsFile = (appDir) => {
|
|
11
|
+
export const findPermissionsFile = (appDir) => {
|
|
12
12
|
for (let dir = resolve(appDir);; dir = dirname(dir)) {
|
|
13
13
|
const file = join(dir, PERMISSIONS_FILE);
|
|
14
14
|
if (existsSync(file))
|
|
@@ -41,7 +41,7 @@ export declare const devSignInOf: (appDir: string, appEnv: Record<string, string
|
|
|
41
41
|
/** @internal The app's id in its zite.config.json, which `local` mints dev tokens for; null without one. */
|
|
42
42
|
export declare const devAppIdOf: (appDir: string) => string | null;
|
|
43
43
|
export type ZiteOptions = {
|
|
44
|
-
/** A server entry the caller owns, relative to the app root. By default
|
|
44
|
+
/** A server entry the caller owns, relative to the app root. By default the app builds on zitejs's own. */
|
|
45
45
|
serverEntry?: string;
|
|
46
46
|
/** Build for Cloudflare Workers, the target the platform deploys. Defaults to true; false builds for Node. */
|
|
47
47
|
cloudflare?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import { loadEnv } from 'vite';
|
|
4
5
|
import { parse as parseEnv } from 'dotenv';
|
|
5
6
|
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
@@ -13,7 +14,7 @@ import { sourceRootOf } from '../../sourceRoots.js';
|
|
|
13
14
|
import { registrationHashes } from './registrationHash.js';
|
|
14
15
|
import { sdkPatches } from './sdkPatches.js';
|
|
15
16
|
import { siteHeadOf } from './siteHead.js';
|
|
16
|
-
import { hasAppStart, renderStartInstance,
|
|
17
|
+
import { hasAppStart, renderStartInstance, renderWorkflowModules, START_INSTANCE_ENTRY, workflowFiles, writeIfChanged, } from './entries.js';
|
|
17
18
|
// Must match the literals in ../serve/server.ts and ../describe/describe.ts, which the build rewrites.
|
|
18
19
|
const FN_IDS_TOKEN = '__ZITE_FN_IDS__';
|
|
19
20
|
const FN_DESCRIPTIONS_LITERAL = /(["'`])__ZITE_FN_DESCRIPTIONS__\1/;
|
|
@@ -176,13 +177,12 @@ const loadCloudflare = async (main) => {
|
|
|
176
177
|
};
|
|
177
178
|
/** The one plugin a Zite app's `vite.config.ts` uses. */
|
|
178
179
|
export function zite(options = {}) {
|
|
179
|
-
const serverEntry = options.serverEntry ?? START_SERVER_ENTRY;
|
|
180
|
-
// Platform-owned, so they're rewritten whenever they differ. Sandboxes run the
|
|
181
|
-
// image's zitejs for `generate`, which may predate Start; the plugin can't.
|
|
182
180
|
const appDir = process.cwd();
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
const serverEntry = options.serverEntry
|
|
182
|
+
? path.join(appDir, options.serverEntry)
|
|
183
|
+
: fileURLToPath(new URL(`../entries/${options.cloudflare === false ? 'node' : 'worker'}/server.js`, import.meta.url));
|
|
184
|
+
// Platform-owned, so it's rewritten whenever it differs. Sandboxes run the
|
|
185
|
+
// image's zitejs for `generate`, which may predate Start; the plugin can't.
|
|
186
186
|
writeIfChanged(appDir, START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir)));
|
|
187
187
|
// Every server function TanStack's compiler found, from its own hook, by id.
|
|
188
188
|
const ids = new Map();
|
|
@@ -225,10 +225,6 @@ export function zite(options = {}) {
|
|
|
225
225
|
find: /^zitejs\/email$/,
|
|
226
226
|
replacement: path.join(root, '.zite/integrations/email.ts'),
|
|
227
227
|
},
|
|
228
|
-
{
|
|
229
|
-
find: /^zitejs\/meta$/,
|
|
230
|
-
replacement: path.join(root, '.zite/meta.ts'),
|
|
231
|
-
},
|
|
232
228
|
// Classic's actions run on better-auth's client; Start's call the sign-in module's routes.
|
|
233
229
|
{ find: /^zitejs\/auth$/, replacement: 'zitejs/start/auth' },
|
|
234
230
|
],
|
|
@@ -418,12 +414,27 @@ export function zite(options = {}) {
|
|
|
418
414
|
return `export const devSignIn = ${JSON.stringify(settings)};\n`;
|
|
419
415
|
},
|
|
420
416
|
};
|
|
417
|
+
// The built-in server entry imports the app's router through this.
|
|
418
|
+
const appRouter = {
|
|
419
|
+
name: 'zite:app-router',
|
|
420
|
+
enforce: 'pre',
|
|
421
|
+
resolveId(id) {
|
|
422
|
+
return id === 'virtual:zite/app-router'
|
|
423
|
+
? this.resolve(path.join(appDir, 'src', 'router'))
|
|
424
|
+
: undefined;
|
|
425
|
+
},
|
|
426
|
+
};
|
|
421
427
|
return [
|
|
422
428
|
// First, so ids name lines in the source, before TanStack splits a route's component out of it.
|
|
423
429
|
ziteId(),
|
|
430
|
+
appRouter,
|
|
424
431
|
tanstackStart({
|
|
425
|
-
// TanStack resolves
|
|
426
|
-
server: {
|
|
432
|
+
// TanStack resolves its entries from the app's src/, and only as relative paths.
|
|
433
|
+
server: {
|
|
434
|
+
entry: path
|
|
435
|
+
.relative(path.join(appDir, 'src'), serverEntry)
|
|
436
|
+
.replace(/\.ts$/, ''),
|
|
437
|
+
},
|
|
427
438
|
start: { entry: `../${START_INSTANCE_ENTRY.replace(/\.ts$/, '')}` },
|
|
428
439
|
serverFns: {
|
|
429
440
|
generateFunctionId: ({ filename, functionName }) => {
|
|
@@ -456,15 +467,15 @@ export function zite(options = {}) {
|
|
|
456
467
|
'zitejs/start/worker',
|
|
457
468
|
'zitejs/start/describe',
|
|
458
469
|
'zitejs/runtime',
|
|
470
|
+
'zitejs/meta',
|
|
459
471
|
],
|
|
460
472
|
// Replaces TanStack's list, so its `**/*.server.*` is restated. File
|
|
461
|
-
// patterns also catch `zitejs/db
|
|
462
|
-
//
|
|
473
|
+
// patterns also catch `zitejs/db` and `zitejs/integrations`, which the
|
|
474
|
+
// aliases above rewrite before specifiers are matched.
|
|
463
475
|
files: [
|
|
464
476
|
'**/*.server.*',
|
|
465
477
|
'**/.zite/db.ts',
|
|
466
478
|
'**/.zite/integrations/**',
|
|
467
|
-
'**/.zite/meta.ts',
|
|
468
479
|
],
|
|
469
480
|
},
|
|
470
481
|
// Replaces TanStack's empty list; its `**/*.client.*` files stay.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The server entry a Start app builds with off Workers: a plain fetch handler.
|
|
2
|
+
// First, so an SDK client an app module builds as it loads gets zitejs's fetch.
|
|
3
|
+
import '../../serve/fetch.js';
|
|
4
|
+
import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
|
|
5
|
+
import { getRouter } from 'virtual:zite/app-router';
|
|
6
|
+
import { createZiteFetch } from '../../serve/server.js';
|
|
7
|
+
export default createServerEntry({
|
|
8
|
+
fetch: createZiteFetch({ handler, getRouter }),
|
|
9
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The server entry every Start app builds with on Workers: an entrypoint, so the host can hand each fetch its props.
|
|
2
|
+
// First, so an SDK client an app module builds as it loads gets zitejs's fetch.
|
|
3
|
+
import '../../serve/fetch.js';
|
|
4
|
+
import handler from '@tanstack/react-start/server-entry';
|
|
5
|
+
import { getRouter } from 'virtual:zite/app-router';
|
|
6
|
+
import { createZiteWorker } from '../../serve/worker.js';
|
|
7
|
+
export default createZiteWorker({ handler, getRouter });
|
|
@@ -2,6 +2,7 @@ import type { StepEventStatus, StepSuspension } from '../steps/index.js';
|
|
|
2
2
|
import type { AiUsageRecord } from './platform/aiUsage.js';
|
|
3
3
|
import type { AirtableCache } from './platform/airtable/cache.js';
|
|
4
4
|
import type { InvokeKind } from './protocol.js';
|
|
5
|
+
import type { ZiteWorkspace } from '../meta/index.js';
|
|
5
6
|
export type Role = {
|
|
6
7
|
id: string;
|
|
7
8
|
name: string;
|
|
@@ -238,13 +239,7 @@ export type SiteHead = {
|
|
|
238
239
|
/** An installable app's, served at `/manifest.webmanifest`. */
|
|
239
240
|
manifest?: WebManifest;
|
|
240
241
|
};
|
|
241
|
-
|
|
242
|
-
export type ZiteWorkspace = {
|
|
243
|
-
workspaceHomeUrl: string;
|
|
244
|
-
editorUrl: string;
|
|
245
|
-
appPublicIdentifier: string;
|
|
246
|
-
projectPublicIdentifier: string;
|
|
247
|
-
};
|
|
242
|
+
export type { ZiteWorkspace };
|
|
248
243
|
/** A marketplace demo's listing, which the platform's runtime shows the visitor. */
|
|
249
244
|
export type DemoListing = {
|
|
250
245
|
listingSlug: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ZITEJS_VERSION = "0.10.
|
|
1
|
+
export declare const ZITEJS_VERSION = "0.10.5";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Written by scripts/write-version.mjs from package.json.
|
|
2
|
-
export const ZITEJS_VERSION = '0.10.
|
|
2
|
+
export const ZITEJS_VERSION = '0.10.5';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zitejs",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "The Zite framework — build apps on Zite Database",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -79,6 +79,11 @@
|
|
|
79
79
|
"import": "./dist/esm/pdf/index.js",
|
|
80
80
|
"require": "./dist/cjs/pdf/index.js"
|
|
81
81
|
},
|
|
82
|
+
"./meta": {
|
|
83
|
+
"types": "./dist/esm/meta/index.d.ts",
|
|
84
|
+
"import": "./dist/esm/meta/index.js",
|
|
85
|
+
"require": "./dist/cjs/meta/index.js"
|
|
86
|
+
},
|
|
82
87
|
"./schedules": {
|
|
83
88
|
"types": "./dist/esm/schedules/index.d.ts",
|
|
84
89
|
"import": "./dist/esm/schedules/index.js",
|
package/tsconfig/start.json
CHANGED
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"zitejs/db": ["${configDir}/../../.zite/db.ts"],
|
|
25
25
|
"zitejs/integrations": ["${configDir}/.zite/integrations/index.ts"],
|
|
26
26
|
"zitejs/email": ["${configDir}/.zite/integrations/email.ts"],
|
|
27
|
-
"zitejs/meta": ["${configDir}/.zite/meta.ts"],
|
|
28
27
|
"react": ["${configDir}/node_modules/@types/react"],
|
|
29
28
|
"react/*": ["${configDir}/node_modules/@types/react/*"],
|
|
30
29
|
"react-dom": ["${configDir}/node_modules/@types/react-dom"],
|
|
@@ -34,6 +33,7 @@
|
|
|
34
33
|
"include": [
|
|
35
34
|
"${configDir}/src",
|
|
36
35
|
"${configDir}/.zite/*.d.ts",
|
|
36
|
+
"${configDir}/../../.zite/*.d.ts",
|
|
37
37
|
"${configDir}/vite.config.ts"
|
|
38
38
|
],
|
|
39
39
|
"exclude": ["${configDir}/node_modules", "${configDir}/dist"]
|