@webiny/pulumi 0.0.0-unstable.eb196ccd2f β†’ 0.0.0-unstable.eb81deee7e

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.
@@ -1,4 +1,4 @@
1
- import type { PulumiApp } from "./types";
1
+ import type { PulumiApp } from "./types.js";
2
2
  export interface PulumiAppModuleCallback<TModule, TConfig> {
3
3
  (this: void, app: PulumiApp, config: TConfig): TModule;
4
4
  }
@@ -1,20 +1,13 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PulumiAppModuleDefinition = void 0;
7
- exports.createAppModule = createAppModule;
8
1
  class PulumiAppModuleDefinition {
9
- symbol = Symbol();
10
- constructor(params) {
11
- this.name = params.name;
12
- this.run = params.config;
13
- }
2
+ constructor(params){
3
+ this.symbol = Symbol();
4
+ this.name = params.name;
5
+ this.run = params.config;
6
+ }
14
7
  }
15
- exports.PulumiAppModuleDefinition = PulumiAppModuleDefinition;
16
8
  function createAppModule(params) {
17
- return new PulumiAppModuleDefinition(params);
9
+ return new PulumiAppModuleDefinition(params);
18
10
  }
11
+ export { PulumiAppModuleDefinition, createAppModule };
19
12
 
20
13
  //# sourceMappingURL=PulumiAppModule.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PulumiAppModuleDefinition","symbol","Symbol","constructor","params","name","run","config","exports","createAppModule"],"sources":["PulumiAppModule.ts"],"sourcesContent":["import type { PulumiApp } from \"./types\";\n\nexport interface PulumiAppModuleCallback<TModule, TConfig> {\n (this: void, app: PulumiApp, config: TConfig): TModule;\n}\n\nexport interface PulumiAppModuleParams<TModule, TConfig> {\n name: string;\n config: PulumiAppModuleCallback<TModule, TConfig>;\n}\n\nexport type PulumiAppModule<T extends PulumiAppModuleDefinition<any, any>> =\n T extends PulumiAppModuleDefinition<infer V, any> ? V : never;\n\nexport class PulumiAppModuleDefinition<TModule, TConfig> {\n public readonly symbol = Symbol();\n public readonly name: string;\n public readonly run: PulumiAppModuleCallback<TModule, TConfig>;\n constructor(params: PulumiAppModuleParams<TModule, TConfig>) {\n this.name = params.name;\n this.run = params.config;\n }\n}\n\nexport function createAppModule<TModule, TConfig = void>(\n params: PulumiAppModuleParams<TModule, TConfig>\n) {\n return new PulumiAppModuleDefinition(params);\n}\n"],"mappings":";;;;;;;AAcO,MAAMA,yBAAyB,CAAmB;EACrCC,MAAM,GAAGC,MAAM,CAAC,CAAC;EAGjCC,WAAWA,CAACC,MAA+C,EAAE;IACzD,IAAI,CAACC,IAAI,GAAGD,MAAM,CAACC,IAAI;IACvB,IAAI,CAACC,GAAG,GAAGF,MAAM,CAACG,MAAM;EAC5B;AACJ;AAACC,OAAA,CAAAR,yBAAA,GAAAA,yBAAA;AAEM,SAASS,eAAeA,CAC3BL,MAA+C,EACjD;EACE,OAAO,IAAIJ,yBAAyB,CAACI,MAAM,CAAC;AAChD","ignoreList":[]}
