@sdlcworks/components 0.0.35 → 0.0.37

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,39 @@ 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 each connection being established.
249
+ * The connect function returns handler entries that can capture this context via closure.
250
+ *
251
+ * connectorComponentName — the app component that is requesting the connection (the consumer).
252
+ * selfComponentName — the app component being connected TO (the dependency / the "self" of the
253
+ * infra component being called). For hosting infra components (e.g. k3s) this is the specific
254
+ * app component whose allocation info should be used to construct URIs.
255
+ * For URL register flows, connectorComponentName is set to ANONYMOUS_CONNECTION_TYPE.
241
256
  */
242
- export type ConnectionHandlerCtx<S, ConnectorData, ConnectionType extends string = string, P extends CloudProvider = CloudProvider> = {
257
+ export type ConnectFnCtx<S, P extends CloudProvider = CloudProvider> = {
243
258
  state: S;
259
+ getCredentials: GetCredentialsFn<P>;
260
+ connectorComponentName: string;
261
+ selfComponentName: string;
262
+ };
263
+ /**
264
+ * Reduced context passed to individual connection handlers.
265
+ * Only contains the per-invocation essentials (connectionData, connectionType, and $).
266
+ * Handlers access state, getCredentials, connectorComponentName, and selfComponentName
267
+ * via closure from the connect function.
268
+ *
269
+ * $ - Naming function for Pulumi resources created by this handler. Always use $ for resource
270
+ * names so the orchestrator can track which resources are created by connection logic and
271
+ * apply the correct delete-protection policy (connection resources are ephemeral and un-protected).
272
+ */
273
+ export type ConnectHandlerCtx<ConnectorData, ConnectionType extends string = string> = {
244
274
  connectionData: ConnectorData;
245
275
  connectionType: ConnectionType;
246
- getCredentials: GetCredentialsFn<P>;
276
+ $: {
277
+ (name: string, ...values: any[]): string;
278
+ (strings: TemplateStringsArray, ...values: any[]): string;
279
+ };
247
280
  };
248
281
  /**
249
282
  * Result returned by connection handlers.
@@ -261,11 +294,14 @@ export type ConnectionHandlerResult<TMetadata = undefined> = {
261
294
  };
262
295
  /**
263
296
  * A connection handler entry mapping a ConnectionInterfaceDef to its handler function.
297
+ * The handler receives a reduced context (connectionData and connectionType only).
298
+ * State, getCredentials, connectorComponentName, and selfComponentName are accessed via
299
+ * closure from the connect function.
264
300
  * The handler returns typed metadata based on the interface's resultSchema.
265
301
  */
266
- export type ConnectionHandlerEntry<S, ConnectionType extends string, D extends ConnectionInterfaceDef, P extends CloudProvider = CloudProvider> = {
302
+ export type ConnectionHandlerEntry<ConnectionType extends string, D extends ConnectionInterfaceDef> = {
267
303
  interface: D;
268
- handler: (ctx: ConnectionHandlerCtx<S, InferConnectionData<D>, ConnectionType, P>) => Promise<ConnectionHandlerResult<InferConnectionResultMetadata<D>>>;
304
+ handler: (ctx: ConnectHandlerCtx<InferConnectionData<D>, ConnectionType>) => Promise<ConnectionHandlerResult<InferConnectionResultMetadata<D>>>;
269
305
  };
270
306
  /**
271
307
  * Type definition for a connection handler entry.
@@ -273,9 +309,57 @@ export type ConnectionHandlerEntry<S, ConnectionType extends string, D extends C
273
309
  */
274
310
  export type ConnectionHandlerDef<D extends ConnectionInterfaceDef> = {
275
311
  interface: D;
276
- handler: (ctx: ConnectionHandlerCtx<any, InferConnectionData<D>, any>) => Promise<ConnectionHandlerResult<InferConnectionResultMetadata<D>>>;
312
+ handler: (ctx: ConnectHandlerCtx<InferConnectionData<D>, any>) => Promise<ConnectionHandlerResult<InferConnectionResultMetadata<D>>>;
277
313
  };
278
314
  export declare function connectionHandler<D extends ConnectionInterfaceDef>(entry: ConnectionHandlerDef<D>): ConnectionHandlerDef<D>;
315
+ /**
316
+ * Type for the connect function.
317
+ * Called once per connection being established.
318
+ * Returns an array of handler entries that can use the context (including
319
+ * connectorComponentName and selfComponentName) via closure.
320
+ */
321
+ export type ConnectFn<S, ConnectionType extends string, P extends CloudProvider = CloudProvider> = (ctx: ConnectFnCtx<S, P>) => readonly ConnectionHandlerEntry<ConnectionType, any>[];
322
+ /**
323
+ * Component entry in the URLRegister provision context.
324
+ * Reference metadata for components, keyed by their original URI.
325
+ *
326
+ * The provision function may or may not use this reference data.
327
+ * Metadata is fully typed based on the ConnectionInterface's resultSchema.
328
+ */
329
+ export type URLRegisterComponentEntry<TInterface extends ConnectionInterfaceDef> = {
330
+ component: string;
331
+ metadata: InferConnectionResultMetadata<TInterface> extends undefined ? Record<string, never> : {
332
+ [K in keyof InferConnectionResultMetadata<TInterface>]: PulumiInput<InferConnectionResultMetadata<TInterface>[K]>;
333
+ };
334
+ };
335
+ /**
336
+ * Context passed to the URLRegister provision function.
337
+ *
338
+ * @property config - Global configuration + URL map definition (user-defined routes/URLs to provision)
339
+ * @property state - Mutable state for this URLRegister instance
340
+ * @property components - Reference metadata keyed by original URI (may or may not be used by provision function)
341
+ * @property $ - Naming helper for Pulumi resource names
342
+ *
343
+ * Fully typed based on configSchema, stateSchema, and the declared ConnectionInterface.
344
+ */
345
+ export type URLRegisterProvisionCtx<TConfig, TInterface extends ConnectionInterfaceDef, S> = {
346
+ config: TConfig;
347
+ state: S;
348
+ components: Record<string, URLRegisterComponentEntry<TInterface>>;
349
+ $: {
350
+ (name: string, ...values: any[]): string;
351
+ (strings: TemplateStringsArray, ...values: any[]): string;
352
+ };
353
+ };
354
+ /**
355
+ * Result returned by the URLRegister provision function.
356
+ * Maps component names to their provisioned URIs.
357
+ */
358
+ export type URLRegisterProvisionResult = Record<string, PulumiOutput<string>>;
359
+ /**
360
+ * Type-erased storage for URLRegister provision function.
361
+ */
362
+ export type StoredProvisionFn = (ctx: URLRegisterProvisionCtx<any, any, any>) => Promise<URLRegisterProvisionResult>;
279
363
  export type ProviderDeployCtx<D, S, P extends CloudProvider = CloudProvider> = {
280
364
  state: S;
281
365
  getCredentials: GetCredentialsFn<P>;
@@ -291,6 +375,19 @@ export type ProviderAllocateCtx<S, P extends CloudProvider = CloudProvider> = {
291
375
  envStore: EnvStore;
292
376
  getCredentials: GetCredentialsFn<P>;
293
377
  };
378
+ export type ProviderAllocateWithPulumiCtxCtx<S, P extends CloudProvider = CloudProvider> = {
379
+ name: string;
380
+ deploymentConfig: Record<string, any>;
381
+ state: S;
382
+ $: {
383
+ (name: string, ...values: any[]): string;
384
+ (strings: TemplateStringsArray, ...values: any[]): string;
385
+ };
386
+ envStore: EnvStore;
387
+ getCredentials: GetCredentialsFn<P>;
388
+ /** Build artifact for this app component, if available. */
389
+ buildArtifact?: ArtifactInfo;
390
+ };
294
391
  export type ProviderDeallocateCtx<S, P extends CloudProvider = CloudProvider> = {
295
392
  name: string;
296
393
  deploymentConfig: Record<string, any>;
@@ -310,6 +407,7 @@ export type ProviderUpsertArtifactsCtx<S, P extends CloudProvider = CloudProvide
310
407
  export type ProviderPulumiFn<I, S, O, P extends CloudProvider = CloudProvider> = (ctx: ProviderPulumiCtx<I, S, P>) => Promise<O>;
311
408
  export type ProviderDeployFn<D, S, P extends CloudProvider = CloudProvider> = (ctx: ProviderDeployCtx<D, S, P>) => Promise<void>;
312
409
  export type ProviderAllocateFn<S, P extends CloudProvider = CloudProvider> = (ctx: ProviderAllocateCtx<S, P>) => Promise<void>;
410
+ export type ProviderAllocateWithPulumiCtxFn<S, P extends CloudProvider = CloudProvider> = (ctx: ProviderAllocateWithPulumiCtxCtx<S, P>) => Promise<void>;
313
411
  export type ProviderDeallocateFn<S, P extends CloudProvider = CloudProvider> = (ctx: ProviderDeallocateCtx<S, P>) => Promise<void>;
314
412
  export type ProviderUpsertArtifactsFn<S, P extends CloudProvider = CloudProvider> = (ctx: ProviderUpsertArtifactsCtx<S, P>) => Promise<void>;
315
413
  declare const emptyStateSchema: z.ZodObject<{}, z.core.$strip>;
@@ -330,29 +428,28 @@ export type ProviderFnsDef<I, D, O, SShape extends z.ZodRawShape = EmptyStateSha
330
428
  stateSchema?: z.ZodObject<SShape>;
331
429
  initialState?: Partial<S>;
332
430
  pulumi: ProviderPulumiFn<I, S, O, P>;
333
- connect?: readonly ConnectionHandlerEntry<S, ConnectionType, any>[];
431
+ connect?: ConnectFn<S, ConnectionType, P>;
334
432
  deploy?: ProviderDeployFn<D, S, P>;
335
433
  allocateComponent?: ProviderAllocateFn<S, P>;
336
434
  deallocateComponent?: ProviderDeallocateFn<S, P>;
435
+ /**
436
+ * Pulumi-context allocation: creates declarative Pulumi resources per app component.
437
+ * Mutually exclusive with `allocateComponent` — defining both will throw an error.
438
+ * Unlike `allocateComponent` (imperative side-effects), resources created here are
439
+ * tracked by Pulumi and automatically destroyed when the app component is removed.
440
+ */
441
+ allocateWithPulumiCtx?: ProviderAllocateWithPulumiCtxFn<S, P>;
337
442
  upsertArtifacts?: ProviderUpsertArtifactsFn<S, P>;
338
443
  };
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
444
  export type StoredProviderFns = {
349
445
  stateSchema: z.ZodObject<any>;
350
446
  initialState?: any;
351
447
  pulumi: ProviderPulumiFn<any, any, any, any>;
352
- connect?: readonly StoredConnectionHandlerEntry[];
448
+ connect?: ConnectFn<any, any, any>;
353
449
  deploy?: ProviderDeployFn<any, any, any>;
354
450
  allocateComponent?: ProviderAllocateFn<any, any>;
355
451
  deallocateComponent?: ProviderDeallocateFn<any, any>;
452
+ allocateWithPulumiCtx?: ProviderAllocateWithPulumiCtxFn<any, any>;
356
453
  upsertArtifacts?: ProviderUpsertArtifactsFn<any, any>;
357
454
  };
358
455
  export type ProviderRegistry = Partial<Record<CloudProvider, StoredProviderFns>>;
@@ -395,5 +492,81 @@ export declare class InfraComponent<CShape extends z.ZodRawShape, DShape extends
395
492
  */
396
493
  getDeclaredInterfaces(): DeclaredConnectionInterfaces;
397
494
  }
495
+ /**
496
+ * URLRegister component for managing URL routing/registration (e.g., DNS, LB paths).
497
+ *
498
+ * Provider-agnostic: runs at app-layer, not tied to specific cloud providers.
499
+ *
500
+ * ## Conceptual Model
501
+ *
502
+ * - **`interface` field**: Required metadata for SDLC orchestrator (determines which components get passed)
503
+ * - **`configSchema`**: Defines global settings + URL map (routes/paths the user wants to provision)
504
+ * - **`ctx.components`**: Reference metadata keyed by URI (provision function may or may not use this)
505
+ * - **Return type**: Component name → rewritten URI (can be empty `{}` if no rewriting needed)
506
+ *
507
+ * @param TName - Unique name for this URLRegister
508
+ * @param TInterface - The ConnectionInterfaceDef this register handles (orchestrator metadata)
509
+ * @param CShape - Zod shape for the config schema (global settings + URL map definition)
510
+ * @param SShape - Zod shape for the state schema (default: empty)
511
+ *
512
+ * @example
513
+ * const BackendServiceCI = defineConnectionInterface(
514
+ * "backend-service",
515
+ * z.object({ backendServiceId: z.string() }),
516
+ * z.object({ region: z.string(), port: z.number() })
517
+ * );
518
+ *
519
+ * const lbPathRegister = new URLRegister({
520
+ * name: "lb-path-manager",
521
+ * interface: BackendServiceCI, // Orchestrator uses this to route components
522
+ * configSchema: z.object({
523
+ * domain: z.string(),
524
+ * urlMapId: z.string(),
525
+ * routes: z.array(z.object({
526
+ * path: z.string(),
527
+ * targetComponent: z.string(),
528
+ * })),
529
+ * }),
530
+ * provision: async (ctx) => {
531
+ * // ctx.config: { domain, urlMapId, routes: [...] }
532
+ * // ctx.components: { [uri: string]: { component: string, metadata: {...typed...} } }
533
+ *
534
+ * const results: Record<string, pulumi.Output<string>> = {};
535
+ * for (const route of ctx.config.routes) {
536
+ * // Find component's original URI if needed
537
+ * const componentEntry = Object.entries(ctx.components)
538
+ * .find(([_, entry]) => entry.component === route.targetComponent);
539
+ *
540
+ * if (componentEntry) {
541
+ * const [originalUri, entry] = componentEntry;
542
+ * // Use originalUri and entry.metadata as needed
543
+ * results[entry.component] = pulumi.interpolate`https://${ctx.config.domain}${route.path}`;
544
+ * }
545
+ * }
546
+ * return results; // Can be {} if no rewriting needed
547
+ * },
548
+ * });
549
+ */
550
+ export declare class URLRegister<TName extends string, TInterface extends ConnectionInterfaceDef, CShape extends z.ZodRawShape, SShape extends z.ZodRawShape = EmptyStateShape> {
551
+ readonly name: TName;
552
+ readonly interface: TInterface;
553
+ readonly configSchema: z.ZodObject<CShape>;
554
+ readonly stateSchema: z.ZodObject<SShape>;
555
+ readonly validationSchema: z.ZodTypeAny;
556
+ private readonly provisionFn;
557
+ readonly initialState?: Partial<RuntimeState<SShape>>;
558
+ constructor(opts: {
559
+ name: TName;
560
+ interface: TInterface;
561
+ configSchema: z.ZodObject<CShape>;
562
+ stateSchema?: z.ZodObject<SShape>;
563
+ initialState?: Partial<RuntimeState<SShape>>;
564
+ provision: (ctx: URLRegisterProvisionCtx<InferZodType<CShape>, TInterface, RuntimeState<SShape>>) => Promise<URLRegisterProvisionResult>;
565
+ });
566
+ /**
567
+ * Get the provision function (for orchestrator use).
568
+ */
569
+ getProvision(): StoredProvisionFn;
570
+ }
398
571
 
399
572
  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.37",
4
4
  "module": "dist/index.js",
5
5
  "files": [
6
6
  "dist"