@sdlcworks/components 0.0.37 → 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 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 = <D extends ConnectionInterfaceDef>(entries: DeclaredConnectionInterfaceEntry<D>[]) => void;
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;
@@ -190,16 +205,13 @@ declare const InfraComponentOptsSchema: z.ZodObject<{
190
205
  connectionTypes: z.ZodRecord<z.ZodString, z.ZodObject<{
191
206
  description: z.ZodString;
192
207
  }, z.core.$strip>>;
208
+ acceptedArtifactTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<typeof DeploymentArtifactType>>>;
193
209
  configSchema: z.ZodCustom<z.ZodObject<Readonly<{
194
210
  [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
195
211
  }>, z.core.$strip>, z.ZodObject<Readonly<{
196
212
  [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
197
213
  }>, z.core.$strip>>;
198
- deploymentInputSchema: z.ZodCustom<z.ZodObject<Readonly<{
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>>;
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>>>>;
203
215
  outputSchema: z.ZodCustom<z.ZodObject<Readonly<{
204
216
  [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
205
217
  }>, z.core.$strip>, z.ZodObject<Readonly<{
@@ -207,15 +219,20 @@ declare const InfraComponentOptsSchema: z.ZodObject<{
207
219
  }>, z.core.$strip>>;
208
220
  }, z.core.$strip>;
209
221
  export type InfraComponentOptsBase = z.infer<typeof InfraComponentOptsSchema>;
210
- export type InfraComponentOpts<CShape extends z.ZodRawShape, DShape extends z.ZodRawShape, OShape extends z.ZodRawShape, ConnTypes extends Record<string, {
222
+ export type InfraComponentOpts<CShape extends z.ZodRawShape, ACTypes extends Record<string, z.ZodTypeAny>, OShape extends z.ZodRawShape, ConnTypes extends Record<string, {
211
223
  description: string;
212
224
  }> = Record<string, {
213
225
  description: string;
214
- }>> = Omit<InfraComponentOptsBase, "configSchema" | "deploymentInputSchema" | "outputSchema" | "connectionTypes"> & {
226
+ }>> = Omit<InfraComponentOptsBase, "configSchema" | "appComponentTypes" | "outputSchema" | "connectionTypes"> & {
215
227
  configSchema: z.ZodObject<CShape>;
216
- deploymentInputSchema: z.ZodObject<DShape>;
228
+ appComponentTypes: ACTypes;
217
229
  outputSchema: z.ZodObject<OShape>;
218
230
  connectionTypes: ConnTypes;
231
+ /**
232
+ * Artifact types this infra component supports receiving.
233
+ * Required when any provider implements `upsertArtifacts`.
234
+ */
235
+ acceptedArtifactTypes?: DeploymentArtifactType[];
219
236
  };
220
237
  export type ArtifactInfo = {
221
238
  artifact: {
@@ -319,6 +336,18 @@ export declare function connectionHandler<D extends ConnectionInterfaceDef>(entr
319
336
  * connectorComponentName and selfComponentName) via closure.
320
337
  */
321
338
  export type ConnectFn<S, ConnectionType extends string, P extends CloudProvider = CloudProvider> = (ctx: ConnectFnCtx<S, P>) => readonly ConnectionHandlerEntry<ConnectionType, any>[];
339
+ /**
340
+ * Naming function for Pulumi resources. Used by all component types to generate
341
+ * deterministic, collision-free resource names scoped to the component's unique ID.
342
+ *
343
+ * Supports both tagged-template and plain-string invocation:
344
+ * $`my-resource`
345
+ * $("my-resource")
346
+ */
347
+ export type NamingFn = {
348
+ (name: string, ...values: any[]): string;
349
+ (strings: TemplateStringsArray, ...values: any[]): string;
350
+ };
322
351
  /**
323
352
  * Component entry in the URLRegister provision context.
324
353
  * Reference metadata for components, keyed by their original URI.
@@ -366,6 +395,7 @@ export type ProviderDeployCtx<D, S, P extends CloudProvider = CloudProvider> = {
366
395
  } & Record<string, DeploymentInfo>;
367
396
  export type ProviderAllocateCtx<S, P extends CloudProvider = CloudProvider> = {
368
397
  name: string;
398
+ appComponentType: string;
369
399
  deploymentConfig: Record<string, any>;
370
400
  state: S;
371
401
  $: {
@@ -377,6 +407,7 @@ export type ProviderAllocateCtx<S, P extends CloudProvider = CloudProvider> = {
377
407
  };
378
408
  export type ProviderAllocateWithPulumiCtxCtx<S, P extends CloudProvider = CloudProvider> = {
379
409
  name: string;
410
+ appComponentType: string;
380
411
  deploymentConfig: Record<string, any>;
381
412
  state: S;
382
413
  $: {
@@ -390,6 +421,7 @@ export type ProviderAllocateWithPulumiCtxCtx<S, P extends CloudProvider = CloudP
390
421
  };
391
422
  export type ProviderDeallocateCtx<S, P extends CloudProvider = CloudProvider> = {
392
423
  name: string;
424
+ appComponentType: string;
393
425
  deploymentConfig: Record<string, any>;
394
426
  state: S;
395
427
  $: {
@@ -462,18 +494,24 @@ export type DeclaredConnectionInterfaces = Map<string, {
462
494
  schema: z.ZodTypeAny;
463
495
  data: any;
464
496
  }>;
465
- export declare class InfraComponent<CShape extends z.ZodRawShape, DShape extends z.ZodRawShape, OShape extends z.ZodRawShape = EmptyOutputShape, ConnTypes extends Record<string, {
497
+ export declare class InfraComponent<CShape extends z.ZodRawShape, ACTypes extends Record<string, z.ZodTypeAny>, OShape extends z.ZodRawShape = EmptyOutputShape, ConnTypes extends Record<string, {
466
498
  description: string;
467
499
  }> = Record<string, {
468
500
  description: string;
469
501
  }>> {
470
- opts: InfraComponentOpts<CShape, DShape, OShape, ConnTypes>;
502
+ opts: InfraComponentOpts<CShape, ACTypes, OShape, ConnTypes>;
471
503
  providers: ProviderRegistry;
472
504
  validationSchema: z.ZodTypeAny;
473
- validationDeploymentInputSchema: z.ZodTypeAny;
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>;
474
510
  private declaredConnectionInterfaces;
475
- constructor(opts: InfraComponentOpts<CShape, DShape, OShape, ConnTypes>);
476
- implement<P extends CloudProvider, SShape extends z.ZodRawShape = EmptyStateShape>(provider: P, fns: ProviderFnsDef<InferZodType<CShape>, InferZodType<DShape>, InferOutputType<OShape>, SShape, keyof ConnTypes & string, P>): this;
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;
477
515
  /**
478
516
  * Get the schema for a specific connection interface.
479
517
  * Used by the orchestrator at runtime.
@@ -568,5 +606,121 @@ export declare class URLRegister<TName extends string, TInterface extends Connec
568
606
  */
569
607
  getProvision(): StoredProvisionFn;
570
608
  }
609
+ /**
610
+ * Context passed to the ArtifactRegistry provision function.
611
+ * Called inside the Pulumi program (during stack:sync) to create cloud resources
612
+ * for the artifact registry (e.g., ECR repository, GCP Artifact Registry repo,
613
+ * CodeArtifact domain, etc.).
614
+ *
615
+ * @property config - Validated config from configSchema (e.g., registry URL, scope)
616
+ * @property state - Mutable state persisted across provision runs
617
+ * @property $ - Naming helper for Pulumi resource names
618
+ * @property getCredentials - Returns typed cloud credentials for the configured provider
619
+ */
620
+ export type ArtifactRegistryProvisionCtx<TConfig, S, P extends CloudProvider = CloudProvider> = {
621
+ config: TConfig;
622
+ state: S;
623
+ $: NamingFn;
624
+ getCredentials: GetCredentialsFn<P>;
625
+ };
626
+ /**
627
+ * Context passed to the ArtifactRegistry publish function.
628
+ * Called outside Pulumi (like deploy/upsertArtifacts) to push a built artifact
629
+ * to the external registry under a versioned tag.
630
+ *
631
+ * @property componentName - Name of the app component being published
632
+ * @property artifact - The build artifact to publish (uri + type)
633
+ * @property version - The version string from the release command
634
+ * @property publishConfig - Per-component publish settings from registry_targets.publish_config
635
+ * @property state - Persisted state from provision (e.g., registry URL, repo name)
636
+ * @property getCredentials - Returns typed cloud credentials for the configured provider
637
+ */
638
+ export type ArtifactRegistryPublishCtx<S, P extends CloudProvider = CloudProvider> = {
639
+ componentName: string;
640
+ artifact: {
641
+ uri: string;
642
+ type: DeploymentArtifactType;
643
+ };
644
+ version: string;
645
+ publishConfig: Record<string, any>;
646
+ state: S;
647
+ getCredentials: GetCredentialsFn<P>;
648
+ };
649
+ /**
650
+ * Type-erased storage for ArtifactRegistry provision function.
651
+ */
652
+ export type StoredArtifactRegistryProvisionFn = (ctx: ArtifactRegistryProvisionCtx<any, any, any>) => Promise<void>;
653
+ /**
654
+ * Type-erased storage for ArtifactRegistry publish function.
655
+ */
656
+ export type StoredArtifactRegistryPublishFn = (ctx: ArtifactRegistryPublishCtx<any, any>) => Promise<void>;
657
+ /**
658
+ * ArtifactRegistry component for publishing build artifacts to external package
659
+ * registries (npm, PyPI, Docker Hub, ECR, GAR, CodeArtifact, etc.).
660
+ *
661
+ * Provides two lifecycle functions:
662
+ * - **`provision`**: Called inside Pulumi to create cloud resources for the registry
663
+ * (e.g., ECR repository, GAR repo, CodeArtifact domain). Runs during `stack:sync`.
664
+ * - **`publish`**: Called outside Pulumi to push a built artifact with a version tag.
665
+ * Runs during the release flow via `sdlc-components-run publish`.
666
+ *
667
+ * App components reference artifact registries via `registry_targets` in the
668
+ * TechStackConfig, parallel to how `infra_targets` links components to infra.
669
+ *
670
+ * @param TName - Unique name for this ArtifactRegistry definition
671
+ * @param CShape - Zod shape for the config schema (provision-time settings)
672
+ * @param SShape - Zod shape for the state schema (persisted across runs, default: empty)
673
+ *
674
+ * @example
675
+ * const registry = new ArtifactRegistry({
676
+ * name: "ecr-registry",
677
+ * acceptedArtifactTypes: [DeploymentArtifactType.oci_spec_image],
678
+ * configSchema: z.object({
679
+ * repositoryPrefix: z.string(),
680
+ * imageTagMutability: z.enum(["MUTABLE", "IMMUTABLE"]).default("IMMUTABLE"),
681
+ * }),
682
+ * stateSchema: z.object({
683
+ * repositoryUrl: z.string(),
684
+ * }),
685
+ * provision: async ({ config, state, $, getCredentials }) => {
686
+ * const repo = new aws.ecr.Repository($`repo`, {
687
+ * name: config.repositoryPrefix,
688
+ * imageTagMutability: config.imageTagMutability,
689
+ * });
690
+ * state.repositoryUrl = repo.repositoryUrl;
691
+ * },
692
+ * publish: async ({ componentName, artifact, version, state, getCredentials }) => {
693
+ * // Push the OCI image from internal store to ECR with version tag
694
+ * // e.g., docker tag + docker push to state.repositoryUrl
695
+ * },
696
+ * });
697
+ */
698
+ export declare class ArtifactRegistry<TName extends string, CShape extends z.ZodRawShape, SShape extends z.ZodRawShape = EmptyStateShape> {
699
+ readonly name: TName;
700
+ readonly acceptedArtifactTypes: DeploymentArtifactType[];
701
+ readonly configSchema: z.ZodObject<CShape>;
702
+ readonly stateSchema: z.ZodObject<SShape>;
703
+ readonly validationSchema: z.ZodTypeAny;
704
+ readonly initialState?: Partial<RuntimeState<SShape>>;
705
+ private readonly provisionFn;
706
+ private readonly publishFn;
707
+ constructor(opts: {
708
+ name: TName;
709
+ acceptedArtifactTypes: DeploymentArtifactType[];
710
+ configSchema: z.ZodObject<CShape>;
711
+ stateSchema?: z.ZodObject<SShape>;
712
+ initialState?: Partial<RuntimeState<SShape>>;
713
+ provision: (ctx: ArtifactRegistryProvisionCtx<InferZodType<CShape>, RuntimeState<SShape>, CloudProvider>) => Promise<void>;
714
+ publish: (ctx: ArtifactRegistryPublishCtx<RuntimeState<SShape>, CloudProvider>) => Promise<void>;
715
+ });
716
+ /**
717
+ * Get the provision function (for orchestrator use during stack:sync).
718
+ */
719
+ getProvision(): StoredArtifactRegistryProvisionFn;
720
+ /**
721
+ * Get the publish function (for orchestrator use during release/publish).
722
+ */
723
+ getPublish(): StoredArtifactRegistryPublishFn;
724
+ }
571
725
 
572
726
  export {};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{z as j}from"zod";import*as Z from"@pulumi/pulumi";var W;((M)=>{M.aws="aws";M.gcloud="gcloud";M.azure="azure";M.linode="linode";M.hetzner="hetzner";M.cloudflare="cloudflare"})(W||={});var X;((F)=>{F.oci_spec_image="oci_spec_image";F.file="file"})(X||={});var Y=new Map;function $(b){return b.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase().replace(/-+/g,"-").replace(/^-|-$/g,"")}function q(b){let B=$(b);if(B.length===0)throw new Error("Connection interface name cannot be empty");let F=Y.get(B);if(F!==void 0&&F!==b)throw new Error(`Connection interface name collision: '${b}' resolves to '${B}' which is already registered by '${F}'`);return Y.set(B,b),B}function E(b,B,F){return{name:q(b),schema:B,resultSchema:F}}function k(b,B){return b.schema.merge(B)}var x=E("public-http",j.object({})),I="@anonymous",R=j.object({});function H(b){if(b instanceof j.ZodObject){let B=b.shape,F={};for(let J in B)F[J]=H(B[J]);return j.object(F)}if(b instanceof j.ZodOptional)return H(b.unwrap()).optional();if(b instanceof j.ZodNullable)return H(b.unwrap()).nullable();if(b instanceof j.ZodDefault)return H(b._def.innerType).default(b._def.defaultValue);if(b instanceof j.ZodArray)return j.array(H(b.element));if(b instanceof j.ZodDiscriminatedUnion){let B=b._def.options.map((F)=>H(F));return j.discriminatedUnion(b._def.discriminator,B)}if(b instanceof j.ZodRecord){let B=b._def.keyType,F=b._def.valueType,J=B?H(B):j.string(),Q=F?H(F):j.any();return j.record(J,Q)}return j.union([b,j.custom((B)=>Z.Output.isInstance(B))])}var G=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 g(b){return b}var _=j.object({});class K{opts;providers;validationSchema;validationDeploymentInputSchema;declaredConnectionInterfaces=new Map;constructor(b){this.opts=G.parse(b),this.providers={},this.validationSchema=H(b.configSchema),this.validationDeploymentInputSchema=H(b.deploymentInputSchema)}implement(b,B){if(B.allocateComponent&&B.allocateWithPulumiCtx)throw new Error(`Provider '${b}' cannot define both 'allocateComponent' and 'allocateWithPulumiCtx'. These are mutually exclusive allocation strategies.`);return this.providers[b]={...B,stateSchema:B.stateSchema??_,initialState:B.initialState},this}getConnectionSchema(b){return b.schema}createDeclareConnectionInterfacesFn(){return(b)=>{this.declaredConnectionInterfaces=new Map;for(let B of b){let F=B.interface.schema,J=H(F),Q=J.safeParse(B.data);if(!Q.success)throw new Error(`Invalid data for connection interface '${B.interface.name}': ${Q.error.message}`);this.declaredConnectionInterfaces.set(B.interface.name,{schema:J,data:B.data})}}}getDeclaredInterfaces(){return this.declaredConnectionInterfaces}}var L=j.object({name:j.string().min(1),interface:j.custom(),configSchema:j.custom(),stateSchema:j.custom().optional(),provision:j.function()});class U{name;interface;configSchema;stateSchema;validationSchema;provisionFn;initialState;constructor(b){L.parse(b),this.name=b.name,this.interface=b.interface,this.configSchema=b.configSchema,this.stateSchema=b.stateSchema??_,this.validationSchema=H(b.configSchema),this.provisionFn=b.provision,this.initialState=b.initialState}getProvision(){return this.provisionFn}}export{$ as toCanonicalInterfaceName,k as extendSchema,E as defineConnectionInterface,g as connectionHandler,U as URLRegister,x as PublicHTTPCI,K as InfraComponent,X as DeploymentArtifactType,W as CloudProvider,I as ANONYMOUS_CONNECTION_TYPE};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdlcworks/components",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "module": "dist/index.js",
5
5
  "files": [
6
6
  "dist"