@sdlcworks/components 0.0.18 → 0.0.20
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 +91 -5
- package/dist/index.js +25 -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
|
*/
|
|
@@ -107,6 +156,12 @@ export type InfraComponentOpts<CShape extends z.ZodRawShape, DShape extends z.Zo
|
|
|
107
156
|
connectionTypes: ConnTypes;
|
|
108
157
|
};
|
|
109
158
|
export type InfraComponentInputs<C> = C;
|
|
159
|
+
export type ArtifactInfo = {
|
|
160
|
+
artifact: {
|
|
161
|
+
uri: string;
|
|
162
|
+
type: DeploymentArtifactType;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
110
165
|
export type DeploymentInfo = {
|
|
111
166
|
config: Record<string, any>;
|
|
112
167
|
artifact: {
|
|
@@ -123,7 +178,7 @@ export type ProviderPulumiCtx<I, S> = {
|
|
|
123
178
|
inputs: I;
|
|
124
179
|
state: S;
|
|
125
180
|
declareConnectionInterfaces: DeclareConnectionInterfacesFn;
|
|
126
|
-
buildArtifacts: Record<string,
|
|
181
|
+
buildArtifacts: Record<string, ArtifactInfo>;
|
|
127
182
|
};
|
|
128
183
|
/**
|
|
129
184
|
* Context passed to connection handlers.
|
|
@@ -137,11 +192,9 @@ export type ConnectionHandlerCtx<S, ConnectorData, ConnectionType extends string
|
|
|
137
192
|
};
|
|
138
193
|
/**
|
|
139
194
|
* Result returned by connection handlers.
|
|
140
|
-
*
|
|
195
|
+
* Maps component names to their URIs, or void if no URIs need to be returned.
|
|
141
196
|
*/
|
|
142
|
-
export type ConnectionHandlerResult =
|
|
143
|
-
uri?: PulumiOutput<string>;
|
|
144
|
-
};
|
|
197
|
+
export type ConnectionHandlerResult = Record<string, PulumiOutput<string>> | void;
|
|
145
198
|
/**
|
|
146
199
|
* A connection handler entry mapping a ConnectionInterface to its handler function.
|
|
147
200
|
*/
|
|
@@ -159,15 +212,44 @@ export declare function connectionHandler<C extends ConnectionInterfaceClass>(en
|
|
|
159
212
|
export type ProviderDeployCtx<D, S> = {
|
|
160
213
|
state: S;
|
|
161
214
|
} & Record<string, DeploymentInfo>;
|
|
215
|
+
export type ProviderAllocateCtx<S> = {
|
|
216
|
+
name: string;
|
|
217
|
+
deploymentConfig: Record<string, any>;
|
|
218
|
+
state: S;
|
|
219
|
+
$: {
|
|
220
|
+
(name: string, ...values: any[]): string;
|
|
221
|
+
(strings: TemplateStringsArray, ...values: any[]): string;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
export type ProviderDeallocateCtx<S> = {
|
|
225
|
+
name: string;
|
|
226
|
+
deploymentConfig: Record<string, any>;
|
|
227
|
+
state: S;
|
|
228
|
+
$: {
|
|
229
|
+
(name: string, ...values: any[]): string;
|
|
230
|
+
(strings: TemplateStringsArray, ...values: any[]): string;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
export type ProviderUpsertArtifactsCtx<S> = {
|
|
234
|
+
buildArtifacts: Record<string, ArtifactInfo>;
|
|
235
|
+
state: S;
|
|
236
|
+
};
|
|
162
237
|
export type ProviderPulumiFn<I, S, O> = (ctx: ProviderPulumiCtx<I, S>) => Promise<O>;
|
|
163
238
|
export type ProviderDeployFn<D, S> = (ctx: ProviderDeployCtx<D, S>) => Promise<void>;
|
|
239
|
+
export type ProviderAllocateFn<S> = (ctx: ProviderAllocateCtx<S>) => Promise<void>;
|
|
240
|
+
export type ProviderDeallocateFn<S> = (ctx: ProviderDeallocateCtx<S>) => Promise<void>;
|
|
241
|
+
export type ProviderUpsertArtifactsFn<S> = (ctx: ProviderUpsertArtifactsCtx<S>) => Promise<void>;
|
|
164
242
|
declare const emptyStateSchema: z.ZodObject<{}, z.core.$strip>;
|
|
165
243
|
export type EmptyStateShape = typeof emptyStateSchema.shape;
|
|
166
244
|
export type ProviderFnsDef<I, D, O, SShape extends z.ZodRawShape = EmptyStateShape, ConnectionType extends string = string> = {
|
|
167
245
|
stateSchema?: z.ZodObject<SShape>;
|
|
246
|
+
initialState?: z.infer<z.ZodObject<SShape>>;
|
|
168
247
|
pulumi: ProviderPulumiFn<I, z.infer<z.ZodObject<SShape>>, O>;
|
|
169
248
|
connect?: readonly ConnectionHandlerEntry<z.infer<z.ZodObject<SShape>>, ConnectionType, any>[];
|
|
170
249
|
deploy?: ProviderDeployFn<D, z.infer<z.ZodObject<SShape>>>;
|
|
250
|
+
allocateComponent?: ProviderAllocateFn<z.infer<z.ZodObject<SShape>>>;
|
|
251
|
+
deallocateComponent?: ProviderDeallocateFn<z.infer<z.ZodObject<SShape>>>;
|
|
252
|
+
upsertArtifacts?: ProviderUpsertArtifactsFn<z.infer<z.ZodObject<SShape>>>;
|
|
171
253
|
};
|
|
172
254
|
/**
|
|
173
255
|
* Stored version of ConnectionHandlerEntry that preserves ConnectionInterfaceClass type.
|
|
@@ -180,9 +262,13 @@ export type StoredConnectionHandlerEntry = {
|
|
|
180
262
|
};
|
|
181
263
|
export type StoredProviderFns = {
|
|
182
264
|
stateSchema: z.ZodObject<any>;
|
|
265
|
+
initialState?: any;
|
|
183
266
|
pulumi: ProviderPulumiFn<any, any, any>;
|
|
184
267
|
connect?: readonly StoredConnectionHandlerEntry[];
|
|
185
268
|
deploy?: ProviderDeployFn<any, any>;
|
|
269
|
+
allocateComponent?: ProviderAllocateFn<any>;
|
|
270
|
+
deallocateComponent?: ProviderDeallocateFn<any>;
|
|
271
|
+
upsertArtifacts?: ProviderUpsertArtifactsFn<any>;
|
|
186
272
|
};
|
|
187
273
|
export type ProviderRegistry = Partial<Record<CloudProvider, StoredProviderFns>>;
|
|
188
274
|
export type DeclaredConnectionInterfaces = Map<ConnectionInterfaceClass, any>;
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,12 @@ var CloudProvider;
|
|
|
10
10
|
CloudProvider2["hetzner"] = "hetzner";
|
|
11
11
|
CloudProvider2["cloudflare"] = "cloudflare";
|
|
12
12
|
})(CloudProvider ||= {});
|
|
13
|
+
var TCPUrlType;
|
|
14
|
+
((TCPUrlType2) => {
|
|
15
|
+
TCPUrlType2["ipv4"] = "ipv4";
|
|
16
|
+
TCPUrlType2["ipv6"] = "ipv6";
|
|
17
|
+
TCPUrlType2["domain"] = "domain";
|
|
18
|
+
})(TCPUrlType ||= {});
|
|
13
19
|
var DeploymentArtifactType;
|
|
14
20
|
((DeploymentArtifactType2) => {
|
|
15
21
|
DeploymentArtifactType2["container_image"] = "container_image";
|
|
@@ -22,6 +28,20 @@ function createConnectionInterface(schema) {
|
|
|
22
28
|
schema = schema;
|
|
23
29
|
};
|
|
24
30
|
}
|
|
31
|
+
function extendConnectionInterface(parentClass, additionalSchema) {
|
|
32
|
+
const parentInstance = new parentClass;
|
|
33
|
+
const mergedSchema = parentInstance.schema.merge(additionalSchema);
|
|
34
|
+
return class extends ConnectionInterface {
|
|
35
|
+
schema = mergedSchema;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var TCPCI = createConnectionInterface(z.object({
|
|
39
|
+
url: z.object({
|
|
40
|
+
type: z.nativeEnum(TCPUrlType),
|
|
41
|
+
value: z.string()
|
|
42
|
+
}),
|
|
43
|
+
publicAccess: z.boolean()
|
|
44
|
+
}));
|
|
25
45
|
var emptyOutputSchema = z.object({});
|
|
26
46
|
function transformSchemaToAcceptOutputs(schema) {
|
|
27
47
|
if (schema instanceof z.ZodObject) {
|
|
@@ -78,7 +98,8 @@ class InfraComponent {
|
|
|
78
98
|
implement(provider, fns) {
|
|
79
99
|
this.providers[provider] = {
|
|
80
100
|
...fns,
|
|
81
|
-
stateSchema: fns.stateSchema ?? emptyStateSchema
|
|
101
|
+
stateSchema: fns.stateSchema ?? emptyStateSchema,
|
|
102
|
+
initialState: fns.initialState
|
|
82
103
|
};
|
|
83
104
|
return this;
|
|
84
105
|
}
|
|
@@ -104,8 +125,11 @@ class InfraComponent {
|
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
127
|
export {
|
|
128
|
+
extendConnectionInterface,
|
|
107
129
|
createConnectionInterface,
|
|
108
130
|
connectionHandler,
|
|
131
|
+
TCPUrlType,
|
|
132
|
+
TCPCI,
|
|
109
133
|
InfraComponent,
|
|
110
134
|
DeploymentArtifactType,
|
|
111
135
|
ConnectionInterface,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdlcworks/components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
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
|
}
|