@sdlcworks/components 0.0.25 → 0.0.26
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 +13 -2
- package/dist/index.js +1 -150
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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 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,E=F(B),J=E.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:E,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};
|