zitejs 0.9.88 → 0.9.90
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 +15 -1
- package/dist/cjs/runtime/index.d.ts +32 -13
- package/dist/cjs/runtime/index.js +14 -7
- package/dist/cjs/sync/lib.js +21 -12
- package/dist/esm/cli.js +0 -0
- package/dist/esm/runtime/index.d.ts +32 -13
- package/dist/esm/runtime/index.js +13 -6
- package/dist/esm/sync/lib.js +21 -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,21 @@ 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
|
+
appIds: ['app-1'],
|
|
15
|
+
filters: { email: 'person@example.com' },
|
|
16
|
+
});
|
|
17
|
+
await zite.auth.updateUserProfile(users[0].id, {
|
|
18
|
+
firstName: 'New name',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Auth users can also be queried with read-only SQL
|
|
22
|
+
const result = await zite.sql({
|
|
23
|
+
query: 'SELECT "id", "email" FROM "ziteUsers"',
|
|
24
|
+
});
|
|
11
25
|
|
|
12
26
|
// Define API endpoints
|
|
13
27
|
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,29 @@ 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
|
+
/** Restrict results to users belonging to any of these apps. */
|
|
70
|
+
appIds?: string[];
|
|
71
|
+
};
|
|
72
|
+
export type FindAllAuthUsersResult<T extends AuthUser = AuthUser> = {
|
|
73
|
+
records: T[];
|
|
74
|
+
total: number;
|
|
75
|
+
hasMore: boolean;
|
|
76
|
+
};
|
|
77
|
+
export type UpdateAuthUserProfile = Partial<Omit<AuthUser, "id" | "email" | "name">>;
|
|
78
|
+
export interface AuthClient<T extends AuthUser = AuthUser> {
|
|
79
|
+
findAllUsers(options?: FindAllAuthUsersOptions): Promise<FindAllAuthUsersResult<T>>;
|
|
80
|
+
updateUserProfile(userId: string, profile: UpdateAuthUserProfile): Promise<T>;
|
|
81
|
+
}
|
|
82
|
+
export declare function createAuthClient<T extends AuthUser = AuthUser>(): AuthClient<T>;
|
|
60
83
|
export interface AirtableTableClient<T> {
|
|
61
84
|
findAll(params?: {
|
|
62
85
|
offset?: string;
|
|
@@ -154,10 +177,6 @@ export declare function createEmailClient(integrationId: string): EmailClient;
|
|
|
154
177
|
export declare function createNotificationsClient(): {
|
|
155
178
|
create(params: NotificationsCreateParams): Promise<NotificationsCreateResult>;
|
|
156
179
|
};
|
|
157
|
-
export declare function createMetaClient(): {
|
|
158
|
-
listUsers(): Promise<MetaListUsersResult>;
|
|
159
|
-
};
|
|
160
180
|
export type { NotificationLink, NotificationsCreateParams, NotificationsCreateResult, } from "../notifications/index.js";
|
|
161
|
-
export type { MetaListUsersResult, ZiteProjectUser } from "../meta/index.js";
|
|
162
181
|
export { createCaller } from "../caller/index.js";
|
|
163
182
|
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,13 @@ 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({ appIds?, filter?, filters?, sort?, limit?, offset? })");
|
|
334
|
+
lines.push("// Supports the same filter, sort, and pagination options as table .findAll()");
|
|
335
|
+
lines.push("// appIds restricts results to users belonging to any listed app");
|
|
336
|
+
lines.push("// zite.auth.updateUserProfile(userId, { firstName?, lastName?, image? })");
|
|
337
|
+
lines.push("// User email addresses cannot be updated through this API");
|
|
338
|
+
lines.push("//");
|
|
331
339
|
lines.push("// Raw SQL (read-only SELECTs for aggregates, joins, multi-table queries):");
|
|
332
340
|
lines.push('// zite.sql({ query: "SELECT ...", params?: [...] })');
|
|
333
341
|
lines.push("// → { rows: Record<string, unknown>[], columns, rowCount, truncated }");
|
|
@@ -336,13 +344,14 @@ function generateDbTs(schema) {
|
|
|
336
344
|
lines.push("// - Use SDK names for tables (PascalCase) and fields (camelCase)");
|
|
337
345
|
lines.push('// - ALWAYS double-quote every identifier: FROM "Orders", WHERE "status" = $1');
|
|
338
346
|
lines.push("// - Use params array for user input ($1, $2, ...): never interpolate into SQL");
|
|
347
|
+
lines.push('// - Auth users are available as "ziteUsers" with id, name, email, firstName, lastName, and image');
|
|
339
348
|
lines.push("// - Soft-deleted rows are excluded automatically — no WHERE deleted_at IS NULL");
|
|
340
349
|
lines.push("// - SELECT only — use .create/.update/.delete for writes");
|
|
341
350
|
lines.push('// - Load the "zite:sql" skill for full SQL reference (formulas, lookups, etc.)');
|
|
342
351
|
lines.push(...buildLinkTableComments(schema));
|
|
343
|
-
lines.push("import { createTableClient, createSqlClient, createNotificationsClient,
|
|
352
|
+
lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createAuthClient } from 'zitejs/runtime';");
|
|
344
353
|
lines.push("");
|
|
345
|
-
for (const table of
|
|
354
|
+
for (const table of tables) {
|
|
346
355
|
const className = toPascalCase(table.sdkName);
|
|
347
356
|
const recordType = `${className}RecordType`;
|
|
348
357
|
lines.push(`export type ${recordType} = {`);
|
|
@@ -362,13 +371,13 @@ function generateDbTs(schema) {
|
|
|
362
371
|
}
|
|
363
372
|
lines.push(...generateSentinelSdkTypes());
|
|
364
373
|
lines.push("export const zite = {");
|
|
365
|
-
for (const table of
|
|
374
|
+
for (const table of tables) {
|
|
366
375
|
const className = toPascalCase(table.sdkName);
|
|
367
376
|
lines.push(` ${table.sdkName}: createTableClient<${className}RecordType>('${className}'),`);
|
|
368
377
|
}
|
|
369
378
|
lines.push(` sql: createSqlClient(),`);
|
|
370
379
|
lines.push(` notifications: createNotificationsClient(),`);
|
|
371
|
-
lines.push(`
|
|
380
|
+
lines.push(` auth: createAuthClient<ZiteAuthUser>(),`);
|
|
372
381
|
lines.push("};");
|
|
373
382
|
lines.push("");
|
|
374
383
|
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,29 @@ 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
|
+
/** Restrict results to users belonging to any of these apps. */
|
|
70
|
+
appIds?: string[];
|
|
71
|
+
};
|
|
72
|
+
export type FindAllAuthUsersResult<T extends AuthUser = AuthUser> = {
|
|
73
|
+
records: T[];
|
|
74
|
+
total: number;
|
|
75
|
+
hasMore: boolean;
|
|
76
|
+
};
|
|
77
|
+
export type UpdateAuthUserProfile = Partial<Omit<AuthUser, "id" | "email" | "name">>;
|
|
78
|
+
export interface AuthClient<T extends AuthUser = AuthUser> {
|
|
79
|
+
findAllUsers(options?: FindAllAuthUsersOptions): Promise<FindAllAuthUsersResult<T>>;
|
|
80
|
+
updateUserProfile(userId: string, profile: UpdateAuthUserProfile): Promise<T>;
|
|
81
|
+
}
|
|
82
|
+
export declare function createAuthClient<T extends AuthUser = AuthUser>(): AuthClient<T>;
|
|
60
83
|
export interface AirtableTableClient<T> {
|
|
61
84
|
findAll(params?: {
|
|
62
85
|
offset?: string;
|
|
@@ -154,10 +177,6 @@ export declare function createEmailClient(integrationId: string): EmailClient;
|
|
|
154
177
|
export declare function createNotificationsClient(): {
|
|
155
178
|
create(params: NotificationsCreateParams): Promise<NotificationsCreateResult>;
|
|
156
179
|
};
|
|
157
|
-
export declare function createMetaClient(): {
|
|
158
|
-
listUsers(): Promise<MetaListUsersResult>;
|
|
159
|
-
};
|
|
160
180
|
export type { NotificationLink, NotificationsCreateParams, NotificationsCreateResult, } from "../notifications/index.js";
|
|
161
|
-
export type { MetaListUsersResult, ZiteProjectUser } from "../meta/index.js";
|
|
162
181
|
export { createCaller } from "../caller/index.js";
|
|
163
182
|
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,13 @@ 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({ appIds?, filter?, filters?, sort?, limit?, offset? })");
|
|
324
|
+
lines.push("// Supports the same filter, sort, and pagination options as table .findAll()");
|
|
325
|
+
lines.push("// appIds restricts results to users belonging to any listed app");
|
|
326
|
+
lines.push("// zite.auth.updateUserProfile(userId, { firstName?, lastName?, image? })");
|
|
327
|
+
lines.push("// User email addresses cannot be updated through this API");
|
|
328
|
+
lines.push("//");
|
|
321
329
|
lines.push("// Raw SQL (read-only SELECTs for aggregates, joins, multi-table queries):");
|
|
322
330
|
lines.push('// zite.sql({ query: "SELECT ...", params?: [...] })');
|
|
323
331
|
lines.push("// → { rows: Record<string, unknown>[], columns, rowCount, truncated }");
|
|
@@ -326,13 +334,14 @@ export function generateDbTs(schema) {
|
|
|
326
334
|
lines.push("// - Use SDK names for tables (PascalCase) and fields (camelCase)");
|
|
327
335
|
lines.push('// - ALWAYS double-quote every identifier: FROM "Orders", WHERE "status" = $1');
|
|
328
336
|
lines.push("// - Use params array for user input ($1, $2, ...): never interpolate into SQL");
|
|
337
|
+
lines.push('// - Auth users are available as "ziteUsers" with id, name, email, firstName, lastName, and image');
|
|
329
338
|
lines.push("// - Soft-deleted rows are excluded automatically — no WHERE deleted_at IS NULL");
|
|
330
339
|
lines.push("// - SELECT only — use .create/.update/.delete for writes");
|
|
331
340
|
lines.push('// - Load the "zite:sql" skill for full SQL reference (formulas, lookups, etc.)');
|
|
332
341
|
lines.push(...buildLinkTableComments(schema));
|
|
333
|
-
lines.push("import { createTableClient, createSqlClient, createNotificationsClient,
|
|
342
|
+
lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createAuthClient } from 'zitejs/runtime';");
|
|
334
343
|
lines.push("");
|
|
335
|
-
for (const table of
|
|
344
|
+
for (const table of tables) {
|
|
336
345
|
const className = toPascalCase(table.sdkName);
|
|
337
346
|
const recordType = `${className}RecordType`;
|
|
338
347
|
lines.push(`export type ${recordType} = {`);
|
|
@@ -352,13 +361,13 @@ export function generateDbTs(schema) {
|
|
|
352
361
|
}
|
|
353
362
|
lines.push(...generateSentinelSdkTypes());
|
|
354
363
|
lines.push("export const zite = {");
|
|
355
|
-
for (const table of
|
|
364
|
+
for (const table of tables) {
|
|
356
365
|
const className = toPascalCase(table.sdkName);
|
|
357
366
|
lines.push(` ${table.sdkName}: createTableClient<${className}RecordType>('${className}'),`);
|
|
358
367
|
}
|
|
359
368
|
lines.push(` sql: createSqlClient(),`);
|
|
360
369
|
lines.push(` notifications: createNotificationsClient(),`);
|
|
361
|
-
lines.push(`
|
|
370
|
+
lines.push(` auth: createAuthClient<ZiteAuthUser>(),`);
|
|
362
371
|
lines.push("};");
|
|
363
372
|
lines.push("");
|
|
364
373
|
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.90",
|
|
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';
|