1
+ {"version":3,"file":"PulumiAppModule.js","sources":["../src/PulumiAppModule.ts"],"sourcesContent":["import type { PulumiApp } from \"./types.js\";\n\nexport interface PulumiAppModuleCallback<TModule, TConfig> {\n (this: void, app: PulumiApp, config: TConfig): TModule;\n}\n\nexport interface PulumiAppModuleParams<TModule, TConfig> {\n name: string;\n config: PulumiAppModuleCallback<TModule, TConfig>;\n}\n\nexport type PulumiAppModule<T extends PulumiAppModuleDefinition<any, any>> =\n T extends PulumiAppModuleDefinition<infer V, any> ? V : never;\n\nexport class PulumiAppModuleDefinition<TModule, TConfig> {\n public readonly symbol = Symbol();\n public readonly name: string;\n public readonly run: PulumiAppModuleCallback<TModule, TConfig>;\n constructor(params: PulumiAppModuleParams<TModule, TConfig>) {\n this.name = params.name;\n this.run = params.config;\n }\n}\n\nexport function createAppModule<TModule, TConfig = void>(\n params: PulumiAppModuleParams<TModule, TConfig>\n) {\n return new PulumiAppModuleDefinition(params);\n}\n"],"names":["PulumiAppModuleDefinition","params","Symbol","createAppModule"],"mappings":"AAcO,MAAMA;IAIT,YAAYC,MAA+C,CAAE;aAH7C,MAAM,GAAGC;QAIrB,IAAI,CAAC,IAAI,GAAGD,OAAO,IAAI;QACvB,IAAI,CAAC,GAAG,GAAGA,OAAO,MAAM;IAC5B;AACJ;AAEO,SAASE,gBACZF,MAA+C;IAE/C,OAAO,IAAID,0BAA0BC;AACzC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=PulumiAppRemoteResource.js.map
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=PulumiAppResource.js.map
package/README.md CHANGED
@@ -1,138 +1,11 @@
1
- # `@webiny/pulumi`
1
+ # @webiny/pulumi
2
2
 
3
- [![](https://img.shields.io/npm/dw/@webiny/pulumi.svg)](https://www.npmjs.com/package/@webiny/pulumi)
4
- [![](https://img.shields.io/npm/v/@webiny/pulumi.svg)](https://www.npmjs.com/package/@webiny/pulumi)
5
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
7
6
 
8
- A small framework for creating flexible Pulumi programs.
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
9
8
 
10
- ## Table of Contents
9
+ ---
11
10
 
12
- - [Installation](#installation)
13
- - [Overview](#overview)
14
- - [Examples](#examples)
15
- - [Reference](#reference)
16
- - [Functions](#functions)
17
- - [`createPulumiApp`](#createPulumiApp)
18
-
19
- ## Installation
20
-
21
- ```
22
- npm install --save @webiny/pulumi
23
- ```
24
-
25
- Or if you prefer yarn:
26
-
27
- ```
28
- yarn add @webiny/pulumi
29
- ```
30
-
31
- ## Overview
32
-
33
- The `@webiny/pulumi` package enables creation of flexible Pulumi apps (programs).
34
-
35
- More specifically, a Pulumi app not only encapsulates the essential Pulumi program code defined by developers, but also, once defined, provides a way to adjust any defined cloud infrastructure resource configuration and even add new resources into the mix.
36
-
37
- This is useful when you just want to export a simple constructor function to the user, and not bother them with all the internals. And, as mentioned, in those rare cases when the user actually needs to perform further adjustments, a Pulumi app provides a way to do it.
38
-
39
- > πŸ’‘ **TIP**
40
- >
41
- > Pulumi apps are heavily used in real Webiny projects. As mentioned, this is because of their ability to abstract the actual cloud infrastructure code from the user, and, at the same time, provide a way for the user to perform adjustments when needed.
42
-
43
- The following example shows how a Pulumi app looks in the actual code:
44
-
45
- ```ts
46
- // This is imported in our Pulumi program's entrypoint file (index.ts).
47
- import createXyzApp from "@webiny/xyz-app";
48
-
49
- export = async () => {
50
- const xyzApp = createXyzApp({
51
- pulumi: app => {
52
- // Let's imagine the `xyz` Pulumi app deploys an Amazon S3 bucket.
53
- // Then, we would be able to do something like the following:
54
- app.resources.bucket.config.acl(aws.s3.CannedAcl.Private);
55
- app.resources.bucket.config.forceDestroy(true);
56
- }
57
- });
58
-
59
- return xyzApp.run();
60
- };
61
-
62
- ```
63
-
64
- ## Examples
65
-
66
- | Example | Description |
67
- | --------------------------------- | --------------------------------------------------------------- |
68
- | [Quick Example](./docs/examples/quickExample.md) | Shows how to create and use a simple Pulumi app. |
69
-
70
- ## Reference
71
-
72
- ### Functions
73
-
74
- #### `createPulumiApp`
75
-
76
- <details>
77
- <summary>Type Declaration</summary>
78
- <p>
79
-
80
- ```ts
81
- export interface CreatePulumiAppParams<TResources extends Record<string, unknown>> {
82
- name: string;
83
- path: string;
84
- config?: Record<string, any>;
85
- program(app: PulumiApp): TResources | Promise<TResources>;
86
- }
87
-
88
- export declare function createPulumiApp<TResources extends Record<string, unknown>>(params: CreatePulumiAppParams<TResources>): PulumiApp<TResources>;
89
- ```
90
-
91
- </p>
92
- </details>
93
-
94
- Creates a new Pulumi app.
95
-
96
- ```ts
97
- // Defining the app.
98
- import * as aws from "@pulumi/aws";
99
- import { createPulumiApp } from "@webiny/pulumi";
100
-
101
- export interface CreateMyAppParams {
102
- pulumi?: (app: ReturnType<typeof createMyApp>) => void;
103
- }
104
-
105
- const createMyApp = (projectAppConfig: CreateMyAppParams) => {
106
- const app = createPulumiApp({
107
- name: "my-app",
108
- path: "relative/path/from/cwd",
109
- program: async app => {
110
- const bucket = app.addResource(aws.s3.Bucket, {
111
- name: "my-app",
112
- config: {
113
- acl: aws.s3.CannedAcl.PublicRead,
114
- forceDestroy: false,
115
- website: {
116
- indexDocument: "index.html",
117
- errorDocument: "index.html"
118
- }
119
- }
120
- });
121
-
122
- app.addOutputs({
123
- appStorage: bucket.output.id
124
- });
125
-
126
- return {
127
- bucket
128
- };
129
- }
130
- });
131
-
132
- if (projectAppConfig.pulumi) {
133
- projectAppConfig.pulumi(app);
134
- }
135
-
136
- return app;
137
- };
138
- ```
11
+ _This README file is automatically generated during the publish process._
@@ -1,2 +1,2 @@
1
- import type { CreatePulumiAppParams, PulumiApp } from "./types";
1
+ import type { CreatePulumiAppParams, PulumiApp } from "./types.js";
2
2
  export declare function createPulumiApp<TResources extends Record<string, unknown>>(params: CreatePulumiAppParams<TResources>): PulumiApp<TResources>;
@@ -1,210 +1,145 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createPulumiApp = createPulumiApp;
9
- var _findUp = _interopRequireDefault(require("find-up"));
10
- var _path = _interopRequireDefault(require("path"));
11
- var pulumi = _interopRequireWildcard(require("@pulumi/pulumi"));
12
- var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
13
- var _constants = require("./constants");
1
+ import { findUpSync } from "find-up";
2
+ import path from "path";
3
+ import cloneDeep from "lodash/cloneDeep.js";
4
+ import { getProjectSdk } from "@webiny/project";
5
+ import * as __rspack_external__pulumi_pulumi_f3e773ed from "@pulumi/pulumi";
14
6
  function createPulumiApp(params) {
15
- let projectRootPath = _findUp.default.sync("webiny.project.ts");
16
- if (projectRootPath) {
17
- projectRootPath = _path.default.dirname(projectRootPath).replace(/\\/g, "/");
18
- } else {
19
- throw new Error("Couldn't detect Webiny project.");
20
- }
21
- const appRelativePath = params.path;
22
- const appRootPath = _path.default.join(projectRootPath, appRelativePath);
23
- const projectAppWorkspacePath = _path.default.join(projectRootPath, ".webiny", "workspaces", appRelativePath);
24
- const programDecorators = [];
25
- const app = {
26
- resourceHandlers: [],
27
- handlers: [],
28
- outputs: {},
29
- modules: new Map(),
30
- paths: {
31
- absolute: appRootPath,
32
- relative: appRelativePath,
33
- workspace: projectAppWorkspacePath
34
- },
35
- resources: {},
36
- name: params.name,
37
- program: params.program,
38
- params: {
39
- create: params.config || {},
40
- run: {
41
- env: "",
42
- variant: ""
43
- }
44
- },
45
- env: {
46
- name: "",
47
- isProduction: false
48
- },
49
- decorateProgram: cb => {
50
- programDecorators.push(cb);
51
- },
52
- async run(config) {
53
- app.params.run = config;
54
-
55
- // Add environment-related variables.
56
- const productionEnvironments = app.params.create.productionEnvironments || _constants.DEFAULT_PROD_ENV_NAMES;
57
- const isProduction = productionEnvironments.includes(app.params.run.env);
58
- app.env = {
59
- name: app.params.run.env,
60
- isProduction
61
- };
62
- const programOutput = programDecorators.reduce((program, decorator) => {
63
- return app => decorator(program, app);
64
- }, input => app.program(input));
65
- Object.assign(app.resources, await programOutput(app));
66
- for (const handler of app.handlers) {
67
- await handler();
68
- }
69
- app.params.run = {
70
- env: "",
71
- variant: ""
72
- };
73
- return app.outputs;
74
- },
75
- onResource(handler) {
76
- app.resourceHandlers.push(handler);
77
- },
78
- /**
79
- * Adds a resource to pulumi app.
80
- * It's not running the script immediately, but enqueues the call.
81
- * This way we are still able to modify the config of the resource.
82
- * @param resourceConstructor Resource to be added, ie aws.s3.Bucket
83
- * @param params Parameters to configure the resource
84
- * @returns Object giving access to both resource outputs and its config.
85
- */
86
- addResource(resourceConstructor, params) {
87
- const config = params.config ?? {};
88
- const opts = params.opts ?? {};
89
- const meta = params.meta ?? {};
90
- const promise = new Promise(resolve => {
91
- app.handlers.push(() => {
92
- app.resourceHandlers.forEach(handler => handler(resource));
93
- resolve(new resourceConstructor(resource.name, config, opts));
94
- });
95
- });
96
- const resource = {
7
+ let projectRootPath = findUpSync("webiny.config.tsx");
8
+ if (projectRootPath) projectRootPath = path.dirname(projectRootPath).replace(/\\/g, "/");
9
+ else throw new Error("Couldn't detect Webiny project.");
10
+ const appRelativePath = params.path;
11
+ const appRootPath = path.join(projectRootPath, appRelativePath);
12
+ const projectAppWorkspacePath = path.join(projectRootPath, ".webiny", "workspace", appRelativePath);
13
+ const programDecorators = [];
14
+ const app = {
15
+ resourceHandlers: [],
16
+ handlers: [],
17
+ outputs: {},
18
+ modules: new Map(),
19
+ paths: {
20
+ absolute: appRootPath,
21
+ relative: appRelativePath,
22
+ workspace: projectAppWorkspacePath
23
+ },
24
+ resources: {},
97
25
  name: params.name,
98
- type: resourceConstructor,
99
- config: createPulumiAppResourceConfigProxy(config),
100
- opts,
101
- meta,
102
- output: pulumi.output(promise)
103
- };
104
- return resource;
105
- },
106
- addRemoteResource(name, getter) {
107
- const promise = getter();
108
- const resource = {
109
- name,
110
- output: pulumi.output(promise)
111
- };
112
- return resource;
113
- },
114
- /**
115
- * Registers output value within pulumi app.
116
- * @param name Name of the output value
117
- * @param output Value of the output
118
- */
119
- addOutput(name, output) {
120
- app.outputs[name] = output;
121
- },
122
- /**
123
- * Registers one or more output values.
124
- * @param outputs Dictionary containing output values.
125
- */
126
- addOutputs(outputs) {
127
- Object.assign(app.outputs, outputs);
128
- },
129
- /**
130
- * Registers an app module within app.
131
- * Allows to decompose application into smaller pieces.
132
- * Added module can be then retrieved with `getModule`.
133
- * @param module
134
- * @param config
135
- */
136
- addModule(module, config) {
137
- if (app.modules.has(module.symbol)) {
138
- throw new Error(`Module "${module.name}" is already present in the "${app.name}" application.`);
139
- }
140
- const createdModule = module.run(app, config);
141
- app.modules.set(module.symbol, createdModule);
142
- return createdModule;
143
- },
144
- /**
145
- * Returns a module by its definition
146
- * @param def
147
- * @param opts
148
- */
149
- getModule(def, opts) {
150
- const module = app.modules.get(def.symbol);
151
- if (!module) {
152
- if (opts?.optional) {
153
- return null;
154
- } else {
155
- throw new Error(`Module "${def.name}" not found in "${app.name}" app`);
26
+ program: params.program,
27
+ params: {
28
+ create: params.config || {},
29
+ run: {
30
+ env: "",
31
+ variant: ""
32
+ }
33
+ },
34
+ env: {
35
+ name: "",
36
+ isProduction: false
37
+ },
38
+ decorateProgram: (cb)=>{
39
+ programDecorators.push(cb);
40
+ },
41
+ async run (config) {
42
+ app.params.run = config;
43
+ const sdk = await getProjectSdk();
44
+ const productionEnvironments = await sdk.getProductionEnvironments();
45
+ const isProduction = productionEnvironments.includes(app.params.run.env);
46
+ app.env = {
47
+ name: app.params.run.env,
48
+ isProduction
49
+ };
50
+ const programOutput = programDecorators.reduce((program, decorator)=>(app)=>decorator(program, app), (input)=>app.program(input));
51
+ Object.assign(app.resources, await programOutput(app));
52
+ for (const handler of app.handlers)await handler();
53
+ app.params.run = {
54
+ env: "",
55
+ variant: ""
56
+ };
57
+ return app.outputs;
58
+ },
59
+ onResource (handler) {
60
+ app.resourceHandlers.push(handler);
61
+ },
62
+ addResource (resourceConstructor, params) {
63
+ const config = params.config ?? {};
64
+ const opts = params.opts ?? {};
65
+ const meta = params.meta ?? {};
66
+ const promise = new Promise((resolve)=>{
67
+ app.handlers.push(()=>{
68
+ app.resourceHandlers.forEach((handler)=>handler(resource));
69
+ resolve(new resourceConstructor(resource.name, config, opts));
70
+ });
71
+ });
72
+ const resource = {
73
+ name: params.name,
74
+ type: resourceConstructor,
75
+ config: createPulumiAppResourceConfigProxy(config),
76
+ opts,
77
+ meta,
78
+ output: __rspack_external__pulumi_pulumi_f3e773ed.output(promise)
79
+ };
80
+ return resource;
81
+ },
82
+ addRemoteResource (name, getter) {
83
+ const promise = getter();
84
+ const resource = {
85
+ name,
86
+ output: __rspack_external__pulumi_pulumi_f3e773ed.output(promise)
87
+ };
88
+ return resource;
89
+ },
90
+ addOutput (name, output) {
91
+ app.outputs[name] = output;
92
+ },
93
+ addOutputs (outputs) {
94
+ Object.assign(app.outputs, outputs);
95
+ },
96
+ addModule (module, config) {
97
+ if (app.modules.has(module.symbol)) throw new Error(`Module "${module.name}" is already present in the "${app.name}" application.`);
98
+ const createdModule = module.run(app, config);
99
+ app.modules.set(module.symbol, createdModule);
100
+ return createdModule;
101
+ },
102
+ getModule (def, opts) {
103
+ const module = app.modules.get(def.symbol);
104
+ if (!module) if (opts?.optional) return null;
105
+ else throw new Error(`Module "${def.name}" not found in "${app.name}" app`);
106
+ return module;
107
+ },
108
+ addHandler (handler) {
109
+ const promise = new Promise((resolve)=>{
110
+ app.handlers.push(async ()=>{
111
+ resolve(await handler());
112
+ });
113
+ });
114
+ return __rspack_external__pulumi_pulumi_f3e773ed.output(promise);
115
+ },
116
+ getParam (param) {
117
+ if ("function" == typeof param) return param(app);
118
+ return param;
156
119
  }
157
- }
158
- return module;
159
- },
160
- /**
161
- * Schedules a handler to be executed when running pulumi script.
162
- * Anything, that is returned from handler will be wrapped in pulumi.Output
163
- * so it can be used in other places.
164
- * @param handler Handler to be executed.
165
- * @returns Result of the handler wrapped with pulumi.Output
166
- */
167
- addHandler(handler) {
168
- const promise = new Promise(resolve => {
169
- app.handlers.push(async () => {
170
- resolve(await handler());
171
- });
172
- });
173
- return pulumi.output(promise);
174
- },
175
- getParam(param) {
176
- if (typeof param === "function") {
177
- return param(app);
178
- }
179
- return param;
180
- }
181
- };
182
- return app;
120
+ };
121
+ return app;
183
122
  }
184
123
  function createPulumiAppResourceConfigProxy(obj) {
185
- return new Proxy(obj, {
186
- get(target, p) {
187
- if (p === "clone") {
188
- return () => (0, _cloneDeep.default)(obj);
189
- }
190
- const key = p;
191
- const setter = value => {
192
- if (typeof value === "function") {
193
- const modifier = value;
194
- const currentValue = target[key];
195
- // Wrap a current config with a function.
196
- const newValue = pulumi.output(currentValue).apply(v => {
197
- const newValue = modifier(v);
198
- return pulumi.output(newValue);
199
- });
200
- target[key] = newValue;
201
- } else {
202
- target[key] = value;
124
+ return new Proxy(obj, {
125
+ get (target, p) {
126
+ if ("clone" === p) return ()=>cloneDeep(obj);
127
+ const key = p;
128
+ const setter = (value)=>{
129
+ if ("function" == typeof value) {
130
+ const modifier = value;
131
+ const currentValue = target[key];
132
+ const newValue = __rspack_external__pulumi_pulumi_f3e773ed.output(currentValue).apply((v)=>{
133
+ const newValue = modifier(v);
134
+ return __rspack_external__pulumi_pulumi_f3e773ed.output(newValue);
135
+ });
136
+ target[key] = newValue;
137
+ } else target[key] = value;
138
+ };
139
+ return setter;
203
140
  }
204
- };
205
- return setter;
206
- }
207
- });
141
+ });
208
142
  }
143
+ export { createPulumiApp };
209
144
 
210
145
  //# sourceMappingURL=createPulumiApp.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_findUp","_interopRequireDefault","require","_path","pulumi","_interopRequireWildcard","_cloneDeep","_constants","createPulumiApp","params","projectRootPath","findUp","sync","path","dirname","replace","Error","appRelativePath","appRootPath","join","projectAppWorkspacePath","programDecorators","app","resourceHandlers","handlers","outputs","modules","Map","paths","absolute","relative","workspace","resources","name","program","create","config","run","env","variant","isProduction","decorateProgram","cb","push","productionEnvironments","DEFAULT_PROD_ENV_NAMES","includes","programOutput","reduce","decorator","input","Object","assign","handler","onResource","addResource","resourceConstructor","opts","meta","promise","Promise","resolve","forEach","resource","type","createPulumiAppResourceConfigProxy","output","addRemoteResource","getter","addOutput","addOutputs","addModule","module","has","symbol","createdModule","set","getModule","def","get","optional","addHandler","getParam","param","obj","Proxy","target","p","cloneDeep","key","setter","value","modifier","currentValue","newValue","apply","v"],"sources":["createPulumiApp.ts"],"sourcesContent":["import findUp from \"find-up\";\nimport path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiAppModuleDefinition } from \"./PulumiAppModule\";\nimport type {\n CreatePulumiAppResourceParams,\n PulumiAppResource,\n PulumiAppResourceArgs,\n PulumiAppResourceConfigModifier,\n PulumiAppResourceConfigProxy,\n PulumiAppResourceConfigSetter,\n PulumiAppResourceConstructor,\n PulumiAppResourceType\n} from \"./PulumiAppResource\";\nimport type {\n CreatePulumiAppParams,\n ProgramDecorator,\n PulumiApp,\n PulumiAppParam,\n PulumiAppParamCallback,\n PulumiProgram,\n ResourceHandler\n} from \"~/types\";\nimport type { PulumiAppRemoteResource } from \"~/PulumiAppRemoteResource\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport { DEFAULT_PROD_ENV_NAMES } from \"./constants\";\n\nexport function createPulumiApp<TResources extends Record<string, unknown>>(\n params: CreatePulumiAppParams<TResources>\n): PulumiApp<TResources> {\n let projectRootPath = findUp.sync(\"webiny.project.ts\");\n if (projectRootPath) {\n projectRootPath = path.dirname(projectRootPath).replace(/\\\\/g, \"/\");\n } else {\n throw new Error(\"Couldn't detect Webiny project.\");\n }\n\n const appRelativePath = params.path;\n const appRootPath = path.join(projectRootPath, appRelativePath);\n\n const projectAppWorkspacePath = path.join(\n projectRootPath,\n \".webiny\",\n \"workspaces\",\n appRelativePath\n );\n\n const programDecorators: ProgramDecorator<any, any>[] = [];\n\n const app: PulumiApp<TResources> = {\n resourceHandlers: [],\n handlers: [],\n outputs: {},\n modules: new Map<symbol, unknown>(),\n paths: {\n absolute: appRootPath,\n relative: appRelativePath,\n workspace: projectAppWorkspacePath\n },\n\n resources: {} as TResources,\n name: params.name,\n program: params.program,\n params: {\n create: params.config || {},\n run: {\n env: \"\",\n variant: \"\"\n }\n },\n env: {\n name: \"\",\n isProduction: false\n },\n decorateProgram: cb => {\n programDecorators.push(cb);\n },\n\n async run(config) {\n app.params.run = config;\n\n // Add environment-related variables.\n const productionEnvironments =\n app.params.create.productionEnvironments || DEFAULT_PROD_ENV_NAMES;\n const isProduction = productionEnvironments.includes(app.params.run.env);\n\n app.env = {\n name: app.params.run.env,\n isProduction\n };\n\n const programOutput = programDecorators.reduce<PulumiProgram<PulumiApp<TResources>>>(\n (program, decorator) => {\n return app => decorator(program, app);\n },\n (input: PulumiApp<any>) => app.program(input)\n );\n\n Object.assign(app.resources, await programOutput(app));\n\n for (const handler of app.handlers) {\n await handler();\n }\n\n app.params.run = {\n env: \"\",\n variant: \"\"\n };\n\n return app.outputs;\n },\n\n onResource(handler: ResourceHandler) {\n app.resourceHandlers.push(handler);\n },\n\n /**\n * Adds a resource to pulumi app.\n * It's not running the script immediately, but enqueues the call.\n * This way we are still able to modify the config of the resource.\n * @param resourceConstructor Resource to be added, ie aws.s3.Bucket\n * @param params Parameters to configure the resource\n * @returns Object giving access to both resource outputs and its config.\n */\n addResource<T extends PulumiAppResourceConstructor>(\n resourceConstructor: T,\n params: CreatePulumiAppResourceParams<T>\n ) {\n const config = params.config ?? ({} as PulumiAppResourceArgs<T>);\n const opts = params.opts ?? {};\n const meta = params.meta ?? {};\n\n const promise = new Promise<PulumiAppResourceType<T>>(resolve => {\n app.handlers.push(() => {\n app.resourceHandlers.forEach(handler => handler(resource));\n\n resolve(new resourceConstructor(resource.name, config, opts));\n });\n });\n\n const resource: PulumiAppResource<T> = {\n name: params.name,\n type: resourceConstructor,\n config: createPulumiAppResourceConfigProxy(config),\n opts,\n meta,\n output: pulumi.output(promise)\n };\n\n return resource;\n },\n\n addRemoteResource<T>(name: string, getter: () => Promise<T>) {\n const promise = getter();\n\n const resource: PulumiAppRemoteResource<T> = {\n name,\n output: pulumi.output(promise)\n };\n\n return resource;\n },\n\n /**\n * Registers output value within pulumi app.\n * @param name Name of the output value\n * @param output Value of the output\n */\n addOutput<T>(name: string, output: T) {\n app.outputs[name] = output;\n },\n\n /**\n * Registers one or more output values.\n * @param outputs Dictionary containing output values.\n */\n addOutputs(outputs: Record<string, unknown>) {\n Object.assign(app.outputs, outputs);\n },\n\n /**\n * Registers an app module within app.\n * Allows to decompose application into smaller pieces.\n * Added module can be then retrieved with `getModule`.\n * @param module\n * @param config\n */\n addModule<TModule, TConfig>(\n module: PulumiAppModuleDefinition<TModule, TConfig>,\n config?: TConfig\n ) {\n if (app.modules.has(module.symbol)) {\n throw new Error(\n `Module \"${module.name}\" is already present in the \"${app.name}\" application.`\n );\n }\n\n const createdModule = module.run(app, config as TConfig);\n app.modules.set(module.symbol, createdModule);\n\n return createdModule;\n },\n\n /**\n * Returns a module by its definition\n * @param def\n * @param opts\n */\n getModule<TConfig, TModule>(\n def: PulumiAppModuleDefinition<TModule, TConfig>,\n opts?: { optional: boolean }\n ) {\n const module = app.modules.get(def.symbol);\n\n if (!module) {\n if (opts?.optional) {\n return null;\n } else {\n throw new Error(`Module \"${def.name}\" not found in \"${app.name}\" app`);\n }\n }\n\n return module;\n },\n\n /**\n * Schedules a handler to be executed when running pulumi script.\n * Anything, that is returned from handler will be wrapped in pulumi.Output\n * so it can be used in other places.\n * @param handler Handler to be executed.\n * @returns Result of the handler wrapped with pulumi.Output\n */\n addHandler<T>(handler: () => Promise<T> | T) {\n const promise = new Promise<T>(resolve => {\n app.handlers.push(async () => {\n resolve(await handler());\n });\n });\n\n return pulumi.output(promise);\n },\n\n getParam<T>(param: PulumiAppParam<T>) {\n if (typeof param === \"function\") {\n return (param as PulumiAppParamCallback<T>)(app);\n }\n\n return param;\n }\n };\n\n return app;\n}\n\nfunction createPulumiAppResourceConfigProxy<T extends object>(obj: T) {\n return new Proxy(obj, {\n get(target, p: string) {\n if (p === \"clone\") {\n return () => cloneDeep(obj);\n }\n\n type V = T[keyof T];\n const key = p as keyof T;\n const setter: PulumiAppResourceConfigSetter<V> = (\n value: V | PulumiAppResourceConfigModifier<V>\n ) => {\n if (typeof value === \"function\") {\n const modifier = value as PulumiAppResourceConfigModifier<V>;\n const currentValue = target[key];\n // Wrap a current config with a function.\n const newValue = pulumi.output(currentValue).apply(v => {\n const newValue = modifier(v);\n return pulumi.output(newValue);\n });\n\n target[key] = newValue as unknown as V;\n } else {\n target[key] = value;\n }\n };\n\n return setter;\n }\n }) as PulumiAppResourceConfigProxy<T>;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAsBA,IAAAI,UAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAEO,SAASM,eAAeA,CAC3BC,MAAyC,EACpB;EACrB,IAAIC,eAAe,GAAGC,eAAM,CAACC,IAAI,CAAC,mBAAmB,CAAC;EACtD,IAAIF,eAAe,EAAE;IACjBA,eAAe,GAAGG,aAAI,CAACC,OAAO,CAACJ,eAAe,CAAC,CAACK,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EACvE,CAAC,MAAM;IACH,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;EACtD;EAEA,MAAMC,eAAe,GAAGR,MAAM,CAACI,IAAI;EACnC,MAAMK,WAAW,GAAGL,aAAI,CAACM,IAAI,CAACT,eAAe,EAAEO,eAAe,CAAC;EAE/D,MAAMG,uBAAuB,GAAGP,aAAI,CAACM,IAAI,CACrCT,eAAe,EACf,SAAS,EACT,YAAY,EACZO,eACJ,CAAC;EAED,MAAMI,iBAA+C,GAAG,EAAE;EAE1D,MAAMC,GAA0B,GAAG;IAC/BC,gBAAgB,EAAE,EAAE;IACpBC,QAAQ,EAAE,EAAE;IACZC,OAAO,EAAE,CAAC,CAAC;IACXC,OAAO,EAAE,IAAIC,GAAG,CAAkB,CAAC;IACnCC,KAAK,EAAE;MACHC,QAAQ,EAAEX,WAAW;MACrBY,QAAQ,EAAEb,eAAe;MACzBc,SAAS,EAAEX;IACf,CAAC;IAEDY,SAAS,EAA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5B,OAAO5F,MAAM,CAAC8D,MAAM,CAAC4B,QAAQ,CAAC;UAClC,CAAC,CAAC;UAEFR,MAAM,CAACG,GAAG,CAAC,GAAGK,QAAwB;QAC1C,CAAC,MAAM;UACHR,MAAM,CAACG,GAAG,CAAC,GAAGE,KAAK;QACvB;MACJ,CAAC;MAED,OAAOD,MAAM;IACjB;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"file":"createPulumiApp.js","sources":["../src/createPulumiApp.ts"],"sourcesContent":["import { findUpSync } from \"find-up\";\nimport path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiAppModuleDefinition } from \"./PulumiAppModule.js\";\nimport type {\n CreatePulumiAppResourceParams,\n PulumiAppResource,\n PulumiAppResourceArgs,\n PulumiAppResourceConfigModifier,\n PulumiAppResourceConfigProxy,\n PulumiAppResourceConfigSetter,\n PulumiAppResourceConstructor,\n PulumiAppResourceType\n} from \"./PulumiAppResource.js\";\nimport type {\n CreatePulumiAppParams,\n ProgramDecorator,\n PulumiApp,\n PulumiAppParam,\n PulumiAppParamCallback,\n PulumiProgram,\n ResourceHandler\n} from \"~/types.js\";\nimport type { PulumiAppRemoteResource } from \"~/PulumiAppRemoteResource.js\";\nimport cloneDeep from \"lodash/cloneDeep.js\";\nimport { getProjectSdk } from \"@webiny/project\";\n\nexport function createPulumiApp<TResources extends Record<string, unknown>>(\n params: CreatePulumiAppParams<TResources>\n): PulumiApp<TResources> {\n let projectRootPath = findUpSync(\"webiny.config.tsx\");\n if (projectRootPath) {\n projectRootPath = path.dirname(projectRootPath).replace(/\\\\/g, \"/\");\n } else {\n throw new Error(\"Couldn't detect Webiny project.\");\n }\n\n const appRelativePath = params.path;\n const appRootPath = path.join(projectRootPath, appRelativePath);\n\n const projectAppWorkspacePath = path.join(\n projectRootPath,\n \".webiny\",\n \"workspace\",\n appRelativePath\n );\n\n const programDecorators: ProgramDecorator<any, any>[] = [];\n\n const app: PulumiApp<TResources> = {\n resourceHandlers: [],\n handlers: [],\n outputs: {},\n modules: new Map<symbol, unknown>(),\n paths: {\n absolute: appRootPath,\n relative: appRelativePath,\n workspace: projectAppWorkspacePath\n },\n\n resources: {} as TResources,\n name: params.name,\n program: params.program,\n params: {\n create: params.config || {},\n run: {\n env: \"\",\n variant: \"\"\n }\n },\n env: {\n name: \"\",\n isProduction: false\n },\n decorateProgram: cb => {\n programDecorators.push(cb);\n },\n\n async run(config) {\n app.params.run = config;\n\n // Add environment-related variables. The list of production environments is\n // resolved from the project SDK, which merges the built-in defaults with any\n // environments registered via the `Infra.ProductionEnvironments` extension.\n const sdk = await getProjectSdk();\n const productionEnvironments = await sdk.getProductionEnvironments();\n const isProduction = productionEnvironments.includes(app.params.run.env);\n\n app.env = {\n name: app.params.run.env,\n isProduction\n };\n\n const programOutput = programDecorators.reduce<PulumiProgram<PulumiApp<TResources>>>(\n (program, decorator) => {\n return app => decorator(program, app);\n },\n (input: PulumiApp<any>) => app.program(input)\n );\n\n Object.assign(app.resources, await programOutput(app));\n\n for (const handler of app.handlers) {\n await handler();\n }\n\n app.params.run = {\n env: \"\",\n variant: \"\"\n };\n\n return app.outputs;\n },\n\n onResource(handler: ResourceHandler) {\n app.resourceHandlers.push(handler);\n },\n\n /**\n * Adds a resource to pulumi app.\n * It's not running the script immediately, but enqueues the call.\n * This way we are still able to modify the config of the resource.\n * @param resourceConstructor Resource to be added, ie aws.s3.Bucket\n * @param params Parameters to configure the resource\n * @returns Object giving access to both resource outputs and its config.\n */\n addResource<T extends PulumiAppResourceConstructor>(\n resourceConstructor: T,\n params: CreatePulumiAppResourceParams<T>\n ) {\n const config = params.config ?? ({} as PulumiAppResourceArgs<T>);\n const opts = params.opts ?? {};\n const meta = params.meta ?? {};\n\n const promise = new Promise<PulumiAppResourceType<T>>(resolve => {\n app.handlers.push(() => {\n app.resourceHandlers.forEach(handler => handler(resource));\n\n resolve(new resourceConstructor(resource.name, config, opts));\n });\n });\n\n const resource: PulumiAppResource<T> = {\n name: params.name,\n type: resourceConstructor,\n config: createPulumiAppResourceConfigProxy(config),\n opts,\n meta,\n output: pulumi.output(promise)\n };\n\n return resource;\n },\n\n addRemoteResource<T>(name: string, getter: () => Promise<T>) {\n const promise = getter();\n\n const resource: PulumiAppRemoteResource<T> = {\n name,\n output: pulumi.output(promise)\n };\n\n return resource;\n },\n\n /**\n * Registers output value within pulumi app.\n * @param name Name of the output value\n * @param output Value of the output\n */\n addOutput<T>(name: string, output: T) {\n app.outputs[name] = output;\n },\n\n /**\n * Registers one or more output values.\n * @param outputs Dictionary containing output values.\n */\n addOutputs(outputs: Record<string, unknown>) {\n Object.assign(app.outputs, outputs);\n },\n\n /**\n * Registers an app module within app.\n * Allows to decompose application into smaller pieces.\n * Added module can be then retrieved with `getModule`.\n * @param module\n * @param config\n */\n addModule<TModule, TConfig>(\n module: PulumiAppModuleDefinition<TModule, TConfig>,\n config?: TConfig\n ) {\n if (app.modules.has(module.symbol)) {\n throw new Error(\n `Module \"${module.name}\" is already present in the \"${app.name}\" application.`\n );\n }\n\n const createdModule = module.run(app, config as TConfig);\n app.modules.set(module.symbol, createdModule);\n\n return createdModule;\n },\n\n /**\n * Returns a module by its definition\n * @param def\n * @param opts\n */\n getModule<TConfig, TModule>(\n def: PulumiAppModuleDefinition<TModule, TConfig>,\n opts?: { optional: boolean }\n ) {\n const module = app.modules.get(def.symbol);\n\n if (!module) {\n if (opts?.optional) {\n return null;\n } else {\n throw new Error(`Module \"${def.name}\" not found in \"${app.name}\" app`);\n }\n }\n\n return module;\n },\n\n /**\n * Schedules a handler to be executed when running pulumi script.\n * Anything, that is returned from handler will be wrapped in pulumi.Output\n * so it can be used in other places.\n * @param handler Handler to be executed.\n * @returns Result of the handler wrapped with pulumi.Output\n */\n addHandler<T>(handler: () => Promise<T> | T) {\n const promise = new Promise<T>(resolve => {\n app.handlers.push(async () => {\n resolve(await handler());\n });\n });\n\n return pulumi.output(promise);\n },\n\n getParam<T>(param: PulumiAppParam<T>) {\n if (typeof param === \"function\") {\n return (param as PulumiAppParamCallback<T>)(app);\n }\n\n return param;\n }\n };\n\n return app;\n}\n\nfunction createPulumiAppResourceConfigProxy<T extends object>(obj: T) {\n return new Proxy(obj, {\n get(target, p: string) {\n if (p === \"clone\") {\n return () => cloneDeep(obj);\n }\n\n type V = T[keyof T];\n const key = p as keyof T;\n const setter: PulumiAppResourceConfigSetter<V> = (\n value: V | PulumiAppResourceConfigModifier<V>\n ) => {\n if (typeof value === \"function\") {\n const modifier = value as PulumiAppResourceConfigModifier<V>;\n const currentValue = target[key];\n // Wrap a current config with a function.\n const newValue = pulumi.output(currentValue).apply(v => {\n const newValue = modifier(v);\n return pulumi.output(newValue);\n });\n\n target[key] = newValue as unknown as V;\n } else {\n target[key] = value;\n }\n };\n\n return setter;\n }\n }) as PulumiAppResourceConfigProxy<T>;\n}\n"],"names":["createPulumiApp","params","projectRootPath","findUpSync","path","Error","appRelativePath","appRootPath","projectAppWorkspacePath","programDecorators","app","Map","cb","config","sdk","getProjectSdk","productionEnvironments","isProduction","programOutput","program","decorator","input","Object","handler","resourceConstructor","opts","meta","promise","Promise","resolve","resource","createPulumiAppResourceConfigProxy","pulumi","name","getter","output","outputs","module","createdModule","def","param","obj","Proxy","target","p","cloneDeep","key","setter","value","modifier","currentValue","newValue","v"],"mappings":";;;;;AA2BO,SAASA,gBACZC,MAAyC;IAEzC,IAAIC,kBAAkBC,WAAW;IACjC,IAAID,iBACAA,kBAAkBE,KAAK,OAAO,CAACF,iBAAiB,OAAO,CAAC,OAAO;SAE/D,MAAM,IAAIG,MAAM;IAGpB,MAAMC,kBAAkBL,OAAO,IAAI;IACnC,MAAMM,cAAcH,KAAK,IAAI,CAACF,iBAAiBI;IAE/C,MAAME,0BAA0BJ,KAAK,IAAI,CACrCF,iBACA,WACA,aACAI;IAGJ,MAAMG,oBAAkD,EAAE;IAE1D,MAAMC,MAA6B;QAC/B,kBAAkB,EAAE;QACpB,UAAU,EAAE;QACZ,SAAS,CAAC;QACV,S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AAE7B,IAAI,IAAI,CAAC,KAAK,CAAC;YAI7E,OAAO2B;QACX;QASA,YAAcd,OAA6B;YACvC,MAAMI,UAAU,IAAIC,QAAWC,CAAAA;gBAC3BnB,IAAI,QAAQ,CAAC,IAAI,CAAC;oBACdmB,QAAQ,MAAMN;gBAClB;YACJ;YAEA,OAAOS,0CAAAA,MAAa,CAACL;QACzB;QAEA,UAAYa,KAAwB;YAChC,IAAI,AAAiB,cAAjB,OAAOA,OACP,OAAQA,MAAoC9B;YAGhD,OAAO8B;QACX;IACJ;IAEA,OAAO9B;AACX;AAEA,SAASqB,mCAAqDU,GAAM;IAChE,OAAO,IAAIC,MAAMD,KAAK;QAClB,KAAIE,MAAM,EAAEC,CAAS;YACjB,IAAIA,AAAM,YAANA,GACA,OAAO,IAAMC,UAAUJ;YAI3B,MAAMK,MAAMF;YACZ,MAAMG,SAA2C,CAC7CC;gBAEA,IAAI,AAAiB,cAAjB,OAAOA,OAAsB;oBAC7B,MAAMC,WAAWD;oBACjB,MAAME,eAAeP,MAAM,CAACG,IAAI;oBAEhC,MAAMK,WAAWnB,0CAAAA,MAAa,CAACkB,cAAc,KAAK,CAACE,CAAAA;wBAC/C,MAAMD,WAAWF,SAASG;wBAC1B,OAAOpB,0CAAAA,MAAa,CAACmB;oBACzB;oBAEAR,MAAM,CAACG,IAAI,GAAGK;gBAClB,OACIR,MAAM,CAACG,IAAI,GAAGE;YAEtB;YAEA,OAAOD;QACX;IACJ;AACJ"}
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./createPulumiApp";
2
- export * from "./isResourceOfType";
3
- export * from "./PulumiAppModule";
4
- export * from "./PulumiAppResource";
5
- export * from "./PulumiAppRemoteResource";
6
- export * from "./types";
1
+ export * from "./createPulumiApp.js";
2
+ export * from "./isResourceOfType.js";
3
+ export * from "./PulumiAppModule.js";
4
+ export * from "./PulumiAppResource.js";
5
+ export * from "./PulumiAppRemoteResource.js";
6
+ export * from "./types.js";
package/index.js CHANGED
@@ -1,73 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _createPulumiApp = require("./createPulumiApp");
7
- Object.keys(_createPulumiApp).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _createPulumiApp[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _createPulumiApp[key];
14
- }
15
- });
16
- });
17
- var _isResourceOfType = require("./isResourceOfType");
18
- Object.keys(_isResourceOfType).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _isResourceOfType[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _isResourceOfType[key];
25
- }
26
- });
27
- });
28
- var _PulumiAppModule = require("./PulumiAppModule");
29
- Object.keys(_PulumiAppModule).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _PulumiAppModule[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _PulumiAppModule[key];
36
- }
37
- });
38
- });
39
- var _PulumiAppResource = require("./PulumiAppResource");
40
- Object.keys(_PulumiAppResource).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _PulumiAppResource[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _PulumiAppResource[key];
47
- }
48
- });
49
- });
50
- var _PulumiAppRemoteResource = require("./PulumiAppRemoteResource");
51
- Object.keys(_PulumiAppRemoteResource).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _PulumiAppRemoteResource[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _PulumiAppRemoteResource[key];
58
- }
59
- });
60
- });
61
- var _types = require("./types");
62
- Object.keys(_types).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _types[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function () {
68
- return _types[key];
69
- }
70
- });
71
- });
72
-
73
- //# sourceMappingURL=index.js.map
1
+ export * from "./createPulumiApp.js";
2
+ export * from "./isResourceOfType.js";
3
+ export * from "./PulumiAppModule.js";
4
+ export * from "./PulumiAppResource.js";
5
+ export * from "./PulumiAppRemoteResource.js";
6
+ export * from "./types.js";
@@ -1,2 +1,2 @@
1
- import type { PulumiAppResource, PulumiAppResourceConstructor } from "./PulumiAppResource";
1
+ import { type PulumiAppResource, type PulumiAppResourceConstructor } from "./PulumiAppResource.js";
2
2
  export declare function isResourceOfType<T extends PulumiAppResourceConstructor>(resource: PulumiAppResource<PulumiAppResourceConstructor>, type: T): resource is PulumiAppResource<T>;
