@madebyentropy/tnl 0.0.0-stage → 0.1.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/LICENSE +28 -0
- package/NOTICE +5 -0
- package/THIRD_PARTY_LICENSES.txt +3297 -0
- package/dist/adapters/ioredis.d.ts +7 -0
- package/dist/adapters/ioredis.js +87 -0
- package/dist/adapters/node-postgres.d.ts +8 -0
- package/dist/adapters/node-postgres.js +41 -0
- package/dist/adapters/postgres-js.d.ts +7 -0
- package/dist/adapters/postgres-js.js +55 -0
- package/dist/bin/tnl.d.ts +2 -0
- package/dist/bin/tnl.js +16 -0
- package/dist/browser.d.ts +18 -0
- package/dist/browser.js +43 -0
- package/dist/bun.d.ts +9 -0
- package/dist/bun.js +6 -0
- package/dist/cloudflare.d.ts +9 -0
- package/dist/cloudflare.js +16 -0
- package/dist/config.d.ts +107 -0
- package/dist/config.gen.d.ts +1185 -0
- package/dist/config.gen.js +2 -0
- package/dist/config.js +3 -0
- package/dist/control.d.ts +5 -0
- package/dist/control.js +9 -0
- package/dist/durable-object.d.ts +51 -0
- package/dist/durable-object.js +374 -0
- package/dist/durable-object.worker.d.ts +5 -0
- package/dist/durable-object.worker.js +11 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.js +230 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2 -0
- package/dist/internal/connector/cancellation.d.ts +7 -0
- package/dist/internal/connector/cancellation.js +30 -0
- package/dist/internal/connector/client.d.ts +62 -0
- package/dist/internal/connector/client.js +504 -0
- package/dist/internal/connector/client_factory.d.ts +6 -0
- package/dist/internal/connector/client_factory.js +123 -0
- package/dist/internal/connector/connection.d.ts +39 -0
- package/dist/internal/connector/connection.js +739 -0
- package/dist/internal/connector/connection_ipc.d.ts +12 -0
- package/dist/internal/connector/connection_ipc.js +198 -0
- package/dist/internal/connector/context.d.ts +28 -0
- package/dist/internal/connector/context.js +19 -0
- package/dist/internal/connector/contract.d.ts +392 -0
- package/dist/internal/connector/contract.js +56 -0
- package/dist/internal/connector/deployment_types.d.ts +27 -0
- package/dist/internal/connector/deployment_types.js +1 -0
- package/dist/internal/connector/driver_socket.d.ts +21 -0
- package/dist/internal/connector/driver_socket.js +129 -0
- package/dist/internal/connector/management.d.ts +29 -0
- package/dist/internal/connector/management.js +118 -0
- package/dist/internal/connector/native_operations.d.ts +16 -0
- package/dist/internal/connector/native_operations.js +30 -0
- package/dist/internal/connector/native_stream.d.ts +7 -0
- package/dist/internal/connector/native_stream.js +219 -0
- package/dist/internal/connector/operation_handles.d.ts +9 -0
- package/dist/internal/connector/operation_handles.js +18 -0
- package/dist/internal/connector/portable_operations.d.ts +13 -0
- package/dist/internal/connector/portable_operations.js +25 -0
- package/dist/internal/connector/snapshot.d.ts +183 -0
- package/dist/internal/connector/snapshot.js +47 -0
- package/dist/internal/connector/wasm_abi.d.ts +76 -0
- package/dist/internal/connector/wasm_abi.js +5 -0
- package/dist/internal/connector/wasm_client.d.ts +58 -0
- package/dist/internal/connector/wasm_client.js +545 -0
- package/dist/internal/connector/wasm_loader.d.ts +15 -0
- package/dist/internal/connector/wasm_loader.js +99 -0
- package/dist/internal/connector/wasm_stream.d.ts +4 -0
- package/dist/internal/connector/wasm_stream.js +177 -0
- package/dist/internal/connector/workload/contract.d.ts +54 -0
- package/dist/internal/connector/workload/contract.js +14 -0
- package/dist/internal/connector/workload/provider.d.ts +24 -0
- package/dist/internal/connector/workload/provider.js +130 -0
- package/dist/internal/enrollment_source.d.ts +4 -0
- package/dist/internal/enrollment_source.js +34 -0
- package/dist/internal/management/client/client.gen.d.ts +2 -0
- package/dist/internal/management/client/client.gen.js +216 -0
- package/dist/internal/management/client/index.d.ts +10 -0
- package/dist/internal/management/client/index.js +6 -0
- package/dist/internal/management/client/types.gen.d.ts +120 -0
- package/dist/internal/management/client/types.gen.js +2 -0
- package/dist/internal/management/client/utils.gen.d.ts +37 -0
- package/dist/internal/management/client/utils.gen.js +228 -0
- package/dist/internal/management/client.gen.d.ts +12 -0
- package/dist/internal/management/client.gen.js +3 -0
- package/dist/internal/management/core/auth.gen.d.ts +25 -0
- package/dist/internal/management/core/auth.gen.js +14 -0
- package/dist/internal/management/core/bodySerializer.gen.d.ts +25 -0
- package/dist/internal/management/core/bodySerializer.gen.js +57 -0
- package/dist/internal/management/core/params.gen.d.ts +43 -0
- package/dist/internal/management/core/params.gen.js +109 -0
- package/dist/internal/management/core/pathSerializer.gen.d.ts +33 -0
- package/dist/internal/management/core/pathSerializer.gen.js +106 -0
- package/dist/internal/management/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/internal/management/core/queryKeySerializer.gen.js +92 -0
- package/dist/internal/management/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/internal/management/core/serverSentEvents.gen.js +132 -0
- package/dist/internal/management/core/types.gen.d.ts +83 -0
- package/dist/internal/management/core/types.gen.js +2 -0
- package/dist/internal/management/core/utils.gen.d.ts +19 -0
- package/dist/internal/management/core/utils.gen.js +87 -0
- package/dist/internal/management/index.d.ts +2 -0
- package/dist/internal/management/index.js +2 -0
- package/dist/internal/management/sdk.gen.d.ts +73 -0
- package/dist/internal/management/sdk.gen.js +191 -0
- package/dist/internal/management/types.gen.d.ts +464 -0
- package/dist/internal/management/types.gen.js +2 -0
- package/dist/internal/management/zod.gen.d.ts +850 -0
- package/dist/internal/management/zod.gen.js +252 -0
- package/dist/internal/native/launcher.d.ts +8 -0
- package/dist/internal/native/launcher.js +75 -0
- package/dist/internal/native/native-targets.d.ts +9 -0
- package/dist/internal/native/native-targets.js +8 -0
- package/dist/internal/portable/cloudflare-publisher-client.d.ts +54 -0
- package/dist/internal/portable/cloudflare-publisher-client.js +91 -0
- package/dist/internal/portable/cloudflare-publisher.d.ts +19 -0
- package/dist/internal/portable/cloudflare-publisher.js +210 -0
- package/dist/internal/portable/durable-deployment.d.ts +10 -0
- package/dist/internal/portable/durable-deployment.js +22 -0
- package/dist/internal/portable/enrollment.d.ts +26 -0
- package/dist/internal/portable/enrollment.js +196 -0
- package/dist/internal/portable/publication.d.ts +54 -0
- package/dist/internal/portable/publication.js +304 -0
- package/dist/internal/portable/request.d.ts +1 -0
- package/dist/internal/portable/request.js +20 -0
- package/dist/internal/portable/storage-browser.d.ts +9 -0
- package/dist/internal/portable/storage-browser.js +115 -0
- package/dist/internal/portable/storage-durable-object.d.ts +11 -0
- package/dist/internal/portable/storage-durable-object.js +110 -0
- package/dist/internal/portable/storage-host.d.ts +8 -0
- package/dist/internal/portable/storage-host.js +142 -0
- package/dist/internal/portable/storage.d.ts +15 -0
- package/dist/internal/portable/storage.js +29 -0
- package/dist/internal/project/native_runtime.d.ts +24 -0
- package/dist/internal/project/native_runtime.js +23 -0
- package/dist/internal/project/runtime.d.ts +467 -0
- package/dist/internal/project/runtime.js +183 -0
- package/dist/internal/project/service_metadata.d.ts +3 -0
- package/dist/internal/project/service_metadata.js +12 -0
- package/dist/internal/publication_certificate.d.ts +28 -0
- package/dist/internal/publication_certificate.js +32 -0
- package/dist/internal/publication_run.d.ts +8 -0
- package/dist/internal/publication_run.js +19 -0
- package/dist/internal/publisher/app.d.ts +33 -0
- package/dist/internal/publisher/app.js +317 -0
- package/dist/internal/publisher/fetch.d.ts +6 -0
- package/dist/internal/publisher/fetch.js +135 -0
- package/dist/internal/publisher/fetch_types.d.ts +1 -0
- package/dist/internal/publisher/fetch_types.js +1 -0
- package/dist/internal/publisher/framework.d.ts +27 -0
- package/dist/internal/publisher/framework.js +82 -0
- package/dist/internal/publisher/local.d.ts +39 -0
- package/dist/internal/publisher/local.js +312 -0
- package/dist/internal/publisher/native_publisher.d.ts +25 -0
- package/dist/internal/publisher/native_publisher.js +228 -0
- package/dist/internal/publisher/port.d.ts +2 -0
- package/dist/internal/publisher/port.js +15 -0
- package/dist/internal/publisher/publication.d.ts +88 -0
- package/dist/internal/publisher/publication.js +627 -0
- package/dist/internal/publisher/register.d.ts +31 -0
- package/dist/internal/publisher/register.js +136 -0
- package/dist/internal/publisher/registration.d.ts +385 -0
- package/dist/internal/publisher/registration.js +223 -0
- package/dist/internal/publisher/status.d.ts +47 -0
- package/dist/internal/publisher/status.js +137 -0
- package/dist/internal/publisher/target.d.ts +6 -0
- package/dist/internal/publisher/target.js +44 -0
- package/dist/internal/runtime_resources.d.ts +38 -0
- package/dist/internal/runtime_resources.js +52 -0
- package/dist/internal/tracing.d.ts +10 -0
- package/dist/internal/tracing.js +78 -0
- package/dist/internal/validation.d.ts +3 -0
- package/dist/internal/validation.js +9 -0
- package/dist/internal/values.d.ts +27 -0
- package/dist/internal/values.js +54 -0
- package/dist/next.d.ts +12 -0
- package/dist/next.js +82 -0
- package/dist/node.d.ts +9 -0
- package/dist/node.js +6 -0
- package/dist/project.d.ts +173 -0
- package/dist/project.js +1 -0
- package/dist/response.d.ts +1 -0
- package/dist/response.js +34 -0
- package/dist/third-party-licenses.txt +1537 -0
- package/dist/vite.d.ts +5 -0
- package/dist/vite.js +200 -0
- package/dist/wasm/build.json +16 -0
- package/dist/wasm/connector.wasm +0 -0
- package/dist/wasm/go-license.txt +27 -0
- package/dist/wasm/publisher.wasm +0 -0
- package/dist/wasm/third-party-licenses.txt +3297 -0
- package/dist/wasm/wasm_exec.d.ts +1 -0
- package/dist/wasm/wasm_exec.js +575 -0
- package/dist/workload.d.ts +11 -0
- package/dist/workload.js +4 -0
- package/package.json +159 -4
- package/readme.md +13 -0
- package/README.md +0 -3
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { protocolSchema } from "../values.js";
|
|
3
|
+
declare const worktreeLabelSchema: z.ZodReadonly<z.ZodObject<{
|
|
4
|
+
project: z.ZodString;
|
|
5
|
+
checkout: z.ZodExactOptional<z.ZodString>;
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
fullLabel: z.ZodString;
|
|
8
|
+
}, z.core.$strict>>;
|
|
9
|
+
declare const pathMetadataSchema: z.ZodReadonly<z.ZodObject<{
|
|
10
|
+
service: z.ZodString;
|
|
11
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
12
|
+
stripPrefix: z.ZodBoolean;
|
|
13
|
+
}, z.core.$strict>>;
|
|
14
|
+
declare const serviceMetadataSchema: z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
15
|
+
namespace: z.ZodString;
|
|
16
|
+
hostname: z.ZodString;
|
|
17
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
18
|
+
public: z.ZodBoolean;
|
|
19
|
+
protocol: z.ZodLiteral<"http">;
|
|
20
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
21
|
+
paths: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodTemplateLiteral<`/${string}`>, z.ZodReadonly<z.ZodObject<{
|
|
22
|
+
service: z.ZodString;
|
|
23
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
24
|
+
stripPrefix: z.ZodBoolean;
|
|
25
|
+
}, z.core.$strict>>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
26
|
+
service: string;
|
|
27
|
+
url: `https://${string}`;
|
|
28
|
+
stripPrefix: boolean;
|
|
29
|
+
}> | undefined>>, Record<`/${string}`, Readonly<{
|
|
30
|
+
service: string;
|
|
31
|
+
url: `https://${string}`;
|
|
32
|
+
stripPrefix: boolean;
|
|
33
|
+
}>>>>>;
|
|
34
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
35
|
+
namespace: z.ZodString;
|
|
36
|
+
hostname: z.ZodString;
|
|
37
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
38
|
+
public: z.ZodBoolean;
|
|
39
|
+
protocol: z.ZodLiteral<"kubernetes">;
|
|
40
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
41
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
42
|
+
namespace: z.ZodString;
|
|
43
|
+
hostname: z.ZodString;
|
|
44
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
45
|
+
public: z.ZodBoolean;
|
|
46
|
+
protocol: z.ZodLiteral<"postgres">;
|
|
47
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
48
|
+
namespace: z.ZodString;
|
|
49
|
+
hostname: z.ZodString;
|
|
50
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
51
|
+
public: z.ZodBoolean;
|
|
52
|
+
protocol: z.ZodLiteral<"mysql">;
|
|
53
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
54
|
+
namespace: z.ZodString;
|
|
55
|
+
hostname: z.ZodString;
|
|
56
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
57
|
+
public: z.ZodBoolean;
|
|
58
|
+
protocol: z.ZodLiteral<"tcp">;
|
|
59
|
+
}, z.core.$strict>], "protocol">>;
|
|
60
|
+
declare const integrationOriginSchema: z.ZodReadonly<z.ZodObject<{
|
|
61
|
+
hostname: z.ZodString;
|
|
62
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
declare const webhookMethodSchema: z.ZodEnum<{
|
|
65
|
+
DELETE: "DELETE";
|
|
66
|
+
GET: "GET";
|
|
67
|
+
HEAD: "HEAD";
|
|
68
|
+
OPTIONS: "OPTIONS";
|
|
69
|
+
PATCH: "PATCH";
|
|
70
|
+
POST: "POST";
|
|
71
|
+
PUT: "PUT";
|
|
72
|
+
}>;
|
|
73
|
+
declare const webhookSchema: z.ZodReadonly<z.ZodObject<{
|
|
74
|
+
hostname: z.ZodString;
|
|
75
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
76
|
+
service: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">]>;
|
|
77
|
+
path: z.ZodTemplateLiteral<`/${string}`>;
|
|
78
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
79
|
+
DELETE: "DELETE";
|
|
80
|
+
GET: "GET";
|
|
81
|
+
HEAD: "HEAD";
|
|
82
|
+
OPTIONS: "OPTIONS";
|
|
83
|
+
PATCH: "PATCH";
|
|
84
|
+
POST: "POST";
|
|
85
|
+
PUT: "PUT";
|
|
86
|
+
}>>>;
|
|
87
|
+
}, z.core.$strict>>;
|
|
88
|
+
declare const aliasSchema: z.ZodReadonly<z.ZodObject<{
|
|
89
|
+
hostname: z.ZodString;
|
|
90
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
91
|
+
service: z.ZodString;
|
|
92
|
+
}, z.core.$strict>>;
|
|
93
|
+
export declare const projectMetadataSchema: z.ZodReadonly<z.ZodObject<{
|
|
94
|
+
namespace: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">]>;
|
|
95
|
+
services: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
96
|
+
namespace: z.ZodString;
|
|
97
|
+
hostname: z.ZodString;
|
|
98
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
99
|
+
public: z.ZodBoolean;
|
|
100
|
+
protocol: z.ZodLiteral<"http">;
|
|
101
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
102
|
+
paths: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodTemplateLiteral<`/${string}`>, z.ZodReadonly<z.ZodObject<{
|
|
103
|
+
service: z.ZodString;
|
|
104
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
105
|
+
stripPrefix: z.ZodBoolean;
|
|
106
|
+
}, z.core.$strict>>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
107
|
+
service: string;
|
|
108
|
+
url: `https://${string}`;
|
|
109
|
+
stripPrefix: boolean;
|
|
110
|
+
}> | undefined>>, Record<`/${string}`, Readonly<{
|
|
111
|
+
service: string;
|
|
112
|
+
url: `https://${string}`;
|
|
113
|
+
stripPrefix: boolean;
|
|
114
|
+
}>>>>>;
|
|
115
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
116
|
+
namespace: z.ZodString;
|
|
117
|
+
hostname: z.ZodString;
|
|
118
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
119
|
+
public: z.ZodBoolean;
|
|
120
|
+
protocol: z.ZodLiteral<"kubernetes">;
|
|
121
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
122
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
123
|
+
namespace: z.ZodString;
|
|
124
|
+
hostname: z.ZodString;
|
|
125
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
126
|
+
public: z.ZodBoolean;
|
|
127
|
+
protocol: z.ZodLiteral<"postgres">;
|
|
128
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
129
|
+
namespace: z.ZodString;
|
|
130
|
+
hostname: z.ZodString;
|
|
131
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
132
|
+
public: z.ZodBoolean;
|
|
133
|
+
protocol: z.ZodLiteral<"mysql">;
|
|
134
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
135
|
+
namespace: z.ZodString;
|
|
136
|
+
hostname: z.ZodString;
|
|
137
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
138
|
+
public: z.ZodBoolean;
|
|
139
|
+
protocol: z.ZodLiteral<"tcp">;
|
|
140
|
+
}, z.core.$strict>], "protocol">>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
141
|
+
namespace: string;
|
|
142
|
+
hostname: string;
|
|
143
|
+
port: number;
|
|
144
|
+
public: boolean;
|
|
145
|
+
protocol: "http";
|
|
146
|
+
url: `https://${string}`;
|
|
147
|
+
paths?: Readonly<Record<string, Readonly<{
|
|
148
|
+
service: string;
|
|
149
|
+
url: `https://${string}`;
|
|
150
|
+
stripPrefix: boolean;
|
|
151
|
+
}> | undefined>> | undefined;
|
|
152
|
+
}> | Readonly<{
|
|
153
|
+
namespace: string;
|
|
154
|
+
hostname: string;
|
|
155
|
+
port: number;
|
|
156
|
+
public: boolean;
|
|
157
|
+
protocol: "kubernetes";
|
|
158
|
+
url: `https://${string}`;
|
|
159
|
+
}> | Readonly<{
|
|
160
|
+
namespace: string;
|
|
161
|
+
hostname: string;
|
|
162
|
+
port: number;
|
|
163
|
+
public: boolean;
|
|
164
|
+
protocol: "postgres";
|
|
165
|
+
}> | Readonly<{
|
|
166
|
+
namespace: string;
|
|
167
|
+
hostname: string;
|
|
168
|
+
port: number;
|
|
169
|
+
public: boolean;
|
|
170
|
+
protocol: "mysql";
|
|
171
|
+
}> | Readonly<{
|
|
172
|
+
namespace: string;
|
|
173
|
+
hostname: string;
|
|
174
|
+
port: number;
|
|
175
|
+
public: boolean;
|
|
176
|
+
protocol: "tcp";
|
|
177
|
+
}> | undefined>>, Record<string, Readonly<{
|
|
178
|
+
namespace: string;
|
|
179
|
+
hostname: string;
|
|
180
|
+
port: number;
|
|
181
|
+
public: boolean;
|
|
182
|
+
protocol: "http";
|
|
183
|
+
url: `https://${string}`;
|
|
184
|
+
paths?: Readonly<Record<string, Readonly<{
|
|
185
|
+
service: string;
|
|
186
|
+
url: `https://${string}`;
|
|
187
|
+
stripPrefix: boolean;
|
|
188
|
+
}> | undefined>> | undefined;
|
|
189
|
+
}> | Readonly<{
|
|
190
|
+
namespace: string;
|
|
191
|
+
hostname: string;
|
|
192
|
+
port: number;
|
|
193
|
+
public: boolean;
|
|
194
|
+
protocol: "kubernetes";
|
|
195
|
+
url: `https://${string}`;
|
|
196
|
+
}> | Readonly<{
|
|
197
|
+
namespace: string;
|
|
198
|
+
hostname: string;
|
|
199
|
+
port: number;
|
|
200
|
+
public: boolean;
|
|
201
|
+
protocol: "postgres";
|
|
202
|
+
}> | Readonly<{
|
|
203
|
+
namespace: string;
|
|
204
|
+
hostname: string;
|
|
205
|
+
port: number;
|
|
206
|
+
public: boolean;
|
|
207
|
+
protocol: "mysql";
|
|
208
|
+
}> | Readonly<{
|
|
209
|
+
namespace: string;
|
|
210
|
+
hostname: string;
|
|
211
|
+
port: number;
|
|
212
|
+
public: boolean;
|
|
213
|
+
protocol: "tcp";
|
|
214
|
+
}>>>>;
|
|
215
|
+
worktree: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
|
|
216
|
+
label: z.ZodReadonly<z.ZodObject<{
|
|
217
|
+
project: z.ZodString;
|
|
218
|
+
checkout: z.ZodExactOptional<z.ZodString>;
|
|
219
|
+
id: z.ZodString;
|
|
220
|
+
fullLabel: z.ZodString;
|
|
221
|
+
}, z.core.$strict>>;
|
|
222
|
+
}, z.core.$strict>>>;
|
|
223
|
+
oauth: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
|
|
224
|
+
hostname: z.ZodString;
|
|
225
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
226
|
+
}, z.core.$strict>>>;
|
|
227
|
+
webhooks: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodReadonly<z.ZodObject<{
|
|
228
|
+
hostname: z.ZodString;
|
|
229
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
230
|
+
service: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">]>;
|
|
231
|
+
path: z.ZodTemplateLiteral<`/${string}`>;
|
|
232
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
233
|
+
DELETE: "DELETE";
|
|
234
|
+
GET: "GET";
|
|
235
|
+
HEAD: "HEAD";
|
|
236
|
+
OPTIONS: "OPTIONS";
|
|
237
|
+
PATCH: "PATCH";
|
|
238
|
+
POST: "POST";
|
|
239
|
+
PUT: "PUT";
|
|
240
|
+
}>>>;
|
|
241
|
+
}, z.core.$strict>>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
242
|
+
hostname: string;
|
|
243
|
+
url: `https://${string}`;
|
|
244
|
+
service: string;
|
|
245
|
+
path: `/${string}`;
|
|
246
|
+
methods: readonly ("DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT")[];
|
|
247
|
+
}> | undefined>>, Record<string, Readonly<{
|
|
248
|
+
hostname: string;
|
|
249
|
+
url: `https://${string}`;
|
|
250
|
+
service: string;
|
|
251
|
+
path: `/${string}`;
|
|
252
|
+
methods: readonly ("DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT")[];
|
|
253
|
+
}>>>>>;
|
|
254
|
+
aliases: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodReadonly<z.ZodObject<{
|
|
255
|
+
hostname: z.ZodString;
|
|
256
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
257
|
+
service: z.ZodString;
|
|
258
|
+
}, z.core.$strict>>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
259
|
+
hostname: string;
|
|
260
|
+
url: `https://${string}`;
|
|
261
|
+
service: string;
|
|
262
|
+
}> | undefined>>, Record<string, Readonly<{
|
|
263
|
+
hostname: string;
|
|
264
|
+
url: `https://${string}`;
|
|
265
|
+
service: string;
|
|
266
|
+
}>>>>>;
|
|
267
|
+
}, z.core.$strict>>;
|
|
268
|
+
export declare const projectRuntimeSchema: z.ZodReadonly<z.ZodObject<{
|
|
269
|
+
namespace: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">]>;
|
|
270
|
+
services: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodReadonly<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
271
|
+
namespace: z.ZodString;
|
|
272
|
+
hostname: z.ZodString;
|
|
273
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
274
|
+
public: z.ZodBoolean;
|
|
275
|
+
protocol: z.ZodLiteral<"http">;
|
|
276
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
277
|
+
paths: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodTemplateLiteral<`/${string}`>, z.ZodReadonly<z.ZodObject<{
|
|
278
|
+
service: z.ZodString;
|
|
279
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
280
|
+
stripPrefix: z.ZodBoolean;
|
|
281
|
+
}, z.core.$strict>>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
282
|
+
service: string;
|
|
283
|
+
url: `https://${string}`;
|
|
284
|
+
stripPrefix: boolean;
|
|
285
|
+
}> | undefined>>, Record<`/${string}`, Readonly<{
|
|
286
|
+
service: string;
|
|
287
|
+
url: `https://${string}`;
|
|
288
|
+
stripPrefix: boolean;
|
|
289
|
+
}>>>>>;
|
|
290
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
291
|
+
namespace: z.ZodString;
|
|
292
|
+
hostname: z.ZodString;
|
|
293
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
294
|
+
public: z.ZodBoolean;
|
|
295
|
+
protocol: z.ZodLiteral<"kubernetes">;
|
|
296
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
297
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
298
|
+
namespace: z.ZodString;
|
|
299
|
+
hostname: z.ZodString;
|
|
300
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
301
|
+
public: z.ZodBoolean;
|
|
302
|
+
protocol: z.ZodLiteral<"postgres">;
|
|
303
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
304
|
+
namespace: z.ZodString;
|
|
305
|
+
hostname: z.ZodString;
|
|
306
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
307
|
+
public: z.ZodBoolean;
|
|
308
|
+
protocol: z.ZodLiteral<"mysql">;
|
|
309
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
310
|
+
namespace: z.ZodString;
|
|
311
|
+
hostname: z.ZodString;
|
|
312
|
+
port: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodInt]>;
|
|
313
|
+
public: z.ZodBoolean;
|
|
314
|
+
protocol: z.ZodLiteral<"tcp">;
|
|
315
|
+
}, z.core.$strict>], "protocol">>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
316
|
+
namespace: string;
|
|
317
|
+
hostname: string;
|
|
318
|
+
port: number;
|
|
319
|
+
public: boolean;
|
|
320
|
+
protocol: "http";
|
|
321
|
+
url: `https://${string}`;
|
|
322
|
+
paths?: Readonly<Record<string, Readonly<{
|
|
323
|
+
service: string;
|
|
324
|
+
url: `https://${string}`;
|
|
325
|
+
stripPrefix: boolean;
|
|
326
|
+
}> | undefined>> | undefined;
|
|
327
|
+
}> | Readonly<{
|
|
328
|
+
namespace: string;
|
|
329
|
+
hostname: string;
|
|
330
|
+
port: number;
|
|
331
|
+
public: boolean;
|
|
332
|
+
protocol: "kubernetes";
|
|
333
|
+
url: `https://${string}`;
|
|
334
|
+
}> | Readonly<{
|
|
335
|
+
namespace: string;
|
|
336
|
+
hostname: string;
|
|
337
|
+
port: number;
|
|
338
|
+
public: boolean;
|
|
339
|
+
protocol: "postgres";
|
|
340
|
+
}> | Readonly<{
|
|
341
|
+
namespace: string;
|
|
342
|
+
hostname: string;
|
|
343
|
+
port: number;
|
|
344
|
+
public: boolean;
|
|
345
|
+
protocol: "mysql";
|
|
346
|
+
}> | Readonly<{
|
|
347
|
+
namespace: string;
|
|
348
|
+
hostname: string;
|
|
349
|
+
port: number;
|
|
350
|
+
public: boolean;
|
|
351
|
+
protocol: "tcp";
|
|
352
|
+
}> | undefined>>, Record<string, Readonly<{
|
|
353
|
+
namespace: string;
|
|
354
|
+
hostname: string;
|
|
355
|
+
port: number;
|
|
356
|
+
public: boolean;
|
|
357
|
+
protocol: "http";
|
|
358
|
+
url: `https://${string}`;
|
|
359
|
+
paths?: Readonly<Record<string, Readonly<{
|
|
360
|
+
service: string;
|
|
361
|
+
url: `https://${string}`;
|
|
362
|
+
stripPrefix: boolean;
|
|
363
|
+
}> | undefined>> | undefined;
|
|
364
|
+
}> | Readonly<{
|
|
365
|
+
namespace: string;
|
|
366
|
+
hostname: string;
|
|
367
|
+
port: number;
|
|
368
|
+
public: boolean;
|
|
369
|
+
protocol: "kubernetes";
|
|
370
|
+
url: `https://${string}`;
|
|
371
|
+
}> | Readonly<{
|
|
372
|
+
namespace: string;
|
|
373
|
+
hostname: string;
|
|
374
|
+
port: number;
|
|
375
|
+
public: boolean;
|
|
376
|
+
protocol: "postgres";
|
|
377
|
+
}> | Readonly<{
|
|
378
|
+
namespace: string;
|
|
379
|
+
hostname: string;
|
|
380
|
+
port: number;
|
|
381
|
+
public: boolean;
|
|
382
|
+
protocol: "mysql";
|
|
383
|
+
}> | Readonly<{
|
|
384
|
+
namespace: string;
|
|
385
|
+
hostname: string;
|
|
386
|
+
port: number;
|
|
387
|
+
public: boolean;
|
|
388
|
+
protocol: "tcp";
|
|
389
|
+
}>>>>;
|
|
390
|
+
worktree: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
|
|
391
|
+
label: z.ZodReadonly<z.ZodObject<{
|
|
392
|
+
project: z.ZodString;
|
|
393
|
+
checkout: z.ZodExactOptional<z.ZodString>;
|
|
394
|
+
id: z.ZodString;
|
|
395
|
+
fullLabel: z.ZodString;
|
|
396
|
+
}, z.core.$strict>>;
|
|
397
|
+
}, z.core.$strict>>>;
|
|
398
|
+
oauth: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
|
|
399
|
+
hostname: z.ZodString;
|
|
400
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
401
|
+
}, z.core.$strict>>>;
|
|
402
|
+
webhooks: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodReadonly<z.ZodObject<{
|
|
403
|
+
hostname: z.ZodString;
|
|
404
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
405
|
+
service: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">]>;
|
|
406
|
+
path: z.ZodTemplateLiteral<`/${string}`>;
|
|
407
|
+
methods: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
|
|
408
|
+
DELETE: "DELETE";
|
|
409
|
+
GET: "GET";
|
|
410
|
+
HEAD: "HEAD";
|
|
411
|
+
OPTIONS: "OPTIONS";
|
|
412
|
+
PATCH: "PATCH";
|
|
413
|
+
POST: "POST";
|
|
414
|
+
PUT: "PUT";
|
|
415
|
+
}>>>;
|
|
416
|
+
}, z.core.$strict>>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
417
|
+
hostname: string;
|
|
418
|
+
url: `https://${string}`;
|
|
419
|
+
service: string;
|
|
420
|
+
path: `/${string}`;
|
|
421
|
+
methods: readonly ("DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT")[];
|
|
422
|
+
}> | undefined>>, Record<string, Readonly<{
|
|
423
|
+
hostname: string;
|
|
424
|
+
url: `https://${string}`;
|
|
425
|
+
service: string;
|
|
426
|
+
path: `/${string}`;
|
|
427
|
+
methods: readonly ("DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT")[];
|
|
428
|
+
}>>>>>;
|
|
429
|
+
aliases: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodReadonly<z.ZodObject<{
|
|
430
|
+
hostname: z.ZodString;
|
|
431
|
+
url: z.ZodTemplateLiteral<`https://${string}`>;
|
|
432
|
+
service: z.ZodString;
|
|
433
|
+
}, z.core.$strict>>>, z.ZodTransform<Readonly<Record<string, Readonly<{
|
|
434
|
+
hostname: string;
|
|
435
|
+
url: `https://${string}`;
|
|
436
|
+
service: string;
|
|
437
|
+
}> | undefined>>, Record<string, Readonly<{
|
|
438
|
+
hostname: string;
|
|
439
|
+
url: `https://${string}`;
|
|
440
|
+
service: string;
|
|
441
|
+
}>>>>>;
|
|
442
|
+
dev: z.ZodBoolean;
|
|
443
|
+
}, z.core.$strict>>;
|
|
444
|
+
export type ServiceProtocol = z.output<typeof protocolSchema>;
|
|
445
|
+
export type ProjectServiceMetadata = z.output<typeof serviceMetadataSchema>;
|
|
446
|
+
export type HTTPServiceMetadata = Extract<ProjectServiceMetadata, {
|
|
447
|
+
protocol: "http";
|
|
448
|
+
}>;
|
|
449
|
+
export type ProjectPathMetadata = z.output<typeof pathMetadataSchema>;
|
|
450
|
+
export type ProjectMetadata = z.output<typeof projectMetadataSchema>;
|
|
451
|
+
export type ProjectRuntime = z.output<typeof projectRuntimeSchema>;
|
|
452
|
+
export type WorktreeLabel = z.output<typeof worktreeLabelSchema>;
|
|
453
|
+
export type IntegrationOrigin = z.output<typeof integrationOriginSchema>;
|
|
454
|
+
export type WebhookMetadata = z.output<typeof webhookSchema>;
|
|
455
|
+
export type WebhookMethod = z.output<typeof webhookMethodSchema>;
|
|
456
|
+
export type AliasMetadata = z.output<typeof aliasSchema>;
|
|
457
|
+
export declare function parseProjectMetadata(value: unknown): ProjectMetadata;
|
|
458
|
+
export declare function parseProjectRuntime(value: unknown): ProjectRuntime;
|
|
459
|
+
/** returns the canonical hostnames that can reach this service. */
|
|
460
|
+
export declare function serviceHostnames(assignment: {
|
|
461
|
+
readonly hostname: string | undefined;
|
|
462
|
+
readonly service: string;
|
|
463
|
+
readonly project: ProjectRuntime;
|
|
464
|
+
}): string[];
|
|
465
|
+
export declare function parseRuntimePayload(serialized: string | undefined): ProjectRuntime | undefined;
|
|
466
|
+
export declare function serializeRuntimePayload({ namespace, services, worktree, oauth, webhooks, aliases }: ProjectMetadata, dev: boolean): string;
|
|
467
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { TnlError } from "../../errors.js";
|
|
3
|
+
import { parseValue } from "../validation.js";
|
|
4
|
+
import { hostnameSchema, httpsOriginSchema, portSchema, protocolSchema, serviceNameSchema, } from "../values.js";
|
|
5
|
+
const maximumRuntimeBytes = 64 * 1024;
|
|
6
|
+
const labelSchema = hostnameSchema.refine((value) => !value.includes("."));
|
|
7
|
+
const worktreeLabelSchema = z
|
|
8
|
+
.strictObject({
|
|
9
|
+
project: labelSchema,
|
|
10
|
+
checkout: labelSchema.exactOptional(),
|
|
11
|
+
id: labelSchema,
|
|
12
|
+
fullLabel: labelSchema,
|
|
13
|
+
})
|
|
14
|
+
.refine(({ project, checkout, id, fullLabel }) => fullLabel === [project, checkout, id].filter((part) => part !== undefined).join("-"))
|
|
15
|
+
.readonly();
|
|
16
|
+
const mountPrefixSchema = z.templateLiteral(["/", z.string()]).refine((prefix) => prefix.length >= 2 &&
|
|
17
|
+
prefix.length <= 256 &&
|
|
18
|
+
!prefix.endsWith("/") &&
|
|
19
|
+
prefix !== "/__tnl" &&
|
|
20
|
+
!prefix.startsWith("/__tnl/") &&
|
|
21
|
+
prefix
|
|
22
|
+
.slice(1)
|
|
23
|
+
.split("/")
|
|
24
|
+
.every((segment) => segment !== "." && segment !== ".." && /^[A-Za-z0-9._~-]+$/.test(segment)));
|
|
25
|
+
// lookups may miss even when consumers disable noUncheckedIndexedAccess.
|
|
26
|
+
function metadataMap(key, value) {
|
|
27
|
+
return z
|
|
28
|
+
.record(key, value)
|
|
29
|
+
.transform((entries) => Object.freeze(Object.assign(Object.create(null), entries)));
|
|
30
|
+
}
|
|
31
|
+
const pathMetadataSchema = z
|
|
32
|
+
.strictObject({
|
|
33
|
+
service: serviceNameSchema,
|
|
34
|
+
url: z.templateLiteral(["https://", z.string()]),
|
|
35
|
+
stripPrefix: z.boolean(),
|
|
36
|
+
})
|
|
37
|
+
.readonly();
|
|
38
|
+
const address = {
|
|
39
|
+
namespace: hostnameSchema,
|
|
40
|
+
hostname: hostnameSchema,
|
|
41
|
+
// non-HTTP zero means no ingress reservation, never a local socket or wildcard.
|
|
42
|
+
port: z.union([z.literal(0), portSchema]),
|
|
43
|
+
public: z.boolean(),
|
|
44
|
+
};
|
|
45
|
+
const httpServiceMetadataSchema = z.strictObject({
|
|
46
|
+
protocol: z.literal("http"),
|
|
47
|
+
...address,
|
|
48
|
+
url: httpsOriginSchema,
|
|
49
|
+
paths: metadataMap(mountPrefixSchema, pathMetadataSchema).optional(),
|
|
50
|
+
});
|
|
51
|
+
const serviceMetadataSchema = z
|
|
52
|
+
.discriminatedUnion("protocol", [
|
|
53
|
+
httpServiceMetadataSchema,
|
|
54
|
+
z.strictObject({ protocol: z.literal("kubernetes"), ...address, url: httpsOriginSchema }),
|
|
55
|
+
z.strictObject({ protocol: z.literal("postgres"), ...address }),
|
|
56
|
+
z.strictObject({ protocol: z.literal("mysql"), ...address }),
|
|
57
|
+
z.strictObject({ protocol: z.literal("tcp"), ...address }),
|
|
58
|
+
])
|
|
59
|
+
.refine((service) => (service.protocol === "http"
|
|
60
|
+
? service.port === 443
|
|
61
|
+
: service.port >= 1024 || (service.port === 0 && !service.public)) &&
|
|
62
|
+
(!("url" in service) ||
|
|
63
|
+
service.url ===
|
|
64
|
+
`https://${service.hostname}${service.port === 0 || service.port === 443 ? "" : `:${service.port}`}`))
|
|
65
|
+
.readonly();
|
|
66
|
+
const integrationOriginSchema = z
|
|
67
|
+
.strictObject({ hostname: hostnameSchema, url: httpsOriginSchema })
|
|
68
|
+
.refine(({ hostname, url }) => url === `https://${hostname}`)
|
|
69
|
+
.readonly();
|
|
70
|
+
const webhookMethodSchema = z.enum(["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"]);
|
|
71
|
+
const webhookSchema = z
|
|
72
|
+
.strictObject({
|
|
73
|
+
hostname: hostnameSchema,
|
|
74
|
+
url: z.templateLiteral(["https://", z.string()]),
|
|
75
|
+
service: z.union([serviceNameSchema, z.literal("")]),
|
|
76
|
+
path: mountPrefixSchema,
|
|
77
|
+
methods: z
|
|
78
|
+
.array(webhookMethodSchema)
|
|
79
|
+
.min(1)
|
|
80
|
+
.max(7)
|
|
81
|
+
.refine((methods) => new Set(methods).size === methods.length)
|
|
82
|
+
.readonly(),
|
|
83
|
+
})
|
|
84
|
+
.refine(({ hostname, path, url }) => url === `https://${hostname}${path}`)
|
|
85
|
+
.readonly();
|
|
86
|
+
const aliasSchema = z
|
|
87
|
+
.strictObject({ hostname: hostnameSchema, url: httpsOriginSchema, service: serviceNameSchema })
|
|
88
|
+
.refine(({ hostname, url }) => url === `https://${hostname}`)
|
|
89
|
+
.readonly();
|
|
90
|
+
const projectFields = {
|
|
91
|
+
namespace: z.union([hostnameSchema, z.literal("")]),
|
|
92
|
+
services: metadataMap(serviceNameSchema, serviceMetadataSchema),
|
|
93
|
+
worktree: z.strictObject({ label: worktreeLabelSchema }).readonly().optional(),
|
|
94
|
+
oauth: integrationOriginSchema.optional(),
|
|
95
|
+
webhooks: metadataMap(serviceNameSchema, webhookSchema).optional(),
|
|
96
|
+
aliases: metadataMap(serviceNameSchema, aliasSchema).optional(),
|
|
97
|
+
};
|
|
98
|
+
function validProject(project) {
|
|
99
|
+
const { services, namespace, oauth, webhooks, aliases } = project;
|
|
100
|
+
if (namespace === "" &&
|
|
101
|
+
(Object.keys(services).length !== 0 ||
|
|
102
|
+
oauth !== undefined ||
|
|
103
|
+
webhooks !== undefined ||
|
|
104
|
+
aliases !== undefined))
|
|
105
|
+
return false;
|
|
106
|
+
const hostnames = new Set();
|
|
107
|
+
for (const [name, service] of Object.entries(services)) {
|
|
108
|
+
if (service === undefined || hostnames.has(service.hostname))
|
|
109
|
+
return false;
|
|
110
|
+
hostnames.add(service.hostname);
|
|
111
|
+
if (service.protocol === "http" && service.paths !== undefined) {
|
|
112
|
+
for (const [prefix, mount] of Object.entries(service.paths)) {
|
|
113
|
+
if (mount === undefined ||
|
|
114
|
+
mount.service === name ||
|
|
115
|
+
mount.url !== `${service.url}${prefix}`)
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (const endpoint of Object.values(webhooks ?? {})) {
|
|
121
|
+
if (endpoint === undefined ||
|
|
122
|
+
(!(endpoint.service === "" && Object.keys(services).length === 0) &&
|
|
123
|
+
services[endpoint.service]?.protocol !== "http"))
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
for (const alias of Object.values(aliases ?? {})) {
|
|
127
|
+
if (alias === undefined ||
|
|
128
|
+
services[alias.service]?.protocol !== "http" ||
|
|
129
|
+
hostnames.has(alias.hostname))
|
|
130
|
+
return false;
|
|
131
|
+
hostnames.add(alias.hostname);
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
export const projectMetadataSchema = z.strictObject(projectFields).refine(validProject).readonly();
|
|
136
|
+
export const projectRuntimeSchema = z
|
|
137
|
+
.strictObject({ ...projectFields, dev: z.boolean() })
|
|
138
|
+
.refine(validProject)
|
|
139
|
+
.readonly();
|
|
140
|
+
export function parseProjectMetadata(value) {
|
|
141
|
+
return parseValue(projectMetadataSchema, value, "sdk.runtime_invalid");
|
|
142
|
+
}
|
|
143
|
+
export function parseProjectRuntime(value) {
|
|
144
|
+
return parseValue(projectRuntimeSchema, value, "sdk.runtime_invalid");
|
|
145
|
+
}
|
|
146
|
+
/** returns the canonical hostnames that can reach this service. */
|
|
147
|
+
export function serviceHostnames(assignment) {
|
|
148
|
+
const hostnames = new Set(assignment.hostname === undefined ? [] : [assignment.hostname]);
|
|
149
|
+
for (const alias of Object.values(assignment.project.aliases ?? {})) {
|
|
150
|
+
if (alias === undefined)
|
|
151
|
+
continue;
|
|
152
|
+
const service = assignment.project.services[alias.service];
|
|
153
|
+
if (alias.service === assignment.service ||
|
|
154
|
+
(service?.protocol === "http" &&
|
|
155
|
+
Object.values(service.paths ?? {}).some((mount) => mount?.service === assignment.service))) {
|
|
156
|
+
hostnames.add(alias.hostname);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return [...hostnames];
|
|
160
|
+
}
|
|
161
|
+
export function parseRuntimePayload(serialized) {
|
|
162
|
+
if (serialized === undefined)
|
|
163
|
+
return undefined;
|
|
164
|
+
if (byteLength(serialized) > maximumRuntimeBytes)
|
|
165
|
+
throw new TnlError("sdk.runtime_invalid");
|
|
166
|
+
let value;
|
|
167
|
+
try {
|
|
168
|
+
value = JSON.parse(serialized);
|
|
169
|
+
}
|
|
170
|
+
catch (cause) {
|
|
171
|
+
throw new TnlError("sdk.runtime_invalid", { cause });
|
|
172
|
+
}
|
|
173
|
+
return parseProjectRuntime(value);
|
|
174
|
+
}
|
|
175
|
+
export function serializeRuntimePayload({ namespace, services, worktree, oauth, webhooks, aliases }, dev) {
|
|
176
|
+
const serialized = JSON.stringify(parseProjectRuntime({ namespace, services, worktree, oauth, webhooks, aliases, dev }));
|
|
177
|
+
if (byteLength(serialized) > maximumRuntimeBytes)
|
|
178
|
+
throw new TnlError("sdk.runtime_invalid");
|
|
179
|
+
return serialized;
|
|
180
|
+
}
|
|
181
|
+
function byteLength(value) {
|
|
182
|
+
return new TextEncoder().encode(value).byteLength;
|
|
183
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProjectRuntime, ProjectServiceMetadata } from "./runtime.js";
|
|
2
|
+
/** absent optional services stay absent; only an unprepared project is an error. */
|
|
3
|
+
export declare function serviceMetadata(runtime: ProjectRuntime | undefined): Readonly<Record<string, ProjectServiceMetadata | undefined>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TnlError } from "../../errors.js";
|
|
2
|
+
/** absent optional services stay absent; only an unprepared project is an error. */
|
|
3
|
+
export function serviceMetadata(runtime) {
|
|
4
|
+
if (runtime === undefined)
|
|
5
|
+
throw new TnlError("sdk.service_unprepared");
|
|
6
|
+
const services = Object.create(null);
|
|
7
|
+
for (const [name, metadata] of Object.entries(runtime.services)) {
|
|
8
|
+
if (metadata !== undefined)
|
|
9
|
+
services[name] = metadata;
|
|
10
|
+
}
|
|
11
|
+
return Object.freeze(services);
|
|
12
|
+
}
|