zitejs 0.9.42 → 0.9.44
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/auth/config.d.ts +4 -0
- package/dist/cjs/auth/constants.d.ts +5 -0
- package/dist/cjs/auth/index.d.ts +18 -0
- package/dist/cjs/backend/index.d.ts +36 -0
- package/dist/cjs/bundle/index.d.ts +1 -0
- package/dist/cjs/bundle/index.js +9 -0
- package/dist/cjs/caller/index.d.ts +7 -0
- package/dist/cjs/check/index.d.ts +1 -0
- package/dist/cjs/cli.d.ts +2 -0
- package/dist/cjs/client/index.d.ts +1273 -0
- package/dist/cjs/dev/index.d.ts +2 -0
- package/dist/cjs/dev/index.js +37 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/internal/env.d.ts +1 -0
- package/dist/cjs/pdf/index.d.ts +9 -0
- package/dist/cjs/runtime/index.d.ts +69 -0
- package/dist/cjs/runtime/index.js +30 -0
- package/dist/cjs/schedules/index.d.ts +16 -0
- package/dist/cjs/sync/index.d.ts +3 -0
- package/dist/cjs/sync/lib.d.ts +55 -0
- package/dist/cjs/sync/lib.js +81 -0
- package/dist/cjs/types/fields.d.ts +552 -0
- package/dist/cjs/types/index.d.ts +2 -0
- package/dist/cjs/types/tables.d.ts +1158 -0
- package/dist/cjs/upload/index.d.ts +6 -0
- package/dist/esm/bundle/index.js +9 -0
- package/dist/esm/dev/index.js +38 -1
- package/dist/esm/runtime/index.d.ts +26 -0
- package/dist/esm/runtime/index.js +29 -0
- package/dist/esm/sync/lib.d.ts +16 -0
- package/dist/esm/sync/lib.js +80 -0
- package/package.json +1 -1
package/dist/cjs/dev/index.js
CHANGED
|
@@ -53,6 +53,42 @@ function regenerateAppApiTs(appDir) {
|
|
|
53
53
|
console.log(`Updated apps/${appDir}/.zite/api.ts`);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
function regenerateAppAirtableSdk(appDir) {
|
|
57
|
+
const lockPath = (0, path_1.join)('apps', appDir, 'zite.lock');
|
|
58
|
+
if (!(0, fs_2.existsSync)(lockPath))
|
|
59
|
+
return;
|
|
60
|
+
try {
|
|
61
|
+
const lockContent = JSON.parse((0, fs_2.readFileSync)(lockPath, 'utf-8'));
|
|
62
|
+
const integrations = lockContent.integrations ?? {};
|
|
63
|
+
for (const [integrationId, integration] of Object.entries(integrations)) {
|
|
64
|
+
const int = integration;
|
|
65
|
+
if (!int.idMappings?.tables)
|
|
66
|
+
continue;
|
|
67
|
+
const airtableLock = {
|
|
68
|
+
integrationId,
|
|
69
|
+
tables: Object.entries(int.idMappings.tables).map(([sdkName, tableId]) => ({
|
|
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
|
+
})),
|
|
78
|
+
};
|
|
79
|
+
const content = (0, lib_js_1.generateAirtableTs)(airtableLock);
|
|
80
|
+
if (content) {
|
|
81
|
+
const outDir = (0, path_1.join)('apps', appDir, '.zite', 'integrations');
|
|
82
|
+
(0, fs_2.mkdirSync)(outDir, { recursive: true });
|
|
83
|
+
(0, fs_2.writeFileSync)((0, path_1.join)(outDir, 'airtable.ts'), content);
|
|
84
|
+
console.log(`Updated apps/${appDir}/.zite/integrations/airtable.ts`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Lock file invalid or missing — skip
|
|
90
|
+
}
|
|
91
|
+
}
|
|
56
92
|
async function runGenerate() {
|
|
57
93
|
// 1. Run sync (generates root .zite/db.ts)
|
|
58
94
|
try {
|
|
@@ -66,6 +102,7 @@ async function runGenerate() {
|
|
|
66
102
|
for (const app of appDirs) {
|
|
67
103
|
regenerateAppApiTs(app);
|
|
68
104
|
regenerateAppTypedWrappers(app);
|
|
105
|
+
regenerateAppAirtableSdk(app);
|
|
69
106
|
}
|
|
70
107
|
console.log('Done!');
|
|
71
108
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { Zite } from "./client/index.js";
|
|
2
|
+
export type { Record, RecordListOutput, RecordListOptions, FieldCreateInput, FieldUpdateInput, TableCreateInput, TableUpdateInput, DatabaseCreateInput, DatabaseListOutput, } from "./client/index.js";
|
|
3
|
+
export * from "./types/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getEnv(key: string, viteKey?: string): string | undefined;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface TableClient<T> {
|
|
2
|
+
findAll(options?: {
|
|
3
|
+
limit?: number;
|
|
4
|
+
offset?: number;
|
|
5
|
+
sort?: unknown[];
|
|
6
|
+
filter?: unknown;
|
|
7
|
+
filters?: unknown;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
records: T[];
|
|
10
|
+
total: number;
|
|
11
|
+
hasMore: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
findOne(recordId: string | {
|
|
14
|
+
filters?: unknown;
|
|
15
|
+
filter?: unknown;
|
|
16
|
+
}): Promise<T>;
|
|
17
|
+
create(data: {
|
|
18
|
+
record: Partial<T>;
|
|
19
|
+
}): Promise<T>;
|
|
20
|
+
update(id: string, data: {
|
|
21
|
+
record: Partial<T>;
|
|
22
|
+
}): Promise<T>;
|
|
23
|
+
delete(id: string): Promise<{
|
|
24
|
+
deleted: true;
|
|
25
|
+
}>;
|
|
26
|
+
bulkCreate(records: Partial<T>[]): Promise<T[]>;
|
|
27
|
+
}
|
|
28
|
+
export declare function createTableClient<T>(className: string): TableClient<T>;
|
|
29
|
+
export interface SqlResult {
|
|
30
|
+
rows: Record<string, unknown>[];
|
|
31
|
+
columns: Array<{
|
|
32
|
+
name: string;
|
|
33
|
+
originalName: string;
|
|
34
|
+
}>;
|
|
35
|
+
rowCount: number;
|
|
36
|
+
truncated: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function createSqlClient(): (params: {
|
|
39
|
+
query: string;
|
|
40
|
+
params?: unknown[];
|
|
41
|
+
}) => Promise<SqlResult>;
|
|
42
|
+
export interface AirtableTableClient<T> {
|
|
43
|
+
findAll(options?: {
|
|
44
|
+
offset?: string;
|
|
45
|
+
limit?: number;
|
|
46
|
+
filters?: unknown;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
records: T[];
|
|
49
|
+
offset: string | undefined;
|
|
50
|
+
hasMore: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
findOne(params: {
|
|
53
|
+
id?: string;
|
|
54
|
+
filters?: unknown;
|
|
55
|
+
}): Promise<T | undefined>;
|
|
56
|
+
create(data: {
|
|
57
|
+
record: Partial<T>;
|
|
58
|
+
}): Promise<T>;
|
|
59
|
+
bulkCreate(records: Partial<T>[]): Promise<T[]>;
|
|
60
|
+
update(id: string, data: {
|
|
61
|
+
record: Partial<T>;
|
|
62
|
+
}): Promise<T>;
|
|
63
|
+
delete(id: string): Promise<{
|
|
64
|
+
deleted: true;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
export declare function createAirtableClient<T>(integrationId: string, className: string, implicitParams: Record<string, unknown>): AirtableTableClient<T>;
|
|
68
|
+
export { createCaller } from "../caller/index.js";
|
|
69
|
+
export type { EndpointConfig } from "../caller/index.js";
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createCaller = void 0;
|
|
4
4
|
exports.createTableClient = createTableClient;
|
|
5
5
|
exports.createSqlClient = createSqlClient;
|
|
6
|
+
exports.createAirtableClient = createAirtableClient;
|
|
6
7
|
function getSdkCall() {
|
|
7
8
|
const fn = globalThis.__wrapSdkCall;
|
|
8
9
|
if (!fn) {
|
|
@@ -76,5 +77,34 @@ function createSqlClient() {
|
|
|
76
77
|
...params,
|
|
77
78
|
});
|
|
78
79
|
}
|
|
80
|
+
function createAirtableClient(integrationId, className, implicitParams) {
|
|
81
|
+
return {
|
|
82
|
+
findAll: (options) => getSdkCall()(integrationId, className, "findAll", {
|
|
83
|
+
...implicitParams,
|
|
84
|
+
...options,
|
|
85
|
+
}),
|
|
86
|
+
findOne: (params) => getSdkCall()(integrationId, className, "findOne", {
|
|
87
|
+
...implicitParams,
|
|
88
|
+
...params,
|
|
89
|
+
}),
|
|
90
|
+
create: (data) => getSdkCall()(integrationId, className, "create", {
|
|
91
|
+
...implicitParams,
|
|
92
|
+
...data,
|
|
93
|
+
}),
|
|
94
|
+
bulkCreate: (records) => getSdkCall()(integrationId, className, "bulkCreate", {
|
|
95
|
+
...implicitParams,
|
|
96
|
+
records,
|
|
97
|
+
}),
|
|
98
|
+
update: (id, data) => getSdkCall()(integrationId, className, "update", {
|
|
99
|
+
...implicitParams,
|
|
100
|
+
id,
|
|
101
|
+
...data,
|
|
102
|
+
}),
|
|
103
|
+
delete: (id) => getSdkCall()(integrationId, className, "delete", {
|
|
104
|
+
...implicitParams,
|
|
105
|
+
id,
|
|
106
|
+
}),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
79
109
|
var index_js_1 = require("../caller/index.js");
|
|
80
110
|
Object.defineProperty(exports, "createCaller", { enumerable: true, get: function () { return index_js_1.createCaller; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class ZiteSchedule {
|
|
2
|
+
static create(config: {
|
|
3
|
+
name: string;
|
|
4
|
+
cron: string;
|
|
5
|
+
endpoint: string;
|
|
6
|
+
input?: Record<string, unknown>;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
id: string;
|
|
9
|
+
}>;
|
|
10
|
+
static delete(id: string): Promise<void>;
|
|
11
|
+
static list(): Promise<Array<{
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
cron: string;
|
|
15
|
+
}>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PublicFieldDefinition } from "../types/fields.js";
|
|
2
|
+
import type { Database } from "../types/tables.js";
|
|
3
|
+
export type ZiteSchemaField = {
|
|
4
|
+
id: string;
|
|
5
|
+
sdkName: string;
|
|
6
|
+
definition: PublicFieldDefinition;
|
|
7
|
+
};
|
|
8
|
+
export type ZiteSchemaTable = {
|
|
9
|
+
id: string;
|
|
10
|
+
sdkName: string;
|
|
11
|
+
primaryFieldId?: string;
|
|
12
|
+
fields: ZiteSchemaField[];
|
|
13
|
+
};
|
|
14
|
+
export type ZiteSchema = {
|
|
15
|
+
tables: ZiteSchemaTable[];
|
|
16
|
+
};
|
|
17
|
+
export declare function toPascalCase(name: string): string;
|
|
18
|
+
export declare function toCamelCase(name: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Build a ZiteSchema from a Database API response.
|
|
21
|
+
*
|
|
22
|
+
* If `existingSchema` is provided, locked SDK names are preserved for
|
|
23
|
+
* tables/fields that already exist (matched by ID). New tables/fields
|
|
24
|
+
* get fresh camelCase SDK names. This is how `zitejs sync` preserves
|
|
25
|
+
* name stability across schema changes.
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateSchema(database: Database, existingSchema?: ZiteSchema): ZiteSchema;
|
|
28
|
+
/**
|
|
29
|
+
* Generate .zite/db.ts purely from ZiteSchema.
|
|
30
|
+
* Pure function — no external data needed beyond what's in the schema file.
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateDbTs(schema: ZiteSchema): string;
|
|
33
|
+
export declare function generateApiTs(endpointFiles: string[]): string | null;
|
|
34
|
+
export declare function generateUserTs(usersTableFields?: Array<{
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
}>): string;
|
|
38
|
+
export declare function generateAuthWrapperTs(): string;
|
|
39
|
+
export type AirtableLockField = {
|
|
40
|
+
id: string;
|
|
41
|
+
sdkName: string;
|
|
42
|
+
type: string;
|
|
43
|
+
options?: string[];
|
|
44
|
+
};
|
|
45
|
+
export type AirtableLockTable = {
|
|
46
|
+
id: string;
|
|
47
|
+
sdkName: string;
|
|
48
|
+
fields: AirtableLockField[];
|
|
49
|
+
};
|
|
50
|
+
export type AirtableLock = {
|
|
51
|
+
integrationId: string;
|
|
52
|
+
tables: AirtableLockTable[];
|
|
53
|
+
};
|
|
54
|
+
export declare function generateAirtableTs(lock: AirtableLock): string | null;
|
|
55
|
+
export declare function generateBackendWrapperTs(): string;
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.generateDbTs = generateDbTs;
|
|
|
7
7
|
exports.generateApiTs = generateApiTs;
|
|
8
8
|
exports.generateUserTs = generateUserTs;
|
|
9
9
|
exports.generateAuthWrapperTs = generateAuthWrapperTs;
|
|
10
|
+
exports.generateAirtableTs = generateAirtableTs;
|
|
10
11
|
exports.generateBackendWrapperTs = generateBackendWrapperTs;
|
|
11
12
|
const FIELD_TYPE_MAP = {
|
|
12
13
|
single_line_text: "string",
|
|
@@ -357,6 +358,86 @@ function generateAuthWrapperTs() {
|
|
|
357
358
|
"",
|
|
358
359
|
].join("\n");
|
|
359
360
|
}
|
|
361
|
+
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
362
|
+
singleLineText: "string",
|
|
363
|
+
multilineText: "string",
|
|
364
|
+
richText: "string",
|
|
365
|
+
email: "string",
|
|
366
|
+
url: "string",
|
|
367
|
+
phoneNumber: "string",
|
|
368
|
+
number: "number",
|
|
369
|
+
currency: "number",
|
|
370
|
+
percent: "number",
|
|
371
|
+
rating: "number",
|
|
372
|
+
duration: "number",
|
|
373
|
+
singleSelect: "string",
|
|
374
|
+
multipleSelects: "string[]",
|
|
375
|
+
checkbox: "boolean",
|
|
376
|
+
date: "string",
|
|
377
|
+
dateTime: "string",
|
|
378
|
+
attachment: "Array<{ url: string; filename?: string }>",
|
|
379
|
+
multipleRecordLinks: "string | string[]",
|
|
380
|
+
formula: "unknown",
|
|
381
|
+
rollup: "unknown",
|
|
382
|
+
lookup: "unknown",
|
|
383
|
+
count: "number",
|
|
384
|
+
autoNumber: "number",
|
|
385
|
+
barcode: "string",
|
|
386
|
+
button: "unknown",
|
|
387
|
+
createdTime: "string",
|
|
388
|
+
lastModifiedTime: "string",
|
|
389
|
+
createdBy: "unknown",
|
|
390
|
+
lastModifiedBy: "unknown",
|
|
391
|
+
externalSyncSource: "unknown",
|
|
392
|
+
aiText: "string",
|
|
393
|
+
};
|
|
394
|
+
function airtableTsType(field) {
|
|
395
|
+
if ((field.type === "singleSelect" || field.type === "multipleSelects") &&
|
|
396
|
+
field.options &&
|
|
397
|
+
field.options.length > 0) {
|
|
398
|
+
const literals = field.options
|
|
399
|
+
.slice(0, MAX_SELECT_OPTIONS)
|
|
400
|
+
.map((o) => `"${o.replace(/"/g, '\\"')}"`)
|
|
401
|
+
.join(" | ");
|
|
402
|
+
const union = `${literals} | string`;
|
|
403
|
+
if (field.type === "multipleSelects")
|
|
404
|
+
return `(${union})[]`;
|
|
405
|
+
return union;
|
|
406
|
+
}
|
|
407
|
+
return AIRTABLE_FIELD_TYPE_MAP[field.type] ?? "unknown";
|
|
408
|
+
}
|
|
409
|
+
function generateAirtableTs(lock) {
|
|
410
|
+
if (lock.tables.length === 0)
|
|
411
|
+
return null;
|
|
412
|
+
const lines = [
|
|
413
|
+
"// Auto-generated by zitejs generate from zite.lock. Do not edit manually.",
|
|
414
|
+
"// Airtable SDK — uses createAirtableClient from zitejs/runtime.",
|
|
415
|
+
"// The airtable package is externalized (not bundled per-endpoint).",
|
|
416
|
+
"",
|
|
417
|
+
"import { createAirtableClient } from 'zitejs/runtime';",
|
|
418
|
+
"",
|
|
419
|
+
];
|
|
420
|
+
for (const table of lock.tables) {
|
|
421
|
+
const recordType = `${table.sdkName}RecordType`;
|
|
422
|
+
lines.push(`export type ${recordType} = {`);
|
|
423
|
+
lines.push(" id: string;");
|
|
424
|
+
for (const field of table.fields) {
|
|
425
|
+
if (field.sdkName === "id")
|
|
426
|
+
continue;
|
|
427
|
+
const tsType = airtableTsType(field);
|
|
428
|
+
lines.push(` ${field.sdkName}: ${tsType};`);
|
|
429
|
+
}
|
|
430
|
+
lines.push("};");
|
|
431
|
+
lines.push("");
|
|
432
|
+
lines.push(`export const ${table.sdkName} = createAirtableClient<${recordType}>(`);
|
|
433
|
+
lines.push(` '${lock.integrationId}',`);
|
|
434
|
+
lines.push(` '${table.sdkName}',`);
|
|
435
|
+
lines.push(` { tableId: '${table.id}' },`);
|
|
436
|
+
lines.push(`);`);
|
|
437
|
+
lines.push("");
|
|
438
|
+
}
|
|
439
|
+
return lines.join("\n");
|
|
440
|
+
}
|
|
360
441
|
function generateBackendWrapperTs() {
|
|
361
442
|
return [
|
|
362
443
|
"// Auto-generated type-narrowing wrapper. Do not edit manually.",
|