@sdlcworks/components 0.0.18 → 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 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
  */
package/dist/index.js CHANGED
@@ -1,113 +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 DeploymentArtifactType;
14
- ((DeploymentArtifactType2) => {
15
- DeploymentArtifactType2["container_image"] = "container_image";
16
- })(DeploymentArtifactType ||= {});
17
-
18
- class ConnectionInterface {
19
- }
20
- function createConnectionInterface(schema) {
21
- return class extends ConnectionInterface {
22
- schema = schema;
23
- };
24
- }
25
- var emptyOutputSchema = z.object({});
26
- function transformSchemaToAcceptOutputs(schema) {
27
- if (schema instanceof z.ZodObject) {
28
- const shape = schema.shape;
29
- const newShape = {};
30
- for (const key in shape) {
31
- newShape[key] = transformSchemaToAcceptOutputs(shape[key]);
32
- }
33
- return z.object(newShape);
34
- }
35
- if (schema instanceof z.ZodOptional) {
36
- return transformSchemaToAcceptOutputs(schema.unwrap()).optional();
37
- }
38
- if (schema instanceof z.ZodNullable) {
39
- return transformSchemaToAcceptOutputs(schema.unwrap()).nullable();
40
- }
41
- if (schema instanceof z.ZodArray) {
42
- return z.array(transformSchemaToAcceptOutputs(schema.element));
43
- }
44
- return z.union([
45
- schema,
46
- z.custom((val) => pulumi.Output.isInstance(val))
47
- ]);
48
- }
49
- var InfraComponentOptsSchema = z.object({
50
- metadata: z.object({
51
- stateful: z.boolean(),
52
- proxiable: z.boolean()
53
- }),
54
- connectionTypes: z.record(z.string(), z.object({
55
- description: z.string().min(5)
56
- })),
57
- configSchema: z.custom(),
58
- deploymentInputSchema: z.custom(),
59
- outputSchema: z.custom()
60
- });
61
- function connectionHandler(entry) {
62
- return entry;
63
- }
64
- var emptyStateSchema = z.object({});
65
-
66
- class InfraComponent {
67
- opts;
68
- providers;
69
- validationSchema;
70
- validationDeploymentInputSchema;
71
- declaredConnectionInterfaces = new Map;
72
- constructor(opts) {
73
- this.opts = InfraComponentOptsSchema.parse(opts);
74
- this.providers = {};
75
- this.validationSchema = transformSchemaToAcceptOutputs(opts.configSchema);
76
- this.validationDeploymentInputSchema = transformSchemaToAcceptOutputs(opts.deploymentInputSchema);
77
- }
78
- implement(provider, fns) {
79
- this.providers[provider] = {
80
- ...fns,
81
- stateSchema: fns.stateSchema ?? emptyStateSchema
82
- };
83
- return this;
84
- }
85
- getConnectionSchema(interfaceClass) {
86
- const instance = new interfaceClass;
87
- return instance.schema;
88
- }
89
- createDeclareConnectionInterfacesFn() {
90
- return (entries) => {
91
- for (const entry of entries) {
92
- const instance = new entry.interface;
93
- const schema = instance.schema;
94
- const parseResult = schema.safeParse(entry.data);
95
- if (!parseResult.success) {
96
- throw new Error(`Invalid data for connection interface ${entry.interface.name}: ${parseResult.error.message}`);
97
- }
98
- this.declaredConnectionInterfaces.set(entry.interface, entry.data);
99
- }
100
- };
101
- }
102
- getDeclaredInterfaces() {
103
- return this.declaredConnectionInterfaces;
104
- }
105
- }
106
- export {
107
- createConnectionInterface,
108
- connectionHandler,
109
- InfraComponent,
110
- DeploymentArtifactType,
111
- ConnectionInterface,
112
- CloudProvider
113
- };
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.18",
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": "^4.1.13"
34
+ "zod": "4.1.13"
35
35
  }
36
36
  }