@webiny/pulumi 0.0.0-unstable.79032b23a5 → 0.0.0-unstable.7be00a75a9

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 { 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
  }
@@ -6,7 +6,7 @@ export interface PulumiAppModuleParams<TModule, TConfig> {
6
6
  name: string;
7
7
  config: PulumiAppModuleCallback<TModule, TConfig>;
8
8
  }
9
- export declare type PulumiAppModule<T extends PulumiAppModuleDefinition<any, any>> = T extends PulumiAppModuleDefinition<infer V, any> ? V : never;
9
+ export type PulumiAppModule<T extends PulumiAppModuleDefinition<any, any>> = T extends PulumiAppModuleDefinition<infer V, any> ? V : never;
10
10
  export declare class PulumiAppModuleDefinition<TModule, TConfig> {
11
11
  readonly symbol: symbol;
12
12
  readonly name: string;
@@ -1,22 +1,13 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.PulumiAppModuleDefinition = void 0;
8
- exports.createAppModule = createAppModule;
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
1
  class PulumiAppModuleDefinition {
11
- constructor(params) {
12
- (0, _defineProperty2.default)(this, "symbol", Symbol());
13
- (0, _defineProperty2.default)(this, "name", void 0);
14
- (0, _defineProperty2.default)(this, "run", void 0);
15
- this.name = params.name;
16
- this.run = params.config;
17
- }
2
+ constructor(params){
3
+ this.symbol = Symbol();
4
+ this.name = params.name;
5
+ this.run = params.config;
6
+ }
18
7
  }
19
- exports.PulumiAppModuleDefinition = PulumiAppModuleDefinition;
20
8
  function createAppModule(params) {
21
- return new PulumiAppModuleDefinition(params);
22
- }
9
+ return new PulumiAppModuleDefinition(params);
10
+ }
11
+ export { PulumiAppModuleDefinition, createAppModule };
12
+
13
+ //# sourceMappingURL=PulumiAppModule.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PulumiAppModuleDefinition","constructor","params","Symbol","name","run","config","createAppModule"],"sources":["PulumiAppModule.ts"],"sourcesContent":["import { 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;EAIrDC,WAAW,CAACC,MAA+C,EAAE;IAAA,8CAHpCC,MAAM,EAAE;IAAA;IAAA;IAI7B,IAAI,CAACC,IAAI,GAAGF,MAAM,CAACE,IAAI;IACvB,IAAI,CAACC,GAAG,GAAGH,MAAM,CAACI,MAAM;EAC5B;AACJ;AAAC;AAEM,SAASC,eAAe,CAC3BL,MAA+C,EACjD;EACE,OAAO,IAAIF,yBAAyB,CAACE,MAAM,CAAC;AAChD"}
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,4 +1,4 @@
1
- import * as pulumi from "@pulumi/pulumi";
1
+ import type * as pulumi from "@pulumi/pulumi";
2
2
  export interface PulumiAppRemoteResource<T> {
3
3
  name: string;
4
4
  readonly output: pulumi.Output<pulumi.Unwrap<T>>;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,9 +1,9 @@
1
- import * as pulumi from "@pulumi/pulumi";
1
+ import type * as pulumi from "@pulumi/pulumi";
2
2
  export interface PulumiAppResourceConstructor<T = any, TArgs = any> {
3
3
  new (name: string, args: TArgs, opts?: pulumi.CustomResourceOptions): T;
4
4
  }
5
- export declare type PulumiAppResourceType<T extends PulumiAppResourceConstructor> = T extends PulumiAppResourceConstructor<infer TType> ? TType : never;
6
- export declare type PulumiAppResourceArgs<T extends PulumiAppResourceConstructor> = T extends PulumiAppResourceConstructor<any, infer TArgs> ? Exclude<TArgs, undefined> : never;
5
+ export type PulumiAppResourceType<T extends PulumiAppResourceConstructor> = T extends PulumiAppResourceConstructor<infer TType> ? TType : never;
6
+ export type PulumiAppResourceArgs<T extends PulumiAppResourceConstructor> = T extends PulumiAppResourceConstructor<any, infer TArgs> ? Exclude<TArgs, undefined> : never;
7
7
  export interface CreatePulumiAppResourceParams<TConstructor extends PulumiAppResourceConstructor> {
8
8
  name: string;
9
9
  config: PulumiAppResourceArgs<TConstructor>;
@@ -17,8 +17,10 @@ export interface PulumiAppResourceConfigSetter<T> {
17
17
  (value: T): void;
18
18
  (fcn: PulumiAppResourceConfigModifier<T>): void;
19
19
  }
20
- export declare type PulumiAppResourceConfigProxy<T extends object> = {
20
+ export type PulumiAppResourceConfigProxy<T extends object> = {
21
21
  readonly [K in keyof T]-?: PulumiAppResourceConfigSetter<T[K]>;
22
+ } & {
23
+ clone(): T;
22
24
  };
23
25
  export interface PulumiAppResource<T extends PulumiAppResourceConstructor> {
24
26
  name: string;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
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._
package/constants.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_PROD_ENV_NAMES: string[];
package/constants.js ADDED
@@ -0,0 +1,7 @@
1
+ const DEFAULT_PROD_ENV_NAMES = [
2
+ "prod",
3
+ "production"
4
+ ];
5
+ export { DEFAULT_PROD_ENV_NAMES };
6
+
7
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const DEFAULT_PROD_ENV_NAMES = [\"prod\", \"production\"];\n"],"names":["DEFAULT_PROD_ENV_NAMES"],"mappings":"AAAO,MAAMA,yBAAyB;IAAC;IAAQ;CAAa"}
@@ -1,2 +1,2 @@
1
- import { 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,178 +1,144 @@
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"));
1
+ import { findUpSync } from "find-up";
2
+ import path from "path";
3
+ import cloneDeep from "lodash/cloneDeep.js";
4
+ import { DEFAULT_PROD_ENV_NAMES } from "./constants.js";
5
+ import * as __rspack_external__pulumi_pulumi_d0276039 from "@pulumi/pulumi";
12
6
  function createPulumiApp(params) {
13
- let projectRootPath = _findUp.default.sync("webiny.project.ts");
14
- if (projectRootPath) {
15
- projectRootPath = _path.default.dirname(projectRootPath).replace(/\\/g, "/");
16
- } else {
17
- throw new Error("Couldn't detect Webiny project.");
18
- }
19
- const appRelativePath = params.path;
20
- const appRootPath = _path.default.join(projectRootPath, appRelativePath);
21
- const projectAppWorkspacePath = _path.default.join(projectRootPath, ".webiny", "workspaces", appRelativePath);
22
- const app = {
23
- resourceHandlers: [],
24
- handlers: [],
25
- outputs: {},
26
- modules: new Map(),
27
- paths: {
28
- absolute: appRootPath,
29
- relative: appRelativePath,
30
- workspace: projectAppWorkspacePath
31
- },
32
- resources: {},
33
- name: params.name,
34
- program: params.program,
35
- params: {
36
- create: params.config || {},
37
- run: {}
38
- },
39
- async run(config) {
40
- app.params.run = config;
41
- Object.assign(app.resources, await app.program(app));
42
- for (const handler of app.handlers) {
43
- await handler();
44
- }
45
- app.params.run = {};
46
- return app.outputs;
47
- },
48
- onResource(handler) {
49
- app.resourceHandlers.push(handler);
50
- },
51
- /**
52
- * Adds a resource to pulumi app.
53
- * It's not running the script immediately, but enqueues the call.
54
- * This way we are still able to modify the config of the resource.
55
- * @param resourceConstructor Resource to be added, ie aws.s3.Bucket
56
- * @param params Parameters to configure the resource
57
- * @returns Object giving access to both resource outputs and its config.
58
- */
59
- addResource(resourceConstructor, params) {
60
- const config = params.config ?? {};
61
- const opts = params.opts ?? {};
62
- const meta = params.meta ?? {};
63
- const promise = new Promise(resolve => {
64
- app.handlers.push(() => {
65
- app.resourceHandlers.forEach(handler => handler(resource));
66
- resolve(new resourceConstructor(resource.name, config, opts));
67
- });
68
- });
69
- 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: {},
70
25
  name: params.name,
71
- type: resourceConstructor,
72
- config: createPulumiAppResourceConfigProxy(config),
73
- opts,
74
- meta,
75
- output: pulumi.output(promise)
76
- };
77
- return resource;
78
- },
79
- addRemoteResource(name, getter) {
80
- const promise = getter();
81
- const resource = {
82
- name,
83
- output: pulumi.output(promise)
84
- };
85
- return resource;
86
- },
87
- /**
88
- * Registers output value within pulumi app.
89
- * @param name Name of the output value
90
- * @param output Value of the output
91
- */
92
- addOutput(name, output) {
93
- app.outputs[name] = output;
94
- },
95
- /**
96
- * Registers one or more output values.
97
- * @param outputs Dictionary containing output values.
98
- */
99
- addOutputs(outputs) {
100
- Object.assign(app.outputs, outputs);
101
- },
102
- /**
103
- * Registers an app module within app.
104
- * Allows to decompose application into smaller pieces.
105
- * Added module can be then retrieved with `getModule`.
106
- * @param module
107
- * @param config
108
- */
109
- addModule(module, config) {
110
- if (app.modules.has(module.symbol)) {
111
- throw new Error(`Module "${module.name}" is already present in the "${app.name}" application.`);
112
- }
113
- const createdModule = module.run(app, config);
114
- app.modules.set(module.symbol, createdModule);
115
- return createdModule;
116
- },
117
- /**
118
- * Returns a module by its definition
119
- * @param def
120
- * @param opts
121
- */
122
- getModule(def, opts) {
123
- const module = app.modules.get(def.symbol);
124
- if (!module) {
125
- if (opts !== null && opts !== void 0 && opts.optional) {
126
- return null;
127
- } else {
128
- 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 productionEnvironments = app.params.create.productionEnvironments || DEFAULT_PROD_ENV_NAMES;
44
+ const isProduction = productionEnvironments.includes(app.params.run.env);
45
+ app.env = {
46
+ name: app.params.run.env,
47
+ isProduction
48
+ };
49
+ const programOutput = programDecorators.reduce((program, decorator)=>(app)=>decorator(program, app), (input)=>app.program(input));
50
+ Object.assign(app.resources, await programOutput(app));
51
+ for (const handler of app.handlers)await handler();
52
+ app.params.run = {
53
+ env: "",
54
+ variant: ""
55
+ };
56
+ return app.outputs;
57
+ },
58
+ onResource (handler) {
59
+ app.resourceHandlers.push(handler);
60
+ },
61
+ addResource (resourceConstructor, params) {
62
+ const config = params.config ?? {};
63
+ const opts = params.opts ?? {};
64
+ const meta = params.meta ?? {};
65
+ const promise = new Promise((resolve)=>{
66
+ app.handlers.push(()=>{
67
+ app.resourceHandlers.forEach((handler)=>handler(resource));
68
+ resolve(new resourceConstructor(resource.name, config, opts));
69
+ });
70
+ });
71
+ const resource = {
72
+ name: params.name,
73
+ type: resourceConstructor,
74
+ config: createPulumiAppResourceConfigProxy(config),
75
+ opts,
76
+ meta,
77
+ output: __rspack_external__pulumi_pulumi_d0276039.output(promise)
78
+ };
79
+ return resource;
80
+ },
81
+ addRemoteResource (name, getter) {
82
+ const promise = getter();
83
+ const resource = {
84
+ name,
85
+ output: __rspack_external__pulumi_pulumi_d0276039.output(promise)
86
+ };
87
+ return resource;
88
+ },
89
+ addOutput (name, output) {
90
+ app.outputs[name] = output;
91
+ },
92
+ addOutputs (outputs) {
93
+ Object.assign(app.outputs, outputs);
94
+ },
95
+ addModule (module, config) {
96
+ if (app.modules.has(module.symbol)) throw new Error(`Module "${module.name}" is already present in the "${app.name}" application.`);
97
+ const createdModule = module.run(app, config);
98
+ app.modules.set(module.symbol, createdModule);
99
+ return createdModule;
100
+ },
101
+ getModule (def, opts) {
102
+ const module = app.modules.get(def.symbol);
103
+ if (!module) if (opts?.optional) return null;
104
+ else throw new Error(`Module "${def.name}" not found in "${app.name}" app`);
105
+ return module;
106
+ },
107
+ addHandler (handler) {
108
+ const promise = new Promise((resolve)=>{
109
+ app.handlers.push(async ()=>{
110
+ resolve(await handler());
111
+ });
112
+ });
113
+ return __rspack_external__pulumi_pulumi_d0276039.output(promise);
114
+ },
115
+ getParam (param) {
116
+ if ("function" == typeof param) return param(app);
117
+ return param;
129
118
  }
130
- }
131
- return module;
132
- },
133
- /**
134
- * Schedules a handler to be executed when running pulumi script.
135
- * Anything, that is returned from handler will be wrapped in pulumi.Output
136
- * so it can be used in other places.
137
- * @param handler Handler to be executed.
138
- * @returns Result of the handler wrapped with pulumi.Output
139
- */
140
- addHandler(handler) {
141
- const promise = new Promise(resolve => {
142
- app.handlers.push(async () => {
143
- resolve(await handler());
144
- });
145
- });
146
- return pulumi.output(promise);
147
- },
148
- getParam(param) {
149
- if (typeof param === "function") {
150
- return param(app);
151
- }
152
- return param;
153
- }
154
- };
155
- return app;
119
+ };
120
+ return app;
156
121
  }
157
122
  function createPulumiAppResourceConfigProxy(obj) {
158
- return new Proxy(obj, {
159
- get(target, p) {
160
- const key = p;
161
- const setter = value => {
162
- if (typeof value === "function") {
163
- const modifier = value;
164
- const currentValue = target[key];
165
- // Wrap a current config with a function.
166
- const newValue = pulumi.output(currentValue).apply(v => {
167
- const newValue = modifier(v);
168
- return pulumi.output(newValue);
169
- });
170
- target[key] = newValue;
171
- } else {
172
- target[key] = value;
123
+ return new Proxy(obj, {
124
+ get (target, p) {
125
+ if ("clone" === p) return ()=>cloneDeep(obj);
126
+ const key = p;
127
+ const setter = (value)=>{
128
+ if ("function" == typeof value) {
129
+ const modifier = value;
130
+ const currentValue = target[key];
131
+ const newValue = __rspack_external__pulumi_pulumi_d0276039.output(currentValue).apply((v)=>{
132
+ const newValue = modifier(v);
133
+ return __rspack_external__pulumi_pulumi_d0276039.output(newValue);
134
+ });
135
+ target[key] = newValue;
136
+ } else target[key] = value;
137
+ };
138
+ return setter;
173
139
  }
174
- };
175
- return setter;
176
- }
177
- });
178
- }
140
+ });
141
+ }
142
+ export { createPulumiApp };
143
+
144
+ //# sourceMappingURL=createPulumiApp.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createPulumiApp","params","projectRootPath","findUp","sync","path","dirname","replace","Error","appRelativePath","appRootPath","join","projectAppWorkspacePath","app","resourceHandlers","handlers","outputs","modules","Map","paths","absolute","relative","workspace","resources","name","program","create","config","run","Object","assign","handler","onResource","push","addResource","resourceConstructor","opts","meta","promise","Promise","resolve","forEach","resource","type","createPulumiAppResourceConfigProxy","output","pulumi","addRemoteResource","getter","addOutput","addOutputs","addModule","module","has","symbol","createdModule","set","getModule","def","get","optional","addHandler","getParam","param","obj","Proxy","target","p","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 { PulumiAppModuleDefinition } from \"./PulumiAppModule\";\nimport {\n PulumiAppResourceArgs,\n PulumiAppResourceConstructor,\n PulumiAppResourceType,\n PulumiAppResource,\n CreatePulumiAppResourceParams,\n PulumiAppResourceConfigSetter,\n PulumiAppResourceConfigModifier,\n PulumiAppResourceConfigProxy\n} from \"./PulumiAppResource\";\nimport {\n CreatePulumiAppParams,\n PulumiApp,\n PulumiAppParam,\n PulumiAppParamCallback,\n ResourceHandler\n} from \"~/types\";\nimport { PulumiAppRemoteResource } from \"~/PulumiAppRemoteResource\";\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 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 },\n\n async run(config) {\n app.params.run = config;\n\n Object.assign(app.resources, await app.program(app));\n\n for (const handler of app.handlers) {\n await handler();\n }\n\n app.params.run = {};\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 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;AACA;AACA;AAqBO,SAASA,eAAe,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,MAA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,CAACkB,IAAI,CAAC,YAAY;UAC1BO,OAAO,CAAC,MAAMT,OAAO,EAAE,CAAC;QAC5B,CAAC,CAAC;MACN,CAAC,CAAC;MAEF,OAAOe,MAAM,CAACD,MAAM,CAACP,OAAO,CAAC;IACjC,CAAC;IAEDwB,QAAQ,CAAIC,KAAwB,EAAE;MAClC,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;QAC7B,OAAQA,KAAK,CAA+BlD,GAAG,CAAC;MACpD;MAEA,OAAOkD,KAAK;IAChB;EACJ,CAAC;EAED,OAAOlD,GAAG;AACd;AAEA,SAAS+B,kCAAkC,CAAmBoB,GAAM,EAAE;EAClE,OAAO,IAAIC,KAAK,CAACD,GAAG,EAAE;IAClBL,GAAG,CAACO,MAAM,EAAEC,CAAS,EAAE;MAEnB,MAAMC,GAAG,GAAGD,CAAY;MACxB,MAAME,MAAwC,GAC1CC,KAA6C,IAC5C;QACD,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;UAC7B,MAAMC,QAAQ,GAAGD,KAA2C;UAC5D,MAAME,YAAY,GAAGN,MAAM,CAACE,GAAG,CAAC;UAChC;UACA,MAAMK,QAAQ,GAAG3B,MAAM,CAACD,MAAM,CAAC2B,YAAY,CAAC,CAACE,KAAK,CAACC,CAAC,IAAI;YACpD,MAAMF,QAAQ,GAAGF,QAAQ,CAACI,CAAC,CAAC;YAC5B,OAAO7B,MAAM,CAACD,MAAM,CAAC4B,QAAQ,CAAC;UAClC,CAAC,CAAC;UAEFP,MAAM,CAACE,GAAG,CAAC,GAAGK,QAAwB;QAC1C,CAAC,MAAM;UACHP,MAAM,CAACE,GAAG,CAAC,GAAGE,KAAK;QACvB;MACJ,CAAC;MAED,OAAOD,MAAM;IACjB;EACJ,CAAC,CAAC;AACN"}
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 { DEFAULT_PROD_ENV_NAMES } from \"./constants.js\";\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.\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"],"names":["createPulumiApp","params","projectRootPath","findUpSync","path","Error","appRelativePath","appRootPath","projectAppWorkspacePath","programDecorators","app","Map","cb","config","productionEnvironments","DEFAULT_PROD_ENV_NAMES","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,SAAS,IAAIC;QACb,OAAO;YACH,UAAUJ;YACV,UAAUD;YACV,WAAWE;QACf;QAEA,WAAW,CAAC;QACZ,MAAMP,OAAO,IAAI;QACjB,SAASA,OAAO,OAAO;QACvB,QAAQ;YACJ,QAAQA,OAAO,MAAM,IAAI,CAAC;YAC1B,KAAK;gBACD,KAAK;gBACL,SAAS;YACb;QACJ;QACA,KAAK;YACD,MAAM;YACN,cAAc;QAClB;QACA,iBAAiBW,CAAAA;YACbH,kBAAkB,IAAI,CAACG;QAC3B;QAEA,MAAM,KAAIC,MAAM;YACZH,IAAI,MAAM,CAAC,GAAG,GAAGG;YAGjB,MAAMC,yBACFJ,IAAI,MAAM,CAAC,M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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,71 +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
- });
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 { 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,9 +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;
9
- }
2
+ return resource.type === type;
3
+ }
4
+ export { isResourceOfType };
5
+
6
+ //# sourceMappingURL=isResourceOfType.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isResourceOfType","resource","type"],"sources":["isResourceOfType.ts"],"sourcesContent":["import { 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,gBAAgB,CAC5BC,QAAyD,EACzDC,IAAO,EACyB;EAChC,OAAOD,QAAQ,CAACC,IAAI,KAAKA,IAAI;AACjC"}
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.79032b23a5",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.7be00a75a9",
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,25 +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.34.0",
18
- "find-up": "5.0.0"
20
+ "@pulumi/pulumi": "^3.242.0",
21
+ "@webiny/project": "0.0.0-unstable.7be00a75a9",
22
+ "find-up": "8.0.0",
23
+ "lodash": "4.18.1"
19
24
  },
