@sdlcworks/components 0.0.22 → 0.0.24
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/index.d.ts +93 -90
- package/dist/index.js +1 -138
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,103 +20,96 @@ export declare enum DeploymentArtifactType {
|
|
|
20
20
|
container_image = "container_image"
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* Transforms any interface name to canonical hyphen-separated lowercase form.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* toCanonicalInterfaceName("ServiceAccount") // "service-account"
|
|
27
|
+
* toCanonicalInterfaceName("service_account") // "service-account"
|
|
28
|
+
* toCanonicalInterfaceName("SERVICE-ACCOUNT") // "service-account"
|
|
29
|
+
* toCanonicalInterfaceName("serviceAccountCI") // "service-account-ci"
|
|
26
30
|
*/
|
|
27
|
-
export declare
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
export declare function toCanonicalInterfaceName(name: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Connection interface definition with a unique name and typed schema.
|
|
34
|
+
* The name is used for matching interfaces across separately bundled components.
|
|
35
|
+
*/
|
|
36
|
+
export type ConnectionInterfaceDef<TName extends string = string, TSchema extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> = {
|
|
37
|
+
readonly name: TName;
|
|
38
|
+
readonly schema: TSchema;
|
|
39
|
+
};
|
|
30
40
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
41
|
+
* Creates a connection interface definition with a unique name and schema.
|
|
42
|
+
* The name is canonicalized to hyphen-separated lowercase and registered
|
|
43
|
+
* globally to detect collisions.
|
|
33
44
|
*
|
|
34
45
|
* @example
|
|
35
|
-
* const
|
|
36
|
-
*
|
|
46
|
+
* const ServiceAccountCI = defineConnectionInterface(
|
|
47
|
+
* "service-account",
|
|
48
|
+
* z.object({ email: z.string() })
|
|
37
49
|
* );
|
|
38
50
|
*/
|
|
39
|
-
export declare function
|
|
40
|
-
new (): {
|
|
41
|
-
readonly schema: TSchema;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
51
|
+
export declare function defineConnectionInterface<TName extends string, TSchema extends z.ZodObject<z.ZodRawShape>>(name: TName, schema: TSchema): ConnectionInterfaceDef<TName, TSchema>;
|
|
44
52
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
53
|
+
* Merges a parent interface's schema with additional fields.
|
|
54
|
+
* Use with defineConnectionInterface to create extended interfaces.
|
|
47
55
|
*
|
|
48
56
|
* @example
|
|
49
|
-
* const
|
|
50
|
-
*
|
|
51
|
-
* )
|
|
52
|
-
* const ExtendedCI = extendConnectionInterface(
|
|
53
|
-
* BaseCI,
|
|
54
|
-
* z.object({ bar: z.number() })
|
|
57
|
+
* const ExtendedCI = defineConnectionInterface(
|
|
58
|
+
* "extended-service",
|
|
59
|
+
* extendSchema(BaseCI, z.object({ extraField: z.string() }))
|
|
55
60
|
* );
|
|
56
|
-
* // ExtendedCI schema: { foo: string, bar: number }
|
|
57
61
|
*/
|
|
58
|
-
export declare function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
[k in keyof T]: T[k];
|
|
70
|
-
} : never, TChildSchema["_zod"]["config"]>;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
62
|
+
export declare function extendSchema<TParentSchema extends z.ZodObject<z.ZodRawShape>, TChildSchema extends z.ZodObject<z.ZodRawShape>>(parentDef: ConnectionInterfaceDef<string, TParentSchema>, additionalSchema: TChildSchema): z.ZodObject<((string | number) & keyof TChildSchema["shape"] extends never ? Readonly<{
|
|
63
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
64
|
+
}> & TChildSchema["shape"] : (Readonly<{
|
|
65
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
66
|
+
}> extends infer T_1 extends z.core.util.SomeObject ? {
|
|
67
|
+
[K in keyof T_1 as K extends keyof TChildSchema["shape"] ? never : K]: T_1[K];
|
|
68
|
+
} : never) & (TChildSchema["shape"] extends infer T_2 extends z.core.util.SomeObject ? {
|
|
69
|
+
[K_1 in keyof T_2]: T_2[K_1];
|
|
70
|
+
} : never)) extends infer T ? {
|
|
71
|
+
[k in keyof T]: T[k];
|
|
72
|
+
} : never, TChildSchema["_zod"]["config"]>;
|
|
73
73
|
/**
|
|
74
74
|
* TCP Connection Interface - defines a TCP-based connection endpoint.
|
|
75
75
|
* Use this for components that expose TCP services.
|
|
76
76
|
*/
|
|
77
|
-
export declare const TCPCI: {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
publicAccess: z.ZodBoolean;
|
|
85
|
-
}, z.core.$strip>;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Type alias for ConnectionInterface class constructors.
|
|
90
|
-
*/
|
|
91
|
-
export type ConnectionInterfaceClass<TSchema extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> = new () => ConnectionInterface<TSchema>;
|
|
77
|
+
export declare const TCPCI: ConnectionInterfaceDef<"tcp", z.ZodObject<{
|
|
78
|
+
url: z.ZodObject<{
|
|
79
|
+
type: z.ZodEnum<typeof TCPUrlType>;
|
|
80
|
+
value: z.ZodString;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
publicAccess: z.ZodBoolean;
|
|
83
|
+
}, z.core.$strip>>;
|
|
92
84
|
/**
|
|
93
|
-
* Extract the inferred data type from a
|
|
85
|
+
* Extract the inferred data type from a ConnectionInterfaceDef.
|
|
94
86
|
*/
|
|
95
|
-
export type InferConnectionData<
|
|
87
|
+
export type InferConnectionData<D extends ConnectionInterfaceDef> = z.infer<D["schema"]>;
|
|
96
88
|
/**
|
|
97
89
|
* Wrap connection data with PulumiInput to support Pulumi Output types.
|
|
98
90
|
*/
|
|
99
|
-
export type InferConnectionDataWithInputs<
|
|
100
|
-
[K in keyof
|
|
101
|
-
};
|
|
91
|
+
export type InferConnectionDataWithInputs<D extends ConnectionInterfaceDef> = InferConnectionData<D> extends infer Data ? {
|
|
92
|
+
[K in keyof Data]: PulumiInput<Data[K]>;
|
|
93
|
+
} : never;
|
|
102
94
|
/**
|
|
103
95
|
* Entry type for declareConnectionInterfaces parameter.
|
|
104
96
|
* Declares an interface that this component exposes with typed data.
|
|
105
97
|
*/
|
|
106
|
-
export type DeclaredConnectionInterfaceEntry<
|
|
107
|
-
interface:
|
|
108
|
-
data: InferConnectionDataWithInputs<
|
|
98
|
+
export type DeclaredConnectionInterfaceEntry<D extends ConnectionInterfaceDef = ConnectionInterfaceDef> = {
|
|
99
|
+
interface: D;
|
|
100
|
+
data: InferConnectionDataWithInputs<D>;
|
|
109
101
|
};
|
|
110
102
|
/**
|
|
111
103
|
* Function type for declareConnectionInterfaces.
|
|
112
104
|
* Called within pulumi function to declare exposed connection interfaces.
|
|
113
105
|
*/
|
|
114
|
-
export type DeclareConnectionInterfacesFn = <
|
|
106
|
+
export type DeclareConnectionInterfacesFn = <D extends ConnectionInterfaceDef>(entries: DeclaredConnectionInterfaceEntry<D>[]) => void;
|
|
107
|
+
export type InferredZodObject<S extends z.ZodRawShape> = z.infer<z.ZodObject<S>>;
|
|
115
108
|
export type InferZodType<S extends z.ZodRawShape> = {
|
|
116
|
-
[K in keyof
|
|
109
|
+
[K in keyof InferredZodObject<S>]: PulumiInput<InferredZodObject<S>[K]>;
|
|
117
110
|
};
|
|
118
111
|
export type InferOutputType<OShape extends z.ZodRawShape> = {
|
|
119
|
-
[K in keyof
|
|
112
|
+
[K in keyof InferredZodObject<OShape>]: PulumiOutput<InferredZodObject<OShape>[K]>;
|
|
120
113
|
};
|
|
121
114
|
declare const emptyOutputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
122
115
|
export type EmptyOutputShape = typeof emptyOutputSchema.shape;
|
|
@@ -155,7 +148,6 @@ export type InfraComponentOpts<CShape extends z.ZodRawShape, DShape extends z.Zo
|
|
|
155
148
|
outputSchema: z.ZodObject<OShape>;
|
|
156
149
|
connectionTypes: ConnTypes;
|
|
157
150
|
};
|
|
158
|
-
export type InfraComponentInputs<C> = C;
|
|
159
151
|
export type ArtifactInfo = {
|
|
160
152
|
artifact: {
|
|
161
153
|
uri: string;
|
|
@@ -196,19 +188,21 @@ export type ConnectionHandlerCtx<S, ConnectorData, ConnectionType extends string
|
|
|
196
188
|
*/
|
|
197
189
|
export type ConnectionHandlerResult = Record<string, PulumiOutput<string>>;
|
|
198
190
|
/**
|
|
199
|
-
* A connection handler entry mapping a
|
|
191
|
+
* A connection handler entry mapping a ConnectionInterfaceDef to its handler function.
|
|
200
192
|
*/
|
|
201
|
-
export type ConnectionHandlerEntry<S, ConnectionType extends string,
|
|
202
|
-
interface:
|
|
203
|
-
handler: (ctx: ConnectionHandlerCtx<S, InferConnectionData<
|
|
193
|
+
export type ConnectionHandlerEntry<S, ConnectionType extends string, D extends ConnectionInterfaceDef> = {
|
|
194
|
+
interface: D;
|
|
195
|
+
handler: (ctx: ConnectionHandlerCtx<S, InferConnectionData<D>, ConnectionType>) => Promise<ConnectionHandlerResult>;
|
|
204
196
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Type definition for a connection handler entry.
|
|
199
|
+
* Simplifies by not duplicating the type in return position.
|
|
200
|
+
*/
|
|
201
|
+
export type ConnectionHandlerDef<D extends ConnectionInterfaceDef> = {
|
|
202
|
+
interface: D;
|
|
203
|
+
handler: (ctx: ConnectionHandlerCtx<any, InferConnectionData<D>, any>) => Promise<ConnectionHandlerResult>;
|
|
211
204
|
};
|
|
205
|
+
export declare function connectionHandler<D extends ConnectionInterfaceDef>(entry: ConnectionHandlerDef<D>): ConnectionHandlerDef<D>;
|
|
212
206
|
export type ProviderDeployCtx<D, S> = {
|
|
213
207
|
state: S;
|
|
214
208
|
} & Record<string, DeploymentInfo>;
|
|
@@ -241,23 +235,24 @@ export type ProviderDeallocateFn<S> = (ctx: ProviderDeallocateCtx<S>) => Promise
|
|
|
241
235
|
export type ProviderUpsertArtifactsFn<S> = (ctx: ProviderUpsertArtifactsCtx<S>) => Promise<void>;
|
|
242
236
|
declare const emptyStateSchema: z.ZodObject<{}, z.core.$strip>;
|
|
243
237
|
export type EmptyStateShape = typeof emptyStateSchema.shape;
|
|
244
|
-
export type
|
|
238
|
+
export type InferredState<SShape extends z.ZodRawShape> = z.infer<z.ZodObject<SShape>>;
|
|
239
|
+
export type ProviderFnsDef<I, D, O, SShape extends z.ZodRawShape = EmptyStateShape, ConnectionType extends string = string, S = InferredState<SShape>> = {
|
|
245
240
|
stateSchema?: z.ZodObject<SShape>;
|
|
246
|
-
initialState?:
|
|
247
|
-
pulumi: ProviderPulumiFn<I,
|
|
248
|
-
connect?: readonly ConnectionHandlerEntry<
|
|
249
|
-
deploy?: ProviderDeployFn<D,
|
|
250
|
-
allocateComponent?: ProviderAllocateFn<
|
|
251
|
-
deallocateComponent?: ProviderDeallocateFn<
|
|
252
|
-
upsertArtifacts?: ProviderUpsertArtifactsFn<
|
|
241
|
+
initialState?: S;
|
|
242
|
+
pulumi: ProviderPulumiFn<I, S, O>;
|
|
243
|
+
connect?: readonly ConnectionHandlerEntry<S, ConnectionType, any>[];
|
|
244
|
+
deploy?: ProviderDeployFn<D, S>;
|
|
245
|
+
allocateComponent?: ProviderAllocateFn<S>;
|
|
246
|
+
deallocateComponent?: ProviderDeallocateFn<S>;
|
|
247
|
+
upsertArtifacts?: ProviderUpsertArtifactsFn<S>;
|
|
253
248
|
};
|
|
254
249
|
/**
|
|
255
|
-
* Stored version of ConnectionHandlerEntry that preserves
|
|
256
|
-
* This ensures `interface` is always typed as
|
|
250
|
+
* Stored version of ConnectionHandlerEntry that preserves ConnectionInterfaceDef type.
|
|
251
|
+
* This ensures `interface` is always typed as ConnectionInterfaceDef (not any)
|
|
257
252
|
* when accessing from the registry, allowing runtime schema access.
|
|
258
253
|
*/
|
|
259
254
|
export type StoredConnectionHandlerEntry = {
|
|
260
|
-
interface:
|
|
255
|
+
interface: ConnectionInterfaceDef;
|
|
261
256
|
handler: (ctx: ConnectionHandlerCtx<any, any, any>) => Promise<ConnectionHandlerResult>;
|
|
262
257
|
};
|
|
263
258
|
export type StoredProviderFns = {
|
|
@@ -271,7 +266,15 @@ export type StoredProviderFns = {
|
|
|
271
266
|
upsertArtifacts?: ProviderUpsertArtifactsFn<any>;
|
|
272
267
|
};
|
|
273
268
|
export type ProviderRegistry = Partial<Record<CloudProvider, StoredProviderFns>>;
|
|
274
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Map of interface name to its schema and declared data.
|
|
271
|
+
* Keyed by canonical interface name for cross-bundle matching.
|
|
272
|
+
* Schema is transformed to accept Pulumi Output types.
|
|
273
|
+
*/
|
|
274
|
+
export type DeclaredConnectionInterfaces = Map<string, {
|
|
275
|
+
schema: z.ZodTypeAny;
|
|
276
|
+
data: any;
|
|
277
|
+
}>;
|
|
275
278
|
export declare class InfraComponent<CShape extends z.ZodRawShape, DShape extends z.ZodRawShape, OShape extends z.ZodRawShape = EmptyOutputShape, ConnTypes extends Record<string, {
|
|
276
279
|
description: string;
|
|
277
280
|
}> = Record<string, {
|
|
@@ -283,12 +286,12 @@ export declare class InfraComponent<CShape extends z.ZodRawShape, DShape extends
|
|
|
283
286
|
validationDeploymentInputSchema: z.ZodTypeAny;
|
|
284
287
|
private declaredConnectionInterfaces;
|
|
285
288
|
constructor(opts: InfraComponentOpts<CShape, DShape, OShape, ConnTypes>);
|
|
286
|
-
implement<SShape extends z.ZodRawShape = EmptyStateShape>(provider: CloudProvider, fns: ProviderFnsDef<
|
|
289
|
+
implement<SShape extends z.ZodRawShape = EmptyStateShape>(provider: CloudProvider, fns: ProviderFnsDef<InferZodType<CShape>, InferZodType<DShape>, InferOutputType<OShape>, SShape, keyof ConnTypes & string>): this;
|
|
287
290
|
/**
|
|
288
291
|
* Get the schema for a specific connection interface.
|
|
289
292
|
* Used by the orchestrator at runtime.
|
|
290
293
|
*/
|
|
291
|
-
getConnectionSchema(
|
|
294
|
+
getConnectionSchema(interfaceDef: ConnectionInterfaceDef): z.ZodObject<z.ZodRawShape>;
|
|
292
295
|
/**
|
|
293
296
|
* Create the declareConnectionInterfaces function for use in pulumi context.
|
|
294
297
|
* The orchestrator calls this before invoking the pulumi function.
|
package/dist/index.js
CHANGED
|
@@ -1,138 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import * as pulumi from "@pulumi/pulumi";
|
|
4
|
-
var CloudProvider;
|
|
5
|
-
((CloudProvider2) => {
|
|
6
|
-
CloudProvider2["aws"] = "aws";
|
|
7
|
-
CloudProvider2["gcloud"] = "gcloud";
|
|
8
|
-
CloudProvider2["azure"] = "azure";
|
|
9
|
-
CloudProvider2["linode"] = "linode";
|
|
10
|
-
CloudProvider2["hetzner"] = "hetzner";
|
|
11
|
-
CloudProvider2["cloudflare"] = "cloudflare";
|
|
12
|
-
})(CloudProvider ||= {});
|
|
13
|
-
var TCPUrlType;
|
|
14
|
-
((TCPUrlType2) => {
|
|
15
|
-
TCPUrlType2["ipv4"] = "ipv4";
|
|
16
|
-
TCPUrlType2["ipv6"] = "ipv6";
|
|
17
|
-
TCPUrlType2["domain"] = "domain";
|
|
18
|
-
})(TCPUrlType ||= {});
|
|
19
|
-
var DeploymentArtifactType;
|
|
20
|
-
((DeploymentArtifactType2) => {
|
|
21
|
-
DeploymentArtifactType2["container_image"] = "container_image";
|
|
22
|
-
})(DeploymentArtifactType ||= {});
|
|
23
|
-
|
|
24
|
-
class ConnectionInterface {
|
|
25
|
-
}
|
|
26
|
-
function createConnectionInterface(schema) {
|
|
27
|
-
return class extends ConnectionInterface {
|
|
28
|
-
schema = schema;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function extendConnectionInterface(parentClass, additionalSchema) {
|
|
32
|
-
const parentInstance = new parentClass;
|
|
33
|
-
const mergedSchema = parentInstance.schema.merge(additionalSchema);
|
|
34
|
-
return class extends ConnectionInterface {
|
|
35
|
-
schema = mergedSchema;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
var TCPCI = createConnectionInterface(z.object({
|
|
39
|
-
url: z.object({
|
|
40
|
-
type: z.nativeEnum(TCPUrlType),
|
|
41
|
-
value: z.string()
|
|
42
|
-
}),
|
|
43
|
-
publicAccess: z.boolean()
|
|
44
|
-
}));
|
|
45
|
-
var emptyOutputSchema = z.object({});
|
|
46
|
-
function transformSchemaToAcceptOutputs(schema) {
|
|
47
|
-
if (schema instanceof z.ZodObject) {
|
|
48
|
-
const shape = schema.shape;
|
|
49
|
-
const newShape = {};
|
|
50
|
-
for (const key in shape) {
|
|
51
|
-
newShape[key] = transformSchemaToAcceptOutputs(shape[key]);
|
|
52
|
-
}
|
|
53
|
-
return z.object(newShape);
|
|
54
|
-
}
|
|
55
|
-
if (schema instanceof z.ZodOptional) {
|
|
56
|
-
return transformSchemaToAcceptOutputs(schema.unwrap()).optional();
|
|
57
|
-
}
|
|
58
|
-
if (schema instanceof z.ZodNullable) {
|
|
59
|
-
return transformSchemaToAcceptOutputs(schema.unwrap()).nullable();
|
|
60
|
-
}
|
|
61
|
-
if (schema instanceof z.ZodArray) {
|
|
62
|
-
return z.array(transformSchemaToAcceptOutputs(schema.element));
|
|
63
|
-
}
|
|
64
|
-
return z.union([
|
|
65
|
-
schema,
|
|
66
|
-
z.custom((val) => pulumi.Output.isInstance(val))
|
|
67
|
-
]);
|
|
68
|
-
}
|
|
69
|
-
var InfraComponentOptsSchema = z.object({
|
|
70
|
-
metadata: z.object({
|
|
71
|
-
stateful: z.boolean(),
|
|
72
|
-
proxiable: z.boolean()
|
|
73
|
-
}),
|
|
74
|
-
connectionTypes: z.record(z.string(), z.object({
|
|
75
|
-
description: z.string().min(5)
|
|
76
|
-
})),
|
|
77
|
-
configSchema: z.custom(),
|
|
78
|
-
deploymentInputSchema: z.custom(),
|
|
79
|
-
outputSchema: z.custom()
|
|
80
|
-
});
|
|
81
|
-
function connectionHandler(entry) {
|
|
82
|
-
return entry;
|
|
83
|
-
}
|
|
84
|
-
var emptyStateSchema = z.object({});
|
|
85
|
-
|
|
86
|
-
class InfraComponent {
|
|
87
|
-
opts;
|
|
88
|
-
providers;
|
|
89
|
-
validationSchema;
|
|
90
|
-
validationDeploymentInputSchema;
|
|
91
|
-
declaredConnectionInterfaces = new Map;
|
|
92
|
-
constructor(opts) {
|
|
93
|
-
this.opts = InfraComponentOptsSchema.parse(opts);
|
|
94
|
-
this.providers = {};
|
|
95
|
-
this.validationSchema = transformSchemaToAcceptOutputs(opts.configSchema);
|
|
96
|
-
this.validationDeploymentInputSchema = transformSchemaToAcceptOutputs(opts.deploymentInputSchema);
|
|
97
|
-
}
|
|
98
|
-
implement(provider, fns) {
|
|
99
|
-
this.providers[provider] = {
|
|
100
|
-
...fns,
|
|
101
|
-
stateSchema: fns.stateSchema ?? emptyStateSchema,
|
|
102
|
-
initialState: fns.initialState
|
|
103
|
-
};
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
getConnectionSchema(interfaceClass) {
|
|
107
|
-
const instance = new interfaceClass;
|
|
108
|
-
return instance.schema;
|
|
109
|
-
}
|
|
110
|
-
createDeclareConnectionInterfacesFn() {
|
|
111
|
-
return (entries) => {
|
|
112
|
-
for (const entry of entries) {
|
|
113
|
-
const instance = new entry.interface;
|
|
114
|
-
const schema = instance.schema;
|
|
115
|
-
const transformedSchema = transformSchemaToAcceptOutputs(schema);
|
|
116
|
-
const parseResult = transformedSchema.safeParse(entry.data);
|
|
117
|
-
if (!parseResult.success) {
|
|
118
|
-
throw new Error(`Invalid data for connection interface ${entry.interface.name}: ${parseResult.error.message}`);
|
|
119
|
-
}
|
|
120
|
-
this.declaredConnectionInterfaces.set(entry.interface, entry.data);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
getDeclaredInterfaces() {
|
|
125
|
-
return this.declaredConnectionInterfaces;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
export {
|
|
129
|
-
extendConnectionInterface,
|
|
130
|
-
createConnectionInterface,
|
|
131
|
-
connectionHandler,
|
|
132
|
-
TCPUrlType,
|
|
133
|
-
TCPCI,
|
|
134
|
-
InfraComponent,
|
|
135
|
-
DeploymentArtifactType,
|
|
136
|
-
ConnectionInterface,
|
|
137
|
-
CloudProvider
|
|
138
|
-
};
|
|
1
|
+
import{z as q}from"zod";import*as L from"@pulumi/pulumi";var Q;((H)=>{H.aws="aws";H.gcloud="gcloud";H.azure="azure";H.linode="linode";H.hetzner="hetzner";H.cloudflare="cloudflare"})(Q||={});var M;((E)=>{E.ipv4="ipv4";E.ipv6="ipv6";E.domain="domain"})(M||={});var V;((j)=>j.container_image="container_image")(V||={});var K=new Map;function W(b){return b.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase().replace(/-+/g,"-").replace(/^-|-$/g,"")}function X(b){let j=W(b);if(j.length===0)throw new Error("Connection interface name cannot be empty");let B=K.get(j);if(B!==void 0&&B!==b)throw new Error(`Connection interface name collision: '${b}' resolves to '${j}' which is already registered by '${B}'`);return K.set(j,b),j}function Y(b,j){return{name:X(b),schema:j}}function k(b,j){return b.schema.merge(j)}var x=Y("tcp",q.object({url:q.object({type:q.nativeEnum(M),value:q.string()}),publicAccess:q.boolean()})),N=q.object({});function F(b){if(b instanceof q.ZodObject){let j=b.shape,B={};for(let E in j)B[E]=F(j[E]);return q.object(B)}if(b instanceof q.ZodOptional)return F(b.unwrap()).optional();if(b instanceof q.ZodNullable)return F(b.unwrap()).nullable();if(b instanceof q.ZodArray)return q.array(F(b.element));return q.union([b,q.custom((j)=>L.Output.isInstance(j))])}var Z=q.object({metadata:q.object({stateful:q.boolean(),proxiable:q.boolean()}),connectionTypes:q.record(q.string(),q.object({description:q.string().min(5)})),configSchema:q.custom(),deploymentInputSchema:q.custom(),outputSchema:q.custom()});function w(b){return b}var _=q.object({});class ${opts;providers;validationSchema;validationDeploymentInputSchema;declaredConnectionInterfaces=new Map;constructor(b){this.opts=Z.parse(b),this.providers={},this.validationSchema=F(b.configSchema),this.validationDeploymentInputSchema=F(b.deploymentInputSchema)}implement(b,j){return this.providers[b]={...j,stateSchema:j.stateSchema??_,initialState:j.initialState},this}getConnectionSchema(b){return b.schema}createDeclareConnectionInterfacesFn(){return(b)=>{for(let j of b){let B=j.interface.schema,E=F(B),J=E.safeParse(j.data);if(!J.success)throw new Error(`Invalid data for connection interface '${j.interface.name}': ${J.error.message}`);this.declaredConnectionInterfaces.set(j.interface.name,{schema:E,data:j.data})}}}getDeclaredInterfaces(){return this.declaredConnectionInterfaces}}export{W as toCanonicalInterfaceName,k as extendSchema,Y as defineConnectionInterface,w as connectionHandler,M as TCPUrlType,x as TCPCI,$ as InfraComponent,V as DeploymentArtifactType,Q as CloudProvider};
|