@@ -1,11 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isResourceOfType = isResourceOfType;
7
1
  function isResourceOfType(resource, type) {
8
- return resource.type === type;
2
+ return resource.type === type;
9
3
  }
4
+ export { isResourceOfType };
10
5
 
11
6
  //# sourceMappingURL=isResourceOfType.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isResourceOfType","resource","type"],"sources":["isResourceOfType.ts"],"sourcesContent":["import type { PulumiAppResource, PulumiAppResourceConstructor } from \"~/PulumiAppResource\";\n\nexport function isResourceOfType<T extends PulumiAppResourceConstructor>(\n resource: PulumiAppResource<PulumiAppResourceConstructor>,\n type: T\n): resource is PulumiAppResource<T> {\n return resource.type === type;\n}\n"],"mappings":";;;;;;AAEO,SAASA,gBAAgBA,CAC5BC,QAAyD,EACzDC,IAAO,EACyB;EAChC,OAAOD,QAAQ,CAACC,IAAI,KAAKA,IAAI;AACjC","ignoreList":[]}
1
+ {"version":3,"file":"isResourceOfType.js","sources":["../src/isResourceOfType.ts"],"sourcesContent":["import { type PulumiAppResource, type PulumiAppResourceConstructor } from \"~/PulumiAppResource.js\";\n\nexport function isResourceOfType<T extends PulumiAppResourceConstructor>(\n resource: PulumiAppResource<PulumiAppResourceConstructor>,\n type: T\n): resource is PulumiAppResource<T> {\n return resource.type === type;\n}\n"],"names":["isResourceOfType","resource","type"],"mappings":"AAEO,SAASA,iBACZC,QAAyD,EACzDC,IAAO;IAEP,OAAOD,SAAS,IAAI,KAAKC;AAC7B"}
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/pulumi",
3
- "version": "0.0.0-unstable.eb196ccd2f",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.eb81deee7e",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
5
9
  "repository": {
6
10
  "type": "git",
7
11
  "url": "https://github.com/webiny/webiny-js.git"
@@ -10,23 +14,22 @@
10
14
  "author": "Webiny Ltd",
11
15
  "license": "MIT",
12
16
  "publishConfig": {
13
- "access": "public",
14
- "directory": "dist"
17
+ "access": "public"
15
18
  },
16
19
  "dependencies": {
17
- "@pulumi/pulumi": "3.147.0",
18
- "find-up": "5.0.0",
19
- "lodash": "4.17.21"
20
+ "@pulumi/pulumi": "^3.259.0",
21
+ "@webiny/project": "0.0.0-unstable.eb81deee7e",
22
+ "find-up": "8.0.0",
23
+ "lodash": "4.18.1"
20
24
  },
21
25
  "devDependencies": {
22
- "@types/lodash": "4.17.13",
23
- "@webiny/project-utils": "0.0.0-unstable.eb196ccd2f",
24
- "rimraf": "6.0.1",
25
- "typescript": "5.3.3"
26
- },
27
- "scripts": {
28
- "build": "node ../cli/bin.js run build",
29
- "watch": "node ../cli/bin.js run watch"
26
+ "@types/lodash": "4.17.25",
27
+ "@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
28
+ "rimraf": "6.1.3",
29
+ "typescript": "7.0.2"
30
30
  },
31
- "gitHead": "eb196ccd2f32296e10f7add6dd7220d4e3abece4"
31
+ "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
32
+ "webiny": {
33
+ "publishFrom": "dist"
34
+ }
32
35
  }
