zitejs 0.9.49 → 0.9.51
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 +25 -15
- package/dist/cjs/sync/lib.js +26 -14
- package/dist/esm/dev/index.js +26 -16
- package/dist/esm/sync/lib.js +26 -14
- package/package.json +1 -1
package/dist/cjs/dev/index.js
CHANGED
|
@@ -55,26 +55,23 @@ function regenerateAppApiTs(appDir) {
|
|
|
55
55
|
}
|
|
56
56
|
function regenerateAppAirtableSdk(appDir) {
|
|
57
57
|
const lockPath = (0, path_1.join)('apps', appDir, 'zite.lock');
|
|
58
|
+
console.log(`[airtable-sdk] Checking ${lockPath} exists: ${(0, fs_2.existsSync)(lockPath)}`);
|
|
58
59
|
if (!(0, fs_2.existsSync)(lockPath))
|
|
59
60
|
return;
|
|
60
61
|
try {
|
|
61
62
|
const lockContent = JSON.parse((0, fs_2.readFileSync)(lockPath, 'utf-8'));
|
|
62
63
|
const integrations = lockContent.integrations ?? {};
|
|
64
|
+
console.log(`[airtable-sdk] Found ${Object.keys(integrations).length} integrations in lock:`, Object.keys(integrations));
|
|
63
65
|
for (const [integrationId, integration] of Object.entries(integrations)) {
|
|
64
66
|
const int = integration;
|
|
65
|
-
if (!int.idMappings?.tables)
|
|
67
|
+
if (!int.idMappings?.tables || !Array.isArray(int.idMappings.tables)) {
|
|
68
|
+
console.log(`[airtable-sdk] Integration ${integrationId}: skipping (no tables array)`);
|
|
66
69
|
continue;
|
|
70
|
+
}
|
|
71
|
+
console.log(`[airtable-sdk] Integration ${integrationId}: ${int.idMappings.tables.length} tables`);
|
|
67
72
|
const airtableLock = {
|
|
68
73
|
integrationId,
|
|
69
|
-
tables:
|
|
70
|
-
id: tableId,
|
|
71
|
-
sdkName,
|
|
72
|
-
fields: Object.entries(int.idMappings?.fields?.[sdkName] ?? {}).map(([fieldSdkName, fieldId]) => ({
|
|
73
|
-
id: fieldId,
|
|
74
|
-
sdkName: fieldSdkName,
|
|
75
|
-
type: 'singleLineText',
|
|
76
|
-
})),
|
|
77
|
-
})),
|
|
74
|
+
tables: int.idMappings.tables,
|
|
78
75
|
};
|
|
79
76
|
const content = (0, lib_js_1.generateAirtableTs)(airtableLock);
|
|
80
77
|
if (content) {
|
|
@@ -85,17 +82,30 @@ function regenerateAppAirtableSdk(appDir) {
|
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
|
-
catch {
|
|
89
|
-
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.error(`[airtable-sdk] Error processing lock for ${appDir}:`, err);
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
89
|
async function runGenerate() {
|
|
93
|
-
//
|
|
90
|
+
// Pure codegen from local files — no network calls.
|
|
91
|
+
// Reads zite.schema.json, zite.lock, zite.config.json, src/api/*.ts
|
|
92
|
+
// and generates all .zite/ files.
|
|
93
|
+
//
|
|
94
|
+
// The backend writes the schema/lock files to the sandbox before
|
|
95
|
+
// calling this. Use `zitejs sync` separately for local dev (fetches
|
|
96
|
+
// metadata from the backend API).
|
|
97
|
+
// 1. Generate root .zite/db.ts from zite.schema.json
|
|
94
98
|
try {
|
|
95
|
-
|
|
99
|
+
if ((0, fs_2.existsSync)('zite.schema.json')) {
|
|
100
|
+
const schema = JSON.parse((0, fs_2.readFileSync)('zite.schema.json', 'utf-8'));
|
|
101
|
+
const dbTs = (0, lib_js_1.generateDbTs)(schema);
|
|
102
|
+
(0, fs_2.mkdirSync)('.zite', { recursive: true });
|
|
103
|
+
(0, fs_2.writeFileSync)((0, path_1.join)('.zite', 'db.ts'), dbTs);
|
|
104
|
+
console.log('Wrote .zite/db.ts');
|
|
105
|
+
}
|
|
96
106
|
}
|
|
97
107
|
catch (err) {
|
|
98
|
-
console.warn('
|
|
108
|
+
console.warn('DB SDK generation failed:', err instanceof Error ? err.message : err);
|
|
99
109
|
}
|
|
100
110
|
// 2. Find all apps and regenerate their .zite/ files
|
|
101
111
|
const appDirs = findAppDirs();
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -106,9 +106,7 @@ function fieldJsdoc(schemaField, table) {
|
|
|
106
106
|
}
|
|
107
107
|
if (def.type === "datetime") {
|
|
108
108
|
const tpl = def.template;
|
|
109
|
-
const timeParts = [
|
|
110
|
-
"Date+time field (ISO 8601 timestamp)",
|
|
111
|
-
];
|
|
109
|
+
const timeParts = ["Date+time field (ISO 8601 timestamp)"];
|
|
112
110
|
if (tpl.dateFormat)
|
|
113
111
|
timeParts.push(`date: ${tpl.dateFormat}`);
|
|
114
112
|
if (tpl.timeFormat)
|
|
@@ -156,7 +154,8 @@ function fieldJsdoc(schemaField, table) {
|
|
|
156
154
|
}
|
|
157
155
|
if ((def.type === "single_select" || def.type === "multiple_select") &&
|
|
158
156
|
def.template?.options) {
|
|
159
|
-
const count = (def.template.options ?? [])
|
|
157
|
+
const count = (def.template.options ?? [])
|
|
158
|
+
.length;
|
|
160
159
|
if (count > MAX_SELECT_OPTIONS) {
|
|
161
160
|
parts.push(`${count - MAX_SELECT_OPTIONS} more options omitted`);
|
|
162
161
|
}
|
|
@@ -359,35 +358,39 @@ function generateAuthWrapperTs() {
|
|
|
359
358
|
].join("\n");
|
|
360
359
|
}
|
|
361
360
|
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
361
|
+
// Writable fields
|
|
362
362
|
singleLineText: "string",
|
|
363
363
|
multilineText: "string",
|
|
364
364
|
richText: "string",
|
|
365
365
|
email: "string",
|
|
366
366
|
url: "string",
|
|
367
367
|
phoneNumber: "string",
|
|
368
|
+
barcode: "string",
|
|
368
369
|
number: "number",
|
|
369
370
|
currency: "number",
|
|
370
371
|
percent: "number",
|
|
371
372
|
rating: "number",
|
|
372
373
|
duration: "number",
|
|
373
|
-
singleSelect: "string",
|
|
374
|
-
multipleSelects: "string[]",
|
|
375
374
|
checkbox: "boolean",
|
|
376
375
|
date: "string",
|
|
377
376
|
dateTime: "string",
|
|
378
|
-
|
|
377
|
+
singleSelect: "string",
|
|
378
|
+
multipleSelects: "string[]",
|
|
379
|
+
multipleAttachments: "Array<{ url: string; filename?: string }>",
|
|
379
380
|
multipleRecordLinks: "string | string[]",
|
|
381
|
+
singleCollaborator: "{ id: string; email: string; name?: string }",
|
|
382
|
+
multipleCollaborators: "Array<{ id: string; email: string; name?: string }>",
|
|
383
|
+
// Read-only fields
|
|
384
|
+
autoNumber: "number",
|
|
385
|
+
count: "number",
|
|
380
386
|
formula: "unknown",
|
|
381
387
|
rollup: "unknown",
|
|
382
|
-
|
|
383
|
-
count: "number",
|
|
384
|
-
autoNumber: "number",
|
|
385
|
-
barcode: "string",
|
|
386
|
-
button: "unknown",
|
|
388
|
+
multipleLookupValues: "unknown",
|
|
387
389
|
createdTime: "string",
|
|
388
390
|
lastModifiedTime: "string",
|
|
389
|
-
createdBy: "
|
|
390
|
-
lastModifiedBy: "
|
|
391
|
+
createdBy: "{ id: string; email: string; name?: string }",
|
|
392
|
+
lastModifiedBy: "{ id: string; email: string; name?: string }",
|
|
393
|
+
button: "unknown",
|
|
391
394
|
externalSyncSource: "unknown",
|
|
392
395
|
aiText: "string",
|
|
393
396
|
};
|
|
@@ -413,6 +416,15 @@ function generateAirtableTs(lock) {
|
|
|
413
416
|
"// Auto-generated by zitejs generate from zite.lock. Do not edit manually.",
|
|
414
417
|
"// Airtable SDK — uses createAirtableClient from zitejs/runtime.",
|
|
415
418
|
"// The airtable package is externalized (not bundled per-endpoint).",
|
|
419
|
+
"//",
|
|
420
|
+
"// Each exported table client has these methods:",
|
|
421
|
+
"// findAll(options?: { offset?: string; limit?: number; filters?: unknown })",
|
|
422
|
+
"// => Promise<{ records: T[]; offset: string | undefined; hasMore: boolean }>",
|
|
423
|
+
"// findOne(params: { id?: string; filters?: unknown }) => Promise<T | undefined>",
|
|
424
|
+
"// create(data: { record: Partial<T> }) => Promise<T>",
|
|
425
|
+
"// bulkCreate(records: Partial<T>[]) => Promise<T[]>",
|
|
426
|
+
"// update(id: string, data: { record: Partial<T> }) => Promise<T>",
|
|
427
|
+
"// delete(id: string) => Promise<{ deleted: true }>",
|
|
416
428
|
"",
|
|
417
429
|
"import { createAirtableClient } from 'zitejs/runtime';",
|
|
418
430
|
"",
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { watch } from 'fs';
|
|
|
2
2
|
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import { runSync } from '../sync/index.js';
|
|
5
|
-
import { generateApiTs, generateUserTs, generateAuthWrapperTs, generateBackendWrapperTs, generateAirtableTs, } from '../sync/lib.js';
|
|
5
|
+
import { generateDbTs, generateApiTs, generateUserTs, generateAuthWrapperTs, generateBackendWrapperTs, generateAirtableTs, } from '../sync/lib.js';
|
|
6
6
|
const debounceTimers = new Map();
|
|
7
7
|
function debounce(key, fn, ms) {
|
|
8
8
|
const existing = debounceTimers.get(key);
|
|
@@ -51,26 +51,23 @@ function regenerateAppApiTs(appDir) {
|
|
|
51
51
|
}
|
|
52
52
|
function regenerateAppAirtableSdk(appDir) {
|
|
53
53
|
const lockPath = join('apps', appDir, 'zite.lock');
|
|
54
|
+
console.log(`[airtable-sdk] Checking ${lockPath} exists: ${existsSync(lockPath)}`);
|
|
54
55
|
if (!existsSync(lockPath))
|
|
55
56
|
return;
|
|
56
57
|
try {
|
|
57
58
|
const lockContent = JSON.parse(readFileSync(lockPath, 'utf-8'));
|
|
58
59
|
const integrations = lockContent.integrations ?? {};
|
|
60
|
+
console.log(`[airtable-sdk] Found ${Object.keys(integrations).length} integrations in lock:`, Object.keys(integrations));
|
|
59
61
|
for (const [integrationId, integration] of Object.entries(integrations)) {
|
|
60
62
|
const int = integration;
|
|
61
|
-
if (!int.idMappings?.tables)
|
|
63
|
+
if (!int.idMappings?.tables || !Array.isArray(int.idMappings.tables)) {
|
|
64
|
+
console.log(`[airtable-sdk] Integration ${integrationId}: skipping (no tables array)`);
|
|
62
65
|
continue;
|
|
66
|
+
}
|
|
67
|
+
console.log(`[airtable-sdk] Integration ${integrationId}: ${int.idMappings.tables.length} tables`);
|
|
63
68
|
const airtableLock = {
|
|
64
69
|
integrationId,
|
|
65
|
-
tables:
|
|
66
|
-
id: tableId,
|
|
67
|
-
sdkName,
|
|
68
|
-
fields: Object.entries(int.idMappings?.fields?.[sdkName] ?? {}).map(([fieldSdkName, fieldId]) => ({
|
|
69
|
-
id: fieldId,
|
|
70
|
-
sdkName: fieldSdkName,
|
|
71
|
-
type: 'singleLineText',
|
|
72
|
-
})),
|
|
73
|
-
})),
|
|
70
|
+
tables: int.idMappings.tables,
|
|
74
71
|
};
|
|
75
72
|
const content = generateAirtableTs(airtableLock);
|
|
76
73
|
if (content) {
|
|
@@ -81,17 +78,30 @@ function regenerateAppAirtableSdk(appDir) {
|
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
catch {
|
|
85
|
-
|
|
81
|
+
catch (err) {
|
|
82
|
+
console.error(`[airtable-sdk] Error processing lock for ${appDir}:`, err);
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
export async function runGenerate() {
|
|
89
|
-
//
|
|
86
|
+
// Pure codegen from local files — no network calls.
|
|
87
|
+
// Reads zite.schema.json, zite.lock, zite.config.json, src/api/*.ts
|
|
88
|
+
// and generates all .zite/ files.
|
|
89
|
+
//
|
|
90
|
+
// The backend writes the schema/lock files to the sandbox before
|
|
91
|
+
// calling this. Use `zitejs sync` separately for local dev (fetches
|
|
92
|
+
// metadata from the backend API).
|
|
93
|
+
// 1. Generate root .zite/db.ts from zite.schema.json
|
|
90
94
|
try {
|
|
91
|
-
|
|
95
|
+
if (existsSync('zite.schema.json')) {
|
|
96
|
+
const schema = JSON.parse(readFileSync('zite.schema.json', 'utf-8'));
|
|
97
|
+
const dbTs = generateDbTs(schema);
|
|
98
|
+
mkdirSync('.zite', { recursive: true });
|
|
99
|
+
writeFileSync(join('.zite', 'db.ts'), dbTs);
|
|
100
|
+
console.log('Wrote .zite/db.ts');
|
|
101
|
+
}
|
|
92
102
|
}
|
|
93
103
|
catch (err) {
|
|
94
|
-
console.warn('
|
|
104
|
+
console.warn('DB SDK generation failed:', err instanceof Error ? err.message : err);
|
|
95
105
|
}
|
|
96
106
|
// 2. Find all apps and regenerate their .zite/ files
|
|
97
107
|
const appDirs = findAppDirs();
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -95,9 +95,7 @@ function fieldJsdoc(schemaField, table) {
|
|
|
95
95
|
}
|
|
96
96
|
if (def.type === "datetime") {
|
|
97
97
|
const tpl = def.template;
|
|
98
|
-
const timeParts = [
|
|
99
|
-
"Date+time field (ISO 8601 timestamp)",
|
|
100
|
-
];
|
|
98
|
+
const timeParts = ["Date+time field (ISO 8601 timestamp)"];
|
|
101
99
|
if (tpl.dateFormat)
|
|
102
100
|
timeParts.push(`date: ${tpl.dateFormat}`);
|
|
103
101
|
if (tpl.timeFormat)
|
|
@@ -145,7 +143,8 @@ function fieldJsdoc(schemaField, table) {
|
|
|
145
143
|
}
|
|
146
144
|
if ((def.type === "single_select" || def.type === "multiple_select") &&
|
|
147
145
|
def.template?.options) {
|
|
148
|
-
const count = (def.template.options ?? [])
|
|
146
|
+
const count = (def.template.options ?? [])
|
|
147
|
+
.length;
|
|
149
148
|
if (count > MAX_SELECT_OPTIONS) {
|
|
150
149
|
parts.push(`${count - MAX_SELECT_OPTIONS} more options omitted`);
|
|
151
150
|
}
|
|
@@ -348,35 +347,39 @@ export function generateAuthWrapperTs() {
|
|
|
348
347
|
].join("\n");
|
|
349
348
|
}
|
|
350
349
|
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
350
|
+
// Writable fields
|
|
351
351
|
singleLineText: "string",
|
|
352
352
|
multilineText: "string",
|
|
353
353
|
richText: "string",
|
|
354
354
|
email: "string",
|
|
355
355
|
url: "string",
|
|
356
356
|
phoneNumber: "string",
|
|
357
|
+
barcode: "string",
|
|
357
358
|
number: "number",
|
|
358
359
|
currency: "number",
|
|
359
360
|
percent: "number",
|
|
360
361
|
rating: "number",
|
|
361
362
|
duration: "number",
|
|
362
|
-
singleSelect: "string",
|
|
363
|
-
multipleSelects: "string[]",
|
|
364
363
|
checkbox: "boolean",
|
|
365
364
|
date: "string",
|
|
366
365
|
dateTime: "string",
|
|
367
|
-
|
|
366
|
+
singleSelect: "string",
|
|
367
|
+
multipleSelects: "string[]",
|
|
368
|
+
multipleAttachments: "Array<{ url: string; filename?: string }>",
|
|
368
369
|
multipleRecordLinks: "string | string[]",
|
|
370
|
+
singleCollaborator: "{ id: string; email: string; name?: string }",
|
|
371
|
+
multipleCollaborators: "Array<{ id: string; email: string; name?: string }>",
|
|
372
|
+
// Read-only fields
|
|
373
|
+
autoNumber: "number",
|
|
374
|
+
count: "number",
|
|
369
375
|
formula: "unknown",
|
|
370
376
|
rollup: "unknown",
|
|
371
|
-
|
|
372
|
-
count: "number",
|
|
373
|
-
autoNumber: "number",
|
|
374
|
-
barcode: "string",
|
|
375
|
-
button: "unknown",
|
|
377
|
+
multipleLookupValues: "unknown",
|
|
376
378
|
createdTime: "string",
|
|
377
379
|
lastModifiedTime: "string",
|
|
378
|
-
createdBy: "
|
|
379
|
-
lastModifiedBy: "
|
|
380
|
+
createdBy: "{ id: string; email: string; name?: string }",
|
|
381
|
+
lastModifiedBy: "{ id: string; email: string; name?: string }",
|
|
382
|
+
button: "unknown",
|
|
380
383
|
externalSyncSource: "unknown",
|
|
381
384
|
aiText: "string",
|
|
382
385
|
};
|
|
@@ -402,6 +405,15 @@ export function generateAirtableTs(lock) {
|
|
|
402
405
|
"// Auto-generated by zitejs generate from zite.lock. Do not edit manually.",
|
|
403
406
|
"// Airtable SDK — uses createAirtableClient from zitejs/runtime.",
|
|
404
407
|
"// The airtable package is externalized (not bundled per-endpoint).",
|
|
408
|
+
"//",
|
|
409
|
+
"// Each exported table client has these methods:",
|
|
410
|
+
"// findAll(options?: { offset?: string; limit?: number; filters?: unknown })",
|
|
411
|
+
"// => Promise<{ records: T[]; offset: string | undefined; hasMore: boolean }>",
|
|
412
|
+
"// findOne(params: { id?: string; filters?: unknown }) => Promise<T | undefined>",
|
|
413
|
+
"// create(data: { record: Partial<T> }) => Promise<T>",
|
|
414
|
+
"// bulkCreate(records: Partial<T>[]) => Promise<T[]>",
|
|
415
|
+
"// update(id: string, data: { record: Partial<T> }) => Promise<T>",
|
|
416
|
+
"// delete(id: string) => Promise<{ deleted: true }>",
|
|
405
417
|
"",
|
|
406
418
|
"import { createAirtableClient } from 'zitejs/runtime';",
|
|
407
419
|
"",
|