@sdlcworks/components 0.0.38 → 0.0.39
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 +40 -16
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export declare function toCanonicalInterfaceName(name: string): string;
|
|
|
88
88
|
* @param TSchema - Input schema (data from connecting component)
|
|
89
89
|
* @param TResultSchema - Optional result metadata schema for typed handler results
|
|
90
90
|
*/
|
|
91
|
-
export type ConnectionInterfaceDef<TName extends string = string, TSchema extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TResultSchema extends z.ZodObject<z.ZodRawShape> | undefined = undefined> = {
|
|
91
|
+
export type ConnectionInterfaceDef<TName extends string = string, TSchema extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TResultSchema extends z.ZodObject<z.ZodRawShape> | undefined = z.ZodObject<z.ZodRawShape> | undefined> = {
|
|
92
92
|
readonly name: TName;
|
|
93
93
|
readonly schema: TSchema;
|
|
94
94
|
readonly resultSchema?: TResultSchema;
|
|
@@ -131,11 +131,6 @@ export declare function extendSchema<TParentSchema extends z.ZodObject<z.ZodRawS
|
|
|
131
131
|
} : never)) extends infer T ? {
|
|
132
132
|
[k in keyof T]: T[k];
|
|
133
133
|
} : never, TChildSchema["_zod"]["config"]>;
|
|
134
|
-
/**
|
|
135
|
-
* Public HTTP Connection Interface - defines a public HTTP endpoint.
|
|
136
|
-
* No metadata, only URI is provided.
|
|
137
|
-
*/
|
|
138
|
-
export declare const PublicHTTPCI: ConnectionInterfaceDef<"public-http", z.ZodObject<{}, z.core.$strip>, undefined>;
|
|
139
134
|
/**
|
|
140
135
|
* Connection type used by the orchestrator when performing anonymous URI discovery
|
|
141
136
|
* for URL register component collection. Infra component connect handlers that expose
|
|
@@ -172,7 +167,7 @@ export type DeclaredConnectionInterfaceEntry<D extends ConnectionInterfaceDef =
|
|
|
172
167
|
* Function type for declareConnectionInterfaces.
|
|
173
168
|
* Called within pulumi function to declare exposed connection interfaces.
|
|
174
169
|
*/
|
|
175
|
-
export type DeclareConnectionInterfacesFn =
|
|
170
|
+
export type DeclareConnectionInterfacesFn = (entries: DeclaredConnectionInterfaceEntry<ConnectionInterfaceDef>[]) => void;
|
|
176
171
|
export type InferredZodObject<S extends z.ZodRawShape> = z.infer<z.ZodObject<S>>;
|
|
177
172
|
export type InferZodType<S extends z.ZodRawShape> = {
|
|
178
173
|
[K in keyof InferredZodObject<S>]: PulumiInput<InferredZodObject<S>[K]>;
|
|
@@ -182,6 +177,26 @@ export type InferOutputType<OShape extends z.ZodRawShape> = {
|
|
|
182
177
|
};
|
|
183
178
|
declare const emptyOutputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
184
179
|
export type EmptyOutputShape = typeof emptyOutputSchema.shape;
|
|
180
|
+
/**
|
|
181
|
+
* The default app component type name.
|
|
182
|
+
* Used when an infra component has a single, uniform deployment input config
|
|
183
|
+
* for all app components deployed on it.
|
|
184
|
+
*/
|
|
185
|
+
export declare const DEFAULT_APP_COMPONENT_TYPE: "default";
|
|
186
|
+
/**
|
|
187
|
+
* Helper to create an appComponentTypes map with a single "default" entry.
|
|
188
|
+
* Use this when the infra component does not distinguish between app component types.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* new InfraComponent({
|
|
192
|
+
* ...
|
|
193
|
+
* appComponentTypes: defaultAppComponentType(z.object({ image: z.string() })),
|
|
194
|
+
* })
|
|
195
|
+
* // Equivalent to: appComponentTypes: { default: z.object({ image: z.string() }) }
|
|
196
|
+
*/
|
|
197
|
+
export declare function defaultAppComponentType<S extends z.ZodTypeAny>(schema: S): {
|
|
198
|
+
default: S;
|
|
199
|
+
};
|
|
185
200
|
declare const InfraComponentOptsSchema: z.ZodObject<{
|
|
186
201
|
metadata: z.ZodObject<{
|
|
187
202
|
stateful: z.ZodBoolean;
|
|
@@ -196,7 +211,7 @@ declare const InfraComponentOptsSchema: z.ZodObject<{
|
|
|
196
211
|
}>, z.core.$strip>, z.ZodObject<Readonly<{
|
|
197
212
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
198
213
|
}>, z.core.$strip>>;
|
|
199
|
-
|
|
214
|
+
appComponentTypes: z.ZodRecord<z.ZodString, z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
200
215
|
outputSchema: z.ZodCustom<z.ZodObject<Readonly<{
|
|
201
216
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
202
217
|
}>, z.core.$strip>, z.ZodObject<Readonly<{
|
|
@@ -204,13 +219,13 @@ declare const InfraComponentOptsSchema: z.ZodObject<{
|
|
|
204
219
|
}>, z.core.$strip>>;
|
|
205
220
|
}, z.core.$strip>;
|
|
206
221
|
export type InfraComponentOptsBase = z.infer<typeof InfraComponentOptsSchema>;
|
|
207
|
-
export type InfraComponentOpts<CShape extends z.ZodRawShape,
|
|
222
|
+
export type InfraComponentOpts<CShape extends z.ZodRawShape, ACTypes extends Record<string, z.ZodTypeAny>, OShape extends z.ZodRawShape, ConnTypes extends Record<string, {
|
|
208
223
|
description: string;
|
|
209
224
|
}> = Record<string, {
|
|
210
225
|
description: string;
|
|
211
|
-
}>> = Omit<InfraComponentOptsBase, "configSchema" | "
|
|
226
|
+
}>> = Omit<InfraComponentOptsBase, "configSchema" | "appComponentTypes" | "outputSchema" | "connectionTypes"> & {
|
|
212
227
|
configSchema: z.ZodObject<CShape>;
|
|
213
|
-
|
|
228
|
+
appComponentTypes: ACTypes;
|
|
214
229
|
outputSchema: z.ZodObject<OShape>;
|
|
215
230
|
connectionTypes: ConnTypes;
|
|
216
231
|
/**
|
|
@@ -380,6 +395,7 @@ export type ProviderDeployCtx<D, S, P extends CloudProvider = CloudProvider> = {
|
|
|
380
395
|
} & Record<string, DeploymentInfo>;
|
|
381
396
|
export type ProviderAllocateCtx<S, P extends CloudProvider = CloudProvider> = {
|
|
382
397
|
name: string;
|
|
398
|
+
appComponentType: string;
|
|
383
399
|
deploymentConfig: Record<string, any>;
|
|
384
400
|
state: S;
|
|
385
401
|
$: {
|
|
@@ -391,6 +407,7 @@ export type ProviderAllocateCtx<S, P extends CloudProvider = CloudProvider> = {
|
|
|
391
407
|
};
|
|
392
408
|
export type ProviderAllocateWithPulumiCtxCtx<S, P extends CloudProvider = CloudProvider> = {
|
|
393
409
|
name: string;
|
|
410
|
+
appComponentType: string;
|
|
394
411
|
deploymentConfig: Record<string, any>;
|
|
395
412
|
state: S;
|
|
396
413
|
$: {
|
|
@@ -404,6 +421,7 @@ export type ProviderAllocateWithPulumiCtxCtx<S, P extends CloudProvider = CloudP
|
|
|
404
421
|
};
|
|
405
422
|
export type ProviderDeallocateCtx<S, P extends CloudProvider = CloudProvider> = {
|
|
406
423
|
name: string;
|
|
424
|
+
appComponentType: string;
|
|
407
425
|
deploymentConfig: Record<string, any>;
|
|
408
426
|
state: S;
|
|
409
427
|
$: {
|
|
@@ -476,18 +494,24 @@ export type DeclaredConnectionInterfaces = Map<string, {
|
|
|
476
494
|
schema: z.ZodTypeAny;
|
|
477
495
|
data: any;
|
|
478
496
|
}>;
|
|
479
|
-
export declare class InfraComponent<CShape extends z.ZodRawShape,
|
|
497
|
+
export declare class InfraComponent<CShape extends z.ZodRawShape, ACTypes extends Record<string, z.ZodTypeAny>, OShape extends z.ZodRawShape = EmptyOutputShape, ConnTypes extends Record<string, {
|
|
480
498
|
description: string;
|
|
481
499
|
}> = Record<string, {
|
|
482
500
|
description: string;
|
|
483
501
|
}>> {
|
|
484
|
-
opts: InfraComponentOpts<CShape,
|
|
502
|
+
opts: InfraComponentOpts<CShape, ACTypes, OShape, ConnTypes>;
|
|
485
503
|
providers: ProviderRegistry;
|
|
486
504
|
validationSchema: z.ZodTypeAny;
|
|
487
|
-
|
|
505
|
+
/**
|
|
506
|
+
* Validation schemas for each app component type, transformed to accept Pulumi Outputs.
|
|
507
|
+
* Keyed by app component type name.
|
|
508
|
+
*/
|
|
509
|
+
validationAppComponentTypes: Record<string, z.ZodTypeAny>;
|
|
488
510
|
private declaredConnectionInterfaces;
|
|
489
|
-
constructor(opts: InfraComponentOpts<CShape,
|
|
490
|
-
implement<P extends CloudProvider, SShape extends z.ZodRawShape = EmptyStateShape>(provider: P, fns: ProviderFnsDef<InferZodType<CShape>,
|
|
511
|
+
constructor(opts: InfraComponentOpts<CShape, ACTypes, OShape, ConnTypes>);
|
|
512
|
+
implement<P extends CloudProvider, SShape extends z.ZodRawShape = EmptyStateShape>(provider: P, fns: ProviderFnsDef<InferZodType<CShape>, {
|
|
513
|
+
[K in keyof ACTypes]: z.infer<ACTypes[K]>;
|
|
514
|
+
}, InferOutputType<OShape>, SShape, keyof ConnTypes & string, P>): this;
|
|
491
515
|
/**
|
|
492
516
|
* Get the schema for a specific connection interface.
|
|
493
517
|
* Used by the orchestrator at runtime.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as B}from"zod";import*as
|
|
1
|
+
import{z as B}from"zod";import*as K from"@pulumi/pulumi";var F;((X)=>{X.aws="aws";X.gcloud="gcloud";X.azure="azure";X.linode="linode";X.hetzner="hetzner";X.cloudflare="cloudflare"})(F||={});var $;((J)=>{J.oci_spec_image="oci_spec_image";J.file="file"})($||={});var G=new Map;function M(j){return j.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase().replace(/-+/g,"-").replace(/^-|-$/g,"")}function V(j){let H=M(j);if(H.length===0)throw new Error("Connection interface name cannot be empty");let J=G.get(H);if(J!==void 0&&J!==j)throw new Error(`Connection interface name collision: '${j}' resolves to '${H}' which is already registered by '${J}'`);return G.set(H,j),H}function k(j,H,J){return{name:V(j),schema:H,resultSchema:J}}function R(j,H){return j.schema.merge(H)}var g="@anonymous",D=B.object({});function Q(j){if(j instanceof B.ZodObject){let H=j.shape,J={};for(let W in H)J[W]=Q(H[W]);return B.object(J)}if(j instanceof B.ZodOptional)return Q(j.unwrap()).optional();if(j instanceof B.ZodNullable)return Q(j.unwrap()).nullable();if(j instanceof B.ZodDefault)return Q(j._def.innerType).default(j._def.defaultValue);if(j instanceof B.ZodArray)return B.array(Q(j.element));if(j instanceof B.ZodDiscriminatedUnion){let H=j._def.options.map((J)=>Q(J));return B.discriminatedUnion(j._def.discriminator,H)}if(j instanceof B.ZodRecord){let H=j._def.keyType,J=j._def.valueType,W=H?Q(H):B.string(),Z=J?Q(J):B.any();return B.record(W,Z)}return B.union([j,B.custom((H)=>K.Output.isInstance(H))])}var Y="default";function C(j){return{[Y]:j}}var b=B.object({metadata:B.object({stateful:B.boolean(),proxiable:B.boolean()}),connectionTypes:B.record(B.string(),B.object({description:B.string().min(5)})),acceptedArtifactTypes:B.array(B.nativeEnum($)).optional(),configSchema:B.custom(),appComponentTypes:B.record(B.string(),B.custom()),outputSchema:B.custom()});function P(j){return j}var q=B.object({});class L{opts;providers;validationSchema;validationAppComponentTypes;declaredConnectionInterfaces=new Map;constructor(j){this.opts=b.parse(j),this.providers={},this.validationSchema=Q(j.configSchema),this.validationAppComponentTypes=Object.fromEntries(Object.entries(j.appComponentTypes).map(([H,J])=>[H,Q(J)]))}implement(j,H){if(H.allocateComponent&&H.allocateWithPulumiCtx)throw new Error(`Provider '${j}' cannot define both 'allocateComponent' and 'allocateWithPulumiCtx'. These are mutually exclusive allocation strategies.`);if(H.upsertArtifacts&&(!this.opts.acceptedArtifactTypes||this.opts.acceptedArtifactTypes.length===0))throw new Error(`Provider '${j}' defines 'upsertArtifacts' but the component is missing 'acceptedArtifactTypes'. Declare which artifact types this component supports (e.g. [DeploymentArtifactType.oci_spec_image]).`);return this.providers[j]={...H,stateSchema:H.stateSchema??q,initialState:H.initialState},this}getConnectionSchema(j){return j.schema}createDeclareConnectionInterfacesFn(){return(j)=>{this.declaredConnectionInterfaces=new Map;for(let H of j){let J=H.interface.schema,W=Q(J),Z=W.safeParse(H.data);if(!Z.success)throw new Error(`Invalid data for connection interface '${H.interface.name}': ${Z.error.message}`);this.declaredConnectionInterfaces.set(H.interface.name,{schema:W,data:H.data})}}}getDeclaredInterfaces(){return this.declaredConnectionInterfaces}}var U=B.object({name:B.string().min(1),interface:B.custom(),configSchema:B.custom(),stateSchema:B.custom().optional(),provision:B.function()});class w{name;interface;configSchema;stateSchema;validationSchema;provisionFn;initialState;constructor(j){U.parse(j),this.name=j.name,this.interface=j.interface,this.configSchema=j.configSchema,this.stateSchema=j.stateSchema??q,this.validationSchema=Q(j.configSchema),this.provisionFn=j.provision,this.initialState=j.initialState}getProvision(){return this.provisionFn}}var _=B.object({name:B.string().min(1),acceptedArtifactTypes:B.array(B.nativeEnum($)).min(1),configSchema:B.custom(),stateSchema:B.custom().optional(),provision:B.function(),publish:B.function()});class x{name;acceptedArtifactTypes;configSchema;stateSchema;validationSchema;initialState;provisionFn;publishFn;constructor(j){_.parse(j),this.name=j.name,this.acceptedArtifactTypes=j.acceptedArtifactTypes,this.configSchema=j.configSchema,this.stateSchema=j.stateSchema??q,this.validationSchema=Q(j.configSchema),this.initialState=j.initialState,this.provisionFn=j.provision,this.publishFn=j.publish}getProvision(){return this.provisionFn}getPublish(){return this.publishFn}}export{M as toCanonicalInterfaceName,R as extendSchema,k as defineConnectionInterface,C as defaultAppComponentType,P as connectionHandler,w as URLRegister,L as InfraComponent,$ as DeploymentArtifactType,Y as DEFAULT_APP_COMPONENT_TYPE,F as CloudProvider,x as ArtifactRegistry,g as ANONYMOUS_CONNECTION_TYPE};
|