package/types.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type * as pulumi from "@pulumi/pulumi";
2
- import type { PulumiAppModuleDefinition } from "./PulumiAppModule";
3
- import type { CreatePulumiAppResourceParams, PulumiAppResource, PulumiAppResourceConstructor } from "./PulumiAppResource";
4
- import type { PulumiAppRemoteResource } from "./PulumiAppRemoteResource";
2
+ import type { PulumiAppModuleDefinition } from "./PulumiAppModule.js";
3
+ import type { CreatePulumiAppResourceParams, PulumiAppResource, PulumiAppResourceConstructor } from "./PulumiAppResource.js";
4
+ import type { PulumiAppRemoteResource } from "./PulumiAppRemoteResource.js";
5
+ import { AppName } from "@webiny/project";
5
6
  export interface ResourceHandler {
6
7
  (resource: PulumiAppResource<PulumiAppResourceConstructor>): void;
7
8
  }
@@ -15,7 +16,7 @@ export type RunConfig = {
15
16
  [key: string]: string | number | undefined | boolean | Record<string, string | number | boolean | undefined>;
16
17
  };
17
18
  export interface CreatePulumiAppParams<TResources extends Record<string, unknown>> {
18
- name: string;
19
+ name: AppName;
19
20
  path: string;
20
21
  config?: CreateConfig;
21
22
  program(app: PulumiApp): TResources | Promise<TResources>;
package/types.js CHANGED
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["PulumiAppRemoteResource.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\n\nexport interface PulumiAppRemoteResource<T> {\n name: string;\n readonly output: pulumi.Output<pulumi.Unwrap<T>>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["PulumiAppResource.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\n\nexport interface PulumiAppResourceConstructor<T = any, TArgs = any> {\n new (name: string, args: TArgs, opts?: pulumi.CustomResourceOptions): T;\n}\n\nexport type PulumiAppResourceType<T extends PulumiAppResourceConstructor> =\n T extends PulumiAppResourceConstructor<infer TType> ? TType : never;\n\nexport type PulumiAppResourceArgs<T extends PulumiAppResourceConstructor> =\n T extends PulumiAppResourceConstructor<any, infer TArgs> ? Exclude<TArgs, undefined> : never;\n\nexport interface CreatePulumiAppResourceParams<TConstructor extends PulumiAppResourceConstructor> {\n name: string;\n config: PulumiAppResourceArgs<TConstructor>;\n opts?: pulumi.CustomResourceOptions;\n meta?: Record<string, any>;\n}\n\nexport interface PulumiAppResourceConfigModifier<T> {\n (value: pulumi.Unwrap<T>): T | void;\n}\n\nexport interface PulumiAppResourceConfigSetter<T> {\n (value: T): void;\n (fcn: PulumiAppResourceConfigModifier<T>): void;\n}\n\nexport type PulumiAppResourceConfigProxy<T extends object> = {\n readonly [K in keyof T]-?: PulumiAppResourceConfigSetter<T[K]>;\n} & {\n clone(): T;\n};\n\nexport interface PulumiAppResource<T extends PulumiAppResourceConstructor> {\n name: string;\n type: T;\n readonly config: PulumiAppResourceConfigProxy<PulumiAppResourceArgs<T>>;\n readonly opts: pulumi.CustomResourceOptions;\n readonly meta: Record<string, any>;\n readonly output: pulumi.Output<pulumi.Unwrap<PulumiAppResourceType<T>>>;\n}\n"],"mappings":"","ignoreList":[]}
package/constants.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const DEFAULT_PROD_ENV_NAMES: string[];
package/constants.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DEFAULT_PROD_ENV_NAMES = void 0;
7
- const DEFAULT_PROD_ENV_NAMES = exports.DEFAULT_PROD_ENV_NAMES = ["prod", "production"];
8
-
9
- //# sourceMappingURL=constants.js.map
package/constants.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["DEFAULT_PROD_ENV_NAMES","exports"],"sources":["constants.ts"],"sourcesContent":["export const DEFAULT_PROD_ENV_NAMES = [\"prod\", \"production\"];\n"],"mappings":";;;;;;AAAO,MAAMA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC","ignoreList":[]}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["_createPulumiApp","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_isResourceOfType","_PulumiAppModule","_PulumiAppResource","_PulumiAppRemoteResource","_types"],"sources":["index.ts"],"sourcesContent":["export * from \"./createPulumiApp\";\nexport * from \"./isResourceOfType\";\nexport * from \"./PulumiAppModule\";\nexport * from \"./PulumiAppResource\";\nexport * from \"./PulumiAppRemoteResource\";\nexport * from \"./types\";\n"],"mappings":";;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,gBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,gBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,gBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,iBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,iBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,iBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,iBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,gBAAA,GAAAV,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AA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,MAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,MAAA,CAAAT,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiAppModuleDefinition } from \"./PulumiAppModule\";\nimport type {\n CreatePulumiAppResourceParams,\n PulumiAppResource,\n PulumiAppResourceConstructor\n} from \"./PulumiAppResource\";\nimport type { PulumiAppRemoteResource } from \"~/PulumiAppRemoteResource\";\n\nexport interface ResourceHandler {\n (resource: PulumiAppResource<PulumiAppResourceConstructor>): void;\n}\n\nexport type PulumiAppParamCallback<T> = (app: PulumiApp) => T | undefined;\nexport type PulumiAppParam<T> = T | PulumiAppParamCallback<T>;\n\nexport type PulumiProgram<TApp = PulumiApp, TResources = Record<string, any>> = (\n app: TApp\n) => TResources | Promise<TResources>;\n\nexport type CreateConfig = Record<string, any>;\nexport type RunConfig = {\n env: string;\n variant: string | undefined;\n [key: string]:\n | string\n | number\n | undefined\n | boolean\n | Record<string, string | number | boolean | undefined>;\n};\n\nexport interface CreatePulumiAppParams<TResources extends Record<string, unknown>> {\n name: string;\n path: string;\n config?: CreateConfig;\n\n program(app: PulumiApp): TResources | Promise<TResources>;\n}\n\nexport interface ProgramDecorator<TApp, TResources> {\n (program: PulumiProgram<TApp, TResources>, app: TApp): ReturnType<PulumiProgram<TResources>>;\n}\n\nexport interface PulumiApp<TResources = Record<string, unknown>> {\n resourceHandlers: ResourceHandler[];\n handlers: (() => void | Promise<void>)[];\n outputs: Record<string, any>;\n modules: Map<symbol, unknown>;\n\n paths: { absolute: string; relative: string; workspace: string };\n name: string;\n decorateProgram: <T>(\n decorator: ProgramDecorator<PulumiApp<TResources> & T, TResources>\n ) => void;\n program: PulumiProgram;\n resources: TResources;\n params: {\n create: CreateConfig;\n run: RunConfig;\n };\n env: {\n name: string;\n\n // Set to `true` if the environment into which the application is being deployed\n // is considered a production environment. The list of environment names\n // that are considered production environments is defined via the\n // `productionEnvironments` parameter. Learn more:\n // https://www.webiny.com/docs/infrastructure/basics/modify-cloud-infrastructure#defining-multiple-production-environments\n isProduction: boolean;\n };\n\n run(params: RunConfig): Record<string, any>;\n\n onResource(handler: ResourceHandler): void;\n\n addResource<T extends PulumiAppResourceConstructor>(\n resourceConstructor: T,\n params: CreatePulumiAppResourceParams<T>\n ): PulumiAppResource<T>;\n\n addRemoteResource<T>(name: string, getter: () => Promise<T>): PulumiAppRemoteResource<T>;\n\n addOutput<T>(name: string, output: T): void;\n\n addOutputs(outputs: Record<string, unknown>): void;\n\n addModule<TModule>(def: PulumiAppModuleDefinition<TModule, void>): TModule;\n\n addModule<TModule, TConfig>(\n def: PulumiAppModuleDefinition<TModule, TConfig>,\n config: TConfig\n ): TModule;\n\n getModule<TConfig, TModule>(def: PulumiAppModuleDefinition<TModule, TConfig>): TModule;\n\n getModule<TConfig, TModule>(\n def: PulumiAppModuleDefinition<TModule, TConfig>,\n opts: { optional: false }\n ): TModule;\n\n getModule<TConfig, TModule>(\n def: PulumiAppModuleDefinition<TModule, TConfig>,\n opts: { optional: true }\n ): TModule | null;\n\n addHandler<T>(handler: () => Promise<T> | T): pulumi.Output<pulumi.Unwrap<T>>;\n\n getParam<T>(param: T | ((app: PulumiApp) => T)): T | undefined;\n}\n"],"mappings":"","ignoreList":[]}