@sdlcworks/components 0.0.17 → 0.0.19
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 +57 -18
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare enum CloudProvider {
|
|
|
11
11
|
hetzner = "hetzner",
|
|
12
12
|
cloudflare = "cloudflare"
|
|
13
13
|
}
|
|
14
|
+
export declare enum TCPUrlType {
|
|
15
|
+
ipv4 = "ipv4",
|
|
16
|
+
ipv6 = "ipv6",
|
|
17
|
+
domain = "domain"
|
|
18
|
+
}
|
|
14
19
|
export declare enum DeploymentArtifactType {
|
|
15
20
|
container_image = "container_image"
|
|
16
21
|
}
|
|
@@ -36,6 +41,50 @@ export declare function createConnectionInterface<TSchema extends z.ZodObject<z.
|
|
|
36
41
|
readonly schema: TSchema;
|
|
37
42
|
};
|
|
38
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Extends a ConnectionInterface class with additional schema fields.
|
|
46
|
+
* The resulting class merges the parent and child schemas.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const BaseCI = createConnectionInterface(
|
|
50
|
+
* z.object({ foo: z.string() })
|
|
51
|
+
* );
|
|
52
|
+
* const ExtendedCI = extendConnectionInterface(
|
|
53
|
+
* BaseCI,
|
|
54
|
+
* z.object({ bar: z.number() })
|
|
55
|
+
* );
|
|
56
|
+
* // ExtendedCI schema: { foo: string, bar: number }
|
|
57
|
+
*/
|
|
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
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* TCP Connection Interface - defines a TCP-based connection endpoint.
|
|
75
|
+
* Use this for components that expose TCP services.
|
|
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
|
+
};
|
|
39
88
|
/**
|
|
40
89
|
* Type alias for ConnectionInterface class constructors.
|
|
41
90
|
*/
|
|
@@ -149,23 +198,13 @@ export type ConnectionHandlerEntry<S, ConnectionType extends string, C extends C
|
|
|
149
198
|
interface: C;
|
|
150
199
|
handler: (ctx: ConnectionHandlerCtx<S, InferConnectionData<C>, ConnectionType>) => Promise<ConnectionHandlerResult>;
|
|
151
200
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
* interface: ServiceAccountCI,
|
|
160
|
-
* handler: async (ctx) => {
|
|
161
|
-
* // ctx.connectionData is now properly typed from ServiceAccountCI schema
|
|
162
|
-
* ctx.connectionData.email // string
|
|
163
|
-
* return {};
|
|
164
|
-
* },
|
|
165
|
-
* }),
|
|
166
|
-
* ] as const,
|
|
167
|
-
*/
|
|
168
|
-
export declare function connectionHandler<S, ConnectionType extends string, C extends ConnectionInterfaceClass>(entry: ConnectionHandlerEntry<S, ConnectionType, C>): ConnectionHandlerEntry<S, ConnectionType, C>;
|
|
201
|
+
export declare function connectionHandler<C extends ConnectionInterfaceClass>(entry: {
|
|
202
|
+
interface: C;
|
|
203
|
+
handler: (ctx: ConnectionHandlerCtx<any, InferConnectionData<C>, any>) => Promise<ConnectionHandlerResult>;
|
|
204
|
+
}): {
|
|
205
|
+
interface: C;
|
|
206
|
+
handler: (ctx: ConnectionHandlerCtx<any, InferConnectionData<C>, any>) => Promise<ConnectionHandlerResult>;
|
|
207
|
+
};
|
|
169
208
|
export type ProviderDeployCtx<D, S> = {
|
|
170
209
|
state: S;
|
|
171
210
|
} & Record<string, DeploymentInfo>;
|
|
@@ -176,7 +215,7 @@ export type EmptyStateShape = typeof emptyStateSchema.shape;
|
|
|
176
215
|
export type ProviderFnsDef<I, D, O, SShape extends z.ZodRawShape = EmptyStateShape, ConnectionType extends string = string> = {
|
|
177
216
|
stateSchema?: z.ZodObject<SShape>;
|
|
178
217
|
pulumi: ProviderPulumiFn<I, z.infer<z.ZodObject<SShape>>, O>;
|
|
179
|
-
connect?: readonly ConnectionHandlerEntry<z.infer<z.ZodObject<SShape>>, ConnectionType,
|
|
218
|
+
connect?: readonly ConnectionHandlerEntry<z.infer<z.ZodObject<SShape>>, ConnectionType, any>[];
|
|
180
219
|
deploy?: ProviderDeployFn<D, z.infer<z.ZodObject<SShape>>>;
|
|
181
220
|
};
|
|
182
221
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as
|
|
1
|
+
import{z as x}from"zod";import*as K from"@pulumi/pulumi";var M;((B)=>{B.aws="aws";B.gcloud="gcloud";B.azure="azure";B.linode="linode";B.hetzner="hetzner";B.cloudflare="cloudflare"})(M||={});var L;((q)=>{q.ipv4="ipv4";q.ipv6="ipv6";q.domain="domain"})(L||={});var N;((j)=>j.container_image="container_image")(N||={});class H{}function Q(b){return class extends H{schema=b}}function Z(b,j){let q=new b().schema.merge(j);return class extends H{schema=q}}var _=Q(x.object({url:x.object({type:x.nativeEnum(L),value:x.string()}),publicAccess:x.boolean()})),$=x.object({});function E(b){if(b instanceof x.ZodObject){let j=b.shape,F={};for(let q in j)F[q]=E(j[q]);return x.object(F)}if(b instanceof x.ZodOptional)return E(b.unwrap()).optional();if(b instanceof x.ZodNullable)return E(b.unwrap()).nullable();if(b instanceof x.ZodArray)return x.array(E(b.element));return x.union([b,x.custom((j)=>K.Output.isInstance(j))])}var V=x.object({metadata:x.object({stateful:x.boolean(),proxiable:x.boolean()}),connectionTypes:x.record(x.string(),x.object({description:x.string().min(5)})),configSchema:x.custom(),deploymentInputSchema:x.custom(),outputSchema:x.custom()});function g(b){return b}var W=x.object({});class X{opts;providers;validationSchema;validationDeploymentInputSchema;declaredConnectionInterfaces=new Map;constructor(b){this.opts=V.parse(b),this.providers={},this.validationSchema=E(b.configSchema),this.validationDeploymentInputSchema=E(b.deploymentInputSchema)}implement(b,j){return this.providers[b]={...j,stateSchema:j.stateSchema??W},this}getConnectionSchema(b){return new b().schema}createDeclareConnectionInterfacesFn(){return(b)=>{for(let j of b){let J=new j.interface().schema.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,j.data)}}}getDeclaredInterfaces(){return this.declaredConnectionInterfaces}}export{Z as extendConnectionInterface,Q as createConnectionInterface,g as connectionHandler,L as TCPUrlType,_ as TCPCI,X as InfraComponent,N as DeploymentArtifactType,H as ConnectionInterface,M as CloudProvider};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdlcworks/components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"module": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"typescript": "^5.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"zod": "
|
|
34
|
+
"zod": "4.1.13"
|
|
35
35
|
}
|
|
36
36
|
}
|