zitejs 0.9.88 → 0.9.89
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/README.md +14 -1
- package/dist/cjs/runtime/index.d.ts +29 -13
- package/dist/cjs/runtime/index.js +14 -7
- package/dist/cjs/sync/lib.js +20 -12
- package/dist/esm/cli.js +0 -0
- package/dist/esm/runtime/index.d.ts +29 -13
- package/dist/esm/runtime/index.js +13 -6
- package/dist/esm/sync/lib.js +20 -12
- package/package.json +1 -9
- package/dist/cjs/api/index.js +0 -5
- package/dist/cjs/db/index.js +0 -5
- package/dist/esm/api/index.d.ts +0 -2
- package/dist/esm/api/index.js +0 -1
- package/dist/esm/db/index.d.ts +0 -2
- package/dist/esm/db/index.js +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,20 @@ The Zite framework package. Provides typed access to your Zite Database, API end
|
|
|
7
7
|
```ts
|
|
8
8
|
// Database client (generated per-project by `zite sync`)
|
|
9
9
|
import { zite } from 'zitejs/db';
|
|
10
|
-
const
|
|
10
|
+
const contacts = await zite.contacts.findAll();
|
|
11
|
+
|
|
12
|
+
// Query and update Zite auth users from backend endpoints
|
|
13
|
+
const { records: users } = await zite.auth.findAllUsers({
|
|
14
|
+
filters: { email: 'person@example.com' },
|
|
15
|
+
});
|
|
16
|
+
await zite.auth.updateUserProfile(users[0].id, {
|
|
17
|
+
firstName: 'New name',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Auth users can also be queried with read-only SQL
|
|
21
|
+
const result = await zite.sql({
|
|
22
|
+
query: 'SELECT "id", "email" FROM "ziteUsers"',
|
|
23
|
+
});
|
|
11
24
|
|
|
12
25
|
// Define API endpoints
|
|
13
26
|
import { createEndpoint, ZiteError } from 'zitejs/api';
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { NotificationsCreateParams, NotificationsCreateResult } from "../notifications/index.js";
|
|
2
|
-
|
|
2
|
+
export interface TableFindAllOptions {
|
|
3
|
+
limit?: number;
|
|
4
|
+
offset?: number;
|
|
5
|
+
sort?: unknown[];
|
|
6
|
+
filter?: unknown;
|
|
7
|
+
filters?: unknown;
|
|
8
|
+
fields?: string[];
|
|
9
|
+
}
|
|
3
10
|
export interface BulkCreateResult<T> {
|
|
4
11
|
success: boolean;
|
|
5
12
|
records: T[];
|
|
@@ -12,14 +19,7 @@ export interface DeleteResult {
|
|
|
12
19
|
id: string;
|
|
13
20
|
}
|
|
14
21
|
export interface TableClient<T> {
|
|
15
|
-
findAll(params?: {
|
|
16
|
-
limit?: number;
|
|
17
|
-
offset?: number;
|
|
18
|
-
sort?: unknown[];
|
|
19
|
-
filter?: unknown;
|
|
20
|
-
filters?: unknown;
|
|
21
|
-
fields?: string[];
|
|
22
|
-
}): Promise<{
|
|
22
|
+
findAll(params?: TableFindAllOptions): Promise<{
|
|
23
23
|
records: T[];
|
|
24
24
|
hasMore: boolean;
|
|
25
25
|
}>;
|
|
@@ -57,6 +57,26 @@ export declare function createSqlClient(): (params: {
|
|
|
57
57
|
query: string;
|
|
58
58
|
params?: unknown[];
|
|
59
59
|
}) => Promise<SqlResult>;
|
|
60
|
+
export interface AuthUser {
|
|
61
|
+
id: string;
|
|
62
|
+
name: string;
|
|
63
|
+
email: string;
|
|
64
|
+
firstName: string | null;
|
|
65
|
+
lastName: string | null;
|
|
66
|
+
image: string | null;
|
|
67
|
+
}
|
|
68
|
+
export type FindAllAuthUsersOptions = Omit<TableFindAllOptions, "fields">;
|
|
69
|
+
export type FindAllAuthUsersResult<T extends AuthUser = AuthUser> = {
|
|
70
|
+
records: T[];
|
|
71
|
+
total: number;
|
|
72
|
+
hasMore: boolean;
|
|
73
|
+
};
|
|
74
|
+
export type UpdateAuthUserProfile = Partial<Omit<AuthUser, "id" | "email" | "name">>;
|
|
75
|
+
export interface AuthClient<T extends AuthUser = AuthUser> {
|
|
76
|
+
findAllUsers(options?: FindAllAuthUsersOptions): Promise<FindAllAuthUsersResult<T>>;
|
|
77
|
+
updateUserProfile(userId: string, profile: UpdateAuthUserProfile): Promise<T>;
|
|
78
|
+
}
|
|
79
|
+
export declare function createAuthClient<T extends AuthUser = AuthUser>(): AuthClient<T>;
|
|
60
80
|
export interface AirtableTableClient<T> {
|
|
61
81
|
findAll(params?: {
|
|
62
82
|
offset?: string;
|
|
@@ -154,10 +174,6 @@ export declare function createEmailClient(integrationId: string): EmailClient;
|
|
|
154
174
|
export declare function createNotificationsClient(): {
|
|
155
175
|
create(params: NotificationsCreateParams): Promise<NotificationsCreateResult>;
|
|
156
176
|
};
|
|
157
|
-
export declare function createMetaClient(): {
|
|
158
|
-
listUsers(): Promise<MetaListUsersResult>;
|
|
159
|
-
};
|
|
160
177
|
export type { NotificationLink, NotificationsCreateParams, NotificationsCreateResult, } from "../notifications/index.js";
|
|
161
|
-
export type { MetaListUsersResult, ZiteProjectUser } from "../meta/index.js";
|
|
162
178
|
export { createCaller } from "../caller/index.js";
|
|
163
179
|
export type { EndpointConfig } from "../caller/index.js";
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createCaller = void 0;
|
|
4
4
|
exports.createTableClient = createTableClient;
|
|
5
5
|
exports.createSqlClient = createSqlClient;
|
|
6
|
+
exports.createAuthClient = createAuthClient;
|
|
6
7
|
exports.createAirtableClient = createAirtableClient;
|
|
7
8
|
exports.createEmailClient = createEmailClient;
|
|
8
9
|
exports.createNotificationsClient = createNotificationsClient;
|
|
9
|
-
exports.createMetaClient = createMetaClient;
|
|
10
10
|
const sdkCall_js_1 = require("../internal/sdkCall.js");
|
|
11
11
|
const DB_INTEGRATION_ID = "databases";
|
|
12
12
|
function getBaseId() {
|
|
@@ -73,6 +73,19 @@ function createSqlClient() {
|
|
|
73
73
|
...params,
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
+
function createAuthClient() {
|
|
77
|
+
return {
|
|
78
|
+
findAllUsers: (options) => (0, sdkCall_js_1.getSdkCall)()(DB_INTEGRATION_ID, "Auth", "findAllUsers", {
|
|
79
|
+
baseId: getBaseId(),
|
|
80
|
+
...options,
|
|
81
|
+
}),
|
|
82
|
+
updateUserProfile: (userId, profile) => (0, sdkCall_js_1.getSdkCall)()(DB_INTEGRATION_ID, "Auth", "updateUserProfile", {
|
|
83
|
+
baseId: getBaseId(),
|
|
84
|
+
userId,
|
|
85
|
+
profile,
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
76
89
|
function createAirtableClient(integrationId, className, implicitParams) {
|
|
77
90
|
return {
|
|
78
91
|
findAll: (params) => (0, sdkCall_js_1.getSdkCall)()(integrationId, className, "findAll", {
|
|
@@ -114,16 +127,10 @@ function createEmailClient(integrationId) {
|
|
|
114
127
|
};
|
|
115
128
|
}
|
|
116
129
|
const NOTIFICATIONS_SDK_INTEGRATION_ID = "__notifications__";
|
|
117
|
-
const META_SDK_INTEGRATION_ID = "__meta__";
|
|
118
130
|
function createNotificationsClient() {
|
|
119
131
|
return {
|
|
120
132
|
create: (params) => (0, sdkCall_js_1.getSdkCall)()(NOTIFICATIONS_SDK_INTEGRATION_ID, "ZiteNotifications", "create", params),
|
|
121
133
|
};
|
|
122
134
|
}
|
|
123
|
-
function createMetaClient() {
|
|
124
|
-
return {
|
|
125
|
-
listUsers: () => (0, sdkCall_js_1.getSdkCall)()(META_SDK_INTEGRATION_ID, "ZiteMeta", "listUsers", {}),
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
135
|
var index_js_1 = require("../caller/index.js");
|
|
129
136
|
Object.defineProperty(exports, "createCaller", { enumerable: true, get: function () { return index_js_1.createCaller; } });
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.generateAirtableTs = generateAirtableTs;
|
|
|
9
9
|
exports.generateBackendWrapperTs = generateBackendWrapperTs;
|
|
10
10
|
exports.generateEmailSdk = generateEmailSdk;
|
|
11
11
|
const parser_1 = require("@babel/parser");
|
|
12
|
+
const AUTH_USERS_TABLE_ID = "zite_user";
|
|
12
13
|
const FIELD_TYPE_MAP = {
|
|
13
14
|
single_line_text: "string",
|
|
14
15
|
long_text: "string",
|
|
@@ -197,6 +198,8 @@ function generateSchema(database, existingSchema) {
|
|
|
197
198
|
}
|
|
198
199
|
const tables = [];
|
|
199
200
|
for (const table of database.tables) {
|
|
201
|
+
if (table.id === AUTH_USERS_TABLE_ID)
|
|
202
|
+
continue;
|
|
200
203
|
const existingTable = existingTableById.get(table.id);
|
|
201
204
|
const existingFieldById = new Map();
|
|
202
205
|
for (const f of existingTable?.fields ?? []) {
|
|
@@ -243,16 +246,13 @@ function generateSentinelSdkTypes() {
|
|
|
243
246
|
" | { created: number }",
|
|
244
247
|
" | { created: 0; preview: true; wouldCreate: number };",
|
|
245
248
|
"",
|
|
246
|
-
"export interface
|
|
247
|
-
"
|
|
249
|
+
"export interface ZiteAuthUser {",
|
|
250
|
+
" id: string;",
|
|
251
|
+
" name: string;",
|
|
252
|
+
" email: string;",
|
|
248
253
|
" firstName: string | null;",
|
|
249
254
|
" lastName: string | null;",
|
|
250
|
-
"
|
|
251
|
-
" profilePictureUrl: string | null;",
|
|
252
|
-
"}",
|
|
253
|
-
"",
|
|
254
|
-
"export interface MetaListUsersResult {",
|
|
255
|
-
" users: ZiteProjectUser[];",
|
|
255
|
+
" image: string | null;",
|
|
256
256
|
"}",
|
|
257
257
|
"",
|
|
258
258
|
];
|
|
@@ -310,6 +310,7 @@ function buildLinkTableComments(schema) {
|
|
|
310
310
|
*/
|
|
311
311
|
function generateDbTs(schema) {
|
|
312
312
|
const lines = [];
|
|
313
|
+
const tables = schema.tables.filter((table) => table.id !== AUTH_USERS_TABLE_ID);
|
|
313
314
|
lines.push("// Auto-generated by zitejs generate. Do not edit manually.");
|
|
314
315
|
lines.push("//");
|
|
315
316
|
lines.push("// Usage in endpoint files (src/api/*.ts):");
|
|
@@ -328,6 +329,12 @@ function generateDbTs(schema) {
|
|
|
328
329
|
lines.push("// .delete({ id }) → { id: string }");
|
|
329
330
|
lines.push("// .bulkCreate({ records, matchOn? }) → { success: boolean, records: T[] }");
|
|
330
331
|
lines.push("//");
|
|
332
|
+
lines.push("// Zite auth users:");
|
|
333
|
+
lines.push("// zite.auth.findAllUsers({ filter?, filters?, sort?, limit?, offset? })");
|
|
334
|
+
lines.push("// Supports the same filter, sort, and pagination options as table .findAll()");
|
|
335
|
+
lines.push("// zite.auth.updateUserProfile(userId, { firstName?, lastName?, image? })");
|
|
336
|
+
lines.push("// User email addresses cannot be updated through this API");
|
|
337
|
+
lines.push("//");
|
|
331
338
|
lines.push("// Raw SQL (read-only SELECTs for aggregates, joins, multi-table queries):");
|
|
332
339
|
lines.push('// zite.sql({ query: "SELECT ...", params?: [...] })');
|
|
333
340
|
lines.push("// → { rows: Record<string, unknown>[], columns, rowCount, truncated }");
|
|
@@ -336,13 +343,14 @@ function generateDbTs(schema) {
|
|
|
336
343
|
lines.push("// - Use SDK names for tables (PascalCase) and fields (camelCase)");
|
|
337
344
|
lines.push('// - ALWAYS double-quote every identifier: FROM "Orders", WHERE "status" = $1');
|
|
338
345
|
lines.push("// - Use params array for user input ($1, $2, ...): never interpolate into SQL");
|
|
346
|
+
lines.push('// - Auth users are available as "ziteUsers" with id, name, email, firstName, lastName, and image');
|
|
339
347
|
lines.push("// - Soft-deleted rows are excluded automatically — no WHERE deleted_at IS NULL");
|
|
340
348
|
lines.push("// - SELECT only — use .create/.update/.delete for writes");
|
|
341
349
|
lines.push('// - Load the "zite:sql" skill for full SQL reference (formulas, lookups, etc.)');
|
|
342
350
|
lines.push(...buildLinkTableComments(schema));
|
|
343
|
-
lines.push("import { createTableClient, createSqlClient, createNotificationsClient,
|
|
351
|
+
lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createAuthClient } from 'zitejs/runtime';");
|
|
344
352
|
lines.push("");
|
|
345
|
-
for (const table of
|
|
353
|
+
for (const table of tables) {
|
|
346
354
|
const className = toPascalCase(table.sdkName);
|
|
347
355
|
const recordType = `${className}RecordType`;
|
|
348
356
|
lines.push(`export type ${recordType} = {`);
|
|
@@ -362,13 +370,13 @@ function generateDbTs(schema) {
|
|
|
362
370
|
}
|
|
363
371
|
lines.push(...generateSentinelSdkTypes());
|
|
364
372
|
lines.push("export const zite = {");
|
|
365
|
-
for (const table of
|
|
373
|
+
for (const table of tables) {
|
|
366
374
|
const className = toPascalCase(table.sdkName);
|
|
367
375
|
lines.push(` ${table.sdkName}: createTableClient<${className}RecordType>('${className}'),`);
|
|
368
376
|
}
|
|
369
377
|
lines.push(` sql: createSqlClient(),`);
|
|
370
378
|
lines.push(` notifications: createNotificationsClient(),`);
|
|
371
|
-
lines.push(`
|
|
379
|
+
lines.push(` auth: createAuthClient<ZiteAuthUser>(),`);
|
|
372
380
|
lines.push("};");
|
|
373
381
|
lines.push("");
|
|
374
382
|
return lines.join("\n");
|
package/dist/esm/cli.js
CHANGED
|
File without changes
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { NotificationsCreateParams, NotificationsCreateResult } from "../notifications/index.js";
|
|
2
|
-
|
|
2
|
+
export interface TableFindAllOptions {
|
|
3
|
+
limit?: number;
|
|
4
|
+
offset?: number;
|
|
5
|
+
sort?: unknown[];
|
|
6
|
+
filter?: unknown;
|
|
7
|
+
filters?: unknown;
|
|
8
|
+
fields?: string[];
|
|
9
|
+
}
|
|
3
10
|
export interface BulkCreateResult<T> {
|
|
4
11
|
success: boolean;
|
|
5
12
|
records: T[];
|
|
@@ -12,14 +19,7 @@ export interface DeleteResult {
|
|
|
12
19
|
id: string;
|
|
13
20
|
}
|
|
14
21
|
export interface TableClient<T> {
|
|
15
|
-
findAll(params?: {
|
|
16
|
-
limit?: number;
|
|
17
|
-
offset?: number;
|
|
18
|
-
sort?: unknown[];
|
|
19
|
-
filter?: unknown;
|
|
20
|
-
filters?: unknown;
|
|
21
|
-
fields?: string[];
|
|
22
|
-
}): Promise<{
|
|
22
|
+
findAll(params?: TableFindAllOptions): Promise<{
|
|
23
23
|
records: T[];
|
|
24
24
|
hasMore: boolean;
|
|
25
25
|
}>;
|
|
@@ -57,6 +57,26 @@ export declare function createSqlClient(): (params: {
|
|
|
57
57
|
query: string;
|
|
58
58
|
params?: unknown[];
|
|
59
59
|
}) => Promise<SqlResult>;
|
|
60
|
+
export interface AuthUser {
|
|
61
|
+
id: string;
|
|
62
|
+
name: string;
|
|
63
|
+
email: string;
|
|
64
|
+
firstName: string | null;
|
|
65
|
+
lastName: string | null;
|
|
66
|
+
image: string | null;
|
|
67
|
+
}
|
|
68
|
+
export type FindAllAuthUsersOptions = Omit<TableFindAllOptions, "fields">;
|
|
69
|
+
export type FindAllAuthUsersResult<T extends AuthUser = AuthUser> = {
|
|
70
|
+
records: T[];
|
|
71
|
+
total: number;
|
|
72
|
+
hasMore: boolean;
|
|
73
|
+
};
|
|
74
|
+
export type UpdateAuthUserProfile = Partial<Omit<AuthUser, "id" | "email" | "name">>;
|
|
75
|
+
export interface AuthClient<T extends AuthUser = AuthUser> {
|
|
76
|
+
findAllUsers(options?: FindAllAuthUsersOptions): Promise<FindAllAuthUsersResult<T>>;
|
|
77
|
+
updateUserProfile(userId: string, profile: UpdateAuthUserProfile): Promise<T>;
|
|
78
|
+
}
|
|
79
|
+
export declare function createAuthClient<T extends AuthUser = AuthUser>(): AuthClient<T>;
|
|
60
80
|
export interface AirtableTableClient<T> {
|
|
61
81
|
findAll(params?: {
|
|
62
82
|
offset?: string;
|
|
@@ -154,10 +174,6 @@ export declare function createEmailClient(integrationId: string): EmailClient;
|
|
|
154
174
|
export declare function createNotificationsClient(): {
|
|
155
175
|
create(params: NotificationsCreateParams): Promise<NotificationsCreateResult>;
|
|
156
176
|
};
|
|
157
|
-
export declare function createMetaClient(): {
|
|
158
|
-
listUsers(): Promise<MetaListUsersResult>;
|
|
159
|
-
};
|
|
160
177
|
export type { NotificationLink, NotificationsCreateParams, NotificationsCreateResult, } from "../notifications/index.js";
|
|
161
|
-
export type { MetaListUsersResult, ZiteProjectUser } from "../meta/index.js";
|
|
162
178
|
export { createCaller } from "../caller/index.js";
|
|
163
179
|
export type { EndpointConfig } from "../caller/index.js";
|
|
@@ -64,6 +64,19 @@ export function createSqlClient() {
|
|
|
64
64
|
...params,
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
+
export function createAuthClient() {
|
|
68
|
+
return {
|
|
69
|
+
findAllUsers: (options) => getSdkCall()(DB_INTEGRATION_ID, "Auth", "findAllUsers", {
|
|
70
|
+
baseId: getBaseId(),
|
|
71
|
+
...options,
|
|
72
|
+
}),
|
|
73
|
+
updateUserProfile: (userId, profile) => getSdkCall()(DB_INTEGRATION_ID, "Auth", "updateUserProfile", {
|
|
74
|
+
baseId: getBaseId(),
|
|
75
|
+
userId,
|
|
76
|
+
profile,
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
67
80
|
export function createAirtableClient(integrationId, className, implicitParams) {
|
|
68
81
|
return {
|
|
69
82
|
findAll: (params) => getSdkCall()(integrationId, className, "findAll", {
|
|
@@ -105,15 +118,9 @@ export function createEmailClient(integrationId) {
|
|
|
105
118
|
};
|
|
106
119
|
}
|
|
107
120
|
const NOTIFICATIONS_SDK_INTEGRATION_ID = "__notifications__";
|
|
108
|
-
const META_SDK_INTEGRATION_ID = "__meta__";
|
|
109
121
|
export function createNotificationsClient() {
|
|
110
122
|
return {
|
|
111
123
|
create: (params) => getSdkCall()(NOTIFICATIONS_SDK_INTEGRATION_ID, "ZiteNotifications", "create", params),
|
|
112
124
|
};
|
|
113
125
|
}
|
|
114
|
-
export function createMetaClient() {
|
|
115
|
-
return {
|
|
116
|
-
listUsers: () => getSdkCall()(META_SDK_INTEGRATION_ID, "ZiteMeta", "listUsers", {}),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
126
|
export { createCaller } from "../caller/index.js";
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parse } from "@babel/parser";
|
|
2
|
+
const AUTH_USERS_TABLE_ID = "zite_user";
|
|
2
3
|
const FIELD_TYPE_MAP = {
|
|
3
4
|
single_line_text: "string",
|
|
4
5
|
long_text: "string",
|
|
@@ -187,6 +188,8 @@ export function generateSchema(database, existingSchema) {
|
|
|
187
188
|
}
|
|
188
189
|
const tables = [];
|
|
189
190
|
for (const table of database.tables) {
|
|
191
|
+
if (table.id === AUTH_USERS_TABLE_ID)
|
|
192
|
+
continue;
|
|
190
193
|
const existingTable = existingTableById.get(table.id);
|
|
191
194
|
const existingFieldById = new Map();
|
|
192
195
|
for (const f of existingTable?.fields ?? []) {
|
|
@@ -233,16 +236,13 @@ function generateSentinelSdkTypes() {
|
|
|
233
236
|
" | { created: number }",
|
|
234
237
|
" | { created: 0; preview: true; wouldCreate: number };",
|
|
235
238
|
"",
|
|
236
|
-
"export interface
|
|
237
|
-
"
|
|
239
|
+
"export interface ZiteAuthUser {",
|
|
240
|
+
" id: string;",
|
|
241
|
+
" name: string;",
|
|
242
|
+
" email: string;",
|
|
238
243
|
" firstName: string | null;",
|
|
239
244
|
" lastName: string | null;",
|
|
240
|
-
"
|
|
241
|
-
" profilePictureUrl: string | null;",
|
|
242
|
-
"}",
|
|
243
|
-
"",
|
|
244
|
-
"export interface MetaListUsersResult {",
|
|
245
|
-
" users: ZiteProjectUser[];",
|
|
245
|
+
" image: string | null;",
|
|
246
246
|
"}",
|
|
247
247
|
"",
|
|
248
248
|
];
|
|
@@ -300,6 +300,7 @@ function buildLinkTableComments(schema) {
|
|
|
300
300
|
*/
|
|
301
301
|
export function generateDbTs(schema) {
|
|
302
302
|
const lines = [];
|
|
303
|
+
const tables = schema.tables.filter((table) => table.id !== AUTH_USERS_TABLE_ID);
|
|
303
304
|
lines.push("// Auto-generated by zitejs generate. Do not edit manually.");
|
|
304
305
|
lines.push("//");
|
|
305
306
|
lines.push("// Usage in endpoint files (src/api/*.ts):");
|
|
@@ -318,6 +319,12 @@ export function generateDbTs(schema) {
|
|
|
318
319
|
lines.push("// .delete({ id }) → { id: string }");
|
|
319
320
|
lines.push("// .bulkCreate({ records, matchOn? }) → { success: boolean, records: T[] }");
|
|
320
321
|
lines.push("//");
|
|
322
|
+
lines.push("// Zite auth users:");
|
|
323
|
+
lines.push("// zite.auth.findAllUsers({ filter?, filters?, sort?, limit?, offset? })");
|
|
324
|
+
lines.push("// Supports the same filter, sort, and pagination options as table .findAll()");
|
|
325
|
+
lines.push("// zite.auth.updateUserProfile(userId, { firstName?, lastName?, image? })");
|
|
326
|
+
lines.push("// User email addresses cannot be updated through this API");
|
|
327
|
+
lines.push("//");
|
|
321
328
|
lines.push("// Raw SQL (read-only SELECTs for aggregates, joins, multi-table queries):");
|
|
322
329
|
lines.push('// zite.sql({ query: "SELECT ...", params?: [...] })');
|
|
323
330
|
lines.push("// → { rows: Record<string, unknown>[], columns, rowCount, truncated }");
|
|
@@ -326,13 +333,14 @@ export function generateDbTs(schema) {
|
|
|
326
333
|
lines.push("// - Use SDK names for tables (PascalCase) and fields (camelCase)");
|
|
327
334
|
lines.push('// - ALWAYS double-quote every identifier: FROM "Orders", WHERE "status" = $1');
|
|
328
335
|
lines.push("// - Use params array for user input ($1, $2, ...): never interpolate into SQL");
|
|
336
|
+
lines.push('// - Auth users are available as "ziteUsers" with id, name, email, firstName, lastName, and image');
|
|
329
337
|
lines.push("// - Soft-deleted rows are excluded automatically — no WHERE deleted_at IS NULL");
|
|
330
338
|
lines.push("// - SELECT only — use .create/.update/.delete for writes");
|
|
331
339
|
lines.push('// - Load the "zite:sql" skill for full SQL reference (formulas, lookups, etc.)');
|
|
332
340
|
lines.push(...buildLinkTableComments(schema));
|
|
333
|
-
lines.push("import { createTableClient, createSqlClient, createNotificationsClient,
|
|
341
|
+
lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createAuthClient } from 'zitejs/runtime';");
|
|
334
342
|
lines.push("");
|
|
335
|
-
for (const table of
|
|
343
|
+
for (const table of tables) {
|
|
336
344
|
const className = toPascalCase(table.sdkName);
|
|
337
345
|
const recordType = `${className}RecordType`;
|
|
338
346
|
lines.push(`export type ${recordType} = {`);
|
|
@@ -352,13 +360,13 @@ export function generateDbTs(schema) {
|
|
|
352
360
|
}
|
|
353
361
|
lines.push(...generateSentinelSdkTypes());
|
|
354
362
|
lines.push("export const zite = {");
|
|
355
|
-
for (const table of
|
|
363
|
+
for (const table of tables) {
|
|
356
364
|
const className = toPascalCase(table.sdkName);
|
|
357
365
|
lines.push(` ${table.sdkName}: createTableClient<${className}RecordType>('${className}'),`);
|
|
358
366
|
}
|
|
359
367
|
lines.push(` sql: createSqlClient(),`);
|
|
360
368
|
lines.push(` notifications: createNotificationsClient(),`);
|
|
361
|
-
lines.push(`
|
|
369
|
+
lines.push(` auth: createAuthClient<ZiteAuthUser>(),`);
|
|
362
370
|
lines.push("};");
|
|
363
371
|
lines.push("");
|
|
364
372
|
return lines.join("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zitejs",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.89",
|
|
4
4
|
"description": "The Zite framework — build apps on Zite Database",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -73,11 +73,6 @@
|
|
|
73
73
|
"import": "./dist/esm/notifications/index.js",
|
|
74
74
|
"require": "./dist/cjs/notifications/index.js"
|
|
75
75
|
},
|
|
76
|
-
"./meta": {
|
|
77
|
-
"types": "./dist/esm/meta/index.d.ts",
|
|
78
|
-
"import": "./dist/esm/meta/index.js",
|
|
79
|
-
"require": "./dist/cjs/meta/index.js"
|
|
80
|
-
},
|
|
81
76
|
"./sync": {
|
|
82
77
|
"types": "./dist/esm/sync/index.d.ts",
|
|
83
78
|
"import": "./dist/esm/sync/index.js",
|
|
@@ -138,9 +133,6 @@
|
|
|
138
133
|
"notifications": [
|
|
139
134
|
"dist/esm/notifications/index.d.ts"
|
|
140
135
|
],
|
|
141
|
-
"meta": [
|
|
142
|
-
"dist/esm/meta/index.d.ts"
|
|
143
|
-
],
|
|
144
136
|
"vite-plugin": [
|
|
145
137
|
"dist/esm/vite/index.d.ts"
|
|
146
138
|
]
|
package/dist/cjs/api/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCaller = void 0;
|
|
4
|
-
var index_js_1 = require("../caller/index.js");
|
|
5
|
-
Object.defineProperty(exports, "createCaller", { enumerable: true, get: function () { return index_js_1.createCaller; } });
|
package/dist/cjs/db/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTableClient = void 0;
|
|
4
|
-
var index_js_1 = require("../runtime/index.js");
|
|
5
|
-
Object.defineProperty(exports, "createTableClient", { enumerable: true, get: function () { return index_js_1.createTableClient; } });
|
package/dist/esm/api/index.d.ts
DELETED
package/dist/esm/api/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createCaller } from '../caller/index.js';
|
package/dist/esm/db/index.d.ts
DELETED
package/dist/esm/db/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createTableClient } from '../runtime/index.js';
|