@sdlcworks/components 0.0.36 → 0.0.38
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 +157 -17
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -190,16 +190,13 @@ declare const InfraComponentOptsSchema: z.ZodObject<{
|
|
|
190
190
|
connectionTypes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
191
191
|
description: z.ZodString;
|
|
192
192
|
}, z.core.$strip>>;
|
|
193
|
+
acceptedArtifactTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<typeof DeploymentArtifactType>>>;
|
|
193
194
|
configSchema: z.ZodCustom<z.ZodObject<Readonly<{
|
|
194
195
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
195
196
|
}>, z.core.$strip>, z.ZodObject<Readonly<{
|
|
196
197
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
197
198
|
}>, z.core.$strip>>;
|
|
198
|
-
deploymentInputSchema: z.ZodCustom<z.
|
|
199
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
200
|
-
}>, z.core.$strip>, z.ZodObject<Readonly<{
|
|
201
|
-
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
202
|
-
}>, z.core.$strip>>;
|
|
199
|
+
deploymentInputSchema: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
203
200
|
outputSchema: z.ZodCustom<z.ZodObject<Readonly<{
|
|
204
201
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
205
202
|
}>, z.core.$strip>, z.ZodObject<Readonly<{
|
|
@@ -207,15 +204,20 @@ declare const InfraComponentOptsSchema: z.ZodObject<{
|
|
|
207
204
|
}>, z.core.$strip>>;
|
|
208
205
|
}, z.core.$strip>;
|
|
209
206
|
export type InfraComponentOptsBase = z.infer<typeof InfraComponentOptsSchema>;
|
|
210
|
-
export type InfraComponentOpts<CShape extends z.ZodRawShape,
|
|
207
|
+
export type InfraComponentOpts<CShape extends z.ZodRawShape, DSchema extends z.ZodTypeAny, OShape extends z.ZodRawShape, ConnTypes extends Record<string, {
|
|
211
208
|
description: string;
|
|
212
209
|
}> = Record<string, {
|
|
213
210
|
description: string;
|
|
214
211
|
}>> = Omit<InfraComponentOptsBase, "configSchema" | "deploymentInputSchema" | "outputSchema" | "connectionTypes"> & {
|
|
215
212
|
configSchema: z.ZodObject<CShape>;
|
|
216
|
-
deploymentInputSchema:
|
|
213
|
+
deploymentInputSchema: DSchema;
|
|
217
214
|
outputSchema: z.ZodObject<OShape>;
|
|
218
215
|
connectionTypes: ConnTypes;
|
|
216
|
+
/**
|
|
217
|
+
* Artifact types this infra component supports receiving.
|
|
218
|
+
* Required when any provider implements `upsertArtifacts`.
|
|
219
|
+
*/
|
|
220
|
+
acceptedArtifactTypes?: DeploymentArtifactType[];
|
|
219
221
|
};
|
|
220
222
|
export type ArtifactInfo = {
|
|
221
223
|
artifact: {
|
|
@@ -245,18 +247,26 @@ export type ProviderPulumiCtx<I, S, P extends CloudProvider = CloudProvider> = {
|
|
|
245
247
|
};
|
|
246
248
|
/**
|
|
247
249
|
* Context passed to the connect function.
|
|
248
|
-
* Called once per
|
|
250
|
+
* Called once per each connection being established.
|
|
249
251
|
* The connect function returns handler entries that can capture this context via closure.
|
|
252
|
+
*
|
|
253
|
+
* connectorComponentName — the app component that is requesting the connection (the consumer).
|
|
254
|
+
* selfComponentName — the app component being connected TO (the dependency / the "self" of the
|
|
255
|
+
* infra component being called). For hosting infra components (e.g. k3s) this is the specific
|
|
256
|
+
* app component whose allocation info should be used to construct URIs.
|
|
257
|
+
* For URL register flows, connectorComponentName is set to ANONYMOUS_CONNECTION_TYPE.
|
|
250
258
|
*/
|
|
251
259
|
export type ConnectFnCtx<S, P extends CloudProvider = CloudProvider> = {
|
|
252
260
|
state: S;
|
|
253
261
|
getCredentials: GetCredentialsFn<P>;
|
|
254
|
-
|
|
262
|
+
connectorComponentName: string;
|
|
263
|
+
selfComponentName: string;
|
|
255
264
|
};
|
|
256
265
|
/**
|
|
257
266
|
* Reduced context passed to individual connection handlers.
|
|
258
267
|
* Only contains the per-invocation essentials (connectionData, connectionType, and $).
|
|
259
|
-
* Handlers access state, getCredentials, and
|
|
268
|
+
* Handlers access state, getCredentials, connectorComponentName, and selfComponentName
|
|
269
|
+
* via closure from the connect function.
|
|
260
270
|
*
|
|
261
271
|
* $ - Naming function for Pulumi resources created by this handler. Always use $ for resource
|
|
262
272
|
* names so the orchestrator can track which resources are created by connection logic and
|
|
@@ -287,7 +297,8 @@ export type ConnectionHandlerResult<TMetadata = undefined> = {
|
|
|
287
297
|
/**
|
|
288
298
|
* A connection handler entry mapping a ConnectionInterfaceDef to its handler function.
|
|
289
299
|
* The handler receives a reduced context (connectionData and connectionType only).
|
|
290
|
-
* State, getCredentials, and
|
|
300
|
+
* State, getCredentials, connectorComponentName, and selfComponentName are accessed via
|
|
301
|
+
* closure from the connect function.
|
|
291
302
|
* The handler returns typed metadata based on the interface's resultSchema.
|
|
292
303
|
*/
|
|
293
304
|
export type ConnectionHandlerEntry<ConnectionType extends string, D extends ConnectionInterfaceDef> = {
|
|
@@ -305,10 +316,23 @@ export type ConnectionHandlerDef<D extends ConnectionInterfaceDef> = {
|
|
|
305
316
|
export declare function connectionHandler<D extends ConnectionInterfaceDef>(entry: ConnectionHandlerDef<D>): ConnectionHandlerDef<D>;
|
|
306
317
|
/**
|
|
307
318
|
* Type for the connect function.
|
|
308
|
-
* Called once per
|
|
309
|
-
* Returns an array of handler entries that can use the context
|
|
319
|
+
* Called once per connection being established.
|
|
320
|
+
* Returns an array of handler entries that can use the context (including
|
|
321
|
+
* connectorComponentName and selfComponentName) via closure.
|
|
310
322
|
*/
|
|
311
323
|
export type ConnectFn<S, ConnectionType extends string, P extends CloudProvider = CloudProvider> = (ctx: ConnectFnCtx<S, P>) => readonly ConnectionHandlerEntry<ConnectionType, any>[];
|
|
324
|
+
/**
|
|
325
|
+
* Naming function for Pulumi resources. Used by all component types to generate
|
|
326
|
+
* deterministic, collision-free resource names scoped to the component's unique ID.
|
|
327
|
+
*
|
|
328
|
+
* Supports both tagged-template and plain-string invocation:
|
|
329
|
+
* $`my-resource`
|
|
330
|
+
* $("my-resource")
|
|
331
|
+
*/
|
|
332
|
+
export type NamingFn = {
|
|
333
|
+
(name: string, ...values: any[]): string;
|
|
334
|
+
(strings: TemplateStringsArray, ...values: any[]): string;
|
|
335
|
+
};
|
|
312
336
|
/**
|
|
313
337
|
* Component entry in the URLRegister provision context.
|
|
314
338
|
* Reference metadata for components, keyed by their original URI.
|
|
@@ -452,18 +476,18 @@ export type DeclaredConnectionInterfaces = Map<string, {
|
|
|
452
476
|
schema: z.ZodTypeAny;
|
|
453
477
|
data: any;
|
|
454
478
|
}>;
|
|
455
|
-
export declare class InfraComponent<CShape extends z.ZodRawShape,
|
|
479
|
+
export declare class InfraComponent<CShape extends z.ZodRawShape, DSchema extends z.ZodTypeAny, OShape extends z.ZodRawShape = EmptyOutputShape, ConnTypes extends Record<string, {
|
|
456
480
|
description: string;
|
|
457
481
|
}> = Record<string, {
|
|
458
482
|
description: string;
|
|
459
483
|
}>> {
|
|
460
|
-
opts: InfraComponentOpts<CShape,
|
|
484
|
+
opts: InfraComponentOpts<CShape, DSchema, OShape, ConnTypes>;
|
|
461
485
|
providers: ProviderRegistry;
|
|
462
486
|
validationSchema: z.ZodTypeAny;
|
|
463
487
|
validationDeploymentInputSchema: z.ZodTypeAny;
|
|
464
488
|
private declaredConnectionInterfaces;
|
|
465
|
-
constructor(opts: InfraComponentOpts<CShape,
|
|
466
|
-
implement<P extends CloudProvider, SShape extends z.ZodRawShape = EmptyStateShape>(provider: P, fns: ProviderFnsDef<InferZodType<CShape>,
|
|
489
|
+
constructor(opts: InfraComponentOpts<CShape, DSchema, OShape, ConnTypes>);
|
|
490
|
+
implement<P extends CloudProvider, SShape extends z.ZodRawShape = EmptyStateShape>(provider: P, fns: ProviderFnsDef<InferZodType<CShape>, z.infer<DSchema>, InferOutputType<OShape>, SShape, keyof ConnTypes & string, P>): this;
|
|
467
491
|
/**
|
|
468
492
|
* Get the schema for a specific connection interface.
|
|
469
493
|
* Used by the orchestrator at runtime.
|
|
@@ -558,5 +582,121 @@ export declare class URLRegister<TName extends string, TInterface extends Connec
|
|
|
558
582
|
*/
|
|
559
583
|
getProvision(): StoredProvisionFn;
|
|
560
584
|
}
|
|
585
|
+
/**
|
|
586
|
+
* Context passed to the ArtifactRegistry provision function.
|
|
587
|
+
* Called inside the Pulumi program (during stack:sync) to create cloud resources
|
|
588
|
+
* for the artifact registry (e.g., ECR repository, GCP Artifact Registry repo,
|
|
589
|
+
* CodeArtifact domain, etc.).
|
|
590
|
+
*
|
|
591
|
+
* @property config - Validated config from configSchema (e.g., registry URL, scope)
|
|
592
|
+
* @property state - Mutable state persisted across provision runs
|
|
593
|
+
* @property $ - Naming helper for Pulumi resource names
|
|
594
|
+
* @property getCredentials - Returns typed cloud credentials for the configured provider
|
|
595
|
+
*/
|
|
596
|
+
export type ArtifactRegistryProvisionCtx<TConfig, S, P extends CloudProvider = CloudProvider> = {
|
|
597
|
+
config: TConfig;
|
|
598
|
+
state: S;
|
|
599
|
+
$: NamingFn;
|
|
600
|
+
getCredentials: GetCredentialsFn<P>;
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* Context passed to the ArtifactRegistry publish function.
|
|
604
|
+
* Called outside Pulumi (like deploy/upsertArtifacts) to push a built artifact
|
|
605
|
+
* to the external registry under a versioned tag.
|
|
606
|
+
*
|
|
607
|
+
* @property componentName - Name of the app component being published
|
|
608
|
+
* @property artifact - The build artifact to publish (uri + type)
|
|
609
|
+
* @property version - The version string from the release command
|
|
610
|
+
* @property publishConfig - Per-component publish settings from registry_targets.publish_config
|
|
611
|
+
* @property state - Persisted state from provision (e.g., registry URL, repo name)
|
|
612
|
+
* @property getCredentials - Returns typed cloud credentials for the configured provider
|
|
613
|
+
*/
|
|
614
|
+
export type ArtifactRegistryPublishCtx<S, P extends CloudProvider = CloudProvider> = {
|
|
615
|
+
componentName: string;
|
|
616
|
+
artifact: {
|
|
617
|
+
uri: string;
|
|
618
|
+
type: DeploymentArtifactType;
|
|
619
|
+
};
|
|
620
|
+
version: string;
|
|
621
|
+
publishConfig: Record<string, any>;
|
|
622
|
+
state: S;
|
|
623
|
+
getCredentials: GetCredentialsFn<P>;
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* Type-erased storage for ArtifactRegistry provision function.
|
|
627
|
+
*/
|
|
628
|
+
export type StoredArtifactRegistryProvisionFn = (ctx: ArtifactRegistryProvisionCtx<any, any, any>) => Promise<void>;
|
|
629
|
+
/**
|
|
630
|
+
* Type-erased storage for ArtifactRegistry publish function.
|
|
631
|
+
*/
|
|
632
|
+
export type StoredArtifactRegistryPublishFn = (ctx: ArtifactRegistryPublishCtx<any, any>) => Promise<void>;
|
|
633
|
+
/**
|
|
634
|
+
* ArtifactRegistry component for publishing build artifacts to external package
|
|
635
|
+
* registries (npm, PyPI, Docker Hub, ECR, GAR, CodeArtifact, etc.).
|
|
636
|
+
*
|
|
637
|
+
* Provides two lifecycle functions:
|
|
638
|
+
* - **`provision`**: Called inside Pulumi to create cloud resources for the registry
|
|
639
|
+
* (e.g., ECR repository, GAR repo, CodeArtifact domain). Runs during `stack:sync`.
|
|
640
|
+
* - **`publish`**: Called outside Pulumi to push a built artifact with a version tag.
|
|
641
|
+
* Runs during the release flow via `sdlc-components-run publish`.
|
|
642
|
+
*
|
|
643
|
+
* App components reference artifact registries via `registry_targets` in the
|
|
644
|
+
* TechStackConfig, parallel to how `infra_targets` links components to infra.
|
|
645
|
+
*
|
|
646
|
+
* @param TName - Unique name for this ArtifactRegistry definition
|
|
647
|
+
* @param CShape - Zod shape for the config schema (provision-time settings)
|
|
648
|
+
* @param SShape - Zod shape for the state schema (persisted across runs, default: empty)
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* const registry = new ArtifactRegistry({
|
|
652
|
+
* name: "ecr-registry",
|
|
653
|
+
* acceptedArtifactTypes: [DeploymentArtifactType.oci_spec_image],
|
|
654
|
+
* configSchema: z.object({
|
|
655
|
+
* repositoryPrefix: z.string(),
|
|
656
|
+
* imageTagMutability: z.enum(["MUTABLE", "IMMUTABLE"]).default("IMMUTABLE"),
|
|
657
|
+
* }),
|
|
658
|
+
* stateSchema: z.object({
|
|
659
|
+
* repositoryUrl: z.string(),
|
|
660
|
+
* }),
|
|
661
|
+
* provision: async ({ config, state, $, getCredentials }) => {
|
|
662
|
+
* const repo = new aws.ecr.Repository($`repo`, {
|
|
663
|
+
* name: config.repositoryPrefix,
|
|
664
|
+
* imageTagMutability: config.imageTagMutability,
|
|
665
|
+
* });
|
|
666
|
+
* state.repositoryUrl = repo.repositoryUrl;
|
|
667
|
+
* },
|
|
668
|
+
* publish: async ({ componentName, artifact, version, state, getCredentials }) => {
|
|
669
|
+
* // Push the OCI image from internal store to ECR with version tag
|
|
670
|
+
* // e.g., docker tag + docker push to state.repositoryUrl
|
|
671
|
+
* },
|
|
672
|
+
* });
|
|
673
|
+
*/
|
|
674
|
+
export declare class ArtifactRegistry<TName extends string, CShape extends z.ZodRawShape, SShape extends z.ZodRawShape = EmptyStateShape> {
|
|
675
|
+
readonly name: TName;
|
|
676
|
+
readonly acceptedArtifactTypes: DeploymentArtifactType[];
|
|
677
|
+
readonly configSchema: z.ZodObject<CShape>;
|
|
678
|
+
readonly stateSchema: z.ZodObject<SShape>;
|
|
679
|
+
readonly validationSchema: z.ZodTypeAny;
|
|
680
|
+
readonly initialState?: Partial<RuntimeState<SShape>>;
|
|
681
|
+
private readonly provisionFn;
|
|
682
|
+
private readonly publishFn;
|
|
683
|
+
constructor(opts: {
|
|
684
|
+
name: TName;
|
|
685
|
+
acceptedArtifactTypes: DeploymentArtifactType[];
|
|
686
|
+
configSchema: z.ZodObject<CShape>;
|
|
687
|
+
stateSchema?: z.ZodObject<SShape>;
|
|
688
|
+
initialState?: Partial<RuntimeState<SShape>>;
|
|
689
|
+
provision: (ctx: ArtifactRegistryProvisionCtx<InferZodType<CShape>, RuntimeState<SShape>, CloudProvider>) => Promise<void>;
|
|
690
|
+
publish: (ctx: ArtifactRegistryPublishCtx<RuntimeState<SShape>, CloudProvider>) => Promise<void>;
|
|
691
|
+
});
|
|
692
|
+
/**
|
|
693
|
+
* Get the provision function (for orchestrator use during stack:sync).
|
|
694
|
+
*/
|
|
695
|
+
getProvision(): StoredArtifactRegistryProvisionFn;
|
|
696
|
+
/**
|
|
697
|
+
* Get the publish function (for orchestrator use during release/publish).
|
|
698
|
+
*/
|
|
699
|
+
getPublish(): StoredArtifactRegistryPublishFn;
|
|
700
|
+
}
|
|
561
701
|
|
|
562
702
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as
|
|
1
|
+
import{z as B}from"zod";import*as $ from"@pulumi/pulumi";var Z;((Q)=>{Q.aws="aws";Q.gcloud="gcloud";Q.azure="azure";Q.linode="linode";Q.hetzner="hetzner";Q.cloudflare="cloudflare"})(Z||={});var X;((H)=>{H.oci_spec_image="oci_spec_image";H.file="file"})(X||={});var _=new Map;function q(j){return j.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase().replace(/-+/g,"-").replace(/^-|-$/g,"")}function E(j){let F=q(j);if(F.length===0)throw new Error("Connection interface name cannot be empty");let H=_.get(F);if(H!==void 0&&H!==j)throw new Error(`Connection interface name collision: '${j}' resolves to '${F}' which is already registered by '${H}'`);return _.set(F,j),F}function G(j,F,H){return{name:E(j),schema:F,resultSchema:H}}function I(j,F){return j.schema.merge(F)}var R=G("public-http",B.object({})),P="@anonymous",g=B.object({});function J(j){if(j instanceof B.ZodObject){let F=j.shape,H={};for(let M in F)H[M]=J(F[M]);return B.object(H)}if(j instanceof B.ZodOptional)return J(j.unwrap()).optional();if(j instanceof B.ZodNullable)return J(j.unwrap()).nullable();if(j instanceof B.ZodDefault)return J(j._def.innerType).default(j._def.defaultValue);if(j instanceof B.ZodArray)return B.array(J(j.element));if(j instanceof B.ZodDiscriminatedUnion){let F=j._def.options.map((H)=>J(H));return B.discriminatedUnion(j._def.discriminator,F)}if(j instanceof B.ZodRecord){let F=j._def.keyType,H=j._def.valueType,M=F?J(F):B.string(),W=H?J(H):B.any();return B.record(M,W)}return B.union([j,B.custom((F)=>$.Output.isInstance(F))])}var K=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(X)).optional(),configSchema:B.custom(),deploymentInputSchema:B.custom(),outputSchema:B.custom()});function D(j){return j}var Y=B.object({});class L{opts;providers;validationSchema;validationDeploymentInputSchema;declaredConnectionInterfaces=new Map;constructor(j){this.opts=K.parse(j),this.providers={},this.validationSchema=J(j.configSchema),this.validationDeploymentInputSchema=J(j.deploymentInputSchema)}implement(j,F){if(F.allocateComponent&&F.allocateWithPulumiCtx)throw new Error(`Provider '${j}' cannot define both 'allocateComponent' and 'allocateWithPulumiCtx'. These are mutually exclusive allocation strategies.`);if(F.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]={...F,stateSchema:F.stateSchema??Y,initialState:F.initialState},this}getConnectionSchema(j){return j.schema}createDeclareConnectionInterfacesFn(){return(j)=>{this.declaredConnectionInterfaces=new Map;for(let F of j){let H=F.interface.schema,M=J(H),W=M.safeParse(F.data);if(!W.success)throw new Error(`Invalid data for connection interface '${F.interface.name}': ${W.error.message}`);this.declaredConnectionInterfaces.set(F.interface.name,{schema:M,data:F.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 V{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??Y,this.validationSchema=J(j.configSchema),this.provisionFn=j.provision,this.initialState=j.initialState}getProvision(){return this.provisionFn}}var b=B.object({name:B.string().min(1),acceptedArtifactTypes:B.array(B.nativeEnum(X)).min(1),configSchema:B.custom(),stateSchema:B.custom().optional(),provision:B.function(),publish:B.function()});class N{name;acceptedArtifactTypes;configSchema;stateSchema;validationSchema;initialState;provisionFn;publishFn;constructor(j){b.parse(j),this.name=j.name,this.acceptedArtifactTypes=j.acceptedArtifactTypes,this.configSchema=j.configSchema,this.stateSchema=j.stateSchema??Y,this.validationSchema=J(j.configSchema),this.initialState=j.initialState,this.provisionFn=j.provision,this.publishFn=j.publish}getProvision(){return this.provisionFn}getPublish(){return this.publishFn}}export{q as toCanonicalInterfaceName,I as extendSchema,G as defineConnectionInterface,D as connectionHandler,V as URLRegister,R as PublicHTTPCI,L as InfraComponent,X as DeploymentArtifactType,Z as CloudProvider,N as ArtifactRegistry,P as ANONYMOUS_CONNECTION_TYPE};
|