zitejs 0.9.73 → 0.9.74
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/backend/index.d.ts +7 -1
- package/dist/cjs/dev/index.js +13 -1
- package/dist/cjs/sync/lib.d.ts +1 -1
- package/dist/cjs/sync/lib.js +21 -2
- package/dist/esm/backend/index.d.ts +7 -1
- package/dist/esm/cli.js +0 -0
- package/dist/esm/dev/index.js +13 -1
- package/dist/esm/sync/lib.d.ts +1 -1
- package/dist/esm/sync/lib.js +21 -2
- package/package.json +1 -1
- package/dist/cjs/api/index.js +0 -5
- package/dist/cjs/db/index.js +0 -5
- package/dist/esm/api/index.d.ts +0 -2
- package/dist/esm/api/index.js +0 -1
- package/dist/esm/db/index.d.ts +0 -2
- package/dist/esm/db/index.js +0 -1
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { ZiteSchedule } from "../schedules/index.js";
|
|
2
|
+
export type { ZiteSchedule };
|
|
3
|
+
export type ZiteWebhook = {
|
|
4
|
+
paused?: boolean;
|
|
5
|
+
};
|
|
1
6
|
export interface ZiteRequestContext {
|
|
2
7
|
user: {
|
|
3
8
|
id: string;
|
|
@@ -31,6 +36,8 @@ export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream ext
|
|
|
31
36
|
outputSchema?: SchemaLike<TOutput>;
|
|
32
37
|
stream?: TStream;
|
|
33
38
|
authenticated?: boolean;
|
|
39
|
+
schedule?: ZiteSchedule;
|
|
40
|
+
webhook?: ZiteWebhook;
|
|
34
41
|
execute: (params: {
|
|
35
42
|
input: TInput;
|
|
36
43
|
context: ZiteRequestContext | ZiteScheduledContext;
|
|
@@ -39,4 +46,3 @@ export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream ext
|
|
|
39
46
|
} : {})) => Promise<TOutput> | TOutput;
|
|
40
47
|
}
|
|
41
48
|
export declare function createEndpoint<TInput = unknown, TOutput = unknown, TStream extends boolean = false>(config: EndpointConfig<TInput, TOutput, TStream>): EndpointConfig<TInput, TOutput, TStream>;
|
|
42
|
-
export {};
|
package/dist/cjs/dev/index.js
CHANGED
|
@@ -52,6 +52,18 @@ function getEmailIntegrationId(appDir) {
|
|
|
52
52
|
catch { }
|
|
53
53
|
return undefined;
|
|
54
54
|
}
|
|
55
|
+
function getDeclaredEnvVarNames(appDir) {
|
|
56
|
+
try {
|
|
57
|
+
const configPath = (0, path_1.join)("apps", appDir, "zite.config.json");
|
|
58
|
+
if (!(0, fs_2.existsSync)(configPath))
|
|
59
|
+
return [];
|
|
60
|
+
const config = JSON.parse((0, fs_2.readFileSync)(configPath, "utf-8"));
|
|
61
|
+
return Object.keys(config.envVars ?? {});
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
55
67
|
function regenerateAppTypedWrappers(appDir) {
|
|
56
68
|
const outDir = (0, path_1.join)("apps", appDir, ".zite");
|
|
57
69
|
(0, fs_2.mkdirSync)(outDir, { recursive: true });
|
|
@@ -66,7 +78,7 @@ function regenerateAppTypedWrappers(appDir) {
|
|
|
66
78
|
(0, fs_2.mkdirSync)(intDir, { recursive: true });
|
|
67
79
|
(0, fs_2.writeFileSync)((0, path_1.join)(intDir, "email.ts"), (0, lib_js_1.generateEmailSdk)(emailIntegrationId));
|
|
68
80
|
}
|
|
69
|
-
(0, fs_2.writeFileSync)((0, path_1.join)(outDir, "backend.ts"), (0, lib_js_1.generateBackendWrapperTs)());
|
|
81
|
+
(0, fs_2.writeFileSync)((0, path_1.join)(outDir, "backend.ts"), (0, lib_js_1.generateBackendWrapperTs)(getDeclaredEnvVarNames(appDir)));
|
|
70
82
|
}
|
|
71
83
|
function regenerateAppApiTs(appDir) {
|
|
72
84
|
const apiDir = (0, path_1.join)("apps", appDir, "src", "api");
|
package/dist/cjs/sync/lib.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export type AirtableLock = {
|
|
|
58
58
|
tables: AirtableLockTable[];
|
|
59
59
|
};
|
|
60
60
|
export declare function generateAirtableTs(lock: AirtableLock): string | null;
|
|
61
|
-
export declare function generateBackendWrapperTs(): string;
|
|
61
|
+
export declare function generateBackendWrapperTs(envVarNames?: string[]): string;
|
|
62
62
|
/**
|
|
63
63
|
* Generate `.zite/integrations/email.ts` — the `Email` client for an app with
|
|
64
64
|
* an email integration connected. Mirrors the airtable SDK generation: a thin
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -700,14 +700,20 @@ function generateAirtableTs(lock) {
|
|
|
700
700
|
}
|
|
701
701
|
return lines.join("\n");
|
|
702
702
|
}
|
|
703
|
-
function generateBackendWrapperTs() {
|
|
703
|
+
function generateBackendWrapperTs(envVarNames = []) {
|
|
704
|
+
const names = [
|
|
705
|
+
"ZITE_APP_URL",
|
|
706
|
+
...envVarNames.filter((n) => n !== "ZITE_APP_URL"),
|
|
707
|
+
];
|
|
704
708
|
return [
|
|
705
709
|
"// Auto-generated type-narrowing wrapper. Do not edit manually.",
|
|
706
710
|
"// Re-exports createEndpoint with context.user typed to the app User.",
|
|
707
711
|
"",
|
|
708
|
-
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext as _ZiteScheduledContext } from 'zitejs/backend/base';",
|
|
712
|
+
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext as _ZiteScheduledContext, ZiteSchedule, ZiteWebhook } from 'zitejs/backend/base';",
|
|
709
713
|
"import type { User } from './user';",
|
|
710
714
|
"",
|
|
715
|
+
"export type { ZiteSchedule, ZiteWebhook };",
|
|
716
|
+
"",
|
|
711
717
|
"export class ZiteError extends Error {",
|
|
712
718
|
" statusCode: number;",
|
|
713
719
|
" constructor(message: string, options?: { statusCode?: number }) {",
|
|
@@ -734,6 +740,8 @@ function generateBackendWrapperTs() {
|
|
|
734
740
|
" outputSchema?: SchemaLike<TOutput>;",
|
|
735
741
|
" stream?: boolean;",
|
|
736
742
|
" authenticated?: boolean;",
|
|
743
|
+
" schedule?: ZiteSchedule;",
|
|
744
|
+
" webhook?: ZiteWebhook;",
|
|
737
745
|
" execute: (params: { input: TInput; context: ZiteRequestContext | ZiteScheduledContext }) => Promise<TOutput> | TOutput;",
|
|
738
746
|
"}",
|
|
739
747
|
"",
|
|
@@ -743,6 +751,17 @@ function generateBackendWrapperTs() {
|
|
|
743
751
|
" return config;",
|
|
744
752
|
"}",
|
|
745
753
|
"",
|
|
754
|
+
// Declared in the wrapper (not a standalone .d.ts) so the merge is
|
|
755
|
+
// guaranteed to be in the program — every endpoint imports this file,
|
|
756
|
+
// while tsconfig `include` does not reliably pick up dot-directories.
|
|
757
|
+
"declare global {",
|
|
758
|
+
" namespace NodeJS {",
|
|
759
|
+
" interface ProcessEnv {",
|
|
760
|
+
...names.map((name) => ` ${JSON.stringify(name)}: string;`),
|
|
761
|
+
" }",
|
|
762
|
+
" }",
|
|
763
|
+
"}",
|
|
764
|
+
"",
|
|
746
765
|
].join("\n");
|
|
747
766
|
}
|
|
748
767
|
/**
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { ZiteSchedule } from "../schedules/index.js";
|
|
2
|
+
export type { ZiteSchedule };
|
|
3
|
+
export type ZiteWebhook = {
|
|
4
|
+
paused?: boolean;
|
|
5
|
+
};
|
|
1
6
|
export interface ZiteRequestContext {
|
|
2
7
|
user: {
|
|
3
8
|
id: string;
|
|
@@ -31,6 +36,8 @@ export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream ext
|
|
|
31
36
|
outputSchema?: SchemaLike<TOutput>;
|
|
32
37
|
stream?: TStream;
|
|
33
38
|
authenticated?: boolean;
|
|
39
|
+
schedule?: ZiteSchedule;
|
|
40
|
+
webhook?: ZiteWebhook;
|
|
34
41
|
execute: (params: {
|
|
35
42
|
input: TInput;
|
|
36
43
|
context: ZiteRequestContext | ZiteScheduledContext;
|
|
@@ -39,4 +46,3 @@ export interface EndpointConfig<TInput = unknown, TOutput = unknown, TStream ext
|
|
|
39
46
|
} : {})) => Promise<TOutput> | TOutput;
|
|
40
47
|
}
|
|
41
48
|
export declare function createEndpoint<TInput = unknown, TOutput = unknown, TStream extends boolean = false>(config: EndpointConfig<TInput, TOutput, TStream>): EndpointConfig<TInput, TOutput, TStream>;
|
|
42
|
-
export {};
|
package/dist/esm/cli.js
CHANGED
|
File without changes
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -48,6 +48,18 @@ function getEmailIntegrationId(appDir) {
|
|
|
48
48
|
catch { }
|
|
49
49
|
return undefined;
|
|
50
50
|
}
|
|
51
|
+
function getDeclaredEnvVarNames(appDir) {
|
|
52
|
+
try {
|
|
53
|
+
const configPath = join("apps", appDir, "zite.config.json");
|
|
54
|
+
if (!existsSync(configPath))
|
|
55
|
+
return [];
|
|
56
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
57
|
+
return Object.keys(config.envVars ?? {});
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
51
63
|
function regenerateAppTypedWrappers(appDir) {
|
|
52
64
|
const outDir = join("apps", appDir, ".zite");
|
|
53
65
|
mkdirSync(outDir, { recursive: true });
|
|
@@ -62,7 +74,7 @@ function regenerateAppTypedWrappers(appDir) {
|
|
|
62
74
|
mkdirSync(intDir, { recursive: true });
|
|
63
75
|
writeFileSync(join(intDir, "email.ts"), generateEmailSdk(emailIntegrationId));
|
|
64
76
|
}
|
|
65
|
-
writeFileSync(join(outDir, "backend.ts"), generateBackendWrapperTs());
|
|
77
|
+
writeFileSync(join(outDir, "backend.ts"), generateBackendWrapperTs(getDeclaredEnvVarNames(appDir)));
|
|
66
78
|
}
|
|
67
79
|
function regenerateAppApiTs(appDir) {
|
|
68
80
|
const apiDir = join("apps", appDir, "src", "api");
|
package/dist/esm/sync/lib.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export type AirtableLock = {
|
|
|
58
58
|
tables: AirtableLockTable[];
|
|
59
59
|
};
|
|
60
60
|
export declare function generateAirtableTs(lock: AirtableLock): string | null;
|
|
61
|
-
export declare function generateBackendWrapperTs(): string;
|
|
61
|
+
export declare function generateBackendWrapperTs(envVarNames?: string[]): string;
|
|
62
62
|
/**
|
|
63
63
|
* Generate `.zite/integrations/email.ts` — the `Email` client for an app with
|
|
64
64
|
* an email integration connected. Mirrors the airtable SDK generation: a thin
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -688,14 +688,20 @@ export function generateAirtableTs(lock) {
|
|
|
688
688
|
}
|
|
689
689
|
return lines.join("\n");
|
|
690
690
|
}
|
|
691
|
-
export function generateBackendWrapperTs() {
|
|
691
|
+
export function generateBackendWrapperTs(envVarNames = []) {
|
|
692
|
+
const names = [
|
|
693
|
+
"ZITE_APP_URL",
|
|
694
|
+
...envVarNames.filter((n) => n !== "ZITE_APP_URL"),
|
|
695
|
+
];
|
|
692
696
|
return [
|
|
693
697
|
"// Auto-generated type-narrowing wrapper. Do not edit manually.",
|
|
694
698
|
"// Re-exports createEndpoint with context.user typed to the app User.",
|
|
695
699
|
"",
|
|
696
|
-
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext as _ZiteScheduledContext } from 'zitejs/backend/base';",
|
|
700
|
+
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext as _ZiteScheduledContext, ZiteSchedule, ZiteWebhook } from 'zitejs/backend/base';",
|
|
697
701
|
"import type { User } from './user';",
|
|
698
702
|
"",
|
|
703
|
+
"export type { ZiteSchedule, ZiteWebhook };",
|
|
704
|
+
"",
|
|
699
705
|
"export class ZiteError extends Error {",
|
|
700
706
|
" statusCode: number;",
|
|
701
707
|
" constructor(message: string, options?: { statusCode?: number }) {",
|
|
@@ -722,6 +728,8 @@ export function generateBackendWrapperTs() {
|
|
|
722
728
|
" outputSchema?: SchemaLike<TOutput>;",
|
|
723
729
|
" stream?: boolean;",
|
|
724
730
|
" authenticated?: boolean;",
|
|
731
|
+
" schedule?: ZiteSchedule;",
|
|
732
|
+
" webhook?: ZiteWebhook;",
|
|
725
733
|
" execute: (params: { input: TInput; context: ZiteRequestContext | ZiteScheduledContext }) => Promise<TOutput> | TOutput;",
|
|
726
734
|
"}",
|
|
727
735
|
"",
|
|
@@ -731,6 +739,17 @@ export function generateBackendWrapperTs() {
|
|
|
731
739
|
" return config;",
|
|
732
740
|
"}",
|
|
733
741
|
"",
|
|
742
|
+
// Declared in the wrapper (not a standalone .d.ts) so the merge is
|
|
743
|
+
// guaranteed to be in the program — every endpoint imports this file,
|
|
744
|
+
// while tsconfig `include` does not reliably pick up dot-directories.
|
|
745
|
+
"declare global {",
|
|
746
|
+
" namespace NodeJS {",
|
|
747
|
+
" interface ProcessEnv {",
|
|
748
|
+
...names.map((name) => ` ${JSON.stringify(name)}: string;`),
|
|
749
|
+
" }",
|
|
750
|
+
" }",
|
|
751
|
+
"}",
|
|
752
|
+
"",
|
|
734
753
|
].join("\n");
|
|
735
754
|
}
|
|
736
755
|
/**
|
package/package.json
CHANGED
package/dist/cjs/api/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCaller = void 0;
|
|
4
|
-
var index_js_1 = require("../caller/index.js");
|
|
5
|
-
Object.defineProperty(exports, "createCaller", { enumerable: true, get: function () { return index_js_1.createCaller; } });
|
package/dist/cjs/db/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTableClient = void 0;
|
|
4
|
-
var index_js_1 = require("../runtime/index.js");
|
|
5
|
-
Object.defineProperty(exports, "createTableClient", { enumerable: true, get: function () { return index_js_1.createTableClient; } });
|
package/dist/esm/api/index.d.ts
DELETED
package/dist/esm/api/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createCaller } from '../caller/index.js';
|
package/dist/esm/db/index.d.ts
DELETED
package/dist/esm/db/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createTableClient } from '../runtime/index.js';
|