@sdlcworks/components 0.0.21 → 0.0.23

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 CHANGED
@@ -20,103 +20,96 @@ export declare enum DeploymentArtifactType {
20
20
  container_image = "container_image"
21
21
  }
22
22
  /**
23
- * Abstract base class for defining connection interfaces.
24
- * Users extend this class to define the schema for data that
25
- * connecting components must provide.
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 abstract class ConnectionInterface<TSchema extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> {
28
- abstract readonly schema: TSchema;
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
- * Factory function to create a ConnectionInterface class from a schema.
32
- * Avoids boilerplate of defining a class manually.
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 TriggerConnection = createConnectionInterface(
36
- * z.object({ eventSource: z.string() })
46
+ * const ServiceAccountCI = defineConnectionInterface(
47
+ * "service-account",
48
+ * z.object({ email: z.string() })
37
49
  * );
38
50
  */
39
- export declare function createConnectionInterface<TSchema extends z.ZodObject<z.ZodRawShape>>(schema: TSchema): {
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
- * Extends a ConnectionInterface class with additional schema fields.
46
- * The resulting class merges the parent and child schemas.
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 BaseCI = createConnectionInterface(
50
- * z.object({ foo: z.string() })
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 extendConnectionInterface<TParentSchema extends z.ZodObject<z.ZodRawShape>, TChildSchema extends z.ZodObject<z.ZodRawShape>>(parentClass: ConnectionInterfaceClass<TParentSchema>, additionalSchema: TChildSchema): {
59
- new (): {
60
- readonly schema: z.ZodObject<((string | number) & keyof TChildSchema["shape"] extends never ? Readonly<{
61
- [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
62
- }> & TChildSchema["shape"] : (Readonly<{
63
- [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
64
- }> extends infer T_1 extends z.core.util.SomeObject ? {
65
- [K in keyof T_1 as K extends keyof TChildSchema["shape"] ? never : K]: T_1[K];
66
- } : never) & (TChildSchema["shape"] extends infer T_2 extends z.core.util.SomeObject ? {
67
- [K_1 in keyof T_2]: T_2[K_1];
68
- } : never)) extends infer T ? {
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
- new (): {
79
- readonly schema: z.ZodObject<{
80
- url: z.ZodObject<{
81
- type: z.ZodEnum<typeof TCPUrlType>;
82
- value: z.ZodString;
83
- }, z.core.$strip>;
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 ConnectionInterface class.
85
+ * Extract the inferred data type from a ConnectionInterfaceDef.
94
86
  */
95
- export type InferConnectionData<C extends ConnectionInterfaceClass> = z.infer<InstanceType<C>["schema"]>;
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<C extends ConnectionInterfaceClass> = {
100
- [K in keyof InferConnectionData<C>]: PulumiInput<InferConnectionData<C>[K]>;
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<C extends ConnectionInterfaceClass = ConnectionInterfaceClass> = {
107
- interface: C;
108
- data: InferConnectionDataWithInputs<C>;
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 = <C extends ConnectionInterfaceClass>(entries: DeclaredConnectionInterfaceEntry<C>[]) => void;
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 z.infer<z.ZodObject<S>>]: PulumiInput<z.infer<z.ZodObject<S>>[K]>;
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 z.infer<z.ZodObject<OShape>>]: PulumiOutput<z.infer<z.ZodObject<OShape>>[K]>;
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;
@@ -192,26 +184,25 @@ export type ConnectionHandlerCtx<S, ConnectorData, ConnectionType extends string
192
184
  };
193
185
  /**
194
186
  * Result returned by connection handlers.
195
- * Can return:
196
- * - A record mapping component names to their URIs
197
- * - A single URI string
198
- * - void if no URIs need to be returned
187
+ * Must return a record mapping component names to their URIs.
199
188
  */
200
- export type ConnectionHandlerResult = Record<string, PulumiOutput<string>> | PulumiOutput<string> | void;
189
+ export type ConnectionHandlerResult = Record<string, PulumiOutput<string>>;
201
190
  /**
202
- * A connection handler entry mapping a ConnectionInterface to its handler function.
191
+ * A connection handler entry mapping a ConnectionInterfaceDef to its handler function.
203
192
  */
204
- export type ConnectionHandlerEntry<S, ConnectionType extends string, C extends ConnectionInterfaceClass> = {
205
- interface: C;
206
- handler: (ctx: ConnectionHandlerCtx<S, InferConnectionData<C>, ConnectionType>) => Promise<ConnectionHandlerResult>;
193
+ export type ConnectionHandlerEntry<S, ConnectionType extends string, D extends ConnectionInterfaceDef> = {
194
+ interface: D;
195
+ handler: (ctx: ConnectionHandlerCtx<S, InferConnectionData<D>, ConnectionType>) => Promise<ConnectionHandlerResult>;
207
196
  };
208
- export declare function connectionHandler<C extends ConnectionInterfaceClass>(entry: {
209
- interface: C;
210
- handler: (ctx: ConnectionHandlerCtx<any, InferConnectionData<C>, any>) => Promise<ConnectionHandlerResult>;
211
- }): {
212
- interface: C;
213
- handler: (ctx: ConnectionHandlerCtx<any, InferConnectionData<C>, any>) => Promise<ConnectionHandlerResult>;
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>;
214
204
  };
205
+ export declare function connectionHandler<D extends ConnectionInterfaceDef>(entry: ConnectionHandlerDef<D>): ConnectionHandlerDef<D>;
215
206
  export type ProviderDeployCtx<D, S> = {
216
207
  state: S;
217
208
  } & Record<string, DeploymentInfo>;
@@ -244,23 +235,24 @@ export type ProviderDeallocateFn<S> = (ctx: ProviderDeallocateCtx<S>) => Promise
244
235
  export type ProviderUpsertArtifactsFn<S> = (ctx: ProviderUpsertArtifactsCtx<S>) => Promise<void>;
245
236
  declare const emptyStateSchema: z.ZodObject<{}, z.core.$strip>;
246
237
  export type EmptyStateShape = typeof emptyStateSchema.shape;
247
- export type ProviderFnsDef<I, D, O, SShape extends z.ZodRawShape = EmptyStateShape, ConnectionType extends string = string> = {
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>> = {
248
240
  stateSchema?: z.ZodObject<SShape>;
249
- initialState?: z.infer<z.ZodObject<SShape>>;
250
- pulumi: ProviderPulumiFn<I, z.infer<z.ZodObject<SShape>>, O>;
251
- connect?: readonly ConnectionHandlerEntry<z.infer<z.ZodObject<SShape>>, ConnectionType, any>[];
252
- deploy?: ProviderDeployFn<D, z.infer<z.ZodObject<SShape>>>;
253
- allocateComponent?: ProviderAllocateFn<z.infer<z.ZodObject<SShape>>>;
254
- deallocateComponent?: ProviderDeallocateFn<z.infer<z.ZodObject<SShape>>>;
255
- upsertArtifacts?: ProviderUpsertArtifactsFn<z.infer<z.ZodObject<SShape>>>;
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>;
256
248
  };
257
249
  /**
258
- * Stored version of ConnectionHandlerEntry that preserves ConnectionInterfaceClass type.
259
- * This ensures `interface` is always typed as ConnectionInterfaceClass (not any)
250
+ * Stored version of ConnectionHandlerEntry that preserves ConnectionInterfaceDef type.
251
+ * This ensures `interface` is always typed as ConnectionInterfaceDef (not any)
260
252
  * when accessing from the registry, allowing runtime schema access.
261
253
  */
262
254
  export type StoredConnectionHandlerEntry = {
263
- interface: ConnectionInterfaceClass;
255
+ interface: ConnectionInterfaceDef;
264
256
  handler: (ctx: ConnectionHandlerCtx<any, any, any>) => Promise<ConnectionHandlerResult>;
265
257
  };
266
258
  export type StoredProviderFns = {
@@ -274,7 +266,14 @@ export type StoredProviderFns = {
274
266
  upsertArtifacts?: ProviderUpsertArtifactsFn<any>;
275
267
  };
276
268
  export type ProviderRegistry = Partial<Record<CloudProvider, StoredProviderFns>>;
277
- export type DeclaredConnectionInterfaces = Map<ConnectionInterfaceClass, any>;
269
+ /**
270
+ * Map of interface name to its schema and declared data.
271
+ * Keyed by canonical interface name for cross-bundle matching.
272
+ */
273
+ export type DeclaredConnectionInterfaces = Map<string, {
274
+ schema: z.ZodObject<z.ZodRawShape>;
275
+ data: any;
276
+ }>;
278
277
  export declare class InfraComponent<CShape extends z.ZodRawShape, DShape extends z.ZodRawShape, OShape extends z.ZodRawShape = EmptyOutputShape, ConnTypes extends Record<string, {
279
278
  description: string;
280
279
  }> = Record<string, {
@@ -286,12 +285,12 @@ export declare class InfraComponent<CShape extends z.ZodRawShape, DShape extends
286
285
  validationDeploymentInputSchema: z.ZodTypeAny;
287
286
  private declaredConnectionInterfaces;
288
287
  constructor(opts: InfraComponentOpts<CShape, DShape, OShape, ConnTypes>);
289
- implement<SShape extends z.ZodRawShape = EmptyStateShape>(provider: CloudProvider, fns: ProviderFnsDef<InfraComponentInputs<InferZodType<CShape>>, InferZodType<DShape>, InferOutputType<OShape>, SShape, keyof ConnTypes & string>): this;
288
+ implement<SShape extends z.ZodRawShape = EmptyStateShape>(provider: CloudProvider, fns: ProviderFnsDef<InferZodType<CShape>, InferZodType<DShape>, InferOutputType<OShape>, SShape, keyof ConnTypes & string>): this;
290
289
  /**
291
290
  * Get the schema for a specific connection interface.
292
291
  * Used by the orchestrator at runtime.
293
292
  */
294
- getConnectionSchema(interfaceClass: ConnectionInterfaceClass): z.ZodObject<z.ZodRawShape> | undefined;
293
+ getConnectionSchema(interfaceDef: ConnectionInterfaceDef): z.ZodObject<z.ZodRawShape>;
295
294
  /**
296
295
  * Create the declareConnectionInterfaces function for use in pulumi context.
297
296
  * The orchestrator calls this before invoking the pulumi function.
package/dist/index.js CHANGED
@@ -1,138 +1 @@
1
- // src/infra.ts
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,J=F(B).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:j.interface.schema,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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdlcworks/components",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "module": "dist/index.js",
5
5
  "files": [
6
6
  "dist"