zitejs 0.9.86 → 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 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 users = await zite.users.findMany();
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';
@@ -67,8 +67,7 @@ function getDeclaredEnvVarNames(appDir) {
67
67
  function regenerateAppTypedWrappers(appDir) {
68
68
  const outDir = (0, path_1.join)("apps", appDir, ".zite");
69
69
  (0, fs_2.mkdirSync)(outDir, { recursive: true });
70
- (0, fs_2.writeFileSync)((0, path_1.join)(outDir, "user.ts"), (0, lib_js_1.generateUserTs)());
71
- (0, fs_2.writeFileSync)((0, path_1.join)(outDir, "auth.ts"), (0, lib_js_1.generateAuthWrapperTs)());
70
+ // user.ts and auth.ts no longer generated — User type is fixed in zitejs/auth
72
71
  // Email integration: generate the Email client at .zite/integrations/email.ts.
73
72
  // Resolved by the `zitejs/email` bundler/tsconfig alias (mirrors airtable's
74
73
  // `zitejs/integrations`), so endpoint code uses `import { Email } from 'zitejs/email'`.
@@ -1,5 +1,12 @@
1
1
  import type { NotificationsCreateParams, NotificationsCreateResult } from "../notifications/index.js";
2
- import type { MetaListUsersResult } from "../meta/index.js";
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; } });
@@ -35,11 +35,6 @@ export type EndpointFileInfo = {
35
35
  content?: string;
36
36
  };
37
37
  export declare function generateApiTs(endpointFiles: (string | EndpointFileInfo)[]): string | null;
