zitejs 0.8.3 → 0.9.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.
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCaller = void 0;
4
- var index_js_1 = require("../runtime/index.js");
4
+ var index_js_1 = require("../caller/index.js");
5
5
  Object.defineProperty(exports, "createCaller", { enumerable: true, get: function () { return index_js_1.createCaller; } });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCaller = createCaller;
4
+ const ENVIRONMENTS = {
5
+ production: 'https://workflows.zite.com',
6
+ staging: 'https://workflows.zitestaging.com',
7
+ local: 'http://localhost:2506',
8
+ };
9
+ function getRunnerUrl() {
10
+ const env = (typeof process !== 'undefined' && process.env?.ZITE_ENV) || 'production';
11
+ return ((typeof process !== 'undefined' && process.env?.ZITE_RUNNER_URL) ||
12
+ ENVIRONMENTS[env] ||
13
+ ENVIRONMENTS.production);
14
+ }
15
+ function getToken() {
16
+ return (typeof process !== 'undefined' && process.env?.ZITE_DB_TOKEN) || '';
17
+ }
18
+ function createCaller(endpoint) {
19
+ return async (input) => {
20
+ const res = await fetch(getRunnerUrl() + '/api/' + endpoint._name, {
21
+ method: 'POST',
22
+ headers: {
23
+ Authorization: `Bearer ${getToken()}`,
24
+ 'Content-Type': 'application/json',
25
+ },
26
+ body: JSON.stringify(input),
27
+ });
28
+ if (!res.ok) {
29
+ const text = await res.text().catch(() => '');
30
+ throw new Error(`API call failed (${res.status}): ${text}`);
31
+ }
32
+ return res.json();
33
+ };
34
+ }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCaller = void 0;
3
4
  exports.wrapSdkCall = wrapSdkCall;
4
5
  exports.createTableClient = createTableClient;
5
- exports.createCaller = createCaller;
6
6
  const ENVIRONMENTS = {
7
7
  production: 'https://workflows.zite.com',
8
8
  staging: 'https://workflows.zitestaging.com',
@@ -51,20 +51,5 @@ function createTableClient(integrationId, className) {
51
51
  }),
52
52
  };
53
53
  }
