zitejs 0.8.2 → 0.8.3

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.
@@ -8,14 +8,20 @@ const ENVIRONMENTS = {
8
8
  staging: 'https://workflows.zitestaging.com',
9
9
  local: 'http://localhost:2506',
10
10
  };
11
- const env = process.env.ZITE_ENV ?? 'production';
12
- const RUNNER_URL = process.env.ZITE_RUNNER_URL ?? ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
13
- const TOKEN = process.env.ZITE_DB_TOKEN ?? '';
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(`${RUNNER_URL}/sdk/execute`, {
21
+ const res = await fetch(`${getRunnerUrl()}/sdk/execute`, {
16
22
  method: 'POST',
17
23
  headers: {
18
- Authorization: `Bearer ${TOKEN}`,
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(runnerUrl + '/api/' + endpoint._name, {
56
+ const res = await fetch(getRunnerUrl() + '/api/' + endpoint._name, {
53
57
  method: 'POST',
54
58
  headers: {
55
- Authorization: `Bearer ${token}`,
59
+ Authorization: `Bearer ${getToken()}`,
56
60
  'Content-Type': 'application/json',
57
61
  },
58
62
  body: JSON.stringify(input),
@@ -3,14 +3,20 @@ const ENVIRONMENTS = {
3
3
  staging: 'https://workflows.zitestaging.com',
4
4
  local: 'http://localhost:2506',
5
5
  };
6
- const env = process.env.ZITE_ENV ?? 'production';
7
- const RUNNER_URL = process.env.ZITE_RUNNER_URL ?? ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
8
- const TOKEN = process.env.ZITE_DB_TOKEN ?? '';
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(`${RUNNER_URL}/sdk/execute`, {
16
+ const res = await fetch(`${getRunnerUrl()}/sdk/execute`, {
11
17
  method: 'POST',
12
18
  headers: {
13
- Authorization: `Bearer ${TOKEN}`,
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(runnerUrl + '/api/' + endpoint._name, {
51
+ const res = await fetch(getRunnerUrl() + '/api/' + endpoint._name, {
48
52
  method: 'POST',
49
53
  headers: {
50
- Authorization: `Bearer ${token}`,
54
+ Authorization: `Bearer ${getToken()}`,
51
55
  'Content-Type': 'application/json',
52
56
  },
53
57
  body: JSON.stringify(input),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/runtime/index.js",