zitejs 0.8.2 → 0.9.0
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.js +13 -9
- package/dist/cjs/sync/lib.js +7 -1
- package/dist/esm/runtime/index.js +13 -9
- package/dist/esm/sync/lib.js +7 -1
- package/package.json +1 -1
|
@@ -8,14 +8,20 @@ const ENVIRONMENTS = {
|
|
|
8
8
|
staging: 'https://workflows.zitestaging.com',
|
|
9
9
|
local: 'http://localhost:2506',
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
11
|
+
function getRunnerUrl() {
|
|
12
|
+
const env = (typeof process !== 'undefined' && process.env?.ZITE_ENV) || 'production';
|
|
13
|
+
return ((typeof process !== 'undefined' && process.env?.ZITE_RUNNER_URL) ||
|
|
14
|
+
ENVIRONMENTS[env] ||
|
|
15
|
+
ENVIRONMENTS.production);
|
|
16
|
+
}
|
|
17
|
+
function getToken() {
|
|
18
|
+
return (typeof process !== 'undefined' && process.env?.ZITE_DB_TOKEN) || '';
|
|
19
|
+
}
|
|
14
20
|
async function wrapSdkCall(integrationId, className, methodName, params) {
|
|
15
|
-
const res = await fetch(`${
|
|
21
|
+
const res = await fetch(`${getRunnerUrl()}/sdk/execute`, {
|
|
16
22
|
method: 'POST',
|
|
17
23
|
headers: {
|
|
18
|
-
Authorization: `Bearer ${
|
|
24
|
+
Authorization: `Bearer ${getToken()}`,
|
|
19
25
|
'Content-Type': 'application/json',
|
|
20
26
|
},
|
|
21
27
|
body: JSON.stringify({ integrationId, className, methodName, params }),
|
|
@@ -46,13 +52,11 @@ function createTableClient(integrationId, className) {
|
|
|
46
52
|
};
|
|
47
53
|
}
|
|
48
54
|
function createCaller(endpoint) {
|
|
49
|
-
const runnerUrl = process.env.ZITE_RUNNER_URL ?? ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
|
|
50
|
-
const token = process.env.ZITE_DB_TOKEN ?? '';
|
|
51
55
|
return async (input) => {
|
|
52
|
-
const res = await fetch(
|
|
56
|
+
const res = await fetch(getRunnerUrl() + '/api/' + endpoint._name, {
|
|
53
57
|
method: 'POST',
|
|
54
58
|
headers: {
|
|
55
|
-
Authorization: `Bearer ${
|
|
59
|
+
Authorization: `Bearer ${getToken()}`,
|
|
56
60
|
'Content-Type': 'application/json',
|
|
57
61
|
},
|
|
58
62
|
body: JSON.stringify(input),
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -136,9 +136,15 @@ function generateApiTs(endpointFiles) {
|
|
|
136
136
|
endpointNames.push(camelName);
|
|
137
137
|
}
|
|
138
138
|
lines.push('');
|
|
139
|
+
// Named exports for each endpoint (backwards compat with old zite-endpoints-sdk imports)
|
|
140
|
+
for (const name of endpointNames) {
|
|
141
|
+
lines.push(`export const ${name} = createCaller(${name}Endpoint);`);
|
|
142
|
+
}
|
|
143
|
+
lines.push('');
|
|
144
|
+
// Also export as a single api object
|
|
139
145
|
lines.push('export const api = {');
|
|
140
146
|
for (const name of endpointNames) {
|
|
141
|
-
lines.push(` ${name}
|
|
147
|
+
lines.push(` ${name},`);
|
|
142
148
|
}
|
|
143
149
|
lines.push('};');
|
|
144
150
|
lines.push('');
|
|
@@ -3,14 +3,20 @@ const ENVIRONMENTS = {
|
|
|
3
3
|
staging: 'https://workflows.zitestaging.com',
|
|
4
4
|
local: 'http://localhost:2506',
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
function getRunnerUrl() {
|
|
7
|
+
const env = (typeof process !== 'undefined' && process.env?.ZITE_ENV) || 'production';
|
|
8
|
+
return ((typeof process !== 'undefined' && process.env?.ZITE_RUNNER_URL) ||
|
|
9
|
+
ENVIRONMENTS[env] ||
|
|
10
|
+
ENVIRONMENTS.production);
|
|
11
|
+
}
|
|
12
|
+
function getToken() {
|
|
13
|
+
return (typeof process !== 'undefined' && process.env?.ZITE_DB_TOKEN) || '';
|
|
14
|
+
}
|
|
9
15
|
export async function wrapSdkCall(integrationId, className, methodName, params) {
|
|
10
|
-
const res = await fetch(`${
|
|
16
|
+
const res = await fetch(`${getRunnerUrl()}/sdk/execute`, {
|
|
11
17
|
method: 'POST',
|
|
12
18
|
headers: {
|
|
13
|
-
Authorization: `Bearer ${
|
|
19
|
+
Authorization: `Bearer ${getToken()}`,
|
|
14
20
|
'Content-Type': 'application/json',
|
|
15
21
|
},
|
|
16
22
|
body: JSON.stringify({ integrationId, className, methodName, params }),
|
|
@@ -41,13 +47,11 @@ export function createTableClient(integrationId, className) {
|
|
|
41
47
|
};
|
|
42
48
|
}
|
|
43
49
|
export function createCaller(endpoint) {
|
|
44
|
-
const runnerUrl = process.env.ZITE_RUNNER_URL ?? ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
|
|
45
|
-
const token = process.env.ZITE_DB_TOKEN ?? '';
|
|
46
50
|
return async (input) => {
|
|
47
|
-
const res = await fetch(
|
|
51
|
+
const res = await fetch(getRunnerUrl() + '/api/' + endpoint._name, {
|
|
48
52
|
method: 'POST',
|
|
49
53
|
headers: {
|
|
50
|
-
Authorization: `Bearer ${
|
|
54
|
+
Authorization: `Bearer ${getToken()}`,
|
|
51
55
|
'Content-Type': 'application/json',
|
|
52
56
|
},
|
|
53
57
|
body: JSON.stringify(input),
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -128,9 +128,15 @@ export function generateApiTs(endpointFiles) {
|
|
|
128
128
|
endpointNames.push(camelName);
|
|
129
129
|
}
|
|
130
130
|
lines.push('');
|
|
131
|
+
// Named exports for each endpoint (backwards compat with old zite-endpoints-sdk imports)
|
|
132
|
+
for (const name of endpointNames) {
|
|
133
|
+
lines.push(`export const ${name} = createCaller(${name}Endpoint);`);
|
|
134
|
+
}
|
|
135
|
+
lines.push('');
|
|
136
|
+
// Also export as a single api object
|
|
131
137
|
lines.push('export const api = {');
|
|
132
138
|
for (const name of endpointNames) {
|
|
133
|
-
lines.push(` ${name}
|
|
139
|
+
lines.push(` ${name},`);
|
|
134
140
|
}
|
|
135
141
|
lines.push('};');
|
|
136
142
|
lines.push('');
|