54
- function createCaller(endpoint) {
55
- return async (input) => {
56
- const res = await fetch(getRunnerUrl() + '/api/' + endpoint._name, {
57
- method: 'POST',
58
- headers: {
59
- Authorization: `Bearer ${getToken()}`,
60
- 'Content-Type': 'application/json',
61
- },
62
- body: JSON.stringify(input),
63
- });
64
- if (!res.ok) {
65
- const text = await res.text().catch(() => '');
66
- throw new Error(`API call failed (${res.status}): ${text}`);
67
- }
68
- return res.json();
69
- };
70
- }
54
+ var index_js_1 = require("../caller/index.js");
55
+ Object.defineProperty(exports, "createCaller", { enumerable: true, get: function () { return index_js_1.createCaller; } });
@@ -125,7 +125,7 @@ function generateApiTs(endpointFiles) {
125
125
  const lines = [
126
126
  '// Auto-generated by zitejs sync. Do not edit manually.',
127
127
  '',
128
- "import { createCaller } from 'zitejs/runtime';",
128
+ "import { createCaller } from 'zitejs/caller';",
129
129
  '',
130
130
  ];
131
131
  const endpointNames = [];
@@ -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}: createCaller(${name}Endpoint),`);
147
+ lines.push(` ${name},`);
142
148
  }
143
149
  lines.push('};');
144
150
  lines.push('');
@@ -1,2 +1,2 @@
1
- export { createCaller } from '../runtime/index.js';
2
- export type { EndpointConfig } from '../runtime/index.js';
1
+ export { createCaller } from '../caller/index.js';
2
+ export type { EndpointConfig } from '../caller/index.js';
@@ -1 +1 @@
1
- export { createCaller } from '../runtime/index.js';
1
+ export { createCaller } from '../caller/index.js';
@@ -0,0 +1,8 @@
1
+ export interface EndpointConfig<TInput = unknown, TOutput = unknown> {
2
+ _name?: string;
3
+ execute: (params: {
4
+ input: TInput;
5
+ context: unknown;
6
+ }) => Promise<TOutput> | TOutput;
7
+ }
8
+ export declare function createCaller<TInput, TOutput>(endpoint: EndpointConfig<TInput, TOutput>): (input: TInput) => Promise<TOutput>;
@@ -0,0 +1,31 @@
1
+ const ENVIRONMENTS = {
2
+ production: 'https://workflows.zite.com',
3
+ staging: 'https://workflows.zitestaging.com',
4
+ local: 'http://localhost:2506',
5
+ };
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
+ }
15
+ export function createCaller(endpoint) {
16
+ return async (input) => {
17
+ const res = await fetch(getRunnerUrl() + '/api/' + endpoint._name, {
18
+ method: 'POST',
19
+ headers: {
20
+ Authorization: `Bearer ${getToken()}`,
21
+ 'Content-Type': 'application/json',
22
+ },
23
+ body: JSON.stringify(input),
24
+ });
25
+ if (!res.ok) {
26
+ const text = await res.text().catch(() => '');
27
+ throw new Error(`API call failed (${res.status}): ${text}`);
28
+ }
29
+ return res.json();
30
+ };
31
+ }
@@ -19,11 +19,5 @@ export interface TableClient<T> {
19
19
  bulkCreate(records: Partial<T>[]): Promise<T[]>;
20
20
  }
21
21
  export declare function createTableClient<T>(integrationId: string, className: string): TableClient<T>;
22
- export interface EndpointConfig<TInput = unknown, TOutput = unknown> {
23
- _name?: string;
24
- execute: (params: {
25
- input: TInput;
26
- context: unknown;
27
- }) => Promise<TOutput> | TOutput;
28
- }
29
- export declare function createCaller<TInput, TOutput>(endpoint: EndpointConfig<TInput, TOutput>): (input: TInput) => Promise<TOutput>;
22
+ export { createCaller } from '../caller/index.js';
23
+ export type { EndpointConfig } from '../caller/index.js';
@@ -46,20 +46,4 @@ export function createTableClient(integrationId, className) {
46
46
  }),
47
47
  };
48
48
  }
49
- export function createCaller(endpoint) {
50
- return async (input) => {
51
- const res = await fetch(getRunnerUrl() + '/api/' + endpoint._name, {
52
- method: 'POST',
53
- headers: {
54
- Authorization: `Bearer ${getToken()}`,
55
- 'Content-Type': 'application/json',
56
- },
57
- body: JSON.stringify(input),
58
- });
59
- if (!res.ok) {
60
- const text = await res.text().catch(() => '');
61
- throw new Error(`API call failed (${res.status}): ${text}`);
62
- }
63
- return res.json();
64
- };
65
- }
49
+ export { createCaller } from '../caller/index.js';
@@ -117,7 +117,7 @@ export function generateApiTs(endpointFiles) {
117
117
  const lines = [
118
118
  '// Auto-generated by zitejs sync. Do not edit manually.',
119
119
  '',
120
- "import { createCaller } from 'zitejs/runtime';",
120
+ "import { createCaller } from 'zitejs/caller';",
121
121
  '',
122
122
  ];
123
123
  const endpointNames = [];
@@ -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}: createCaller(${name}Endpoint),`);
139
+ lines.push(` ${name},`);
134
140
  }
135
141
  lines.push('};');
136
142
  lines.push('');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.8.3",
3
+ "version": "0.9.1",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/runtime/index.js",
@@ -16,6 +16,12 @@
16
16
  "require": "./dist/cjs/runtime/index.js",
17
17
  "default": "./dist/esm/runtime/index.js"
18
18
  },
19
+ "./caller": {
20
+ "types": "./dist/esm/caller/index.d.ts",
21
+ "import": "./dist/esm/caller/index.js",
22
+ "require": "./dist/cjs/caller/index.js",
23
+ "default": "./dist/esm/caller/index.js"
24
+ },
19
25
  "./db": {
20
26
  "types": "./dist/esm/db/index.d.ts",
21
27
  "import": "./dist/esm/db/index.js",