20
25
  "devDependencies": {
21
- "@babel/cli": "^7.19.3",
22
- "@babel/core": "^7.19.3",
23
- "@types/lodash": "^4.14.190",
24
- "@webiny/cli": "^0.0.0-unstable.79032b23a5",
25
- "@webiny/project-utils": "^0.0.0-unstable.79032b23a5",
26
- "rimraf": "^3.0.2",
27
- "typescript": "4.7.4"
28
- },
29
- "scripts": {
30
- "build": "yarn webiny run build",
31
- "watch": "yarn webiny run watch"
26
+ "@types/lodash": "4.17.24",
27
+ "@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
28
+ "rimraf": "6.1.3",
29
+ "typescript": "6.0.3"
32
30
  },
33
- "gitHead": "79032b23a5e5b580fb21be88e8cc66d0dce7afdc"
31
+ "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
32
+ "webiny": {
33
+ "publishFrom": "dist"
34
+ }
34
35
  }
package/types.d.ts CHANGED
@@ -1,21 +1,29 @@
1
- import * as pulumi from "@pulumi/pulumi";
2
- import { PulumiAppModuleDefinition } from "./PulumiAppModule";
3
- import { PulumiAppResourceConstructor, PulumiAppResource, CreatePulumiAppResourceParams } from "./PulumiAppResource";
4
- import { PulumiAppRemoteResource } from "./PulumiAppRemoteResource";
1
+ import type * as pulumi from "@pulumi/pulumi";
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
  }
