zitejs 0.10.1-device.0 → 0.10.1
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/auth/actions.js +0 -2
- package/dist/cjs/auth/client.js +0 -5
- package/dist/cjs/auth/useAuth.test.js +0 -1
- package/dist/cjs/caller/index.js +16 -5
- package/dist/cjs/check/index.js +10 -4
- package/dist/cjs/start/build/entries.d.ts +5 -0
- package/dist/cjs/start/build/entries.js +16 -8
- package/dist/cjs/start/build/roleIds.d.ts +11 -0
- package/dist/cjs/start/build/roleIds.js +59 -0
- package/dist/cjs/start/describe/schema.d.ts +574 -0
- package/dist/cjs/start/describe/schema.js +178 -0
- package/dist/cjs/start/protocol.d.ts +7 -0
- package/dist/cjs/start/protocol.js +27 -3
- package/dist/cjs/start/serve/authHookNames.d.ts +3 -0
- package/dist/cjs/start/serve/authHookNames.js +13 -0
- package/dist/cjs/vite/index.js +0 -41
- package/dist/cjs/vite/index.test.js +0 -36
- package/dist/esm/auth/actions.js +0 -2
- package/dist/esm/auth/client.js +0 -5
- package/dist/esm/auth/useAuth.test.js +0 -1
- package/dist/esm/caller/index.js +15 -4
- package/dist/esm/check/index.js +10 -4
- package/dist/esm/start/build/entries.d.ts +5 -0
- package/dist/esm/start/build/entries.js +15 -8
- package/dist/esm/start/build/roleIds.d.ts +11 -0
- package/dist/esm/start/build/roleIds.js +54 -0
- package/dist/esm/start/build/vite.js +0 -4
- package/dist/esm/start/classicOnly.js +3 -3
- package/dist/esm/start/describe/schema.d.ts +574 -0
- package/dist/esm/start/describe/schema.js +175 -0
- package/dist/esm/start/describe/schema.test-d.d.ts +1 -0
- package/dist/esm/start/describe/schema.test-d.js +23 -0
- package/dist/esm/start/index.d.ts +1 -1
- package/dist/esm/start/protocol.d.ts +7 -0
- package/dist/esm/start/protocol.js +17 -2
- package/dist/esm/start/roles.d.ts +10 -2
- package/dist/esm/start/serve/authHookNames.d.ts +3 -0
- package/dist/esm/start/serve/authHookNames.js +9 -0
- package/dist/esm/start/serve/authHooks.d.ts +2 -4
- package/dist/esm/start/serve/authHooks.js +2 -8
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/dist/esm/vite/index.js +0 -41
- package/dist/esm/vite/index.test.js +0 -36
- package/package.json +5 -13
- package/tsconfig/start.json +40 -0
- package/dist/cjs/internal/browserMode.d.ts +0 -2
- package/dist/cjs/internal/browserMode.js +0 -18
- package/dist/cjs/internal/deviceCache.d.ts +0 -11
- package/dist/cjs/internal/deviceCache.js +0 -29
- package/dist/cjs/query/deviceCache.d.ts +0 -14
- package/dist/cjs/query/deviceCache.js +0 -304
- package/dist/cjs/query/index.d.ts +0 -19
- package/dist/cjs/query/index.js +0 -369
- package/dist/esm/internal/browserMode.d.ts +0 -2
- package/dist/esm/internal/browserMode.js +0 -15
- package/dist/esm/internal/deviceCache.d.ts +0 -11
- package/dist/esm/internal/deviceCache.js +0 -24
- package/dist/esm/query/deviceCache.d.ts +0 -14
- package/dist/esm/query/deviceCache.js +0 -301
- package/dist/esm/query/index.d.ts +0 -19
- package/dist/esm/query/index.js +0 -366
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeOutputSchema = exports.authHookNameSchema = exports.describedWorkflowSchema = exports.describedTriggerSchema = exports.describedScheduleSchema = exports.describedPageSchema = exports.describedRouteSchema = exports.describedFunctionSchema = exports.describedAccessSchema = void 0;
|
|
4
|
+
// Describe's answer as zod, for the platform to check a build's description with before it reads one: the shape of
|
|
5
|
+
// `Description`, nothing of the platform's limits. Imports only zod and the auth hook names, so
|
|
6
|
+
// zitejs/start/protocol stays light; schema.test-d.ts holds it to the type.
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const authHookNames_js_1 = require("../serve/authHookNames.js");
|
|
9
|
+
exports.describedAccessSchema = zod_1.z.object({
|
|
10
|
+
kind: zod_1.z.enum(['signedIn', 'anyone', 'webhook', 'none']),
|
|
11
|
+
roles: zod_1.z.array(zod_1.z.string()),
|
|
12
|
+
paused: zod_1.z.literal(true).optional(),
|
|
13
|
+
});
|
|
14
|
+
exports.describedFunctionSchema = zod_1.z.object({
|
|
15
|
+
id: zod_1.z.string(),
|
|
16
|
+
name: zod_1.z.string().optional(),
|
|
17
|
+
file: zod_1.z.string().optional(),
|
|
18
|
+
method: zod_1.z.string().optional(),
|
|
19
|
+
description: zod_1.z.string().optional(),
|
|
20
|
+
access: exports.describedAccessSchema,
|
|
21
|
+
/** The validator's JSON Schema, `{ unrepresentable: true }` or `{ opaque: true }`. */
|
|
22
|
+
input: zod_1.z.unknown().optional(),
|
|
23
|
+
problems: zod_1.z.array(zod_1.z.string()),
|
|
24
|
+
});
|
|
25
|
+
exports.describedRouteSchema = zod_1.z.object({
|
|
26
|
+
path: zod_1.z.string(),
|
|
27
|
+
file: zod_1.z.string().optional(),
|
|
28
|
+
description: zod_1.z.string().optional(),
|
|
29
|
+
methods: zod_1.z.record(zod_1.z.string(), exports.describedAccessSchema),
|
|
30
|
+
problems: zod_1.z.array(zod_1.z.string()),
|
|
31
|
+
});
|
|
32
|
+
exports.describedPageSchema = zod_1.z.object({
|
|
33
|
+
id: zod_1.z.string(),
|
|
34
|
+
path: zod_1.z.string(),
|
|
35
|
+
file: zod_1.z.string().optional(),
|
|
36
|
+
});
|
|
37
|
+
const dayOfWeek = zod_1.z.enum(['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']);
|
|
38
|
+
const activeWindow = zod_1.z.object({
|
|
39
|
+
hoursRange: zod_1.z.object({ from: zod_1.z.string(), to: zod_1.z.string() }).optional(),
|
|
40
|
+
daysOfWeek: zod_1.z.array(dayOfWeek).optional(),
|
|
41
|
+
});
|
|
42
|
+
/** `ZiteSchedule`, as an automation declares it. */
|
|
43
|
+
exports.describedScheduleSchema = zod_1.z.discriminatedUnion('scheduleType', [
|
|
44
|
+
zod_1.z.object({
|
|
45
|
+
scheduleType: zod_1.z.literal('recurring'),
|
|
46
|
+
schedule: zod_1.z.discriminatedUnion('frequency', [
|
|
47
|
+
zod_1.z.object({
|
|
48
|
+
frequency: zod_1.z.literal('minutely'),
|
|
49
|
+
interval: zod_1.z.number(),
|
|
50
|
+
activeWindow: activeWindow.optional(),
|
|
51
|
+
}),
|
|
52
|
+
zod_1.z.object({
|
|
53
|
+
frequency: zod_1.z.literal('hourly'),
|
|
54
|
+
interval: zod_1.z.number(),
|
|
55
|
+
minute: zod_1.z.number().optional(),
|
|
56
|
+
activeWindow: activeWindow.optional(),
|
|
57
|
+
}),
|
|
58
|
+
zod_1.z.object({
|
|
59
|
+
frequency: zod_1.z.literal('daily'),
|
|
60
|
+
interval: zod_1.z.number(),
|
|
61
|
+
times: zod_1.z.array(zod_1.z.string()),
|
|
62
|
+
}),
|
|
63
|
+
zod_1.z.object({
|
|
64
|
+
frequency: zod_1.z.literal('weekly'),
|
|
65
|
+
interval: zod_1.z.number(),
|
|
66
|
+
daysOfWeek: zod_1.z.array(dayOfWeek),
|
|
67
|
+
times: zod_1.z.array(zod_1.z.string()),
|
|
68
|
+
}),
|
|
69
|
+
zod_1.z.object({
|
|
70
|
+
frequency: zod_1.z.literal('monthly'),
|
|
71
|
+
interval: zod_1.z.literal(1),
|
|
72
|
+
monthlyDay: zod_1.z.discriminatedUnion('type', [
|
|
73
|
+
zod_1.z.object({
|
|
74
|
+
type: zod_1.z.literal('dayOfMonth'),
|
|
75
|
+
day: zod_1.z.union([zod_1.z.number(), zod_1.z.literal('last')]),
|
|
76
|
+
}),
|
|
77
|
+
zod_1.z.object({
|
|
78
|
+
type: zod_1.z.literal('weekdayOccurrence'),
|
|
79
|
+
weekday: dayOfWeek,
|
|
80
|
+
occurrence: zod_1.z.union([zod_1.z.literal([1, 2, 3, 4]), zod_1.z.literal('last')]),
|
|
81
|
+
}),
|
|
82
|
+
]),
|
|
83
|
+
times: zod_1.z.array(zod_1.z.string()),
|
|
84
|
+
}),
|
|
85
|
+
]),
|
|
86
|
+
endPolicy: zod_1.z
|
|
87
|
+
.discriminatedUnion('type', [
|
|
88
|
+
zod_1.z.object({ type: zod_1.z.literal('never') }),
|
|
89
|
+
zod_1.z.object({ type: zod_1.z.literal('onDate'), endAt: zod_1.z.string() }),
|
|
90
|
+
zod_1.z.object({
|
|
91
|
+
type: zod_1.z.literal('afterOccurrences'),
|
|
92
|
+
occurrences: zod_1.z.number(),
|
|
93
|
+
}),
|
|
94
|
+
])
|
|
95
|
+
.optional(),
|
|
96
|
+
overlapPolicy: zod_1.z.enum(['skip', 'allow']).optional(),
|
|
97
|
+
timezone: zod_1.z.string(),
|
|
98
|
+
paused: zod_1.z.boolean().optional(),
|
|
99
|
+
}),
|
|
100
|
+
zod_1.z.object({
|
|
101
|
+
scheduleType: zod_1.z.literal('oneTime'),
|
|
102
|
+
fireAt: zod_1.z.string(),
|
|
103
|
+
timezone: zod_1.z.string(),
|
|
104
|
+
paused: zod_1.z.boolean().optional(),
|
|
105
|
+
}),
|
|
106
|
+
]);
|
|
107
|
+
const absent = zod_1.z.never().optional();
|
|
108
|
+
const shown = { label: zod_1.z.string().optional(), paused: zod_1.z.boolean().optional() };
|
|
109
|
+
/**
|
|
110
|
+
* `ZiteTrigger`, as an automation declares it, without a provider trigger's `subscribe` and `unsubscribe`. Database
|
|
111
|
+
* and form triggers are in it: describe reports one it refuses.
|
|
112
|
+
*/
|
|
113
|
+
exports.describedTriggerSchema = zod_1.z.union([
|
|
114
|
+
zod_1.z.object({
|
|
115
|
+
integration: zod_1.z.string(),
|
|
116
|
+
...shown,
|
|
117
|
+
every: absent,
|
|
118
|
+
events: absent,
|
|
119
|
+
table: absent,
|
|
120
|
+
form: absent,
|
|
121
|
+
}),
|
|
122
|
+
zod_1.z.object({
|
|
123
|
+
integration: zod_1.z.string(),
|
|
124
|
+
events: zod_1.z.array(zod_1.z.string()),
|
|
125
|
+
...shown,
|
|
126
|
+
every: absent,
|
|
127
|
+
table: absent,
|
|
128
|
+
form: absent,
|
|
129
|
+
}),
|
|
130
|
+
zod_1.z.object({
|
|
131
|
+
every: zod_1.z.string(),
|
|
132
|
+
integration: zod_1.z.string().optional(),
|
|
133
|
+
...shown,
|
|
134
|
+
events: absent,
|
|
135
|
+
table: absent,
|
|
136
|
+
form: absent,
|
|
137
|
+
}),
|
|
138
|
+
zod_1.z.object({
|
|
139
|
+
table: zod_1.z.string(),
|
|
140
|
+
on: zod_1.z.array(zod_1.z.enum(['created', 'updated', 'deleted'])),
|
|
141
|
+
fields: zod_1.z.array(zod_1.z.string()).optional(),
|
|
142
|
+
...shown,
|
|
143
|
+
integration: absent,
|
|
144
|
+
every: absent,
|
|
145
|
+
events: absent,
|
|
146
|
+
form: absent,
|
|
147
|
+
}),
|
|
148
|
+
zod_1.z.object({
|
|
149
|
+
form: zod_1.z.string(),
|
|
150
|
+
on: zod_1.z.array(zod_1.z.literal('submitted')),
|
|
151
|
+
...shown,
|
|
152
|
+
integration: absent,
|
|
153
|
+
every: absent,
|
|
154
|
+
events: absent,
|
|
155
|
+
table: absent,
|
|
156
|
+
}),
|
|
157
|
+
]);
|
|
158
|
+
exports.describedWorkflowSchema = zod_1.z.object({
|
|
159
|
+
id: zod_1.z.string(),
|
|
160
|
+
file: zod_1.z.string(),
|
|
161
|
+
description: zod_1.z.string().optional(),
|
|
162
|
+
schedule: exports.describedScheduleSchema.optional(),
|
|
163
|
+
trigger: exports.describedTriggerSchema.optional(),
|
|
164
|
+
registration: zod_1.z
|
|
165
|
+
.object({ unsubscribe: zod_1.z.boolean(), hash: zod_1.z.string(), module: zod_1.z.string() })
|
|
166
|
+
.optional(),
|
|
167
|
+
problems: zod_1.z.array(zod_1.z.string()),
|
|
168
|
+
});
|
|
169
|
+
exports.authHookNameSchema = zod_1.z.enum(authHookNames_js_1.AUTH_HOOK_NAMES);
|
|
170
|
+
/** What `zitejs describe` and a build's describe invoke answer. */
|
|
171
|
+
exports.describeOutputSchema = zod_1.z.object({
|
|
172
|
+
functions: zod_1.z.array(exports.describedFunctionSchema),
|
|
173
|
+
routes: zod_1.z.array(exports.describedRouteSchema),
|
|
174
|
+
pages: zod_1.z.array(exports.describedPageSchema),
|
|
175
|
+
workflows: zod_1.z.array(exports.describedWorkflowSchema),
|
|
176
|
+
authHooks: zod_1.z.array(exports.authHookNameSchema),
|
|
177
|
+
problems: zod_1.z.array(zod_1.z.string()),
|
|
178
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { isReservedIntegrationId, RESERVED_INTEGRATION_IDS, } from '../internal/reservedIds.js';
|
|
2
|
+
export { authHookNameSchema, describedAccessSchema, describedFunctionSchema, describedPageSchema, describedRouteSchema, describedScheduleSchema, describedTriggerSchema, describedWorkflowSchema, describeOutputSchema, } from './describe/schema.js';
|
|
2
3
|
export type { AppContext, ExpiringToken, HostConnection, HostMode, HostPage, HostProps, PlatformBinding, SiteHead, WebManifest, } from './types.js';
|
|
3
4
|
/** What the host dispatches a request to do beside serving it; without props, only `warm` and `describe`. */
|
|
4
5
|
export declare const INVOKE_KINDS: readonly ["webhook", "describe", "workflow", "register", "warm", "authHook", "function"];
|
|
@@ -17,3 +18,9 @@ export declare const GATEWAY_CONNECTION_HEADER = "x-zite-gateway-connection";
|
|
|
17
18
|
/** On a demo's refused answer, beside its 403, so the platform's runtime shows the demo notice. */
|
|
18
19
|
export declare const ERROR_CODE_HEADER = "x-zite-error-code";
|
|
19
20
|
export declare const DEMO_READ_ONLY_CODE = "DEMO_READ_ONLY";
|
|
21
|
+
/**
|
|
22
|
+
* What a Start app installs beside zitejs, exactly: the TanStack peers zitejs pins, and React Query with its core,
|
|
23
|
+
* pinned together so only one query-core is ever installed. tests/startAppDependencies.test.ts holds it to
|
|
24
|
+
* package.json.
|
|
25
|
+
*/
|
|
26
|
+
export declare const START_APP_DEPENDENCIES: Readonly<Record<string, string>>;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// What a Start build and the platform's host say to each other on the wire. Import-free but for the reserved ids
|
|
3
|
-
//
|
|
2
|
+
// What a Start build and the platform's host say to each other on the wire. Import-free but for the reserved ids and
|
|
3
|
+
// describe's output schema, which imports only zod and the auth hook names, so the host takes these without loading
|
|
4
|
+
// anything of zitejs.
|
|
4
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.DEMO_READ_ONLY_CODE = exports.ERROR_CODE_HEADER = exports.GATEWAY_CONNECTION_HEADER = exports.PREVIEW_CLAIM_HEADER = exports.RUNTIME_VERSION_HEADER = exports.INVOKE_PATH = exports.INVOKE_HEADER = exports.isInvokeKind = exports.INVOKE_KINDS = exports.RESERVED_INTEGRATION_IDS = exports.isReservedIntegrationId = void 0;
|
|
6
|
+
exports.START_APP_DEPENDENCIES = exports.DEMO_READ_ONLY_CODE = exports.ERROR_CODE_HEADER = exports.GATEWAY_CONNECTION_HEADER = exports.PREVIEW_CLAIM_HEADER = exports.RUNTIME_VERSION_HEADER = exports.INVOKE_PATH = exports.INVOKE_HEADER = exports.isInvokeKind = exports.INVOKE_KINDS = exports.describeOutputSchema = exports.describedWorkflowSchema = exports.describedTriggerSchema = exports.describedScheduleSchema = exports.describedRouteSchema = exports.describedPageSchema = exports.describedFunctionSchema = exports.describedAccessSchema = exports.authHookNameSchema = exports.RESERVED_INTEGRATION_IDS = exports.isReservedIntegrationId = void 0;
|
|
6
7
|
var reservedIds_js_1 = require("../internal/reservedIds.js");
|
|
7
8
|
Object.defineProperty(exports, "isReservedIntegrationId", { enumerable: true, get: function () { return reservedIds_js_1.isReservedIntegrationId; } });
|
|
8
9
|
Object.defineProperty(exports, "RESERVED_INTEGRATION_IDS", { enumerable: true, get: function () { return reservedIds_js_1.RESERVED_INTEGRATION_IDS; } });
|
|
10
|
+
var schema_js_1 = require("./describe/schema.js");
|
|
11
|
+
Object.defineProperty(exports, "authHookNameSchema", { enumerable: true, get: function () { return schema_js_1.authHookNameSchema; } });
|
|
12
|
+
Object.defineProperty(exports, "describedAccessSchema", { enumerable: true, get: function () { return schema_js_1.describedAccessSchema; } });
|
|
13
|
+
Object.defineProperty(exports, "describedFunctionSchema", { enumerable: true, get: function () { return schema_js_1.describedFunctionSchema; } });
|
|
14
|
+
Object.defineProperty(exports, "describedPageSchema", { enumerable: true, get: function () { return schema_js_1.describedPageSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "describedRouteSchema", { enumerable: true, get: function () { return schema_js_1.describedRouteSchema; } });
|
|
16
|
+
Object.defineProperty(exports, "describedScheduleSchema", { enumerable: true, get: function () { return schema_js_1.describedScheduleSchema; } });
|
|
17
|
+
Object.defineProperty(exports, "describedTriggerSchema", { enumerable: true, get: function () { return schema_js_1.describedTriggerSchema; } });
|
|
18
|
+
Object.defineProperty(exports, "describedWorkflowSchema", { enumerable: true, get: function () { return schema_js_1.describedWorkflowSchema; } });
|
|
19
|
+
Object.defineProperty(exports, "describeOutputSchema", { enumerable: true, get: function () { return schema_js_1.describeOutputSchema; } });
|
|
9
20
|
/** What the host dispatches a request to do beside serving it; without props, only `warm` and `describe`. */
|
|
10
21
|
exports.INVOKE_KINDS = [
|
|
11
22
|
'webhook',
|
|
@@ -31,3 +42,16 @@ exports.GATEWAY_CONNECTION_HEADER = 'x-zite-gateway-connection';
|
|
|
31
42
|
/** On a demo's refused answer, beside its 403, so the platform's runtime shows the demo notice. */
|
|
32
43
|
exports.ERROR_CODE_HEADER = 'x-zite-error-code';
|
|
33
44
|
exports.DEMO_READ_ONLY_CODE = 'DEMO_READ_ONLY';
|
|
45
|
+
/**
|
|
46
|
+
* What a Start app installs beside zitejs, exactly: the TanStack peers zitejs pins, and React Query with its core,
|
|
47
|
+
* pinned together so only one query-core is ever installed. tests/startAppDependencies.test.ts holds it to
|
|
48
|
+
* package.json.
|
|
49
|
+
*/
|
|
50
|
+
exports.START_APP_DEPENDENCIES = {
|
|
51
|
+
'@tanstack/query-core': '5.104.0',
|
|
52
|
+
'@tanstack/react-query': '5.104.0',
|
|
53
|
+
'@tanstack/react-router': '1.170.45',
|
|
54
|
+
'@tanstack/react-router-ssr-query': '1.167.3',
|
|
55
|
+
'@tanstack/react-start': '1.169.3',
|
|
56
|
+
'@tanstack/start-storage-context': '1.167.40',
|
|
57
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Import-free, so describe's output schema in zitejs/start/protocol can name them.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isAuthHookName = exports.AUTH_HOOK_NAMES = void 0;
|
|
5
|
+
exports.AUTH_HOOK_NAMES = [
|
|
6
|
+
'beforeSignUp',
|
|
7
|
+
'beforeSignIn',
|
|
8
|
+
'afterSignUp',
|
|
9
|
+
'afterSignIn',
|
|
10
|
+
'verifySession',
|
|
11
|
+
];
|
|
12
|
+
const isAuthHookName = (name) => exports.AUTH_HOOK_NAMES.includes(name);
|
|
13
|
+
exports.isAuthHookName = isAuthHookName;
|
package/dist/cjs/vite/index.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ziteId = ziteId;
|
|
7
7
|
const parser_1 = require("@babel/parser");
|
|
8
8
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
9
|
-
const fs_1 = require("fs");
|
|
10
9
|
const path_1 = __importDefault(require("path"));
|
|
11
10
|
const estree_walker_1 = require("estree-walker");
|
|
12
11
|
const domTagNames_js_1 = require("./domTagNames.js");
|
|
@@ -70,51 +69,11 @@ function classifyElement(name) {
|
|
|
70
69
|
}
|
|
71
70
|
return null;
|
|
72
71
|
}
|
|
73
|
-
/**
|
|
74
|
-
* What zitejs/query needs to keep data on the device, in a built page: an id
|
|
75
|
-
* for this build, so data an older build saved is never shown, and the app's
|
|
76
|
-
* `deviceCache` from `zite.config.json` beside the vite config. Only `"disk"`
|
|
77
|
-
* keeps anything: an app that hasn't chosen, or whose config can't be read,
|
|
78
|
-
* keeps nothing.
|
|
79
|
-
*/
|
|
80
|
-
const deviceCacheTags = (appDir, build) => {
|
|
81
|
-
let deviceCache;
|
|
82
|
-
try {
|
|
83
|
-
deviceCache = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(appDir, 'zite.config.json'), 'utf8')).deviceCache;
|
|
84
|
-
}
|
|
85
|
-
catch { }
|
|
86
|
-
return [
|
|
87
|
-
{ tag: 'meta', attrs: { name: 'zite-build', content: build } },
|
|
88
|
-
...(deviceCache === 'disk'
|
|
89
|
-
? []
|
|
90
|
-
: [
|
|
91
|
-
{
|
|
92
|
-
tag: 'meta',
|
|
93
|
-
attrs: { name: 'zite-device-cache', content: 'memory' },
|
|
94
|
-
},
|
|
95
|
-
]),
|
|
96
|
-
];
|
|
97
|
-
};
|
|
98
72
|
function ziteId() {
|
|
99
73
|
const cwd = process.cwd();
|
|
100
|
-
let appDir = cwd;
|
|
101
|
-
let building = false;
|
|
102
|
-
// One per build, shared by every page of it.
|
|
103
|
-
const build = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
104
74
|
return {
|
|
105
75
|
name: 'vite-plugin-zite-id',
|
|
106
76
|
enforce: 'pre',
|
|
107
|
-
configResolved(config) {
|
|
108
|
-
// Beside the vite config, as the app's own config reads zite.config.json:
|
|
109
|
-
// the build's cwd isn't always the app's directory.
|
|
110
|
-
appDir = config.configFile
|
|
111
|
-
? path_1.default.dirname(config.configFile)
|
|
112
|
-
: config.root;
|
|
113
|
-
building = config.command === 'build';
|
|
114
|
-
},
|
|
115
|
-
transformIndexHtml() {
|
|
116
|
-
return building ? deviceCacheTags(appDir, build) : [];
|
|
117
|
-
},
|
|
118
77
|
async transform(code, id) {
|
|
119
78
|
// TanStack's route code splitting moves a route's component into its own module, `route.tsx?tsr-split=…`.
|
|
120
79
|
const file = id.split('?')[0];
|
|
@@ -3,8 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const os_1 = require("os");
|
|
8
6
|
const path_1 = __importDefault(require("path"));
|
|
9
7
|
const vitest_1 = require("vitest");
|
|
10
8
|
const index_js_1 = require("./index.js");
|
|
@@ -117,37 +115,3 @@ async function transform(code, file = 'src/App.tsx') {
|
|
|
117
115
|
(0, vitest_1.expect)(await transform(source)).toBe(source);
|
|
118
116
|
});
|
|
119
117
|
});
|
|
120
|
-
(0, vitest_1.describe)("ziteId's tags for zitejs/query's device cache", () => {
|
|
121
|
-
const plugin = (command, config) => {
|
|
122
|
-
const dir = (0, fs_1.mkdtempSync)(path_1.default.join((0, os_1.tmpdir)(), 'zite-app-'));
|
|
123
|
-
if (config) {
|
|
124
|
-
(0, fs_1.writeFileSync)(path_1.default.join(dir, 'zite.config.json'), JSON.stringify(config));
|
|
125
|
-
}
|
|
126
|
-
const instance = (0, index_js_1.ziteId)();
|
|
127
|
-
instance.configResolved({
|
|
128
|
-
command,
|
|
129
|
-
configFile: path_1.default.join(dir, 'vite.config.ts'),
|
|
130
|
-
root: process.cwd(),
|
|
131
|
-
});
|
|
132
|
-
return () => Object.fromEntries(instance.transformIndexHtml().map(t => [
|
|
133
|
-
t.attrs?.name,
|
|
134
|
-
t.attrs?.content,
|
|
135
|
-
]));
|
|
136
|
-
};
|
|
137
|
-
(0, vitest_1.it)('keeps data on the device only for an app that chose disk', () => {
|
|
138
|
-
(0, vitest_1.expect)(plugin('build', { deviceCache: 'disk' })()['zite-device-cache']).toBeUndefined();
|
|
139
|
-
(0, vitest_1.expect)(plugin('build', { deviceCache: 'memory' })()['zite-device-cache']).toBe('memory');
|
|
140
|
-
(0, vitest_1.expect)(plugin('build', { id: 'app' })()['zite-device-cache']).toBe('memory');
|
|
141
|
-
(0, vitest_1.expect)(plugin('build')()['zite-device-cache']).toBe('memory');
|
|
142
|
-
});
|
|
143
|
-
(0, vitest_1.it)('gives every page of a build the same id, and each build its own', () => {
|
|
144
|
-
const pages = plugin('build', { deviceCache: 'disk' });
|
|
145
|
-
const id = pages()['zite-build'];
|
|
146
|
-
(0, vitest_1.expect)(id).toMatch(/\w{6,}/);
|
|
147
|
-
(0, vitest_1.expect)(pages()['zite-build']).toBe(id);
|
|
148
|
-
(0, vitest_1.expect)(plugin('build', { deviceCache: 'disk' })()['zite-build']).not.toBe(id);
|
|
149
|
-
});
|
|
150
|
-
(0, vitest_1.it)('tags nothing on a dev server', () => {
|
|
151
|
-
(0, vitest_1.expect)(plugin('serve', { deviceCache: 'disk' })()).toEqual({});
|
|
152
|
-
});
|
|
153
|
-
});
|
package/dist/esm/auth/actions.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { USAGE_TOKEN_QUERY_PARAM } from './constants.js';
|
|
2
2
|
import { browserPreviewClaim, PREVIEW_CLAIM_PARAM } from './previewClaim.js';
|
|
3
3
|
import { profileUpdated } from './profileUpdates.js';
|
|
4
|
-
import { forgetDeviceCache } from '../internal/deviceCache.js';
|
|
5
4
|
export function loginWithRedirect(opts) {
|
|
6
5
|
if (window.location.pathname.startsWith('/auth/'))
|
|
7
6
|
return;
|
|
@@ -43,7 +42,6 @@ export function loginWithRedirect(opts) {
|
|
|
43
42
|
window.location.href = query ? `/auth/login?${query}` : '/auth/login';
|
|
44
43
|
}
|
|
45
44
|
export function logout(opts) {
|
|
46
|
-
forgetDeviceCache();
|
|
47
45
|
void import('./client.js').then(({ signOut }) => signOut().then(() => {
|
|
48
46
|
window.location.href = opts?.returnTo || '/';
|
|
49
47
|
}));
|
package/dist/esm/auth/client.js
CHANGED
|
@@ -3,7 +3,6 @@ import { createAuthClient } from 'better-auth/react';
|
|
|
3
3
|
import { magicLinkClient, inferAdditionalFields, } from 'better-auth/client/plugins';
|
|
4
4
|
import { getAccessMode } from './config.js';
|
|
5
5
|
import { loginWithRedirect, logout } from './actions.js';
|
|
6
|
-
import { sessionChanged } from '../internal/deviceCache.js';
|
|
7
6
|
// Apart from the actions, so an app that never reads the session here (a Start
|
|
8
7
|
// app reads its user from the router) never ships better-auth's client.
|
|
9
8
|
export const authClient = createAuthClient({
|
|
@@ -19,10 +18,6 @@ export const authClient = createAuthClient({
|
|
|
19
18
|
],
|
|
20
19
|
});
|
|
21
20
|
export const useSession = authClient.useSession;
|
|
22
|
-
// better-auth flips this after any call that changes who's signed in (sign-in,
|
|
23
|
-
// sign-up, sign-out) or what's known about them. What the app kept on the
|
|
24
|
-
// device may belong to someone else now.
|
|
25
|
-
authClient.$store.atoms.$sessionSignal?.listen(sessionChanged);
|
|
26
21
|
/**
|
|
27
22
|
* An internal app has no signed-out state — SSO runs before the bundle — so an
|
|
28
23
|
* empty session means it died underneath the app. Only `internal`: elsewhere a
|
package/dist/esm/caller/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { getEnv } from '../internal/env.js';
|
|
2
|
-
|
|
2
|
+
function getMode() {
|
|
3
|
+
if (typeof window === 'undefined')
|
|
4
|
+
return 'preview';
|
|
5
|
+
const host = window.location.host;
|
|
6
|
+
return host.startsWith('zite-editor') ||
|
|
7
|
+
host.startsWith('zite-action-') ||
|
|
8
|
+
host.startsWith('zite-snapshot-') ||
|
|
9
|
+
host.endsWith('.zite-dev-sandbox.com') ||
|
|
10
|
+
host.endsWith('.zite-sandbox.com') ||
|
|
11
|
+
host.endsWith('.zite-dev-app.com') ||
|
|
12
|
+
host.endsWith('.zite-app.com')
|
|
13
|
+
? 'preview'
|
|
14
|
+
: 'live';
|
|
15
|
+
}
|
|
3
16
|
const ENVIRONMENTS = {
|
|
4
17
|
production: 'https://workflows.zite.com',
|
|
5
18
|
staging: 'https://workflows.zitestaging.com',
|
|
@@ -78,9 +91,7 @@ export function createCaller(endpointOrName, nameOrFlowId, flowId) {
|
|
|
78
91
|
const res = await fetch(url, init);
|
|
79
92
|
if (!res.ok) {
|
|
80
93
|
const text = await res.text().catch(() => '');
|
|
81
|
-
throw
|
|
82
|
-
status: res.status,
|
|
83
|
-
});
|
|
94
|
+
throw new Error(`API call failed (${res.status}): ${text}`);
|
|
84
95
|
}
|
|
85
96
|
return res.json();
|
|
86
97
|
};
|
package/dist/esm/check/index.js
CHANGED
|
@@ -130,14 +130,20 @@ export function runTool(file, args, cwd) {
|
|
|
130
130
|
}
|
|
131
131
|
const isMissingModule = (err) => err?.code === 'MODULE_NOT_FOUND';
|
|
132
132
|
/**
|
|
133
|
-
* A Start app, in about a second: its
|
|
134
|
-
* writes
|
|
135
|
-
* the platform build's and its describe's to
|
|
133
|
+
* A Start app, in about a second: its `.zite/` entries and role ids, and its
|
|
134
|
+
* route tree, written as `vite build` writes them, then a tsgo typecheck, which
|
|
135
|
+
* reads them. Everything else is the platform build's and its describe's to
|
|
136
|
+
* refuse.
|
|
136
137
|
*/
|
|
137
138
|
async function checkStartApp(reporter, app, appPath) {
|
|
138
|
-
const { regenerateRouteTree } = await
|
|
139
|
+
const [{ regenerateRouteTree }, { writeStartFiles }] = await Promise.all([
|
|
140
|
+
import('./start/routeTree.js'),
|
|
141
|
+
import('../start/build/entries.js'),
|
|
142
|
+
]);
|
|
139
143
|
let routeTree = { ok: true };
|
|
140
144
|
try {
|
|
145
|
+
// First: the route tree's footer types the start instance only when .zite/start.ts is there.
|
|
146
|
+
writeStartFiles(appPath);
|
|
141
147
|
await regenerateRouteTree(appPath);
|
|
142
148
|
}
|
|
143
149
|
catch (err) {
|
|
@@ -15,6 +15,11 @@ export declare const hasAppStart: (appDir: string) => boolean;
|
|
|
15
15
|
export declare const writeIfChanged: (appDir: string, file: string, content: string) => boolean;
|
|
16
16
|
export declare const isStartAppDir: (appPath: string) => boolean;
|
|
17
17
|
export declare const workspaceHasStartApps: () => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The `.zite/` files a Start app's typecheck reads, its entries as `vite build` writes them: `check`, `generate` and
|
|
20
|
+
* `dev` all write them. Returns the ones that changed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeStartFiles(appDir: string): string[];
|
|
18
23
|
export declare function regenerateStartEntries(app: SourceDir): void;
|
|
19
24
|
/**
|
|
20
25
|
* App modules that mention createAutomation or createProviderTrigger: what the workflow registry imports. Describe
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import { dirname, join, relative } from 'node:path';
|
|
3
3
|
import { listSourceDirs } from '../../sourceRoots.js';
|
|
4
|
+
import { renderRoleIds, START_ROLES_FILE, workspaceRoleIds, } from './roleIds.js';
|
|
4
5
|
export const START_SERVER_ENTRY = '.zite/server.ts';
|
|
5
6
|
export const START_INSTANCE_ENTRY = '.zite/start.ts';
|
|
6
7
|
const APP_START_FILES = ['src/start.ts', 'src/start.tsx'];
|
|
@@ -64,17 +65,23 @@ export const isStartAppDir = (appPath) => {
|
|
|
64
65
|
};
|
|
65
66
|
const isStartApp = (app) => isStartAppDir(app.path);
|
|
66
67
|
export const workspaceHasStartApps = () => listSourceDirs().some(isStartApp);
|
|
68
|
+
/**
|
|
69
|
+
* The `.zite/` files a Start app's typecheck reads, its entries as `vite build` writes them: `check`, `generate` and
|
|
70
|
+
* `dev` all write them. Returns the ones that changed.
|
|
71
|
+
*/
|
|
72
|
+
export function writeStartFiles(appDir) {
|
|
73
|
+
const files = [
|
|
74
|
+
[START_SERVER_ENTRY, renderStartServerEntry()],
|
|
75
|
+
[START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir))],
|
|
76
|
+
[START_ROLES_FILE, renderRoleIds(workspaceRoleIds(appDir))],
|
|
77
|
+
];
|
|
78
|
+
return files.flatMap(([file, content]) => writeIfChanged(appDir, file, content) ? [file] : []);
|
|
79
|
+
}
|
|
67
80
|
export function regenerateStartEntries(app) {
|
|
68
81
|
if (!isStartApp(app))
|
|
69
82
|
return;
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
[START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(app.path))],
|
|
73
|
-
];
|
|
74
|
-
for (const [file, content] of entries) {
|
|
75
|
-
if (writeIfChanged(app.path, file, content))
|
|
76
|
-
console.log(`Wrote ${join(app.path, file)}`);
|
|
77
|
-
}
|
|
83
|
+
for (const file of writeStartFiles(app.path))
|
|
84
|
+
console.log(`Wrote ${join(app.path, file)}`);
|
|
78
85
|
}
|
|
79
86
|
const SOURCE_FILE = /\.[mc]?[jt]sx?$/;
|
|
80
87
|
const NOT_APP_CODE = /(\.(test|spec)\.[^.]+|\.d\.ts|routeTree\.gen\.ts)$/;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const START_ROLES_FILE = ".zite/roles.d.ts";
|
|
2
|
+
/** The roles every workspace has without defining them, as the platform names them. */
|
|
3
|
+
export declare const BUILTIN_ROLE_IDS: readonly ["builtin:all-team-members", "builtin:all-users"];
|
|
4
|
+
/**
|
|
5
|
+
* The built-ins, then the roles the nearest `zite.permissions.json` defines. None at all when there's no readable
|
|
6
|
+
* file, so role ids stay plain strings: a missing or broken file would otherwise type every role the app names as a
|
|
7
|
+
* typo, and the nearest id that compiles is a built-in that admits everyone.
|
|
8
|
+
*/
|
|
9
|
+
export declare const workspaceRoleIds: (appDir: string) => string[];
|
|
10
|
+
/** `.zite/roles.d.ts`, which types `role()` and `hasRole` to these ids. Its `export {}` makes it an augmentation. */
|
|
11
|
+
export declare const renderRoleIds: (ids: readonly string[]) => string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
export const START_ROLES_FILE = '.zite/roles.d.ts';
|
|
4
|
+
/** The roles every workspace has without defining them, as the platform names them. */
|
|
5
|
+
export const BUILTIN_ROLE_IDS = [
|
|
6
|
+
'builtin:all-team-members',
|
|
7
|
+
'builtin:all-users',
|
|
8
|
+
];
|
|
9
|
+
const PERMISSIONS_FILE = 'zite.permissions.json';
|
|
10
|
+
// The workspace root's in a monorepo, above apps/<dir>/.
|
|
11
|
+
const findPermissionsFile = (appDir) => {
|
|
12
|
+
for (let dir = resolve(appDir);; dir = dirname(dir)) {
|
|
13
|
+
const file = join(dir, PERMISSIONS_FILE);
|
|
14
|
+
if (existsSync(file))
|
|
15
|
+
return file;
|
|
16
|
+
if (dirname(dir) === dir)
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
// Undefined for a file that isn't a permissions file: its roles can't be known.
|
|
21
|
+
const definedRoleIds = (file) => {
|
|
22
|
+
try {
|
|
23
|
+
const { roles } = (JSON.parse(readFileSync(file, 'utf-8')) ?? {});
|
|
24
|
+
if (!Array.isArray(roles))
|
|
25
|
+
return undefined;
|
|
26
|
+
return roles.flatMap(role => {
|
|
27
|
+
const id = role?.id;
|
|
28
|
+
return typeof id === 'string' && id ? [id] : [];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The built-ins, then the roles the nearest `zite.permissions.json` defines. None at all when there's no readable
|
|
37
|
+
* file, so role ids stay plain strings: a missing or broken file would otherwise type every role the app names as a
|
|
38
|
+
* typo, and the nearest id that compiles is a built-in that admits everyone.
|
|
39
|
+
*/
|
|
40
|
+
export const workspaceRoleIds = (appDir) => {
|
|
41
|
+
const file = findPermissionsFile(appDir);
|
|
42
|
+
const defined = file ? definedRoleIds(file) : undefined;
|
|
43
|
+
return defined ? [...new Set([...BUILTIN_ROLE_IDS, ...defined])] : [];
|
|
44
|
+
};
|
|
45
|
+
/** `.zite/roles.d.ts`, which types `role()` and `hasRole` to these ids. Its `export {}` makes it an augmentation. */
|
|
46
|
+
export const renderRoleIds = (ids) => `// Generated by zitejs from the built-in roles and zite.permissions.json. The platform owns this file.
|
|
47
|
+
export {};
|
|
48
|
+
|
|
49
|
+
declare module 'zitejs/start' {
|
|
50
|
+
interface ZiteRoles {
|
|
51
|
+
${ids.map(id => ` ${JSON.stringify(id)}: true;`).join('\n')}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
@@ -55,10 +55,6 @@ const REFUSED = [
|
|
|
55
55
|
pattern: /^zitejs\/(api|caller)(\/|$)/,
|
|
56
56
|
fix: "it's classic's: a Start app calls its own server functions directly, from a loader or an event handler",
|
|
57
57
|
},
|
|
58
|
-
{
|
|
59
|
-
pattern: /^zitejs\/query(\/|$)/,
|
|
60
|
-
fix: "it's classic's: a Start app's router already provides its query client",
|
|
61
|
-
},
|
|
62
58
|
{
|
|
63
59
|
pattern: /^zitejs\/backend(\/|$)/,
|
|
64
60
|
fix: "it's classic's server module: import ZiteError and the rest from zitejs/start",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// zitejs/backend, zitejs/backend/base
|
|
2
|
-
//
|
|
3
|
-
// zitejs/start, server functions are called directly
|
|
1
|
+
// zitejs/backend, zitejs/backend/base and zitejs/caller as a Start app's types see them, under the `zite-start`
|
|
2
|
+
// condition: classic's server modules, with nothing in them for a Start app. ZiteError and the rest come from
|
|
3
|
+
// zitejs/start, and server functions are called directly.
|
|
4
4
|
export {};
|