38
- export declare function generateUserTs(usersTableFields?: Array<{
39
- name: string;
40
- type: string;
41
- }>): string;
42
- export declare function generateAuthWrapperTs(): string;
43
38
  export type AirtableLockField = {
44
39
  id: string;
45
40
  sdkName: string;
@@ -5,12 +5,11 @@ exports.toCamelCase = toCamelCase;
5
5
  exports.generateSchema = generateSchema;
6
6
  exports.generateDbTs = generateDbTs;
7
7
  exports.generateApiTs = generateApiTs;
8
- exports.generateUserTs = generateUserTs;
9
- exports.generateAuthWrapperTs = generateAuthWrapperTs;
10
8
  exports.generateAirtableTs = generateAirtableTs;
11
9
  exports.generateBackendWrapperTs = generateBackendWrapperTs;
12
10
  exports.generateEmailSdk = generateEmailSdk;
13
11
  const parser_1 = require("@babel/parser");
12
+ const AUTH_USERS_TABLE_ID = "zite_user";
14
13
  const FIELD_TYPE_MAP = {
15
14
  single_line_text: "string",
16
15
  long_text: "string",
@@ -199,6 +198,8 @@ function generateSchema(database, existingSchema) {
199
198
  }
200
199
  const tables = [];
201
200
  for (const table of database.tables) {
201
+ if (table.id === AUTH_USERS_TABLE_ID)
202
+ continue;
202
203
  const existingTable = existingTableById.get(table.id);
203
204
  const existingFieldById = new Map();
204
205
  for (const f of existingTable?.fields ?? []) {
@@ -245,16 +246,13 @@ function generateSentinelSdkTypes() {
245
246
  " | { created: number }",
246
247
  " | { created: 0; preview: true; wouldCreate: number };",
247
248
  "",
248
- "export interface ZiteProjectUser {",
249
- " uuid: string;",
249
+ "export interface ZiteAuthUser {",
250
+ " id: string;",
251
+ " name: string;",
252
+ " email: string;",
250
253
  " firstName: string | null;",
251
254
  " lastName: string | null;",
252
- " email: string;",
253
- " profilePictureUrl: string | null;",
254
- "}",
255
- "",
256
- "export interface MetaListUsersResult {",
257
- " users: ZiteProjectUser[];",
255
+ " image: string | null;",
258
256
  "}",
259
257
  "",
260
258
  ];
@@ -312,6 +310,7 @@ function buildLinkTableComments(schema) {
312
310
  */
313
311
  function generateDbTs(schema) {
314
312
  const lines = [];
313
+ const tables = schema.tables.filter((table) => table.id !== AUTH_USERS_TABLE_ID);
315
314
  lines.push("// Auto-generated by zitejs generate. Do not edit manually.");
316
315
  lines.push("//");
317
316
  lines.push("// Usage in endpoint files (src/api/*.ts):");
@@ -330,6 +329,12 @@ function generateDbTs(schema) {
330
329
  lines.push("// .delete({ id }) → { id: string }");
331
330
  lines.push("// .bulkCreate({ records, matchOn? }) → { success: boolean, records: T[] }");
332
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("//");
333
338
  lines.push("// Raw SQL (read-only SELECTs for aggregates, joins, multi-table queries):");
334
339
  lines.push('// zite.sql({ query: "SELECT ...", params?: [...] })');
335
340
  lines.push("// → { rows: Record<string, unknown>[], columns, rowCount, truncated }");
@@ -338,13 +343,14 @@ function generateDbTs(schema) {
338
343
  lines.push("// - Use SDK names for tables (PascalCase) and fields (camelCase)");
339
344
  lines.push('// - ALWAYS double-quote every identifier: FROM "Orders", WHERE "status" = $1');
340
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');
341
347
  lines.push("// - Soft-deleted rows are excluded automatically — no WHERE deleted_at IS NULL");
342
348
  lines.push("// - SELECT only — use .create/.update/.delete for writes");
343
349
  lines.push('// - Load the "zite:sql" skill for full SQL reference (formulas, lookups, etc.)');
344
350
  lines.push(...buildLinkTableComments(schema));
345
- lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createMetaClient } from 'zitejs/runtime';");
351
+ lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createAuthClient } from 'zitejs/runtime';");
346
352
  lines.push("");
347
- for (const table of schema.tables) {
353
+ for (const table of tables) {
348
354
  const className = toPascalCase(table.sdkName);
349
355
  const recordType = `${className}RecordType`;
350
356
  lines.push(`export type ${recordType} = {`);
@@ -364,13 +370,13 @@ function generateDbTs(schema) {
364
370
  }
365
371
  lines.push(...generateSentinelSdkTypes());
366
372
  lines.push("export const zite = {");
367
- for (const table of schema.tables) {
373
+ for (const table of tables) {
368
374
  const className = toPascalCase(table.sdkName);
369
375
  lines.push(` ${table.sdkName}: createTableClient<${className}RecordType>('${className}'),`);
370
376
  }
371
377
  lines.push(` sql: createSqlClient(),`);
372
378
  lines.push(` notifications: createNotificationsClient(),`);
373
- lines.push(` meta: createMetaClient(),`);
379
+ lines.push(` auth: createAuthClient<ZiteAuthUser>(),`);
374
380
  lines.push("};");
375
381
  lines.push("");
376
382
  return lines.join("\n");
@@ -459,66 +465,6 @@ function tsTypeForField(field) {
459
465
  return FIELD_TYPE_MAP[field.type];
460
466
  return "string";
461
467
  }
462
- function generateUserTs(usersTableFields) {
463
- const lines = [
464
- "// Auto-generated by zitejs generate. Do not edit manually.",
465
- "",
466
- ];
467
- if (usersTableFields && usersTableFields.length > 0) {
468
- lines.push("export type User = {");
469
- lines.push(" id: string;");
470
- lines.push(" email: string;");
471
- for (const field of usersTableFields) {
472
- const lowerName = field.name.toLowerCase();
473
- if (lowerName === "id" || lowerName === "email")
474
- continue;
475
- const fieldName = toCamelCase(field.name);
476
- const tsType = tsTypeForField(field);
477
- lines.push(` ${fieldName}: ${tsType};`);
478
- }
479
- lines.push(" [key: string]: unknown;");
480
- lines.push("};");
481
- }
482
- else {
483
- lines.push("export type User = {");
484
- lines.push(" id: string;");
485
- lines.push(" email: string;");
486
- lines.push(" firstName?: string;");
487
- lines.push(" lastName?: string;");
488
- lines.push(" [key: string]: unknown;");
489
- lines.push("};");
490
- }
491
- lines.push("");
492
- return lines.join("\n");
493
- }
494
- function generateAuthWrapperTs() {
495
- return [
496
- "// Auto-generated auth re-exports. Do not edit manually.",
497
- "// The real auth logic lives in the zitejs npm package (zitejs/auth).",
498
- "// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
499
- "",
500
- "export {",
501
- " useAuth,",
502
- " useSession,",
503
- " signIn,",
504
- " signOut,",
505
- " signUp,",
506
- " loginWithRedirect,",
507
- " logout,",
508
- " updateProfile,",
509
- "} from 'zitejs/auth/base';",
510
- "",
511
- "export type {",
512
- " User,",
513
- " ZiteAppConfig,",
514
- " ZiteAuthenticationConfig,",
515
- " ZiteAuthMethods,",
516
- " ZiteAuthPage,",
517
- " ZiteAuthPageMessages,",
518
- "} from 'zitejs/auth/base';",
519
- "",
520
- ].join("\n");
521
- }
522
468
  const AIRTABLE_FIELD_TYPE_MAP = {
523
469
  // Writable fields
524
470
  singleLineText: "string",
@@ -723,7 +669,7 @@ function generateBackendWrapperTs(envVarNames = []) {
723
669
  "// Re-exports createEndpoint with context.user typed to the app User.",
724
670
  "",
725
671
  "import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext as _ZiteScheduledContext, ZiteSchedule, ZiteWebhook } from 'zitejs/backend/base';",
726
- "import type { User } from './user';",
672
+ "import type { User } from 'zitejs/auth';",
727
673
  "",
728
674
  "export type { ZiteSchedule, ZiteWebhook };",
729
675
  "",
@@ -2,42 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
4
  const lib_js_1 = require("./lib.js");
5
- (0, vitest_1.describe)('generateAuthWrapperTs', () => {
6
- const output = (0, lib_js_1.generateAuthWrapperTs)();
7
- (0, vitest_1.it)('imports from zitejs/auth/base (not zitejs/auth) to avoid circular alias', () => {
8
- (0, vitest_1.expect)(output).toContain("from 'zitejs/auth/base'");
9
- (0, vitest_1.expect)(output).not.toContain("from 'zitejs/auth';");
5
+ (0, vitest_1.describe)('generateBackendWrapperTs', () => {
6
+ const output = (0, lib_js_1.generateBackendWrapperTs)();
7
+ (0, vitest_1.it)('imports User from zitejs/auth', () => {
8
+ (0, vitest_1.expect)(output).toContain("from 'zitejs/auth'");
10
9
  });
11
- (0, vitest_1.it)('re-exports all auth runtime functions', () => {
12
- for (const fn of [
13
- 'useSession',
14
- 'signIn',
15
- 'signOut',
16
- 'signUp',
17
- 'loginWithRedirect',
18
- 'logout',
19
- ]) {
20
- (0, vitest_1.expect)(output).toContain(fn);
21
- }
10
+ (0, vitest_1.it)('exports createEndpoint', () => {
11
+ (0, vitest_1.expect)(output).toContain('createEndpoint');
22
12
  });
23
- (0, vitest_1.it)('re-exports all config types', () => {
24
- for (const type of [
25
- 'User',
26
- 'ZiteAppConfig',
27
- 'ZiteAuthenticationConfig',
28
- 'ZiteAuthMethods',
29
- 'ZiteAuthPage',
30
- 'ZiteAuthPageMessages',
31
- ]) {
32
- (0, vitest_1.expect)(output).toContain(type);
33
- }
34
- });
35
- (0, vitest_1.it)('always exports useAuth as primary API', () => {
36
- (0, vitest_1.expect)(output).toContain('useAuth');
37
- });
38
- (0, vitest_1.it)('exports all standard functions', () => {
39
- for (const fn of ['useAuth', 'useSession', 'signIn', 'signOut', 'loginWithRedirect', 'logout']) {
40
- (0, vitest_1.expect)(output).toContain(fn);
41
- }
13
+ (0, vitest_1.it)('exports ZiteError', () => {
14
+ (0, vitest_1.expect)(output).toContain('ZiteError');
42
15
  });
43
16
  });
package/dist/esm/cli.js CHANGED
File without changes
@@ -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 { generateDbTs, generateApiTs, generateUserTs, generateAuthWrapperTs, generateBackendWrapperTs, generateAirtableTs, generateEmailSdk, } from "../sync/lib.js";
5
+ import { generateDbTs, generateApiTs, generateBackendWrapperTs, generateAirtableTs, generateEmailSdk, } from "../sync/lib.js";
6
6
  const debounceTimers = new Map();
7
7
  function debounce(key, fn, ms) {
8
8
  const existing = debounceTimers.get(key);
@@ -63,8 +63,7 @@ function getDeclaredEnvVarNames(appDir) {
63
63
  function regenerateAppTypedWrappers(appDir) {
64
64
  const outDir = join("apps", appDir, ".zite");
65
65
  mkdirSync(outDir, { recursive: true });
66
- writeFileSync(join(outDir, "user.ts"), generateUserTs());
67
- writeFileSync(join(outDir, "auth.ts"), generateAuthWrapperTs());
66
+ // user.ts and auth.ts no longer generated — User type is fixed in zitejs/auth
68
67
  // Email integration: generate the Email client at .zite/integrations/email.ts.
69
68
  // Resolved by the `zitejs/email` bundler/tsconfig alias (mirrors airtable's
70
69
  // `zitejs/integrations`), so endpoint code uses `import { Email } from 'zitejs/email'`.
@@ -1,5 +1,12 @@
1
1
  import type { NotificationsCreateParams, NotificationsCreateResult } from "../notifications/index.js";
2
- import type { MetaListUsersResult } from "../meta/index.js";
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";
@@ -35,11 +35,6 @@ export type EndpointFileInfo = {
35
35
  content?: string;
36
36
  };
37
37
  export declare function generateApiTs(endpointFiles: (string | EndpointFileInfo)[]): string | null;
38
- export declare function generateUserTs(usersTableFields?: Array<{
39
- name: string;
40
- type: string;
41
- }>): string;
42
- export declare function generateAuthWrapperTs(): string;
43
38
  export type AirtableLockField = {
44
39
  id: string;
45
40
  sdkName: string;
@@ -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 ZiteProjectUser {",
237
- " uuid: string;",
239
+ "export interface ZiteAuthUser {",
240
+ " id: string;",
241
+ " name: string;",
242
+ " email: string;",
238
243
  " firstName: string | null;",
239
244
  " lastName: string | null;",
240
- " email: string;",
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, createMetaClient } from 'zitejs/runtime';");
341
+ lines.push("import { createTableClient, createSqlClient, createNotificationsClient, createAuthClient } from 'zitejs/runtime';");
334
342
  lines.push("");
335
- for (const table of schema.tables) {
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 schema.tables) {
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(` meta: createMetaClient(),`);
369
+ lines.push(` auth: createAuthClient<ZiteAuthUser>(),`);
362
370
  lines.push("};");
363
371
  lines.push("");
364
372
  return lines.join("\n");
@@ -447,66 +455,6 @@ function tsTypeForField(field) {
447
455
  return FIELD_TYPE_MAP[field.type];
448
456
  return "string";
449
457
  }
450
- export function generateUserTs(usersTableFields) {
451
- const lines = [
452
- "// Auto-generated by zitejs generate. Do not edit manually.",
453
- "",
454
- ];
455
- if (usersTableFields && usersTableFields.length > 0) {
456
- lines.push("export type User = {");
457
- lines.push(" id: string;");
458
- lines.push(" email: string;");
459
- for (const field of usersTableFields) {
460
- const lowerName = field.name.toLowerCase();
461
- if (lowerName === "id" || lowerName === "email")
462
- continue;
463
- const fieldName = toCamelCase(field.name);
464
- const tsType = tsTypeForField(field);
465
- lines.push(` ${fieldName}: ${tsType};`);
466
- }
467
- lines.push(" [key: string]: unknown;");
468
- lines.push("};");
469
- }
470
- else {
471
- lines.push("export type User = {");
472
- lines.push(" id: string;");
473
- lines.push(" email: string;");
474
- lines.push(" firstName?: string;");
475
- lines.push(" lastName?: string;");
476
- lines.push(" [key: string]: unknown;");
477
- lines.push("};");
478
- }
479
- lines.push("");
480
- return lines.join("\n");
481
- }
482
- export function generateAuthWrapperTs() {
483
- return [
484
- "// Auto-generated auth re-exports. Do not edit manually.",
485
- "// The real auth logic lives in the zitejs npm package (zitejs/auth).",
486
- "// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
487
- "",
488
- "export {",
489
- " useAuth,",
490
- " useSession,",
491
- " signIn,",
492
- " signOut,",
493
- " signUp,",
494
- " loginWithRedirect,",
495
- " logout,",
496
- " updateProfile,",
497
- "} from 'zitejs/auth/base';",
498
- "",
499
- "export type {",
500
- " User,",
501
- " ZiteAppConfig,",
502
- " ZiteAuthenticationConfig,",
503
- " ZiteAuthMethods,",
504
- " ZiteAuthPage,",
505
- " ZiteAuthPageMessages,",
506
- "} from 'zitejs/auth/base';",
507
- "",
508
- ].join("\n");
509
- }
510
458
  const AIRTABLE_FIELD_TYPE_MAP = {
511
459
  // Writable fields
512
460
  singleLineText: "string",
@@ -711,7 +659,7 @@ export function generateBackendWrapperTs(envVarNames = []) {
711
659
  "// Re-exports createEndpoint with context.user typed to the app User.",
712
660
  "",
713
661
  "import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext as _ZiteScheduledContext, ZiteSchedule, ZiteWebhook } from 'zitejs/backend/base';",
714
- "import type { User } from './user';",
662
+ "import type { User } from 'zitejs/auth';",
715
663
  "",
716
664
  "export type { ZiteSchedule, ZiteWebhook };",
717
665
  "",
@@ -1,41 +1,14 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { generateAuthWrapperTs } from './lib.js';
3
- describe('generateAuthWrapperTs', () => {
4
- const output = generateAuthWrapperTs();
5
- it('imports from zitejs/auth/base (not zitejs/auth) to avoid circular alias', () => {
6
- expect(output).toContain("from 'zitejs/auth/base'");
7
- expect(output).not.toContain("from 'zitejs/auth';");
2
+ import { generateBackendWrapperTs } from './lib.js';
3
+ describe('generateBackendWrapperTs', () => {
4
+ const output = generateBackendWrapperTs();
5
+ it('imports User from zitejs/auth', () => {
6
+ expect(output).toContain("from 'zitejs/auth'");
8
7
  });
9
- it('re-exports all auth runtime functions', () => {
10
- for (const fn of [
11
- 'useSession',
12
- 'signIn',
13
- 'signOut',
14
- 'signUp',
15
- 'loginWithRedirect',
16
- 'logout',
17
- ]) {
18
- expect(output).toContain(fn);
19
- }
8
+ it('exports createEndpoint', () => {
9
+ expect(output).toContain('createEndpoint');
20
10
  });
21
- it('re-exports all config types', () => {
22
- for (const type of [
23
- 'User',
24
- 'ZiteAppConfig',
25
- 'ZiteAuthenticationConfig',
26
- 'ZiteAuthMethods',
27
- 'ZiteAuthPage',
28
- 'ZiteAuthPageMessages',
29
- ]) {
30
- expect(output).toContain(type);
31
- }
32
- });
33
- it('always exports useAuth as primary API', () => {
34
- expect(output).toContain('useAuth');
35
- });
36
- it('exports all standard functions', () => {
37
- for (const fn of ['useAuth', 'useSession', 'signIn', 'signOut', 'loginWithRedirect', 'logout']) {
38
- expect(output).toContain(fn);
39
- }
11
+ it('exports ZiteError', () => {
12
+ expect(output).toContain('ZiteError');
40
13
  });
41
14
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.86",
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
  ]
@@ -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; } });
@@ -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; } });
@@ -1,2 +0,0 @@
1
- export { createCaller } from '../caller/index.js';
2
- export type { EndpointConfig } from '../caller/index.js';
@@ -1 +0,0 @@
1
- export { createCaller } from '../caller/index.js';
@@ -1,2 +0,0 @@
1
- export { createTableClient } from '../runtime/index.js';
2
- export type { TableClient } from '../runtime/index.js';
@@ -1 +0,0 @@
1
- export { createTableClient } from '../runtime/index.js';