@awsless/awsless 0.0.38 → 0.0.40

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/bin.cjs CHANGED
@@ -1123,20 +1123,36 @@ var TypeGen = class {
1123
1123
  if (this.types.size === 0) {
1124
1124
  return;
1125
1125
  }
1126
- const imports = Array.from(this.imports.entries()).map(([varName, path]) => {
1127
- return `import ${(0, import_change_case3.camelCase)(varName)} from '${path}'`;
1128
- }).join("\n");
1126
+ const lines = [];
1127
+ if (this.imports.size > 0) {
1128
+ lines.push(...[
1129
+ "// Imports",
1130
+ ...Array.from(this.imports.entries()).map(([varName, path]) => {
1131
+ return `import ${(0, import_change_case3.camelCase)(varName)} from '${path}'`;
1132
+ }),
1133
+ ""
1134
+ ]);
1135
+ }
1136
+ if (this.codes.size > 0) {
1137
+ lines.push(...[
1138
+ "// Types",
1139
+ ...Array.from(this.codes).map((v) => v.trim()),
1140
+ ""
1141
+ ]);
1142
+ }
1129
1143
  return [
1130
- imports,
1131
- ...Array.from(this.codes),
1132
- `export {}`,
1144
+ ...lines,
1145
+ "// Extend module",
1133
1146
  `declare module '${this.module}' {`,
1134
1147
  ` interface ${this.interfaceName} {`,
1135
1148
  ...Array.from(this.types.entries()).map(([propName, type]) => {
1136
1149
  return ` readonly ${(0, import_change_case3.camelCase)(propName)}: ${type}`;
1137
1150
  }),
1138
1151
  ` }`,
1139
- `}`
1152
+ `}`,
1153
+ "",
1154
+ "// Export fix",
1155
+ `export {}`
1140
1156
  ].join("\n");
1141
1157
  }
1142
1158
  };
@@ -2114,6 +2130,18 @@ var storePlugin = definePlugin({
2114
2130
  stores: import_zod10.z.array(ResourceIdSchema).optional()
2115
2131
  }).array()
2116
2132
  }),
