zitejs 0.9.116 → 0.9.118

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.
@@ -96,6 +96,12 @@ const PREBUNDLED_LIBS = {
96
96
  '@elevenlabs/elevenlabs-js': '__elevenlabs__.js',
97
97
  'resend': '__resend__.js',
98
98
  '@clickhouse/client-web': '__clickhouse__.js',
99
+ // Three packages, one module: the presigners take an S3Client instance, so a
100
+ // separate bundle each would hand them a structurally identical but distinct
101
+ // class. The worker bundles all three together for that reason.
102
+ '@aws-sdk/client-s3': '__aws-s3__.js',
103
+ '@aws-sdk/s3-request-presigner': '__aws-s3__.js',
104
+ '@aws-sdk/s3-presigned-post': '__aws-s3__.js',
99
105
  };
100
106
  exports.BASE_BUILD_OPTIONS = {
101
107
  bundle: true,
@@ -332,6 +332,5 @@ export interface EmailClient {
332
332
  * app's connected email integration key.
333
333
  */
334
334
  export declare function createEmailClient(integrationId: string): EmailClient;
335
- export type { NotificationLink, NotificationsCreateParams, NotificationsCreateResult, } from "../notifications/index.js";
336
335
  export { createCaller } from "../caller/index.js";
337
336
  export type { EndpointConfig } from "../caller/index.js";
@@ -412,26 +412,6 @@ function generateSchema(database, existingSchema) {
412
412
  }
413
413
  function generateSentinelSdkTypes() {
414
414
  return [
415
- "export interface NotificationLink {",
416
- " path?: string;",
417
- " params?: Record<string, string>;",
418
- "}",
419
- "",
420
- "export interface NotificationsCreateParams {",
421
- " recipients: string[];",
422
- " title: string;",
423
- " body?: string;",
424
- " link?: NotificationLink;",
425
- " path?: string;",
426
- " params?: Record<string, string>;",
427
- " payload?: Record<string, unknown>;",
428
- " idempotencyKey?: string;",
429
- "}",
430
- "",
431
- "export type NotificationsCreateResult =",
432
- " | { created: number }",
433
- " | { created: 0; preview: true; wouldCreate: number };",
434
- "",
435
415
  // Must match `AuthUser` in zitejs/runtime and `User` in zitejs/auth.
436
416
  "export interface ZiteAuthUser {",
437
417
  " id: string;",
@@ -638,10 +618,6 @@ function generateDbTs(inputSchema) {
638
618
  (table.name ? ` // "${commentSafe(table.name)}"` : ""));
639
619
  }
640
620
  lines.push(` sql: createSqlClient(),`);
641
- // No `notifications` here: it is a platform primitive, not something backed
642
- // by the project database, so it lives at `zitejs/notifications` alongside
643
- // `zitejs/pdf` and `zitejs/schedules`. Keeping it on `zite` cost a table
644
- // named "Notifications" its accessor — see RESERVED_TABLE_ACCESSORS.
645
621
  lines.push(` auth: createAuthClient<ZiteAuthUser>(),`);
646
622
  lines.push("};");
647
623
  lines.push("");
@@ -41,9 +41,9 @@ export declare function toSdkName(name: string): string;
41
41
  * `notifications` used to be here and no longer is: it was a platform
42
42
  * primitive hanging off `zite`, so a table named "Notifications" collided with
43
43
  * it and — because the sentinel was written last — lost its client entirely.
44
- * Moving it to `zitejs/notifications` removes the collision rather than
45
- * managing it, and frees the name for the table that wants it. Everything left
46
- * is genuinely backed by the project database.
44
+ * The platform client is unpublished for now, which removes the collision
45
+ * rather than managing it, and frees the name for the table that wants it.
46
+ * Everything left is genuinely backed by the project database.
47
47
  */
48
48
  export declare const RESERVED_TABLE_ACCESSORS: readonly ["sql", "auth"];
49
49
  /**
@@ -86,9 +86,9 @@ function toSdkName(name) {
86
86
  * `notifications` used to be here and no longer is: it was a platform
87
87
  * primitive hanging off `zite`, so a table named "Notifications" collided with
88
88
  * it and — because the sentinel was written last — lost its client entirely.
89
- * Moving it to `zitejs/notifications` removes the collision rather than
90
- * managing it, and frees the name for the table that wants it. Everything left
91
- * is genuinely backed by the project database.
89
+ * The platform client is unpublished for now, which removes the collision
90
+ * rather than managing it, and frees the name for the table that wants it.
91
+ * Everything left is genuinely backed by the project database.
92
92
  */
93
93
  exports.RESERVED_TABLE_ACCESSORS = ["sql", "auth"];
94
94
  /**
@@ -35,8 +35,8 @@ const recordTypeKeys = (source, typeName) => {
35
35
  // Sudzy Dashboard: a table named "Notifications" emitted a second
36
36
  // `notifications:` key and the platform client — written last — won, so the
37
37
  // table lost findAll and typed as `{ create(NotificationsCreateParams) }`.
38
- // The platform client has since moved to `zitejs/notifications`, so the name
39
- // belongs to the table again and there is nothing left to collide with.
38
+ // The platform client is unpublished, so the name belongs to the table
39
+ // again and there is nothing left to collide with.
40
40
  (0, vitest_1.it)("lets a table keep the notifications accessor", () => {
41
41
  const schema = (0, lib_js_1.generateSchema)(database([{ id: "tbl_1", name: "Notifications", fields: [] }]));
42
42
  (0, vitest_1.expect)(schema.tables[0].sdkName).toBe("notifications");
@@ -194,8 +194,8 @@ const recordTypeKeys = (source, typeName) => {
194
194
  // the only thing standing between it and a TS1117 it cannot build past.
195
195
  (0, vitest_1.it)("repairs a committed schema that already holds the collision", () => {
196
196
  // `sql`, not `notifications` — the latter stopped being a platform
197
- // accessor when the client moved to `zitejs/notifications`, so a schema
198
- // holding it is no longer a collision to repair.
197
+ // accessor when the client was unpublished, so a schema holding it is
198
+ // no longer a collision to repair.
199
199
  const source = (0, lib_js_1.generateDbTs)({
200
200
  tables: [
201
201
  { id: "tbl_1", sdkName: "sql", fields: [] },
@@ -59,6 +59,12 @@ const PREBUNDLED_LIBS = {
59
59
  '@elevenlabs/elevenlabs-js': '__elevenlabs__.js',
60
60
  'resend': '__resend__.js',
61
61
  '@clickhouse/client-web': '__clickhouse__.js',
62
+ // Three packages, one module: the presigners take an S3Client instance, so a
63
+ // separate bundle each would hand them a structurally identical but distinct
64
+ // class. The worker bundles all three together for that reason.
65
+ '@aws-sdk/client-s3': '__aws-s3__.js',
66
+ '@aws-sdk/s3-request-presigner': '__aws-s3__.js',
67
+ '@aws-sdk/s3-presigned-post': '__aws-s3__.js',
62
68
  };
63
69
  export const BASE_BUILD_OPTIONS = {
64
70
  bundle: true,
@@ -332,6 +332,5 @@ export interface EmailClient {
332
332
  * app's connected email integration key.
333
333
  */
334
334
  export declare function createEmailClient(integrationId: string): EmailClient;
335
- export type { NotificationLink, NotificationsCreateParams, NotificationsCreateResult, } from "../notifications/index.js";
336
335
  export { createCaller } from "../caller/index.js";
337
336
  export type { EndpointConfig } from "../caller/index.js";
@@ -399,26 +399,6 @@ export function generateSchema(database, existingSchema) {
399
399
  }
400
400
  function generateSentinelSdkTypes() {
401
401
  return [
402
- "export interface NotificationLink {",
403
- " path?: string;",
404
- " params?: Record<string, string>;",
405
- "}",
406
- "",
407
- "export interface NotificationsCreateParams {",
408
- " recipients: string[];",
409
- " title: string;",
410
- " body?: string;",
411
- " link?: NotificationLink;",
412
- " path?: string;",
413
- " params?: Record<string, string>;",
414
- " payload?: Record<string, unknown>;",
415
- " idempotencyKey?: string;",
416
- "}",
417
- "",
418
- "export type NotificationsCreateResult =",
419
- " | { created: number }",
420
- " | { created: 0; preview: true; wouldCreate: number };",
421
- "",
422
402
  // Must match `AuthUser` in zitejs/runtime and `User` in zitejs/auth.
423
403
  "export interface ZiteAuthUser {",
424
404
  " id: string;",
@@ -625,10 +605,6 @@ export function generateDbTs(inputSchema) {
625
605
  (table.name ? ` // "${commentSafe(table.name)}"` : ""));
626
606
  }
627
607
  lines.push(` sql: createSqlClient(),`);
628
- // No `notifications` here: it is a platform primitive, not something backed
629
- // by the project database, so it lives at `zitejs/notifications` alongside
630
- // `zitejs/pdf` and `zitejs/schedules`. Keeping it on `zite` cost a table
631
- // named "Notifications" its accessor — see RESERVED_TABLE_ACCESSORS.
632
608
  lines.push(` auth: createAuthClient<ZiteAuthUser>(),`);
633
609
  lines.push("};");
634
610
  lines.push("");
@@ -41,9 +41,9 @@ export declare function toSdkName(name: string): string;
41
41
  * `notifications` used to be here and no longer is: it was a platform
42
42
  * primitive hanging off `zite`, so a table named "Notifications" collided with
43
43
  * it and — because the sentinel was written last — lost its client entirely.
44
- * Moving it to `zitejs/notifications` removes the collision rather than
45
- * managing it, and frees the name for the table that wants it. Everything left
46
- * is genuinely backed by the project database.
44
+ * The platform client is unpublished for now, which removes the collision
45
+ * rather than managing it, and frees the name for the table that wants it.
46
+ * Everything left is genuinely backed by the project database.
47
47
  */
48
48
  export declare const RESERVED_TABLE_ACCESSORS: readonly ["sql", "auth"];
49
49
  /**
@@ -76,9 +76,9 @@ export function toSdkName(name) {
76
76
  * `notifications` used to be here and no longer is: it was a platform
77
77
  * primitive hanging off `zite`, so a table named "Notifications" collided with
78
78
  * it and — because the sentinel was written last — lost its client entirely.
79
- * Moving it to `zitejs/notifications` removes the collision rather than
80
- * managing it, and frees the name for the table that wants it. Everything left
81
- * is genuinely backed by the project database.
79
+ * The platform client is unpublished for now, which removes the collision
80
+ * rather than managing it, and frees the name for the table that wants it.
81
+ * Everything left is genuinely backed by the project database.
82
82
  */
83
83
  export const RESERVED_TABLE_ACCESSORS = ["sql", "auth"];
84
84
  /**
@@ -33,8 +33,8 @@ describe("reserved platform accessors", () => {
33
33
  // Sudzy Dashboard: a table named "Notifications" emitted a second
34
34
  // `notifications:` key and the platform client — written last — won, so the
35
35
  // table lost findAll and typed as `{ create(NotificationsCreateParams) }`.
36
- // The platform client has since moved to `zitejs/notifications`, so the name
37
- // belongs to the table again and there is nothing left to collide with.
36
+ // The platform client is unpublished, so the name belongs to the table
37
+ // again and there is nothing left to collide with.
38
38
  it("lets a table keep the notifications accessor", () => {
39
39
  const schema = generateSchema(database([{ id: "tbl_1", name: "Notifications", fields: [] }]));
40
40
  expect(schema.tables[0].sdkName).toBe("notifications");
@@ -192,8 +192,8 @@ describe("normalizeSchemaNames", () => {
192
192
  // the only thing standing between it and a TS1117 it cannot build past.
193
193
  it("repairs a committed schema that already holds the collision", () => {
194
194
  // `sql`, not `notifications` — the latter stopped being a platform
195
- // accessor when the client moved to `zitejs/notifications`, so a schema
196
- // holding it is no longer a collision to repair.
195
+ // accessor when the client was unpublished, so a schema holding it is
196
+ // no longer a collision to repair.
197
197
  const source = generateDbTs({
198
198
  tables: [
199
199
  { id: "tbl_1", sdkName: "sql", fields: [] },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.116",
4
- "description": "The Zite framework \u2014 build apps on Zite Database",
3
+ "version": "0.9.118",
4
+ "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/esm/index.js",
@@ -74,11 +74,6 @@
74
74
  "import": "./dist/esm/schedules/index.js",
75
75
  "require": "./dist/cjs/schedules/index.js"
76
76
  },
77
- "./notifications": {
78
- "types": "./dist/esm/notifications/index.d.ts",
79
- "import": "./dist/esm/notifications/index.js",
80
- "require": "./dist/cjs/notifications/index.js"
81
- },
82
77
  "./sync": {
83
78
  "types": "./dist/esm/sync/index.d.ts",
84
79
  "import": "./dist/esm/sync/index.js",
@@ -136,9 +131,6 @@
136
131
  "schedules": [
137
132
  "dist/esm/schedules/index.d.ts"
138
133
  ],
139
- "notifications": [
140
- "dist/esm/notifications/index.d.ts"
141
- ],
142
134
  "vite-plugin": [
143
135
  "dist/esm/vite/index.d.ts"
144
136
  ]
@@ -1 +0,0 @@
1
- export {};
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- /**
5
- * The signed-out redirect on internal apps.
6
- *
7
- * A separate file from `index.test.ts` because it has to replace
8
- * `better-auth/react` wholesale to drive `useSession`, and that would strip the
9
- * real client the export tests next door assert against.
10
- *
11
- * The value here is entirely in WHICH signed-out renders it reacts to. An
12
- * external app has a real logged-out state, and an app built before the
13
- * platform sent an access mode tells us nothing — redirecting either turns a
14
- * working public page into a forced sign-in.
15
- */
16
- const { useSessionMock } = vitest_1.vi.hoisted(() => ({ useSessionMock: vitest_1.vi.fn() }));
17
- vitest_1.vi.mock('better-auth/react', () => ({
18
- createAuthClient: () => ({
19
- useSession: useSessionMock,
20
- signIn: {},
21
- signUp: {},
22
- signOut: vitest_1.vi.fn(),
23
- updateUser: vitest_1.vi.fn(),
24
- }),
25
- }));
26
- vitest_1.vi.mock('better-auth/client/plugins', () => ({
27
- magicLinkClient: () => ({}),
28
- inferAdditionalFields: () => ({}),
29
- }));
30
- // `useAuth` takes only `useEffect` from React. Running it inline is the whole
31
- // of what a render would do here, and avoids pulling in a renderer.
32
- vitest_1.vi.mock('react', () => ({ useEffect: (fn) => fn() }));
33
- const index_js_1 = require("./index.js");
34
- const APP_URL = 'https://app.zite.so/dashboard';
35
- function stubLocation(href) {
36
- const location = { pathname: new URL(href).pathname, href };
37
- vitest_1.vi.stubGlobal('window', { location });
38
- return location;
39
- }
40
- const signedOut = { data: null, isPending: false };
41
- (0, vitest_1.beforeEach)(() => {
42
- delete process.env.ZITE_ACCESS_MODE;
43
- });
44
- (0, vitest_1.afterEach)(() => {
45
- delete process.env.ZITE_ACCESS_MODE;
46
- vitest_1.vi.unstubAllGlobals();
47
- useSessionMock.mockReset();
48
- });
49
- const render = (session, { accessMode, href = APP_URL } = {}) => {
50
- if (accessMode !== undefined)
51
- process.env.ZITE_ACCESS_MODE = accessMode;
52
- const location = stubLocation(href);
53
- useSessionMock.mockReturnValue(session);
54
- return { result: (0, index_js_1.useAuth)(), location };
55
- };
56
- (0, vitest_1.describe)('useAuth signed-out handling', () => {
57
- (0, vitest_1.it)('sends a signed-out visitor on an internal app to sign-in', () => {
58
- const { result, location } = render(signedOut, { accessMode: 'internal' });
59
- (0, vitest_1.expect)(location.href.startsWith('/auth/login')).toBe(true);
60
- // Reported as loading rather than signed out: the signed-out branch of an
61
- // internal app is the empty screen this exists to prevent.
62
- (0, vitest_1.expect)(result.isLoading).toBe(true);
63
- });
64
- (0, vitest_1.it)('leaves a signed-out visitor on an external app alone', () => {
65
- const { result, location } = render(signedOut, { accessMode: 'external' });
66
- (0, vitest_1.expect)(location.href).toBe(APP_URL);
67
- (0, vitest_1.expect)(result.isLoading).toBe(false);
68
- (0, vitest_1.expect)(result.user).toBe(null);
69
- });
70
- // Every app published before the platform started sending an access mode.
71
- (0, vitest_1.it)('leaves an app that never declared an access mode alone', () => {
72
- const { result, location } = render(signedOut);
73
- (0, vitest_1.expect)(location.href).toBe(APP_URL);
74
- (0, vitest_1.expect)(result.isLoading).toBe(false);
75
- });
76
- (0, vitest_1.it)('does not redirect while the session is still resolving', () => {
77
- const { result, location } = render({ data: null, isPending: true }, { accessMode: 'internal' });
78
- (0, vitest_1.expect)(location.href).toBe(APP_URL);
79
- (0, vitest_1.expect)(result.isLoading).toBe(true);
80
- });
81
- (0, vitest_1.it)('does not redirect a signed-in visitor', () => {
82
- const { result, location } = render({ data: { user: { id: 'u1', email: 'a@b.com' } }, isPending: false }, { accessMode: 'internal' });
83
- (0, vitest_1.expect)(location.href).toBe(APP_URL);
84
- (0, vitest_1.expect)(result.isLoading).toBe(false);
85
- (0, vitest_1.expect)(result.user).toMatchObject({ id: 'u1' });
86
- });
87
- // `loginWithRedirect` refuses to navigate away from an auth page, so claiming
88
- // a redirect here would hang the caller on `isLoading` forever.
89
- (0, vitest_1.it)('does not claim to be loading on an auth page it cannot leave', () => {
90
- const { result } = render(signedOut, {
91
- accessMode: 'internal',
92
- href: 'https://app.zite.so/auth/login',
93
- });
94
- (0, vitest_1.expect)(result.isLoading).toBe(false);
95
- });
96
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,94 +0,0 @@
1
- import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest';
2
- /**
3
- * The signed-out redirect on internal apps.
4
- *
5
- * A separate file from `index.test.ts` because it has to replace
6
- * `better-auth/react` wholesale to drive `useSession`, and that would strip the
7
- * real client the export tests next door assert against.
8
- *
9
- * The value here is entirely in WHICH signed-out renders it reacts to. An
10
- * external app has a real logged-out state, and an app built before the
11
- * platform sent an access mode tells us nothing — redirecting either turns a
12
- * working public page into a forced sign-in.
13
- */
14
- const { useSessionMock } = vi.hoisted(() => ({ useSessionMock: vi.fn() }));
15
- vi.mock('better-auth/react', () => ({
16
- createAuthClient: () => ({
17
- useSession: useSessionMock,
18
- signIn: {},
19
- signUp: {},
20
- signOut: vi.fn(),
21
- updateUser: vi.fn(),
22
- }),
23
- }));
24
- vi.mock('better-auth/client/plugins', () => ({
25
- magicLinkClient: () => ({}),
26
- inferAdditionalFields: () => ({}),
27
- }));
28
- // `useAuth` takes only `useEffect` from React. Running it inline is the whole
29
- // of what a render would do here, and avoids pulling in a renderer.
30
- vi.mock('react', () => ({ useEffect: (fn) => fn() }));
31
- import { useAuth } from './index.js';
32
- const APP_URL = 'https://app.zite.so/dashboard';
33
- function stubLocation(href) {
34
- const location = { pathname: new URL(href).pathname, href };
35
- vi.stubGlobal('window', { location });
36
- return location;
37
- }
38
- const signedOut = { data: null, isPending: false };
39
- beforeEach(() => {
40
- delete process.env.ZITE_ACCESS_MODE;
41
- });
42
- afterEach(() => {
43
- delete process.env.ZITE_ACCESS_MODE;
44
- vi.unstubAllGlobals();
45
- useSessionMock.mockReset();
46
- });
47
- const render = (session, { accessMode, href = APP_URL } = {}) => {
48
- if (accessMode !== undefined)
49
- process.env.ZITE_ACCESS_MODE = accessMode;
50
- const location = stubLocation(href);
51
- useSessionMock.mockReturnValue(session);
52
- return { result: useAuth(), location };
53
- };
54
- describe('useAuth signed-out handling', () => {
55
- it('sends a signed-out visitor on an internal app to sign-in', () => {
56
- const { result, location } = render(signedOut, { accessMode: 'internal' });
57
- expect(location.href.startsWith('/auth/login')).toBe(true);
58
- // Reported as loading rather than signed out: the signed-out branch of an
59
- // internal app is the empty screen this exists to prevent.
60
- expect(result.isLoading).toBe(true);
61
- });
62
- it('leaves a signed-out visitor on an external app alone', () => {
63
- const { result, location } = render(signedOut, { accessMode: 'external' });
64
- expect(location.href).toBe(APP_URL);
65
- expect(result.isLoading).toBe(false);
66
- expect(result.user).toBe(null);
67
- });
68
- // Every app published before the platform started sending an access mode.
69
- it('leaves an app that never declared an access mode alone', () => {
70
- const { result, location } = render(signedOut);
71
- expect(location.href).toBe(APP_URL);
72
- expect(result.isLoading).toBe(false);
73
- });
74
- it('does not redirect while the session is still resolving', () => {
75
- const { result, location } = render({ data: null, isPending: true }, { accessMode: 'internal' });
76
- expect(location.href).toBe(APP_URL);
77
- expect(result.isLoading).toBe(true);
78
- });
79
- it('does not redirect a signed-in visitor', () => {
80
- const { result, location } = render({ data: { user: { id: 'u1', email: 'a@b.com' } }, isPending: false }, { accessMode: 'internal' });
81
- expect(location.href).toBe(APP_URL);
82
- expect(result.isLoading).toBe(false);
83
- expect(result.user).toMatchObject({ id: 'u1' });
84
- });
85
- // `loginWithRedirect` refuses to navigate away from an auth page, so claiming
86
- // a redirect here would hang the caller on `isLoading` forever.
87
- it('does not claim to be loading on an auth page it cannot leave', () => {
88
- const { result } = render(signedOut, {
89
- accessMode: 'internal',
90
- href: 'https://app.zite.so/auth/login',
91
- });
92
- expect(result.isLoading).toBe(false);
93
- });
94
- });