8
- export declare type PulumiAppParamCallback<T> = (app: PulumiApp) => T | undefined;
9
- export declare type PulumiAppParam<T> = T | PulumiAppParamCallback<T>;
10
- export declare type PulumiProgram<TResources = Record<string, any>> = (app: PulumiApp) => TResources | Promise<TResources>;
11
- export declare type CreateConfig = Record<string, any>;
12
- export declare type RunConfig = Record<string, any>;
9
+ export type PulumiAppParamCallback<T> = (app: PulumiApp) => T | undefined;
10
+ export type PulumiAppParam<T> = T | PulumiAppParamCallback<T>;
11
+ export type PulumiProgram<TApp = PulumiApp, TResources = Record<string, any>> = (app: TApp) => TResources | Promise<TResources>;
12
+ export type CreateConfig = Record<string, any>;
13
+ export type RunConfig = {
14
+ env: string;
15
+ variant: string | undefined;
16
+ [key: string]: string | number | undefined | boolean | Record<string, string | number | boolean | undefined>;
17
+ };
13
18
  export interface CreatePulumiAppParams<TResources extends Record<string, unknown>> {
14
- name: string;
19
+ name: AppName;
15
20
  path: string;
16
21
  config?: CreateConfig;
17
22
  program(app: PulumiApp): TResources | Promise<TResources>;
18
23
  }