2133
+ onTypeGen({ config }) {
2134
+ const types2 = new TypeGen("@awsless/awsless", "StoreResources");
2135
+ for (const stack of config.stacks) {
2136
+ const list3 = new TypeObject();
2137
+ for (const name of stack.stores || []) {
2138
+ const storeName = formatName(`${config.name}-${stack.name}-${name}`);
2139
+ list3.addType(name, `{ name: '${storeName}' }`);
2140
+ }
2141
+ types2.addType(stack.name, list3.toString());
2142
+ }
2143
+ return types2.toString();
2144
+ },
2117
2145
  onStack({ config, stack, stackConfig, bind }) {
2118
2146
  for (const id of stackConfig.stores || []) {
2119
2147
  const bucket = new Bucket(id, {
@@ -3873,6 +3901,18 @@ var searchPlugin = definePlugin({
3873
3901
  searchs: import_zod18.z.array(ResourceIdSchema).optional()
3874
3902
  }).array()
3875
3903
  }),
3904
+ onTypeGen({ config }) {
3905
+ const gen = new TypeGen("@awsless/awsless", "SearchResources");
3906
+ for (const stack of config.stacks) {
3907
+ const list3 = new TypeObject();
3908
+ for (const id of stack.searchs || []) {
3909
+ const name = formatName(`${config.name}-${stack.name}-${id}`);
3910
+ list3.addType(name, `{ name: '${name}' }`);
3911
+ }
3912
+ gen.addType(stack.name, list3.toString());
3913
+ }
3914
+ return gen.toString();
3915
+ },
3876
3916
  onStack({ config, stack, stackConfig, bind }) {
3877
3917
  for (const id of stackConfig.searchs || []) {
3878
3918
  const collection = new Collection(id, {
@@ -4001,6 +4041,17 @@ var cachePlugin = definePlugin({
4001
4041
  ).optional()
4002
4042
  }).array()
4003
4043
  }),
4044
+ onTypeGen({ config }) {
4045
+ const gen = new TypeGen("@awsless/awsless", "CacheResources");
4046
+ for (const stack of config.stacks) {
4047
+ const list3 = new TypeObject();
4048
+ for (const name of Object.keys(stack.caches || {})) {
4049
+ list3.addType(name, `{ host: string, port:number }`);
4050
+ }
4051
+ gen.addType(stack.name, list3.toString());
4052
+ }
4053
+ return gen.toString();
4054
+ },
4004
4055
  onStack({ config, stack, stackConfig, bootstrap: bootstrap2, bind }) {
4005
4056
  for (const [id, props] of Object.entries(stackConfig.caches || {})) {
4006
4057
  const name = `${config.name}-${stack.name}-${id}`;
package/dist/bin.js CHANGED
@@ -1100,20 +1100,36 @@ var TypeGen = class {
1100
1100
  if (this.types.size === 0) {
1101
1101
  return;
1102
1102
  }
1103
- const imports = Array.from(this.imports.entries()).map(([varName, path]) => {
1104
- return `import ${camelCase(varName)} from '${path}'`;
1105
- }).join("\n");
1103
+ const lines = [];
1104
+ if (this.imports.size > 0) {
1105
+ lines.push(...[
1106
+ "// Imports",
1107
+ ...Array.from(this.imports.entries()).map(([varName, path]) => {
1108
+ return `import ${camelCase(varName)} from '${path}'`;
1109
+ }),
1110
+ ""
1111
+ ]);
1112
+ }
1113
+ if (this.codes.size > 0) {
1114
+ lines.push(...[
1115
+ "// Types",
1116
+ ...Array.from(this.codes).map((v) => v.trim()),
1117
+ ""
1118
+ ]);
1119
+ }
1106
1120
  return [
1107
- imports,
1108
- ...Array.from(this.codes),
1109
- `export {}`,
1121
+ ...lines,
1122
+ "// Extend module",
1110
1123
  `declare module '${this.module}' {`,
1111
1124
  ` interface ${this.interfaceName} {`,
1112
1125
  ...Array.from(this.types.entries()).map(([propName, type]) => {
1113
1126
  return ` readonly ${camelCase(propName)}: ${type}`;
1114
1127
  }),
1115
1128
  ` }`,
1116
- `}`
1129
+ `}`,
1130
+ "",
1131
+ "// Export fix",
1132
+ `export {}`
1117
1133
  ].join("\n");
1118
1134
  }
1119
1135
  };
@@ -2091,6 +2107,18 @@ var storePlugin = definePlugin({
2091
2107
  stores: z10.array(ResourceIdSchema).optional()
2092
2108
  }).array()
2093
2109
  }),
2110
+ onTypeGen({ config }) {
2111
+ const types2 = new TypeGen("@awsless/awsless", "StoreResources");
2112
+ for (const stack of config.stacks) {
2113
+ const list3 = new TypeObject();
2114
+ for (const name of stack.stores || []) {
2115
+ const storeName = formatName(`${config.name}-${stack.name}-${name}`);
2116
+ list3.addType(name, `{ name: '${storeName}' }`);
2117
+ }
2118
+ types2.addType(stack.name, list3.toString());
2119
+ }
2120
+ return types2.toString();
2121
+ },
2094
2122
  onStack({ config, stack, stackConfig, bind }) {
2095
2123
  for (const id of stackConfig.stores || []) {
2096
2124
  const bucket = new Bucket(id, {
@@ -3850,6 +3878,18 @@ var searchPlugin = definePlugin({
3850
3878
  searchs: z18.array(ResourceIdSchema).optional()
3851
3879
  }).array()
3852
3880
  }),
3881
+ onTypeGen({ config }) {
3882
+ const gen = new TypeGen("@awsless/awsless", "SearchResources");
3883
+ for (const stack of config.stacks) {
3884
+ const list3 = new TypeObject();
3885
+ for (const id of stack.searchs || []) {
3886
+ const name = formatName(`${config.name}-${stack.name}-${id}`);
3887
+ list3.addType(name, `{ name: '${name}' }`);
3888
+ }
3889
+ gen.addType(stack.name, list3.toString());
3890
+ }
3891
+ return gen.toString();
3892
+ },
3853
3893
  onStack({ config, stack, stackConfig, bind }) {
3854
3894
  for (const id of stackConfig.searchs || []) {
3855
3895
  const collection = new Collection(id, {
@@ -3978,6 +4018,17 @@ var cachePlugin = definePlugin({
3978
4018
  ).optional()
3979
4019
  }).array()
3980
4020
  }),
4021
+ onTypeGen({ config }) {
4022
+ const gen = new TypeGen("@awsless/awsless", "CacheResources");
4023
+ for (const stack of config.stacks) {
4024
+ const list3 = new TypeObject();
4025
+ for (const name of Object.keys(stack.caches || {})) {
4026
+ list3.addType(name, `{ host: string, port:number }`);
4027
+ }
4028
+ gen.addType(stack.name, list3.toString());
4029
+ }
4030
+ return gen.toString();
4031
+ },
3981
4032
  onStack({ config, stack, stackConfig, bootstrap: bootstrap2, bind }) {
3982
4033
  for (const [id, props] of Object.entries(stackConfig.caches || {})) {
3983
4034
  const name = `${config.name}-${stack.name}-${id}`;
package/dist/index.cjs CHANGED
@@ -20,8 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ APP: () => APP,
24
+ Cache: () => Cache,
23
25
  Function: () => Function,
24
26
  Queue: () => Queue,
27
+ STACK: () => STACK,
28
+ Search: () => Search,
29
+ Store: () => Store,
25
30
  Table: () => Table,
26
31
  Topic: () => Topic,
27
32
  defineAppConfig: () => defineAppConfig,
@@ -53,18 +58,9 @@ var getLocalResourceName = (name, stack = STACK) => {
53
58
  var getGlobalResourceName = (name) => {
54
59
  return `${APP}-${(0, import_change_case.paramCase)(name)}`;
55
60
  };
56
- var getSearchName = getLocalResourceName;
57
- var getStoreName = getLocalResourceName;
58
61
  var getSecretName = (name) => {
59
62
  return `/.awsless/${APP}/${name}`;
60
63
  };
61
- var getCacheProps = (name, stack = STACK) => {
62
- const prefix = `CACHE_${stack}_${name}`;
63
- return {
64
- host: process.env[`${prefix}_HOST`],
65
- port: parseInt(process.env[`${prefix}_PORT`], 10)
66
- };
67
- };
68
64
 
69
65
  // src/node/function.ts
70
66
  var import_lambda = require("@awsless/lambda");
@@ -145,6 +141,40 @@ var Queue = createProxy((stack) => {
145
141
  });
146
142
  });
147
143
 
144
+ // src/node/cache.ts
145
+ var getCacheProps = (name, stack = STACK) => {
146
+ const prefix = `CACHE_${stack}_${name}`;
147
+ return {
148
+ host: process.env[`${prefix}_HOST`],
149
+ port: parseInt(process.env[`${prefix}_PORT`], 10)
150
+ };
151
+ };
152
+ var Cache = createProxy((stack) => {
153
+ return createProxy((name) => {
154
+ return getCacheProps(name, stack);
155
+ });
156
+ });
157
+
158
+ // src/node/store.ts
159
+ var getStoreName = getLocalResourceName;
160
+ var Store = createProxy((stack) => {
161
+ return createProxy((name) => {
162
+ return {
163
+ name: getStoreName(name, stack)
164
+ };
165
+ });
166
+ });
167
+
168
+ // src/node/search.ts
169
+ var getSearchName = getLocalResourceName;
170
+ var Search = createProxy((stack) => {
171
+ return createProxy((name) => {
172
+ return {
173
+ name: getSearchName(name, stack)
174
+ };
175
+ });
176
+ });
177
+
148
178
  // src/index.ts
149
179
  var defineStackConfig = (config) => {
150
180
  return config;
@@ -154,8 +184,13 @@ var defineAppConfig = (config) => {
154
184
  };
155
185
  // Annotate the CommonJS export names for ESM import in node:
156
186
  0 && (module.exports = {
187
+ APP,
188
+ Cache,
157
189
  Function,
158
190
  Queue,
191
+ STACK,
192
+ Search,
193
+ Store,
159
194
  Table,
160
195
  Topic,
161
196
  defineAppConfig,
package/dist/index.d.ts CHANGED
@@ -2470,15 +2470,11 @@ type Plugin<S extends AnyZodObject | undefined = undefined> = {
2470
2470
  };
2471
2471
  declare const definePlugin: <S extends AnyZodObject | undefined = undefined>(plugin: Plugin<S>) => Plugin<S>;
2472
2472
 
2473
+ declare const APP: "app";
2474
+ declare const STACK: "stack";
2473
2475
  declare const getLocalResourceName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2474
2476
  declare const getGlobalResourceName: <N extends string>(name: N) => `app-${N}`;
2475
- declare const getSearchName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2476
- declare const getStoreName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2477
2477
  declare const getSecretName: (name: string) => string;
2478
- declare const getCacheProps: (name: string, stack?: "stack") => {
2479
- readonly host: string;
2480
- readonly port: number;
2481
- };
2482
2478
 
2483
2479
  declare const getFunctionName: <S extends string, N extends string>(stack: S, name: N) => `app-${S}-${N}`;
2484
2480
  interface FunctionResources {
@@ -2493,12 +2489,30 @@ declare const Table: TableResources;
2493
2489
  declare const getTopicName: <N extends string>(name: N) => `app-${N}`;
2494
2490
  interface TopicResources {
2495
2491
  }
2496
- declare const Topic: {};
2492
+ declare const Topic: TopicResources;
2497
2493
 
2498
2494
  declare const getQueueName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2499
2495
  interface QueueResources {
2500
2496
  }
2501
- declare const Queue: {};
2497
+ declare const Queue: QueueResources;
2498
+
2499
+ declare const getCacheProps: (name: string, stack?: string) => {
2500
+ readonly host: string;
2501
+ readonly port: number;
2502
+ };
2503
+ interface CacheResources {
2504
+ }
2505
+ declare const Cache: CacheResources;
2506
+
2507
+ declare const getStoreName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2508
+ interface StoreResources {
2509
+ }
2510
+ declare const Store: StoreResources;
2511
+
2512
+ declare const getSearchName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2513
+ interface SearchResources {
2514
+ }
2515
+ declare const Search: SearchResources;
2502
2516
 
2503
2517
  type AppConfig = CombinedDefaultPluginsConfigInput;
2504
2518
  type StackConfig = CombinedDefaultPluginsConfigInput['stacks'][number];
@@ -2718,4 +2732,4 @@ declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (Stack
2718
2732
  });
2719
2733
  declare const defineAppConfig: (config: AppConfig | AppConfigFactory<AppConfig>) => CombinedDefaultPluginsConfigInput | AppConfigFactory<CombinedDefaultPluginsConfigInput>;
2720
2734
 
2721
- export { AppConfig, Function, FunctionResources, Plugin, Queue, QueueResources, StackConfig, Table, TableResources, Topic, TopicResources, defineAppConfig, definePlugin, defineStackConfig, getCacheProps, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getSecretName, getStoreName, getTableName, getTopicName };
2735
+ export { APP, AppConfig, Cache, CacheResources, Function, FunctionResources, Plugin, Queue, QueueResources, STACK, Search, SearchResources, StackConfig, Store, StoreResources, Table, TableResources, Topic, TopicResources, defineAppConfig, definePlugin, defineStackConfig, getCacheProps, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getSecretName, getStoreName, getTableName, getTopicName };
package/dist/index.js CHANGED
@@ -12,18 +12,9 @@ var getLocalResourceName = (name, stack = STACK) => {
12
12
  var getGlobalResourceName = (name) => {
13
13
  return `${APP}-${paramCase(name)}`;
14
14
  };
15
- var getSearchName = getLocalResourceName;
16
- var getStoreName = getLocalResourceName;
17
15
  var getSecretName = (name) => {
18
16
  return `/.awsless/${APP}/${name}`;
19
17
  };
20
- var getCacheProps = (name, stack = STACK) => {
21
- const prefix = `CACHE_${stack}_${name}`;
22
- return {
23
- host: process.env[`${prefix}_HOST`],
24
- port: parseInt(process.env[`${prefix}_PORT`], 10)
25
- };
26
- };
27
18
 
28
19
  // src/node/function.ts
29
20
  import { invoke } from "@awsless/lambda";
@@ -104,6 +95,40 @@ var Queue = createProxy((stack) => {
104
95
  });
105
96
  });
106
97
 
98
+ // src/node/cache.ts
99
+ var getCacheProps = (name, stack = STACK) => {
100
+ const prefix = `CACHE_${stack}_${name}`;
101
+ return {
102
+ host: process.env[`${prefix}_HOST`],
103
+ port: parseInt(process.env[`${prefix}_PORT`], 10)
104
+ };
105
+ };
106
+ var Cache = createProxy((stack) => {
107
+ return createProxy((name) => {
108
+ return getCacheProps(name, stack);
109
+ });
110
+ });
111
+
112
+ // src/node/store.ts
113
+ var getStoreName = getLocalResourceName;
114
+ var Store = createProxy((stack) => {
115
+ return createProxy((name) => {
116
+ return {
117
+ name: getStoreName(name, stack)
118
+ };
119
+ });
120
+ });
121
+
122
+ // src/node/search.ts
123
+ var getSearchName = getLocalResourceName;
124
+ var Search = createProxy((stack) => {
125
+ return createProxy((name) => {
126
+ return {
127
+ name: getSearchName(name, stack)
128
+ };
129
+ });
130
+ });
131
+
107
132
  // src/index.ts
108
133
  var defineStackConfig = (config) => {
109
134
  return config;
@@ -112,8 +137,13 @@ var defineAppConfig = (config) => {
112
137
  return config;
113
138
  };
114
139
  export {
140
+ APP,
141
+ Cache,
115
142
  Function,
116
143
  Queue,
144
+ STACK,
145
+ Search,
146
+ Store,
117
147
  Table,
118
148
  Topic,
119
149
  defineAppConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -25,9 +25,9 @@
25
25
  }
26
26
  },
27
27
  "peerDependencies": {
28
+ "@awsless/sqs": "^0.0.5",
28
29
  "@awsless/lambda": "^0.0.5",
29
- "@awsless/sns": "^0.0.5",
30
- "@awsless/sqs": "^0.0.5"
30
+ "@awsless/sns": "^0.0.5"
31
31
  },
32
32
  "dependencies": {
33
33
  "@aws-sdk/client-cloudformation": "^3.369.0",