zitejs 0.9.49 → 0.9.50
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 +14 -10
- package/dist/esm/dev/index.js +26 -16
- package/dist/esm/sync/lib.js +14 -10
- 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
|
@@ -359,35 +359,39 @@ function generateAuthWrapperTs() {
|
|
|
359
359
|
].join("\n");
|
|
360
360
|
}
|
|
361
361
|
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
362
|
+
// Writable fields
|
|
362
363
|
singleLineText: "string",
|
|
363
364
|
multilineText: "string",
|
|
364
365
|
richText: "string",
|
|
365
366
|
email: "string",
|
|
366
367
|
url: "string",
|
|
367
368
|
phoneNumber: "string",
|
|
369
|
+
barcode: "string",
|
|
368
370
|
number: "number",
|
|
369
371
|
currency: "number",
|
|
370
372
|
percent: "number",
|
|
371
373
|
rating: "number",
|
|
372
374
|
duration: "number",
|
|
373
|
-
singleSelect: "string",
|
|
374
|
-
multipleSelects: "string[]",
|
|
375
375
|
checkbox: "boolean",
|
|
376
376
|
date: "string",
|
|
377
377
|
dateTime: "string",
|
|
378
|
-
|
|
378
|
+
singleSelect: "string",
|
|
379
|
+
multipleSelects: "string[]",
|
|
380
|
+
multipleAttachments: "Array<{ url: string; filename?: string }>",
|
|
379
381
|
multipleRecordLinks: "string | string[]",
|
|
382
|
+
singleCollaborator: "{ id: string; email: string; name?: string }",
|
|
383
|
+
multipleCollaborators: "Array<{ id: string; email: string; name?: string }>",
|
|
384
|
+
// Read-only fields
|
|
385
|
+
autoNumber: "number",
|
|
386
|
+
count: "number",
|
|
380
387
|
formula: "unknown",
|
|
381
388
|
rollup: "unknown",
|
|
382
|
-
|
|
383
|
-
count: "number",
|
|
384
|
-
autoNumber: "number",
|
|
385
|
-
barcode: "string",
|
|
386
|
-
button: "unknown",
|
|
389
|
+
multipleLookupValues: "unknown",
|
|
387
390
|
createdTime: "string",
|
|
388
391
|
lastModifiedTime: "string",
|
|
389
|
-
createdBy: "
|
|
390
|
-
lastModifiedBy: "
|
|
392
|
+
createdBy: "{ id: string; email: string; name?: string }",
|
|
393
|
+
lastModifiedBy: "{ id: string; email: string; name?: string }",
|
|
394
|
+
button: "unknown",
|
|
391
395
|
externalSyncSource: "unknown",
|
|
392
396
|
aiText: "string",
|
|
393
397
|
};
|
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
|
@@ -348,35 +348,39 @@ export function generateAuthWrapperTs() {
|
|
|
348
348
|
].join("\n");
|
|
349
349
|
}
|
|
350
350
|
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
351
|
+
// Writable fields
|
|
351
352
|
singleLineText: "string",
|
|
352
353
|
multilineText: "string",
|
|
353
354
|
richText: "string",
|
|
354
355
|
email: "string",
|
|
355
356
|
url: "string",
|
|
356
357
|
phoneNumber: "string",
|
|
358
|
+
barcode: "string",
|
|
357
359
|
number: "number",
|
|
358
360
|
currency: "number",
|
|
359
361
|
percent: "number",
|
|
360
362
|
rating: "number",
|
|
361
363
|
duration: "number",
|
|
362
|
-
singleSelect: "string",
|
|
363
|
-
multipleSelects: "string[]",
|
|
364
364
|
checkbox: "boolean",
|
|
365
365
|
date: "string",
|
|
366
366
|
dateTime: "string",
|
|
367
|
-
|
|
367
|
+
singleSelect: "string",
|
|
368
|
+
multipleSelects: "string[]",
|
|
369
|
+
multipleAttachments: "Array<{ url: string; filename?: string }>",
|
|
368
370
|
multipleRecordLinks: "string | string[]",
|
|
371
|
+
singleCollaborator: "{ id: string; email: string; name?: string }",
|
|
372
|
+
multipleCollaborators: "Array<{ id: string; email: string; name?: string }>",
|
|
373
|
+
// Read-only fields
|
|
374
|
+
autoNumber: "number",
|
|
375
|
+
count: "number",
|
|
369
376
|
formula: "unknown",
|
|
370
377
|
rollup: "unknown",
|
|
371
|
-
|
|
372
|
-
count: "number",
|
|
373
|
-
autoNumber: "number",
|
|
374
|
-
barcode: "string",
|
|
375
|
-
button: "unknown",
|
|
378
|
+
multipleLookupValues: "unknown",
|
|
376
379
|
createdTime: "string",
|
|
377
380
|
lastModifiedTime: "string",
|
|
378
|
-
createdBy: "
|
|
379
|
-
lastModifiedBy: "
|
|
381
|
+
createdBy: "{ id: string; email: string; name?: string }",
|
|
382
|
+
lastModifiedBy: "{ id: string; email: string; name?: string }",
|
|
383
|
+
button: "unknown",
|
|
380
384
|
externalSyncSource: "unknown",
|
|
381
385
|
aiText: "string",
|
|
382
386
|
};
|