zitejs 0.9.3 → 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/caller/index.js +16 -7
- package/dist/cjs/runtime/index.js +14 -5
- package/dist/cjs/sync/lib.js +1 -1
- 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/cli.js +0 -0
- package/dist/esm/runtime/index.js +14 -5
- package/dist/esm/sync/lib.js +1 -1
- package/package.json +1 -1
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()}`,
|
|
@@ -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
|
|
@@ -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()}`,
|
package/dist/esm/cli.js
CHANGED
|
File without changes
|
|
@@ -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
|