zitejs 0.9.2 → 0.9.4
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/index.js +0 -44
- package/dist/cjs/caller/index.js +16 -7
- package/dist/cjs/check/index.js +74 -0
- package/dist/cjs/cli.js +7 -1
- package/dist/cjs/runtime/index.js +14 -5
- package/dist/cjs/sync/lib.js +1 -1
- package/dist/esm/auth/index.d.ts +1 -13
- package/dist/esm/auth/index.js +1 -42
- package/dist/esm/backend/index.d.ts +0 -1
- package/dist/esm/caller/index.d.ts +1 -2
- package/dist/esm/caller/index.js +16 -7
- package/dist/esm/check/index.d.ts +1 -0
- package/dist/esm/check/index.js +71 -0
- package/dist/esm/cli.js +7 -1
- package/dist/esm/runtime/index.js +14 -5
- package/dist/esm/sync/lib.js +1 -1
- package/package.json +4 -17
package/dist/cjs/auth/index.js
CHANGED
|
@@ -1,46 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAuth = useAuth;
|
|
4
|
-
exports.getCurrentUser = getCurrentUser;
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
function useAuth() {
|
|
7
|
-
const [user, setUser] = (0, react_1.useState)(null);
|
|
8
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
9
|
-
(0, react_1.useEffect)(() => {
|
|
10
|
-
// Check if running inside the Zite sandbox (app-runtime provides auth)
|
|
11
|
-
const win = window;
|
|
12
|
-
if (typeof win._ziteGetUser === 'function') {
|
|
13
|
-
try {
|
|
14
|
-
const u = win._ziteGetUser();
|
|
15
|
-
setUser(u);
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
// Fall through to local dev mode
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
// Local dev mode — return anonymous user
|
|
23
|
-
setUser({
|
|
24
|
-
id: 'local-dev',
|
|
25
|
-
email: 'dev@localhost',
|
|
26
|
-
name: 'Local Developer',
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
setIsLoading(false);
|
|
30
|
-
}, []);
|
|
31
|
-
return {
|
|
32
|
-
user,
|
|
33
|
-
isLoading,
|
|
34
|
-
authLoading: isLoading,
|
|
35
|
-
logout: () => {
|
|
36
|
-
setUser(null);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function getCurrentUser() {
|
|
41
|
-
const win = window;
|
|
42
|
-
if (typeof win._ziteGetUser === 'function') {
|
|
43
|
-
return win._ziteGetUser();
|
|
44
|
-
}
|
|
45
|
-
return { id: 'local-dev', email: 'dev@localhost', name: 'Local Developer' };
|
|
46
|
-
}
|
package/dist/cjs/caller/index.js
CHANGED
|
@@ -6,18 +6,27 @@ const ENVIRONMENTS = {
|
|
|
6
6
|
staging: 'https://workflows.zitestaging.com',
|
|
7
7
|
local: 'http://localhost:2506',
|
|
8
8
|
};
|
|
9
|
+
function getEnv(key, viteKey) {
|
|
10
|
+
if (typeof process !== 'undefined' && process.env?.[key])
|
|
11
|
+
return process.env[key];
|
|
12
|
+
try {
|
|
13
|
+
// @ts-ignore — import.meta.env is Vite-specific
|
|
14
|
+
if (viteKey && typeof import.meta !== 'undefined' && import.meta.env?.[viteKey])
|
|
15
|
+
return import.meta.env[viteKey];
|
|
16
|
+
}
|
|
17
|
+
catch { }
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
9
20
|
function getRunnerUrl() {
|
|
10
|
-
const env = (
|
|
11
|
-
return (
|
|
12
|
-
ENVIRONMENTS[env] ||
|
|
13
|
-
ENVIRONMENTS.production);
|
|
21
|
+
const env = getEnv('ZITE_ENV', 'VITE_ZITE_ENV') ?? 'production';
|
|
22
|
+
return getEnv('ZITE_RUNNER_URL', 'VITE_ZITE_RUNNER_URL') ?? ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
|
|
14
23
|
}
|
|
15
24
|
function getToken() {
|
|
16
|
-
return (
|
|
25
|
+
return getEnv('ZITE_DB_TOKEN', 'VITE_ZITE_DB_TOKEN') ?? '';
|
|
17
26
|
}
|
|
18
|
-
function createCaller(endpoint) {
|
|
27
|
+
function createCaller(endpoint, name) {
|
|
19
28
|
return async (input) => {
|
|
20
|
-
const res = await fetch(getRunnerUrl() + '/api/' +
|
|
29
|
+
const res = await fetch(getRunnerUrl() + '/api/' + name, {
|
|
21
30
|
method: 'POST',
|
|
22
31
|
headers: {
|
|
23
32
|
Authorization: `Bearer ${getToken()}`,
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCheck = runCheck;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
function findAppDirs() {
|
|
8
|
+
const appsDir = 'apps';
|
|
9
|
+
if (!(0, fs_1.existsSync)(appsDir))
|
|
10
|
+
return [];
|
|
11
|
+
return (0, fs_1.readdirSync)(appsDir, { withFileTypes: true })
|
|
12
|
+
.filter(d => d.isDirectory())
|
|
13
|
+
.map(d => d.name);
|
|
14
|
+
}
|
|
15
|
+
function run(cmd, cwd) {
|
|
16
|
+
try {
|
|
17
|
+
const output = (0, child_process_1.execSync)(cmd, {
|
|
18
|
+
cwd,
|
|
19
|
+
encoding: 'utf-8',
|
|
20
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
21
|
+
});
|
|
22
|
+
return { ok: true, output };
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
const e = err;
|
|
26
|
+
return { ok: false, output: (e.stderr ?? '') + (e.stdout ?? '') };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function runCheck() {
|
|
30
|
+
const appDirs = findAppDirs();
|
|
31
|
+
if (appDirs.length === 0) {
|
|
32
|
+
console.error('No apps found in apps/ directory.');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
let allPassed = true;
|
|
36
|
+
for (const app of appDirs) {
|
|
37
|
+
const appPath = (0, path_1.join)('apps', app);
|
|
38
|
+
console.log(`\n── ${app} ──`);
|
|
39
|
+
const tsconfigPath = (0, path_1.join)(appPath, 'tsconfig.json');
|
|
40
|
+
if ((0, fs_1.existsSync)(tsconfigPath)) {
|
|
41
|
+
process.stdout.write(' tsc --noEmit ... ');
|
|
42
|
+
const tsc = run(`npx tsc --noEmit -p ${tsconfigPath}`, '.');
|
|
43
|
+
if (tsc.ok) {
|
|
44
|
+
console.log('✓');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log('✗');
|
|
48
|
+
console.log(tsc.output.trim().split('\n').map(l => ` ${l}`).join('\n'));
|
|
49
|
+
allPassed = false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const viteConfig = (0, path_1.join)(appPath, 'vite.config.ts');
|
|
53
|
+
if ((0, fs_1.existsSync)(viteConfig)) {
|
|
54
|
+
process.stdout.write(' vite build ... ');
|
|
55
|
+
const vite = run('npx vite build', appPath);
|
|
56
|
+
if (vite.ok) {
|
|
57
|
+
console.log('✓');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
console.log('✗');
|
|
61
|
+
console.log(vite.output.trim().split('\n').map(l => ` ${l}`).join('\n'));
|
|
62
|
+
allPassed = false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
console.log('');
|
|
67
|
+
if (allPassed) {
|
|
68
|
+
console.log('All apps pass.');
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.log('Some apps failed.');
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
package/dist/cjs/cli.js
CHANGED
|
@@ -50,14 +50,20 @@ async function main() {
|
|
|
50
50
|
await runDev();
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
|
+
case 'check': {
|
|
54
|
+
const { runCheck } = await Promise.resolve().then(() => __importStar(require('./check/index.js')));
|
|
55
|
+
await runCheck();
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
53
58
|
default:
|
|
54
59
|
console.error(command
|
|
55
60
|
? `Unknown command: ${command}`
|
|
56
|
-
: 'Usage: zitejs <sync|dev>');
|
|
61
|
+
: 'Usage: zitejs <sync|dev|check>');
|
|
57
62
|
console.error('');
|
|
58
63
|
console.error('Commands:');
|
|
59
64
|
console.error(' sync Generate .zite/db.ts and .zite/api.ts from your database schema');
|
|
60
65
|
console.error(' dev Run sync then watch for changes (like npx convex dev)');
|
|
66
|
+
console.error(' check Run tsc --noEmit and vite build for all apps');
|
|
61
67
|
process.exit(1);
|
|
62
68
|
}
|
|
63
69
|
}
|
|
@@ -8,14 +8,23 @@ const ENVIRONMENTS = {
|
|
|
8
8
|
staging: 'https://workflows.zitestaging.com',
|
|
9
9
|
local: 'http://localhost:2506',
|
|
10
10
|
};
|
|
11
|
+
function getEnv(key, viteKey) {
|
|
12
|
+
if (typeof process !== 'undefined' && process.env?.[key])
|
|
13
|
+
return process.env[key];
|
|
14
|
+
try {
|
|
15
|
+
// @ts-ignore — import.meta.env is Vite-specific
|
|
16
|
+
if (viteKey && typeof import.meta !== 'undefined' && import.meta.env?.[viteKey])
|
|
17
|
+
return import.meta.env[viteKey];
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
11
22
|
function getRunnerUrl() {
|
|
12
|
-
const env = (
|
|
13
|
-
return (
|
|
14
|
-
ENVIRONMENTS[env] ||
|
|
15
|
-
ENVIRONMENTS.production);
|
|
23
|
+
const env = getEnv('ZITE_ENV', 'VITE_ZITE_ENV') ?? 'production';
|
|
24
|
+
return getEnv('ZITE_RUNNER_URL', 'VITE_ZITE_RUNNER_URL') ?? ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
|
|
16
25
|
}
|
|
17
26
|
function getToken() {
|
|
18
|
-
return (
|
|
27
|
+
return getEnv('ZITE_DB_TOKEN', 'VITE_ZITE_DB_TOKEN') ?? '';
|
|
19
28
|
}
|
|
20
29
|
async function wrapSdkCall(integrationId, className, methodName, params) {
|
|
21
30
|
const res = await fetch(`${getRunnerUrl()}/sdk/execute`, {
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -138,7 +138,7 @@ function generateApiTs(endpointFiles) {
|
|
|
138
138
|
lines.push('');
|
|
139
139
|
// Named exports for each endpoint (backwards compat with old zite-endpoints-sdk imports)
|
|
140
140
|
for (const name of endpointNames) {
|
|
141
|
-
lines.push(`export const ${name} = createCaller(${name}Endpoint);`);
|
|
141
|
+
lines.push(`export const ${name} = createCaller(${name}Endpoint, '${name}');`);
|
|
142
142
|
}
|
|
143
143
|
lines.push('');
|
|
144
144
|
// Also export as a single api object
|
package/dist/esm/auth/index.d.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
id: string;
|
|
3
|
-
email?: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
}
|
|
7
|
-
export declare function useAuth(): {
|
|
8
|
-
user: ZiteUser | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
authLoading: boolean;
|
|
11
|
-
logout: () => void;
|
|
12
|
-
};
|
|
13
|
-
export declare function getCurrentUser(): ZiteUser | null;
|
|
1
|
+
export {};
|
package/dist/esm/auth/index.js
CHANGED
|
@@ -1,42 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export function useAuth() {
|
|
3
|
-
const [user, setUser] = useState(null);
|
|
4
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
// Check if running inside the Zite sandbox (app-runtime provides auth)
|
|
7
|
-
const win = window;
|
|
8
|
-
if (typeof win._ziteGetUser === 'function') {
|
|
9
|
-
try {
|
|
10
|
-
const u = win._ziteGetUser();
|
|
11
|
-
setUser(u);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
// Fall through to local dev mode
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
// Local dev mode — return anonymous user
|
|
19
|
-
setUser({
|
|
20
|
-
id: 'local-dev',
|
|
21
|
-
email: 'dev@localhost',
|
|
22
|
-
name: 'Local Developer',
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
setIsLoading(false);
|
|
26
|
-
}, []);
|
|
27
|
-
return {
|
|
28
|
-
user,
|
|
29
|
-
isLoading,
|
|
30
|
-
authLoading: isLoading,
|
|
31
|
-
logout: () => {
|
|
32
|
-
setUser(null);
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function getCurrentUser() {
|
|
37
|
-
const win = window;
|
|
38
|
-
if (typeof win._ziteGetUser === 'function') {
|
|
39
|
-
return win._ziteGetUser();
|
|
40
|
-
}
|
|
41
|
-
return { id: 'local-dev', email: 'dev@localhost', name: 'Local Developer' };
|
|
42
|
-
}
|
|
1
|
+
export {};
|
|
@@ -21,7 +21,6 @@ export interface EndpointConfig<TInput = unknown, TOutput = unknown> {
|
|
|
21
21
|
inputSchema?: SchemaLike<TInput>;
|
|
22
22
|
outputSchema?: SchemaLike<TOutput>;
|
|
23
23
|
stream?: boolean;
|
|
24
|
-
_name?: string;
|
|
25
24
|
execute: (params: {
|
|
26
25
|
input: TInput;
|
|
27
26
|
context: ZiteRequestContext | ZiteScheduledContext;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export interface EndpointConfig<TInput = unknown, TOutput = unknown> {
|
|
2
|
-
_name?: string;
|
|
3
2
|
execute: (params: {
|
|
4
3
|
input: TInput;
|
|
5
4
|
context: unknown;
|
|
6
5
|
}) => Promise<TOutput> | TOutput;
|
|
7
6
|
}
|
|
8
|
-
export declare function createCaller<TInput, TOutput>(endpoint: EndpointConfig<TInput, TOutput
|
|
7
|
+
export declare function createCaller<TInput, TOutput>(endpoint: EndpointConfig<TInput, TOutput>, name: string): (input: TInput) => Promise<TOutput>;
|
package/dist/esm/caller/index.js
CHANGED
|
@@ -3,18 +3,27 @@ const ENVIRONMENTS = {
|
|
|
3
3
|
staging: 'https://workflows.zitestaging.com',
|
|
4
4
|
local: 'http://localhost:2506',
|
|
5
5
|
};
|
|
6
|
+
function getEnv(key, viteKey) {
|
|
7
|
+
if (typeof process !== 'undefined' && process.env?.[key])
|
|
8
|
+
return process.env[key];
|
|
9
|
+
try {
|
|
10
|
+
// @ts-ignore — import.meta.env is Vite-specific
|
|
11
|
+
if (viteKey && typeof import.meta !== 'undefined' && import.meta.env?.[viteKey])
|
|
12
|
+
return import.meta.env[viteKey];
|
|
13
|
+
}
|
|
14
|
+
catch { }
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
6
17
|
function getRunnerUrl() {
|
|
7
|
-
const env = (
|
|
8
|
-
return (
|
|
9
|
-
ENVIRONMENTS[env] ||
|
|
10
|
-
ENVIRONMENTS.production);
|
|
18
|
+
const env = getEnv('ZITE_ENV', 'VITE_ZITE_ENV') ?? 'production';
|
|
19
|
+
return getEnv('ZITE_RUNNER_URL', 'VITE_ZITE_RUNNER_URL') ?? ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
|
|
11
20
|
}
|
|
12
21
|
function getToken() {
|
|
13
|
-
return (
|
|
22
|
+
return getEnv('ZITE_DB_TOKEN', 'VITE_ZITE_DB_TOKEN') ?? '';
|
|
14
23
|
}
|
|
15
|
-
export function createCaller(endpoint) {
|
|
24
|
+
export function createCaller(endpoint, name) {
|
|
16
25
|
return async (input) => {
|
|
17
|
-
const res = await fetch(getRunnerUrl() + '/api/' +
|
|
26
|
+
const res = await fetch(getRunnerUrl() + '/api/' + name, {
|
|
18
27
|
method: 'POST',
|
|
19
28
|
headers: {
|
|
20
29
|
Authorization: `Bearer ${getToken()}`,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCheck(): Promise<void>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { existsSync, readdirSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
function findAppDirs() {
|
|
5
|
+
const appsDir = 'apps';
|
|
6
|
+
if (!existsSync(appsDir))
|
|
7
|
+
return [];
|
|
8
|
+
return readdirSync(appsDir, { withFileTypes: true })
|
|
9
|
+
.filter(d => d.isDirectory())
|
|
10
|
+
.map(d => d.name);
|
|
11
|
+
}
|
|
12
|
+
function run(cmd, cwd) {
|
|
13
|
+
try {
|
|
14
|
+
const output = execSync(cmd, {
|
|
15
|
+
cwd,
|
|
16
|
+
encoding: 'utf-8',
|
|
17
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
18
|
+
});
|
|
19
|
+
return { ok: true, output };
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
const e = err;
|
|
23
|
+
return { ok: false, output: (e.stderr ?? '') + (e.stdout ?? '') };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export async function runCheck() {
|
|
27
|
+
const appDirs = findAppDirs();
|
|
28
|
+
if (appDirs.length === 0) {
|
|
29
|
+
console.error('No apps found in apps/ directory.');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
let allPassed = true;
|
|
33
|
+
for (const app of appDirs) {
|
|
34
|
+
const appPath = join('apps', app);
|
|
35
|
+
console.log(`\n── ${app} ──`);
|
|
36
|
+
const tsconfigPath = join(appPath, 'tsconfig.json');
|
|
37
|
+
if (existsSync(tsconfigPath)) {
|
|
38
|
+
process.stdout.write(' tsc --noEmit ... ');
|
|
39
|
+
const tsc = run(`npx tsc --noEmit -p ${tsconfigPath}`, '.');
|
|
40
|
+
if (tsc.ok) {
|
|
41
|
+
console.log('✓');
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.log('✗');
|
|
45
|
+
console.log(tsc.output.trim().split('\n').map(l => ` ${l}`).join('\n'));
|
|
46
|
+
allPassed = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const viteConfig = join(appPath, 'vite.config.ts');
|
|
50
|
+
if (existsSync(viteConfig)) {
|
|
51
|
+
process.stdout.write(' vite build ... ');
|
|
52
|
+
const vite = run('npx vite build', appPath);
|
|
53
|
+
if (vite.ok) {
|
|
54
|
+
console.log('✓');
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
console.log('✗');
|
|
58
|
+
console.log(vite.output.trim().split('\n').map(l => ` ${l}`).join('\n'));
|
|
59
|
+
allPassed = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
console.log('');
|
|
64
|
+
if (allPassed) {
|
|
65
|
+
console.log('All apps pass.');
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
console.log('Some apps failed.');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
}
|
package/dist/esm/cli.js
CHANGED
|
@@ -15,14 +15,20 @@ async function main() {
|
|
|
15
15
|
await runDev();
|
|
16
16
|
break;
|
|
17
17
|
}
|
|
18
|
+
case 'check': {
|
|
19
|
+
const { runCheck } = await import('./check/index.js');
|
|
20
|
+
await runCheck();
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
18
23
|
default:
|
|
19
24
|
console.error(command
|
|
20
25
|
? `Unknown command: ${command}`
|
|
21
|
-
: 'Usage: zitejs <sync|dev>');
|
|
26
|
+
: 'Usage: zitejs <sync|dev|check>');
|
|
22
27
|
console.error('');
|
|
23
28
|
console.error('Commands:');
|
|
24
29
|
console.error(' sync Generate .zite/db.ts and .zite/api.ts from your database schema');
|
|
25
30
|
console.error(' dev Run sync then watch for changes (like npx convex dev)');
|
|
31
|
+
console.error(' check Run tsc --noEmit and vite build for all apps');
|
|
26
32
|
process.exit(1);
|
|
27
33
|
}
|
|
28
34
|
}
|
|
@@ -3,14 +3,23 @@ const ENVIRONMENTS = {
|
|
|
3
3
|
staging: 'https://workflows.zitestaging.com',
|
|
4
4
|
local: 'http://localhost:2506',
|
|
5
5
|
};
|
|
6
|
+
function getEnv(key, viteKey) {
|
|
7
|
+
if (typeof process !== 'undefined' && process.env?.[key])
|
|
8
|
+
return process.env[key];
|
|
9
|
+
try {
|
|
10
|
+
// @ts-ignore — import.meta.env is Vite-specific
|
|
11
|
+
if (viteKey && typeof import.meta !== 'undefined' && import.meta.env?.[viteKey])
|
|
12
|
+
return import.meta.env[viteKey];
|
|
13
|
+
}
|
|
14
|
+
catch { }
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
6
17
|
function getRunnerUrl() {
|
|
7
|
-
const env = (
|
|
8
|
-
return (
|
|
9
|
-
ENVIRONMENTS[env] ||
|
|
10
|
-
ENVIRONMENTS.production);
|
|
18
|
+
const env = getEnv('ZITE_ENV', 'VITE_ZITE_ENV') ?? 'production';
|
|
19
|
+
return getEnv('ZITE_RUNNER_URL', 'VITE_ZITE_RUNNER_URL') ?? ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
|
|
11
20
|
}
|
|
12
21
|
function getToken() {
|
|
13
|
-
return (
|
|
22
|
+
return getEnv('ZITE_DB_TOKEN', 'VITE_ZITE_DB_TOKEN') ?? '';
|
|
14
23
|
}
|
|
15
24
|
export async function wrapSdkCall(integrationId, className, methodName, params) {
|
|
16
25
|
const res = await fetch(`${getRunnerUrl()}/sdk/execute`, {
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -130,7 +130,7 @@ export function generateApiTs(endpointFiles) {
|
|
|
130
130
|
lines.push('');
|
|
131
131
|
// Named exports for each endpoint (backwards compat with old zite-endpoints-sdk imports)
|
|
132
132
|
for (const name of endpointNames) {
|
|
133
|
-
lines.push(`export const ${name} = createCaller(${name}Endpoint);`);
|
|
133
|
+
lines.push(`export const ${name} = createCaller(${name}Endpoint, '${name}');`);
|
|
134
134
|
}
|
|
135
135
|
lines.push('');
|
|
136
136
|
// Also export as a single api object
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zitejs",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "The Zite framework — build apps on Zite Database",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/runtime/index.js",
|
|
@@ -22,31 +22,16 @@
|
|
|
22
22
|
"require": "./dist/cjs/caller/index.js",
|
|
23
23
|
"default": "./dist/esm/caller/index.js"
|
|
24
24
|
},
|
|
25
|
-
"./db": {
|
|
26
|
-
"types": "./dist/esm/db/index.d.ts",
|
|
27
|
-
"import": "./dist/esm/db/index.js",
|
|
28
|
-
"require": "./dist/cjs/db/index.js"
|
|
29
|
-
},
|
|
30
25
|
"./runtime": {
|
|
31
26
|
"types": "./dist/esm/runtime/index.d.ts",
|
|
32
27
|
"import": "./dist/esm/runtime/index.js",
|
|
33
28
|
"require": "./dist/cjs/runtime/index.js"
|
|
34
29
|
},
|
|
35
|
-
"./api": {
|
|
36
|
-
"types": "./dist/esm/api/index.d.ts",
|
|
37
|
-
"import": "./dist/esm/api/index.js",
|
|
38
|
-
"require": "./dist/cjs/api/index.js"
|
|
39
|
-
},
|
|
40
30
|
"./backend": {
|
|
41
31
|
"types": "./dist/esm/backend/index.d.ts",
|
|
42
32
|
"import": "./dist/esm/backend/index.js",
|
|
43
33
|
"require": "./dist/cjs/backend/index.js"
|
|
44
34
|
},
|
|
45
|
-
"./auth": {
|
|
46
|
-
"types": "./dist/esm/auth/index.d.ts",
|
|
47
|
-
"import": "./dist/esm/auth/index.js",
|
|
48
|
-
"require": "./dist/cjs/auth/index.js"
|
|
49
|
-
},
|
|
50
35
|
"./upload": {
|
|
51
36
|
"types": "./dist/esm/upload/index.d.ts",
|
|
52
37
|
"import": "./dist/esm/upload/index.js",
|
|
@@ -82,7 +67,9 @@
|
|
|
82
67
|
"react": ">=18"
|
|
83
68
|
},
|
|
84
69
|
"peerDependenciesMeta": {
|
|
85
|
-
"react": {
|
|
70
|
+
"react": {
|
|
71
|
+
"optional": true
|
|
72
|
+
}
|
|
86
73
|
},
|
|
87
74
|
"devDependencies": {
|
|
88
75
|
"@types/node": "^25.9.1",
|