@sdlcworks/components 0.0.25 → 0.0.27

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
@@ -236,9 +236,20 @@ export type ProviderUpsertArtifactsFn<S> = (ctx: ProviderUpsertArtifactsCtx<S>)
236
236
  declare const emptyStateSchema: z.ZodObject<{}, z.core.$strip>;
237
237
  export type EmptyStateShape = typeof emptyStateSchema.shape;
238
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>> = {
239
+ /**
240
+ * Runtime state type that allows each field to be either a plain value OR a Pulumi Output.
241
+ * This enables storing Pulumi Output references in state for automatic dependency tracking.
242
+ *
243
+ * @example
244
+ * stateSchema: z.object({ jobName: z.string(), location: z.string() })
245
+ * RuntimeState: { jobName: string | Output<string>, location: string | Output<string> }
246
+ */
247
+ export type RuntimeState<SShape extends z.ZodRawShape> = {
248
+ [K in keyof InferredState<SShape>]: InferredState<SShape>[K] | PulumiOutput<InferredState<SShape>[K]>;
249
+ };
250
+ export type ProviderFnsDef<I, D, O, SShape extends z.ZodRawShape = EmptyStateShape, ConnectionType extends string = string, S = RuntimeState<SShape>> = {
240
251
  stateSchema?: z.ZodObject<SShape>;
241
- initialState?: S;
252
+ initialState?: Partial<S>;
242
253
  pulumi: ProviderPulumiFn<I, S, O>;
243
254
  connect?: readonly ConnectionHandlerEntry<S, ConnectionType, any>[];
244
255
  deploy?: ProviderDeployFn<D, S>;
package/dist/index.js CHANGED
@@ -1,150 +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.ZodArray) {
73
- return z.array(transformSchemaToAcceptOutputs(schema.element));
74
- }
75
- return z.union([
76
- schema,
77
- z.custom((val) => pulumi.Output.isInstance(val))
78
- ]);
79
- }
80
- var InfraComponentOptsSchema = z.object({
81
- metadata: z.object({
82
- stateful: z.boolean(),
83
- proxiable: z.boolean()
84
- }),
85
- connectionTypes: z.record(z.string(), z.object({
86
- description: z.string().min(5)
87
- })),
88
- configSchema: z.custom(),
89
- deploymentInputSchema: z.custom(),
90
- outputSchema: z.custom()
91
- });
92
- function connectionHandler(entry) {
93
- return entry;
94
- }
95
- var emptyStateSchema = z.object({});
96
-
97
- class InfraComponent {
98
- opts;
99
- providers;
100
- validationSchema;
101
- validationDeploymentInputSchema;
102
- declaredConnectionInterfaces = new Map;
103
- constructor(opts) {
104
- this.opts = InfraComponentOptsSchema.parse(opts);
105
- this.providers = {};
106
- this.validationSchema = transformSchemaToAcceptOutputs(opts.configSchema);
107
- this.validationDeploymentInputSchema = transformSchemaToAcceptOutputs(opts.deploymentInputSchema);
108
- }
109
- implement(provider, fns) {
110
- this.providers[provider] = {
111
- ...fns,
112
- stateSchema: fns.stateSchema ?? emptyStateSchema,
113
- initialState: fns.initialState
114
- };
115
- return this;
116
- }
117
- getConnectionSchema(interfaceDef) {
118
- return interfaceDef.schema;
119
- }
120
- createDeclareConnectionInterfacesFn() {
121
- return (entries) => {
122
- for (const entry of entries) {
123
- const schema = entry.interface.schema;
124
- const transformedSchema = transformSchemaToAcceptOutputs(schema);
125
- const parseResult = transformedSchema.safeParse(entry.data);
126
- if (!parseResult.success) {
127
- throw new Error(`Invalid data for connection interface '${entry.interface.name}': ${parseResult.error.message}`);
128
- }
129
- this.declaredConnectionInterfaces.set(entry.interface.name, {
130
- schema: transformedSchema,
131
- data: entry.data
132
- });
133
- }
134
- };
135
- }
136
- getDeclaredInterfaces() {
137
- return this.declaredConnectionInterfaces;
138
- }
139
- }
140
- export {
141
- toCanonicalInterfaceName,
142
- extendSchema,
143
- defineConnectionInterface,
144
- connectionHandler,
145
- TCPUrlType,
146
- TCPCI,
147
- InfraComponent,
148
- DeploymentArtifactType,
149
- CloudProvider
150
- };
1
+ import{z as j}from"zod";import*as M from"@pulumi/pulumi";var W;((H)=>{H.aws="aws";H.gcloud="gcloud";H.azure="azure";H.linode="linode";H.hetzner="hetzner";H.cloudflare="cloudflare"})(W||={});var Q;((E)=>{E.ipv4="ipv4";E.ipv6="ipv6";E.domain="domain"})(Q||={});var X;((q)=>q.container_image="container_image")(X||={});var L=new Map;function Y(b){return b.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase().replace(/-+/g,"-").replace(/^-|-$/g,"")}function Z(b){let q=Y(b);if(q.length===0)throw new Error("Connection interface name cannot be empty");let B=L.get(q);if(B!==void 0&&B!==b)throw new Error(`Connection interface name collision: '${b}' resolves to '${q}' which is already registered by '${B}'`);return L.set(q,b),q}function _(b,q){return{name:Z(b),schema:q}}function x(b,q){return b.schema.merge(q)}var N=_("tcp",j.object({url:j.object({type:j.nativeEnum(Q),value:j.string()}),publicAccess:j.boolean()})),w=j.object({});function F(b){if(b instanceof j.ZodObject){let q=b.shape,B={};for(let E in q)B[E]=F(q[E]);return j.object(B)}if(b instanceof j.ZodOptional)return F(b.unwrap()).optional();if(b instanceof j.ZodNullable)return F(b.unwrap()).nullable();if(b instanceof j.ZodDefault)return F(b._def.innerType).default(b._def.defaultValue);if(b instanceof j.ZodArray)return j.array(F(b.element));if(b instanceof j.ZodDiscriminatedUnion){let q=b._def.options.map((B)=>F(B));return j.discriminatedUnion(b._def.discriminator,q)}if(b instanceof j.ZodRecord){let q=b._def.keyType,B=b._def.valueType,E=q?F(q):j.string(),J=B?F(B):j.any();return j.record(E,J)}return j.union([b,j.custom((q)=>M.Output.isInstance(q))])}var $=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 k(b){return b}var G=j.object({});class K{opts;providers;validationSchema;validationDeploymentInputSchema;declaredConnectionInterfaces=new Map;constructor(b){this.opts=$.parse(b),this.providers={},this.validationSchema=F(b.configSchema),this.validationDeploymentInputSchema=F(b.deploymentInputSchema)}implement(b,q){return this.providers[b]={...q,stateSchema:q.stateSchema??G,initialState:q.initialState},this}getConnectionSchema(b){return b.schema}createDeclareConnectionInterfacesFn(){return(b)=>{for(let q of b){let B=q.interface.schema,E=F(B),J=E.safeParse(q.data);if(!J.success)throw new Error(`Invalid data for connection interface '${q.interface.name}': ${J.error.message}`);this.declaredConnectionInterfaces.set(q.interface.name,{schema:E,data:q.data})}}}getDeclaredInterfaces(){return this.declaredConnectionInterfaces}}export{Y as toCanonicalInterfaceName,x as extendSchema,_ as defineConnectionInterface,k as connectionHandler,Q as TCPUrlType,N as TCPCI,K as InfraComponent,X as DeploymentArtifactType,W as CloudProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdlcworks/components",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "module": "dist/index.js",
5
5
  "files": [
6
6
  "dist"