@awsless/awsless 0.0.42 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6,15 +6,13 @@ import {
6
6
  import { paramCase } from "change-case";
7
7
  var APP = process.env.APP || "app";
8
8
  var STACK = process.env.STACK || "stack";
9
+ var STAGE = process.env.STAGE || "stage";
9
10
  var getLocalResourceName = (name, stack = STACK) => {
10
11
  return `${APP}-${paramCase(stack)}-${paramCase(name)}`;
11
12
  };
12
13
  var getGlobalResourceName = (name) => {
13
14
  return `${APP}-${paramCase(name)}`;
14
15
  };
15
- var getSecretName = (name) => {
16
- return `/.awsless/${APP}/${name}`;
17
- };
18
16
 
19
17
  // src/node/function.ts
20
18
  import { invoke } from "@awsless/lambda";
@@ -145,6 +143,43 @@ var Store = createProxy((stack) => {
145
143
  });
146
144
  });
147
145
 
146
+ // src/node/config.ts
147
+ import { ssm } from "@awsless/ssm";
148
+ import { paramCase as paramCase2 } from "change-case";
149
+ var getConfigName = (name) => {
150
+ return `/.awsless/${APP}/${name}`;
151
+ };
152
+ var data = {};
153
+ var TEST = process.env.NODE_ENV === "test";
154
+ var CONFIGS = process.env.AWSLESS_CONFIG;
155
+ if (!TEST && CONFIGS) {
156
+ const keys = CONFIGS.split(",");
157
+ if (keys.length > 0) {
158
+ const paths = {};
159
+ for (const key of keys) {
160
+ paths[key] = getConfigName(key);
161
+ }
162
+ data = await ssm(paths);
163
+ }
164
+ }
165
+ var Config = new Proxy({}, {
166
+ get(_, name) {
167
+ const key = paramCase2(name);
168
+ const value = data[key];
169
+ if (typeof value === "undefined") {
170
+ throw new Error(
171
+ `The "${name}" config value hasn't been set yet. ${TEST ? `Use "Config.${name} = 'VAlUE'" to define your mock value.` : `Define access to the desired config value inside your awsless stack file.`}`
172
+ );
173
+ }
174
+ return value;
175
+ },
176
+ set(_, name, value) {
177
+ const key = paramCase2(name);
178
+ data[key] = value;
179
+ return true;
180
+ }
181
+ });
182
+
148
183
  // src/node/search.ts
149
184
  var getSearchName = getLocalResourceName;
150
185
  var Search = createProxy((stack) => {
@@ -165,6 +200,7 @@ var defineAppConfig = (config) => {
165
200
  export {
166
201
  APP,
167
202
  Cache,
203
+ Config,
168
204
  Function,
169
205
  Queue,
170
206
  STACK,
@@ -176,12 +212,12 @@ export {
176
212
  definePlugin,
177
213
  defineStackConfig,
178
214
  getCacheProps,
215
+ getConfigName,
179
216
  getFunctionName,
180
217
  getGlobalResourceName,
181
218
  getLocalResourceName,
182
219
  getQueueName,
183
220
  getSearchName,
184
- getSecretName,
185
221
  getStoreName,
186
222
  getTableName,
187
223
  getTopicName
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -14,20 +14,19 @@
14
14
  "dist"
15
15
  ],
16
16
  "bin": "./dist/bin.js",
17
- "main": "./dist/index.cjs",
18
17
  "module": "./dist/index.js",
19
18
  "types": "./dist/index.d.ts",
20
19
  "exports": {
21
20
  ".": {
22
- "require": "./dist/index.cjs",
23
21
  "import": "./dist/index.js",
24
22
  "types": "./dist/index.d.ts"
25
23
  }
26
24
  },
27
25
  "peerDependencies": {
28
26
  "@awsless/lambda": "^0.0.5",
29
- "@awsless/sns": "^0.0.5",
30
- "@awsless/sqs": "^0.0.5"
27
+ "@awsless/sns": "^0.0.6",
28
+ "@awsless/sqs": "^0.0.6",
29
+ "@awsless/ssm": "^0.0.7"
31
30
  },
32
31
  "dependencies": {
33
32
  "@aws-sdk/client-cloudformation": "^3.369.0",
@@ -64,7 +63,7 @@
64
63
  "test": "pnpm code test",
65
64
  "term": "zsh -c 'node dist/bin.js ${*} --config-file=./test/_data/config.ts' --",
66
65
  "berm": "zsh -c 'pnpm build; node dist/bin.js ${*} --config-file=./test/_data/config.ts' --",
67
- "build": "pnpm tsup src/index.ts src/bin.ts --format cjs,esm --dts --clean",
66
+ "build": "pnpm tsup src/index.ts src/bin.ts --format esm --dts --clean",
68
67
  "prepublish": "if pnpm test schema; then pnpm build; else exit; fi"
69
68
  }
70
69
  }