@sdlcworks/components 0.0.1

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/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @sdlc/components
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run src/index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.2.2. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
@@ -0,0 +1,122 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { Output as PulumiOutput } from '@pulumi/pulumi';
4
+ import { z } from 'zod';
5
+
6
+ declare const InfraComponentOutputSchema = z.object({
7
+ service_name: z.string().nullable().optional(),
8
+ public_url: z.string().nullable().optional(),
9
+ env_outputs: z.array(z.string()).default([]),
10
+ resource_urns: z.array(z.string()),
11
+ });
12
+ export type InfraComponentOutput = z.infer<typeof InfraComponentOutputSchema>;
13
+ declare const InfraComponentOptsSchema: z.ZodObject<{
14
+ metadata: z.ZodObject<{
15
+ stateful: z.ZodBoolean;
16
+ proxiable: z.ZodBoolean;
17
+ }, z.core.$strip>;
18
+ connectionTypes: z.ZodRecord<z.ZodString, z.ZodObject<{
19
+ description: z.ZodString;
20
+ }, z.core.$strip>>;
21
+ configSchema: z.ZodAny;
22
+ networkInputSchema: z.ZodAny;
23
+ deploymentInputSchema: z.ZodAny;
24
+ }, z.core.$strip>;
25
+ export interface InfraComponentOpts extends z.infer<typeof InfraComponentOptsSchema> {
26
+ configSchema: z.ZodObject<any>;
27
+ networkInputSchema: z.ZodObject<any>;
28
+ deploymentInputSchema: z.ZodObject<any>;
29
+ }
30
+ export interface ICPulumiCtx extends CommonPulumiFnInputs {
31
+ }
32
+ export type InfraComponentPulumiFn = PulumiFn<ICPulumiCtx>;
33
+ export type InfraComponentProviderPulumiFns = Partial<Record<string, InfraComponentPulumiFn>>;
34
+ export declare class InfraComponent {
35
+ opts: InfraComponentOpts;
36
+ connect?: ConnectorFn;
37
+ deploy?: DeployFn;
38
+ pulumiFns: InfraComponentProviderPulumiFns;
39
+ constructor(opts: InfraComponentOpts);
40
+ onConnect(connectFn: ConnectorFn): void;
41
+ onDeploy(deployFn: DeployFn): void;
42
+ pulumi(provider: CloudProvider, pulumiFn: InfraComponentPulumiFn): void;
43
+ }
44
+ export type SubnetComponentOpts<IShape extends z.ZodRawShape> = {
45
+ inputSchema: z.ZodObject<IShape>;
46
+ };
47
+ export interface SubnetComponentCtx<T = undefined> extends CommonPulumiFnInputs {
48
+ inputs: T;
49
+ }
50
+ export type SubnetComponentOutputs = {
51
+ id: PulumiOutput<string>;
52
+ region: PulumiOutput<string>;
53
+ cidr?: PulumiOutput<string>;
54
+ zone?: PulumiOutput<string>;
55
+ [key: string]: any;
56
+ };
57
+ export type SubnetComponentPulumiFn<I> = PulumiFn<SubnetComponentCtx<I>, SubnetComponentOutputs>;
58
+ export declare class SubnetComponent<IShape extends z.ZodRawShape> {
59
+ inputSchema: z.ZodObject<IShape>;
60
+ pulumiFns: Partial<Record<CloudProvider, SubnetComponentPulumiFn<InferZodType<IShape>>>>;
61
+ constructor(opts: SubnetComponentOpts<IShape>);
62
+ pulumi(provider: CloudProvider, pulumiFn: SubnetComponentPulumiFn<InferZodType<IShape>>): void;
63
+ }
64
+ export type SomeComponent = InfraComponent | NetworkComponent<any> | SubnetComponent<any>;
65
+ export type InferZodType<S extends z.ZodRawShape> = z.infer<z.ZodObject<S>>;
66
+ export type DefaultPulumiFnOutputs = Record<string, PulumiOutput<any>>;
67
+ export declare enum CloudProvider {
68
+ aws = "aws",
69
+ gcloud = "gcloud",
70
+ azure = "azure",
71
+ linode = "linode",
72
+ hetzner = "hetzner",
73
+ cloudflare = "cloudflare"
74
+ }
75
+ export declare enum DeploymentArtifactType {
76
+ container_image = "container_image",
77
+ local_file = "local_file"
78
+ }
79
+ export type CommonPulumiFnInputs = {
80
+ componentName: string;
81
+ $: {
82
+ (name: string, ...values: any[]): string;
83
+ (strings: TemplateStringsArray, ...values: any[]): string;
84
+ };
85
+ };
86
+ export type CommonDeployFnInputs<T = undefined> = Record<string, {
87
+ provisionOutput: InfraComponentOutput;
88
+ deploymentConfig: T;
89
+ deploymentArtifact: {
90
+ uri: string;
91
+ type: DeploymentArtifactType;
92
+ };
93
+ }>;
94
+ export type ConnectorFn = (ctx: any) => Promise<void>;
95
+ export type DeployFn<T = CommonDeployFnInputs> = (ctx: T) => Promise<void>;
96
+ export type PulumiFn<T = CommonPulumiFnInputs, R = any> = (ctx: T) => Promise<R>;
97
+ export type ProviderPulumiFns<Ctx = undefined, R = any> = Partial<Record<CloudProvider, PulumiFn<Ctx, R>>>;
98
+ export type NetworkComponentOpts<IShape extends z.ZodRawShape> = {
99
+ inputSchema: z.ZodObject<IShape>;
100
+ };
101
+ export interface NetworkCtx<T = undefined> extends CommonPulumiFnInputs {
102
+ inputs: T;
103
+ }
104
+ export type NetworkComponentOutputs = {
105
+ id: PulumiOutput<string>;
106
+ region?: PulumiOutput<string>;
107
+ cidr?: PulumiOutput<string>;
108
+ [key: string]: any;
109
+ };
110
+ export type NetworkComponentPulumiFn<I> = PulumiFn<NetworkCtx<I>, NetworkComponentOutputs>;
111
+ export type NetworkComponentProviderPulumiFns<I> = Partial<Record<CloudProvider, NetworkComponentPulumiFn<I>>>;
112
+ export declare class NetworkComponent<IShape extends z.ZodRawShape> {
113
+ inputSchema: z.ZodObject<IShape>;
114
+ pulumiFns: NetworkComponentProviderPulumiFns<InferZodType<IShape>>;
115
+ constructor(opts: NetworkComponentOpts<IShape>);
116
+ pulumi(provider: CloudProvider, pulumiFn: NetworkComponentPulumiFn<InferZodType<IShape>>): void;
117
+ }
118
+ export declare function sanitizeForAlphaNum(_name: string, validSpaceRepl: string): string;
119
+ export declare function getComponentInfraID(componentName: string): string;
120
+ export declare function generateFullResourceName(componentInfraID: string, name: string): string;
121
+
122
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{createRequire as f}from"node:module";var l=Object.create;var{getPrototypeOf:c,defineProperty:m,getOwnPropertyNames:C}=Object;var d=Object.prototype.hasOwnProperty;var y=(t,n,e)=>{e=t!=null?l(c(t)):{};let p=n||!t||!t.__esModule?m(e,"default",{value:t,enumerable:!0}):e;for(let r of C(t))if(!d.call(p,r))m(p,r,{get:()=>t[r],enumerable:!0});return p};var I=f(import.meta.url);class P{inputSchema;pulumiFns;constructor(t){import("@pulumi/pulumi/package.json",{with:{type:"json"}}).then((n)=>console.log("pulumi package json",n)),this.inputSchema=t.inputSchema,this.pulumiFns={}}pulumi(t,n){this.pulumiFns[t]=n}}import{z as o}from"zod";var h=o.object({metadata:o.object({stateful:o.boolean(),proxiable:o.boolean()}),connectionTypes:o.record(o.string(),o.object({description:o.string().min(5)})),configSchema:o.any(),networkInputSchema:o.any(),deploymentInputSchema:o.any()});class F{opts;connect;deploy;pulumiFns;constructor(t){this.opts=h.parse(t),this.pulumiFns={}}onConnect(t){this.connect=t}onDeploy(t){this.deploy=t}pulumi(t,n){this.pulumiFns[t]=n}}var g;((u)=>{u.aws="aws";u.gcloud="gcloud";u.azure="azure";u.linode="linode";u.hetzner="hetzner";u.cloudflare="cloudflare"})(g||={});var S;((e)=>{e.container_image="container_image";e.local_file="local_file"})(S||={});class x{inputSchema;pulumiFns;constructor(t){this.inputSchema=t.inputSchema,this.pulumiFns={}}pulumi(t,n){this.pulumiFns[t]=n}}import s from"crypto";var O=10,b=2,N=10,w=2;function R(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i(t,n){let e=t;e=e.replace(/\s+/g," "),e=e.split(" ").join(n);let p=R(n),r=new RegExp(`${p}+`,"g");e=e.replace(r,n);let a=new RegExp(`^${p}+|${p}+$`,"g");return e=e.replace(a,""),e=e.toLowerCase(),e=e.replace(/[^a-z0-9\-]/g,""),e}function _(t){let n=i(s.createHash("sha256").update(`${Date.now()}${Math.random()}`).digest("base64"),"-").slice(0,b);return`${i(t,"-").slice(O)}${n}`}function $(t,n){let e=i(n,"-").slice(N);return e=i(s.createHash("sha256").update(e).digest("base64"),"-").slice(0,w),`${t}-${e}`}export{i as sanitizeForAlphaNum,_ as getComponentInfraID,$ as generateFullResourceName,x as SubnetComponent,P as NetworkComponent,F as InfraComponent,S as DeploymentArtifactType,g as CloudProvider};
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@sdlcworks/components",
3
+ "version": "0.0.1",
4
+ "module": "dist/index.js",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "types": "dist/index.d.ts",
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "bun run build.ts",
18
+ "dev": "watchexec -w src -r -- env DEBUG=1 bun run build.ts",
19
+ "lint": "eslint .",
20
+ "check-types": "tsc --noEmit"
21
+ },
22
+ "devDependencies": {
23
+ "@repo/build-utils": "workspace:*",
24
+ "@repo/eslint-config": "workspace:*",
25
+ "eslint": "^9.0.0",
26
+ "typescript": "^5.0.0"
27
+ },
28
+ "peerDependencies": {
29
+ "@pulumi/gcp": "^9.6.0",
30
+ "@pulumi/pulumi": "3.213.0",
31
+ "typescript": "^5.0.0"
32
+ },
33
+ "dependencies": {
34
+ "zod": "^4.1.13"
35
+ }
36
+ }