24
+ export interface ProgramDecorator<TApp, TResources> {
25
+ (program: PulumiProgram<TApp, TResources>, app: TApp): ReturnType<PulumiProgram<TResources>>;
26
+ }
19
27
  export interface PulumiApp<TResources = Record<string, unknown>> {
20
28
  resourceHandlers: ResourceHandler[];
21
29
  handlers: (() => void | Promise<void>)[];
@@ -27,12 +35,17 @@ export interface PulumiApp<TResources = Record<string, unknown>> {
27
35
  workspace: string;
28
36
  };
29
37
  name: string;
30
- program: PulumiProgram<TResources>;
38
+ decorateProgram: <T>(decorator: ProgramDecorator<PulumiApp<TResources> & T, TResources>) => void;
39
+ program: PulumiProgram;
31
40
  resources: TResources;
32
41
  params: {
33
42
  create: CreateConfig;
34
43
  run: RunConfig;
35
44
  };
45
+ env: {
46
+ name: string;
47
+ isProduction: boolean;
48
+ };
36
49
  run(params: RunConfig): Record<string, any>;
37
50
  onResource(handler: ResourceHandler): void;
38
51
  addResource<T extends PulumiAppResourceConstructor>(resourceConstructor: T, params: CreatePulumiAppResourceParams<T>): PulumiAppResource<T>;
package/types.js CHANGED
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["PulumiAppRemoteResource.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nexport interface PulumiAppRemoteResource<T> {\n name: string;\n readonly output: pulumi.Output<pulumi.Unwrap<T>>;\n}\n"],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["PulumiAppResource.ts"],"sourcesContent":["import * 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\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":""}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"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;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
package/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport { PulumiAppModuleDefinition } from \"./PulumiAppModule\";\nimport {\n PulumiAppResourceConstructor,\n PulumiAppResource,\n CreatePulumiAppResourceParams\n} from \"./PulumiAppResource\";\nimport { 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<TResources = Record<string, any>> = (\n app: PulumiApp\n) => TResources | Promise<TResources>;\n\nexport type CreateConfig = Record<string, any>;\nexport type RunConfig = Record<string, any>;\n\nexport interface CreatePulumiAppParams<TResources extends Record<string, unknown>> {\n name: string;\n path: string;\n config?: CreateConfig;\n program(app: PulumiApp): TResources | Promise<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 program: PulumiProgram<TResources>;\n resources: TResources;\n params: {\n create: CreateConfig;\n run: RunConfig;\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 addOutputs(outputs: Record<string, unknown>): void;\n\n addModule<TModule>(def: PulumiAppModuleDefinition<TModule, void>): TModule;\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 getModule<TConfig, TModule>(\n def: PulumiAppModuleDefinition<TModule, TConfig>,\n opts: { optional: false }\n ): TModule;\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":""}