@powersync/cli-schemas 0.0.0-dev-20260305082615
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 +67 -0
- package/README.md +5 -0
- package/dist/CLIConfig.d.ts +49 -0
- package/dist/CLIConfig.js +28 -0
- package/dist/ServiceCloudConfig.d.ts +388 -0
- package/dist/ServiceCloudConfig.js +10 -0
- package/dist/ServiceConfig.d.ts +4 -0
- package/dist/ServiceConfig.js +6 -0
- package/dist/ServiceSelfHostedConfig.d.ts +395 -0
- package/dist/ServiceSelfHostedConfig.js +27 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/scripts/create-schemas.d.ts +1 -0
- package/dist/scripts/create-schemas.js +12 -0
- package/dist/validators.d.ts +93 -0
- package/dist/validators.js +55 -0
- package/json-schema/cli-config.json +52 -0
- package/json-schema/service-config.json +2042 -0
- package/json-schema/sync-config.json +214 -0
- package/package.json +57 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import * as t from 'ts-codec';
|
|
2
|
+
export declare const BaseServiceSelfHostedConfig: t.Intersection<t.Codec<{
|
|
3
|
+
storage: {
|
|
4
|
+
type: string;
|
|
5
|
+
max_pool_size?: number | undefined;
|
|
6
|
+
} & Record<string, any>;
|
|
7
|
+
replication?: {
|
|
8
|
+
connections?: ({
|
|
9
|
+
type: string;
|
|
10
|
+
id?: string | undefined;
|
|
11
|
+
tag?: string | undefined;
|
|
12
|
+
debug_api?: boolean | undefined;
|
|
13
|
+
} & Record<string, any>)[] | undefined;
|
|
14
|
+
} | undefined;
|
|
15
|
+
client_auth?: {
|
|
16
|
+
jwks_uri?: string | string[] | undefined;
|
|
17
|
+
block_local_jwks?: boolean | undefined;
|
|
18
|
+
jwks_reject_ip_ranges?: string[] | undefined;
|
|
19
|
+
jwks?: {
|
|
20
|
+
keys: ({
|
|
21
|
+
kty: "RSA";
|
|
22
|
+
kid: string;
|
|
23
|
+
n: string;
|
|
24
|
+
e: string;
|
|
25
|
+
alg?: "RS256" | "RS384" | "RS512" | undefined;
|
|
26
|
+
use?: string | undefined;
|
|
27
|
+
} | {
|
|
28
|
+
kty: "oct";
|
|
29
|
+
alg: "HS256" | "HS384" | "HS512";
|
|
30
|
+
k: string;
|
|
31
|
+
kid?: string | undefined;
|
|
32
|
+
use?: string | undefined;
|
|
33
|
+
} | {
|
|
34
|
+
kty: "OKP";
|
|
35
|
+
alg: "EdDSA";
|
|
36
|
+
crv: "Ed25519" | "Ed448";
|
|
37
|
+
x: string;
|
|
38
|
+
kid?: string | undefined;
|
|
39
|
+
use?: string | undefined;
|
|
40
|
+
} | {
|
|
41
|
+
kty: "EC";
|
|
42
|
+
alg: "ES256" | "ES384" | "ES512";
|
|
43
|
+
crv: "P-256" | "P-384" | "P-512";
|
|
44
|
+
x: string;
|
|
45
|
+
y: string;
|
|
46
|
+
kid?: string | undefined;
|
|
47
|
+
use?: string | undefined;
|
|
48
|
+
})[];
|
|
49
|
+
} | undefined;
|
|
50
|
+
supabase?: boolean | undefined;
|
|
51
|
+
supabase_jwt_secret?: string | undefined;
|
|
52
|
+
audience?: string[] | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
parameters?: Record<string, string | number | boolean | null> | undefined;
|
|
55
|
+
api?: {
|
|
56
|
+
tokens?: string[] | undefined;
|
|
57
|
+
parameters?: {
|
|
58
|
+
max_concurrent_connections?: number | undefined;
|
|
59
|
+
max_data_fetch_concurrency?: number | undefined;
|
|
60
|
+
max_buckets_per_connection?: number | undefined;
|
|
61
|
+
max_parameter_query_results?: number | undefined;
|
|
62
|
+
} | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
port?: number | undefined;
|
|
65
|
+
sync_config?: {
|
|
66
|
+
content?: string | undefined;
|
|
67
|
+
path?: string | undefined;
|
|
68
|
+
exit_on_error?: boolean | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
sync_rules?: {
|
|
71
|
+
content?: string | undefined;
|
|
72
|
+
path?: string | undefined;
|
|
73
|
+
exit_on_error?: boolean | undefined;
|
|
74
|
+
} | undefined;
|
|
75
|
+
metadata?: Record<string, string> | undefined;
|
|
76
|
+
migrations?: {
|
|
77
|
+
disable_auto_migration?: boolean | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
telemetry?: {
|
|
80
|
+
disable_telemetry_sharing: boolean;
|
|
81
|
+
prometheus_port?: number | undefined;
|
|
82
|
+
internal_service_endpoint?: string | undefined;
|
|
83
|
+
} | undefined;
|
|
84
|
+
healthcheck?: {
|
|
85
|
+
probes?: {
|
|
86
|
+
use_filesystem?: boolean | undefined;
|
|
87
|
+
use_http?: boolean | undefined;
|
|
88
|
+
use_legacy?: boolean | undefined;
|
|
89
|
+
} | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
system?: {
|
|
92
|
+
logging?: {
|
|
93
|
+
level?: "silly" | "debug" | "verbose" | "http" | "info" | "warn" | "error" | undefined;
|
|
94
|
+
format?: "text" | "json" | undefined;
|
|
95
|
+
} | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
}, {
|
|
98
|
+
storage: {
|
|
99
|
+
type: string;
|
|
100
|
+
max_pool_size?: number | undefined;
|
|
101
|
+
} & Record<string, any>;
|
|
102
|
+
replication?: {
|
|
103
|
+
connections?: ({
|
|
104
|
+
type: string;
|
|
105
|
+
id?: string | undefined;
|
|
106
|
+
tag?: string | undefined;
|
|
107
|
+
debug_api?: boolean | undefined;
|
|
108
|
+
} & Record<string, any>)[] | undefined;
|
|
109
|
+
} | undefined;
|
|
110
|
+
client_auth?: {
|
|
111
|
+
jwks_uri?: string | string[] | undefined;
|
|
112
|
+
block_local_jwks?: boolean | undefined;
|
|
113
|
+
jwks_reject_ip_ranges?: string[] | undefined;
|
|
114
|
+
jwks?: {
|
|
115
|
+
keys: ({
|
|
116
|
+
kty: "RSA";
|
|
117
|
+
kid: string;
|
|
118
|
+
n: string;
|
|
119
|
+
e: string;
|
|
120
|
+
alg?: "RS256" | "RS384" | "RS512" | undefined;
|
|
121
|
+
use?: string | undefined;
|
|
122
|
+
} | {
|
|
123
|
+
kty: "oct";
|
|
124
|
+
alg: "HS256" | "HS384" | "HS512";
|
|
125
|
+
k: string;
|
|
126
|
+
kid?: string | undefined;
|
|
127
|
+
use?: string | undefined;
|
|
128
|
+
} | {
|
|
129
|
+
kty: "OKP";
|
|
130
|
+
alg: "EdDSA";
|
|
131
|
+
crv: "Ed25519" | "Ed448";
|
|
132
|
+
x: string;
|
|
133
|
+
kid?: string | undefined;
|
|
134
|
+
use?: string | undefined;
|
|
135
|
+
} | {
|
|
136
|
+
kty: "EC";
|
|
137
|
+
alg: "ES256" | "ES384" | "ES512";
|
|
138
|
+
crv: "P-256" | "P-384" | "P-512";
|
|
139
|
+
x: string;
|
|
140
|
+
y: string;
|
|
141
|
+
kid?: string | undefined;
|
|
142
|
+
use?: string | undefined;
|
|
143
|
+
})[];
|
|
144
|
+
} | undefined;
|
|
145
|
+
supabase?: boolean | undefined;
|
|
146
|
+
supabase_jwt_secret?: string | undefined;
|
|
147
|
+
audience?: string[] | undefined;
|
|
148
|
+
} | undefined;
|
|
149
|
+
parameters?: Record<string, string | number | boolean | null> | undefined;
|
|
150
|
+
api?: {
|
|
151
|
+
tokens?: string[] | undefined;
|
|
152
|
+
parameters?: {
|
|
153
|
+
max_concurrent_connections?: number | undefined;
|
|
154
|
+
max_data_fetch_concurrency?: number | undefined;
|
|
155
|
+
max_buckets_per_connection?: number | undefined;
|
|
156
|
+
max_parameter_query_results?: number | undefined;
|
|
157
|
+
} | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
port?: string | number | undefined;
|
|
160
|
+
sync_config?: {
|
|
161
|
+
content?: string | undefined;
|
|
162
|
+
path?: string | undefined;
|
|
163
|
+
exit_on_error?: boolean | undefined;
|
|
164
|
+
} | undefined;
|
|
165
|
+
sync_rules?: {
|
|
166
|
+
content?: string | undefined;
|
|
167
|
+
path?: string | undefined;
|
|
168
|
+
exit_on_error?: boolean | undefined;
|
|
169
|
+
} | undefined;
|
|
170
|
+
metadata?: Record<string, string> | undefined;
|
|
171
|
+
migrations?: {
|
|
172
|
+
disable_auto_migration?: boolean | undefined;
|
|
173
|
+
} | undefined;
|
|
174
|
+
telemetry?: {
|
|
175
|
+
disable_telemetry_sharing: boolean;
|
|
176
|
+
prometheus_port?: string | number | undefined;
|
|
177
|
+
internal_service_endpoint?: string | undefined;
|
|
178
|
+
} | undefined;
|
|
179
|
+
healthcheck?: {
|
|
180
|
+
probes?: {
|
|
181
|
+
use_filesystem?: boolean | undefined;
|
|
182
|
+
use_http?: boolean | undefined;
|
|
183
|
+
use_legacy?: boolean | undefined;
|
|
184
|
+
} | undefined;
|
|
185
|
+
} | undefined;
|
|
186
|
+
system?: {
|
|
187
|
+
logging?: {
|
|
188
|
+
level?: "silly" | "debug" | "verbose" | "http" | "info" | "warn" | "error" | undefined;
|
|
189
|
+
format?: "text" | "json" | undefined;
|
|
190
|
+
} | undefined;
|
|
191
|
+
} | undefined;
|
|
192
|
+
}, string, t.CodecProps>, t.ObjectCodec<{
|
|
193
|
+
_type: t.LiteralCodec<"self-hosted">;
|
|
194
|
+
}>>;
|
|
195
|
+
export type BaseServiceSelfHostedConfig = t.Encoded<typeof BaseServiceSelfHostedConfig>;
|
|
196
|
+
export type BaseServiceSelfHostedConfigDecoded = t.Decoded<typeof BaseServiceSelfHostedConfig>;
|
|
197
|
+
export declare const ServiceSelfHostedConfig: t.Intersection<t.Codec<{
|
|
198
|
+
storage: {
|
|
199
|
+
type: string;
|
|
200
|
+
max_pool_size?: number | undefined;
|
|
201
|
+
} & Record<string, any>;
|
|
202
|
+
replication?: {
|
|
203
|
+
connections?: ({
|
|
204
|
+
type: string;
|
|
205
|
+
id?: string | undefined;
|
|
206
|
+
tag?: string | undefined;
|
|
207
|
+
debug_api?: boolean | undefined;
|
|
208
|
+
} & Record<string, any>)[] | undefined;
|
|
209
|
+
} | undefined;
|
|
210
|
+
client_auth?: {
|
|
211
|
+
jwks_uri?: string | string[] | undefined;
|
|
212
|
+
block_local_jwks?: boolean | undefined;
|
|
213
|
+
jwks_reject_ip_ranges?: string[] | undefined;
|
|
214
|
+
jwks?: {
|
|
215
|
+
keys: ({
|
|
216
|
+
kty: "RSA";
|
|
217
|
+
kid: string;
|
|
218
|
+
n: string;
|
|
219
|
+
e: string;
|
|
220
|
+
alg?: "RS256" | "RS384" | "RS512" | undefined;
|
|
221
|
+
use?: string | undefined;
|
|
222
|
+
} | {
|
|
223
|
+
kty: "oct";
|
|
224
|
+
alg: "HS256" | "HS384" | "HS512";
|
|
225
|
+
k: string;
|
|
226
|
+
kid?: string | undefined;
|
|
227
|
+
use?: string | undefined;
|
|
228
|
+
} | {
|
|
229
|
+
kty: "OKP";
|
|
230
|
+
alg: "EdDSA";
|
|
231
|
+
crv: "Ed25519" | "Ed448";
|
|
232
|
+
x: string;
|
|
233
|
+
kid?: string | undefined;
|
|
234
|
+
use?: string | undefined;
|
|
235
|
+
} | {
|
|
236
|
+
kty: "EC";
|
|
237
|
+
alg: "ES256" | "ES384" | "ES512";
|
|
238
|
+
crv: "P-256" | "P-384" | "P-512";
|
|
239
|
+
x: string;
|
|
240
|
+
y: string;
|
|
241
|
+
kid?: string | undefined;
|
|
242
|
+
use?: string | undefined;
|
|
243
|
+
})[];
|
|
244
|
+
} | undefined;
|
|
245
|
+
supabase?: boolean | undefined;
|
|
246
|
+
supabase_jwt_secret?: string | undefined;
|
|
247
|
+
audience?: string[] | undefined;
|
|
248
|
+
} | undefined;
|
|
249
|
+
parameters?: Record<string, string | number | boolean | null> | undefined;
|
|
250
|
+
api?: {
|
|
251
|
+
tokens?: string[] | undefined;
|
|
252
|
+
parameters?: {
|
|
253
|
+
max_concurrent_connections?: number | undefined;
|
|
254
|
+
max_data_fetch_concurrency?: number | undefined;
|
|
255
|
+
max_buckets_per_connection?: number | undefined;
|
|
256
|
+
max_parameter_query_results?: number | undefined;
|
|
257
|
+
} | undefined;
|
|
258
|
+
} | undefined;
|
|
259
|
+
port?: number | undefined;
|
|
260
|
+
sync_config?: {
|
|
261
|
+
content?: string | undefined;
|
|
262
|
+
path?: string | undefined;
|
|
263
|
+
exit_on_error?: boolean | undefined;
|
|
264
|
+
} | undefined;
|
|
265
|
+
sync_rules?: {
|
|
266
|
+
content?: string | undefined;
|
|
267
|
+
path?: string | undefined;
|
|
268
|
+
exit_on_error?: boolean | undefined;
|
|
269
|
+
} | undefined;
|
|
270
|
+
metadata?: Record<string, string> | undefined;
|
|
271
|
+
migrations?: {
|
|
272
|
+
disable_auto_migration?: boolean | undefined;
|
|
273
|
+
} | undefined;
|
|
274
|
+
telemetry?: {
|
|
275
|
+
disable_telemetry_sharing: boolean;
|
|
276
|
+
prometheus_port?: number | undefined;
|
|
277
|
+
internal_service_endpoint?: string | undefined;
|
|
278
|
+
} | undefined;
|
|
279
|
+
healthcheck?: {
|
|
280
|
+
probes?: {
|
|
281
|
+
use_filesystem?: boolean | undefined;
|
|
282
|
+
use_http?: boolean | undefined;
|
|
283
|
+
use_legacy?: boolean | undefined;
|
|
284
|
+
} | undefined;
|
|
285
|
+
} | undefined;
|
|
286
|
+
system?: {
|
|
287
|
+
logging?: {
|
|
288
|
+
level?: "silly" | "debug" | "verbose" | "http" | "info" | "warn" | "error" | undefined;
|
|
289
|
+
format?: "text" | "json" | undefined;
|
|
290
|
+
} | undefined;
|
|
291
|
+
} | undefined;
|
|
292
|
+
} & {
|
|
293
|
+
_type: "self-hosted";
|
|
294
|
+
}, {
|
|
295
|
+
storage: {
|
|
296
|
+
type: string;
|
|
297
|
+
max_pool_size?: number | undefined;
|
|
298
|
+
} & Record<string, any>;
|
|
299
|
+
replication?: {
|
|
300
|
+
connections?: ({
|
|
301
|
+
type: string;
|
|
302
|
+
id?: string | undefined;
|
|
303
|
+
tag?: string | undefined;
|
|
304
|
+
debug_api?: boolean | undefined;
|
|
305
|
+
} & Record<string, any>)[] | undefined;
|
|
306
|
+
} | undefined;
|
|
307
|
+
client_auth?: {
|
|
308
|
+
jwks_uri?: string | string[] | undefined;
|
|
309
|
+
block_local_jwks?: boolean | undefined;
|
|
310
|
+
jwks_reject_ip_ranges?: string[] | undefined;
|
|
311
|
+
jwks?: {
|
|
312
|
+
keys: ({
|
|
313
|
+
kty: "RSA";
|
|
314
|
+
kid: string;
|
|
315
|
+
n: string;
|
|
316
|
+
e: string;
|
|
317
|
+
alg?: "RS256" | "RS384" | "RS512" | undefined;
|
|
318
|
+
use?: string | undefined;
|
|
319
|
+
} | {
|
|
320
|
+
kty: "oct";
|
|
321
|
+
alg: "HS256" | "HS384" | "HS512";
|
|
322
|
+
k: string;
|
|
323
|
+
kid?: string | undefined;
|
|
324
|
+
use?: string | undefined;
|
|
325
|
+
} | {
|
|
326
|
+
kty: "OKP";
|
|
327
|
+
alg: "EdDSA";
|
|
328
|
+
crv: "Ed25519" | "Ed448";
|
|
329
|
+
x: string;
|
|
330
|
+
kid?: string | undefined;
|
|
331
|
+
use?: string | undefined;
|
|
332
|
+
} | {
|
|
333
|
+
kty: "EC";
|
|
334
|
+
alg: "ES256" | "ES384" | "ES512";
|
|
335
|
+
crv: "P-256" | "P-384" | "P-512";
|
|
336
|
+
x: string;
|
|
337
|
+
y: string;
|
|
338
|
+
kid?: string | undefined;
|
|
339
|
+
use?: string | undefined;
|
|
340
|
+
})[];
|
|
341
|
+
} | undefined;
|
|
342
|
+
supabase?: boolean | undefined;
|
|
343
|
+
supabase_jwt_secret?: string | undefined;
|
|
344
|
+
audience?: string[] | undefined;
|
|
345
|
+
} | undefined;
|
|
346
|
+
parameters?: Record<string, string | number | boolean | null> | undefined;
|
|
347
|
+
api?: {
|
|
348
|
+
tokens?: string[] | undefined;
|
|
349
|
+
parameters?: {
|
|
350
|
+
max_concurrent_connections?: number | undefined;
|
|
351
|
+
max_data_fetch_concurrency?: number | undefined;
|
|
352
|
+
max_buckets_per_connection?: number | undefined;
|
|
353
|
+
max_parameter_query_results?: number | undefined;
|
|
354
|
+
} | undefined;
|
|
355
|
+
} | undefined;
|
|
356
|
+
port?: string | number | undefined;
|
|
357
|
+
sync_config?: {
|
|
358
|
+
content?: string | undefined;
|
|
359
|
+
path?: string | undefined;
|
|
360
|
+
exit_on_error?: boolean | undefined;
|
|
361
|
+
} | undefined;
|
|
362
|
+
sync_rules?: {
|
|
363
|
+
content?: string | undefined;
|
|
364
|
+
path?: string | undefined;
|
|
365
|
+
exit_on_error?: boolean | undefined;
|
|
366
|
+
} | undefined;
|
|
367
|
+
metadata?: Record<string, string> | undefined;
|
|
368
|
+
migrations?: {
|
|
369
|
+
disable_auto_migration?: boolean | undefined;
|
|
370
|
+
} | undefined;
|
|
371
|
+
telemetry?: {
|
|
372
|
+
disable_telemetry_sharing: boolean;
|
|
373
|
+
prometheus_port?: string | number | undefined;
|
|
374
|
+
internal_service_endpoint?: string | undefined;
|
|
375
|
+
} | undefined;
|
|
376
|
+
healthcheck?: {
|
|
377
|
+
probes?: {
|
|
378
|
+
use_filesystem?: boolean | undefined;
|
|
379
|
+
use_http?: boolean | undefined;
|
|
380
|
+
use_legacy?: boolean | undefined;
|
|
381
|
+
} | undefined;
|
|
382
|
+
} | undefined;
|
|
383
|
+
system?: {
|
|
384
|
+
logging?: {
|
|
385
|
+
level?: "silly" | "debug" | "verbose" | "http" | "info" | "warn" | "error" | undefined;
|
|
386
|
+
format?: "text" | "json" | undefined;
|
|
387
|
+
} | undefined;
|
|
388
|
+
} | undefined;
|
|
389
|
+
} & {
|
|
390
|
+
_type: "self-hosted";
|
|
391
|
+
}, string, t.CodecProps>, t.RecordCodec<t.Codec<any, any, t.CodecType.Any, t.CodecProps>>>;
|
|
392
|
+
export type ServiceSelfHostedConfig = t.Encoded<typeof ServiceSelfHostedConfig>;
|
|
393
|
+
export type ServiceSelfHostedConfigDecoded = t.Decoded<typeof ServiceSelfHostedConfig>;
|
|
394
|
+
/** JSON Schema for self-hosted service config: BaseServiceSelfHostedConfig + SelfHostedSchema (management-types). */
|
|
395
|
+
export declare const ServiceSelfHostedConfigSchema: Record<string, unknown>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import SelfHostedSchema from '@powersync/service-schema/schema.json' with { type: 'json' };
|
|
2
|
+
import { configFile } from '@powersync/service-types';
|
|
3
|
+
import * as t from 'ts-codec';
|
|
4
|
+
/** Merges two JSON Schema object schemas by combining properties and required arrays. */
|
|
5
|
+
function mergeObjectSchemas(base, extension) {
|
|
6
|
+
const baseProps = base.properties ?? {};
|
|
7
|
+
const extProps = extension.properties ?? {};
|
|
8
|
+
const baseRequired = Array.isArray(base.required) ? base.required : [];
|
|
9
|
+
const extRequired = Array.isArray(extension.required) ? extension.required : [];
|
|
10
|
+
const required = [...new Set([...baseRequired, ...extRequired])];
|
|
11
|
+
return {
|
|
12
|
+
...base,
|
|
13
|
+
properties: { ...baseProps, ...extProps },
|
|
14
|
+
type: 'object',
|
|
15
|
+
...(required.length > 0 ? { required } : {})
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// For self hosted, we use the json schema as a merged source of truth
|
|
19
|
+
export const BaseServiceSelfHostedConfig = configFile.powerSyncConfig.and(t.object({
|
|
20
|
+
_type: t.literal('self-hosted')
|
|
21
|
+
}));
|
|
22
|
+
export const ServiceSelfHostedConfig = BaseServiceSelfHostedConfig.and(t.record(t.any));
|
|
23
|
+
const BaseServiceSelfHostedConfigSchema = t.generateJSONSchema(BaseServiceSelfHostedConfig, {
|
|
24
|
+
parsers: [configFile.portParser]
|
|
25
|
+
});
|
|
26
|
+
/** JSON Schema for self-hosted service config: BaseServiceSelfHostedConfig + SelfHostedSchema (management-types). */
|
|
27
|
+
export const ServiceSelfHostedConfigSchema = mergeObjectSchemas(BaseServiceSelfHostedConfigSchema, SelfHostedSchema);
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _SyncSchema from '@powersync/service-sync-rules/schema/sync_rules.json' with { type: 'json' };
|
|
2
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { CLIConfigSchema } from '../CLIConfig.js';
|
|
6
|
+
import { ServiceConfigSchema } from '../ServiceConfig.js';
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const schemaDir = join(__dirname, '..', '..', 'json-schema');
|
|
9
|
+
mkdirSync(schemaDir, { recursive: true });
|
|
10
|
+
writeFileSync(join(schemaDir, 'cli-config.json'), JSON.stringify(CLIConfigSchema, null, 2));
|
|
11
|
+
writeFileSync(join(schemaDir, 'service-config.json'), JSON.stringify(ServiceConfigSchema, null, 2));
|
|
12
|
+
writeFileSync(join(schemaDir, 'sync-config.json'), JSON.stringify(_SyncSchema, null, 2));
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export declare const CLOUD_CONFIG_VALIDATOR: {
|
|
2
|
+
validate(data: unknown): {
|
|
3
|
+
errors: string[];
|
|
4
|
+
valid: boolean;
|
|
5
|
+
} | {
|
|
6
|
+
valid: boolean;
|
|
7
|
+
errors?: undefined;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const SELF_HOSTED_CONFIG_VALIDATOR: {
|
|
11
|
+
validate(data: unknown): {
|
|
12
|
+
errors: string[];
|
|
13
|
+
valid: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
valid: boolean;
|
|
16
|
+
errors?: undefined;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare const SERVICE_CONFIG_VALIDATOR: {
|
|
20
|
+
validate(data: unknown): {
|
|
21
|
+
errors: string[];
|
|
22
|
+
valid: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
valid: boolean;
|
|
25
|
+
errors?: undefined;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const CLI_CONFIG_VALIDATOR: {
|
|
29
|
+
validate(data: unknown): {
|
|
30
|
+
errors: string[];
|
|
31
|
+
valid: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
errors?: undefined;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Validate cloud service config (service.yaml with _type: cloud) against the cloud JSON schema.
|
|
39
|
+
*/
|
|
40
|
+
export declare const validateCloudConfig: (config: unknown) => {
|
|
41
|
+
errors: string[];
|
|
42
|
+
valid: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
valid: boolean;
|
|
45
|
+
errors?: undefined;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Validate self-hosted service config (service.yaml with _type: self-hosted) against the self-hosted JSON schema.
|
|
49
|
+
*/
|
|
50
|
+
export declare const validateSelfHostedConfig: (config: unknown) => {
|
|
51
|
+
errors: string[];
|
|
52
|
+
valid: boolean;
|
|
53
|
+
} | {
|
|
54
|
+
valid: boolean;
|
|
55
|
+
errors?: undefined;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Validate either cloud or self-hosted service config against the JSON schema (discriminated by _type).
|
|
59
|
+
*/
|
|
60
|
+
export declare const validateServiceConfig: (config: unknown) => {
|
|
61
|
+
errors: string[];
|
|
62
|
+
valid: boolean;
|
|
63
|
+
} | {
|
|
64
|
+
valid: boolean;
|
|
65
|
+
errors?: undefined;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Validate CLI config (cli.yaml: cloud or self-hosted) against the CLI config JSON schema.
|
|
69
|
+
*/
|
|
70
|
+
export declare const validateCLIConfig: (config: unknown) => {
|
|
71
|
+
errors: string[];
|
|
72
|
+
valid: boolean;
|
|
73
|
+
} | {
|
|
74
|
+
valid: boolean;
|
|
75
|
+
errors?: undefined;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Creates a validator that checks data against a JSON Schema using AJV.
|
|
79
|
+
* Returns an object with a `validate(data)` method that returns
|
|
80
|
+
* `{ valid: true }` or `{ valid: false, errors: string[] }`.
|
|
81
|
+
*
|
|
82
|
+
* @param schema - JSON Schema object (e.g. ServiceConfigSchema, CLIConfigSchema)
|
|
83
|
+
* @returns Validator with validate(data) method
|
|
84
|
+
*/
|
|
85
|
+
export declare function createSchemaValidator(schema: Record<string, unknown>): {
|
|
86
|
+
validate(data: unknown): {
|
|
87
|
+
errors: string[];
|
|
88
|
+
valid: boolean;
|
|
89
|
+
} | {
|
|
90
|
+
valid: boolean;
|
|
91
|
+
errors?: undefined;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import AJV from 'ajv';
|
|
2
|
+
import ajvFormatter from 'better-ajv-errors';
|
|
3
|
+
import { CLIConfigSchema } from './CLIConfig.js';
|
|
4
|
+
import { ServiceCloudConfigSchema } from './ServiceCloudConfig.js';
|
|
5
|
+
import { ServiceConfigSchema } from './ServiceConfig.js';
|
|
6
|
+
import { ServiceSelfHostedConfigSchema } from './ServiceSelfHostedConfig.js';
|
|
7
|
+
export const CLOUD_CONFIG_VALIDATOR = createSchemaValidator(ServiceCloudConfigSchema);
|
|
8
|
+
export const SELF_HOSTED_CONFIG_VALIDATOR = createSchemaValidator(ServiceSelfHostedConfigSchema);
|
|
9
|
+
export const SERVICE_CONFIG_VALIDATOR = createSchemaValidator(ServiceConfigSchema);
|
|
10
|
+
export const CLI_CONFIG_VALIDATOR = createSchemaValidator(CLIConfigSchema);
|
|
11
|
+
/**
|
|
12
|
+
* Validate cloud service config (service.yaml with _type: cloud) against the cloud JSON schema.
|
|
13
|
+
*/
|
|
14
|
+
export const validateCloudConfig = (config) => CLOUD_CONFIG_VALIDATOR.validate(config);
|
|
15
|
+
/**
|
|
16
|
+
* Validate self-hosted service config (service.yaml with _type: self-hosted) against the self-hosted JSON schema.
|
|
17
|
+
*/
|
|
18
|
+
export const validateSelfHostedConfig = (config) => SELF_HOSTED_CONFIG_VALIDATOR.validate(config);
|
|
19
|
+
/**
|
|
20
|
+
* Validate either cloud or self-hosted service config against the JSON schema (discriminated by _type).
|
|
21
|
+
*/
|
|
22
|
+
export const validateServiceConfig = (config) => SERVICE_CONFIG_VALIDATOR.validate(config);
|
|
23
|
+
/**
|
|
24
|
+
* Validate CLI config (cli.yaml: cloud or self-hosted) against the CLI config JSON schema.
|
|
25
|
+
*/
|
|
26
|
+
export const validateCLIConfig = (config) => CLI_CONFIG_VALIDATOR.validate(config);
|
|
27
|
+
/**
|
|
28
|
+
* Creates a validator that checks data against a JSON Schema using AJV.
|
|
29
|
+
* Returns an object with a `validate(data)` method that returns
|
|
30
|
+
* `{ valid: true }` or `{ valid: false, errors: string[] }`.
|
|
31
|
+
*
|
|
32
|
+
* @param schema - JSON Schema object (e.g. ServiceConfigSchema, CLIConfigSchema)
|
|
33
|
+
* @returns Validator with validate(data) method
|
|
34
|
+
*/
|
|
35
|
+
export function createSchemaValidator(schema) {
|
|
36
|
+
const ajv = new AJV.Ajv();
|
|
37
|
+
const validator = ajv.compile(schema);
|
|
38
|
+
return {
|
|
39
|
+
validate(data) {
|
|
40
|
+
const valid = validator(data);
|
|
41
|
+
if (!valid) {
|
|
42
|
+
const errors = ajvFormatter(schema, data, validator.errors || [], {
|
|
43
|
+
format: 'js'
|
|
44
|
+
})?.map((error) => error.error);
|
|
45
|
+
return {
|
|
46
|
+
errors: errors || [],
|
|
47
|
+
valid: false
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
valid: true
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"definitions": {},
|
|
3
|
+
"anyOf": [
|
|
4
|
+
{
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"instance_id": {
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
10
|
+
"org_id": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"project_id": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"type": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"const": "cloud"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"required": [
|
|
23
|
+
"type"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"api_key": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"api_url": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"plugins": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"additionalProperties": {},
|
|
38
|
+
"properties": {},
|
|
39
|
+
"required": []
|
|
40
|
+
},
|
|
41
|
+
"type": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"const": "self-hosted"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"additionalProperties": false,
|
|
47
|
+
"required": [
|
|
48
|
+
"type"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|