@sdlcworks/components 0.0.35 → 0.0.36

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
@@ -136,6 +136,15 @@ export declare function extendSchema<TParentSchema extends z.ZodObject<z.ZodRawS
136
136
  * No metadata, only URI is provided.
137
137
  */
138
138
  export declare const PublicHTTPCI: ConnectionInterfaceDef<"public-http", z.ZodObject<{}, z.core.$strip>, undefined>;
139
+ /**
140
+ * Connection type used by the orchestrator when performing anonymous URI discovery
141
+ * for URL register component collection. Infra component connect handlers that expose
142
+ * interfaces consumed by URL registers must accept this connection type.
143
+ *
144
+ * If your infra component's connect handler does not handle this type, the orchestrator
145
+ * will raise an error instructing you to add support for it.
146
+ */
147
+ export declare const ANONYMOUS_CONNECTION_TYPE: "@anonymous";
139
148
  /**
140
149
  * Extract the inferred data type from a ConnectionInterfaceDef.
141
150
  */
@@ -235,15 +244,31 @@ export type ProviderPulumiCtx<I, S, P extends CloudProvider = CloudProvider> = {
235
244
  getCredentials: GetCredentialsFn<P>;
236
245
  };
237
246
  /**
238
- * Context passed to connection handlers.
239
- * Contains the provider state, typed data from the connecting component,
240
- * the connection type chosen by the orchestrator, and getCredentials function.
247
+ * Context passed to the connect function.
248
+ * Called once per app component requesting a connection.
249
+ * The connect function returns handler entries that can capture this context via closure.
241
250
  */
