zitejs 0.9.116 → 0.9.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/runtime/index.d.ts +0 -1
- package/dist/cjs/sync/lib.js +0 -24
- package/dist/cjs/sync/sdkNames.d.ts +3 -3
- package/dist/cjs/sync/sdkNames.js +3 -3
- package/dist/cjs/sync/sdkNames.test.js +4 -4
- package/dist/esm/runtime/index.d.ts +0 -1
- package/dist/esm/sync/lib.js +0 -24
- package/dist/esm/sync/sdkNames.d.ts +3 -3
- package/dist/esm/sync/sdkNames.js +3 -3
- package/dist/esm/sync/sdkNames.test.js +4 -4
- package/package.json +1 -9
- package/dist/cjs/auth/useAuth.test.d.ts +0 -1
- package/dist/cjs/auth/useAuth.test.js +0 -96
- package/dist/cjs/meta/index.d.ts +0 -14
- package/dist/cjs/meta/index.js +0 -12
- package/dist/cjs/notifications/index.d.ts +0 -25
- package/dist/cjs/notifications/index.js +0 -12
- package/dist/esm/auth/useAuth.test.d.ts +0 -1
- package/dist/esm/auth/useAuth.test.js +0 -94
- package/dist/esm/meta/index.d.ts +0 -14
- package/dist/esm/meta/index.js +0 -8
- package/dist/esm/notifications/index.d.ts +0 -25
- package/dist/esm/notifications/index.js +0 -8
|
@@ -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";
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -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
|
-
*
|
|
45
|
-
* managing it, and frees the name for the table that wants it.
|
|
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
|
-
*
|
|
90
|
-
* managing it, and frees the name for the table that wants it.
|
|
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
|
|
39
|
-
//
|
|
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
|
|
198
|
-
//
|
|
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: [] },
|
|
@@ -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";
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -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
|
-
*
|
|
45
|
-
* managing it, and frees the name for the table that wants it.
|
|
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
|
-
*
|
|
80
|
-
* managing it, and frees the name for the table that wants it.
|
|
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
|
|
37
|
-
//
|
|
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
|
|
196
|
-
//
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zitejs",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.117",
|
|
4
4
|
"description": "The Zite framework \u2014 build apps on Zite Database",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/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
|
-
});
|
package/dist/cjs/meta/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type ZiteProjectUser = {
|
|
2
|
-
uuid: string;
|
|
3
|
-
firstName: string | null;
|
|
4
|
-
lastName: string | null;
|
|
5
|
-
email: string;
|
|
6
|
-
profilePictureUrl: string | null;
|
|
7
|
-
};
|
|
8
|
-
export type MetaListUsersResult = {
|
|
9
|
-
users: ZiteProjectUser[];
|
|
10
|
-
};
|
|
11
|
-
export declare class ZiteMeta {
|
|
12
|
-
static listUsers(): Promise<MetaListUsersResult>;
|
|
13
|
-
}
|
|
14
|
-
export declare const Meta: typeof ZiteMeta;
|
package/dist/cjs/meta/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Meta = exports.ZiteMeta = void 0;
|
|
4
|
-
const sdkCall_js_1 = require("../internal/sdkCall.js");
|
|
5
|
-
const META_SDK_INTEGRATION_ID = '__meta__';
|
|
6
|
-
class ZiteMeta {
|
|
7
|
-
static listUsers() {
|
|
8
|
-
return (0, sdkCall_js_1.getSdkCall)()(META_SDK_INTEGRATION_ID, 'ZiteMeta', 'listUsers', {});
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.ZiteMeta = ZiteMeta;
|
|
12
|
-
exports.Meta = ZiteMeta;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface NotificationLink {
|
|
2
|
-
path?: string;
|
|
3
|
-
params?: Record<string, string>;
|
|
4
|
-
}
|
|
5
|
-
export type NotificationsCreateParams = {
|
|
6
|
-
recipients: string[];
|
|
7
|
-
title: string;
|
|
8
|
-
body?: string;
|
|
9
|
-
link?: NotificationLink;
|
|
10
|
-
path?: string;
|
|
11
|
-
params?: Record<string, string>;
|
|
12
|
-
payload?: Record<string, unknown>;
|
|
13
|
-
idempotencyKey?: string;
|
|
14
|
-
};
|
|
15
|
-
export type NotificationsCreateResult = {
|
|
16
|
-
created: number;
|
|
17
|
-
} | {
|
|
18
|
-
created: 0;
|
|
19
|
-
preview: true;
|
|
20
|
-
wouldCreate: number;
|
|
21
|
-
};
|
|
22
|
-
export declare class ZiteNotifications {
|
|
23
|
-
static create(params: NotificationsCreateParams): Promise<NotificationsCreateResult>;
|
|
24
|
-
}
|
|
25
|
-
export declare const Notifications: typeof ZiteNotifications;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Notifications = exports.ZiteNotifications = void 0;
|
|
4
|
-
const sdkCall_js_1 = require("../internal/sdkCall.js");
|
|
5
|
-
const NOTIFICATIONS_SDK_INTEGRATION_ID = '__notifications__';
|
|
6
|
-
class ZiteNotifications {
|
|
7
|
-
static create(params) {
|
|
8
|
-
return (0, sdkCall_js_1.getSdkCall)()(NOTIFICATIONS_SDK_INTEGRATION_ID, 'ZiteNotifications', 'create', params);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.ZiteNotifications = ZiteNotifications;
|
|
12
|
-
exports.Notifications = ZiteNotifications;
|
|
@@ -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
|
-
});
|
package/dist/esm/meta/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type ZiteProjectUser = {
|
|
2
|
-
uuid: string;
|
|
3
|
-
firstName: string | null;
|
|
4
|
-
lastName: string | null;
|
|
5
|
-
email: string;
|
|
6
|
-
profilePictureUrl: string | null;
|
|
7
|
-
};
|
|
8
|
-
export type MetaListUsersResult = {
|
|
9
|
-
users: ZiteProjectUser[];
|
|
10
|
-
};
|
|
11
|
-
export declare class ZiteMeta {
|
|
12
|
-
static listUsers(): Promise<MetaListUsersResult>;
|
|
13
|
-
}
|
|
14
|
-
export declare const Meta: typeof ZiteMeta;
|
package/dist/esm/meta/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface NotificationLink {
|
|
2
|
-
path?: string;
|
|
3
|
-
params?: Record<string, string>;
|
|
4
|
-
}
|
|
5
|
-
export type NotificationsCreateParams = {
|
|
6
|
-
recipients: string[];
|
|
7
|
-
title: string;
|
|
8
|
-
body?: string;
|
|
9
|
-
link?: NotificationLink;
|
|
10
|
-
path?: string;
|
|
11
|
-
params?: Record<string, string>;
|
|
12
|
-
payload?: Record<string, unknown>;
|
|
13
|
-
idempotencyKey?: string;
|
|
14
|
-
};
|
|
15
|
-
export type NotificationsCreateResult = {
|
|
16
|
-
created: number;
|
|
17
|
-
} | {
|
|
18
|
-
created: 0;
|
|
19
|
-
preview: true;
|
|
20
|
-
wouldCreate: number;
|
|
21
|
-
};
|
|
22
|
-
export declare class ZiteNotifications {
|
|
23
|
-
static create(params: NotificationsCreateParams): Promise<NotificationsCreateResult>;
|
|
24
|
-
}
|
|
25
|
-
export declare const Notifications: typeof ZiteNotifications;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { getSdkCall } from '../internal/sdkCall.js';
|
|
2
|
-
const NOTIFICATIONS_SDK_INTEGRATION_ID = '__notifications__';
|
|
3
|
-
export class ZiteNotifications {
|
|
4
|
-
static create(params) {
|
|
5
|
-
return getSdkCall()(NOTIFICATIONS_SDK_INTEGRATION_ID, 'ZiteNotifications', 'create', params);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export const Notifications = ZiteNotifications;
|