zitejs 0.9.62 → 0.9.64
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,20 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
type: 'record';
|
|
3
|
-
basePublicId: string;
|
|
4
|
-
tableId: string;
|
|
5
|
-
recordId: string;
|
|
6
|
-
} | {
|
|
7
|
-
type: 'app';
|
|
8
|
-
appId: string;
|
|
1
|
+
export interface NotificationLink {
|
|
9
2
|
path?: string;
|
|
10
3
|
params?: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
type: 'route';
|
|
13
|
-
path: string;
|
|
14
|
-
} | {
|
|
15
|
-
type: 'external';
|
|
16
|
-
url: string;
|
|
17
|
-
};
|
|
4
|
+
}
|
|
18
5
|
export type NotificationsCreateParams = {
|
|
19
6
|
recipients: string[];
|
|
20
7
|
title: string;
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -206,11 +206,10 @@ function generateSchema(database, existingSchema) {
|
|
|
206
206
|
}
|
|
207
207
|
function generateSentinelSdkTypes() {
|
|
208
208
|
return [
|
|
209
|
-
"export
|
|
210
|
-
"
|
|
211
|
-
"
|
|
212
|
-
"
|
|
213
|
-
" | { type: 'external'; url: string };",
|
|
209
|
+
"export interface NotificationLink {",
|
|
210
|
+
" path?: string;",
|
|
211
|
+
" params?: Record<string, string>;",
|
|
212
|
+
"}",
|
|
214
213
|
"",
|
|
215
214
|
"export interface NotificationsCreateParams {",
|
|
216
215
|
" recipients: string[];",
|
|
@@ -241,6 +240,53 @@ function generateSentinelSdkTypes() {
|
|
|
241
240
|
"",
|
|
242
241
|
];
|
|
243
242
|
}
|
|
243
|
+
function buildLinkTableComments(schema) {
|
|
244
|
+
const tablesById = new Map();
|
|
245
|
+
for (const t of schema.tables)
|
|
246
|
+
tablesById.set(t.id, t);
|
|
247
|
+
const seen = new Set();
|
|
248
|
+
const entries = [];
|
|
249
|
+
for (const table of schema.tables) {
|
|
250
|
+
for (const field of table.fields) {
|
|
251
|
+
if (field.definition.type !== "linked_record")
|
|
252
|
+
continue;
|
|
253
|
+
const tpl = field.definition.template;
|
|
254
|
+
if (tpl.isInverse)
|
|
255
|
+
continue;
|
|
256
|
+
const targetId = tpl.tableId;
|
|
257
|
+
if (!targetId)
|
|
258
|
+
continue;
|
|
259
|
+
const target = tablesById.get(targetId);
|
|
260
|
+
if (!target)
|
|
261
|
+
continue;
|
|
262
|
+
const sourceSdk = toPascalCase(table.sdkName);
|
|
263
|
+
const targetSdk = toPascalCase(target.sdkName);
|
|
264
|
+
const [first, second] = [sourceSdk, targetSdk].sort();
|
|
265
|
+
const linkName = `${first}${second}`;
|
|
266
|
+
if (seen.has(linkName))
|
|
267
|
+
continue;
|
|
268
|
+
seen.add(linkName);
|
|
269
|
+
const isSelf = table.id === targetId;
|
|
270
|
+
const col1 = isSelf
|
|
271
|
+
? `source${first}Id`
|
|
272
|
+
: `${first.charAt(0).toLowerCase()}${first.slice(1)}Id`;
|
|
273
|
+
const col2 = isSelf
|
|
274
|
+
? `target${second}Id`
|
|
275
|
+
: `${second.charAt(0).toLowerCase()}${second.slice(1)}Id`;
|
|
276
|
+
entries.push({ name: linkName, cols: [col1, col2] });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (entries.length === 0)
|
|
280
|
+
return [];
|
|
281
|
+
const lines = [
|
|
282
|
+
"//",
|
|
283
|
+
"// Link tables for zite.sql() JOINs (use these exact names):",
|
|
284
|
+
];
|
|
285
|
+
for (const e of entries) {
|
|
286
|
+
lines.push(`// "${e.name}" — columns: "${e.cols[0]}", "${e.cols[1]}"`);
|
|
287
|
+
}
|
|
288
|
+
return lines;
|
|
289
|
+
}
|
|
244
290
|
/**
|
|
245
291
|
* Generate .zite/db.ts purely from ZiteSchema.
|
|
246
292
|
* Pure function — no external data needed beyond what's in the schema file.
|
|
@@ -272,11 +318,10 @@ function generateDbTs(schema) {
|
|
|
272
318
|
lines.push("// - Use SDK names for tables (PascalCase) and fields (camelCase)");
|
|
273
319
|
lines.push('// - ALWAYS double-quote every identifier: FROM "Orders", WHERE "status" = $1');
|
|
274
320
|
lines.push("// - Use params array for user input ($1, $2, ...): never interpolate into SQL");
|
|
275
|
-
lines.push('// - Link tables: alphabetical PascalCase concat (Items+Orders → "ItemsOrders")');
|
|
276
|
-
lines.push('// with id columns: "itemsId", "ordersId"');
|
|
277
321
|
lines.push("// - Soft-deleted rows are excluded automatically — no WHERE deleted_at IS NULL");
|
|
278
322
|
lines.push("// - SELECT only — use .create/.update/.delete for writes");
|
|
279
323
|
lines.push('// - Load the "zite:sql" skill for full SQL reference (formulas, lookups, etc.)');
|
|
324
|
+
lines.push(...buildLinkTableComments(schema));
|
|
280
325
|
lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createMetaClient } from 'zitejs/runtime';");
|
|
281
326
|
lines.push("");
|
|
282
327
|
for (const table of schema.tables) {
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
type: 'record';
|
|
3
|
-
basePublicId: string;
|
|
4
|
-
tableId: string;
|
|
5
|
-
recordId: string;
|
|
6
|
-
} | {
|
|
7
|
-
type: 'app';
|
|
8
|
-
appId: string;
|
|
1
|
+
export interface NotificationLink {
|
|
9
2
|
path?: string;
|
|
10
3
|
params?: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
type: 'route';
|
|
13
|
-
path: string;
|
|
14
|
-
} | {
|
|
15
|
-
type: 'external';
|
|
16
|
-
url: string;
|
|
17
|
-
};
|
|
4
|
+
}
|
|
18
5
|
export type NotificationsCreateParams = {
|
|
19
6
|
recipients: string[];
|
|
20
7
|
title: string;
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -195,11 +195,10 @@ export function generateSchema(database, existingSchema) {
|
|
|
195
195
|
}
|
|
196
196
|
function generateSentinelSdkTypes() {
|
|
197
197
|
return [
|
|
198
|
-
"export
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
"
|
|
202
|
-
" | { type: 'external'; url: string };",
|
|
198
|
+
"export interface NotificationLink {",
|
|
199
|
+
" path?: string;",
|
|
200
|
+
" params?: Record<string, string>;",
|
|
201
|
+
"}",
|
|
203
202
|
"",
|
|
204
203
|
"export interface NotificationsCreateParams {",
|
|
205
204
|
" recipients: string[];",
|
|
@@ -230,6 +229,53 @@ function generateSentinelSdkTypes() {
|
|
|
230
229
|
"",
|
|
231
230
|
];
|
|
232
231
|
}
|
|
232
|
+
function buildLinkTableComments(schema) {
|
|
233
|
+
const tablesById = new Map();
|
|
234
|
+
for (const t of schema.tables)
|
|
235
|
+
tablesById.set(t.id, t);
|
|
236
|
+
const seen = new Set();
|
|
237
|
+
const entries = [];
|
|
238
|
+
for (const table of schema.tables) {
|
|
239
|
+
for (const field of table.fields) {
|
|
240
|
+
if (field.definition.type !== "linked_record")
|
|
241
|
+
continue;
|
|
242
|
+
const tpl = field.definition.template;
|
|
243
|
+
if (tpl.isInverse)
|
|
244
|
+
continue;
|
|
245
|
+
const targetId = tpl.tableId;
|
|
246
|
+
if (!targetId)
|
|
247
|
+
continue;
|
|
248
|
+
const target = tablesById.get(targetId);
|
|
249
|
+
if (!target)
|
|
250
|
+
continue;
|
|
251
|
+
const sourceSdk = toPascalCase(table.sdkName);
|
|
252
|
+
const targetSdk = toPascalCase(target.sdkName);
|
|
253
|
+
const [first, second] = [sourceSdk, targetSdk].sort();
|
|
254
|
+
const linkName = `${first}${second}`;
|
|
255
|
+
if (seen.has(linkName))
|
|
256
|
+
continue;
|
|
257
|
+
seen.add(linkName);
|
|
258
|
+
const isSelf = table.id === targetId;
|
|
259
|
+
const col1 = isSelf
|
|
260
|
+
? `source${first}Id`
|
|
261
|
+
: `${first.charAt(0).toLowerCase()}${first.slice(1)}Id`;
|
|
262
|
+
const col2 = isSelf
|
|
263
|
+
? `target${second}Id`
|
|
264
|
+
: `${second.charAt(0).toLowerCase()}${second.slice(1)}Id`;
|
|
265
|
+
entries.push({ name: linkName, cols: [col1, col2] });
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (entries.length === 0)
|
|
269
|
+
return [];
|
|
270
|
+
const lines = [
|
|
271
|
+
"//",
|
|
272
|
+
"// Link tables for zite.sql() JOINs (use these exact names):",
|
|
273
|
+
];
|
|
274
|
+
for (const e of entries) {
|
|
275
|
+
lines.push(`// "${e.name}" — columns: "${e.cols[0]}", "${e.cols[1]}"`);
|
|
276
|
+
}
|
|
277
|
+
return lines;
|
|
278
|
+
}
|
|
233
279
|
/**
|
|
234
280
|
* Generate .zite/db.ts purely from ZiteSchema.
|
|
235
281
|
* Pure function — no external data needed beyond what's in the schema file.
|
|
@@ -261,11 +307,10 @@ export function generateDbTs(schema) {
|
|
|
261
307
|
lines.push("// - Use SDK names for tables (PascalCase) and fields (camelCase)");
|
|
262
308
|
lines.push('// - ALWAYS double-quote every identifier: FROM "Orders", WHERE "status" = $1');
|
|
263
309
|
lines.push("// - Use params array for user input ($1, $2, ...): never interpolate into SQL");
|
|
264
|
-
lines.push('// - Link tables: alphabetical PascalCase concat (Items+Orders → "ItemsOrders")');
|
|
265
|
-
lines.push('// with id columns: "itemsId", "ordersId"');
|
|
266
310
|
lines.push("// - Soft-deleted rows are excluded automatically — no WHERE deleted_at IS NULL");
|
|
267
311
|
lines.push("// - SELECT only — use .create/.update/.delete for writes");
|
|
268
312
|
lines.push('// - Load the "zite:sql" skill for full SQL reference (formulas, lookups, etc.)');
|
|
313
|
+
lines.push(...buildLinkTableComments(schema));
|
|
269
314
|
lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createMetaClient } from 'zitejs/runtime';");
|
|
270
315
|
lines.push("");
|
|
271
316
|
for (const table of schema.tables) {
|