@sdlcworks/components 0.0.28 → 0.0.29

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
@@ -3,25 +3,14 @@
3
3
  import { Input as PulumiInput, Output as PulumiOutput } from '@pulumi/pulumi';
4
4
  import { z } from 'zod';
5
5
 
6
- declare const BranchMetadataCloudCredentialGCPSchema = z.object({
7
- GCP_PROJECT_ID: z.string().describe("Required GCP Project ID"),
8
- GCP_SERVICE_ACCOUNT_KEY: z.string()
9
- .describe("Required GCP Service Account Key"),
10
- });
11
- export type BranchMetadataCloudCredentialGCP = z.infer<typeof BranchMetadataCloudCredentialGCPSchema>;
12
- declare const BranchMetadataCloudCredentialAWSSchema = z.object({
13
- AWS_ACCESS_KEY_ID: z.string().describe("Required AWS Access Key ID"),
14
- AWS_SECRET_ACCESS_KEY: z.string().describe("Required AWS Secret Access Key"),
15
- AWS_REGION: z.string().describe("Required AWS Region"),
16
- });
17
- export type BranchMetadataCloudCredentialAWS = z.infer<typeof BranchMetadataCloudCredentialAWSSchema>;
18
- declare const BranchMetadataCloudCredentialCloudflareSchema = z.object({
19
- CLOUDFLARE_API_TOKEN: z.string().describe("Required Cloudflare API Token"),
20
- CLOUDFLARE_ACCOUNT_ID: z.string()
21
- .optional()
22
- .describe("Optional Cloudflare Account ID (required for account-scoped resources like Workers, R2, Pages)"),
23
- });
24
- export type BranchMetadataCloudCredentialCloudflare = z.infer<typeof BranchMetadataCloudCredentialCloudflareSchema>;
6
+ /**
7
+ * Types copied from @sdlc/types for use in the published @sdlcworks/components package.
8
+ * These are duplicated here to avoid requiring users to install @sdlc/types
9
+ * (which is an internal monorepo package not published to npm).
10
+ *
11
+ * ⚠️ SYNC REQUIRED: When modifying these types, also update @sdlc/types/src/index.ts
12
+ * and vice versa. These files must be kept in sync manually.
13
+ */
25
14
  export declare enum CloudProvider {
26
15
  aws = "aws",
27
16
  gcloud = "gcloud",
@@ -30,6 +19,31 @@ export declare enum CloudProvider {
30
19
  hetzner = "hetzner",
31
20
  cloudflare = "cloudflare"
32
21
  }
22
+ export declare enum DeploymentArtifactType {
23
+ container_image = "container_image"
24
+ }
25
+ /**
26
+ * GCP credential fields required for authentication.
27
+ */
28
+ export type BranchMetadataCloudCredentialGCP = {
29
+ GCP_PROJECT_ID: string;
30
+ GCP_SERVICE_ACCOUNT_KEY: string;
31
+ };
32
+ /**
33
+ * AWS credential fields required for authentication.
34
+ */
35
+ export type BranchMetadataCloudCredentialAWS = {
36
+ AWS_ACCESS_KEY_ID: string;
37
+ AWS_SECRET_ACCESS_KEY: string;
38
+ AWS_REGION: string;
39
+ };
40
+ /**
41
+ * Cloudflare credential fields required for authentication.
42
+ */
43
+ export type BranchMetadataCloudCredentialCloudflare = {
44
+ CLOUDFLARE_API_TOKEN: string;
45
+ CLOUDFLARE_ACCOUNT_ID?: string;
46
+ };
33
47
  /**
34
48
  * Maps each CloudProvider to its corresponding credential type.
35
49
  * Used to provide fully-typed credentials in handler contexts.
@@ -52,9 +66,6 @@ export declare enum TCPUrlType {
52
66
  ipv6 = "ipv6",
53
67
  domain = "domain"
54
68
  }
55
- export declare enum DeploymentArtifactType {
56
- container_image = "container_image"
57
- }
58
69
  /**
59
70
  * Transforms any interface name to canonical hyphen-separated lowercase form.
60
71
  *
package/dist/index.js CHANGED
@@ -1,164 +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
- var connectionInterfaceRegistry = new Map;
24
- function toCanonicalInterfaceName(name) {
25
- return name.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase().replace(/-+/g, "-").replace(/^-|-$/g, "");
26
- }
27
- function registerInterfaceName(name) {
28
- const canonical = toCanonicalInterfaceName(name);
29
- if (canonical.length === 0) {
30
- throw new Error(`Connection interface name cannot be empty`);
31
- }
32
- const existing = connectionInterfaceRegistry.get(canonical);
33
- if (existing !== undefined && existing !== name) {
34
- throw new Error(`Connection interface name collision: '${name}' resolves to '${canonical}' which is already registered by '${existing}'`);
35
- }
36
- connectionInterfaceRegistry.set(canonical, name);
37
- return canonical;
38
- }
39
- function defineConnectionInterface(name, schema) {
40
- const canonicalName = registerInterfaceName(name);
41
- return {
42
- name: canonicalName,
43
- schema
44
- };
45
- }
46
- function extendSchema(parentDef, additionalSchema) {
47
- return parentDef.schema.merge(additionalSchema);
48
- }
49
- var TCPCI = defineConnectionInterface("tcp", z.object({
50
- url: z.object({
51
- type: z.nativeEnum(TCPUrlType),
52
- value: z.string()
53
- }),
54
- publicAccess: z.boolean()
55
- }));
56
- var emptyOutputSchema = z.object({});
57
- function transformSchemaToAcceptOutputs(schema) {
58
- if (schema instanceof z.ZodObject) {
59
- const shape = schema.shape;
60
- const newShape = {};
61
- for (const key in shape) {
62
- newShape[key] = transformSchemaToAcceptOutputs(shape[key]);
63
- }
64
- return z.object(newShape);
65
- }
66
- if (schema instanceof z.ZodOptional) {
67
- return transformSchemaToAcceptOutputs(schema.unwrap()).optional();
68
- }
69
- if (schema instanceof z.ZodNullable) {
70
- return transformSchemaToAcceptOutputs(schema.unwrap()).nullable();
71
- }
72
- if (schema instanceof z.ZodDefault) {
73
- return transformSchemaToAcceptOutputs(schema._def.innerType).default(schema._def.defaultValue);
74
- }
75
- if (schema instanceof z.ZodArray) {
76
- return z.array(transformSchemaToAcceptOutputs(schema.element));
77
- }
78
- if (schema instanceof z.ZodDiscriminatedUnion) {
79
- const transformedOptions = schema._def.options.map((option) => transformSchemaToAcceptOutputs(option));
80
- return z.discriminatedUnion(schema._def.discriminator, transformedOptions);
81
- }
82
- if (schema instanceof z.ZodRecord) {
83
- const keyType = schema._def.keyType;
84
- const valueType = schema._def.valueType;
85
- const transformedKey = keyType ? transformSchemaToAcceptOutputs(keyType) : z.string();
86
- const transformedValue = valueType ? transformSchemaToAcceptOutputs(valueType) : z.any();
87
- return z.record(transformedKey, transformedValue);
88
- }
89
- return z.union([
90
- schema,
91
- z.custom((val) => pulumi.Output.isInstance(val))
92
- ]);
93
- }
94
- var InfraComponentOptsSchema = z.object({
95
- metadata: z.object({
96
- stateful: z.boolean(),
97
- proxiable: z.boolean()
98
- }),
99
- connectionTypes: z.record(z.string(), z.object({
100
- description: z.string().min(5)
101
- })),
102
- configSchema: z.custom(),
103
- deploymentInputSchema: z.custom(),
104
- outputSchema: z.custom()
105
- });
106
- function connectionHandler(entry) {
107
- return entry;
108
- }
109
- var emptyStateSchema = z.object({});
110
-
111
- class InfraComponent {
112
- opts;
113
- providers;
114
- validationSchema;
115
- validationDeploymentInputSchema;
116
- declaredConnectionInterfaces = new Map;
117
- constructor(opts) {
118
- this.opts = InfraComponentOptsSchema.parse(opts);
119
- this.providers = {};
120
- this.validationSchema = transformSchemaToAcceptOutputs(opts.configSchema);
121
- this.validationDeploymentInputSchema = transformSchemaToAcceptOutputs(opts.deploymentInputSchema);
122
- }
123
- implement(provider, fns) {
124
- this.providers[provider] = {
125
- ...fns,
126
- stateSchema: fns.stateSchema ?? emptyStateSchema,
127
- initialState: fns.initialState
128
- };
129
- return this;
130
- }
131
- getConnectionSchema(interfaceDef) {
132
- return interfaceDef.schema;
133
- }
134
- createDeclareConnectionInterfacesFn() {
135
- return (entries) => {
136
- for (const entry of entries) {
137
- const schema = entry.interface.schema;
138
- const transformedSchema = transformSchemaToAcceptOutputs(schema);
139
- const parseResult = transformedSchema.safeParse(entry.data);
140
- if (!parseResult.success) {
141
- throw new Error(`Invalid data for connection interface '${entry.interface.name}': ${parseResult.error.message}`);
142
- }
143
- this.declaredConnectionInterfaces.set(entry.interface.name, {
144
- schema: transformedSchema,
145
- data: entry.data
146
- });
147
- }
148
- };
149
- }
150
- getDeclaredInterfaces() {
151
- return this.declaredConnectionInterfaces;
152
- }
153
- }
154
- export {
155
- toCanonicalInterfaceName,
156
- extendSchema,
157
- defineConnectionInterface,
158
- connectionHandler,
159
- TCPUrlType,
160
- TCPCI,
161
- InfraComponent,
162
- DeploymentArtifactType,
163
- CloudProvider
164
- };
1
+ import{z as j}from"zod";import*as Y from"@pulumi/pulumi";var Q;((L)=>{L.aws="aws";L.gcloud="gcloud";L.azure="azure";L.linode="linode";L.hetzner="hetzner";L.cloudflare="cloudflare"})(Q||={});var W;((B)=>B.container_image="container_image")(W||={});var Z;((H)=>{H.ipv4="ipv4";H.ipv6="ipv6";H.domain="domain"})(Z||={});var X=new Map;function _(b){return b.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase().replace(/-+/g,"-").replace(/^-|-$/g,"")}function $(b){let B=_(b);if(B.length===0)throw new Error("Connection interface name cannot be empty");let F=X.get(B);if(F!==void 0&&F!==b)throw new Error(`Connection interface name collision: '${b}' resolves to '${B}' which is already registered by '${F}'`);return X.set(B,b),B}function q(b,B){return{name:$(b),schema:B}}function w(b,B){return b.schema.merge(B)}var x=q("tcp",j.object({url:j.object({type:j.nativeEnum(Z),value:j.string()}),publicAccess:j.boolean()})),R=j.object({});function J(b){if(b instanceof j.ZodObject){let B=b.shape,F={};for(let H in B)F[H]=J(B[H]);return j.object(F)}if(b instanceof j.ZodOptional)return J(b.unwrap()).optional();if(b instanceof j.ZodNullable)return J(b.unwrap()).nullable();if(b instanceof j.ZodDefault)return J(b._def.innerType).default(b._def.defaultValue);if(b instanceof j.ZodArray)return j.array(J(b.element));if(b instanceof j.ZodDiscriminatedUnion){let B=b._def.options.map((F)=>J(F));return j.discriminatedUnion(b._def.discriminator,B)}if(b instanceof j.ZodRecord){let B=b._def.keyType,F=b._def.valueType,H=B?J(B):j.string(),M=F?J(F):j.any();return j.record(H,M)}return j.union([b,j.custom((B)=>Y.Output.isInstance(B))])}var E=j.object({metadata:j.object({stateful:j.boolean(),proxiable:j.boolean()}),connectionTypes:j.record(j.string(),j.object({description:j.string().min(5)})),configSchema:j.custom(),deploymentInputSchema:j.custom(),outputSchema:j.custom()});function U(b){return b}var G=j.object({});class K{opts;providers;validationSchema;validationDeploymentInputSchema;declaredConnectionInterfaces=new Map;constructor(b){this.opts=E.parse(b),this.providers={},this.validationSchema=J(b.configSchema),this.validationDeploymentInputSchema=J(b.deploymentInputSchema)}implement(b,B){return this.providers[b]={...B,stateSchema:B.stateSchema??G,initialState:B.initialState},this}getConnectionSchema(b){return b.schema}createDeclareConnectionInterfacesFn(){return(b)=>{for(let B of b){let F=B.interface.schema,H=J(F),M=H.safeParse(B.data);if(!M.success)throw new Error(`Invalid data for connection interface '${B.interface.name}': ${M.error.message}`);this.declaredConnectionInterfaces.set(B.interface.name,{schema:H,data:B.data})}}}getDeclaredInterfaces(){return this.declaredConnectionInterfaces}}export{_ as toCanonicalInterfaceName,w as extendSchema,q as defineConnectionInterface,U as connectionHandler,Z as TCPUrlType,x as TCPCI,K as InfraComponent,W as DeploymentArtifactType,Q as CloudProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdlcworks/components",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "module": "dist/index.js",
5
5
  "files": [
6
6
  "dist"
@@ -31,7 +31,6 @@
31
31
  "typescript": "^5.0.0"
32
32
  },
33
33
  "dependencies": {
34
- "@sdlc/types": "workspace:*",
35
34
  "zod": "4.1.13"
36
35
  }
37
36
  }