242
- export type ConnectionHandlerCtx<S, ConnectorData, ConnectionType extends string = string, P extends CloudProvider = CloudProvider> = {
251
+ export type ConnectFnCtx<S, P extends CloudProvider = CloudProvider> = {
243
252
  state: S;
253
+ getCredentials: GetCredentialsFn<P>;
254
+ componentName: string;
255
+ };
256
+ /**
257
+ * Reduced context passed to individual connection handlers.
258
+ * Only contains the per-invocation essentials (connectionData, connectionType, and $).
259
+ * Handlers access state, getCredentials, and componentName via closure from the connect function.
260
+ *
261
+ * $ - Naming function for Pulumi resources created by this handler. Always use $ for resource
262
+ * names so the orchestrator can track which resources are created by connection logic and
263
+ * apply the correct delete-protection policy (connection resources are ephemeral and un-protected).
264
+ */
265
+ export type ConnectHandlerCtx<ConnectorData, ConnectionType extends string = string> = {
244
266
  connectionData: ConnectorData;
245
267
  connectionType: ConnectionType;
246
- getCredentials: GetCredentialsFn<P>;
268
+ $: {
269
+ (name: string, ...values: any[]): string;
270
+ (strings: TemplateStringsArray, ...values: any[]): string;
271
+ };
247
272
  };
248
273
  /**
249
274
  * Result returned by connection handlers.
@@ -261,11 +286,13 @@ export type ConnectionHandlerResult<TMetadata = undefined> = {
261
286
  };
262
287
  /**
263
288
  * A connection handler entry mapping a ConnectionInterfaceDef to its handler function.
289
+ * The handler receives a reduced context (connectionData and connectionType only).
290
+ * State, getCredentials, and componentName are accessed via closure from the connect function.
264
291
  * The handler returns typed metadata based on the interface's resultSchema.
265
292
  */
266
- export type ConnectionHandlerEntry<S, ConnectionType extends string, D extends ConnectionInterfaceDef, P extends CloudProvider = CloudProvider> = {
293
+ export type ConnectionHandlerEntry<ConnectionType extends string, D extends ConnectionInterfaceDef> = {
267
294
  interface: D;
268
- handler: (ctx: ConnectionHandlerCtx<S, InferConnectionData<D>, ConnectionType, P>) => Promise<ConnectionHandlerResult<InferConnectionResultMetadata<D>>>;
295
+ handler: (ctx: ConnectHandlerCtx<InferConnectionData<D>, ConnectionType>) => Promise<ConnectionHandlerResult<InferConnectionResultMetadata<D>>>;
269
296
  };
270
297
  /**
271
298
  * Type definition for a connection handler entry.
@@ -273,9 +300,56 @@ export type ConnectionHandlerEntry<S, ConnectionType extends string, D extends C
273
300
  */
274
301
  export type ConnectionHandlerDef<D extends ConnectionInterfaceDef> = {
275
302
  interface: D;
276
- handler: (ctx: ConnectionHandlerCtx<any, InferConnectionData<D>, any>) => Promise<ConnectionHandlerResult<InferConnectionResultMetadata<D>>>;
303
+ handler: (ctx: ConnectHandlerCtx<InferConnectionData<D>, any>) => Promise<ConnectionHandlerResult<InferConnectionResultMetadata<D>>>;
277
304
  };
278
305
  export declare function connectionHandler<D extends ConnectionInterfaceDef>(entry: ConnectionHandlerDef<D>): ConnectionHandlerDef<D>;
306
+ /**
307
+ * Type for the connect function.
308
+ * Called once per app component requesting a connection.
309
+ * Returns an array of handler entries that can use the context via closure.
310
+ */
311
+ export type ConnectFn<S, ConnectionType extends string, P extends CloudProvider = CloudProvider> = (ctx: ConnectFnCtx<S, P>) => readonly ConnectionHandlerEntry<ConnectionType, any>[];
312
+ /**
313
+ * Component entry in the URLRegister provision context.
314
+ * Reference metadata for components, keyed by their original URI.
315
+ *
316
+ * The provision function may or may not use this reference data.
317
+ * Metadata is fully typed based on the ConnectionInterface's resultSchema.
318
+ */
319
+ export type URLRegisterComponentEntry<TInterface extends ConnectionInterfaceDef> = {
320
+ component: string;
321
+ metadata: InferConnectionResultMetadata<TInterface> extends undefined ? Record<string, never> : {
322
+ [K in keyof InferConnectionResultMetadata<TInterface>]: PulumiInput<InferConnectionResultMetadata<TInterface>[K]>;
323
+ };
324
+ };
325
+ /**
326
+ * Context passed to the URLRegister provision function.
327
+ *
328
+ * @property config - Global configuration + URL map definition (user-defined routes/URLs to provision)
329
+ * @property state - Mutable state for this URLRegister instance
330
+ * @property components - Reference metadata keyed by original URI (may or may not be used by provision function)
331
+ * @property $ - Naming helper for Pulumi resource names
332
+ *
333
+ * Fully typed based on configSchema, stateSchema, and the declared ConnectionInterface.
334
+ */
335
+ export type URLRegisterProvisionCtx<TConfig, TInterface extends ConnectionInterfaceDef, S> = {
336
+ config: TConfig;
337
+ state: S;
338
+ components: Record<string, URLRegisterComponentEntry<TInterface>>;
339
+ $: {
340
+ (name: string, ...values: any[]): string;
341
+ (strings: TemplateStringsArray, ...values: any[]): string;
342
+ };
343
+ };
344
+ /**
345
+ * Result returned by the URLRegister provision function.
346
+ * Maps component names to their provisioned URIs.
347
+ */
348
+ export type URLRegisterProvisionResult = Record<string, PulumiOutput<string>>;
349
+ /**
350
+ * Type-erased storage for URLRegister provision function.
351
+ */
352
+ export type StoredProvisionFn = (ctx: URLRegisterProvisionCtx<any, any, any>) => Promise<URLRegisterProvisionResult>;
279
353
  export type ProviderDeployCtx<D, S, P extends CloudProvider = CloudProvider> = {
280
354
  state: S;
281
355
  getCredentials: GetCredentialsFn<P>;
@@ -291,6 +365,19 @@ export type ProviderAllocateCtx<S, P extends CloudProvider = CloudProvider> = {
291
365
  envStore: EnvStore;
292
366
  getCredentials: GetCredentialsFn<P>;
293
367
  };
368
+ export type ProviderAllocateWithPulumiCtxCtx<S, P extends CloudProvider = CloudProvider> = {
369
+ name: string;
370
+ deploymentConfig: Record<string, any>;
371
+ state: S;
372
+ $: {
373
+ (name: string, ...values: any[]): string;
374
+ (strings: TemplateStringsArray, ...values: any[]): string;
375
+ };
376
+ envStore: EnvStore;
377
+ getCredentials: GetCredentialsFn<P>;
378
+ /** Build artifact for this app component, if available. */
379
+ buildArtifact?: ArtifactInfo;
380
+ };
294
381
  export type ProviderDeallocateCtx<S, P extends CloudProvider = CloudProvider> = {
295
382
  name: string;
296
383
  deploymentConfig: Record<string, any>;
@@ -310,6 +397,7 @@ export type ProviderUpsertArtifactsCtx<S, P extends CloudProvider = CloudProvide
310
397
  export type ProviderPulumiFn<I, S, O, P extends CloudProvider = CloudProvider> = (ctx: ProviderPulumiCtx<I, S, P>) => Promise<O>;
311
398
  export type ProviderDeployFn<D, S, P extends CloudProvider = CloudProvider> = (ctx: ProviderDeployCtx<D, S, P>) => Promise<void>;
312
399
  export type ProviderAllocateFn<S, P extends CloudProvider = CloudProvider> = (ctx: ProviderAllocateCtx<S, P>) => Promise<void>;
400
+ export type ProviderAllocateWithPulumiCtxFn<S, P extends CloudProvider = CloudProvider> = (ctx: ProviderAllocateWithPulumiCtxCtx<S, P>) => Promise<void>;
313
401
  export type ProviderDeallocateFn<S, P extends CloudProvider = CloudProvider> = (ctx: ProviderDeallocateCtx<S, P>) => Promise<void>;
314
402
  export type ProviderUpsertArtifactsFn<S, P extends CloudProvider = CloudProvider> = (ctx: ProviderUpsertArtifactsCtx<S, P>) => Promise<void>;
315
403
  declare const emptyStateSchema: z.ZodObject<{}, z.core.$strip>;
@@ -330,29 +418,28 @@ export type ProviderFnsDef<I, D, O, SShape extends z.ZodRawShape = EmptyStateSha
330
418
  stateSchema?: z.ZodObject<SShape>;
331
419
  initialState?: Partial<S>;
332
420
  pulumi: ProviderPulumiFn<I, S, O, P>;
333
- connect?: readonly ConnectionHandlerEntry<S, ConnectionType, any>[];
421
+ connect?: ConnectFn<S, ConnectionType, P>;
334
422
  deploy?: ProviderDeployFn<D, S, P>;
335
423
  allocateComponent?: ProviderAllocateFn<S, P>;
336
424
  deallocateComponent?: ProviderDeallocateFn<S, P>;
425
+ /**
426
+ * Pulumi-context allocation: creates declarative Pulumi resources per app component.
427
+ * Mutually exclusive with `allocateComponent` — defining both will throw an error.
428
+ * Unlike `allocateComponent` (imperative side-effects), resources created here are
429
+ * tracked by Pulumi and automatically destroyed when the app component is removed.
430
+ */
431
+ allocateWithPulumiCtx?: ProviderAllocateWithPulumiCtxFn<S, P>;
337
432
  upsertArtifacts?: ProviderUpsertArtifactsFn<S, P>;
338
433
  };
339
- /**
340
- * Stored version of ConnectionHandlerEntry that preserves ConnectionInterfaceDef type.
341
- * This ensures `interface` is always typed as ConnectionInterfaceDef (not any)
342
- * when accessing from the registry, allowing runtime schema access.
343
- */
344
- export type StoredConnectionHandlerEntry = {
345
- interface: ConnectionInterfaceDef<string, any, any>;
346
- handler: (ctx: ConnectionHandlerCtx<any, any, any, any>) => Promise<ConnectionHandlerResult<any>>;
347
- };
348
434
  export type StoredProviderFns = {
349
435
  stateSchema: z.ZodObject<any>;
350
436
  initialState?: any;
351
437
  pulumi: ProviderPulumiFn<any, any, any, any>;
352
- connect?: readonly StoredConnectionHandlerEntry[];
438
+ connect?: ConnectFn<any, any, any>;
353
439
  deploy?: ProviderDeployFn<any, any, any>;
354
440
  allocateComponent?: ProviderAllocateFn<any, any>;
355
441
  deallocateComponent?: ProviderDeallocateFn<any, any>;
442
+ allocateWithPulumiCtx?: ProviderAllocateWithPulumiCtxFn<any, any>;
356
443
  upsertArtifacts?: ProviderUpsertArtifactsFn<any, any>;
357
444
  };
358
445
  export type ProviderRegistry = Partial<Record<CloudProvider, StoredProviderFns>>;
@@ -395,5 +482,81 @@ export declare class InfraComponent<CShape extends z.ZodRawShape, DShape extends
395
482
  */
396
483
  getDeclaredInterfaces(): DeclaredConnectionInterfaces;
397
484
  }
485
+ /**
486
+ * URLRegister component for managing URL routing/registration (e.g., DNS, LB paths).
487
+ *
488
+ * Provider-agnostic: runs at app-layer, not tied to specific cloud providers.
489
+ *
490
+ * ## Conceptual Model
491
+ *
492
+ * - **`interface` field**: Required metadata for SDLC orchestrator (determines which components get passed)
493
+ * - **`configSchema`**: Defines global settings + URL map (routes/paths the user wants to provision)
494
+ * - **`ctx.components`**: Reference metadata keyed by URI (provision function may or may not use this)
495
+ * - **Return type**: Component name → rewritten URI (can be empty `{}` if no rewriting needed)
496
+ *
497
+ * @param TName - Unique name for this URLRegister
498
+ * @param TInterface - The ConnectionInterfaceDef this register handles (orchestrator metadata)
499
+ * @param CShape - Zod shape for the config schema (global settings + URL map definition)
500
+ * @param SShape - Zod shape for the state schema (default: empty)
501
+ *
502
+ * @example
503
+ * const BackendServiceCI = defineConnectionInterface(
504
+ * "backend-service",
505
+ * z.object({ backendServiceId: z.string() }),
506
+ * z.object({ region: z.string(), port: z.number() })
507
+ * );
508
+ *
509
+ * const lbPathRegister = new URLRegister({
510
+ * name: "lb-path-manager",
511
+ * interface: BackendServiceCI, // Orchestrator uses this to route components
512
+ * configSchema: z.object({
513
+ * domain: z.string(),
514
+ * urlMapId: z.string(),
515
+ * routes: z.array(z.object({
516
+ * path: z.string(),
517
+ * targetComponent: z.string(),
518
+ * })),
519
+ * }),
520
+ * provision: async (ctx) => {
521
+ * // ctx.config: { domain, urlMapId, routes: [...] }
522
+ * // ctx.components: { [uri: string]: { component: string, metadata: {...typed...} } }
523
+ *
524
+ * const results: Record<string, pulumi.Output<string>> = {};
525
+ * for (const route of ctx.config.routes) {
526
+ * // Find component's original URI if needed
527
+ * const componentEntry = Object.entries(ctx.components)
528
+ * .find(([_, entry]) => entry.component === route.targetComponent);
529
+ *
530
+ * if (componentEntry) {
531
+ * const [originalUri, entry] = componentEntry;
532
+ * // Use originalUri and entry.metadata as needed
533
+ * results[entry.component] = pulumi.interpolate`https://${ctx.config.domain}${route.path}`;
534
+ * }
535
+ * }
536
+ * return results; // Can be {} if no rewriting needed
537
+ * },
538
+ * });
539
+ */
540
+ export declare class URLRegister<TName extends string, TInterface extends ConnectionInterfaceDef, CShape extends z.ZodRawShape, SShape extends z.ZodRawShape = EmptyStateShape> {
541
+ readonly name: TName;
542
+ readonly interface: TInterface;
543
+ readonly configSchema: z.ZodObject<CShape>;
544
+ readonly stateSchema: z.ZodObject<SShape>;
545
+ readonly validationSchema: z.ZodTypeAny;
546
+ private readonly provisionFn;
547
+ readonly initialState?: Partial<RuntimeState<SShape>>;
548
+ constructor(opts: {
549
+ name: TName;
550
+ interface: TInterface;
551
+ configSchema: z.ZodObject<CShape>;
552
+ stateSchema?: z.ZodObject<SShape>;
553
+ initialState?: Partial<RuntimeState<SShape>>;
554
+ provision: (ctx: URLRegisterProvisionCtx<InferZodType<CShape>, TInterface, RuntimeState<SShape>>) => Promise<URLRegisterProvisionResult>;
555
+ });
556
+ /**
557
+ * Get the provision function (for orchestrator use).
558
+ */
559
+ getProvision(): StoredProvisionFn;
560
+ }
398
561
 
399
562
  export {};
package/dist/index.js CHANGED
@@ -1,158 +1 @@
1
- // src/infra.ts
2
- import { z } from "zod";
3
- import * as pulumi from "@pulumi/pulumi";
4
-
5
- // src/copied-types.ts
6
- var CloudProvider;
7
- ((CloudProvider2) => {
8
- CloudProvider2["aws"] = "aws";
9
- CloudProvider2["gcloud"] = "gcloud";
10
- CloudProvider2["azure"] = "azure";
11
- CloudProvider2["linode"] = "linode";
12
- CloudProvider2["hetzner"] = "hetzner";
13
- CloudProvider2["cloudflare"] = "cloudflare";
14
- })(CloudProvider ||= {});
15
- var DeploymentArtifactType;
16
- ((DeploymentArtifactType2) => {
17
- DeploymentArtifactType2["oci_spec_image"] = "oci_spec_image";
18
- DeploymentArtifactType2["file"] = "file";
19
- })(DeploymentArtifactType ||= {});
20
-
21
- // src/infra.ts
22
- var connectionInterfaceRegistry = new Map;
23
- function toCanonicalInterfaceName(name) {
24
- return name.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase().replace(/-+/g, "-").replace(/^-|-$/g, "");
25
- }
26
- function registerInterfaceName(name) {
27
- const canonical = toCanonicalInterfaceName(name);
28
- if (canonical.length === 0) {
29
- throw new Error(`Connection interface name cannot be empty`);
30
- }
31
- const existing = connectionInterfaceRegistry.get(canonical);
32
- if (existing !== undefined && existing !== name) {
33
- throw new Error(`Connection interface name collision: '${name}' resolves to '${canonical}' which is already registered by '${existing}'`);
34
- }
35
- connectionInterfaceRegistry.set(canonical, name);
36
- return canonical;
37
- }
38
- function defineConnectionInterface(name, schema, resultSchema) {
39
- const canonicalName = registerInterfaceName(name);
40
- return {
41
- name: canonicalName,
42
- schema,
43
- resultSchema
44
- };
45
- }
46
- function extendSchema(parentDef, additionalSchema) {
47
- return parentDef.schema.merge(additionalSchema);
48
- }
49
- var PublicHTTPCI = defineConnectionInterface("public-http", z.object({}));
50
- var emptyOutputSchema = z.object({});
51
- function transformSchemaToAcceptOutputs(schema) {
52
- if (schema instanceof z.ZodObject) {
53
- const shape = schema.shape;
54
- const newShape = {};
55
- for (const key in shape) {
56
- newShape[key] = transformSchemaToAcceptOutputs(shape[key]);
57
- }
58
- return z.object(newShape);
59
- }
60
- if (schema instanceof z.ZodOptional) {
61
- return transformSchemaToAcceptOutputs(schema.unwrap()).optional();
62
- }
63
- if (schema instanceof z.ZodNullable) {
64
- return transformSchemaToAcceptOutputs(schema.unwrap()).nullable();
65
- }
66
- if (schema instanceof z.ZodDefault) {
67
- return transformSchemaToAcceptOutputs(schema._def.innerType).default(schema._def.defaultValue);
68
- }
69
- if (schema instanceof z.ZodArray) {
70
- return z.array(transformSchemaToAcceptOutputs(schema.element));
71
- }
72
- if (schema instanceof z.ZodDiscriminatedUnion) {
73
- const transformedOptions = schema._def.options.map((option) => transformSchemaToAcceptOutputs(option));
74
- return z.discriminatedUnion(schema._def.discriminator, transformedOptions);
75
- }
76
- if (schema instanceof z.ZodRecord) {
77
- const keyType = schema._def.keyType;
78
- const valueType = schema._def.valueType;
79
- const transformedKey = keyType ? transformSchemaToAcceptOutputs(keyType) : z.string();
80
- const transformedValue = valueType ? transformSchemaToAcceptOutputs(valueType) : z.any();
81
- return z.record(transformedKey, transformedValue);
82
- }
83
- return z.union([
84
- schema,
85
- z.custom((val) => pulumi.Output.isInstance(val))
86
- ]);
87
- }
88
- var InfraComponentOptsSchema = z.object({
89
- metadata: z.object({
90
- stateful: z.boolean(),
91
- proxiable: z.boolean()
92
- }),
93
- connectionTypes: z.record(z.string(), z.object({
94
- description: z.string().min(5)
95
- })),
96
- configSchema: z.custom(),
97
- deploymentInputSchema: z.custom(),
98
- outputSchema: z.custom()
99
- });
100
- function connectionHandler(entry) {
101
- return entry;
102
- }
103
- var emptyStateSchema = z.object({});
104
-
105
- class InfraComponent {
106
- opts;
107
- providers;
108
- validationSchema;
109
- validationDeploymentInputSchema;
110
- declaredConnectionInterfaces = new Map;
111
- constructor(opts) {
112
- this.opts = InfraComponentOptsSchema.parse(opts);
113
- this.providers = {};
114
- this.validationSchema = transformSchemaToAcceptOutputs(opts.configSchema);
115
- this.validationDeploymentInputSchema = transformSchemaToAcceptOutputs(opts.deploymentInputSchema);
116
- }
117
- implement(provider, fns) {
118
- this.providers[provider] = {
119
- ...fns,
120
- stateSchema: fns.stateSchema ?? emptyStateSchema,
121
- initialState: fns.initialState
122
- };
123
- return this;
124
- }
125
- getConnectionSchema(interfaceDef) {
126
- return interfaceDef.schema;
127
- }
128
- createDeclareConnectionInterfacesFn() {
129
- return (entries) => {
130
- this.declaredConnectionInterfaces = new Map;
131
- for (const entry of entries) {
132
- const schema = entry.interface.schema;
133
- const transformedSchema = transformSchemaToAcceptOutputs(schema);
134
- const parseResult = transformedSchema.safeParse(entry.data);
135
- if (!parseResult.success) {
136
- throw new Error(`Invalid data for connection interface '${entry.interface.name}': ${parseResult.error.message}`);
137
- }
138
- this.declaredConnectionInterfaces.set(entry.interface.name, {
139
- schema: transformedSchema,
140
- data: entry.data
141
- });
142
- }
143
- };
144
- }
145
- getDeclaredInterfaces() {
146
- return this.declaredConnectionInterfaces;
147
- }
148
- }
149
- export {
150
- toCanonicalInterfaceName,
151
- extendSchema,
152
- defineConnectionInterface,
153
- connectionHandler,
154
- PublicHTTPCI,
155
- InfraComponent,
156
- DeploymentArtifactType,
157
- CloudProvider
158
- };
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdlcworks/components",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "module": "dist/index.js",
5
5
  "files": [
6
6
  "dist"