zitejs 0.10.4 → 0.10.6

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.
@@ -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}`);
@@ -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}`);
@@ -69,8 +69,8 @@ export type AppFacts = {
69
69
  };
70
70
  /** Written in by `zite()` at build; both false where it didn't build the app. */
71
71
  export declare const builtAppFacts: () => AppFacts;
72
- /** @internal What the app's access mode and a function's own input say of it. */
73
- export declare const functionRules: ({ access, input }: DescribedFunction, facts: AppFacts) => string[];
72
+ /** @internal What the app's access mode says of a function. */
73
+ export declare const functionRules: ({ access }: DescribedFunction, facts: AppFacts) => string[];
74
74
  export declare function describeFunction(id: string, request: Request): Promise<DescribedFunction>;
75
75
  type RouteLike = {
76
76
  id: string;
@@ -35,33 +35,12 @@ const RESERVED_PATHS = [
35
35
  ];
36
36
  const RESERVED_PATH = 'reserved-path: the platform answers this path before the app does; give the route another';
37
37
  const WEBHOOK_PATH_PARAM = "webhook-path-param: a webhook route's path can't have parameters, because its URL is registered once; put the value in the body or query";
38
- const OWNER_INPUTS = ['userId', 'ownerId'];
39
- const inputProperties = (input) => {
40
- const properties = input
41
- ?.properties;
42
- return properties && typeof properties === 'object'
43
- ? Object.keys(properties)
44
- : [];
45
- };
46
- /** @internal What the app's access mode and a function's own input say of it. */
47
- export const functionRules = ({ access, input }, facts) => {
48
- // A role may act for other users, which is what its middleware is for.
49
- const owner = access.kind === 'signedIn' && access.roles.length === 0
50
- ? inputProperties(input).find(key => OWNER_INPUTS.includes(key))
51
- : undefined;
52
- return [
53
- ...(facts.internal && access.kind === 'anyone'
54
- ? [
55
- 'public-in-internal: anyone can call it, and this internal app signs everyone in; make it a signedInFn',
56
- ]
57
- : []),
58
- ...(owner
59
- ? [
60
- `owner-from-input: it takes ${owner} as input, which any caller can set; use context.user.id, or if a role may act for other users, add role(id) to its middleware`,
61
- ]
62
- : []),
63
- ];
64
- };
38
+ /** @internal What the app's access mode says of a function. */
39
+ export const functionRules = ({ access }, facts) => facts.internal && access.kind === 'anyone'
40
+ ? [
41
+ 'public-in-internal: anyone can call it, and this internal app signs everyone in; make it a signedInFn',
42
+ ]
43
+ : [];
65
44
  const accessOf = (chain, problems) => {
66
45
  const kinds = chain
67
46
  .map(ziteMiddlewareKind)
@@ -1 +1 @@
1
- export declare const ZITEJS_VERSION = "0.10.4";
1
+ export declare const ZITEJS_VERSION = "0.10.6";
@@ -1,2 +1,2 @@
1
1
  // Written by scripts/write-version.mjs from package.json.
2
- export const ZITEJS_VERSION = '0.10.4';
2
+ export const ZITEJS_VERSION = '0.10.6';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.10.4",
3
+ "version": "0.10.6",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "sideEffects": [