@awsless/awsless 0.0.38 → 0.0.39

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
@@ -1127,16 +1127,23 @@ var TypeGen = class {
1127
1127
  return `import ${(0, import_change_case3.camelCase)(varName)} from '${path}'`;
1128
1128
  }).join("\n");
1129
1129
  return [
1130
+ "// Imports",
1130
1131
  imports,
1131
- ...Array.from(this.codes),
1132
- `export {}`,
1132
+ "",
1133
+ "// Types",
1134
+ ...Array.from(this.codes).map((v) => v.trim()),
1135
+ "",
1136
+ "// Module",
1133
1137
  `declare module '${this.module}' {`,
1134
1138
  ` interface ${this.interfaceName} {`,
1135
1139
  ...Array.from(this.types.entries()).map(([propName, type]) => {
1136
1140
  return ` readonly ${(0, import_change_case3.camelCase)(propName)}: ${type}`;
1137
1141
  }),
1138
1142
  ` }`,
1139
- `}`
1143
+ `}`,
1144
+ "",
1145
+ "// Declare module file FIX",
1146
+ `export {}`
1140
1147
  ].join("\n");
1141
1148
  }
1142
1149
  };
@@ -2114,6 +2121,18 @@ var storePlugin = definePlugin({
2114
2121
  stores: import_zod10.z.array(ResourceIdSchema).optional()
2115
2122
  }).array()
2116
2123
  }),
2124
+ onTypeGen({ config }) {
2125
+ const types2 = new TypeGen("@awsless/awsless", "StoreResources");
2126
+ for (const stack of config.stacks) {
2127
+ const list3 = new TypeObject();
2128
+ for (const name of stack.stores || []) {
2129
+ const storeName = formatName(`${config.name}-${stack.name}-${name}`);
2130
+ list3.addType(name, `{ name: '${storeName}' }`);
2131
+ }
2132
+ types2.addType(stack.name, list3.toString());
2133
+ }
2134
+ return types2.toString();
2135
+ },
2117
2136
  onStack({ config, stack, stackConfig, bind }) {
2118
2137
  for (const id of stackConfig.stores || []) {
2119
2138
  const bucket = new Bucket(id, {
@@ -3873,6 +3892,18 @@ var searchPlugin = definePlugin({
3873
3892
  searchs: import_zod18.z.array(ResourceIdSchema).optional()
3874
3893
  }).array()
3875
3894
  }),
3895
+ onTypeGen({ config }) {
3896
+ const gen = new TypeGen("@awsless/awsless", "SearchResources");
3897
+ for (const stack of config.stacks) {
3898
+ const list3 = new TypeObject();
3899
+ for (const id of stack.searchs || []) {
3900
+ const name = formatName(`${config.name}-${stack.name}-${id}`);
3901
+ list3.addType(name, `{ name: '${name}' }`);
3902
+ }
3903
+ gen.addType(stack.name, list3.toString());
3904
+ }
3905
+ return gen.toString();
3906
+ },
3876
3907
  onStack({ config, stack, stackConfig, bind }) {
3877
3908
  for (const id of stackConfig.searchs || []) {
3878
3909
  const collection = new Collection(id, {
@@ -4001,6 +4032,17 @@ var cachePlugin = definePlugin({
4001
4032
  ).optional()
4002
4033
  }).array()
4003
4034
  }),
4035
+ onTypeGen({ config }) {
4036
+ const gen = new TypeGen("@awsless/awsless", "CacheResources");
4037
+ for (const stack of config.stacks) {
4038
+ const list3 = new TypeObject();
4039
+ for (const name of Object.keys(stack.caches || {})) {
4040
+ list3.addType(name, `{ host: string, port:number }`);
4041
+ }
4042
+ gen.addType(stack.name, list3.toString());
4043
+ }
4044
+ return gen.toString();
4045
+ },
4004
4046
  onStack({ config, stack, stackConfig, bootstrap: bootstrap2, bind }) {
4005
4047
  for (const [id, props] of Object.entries(stackConfig.caches || {})) {
4006
4048
  const name = `${config.name}-${stack.name}-${id}`;
package/dist/bin.js CHANGED
@@ -1104,16 +1104,23 @@ var TypeGen = class {
1104
1104
  return `import ${camelCase(varName)} from '${path}'`;
1105
1105
  }).join("\n");
1106
1106
  return [
1107
+ "// Imports",
1107
1108
  imports,
1108
- ...Array.from(this.codes),
1109
- `export {}`,
1109
+ "",
1110
+ "// Types",
1111
+ ...Array.from(this.codes).map((v) => v.trim()),
1112
+ "",
1113
+ "// Module",
1110
1114
  `declare module '${this.module}' {`,
1111
1115
  ` interface ${this.interfaceName} {`,
1112
1116
  ...Array.from(this.types.entries()).map(([propName, type]) => {
1113
1117
  return ` readonly ${camelCase(propName)}: ${type}`;
1114
1118
  }),
1115
1119
  ` }`,
1116
- `}`
1120
+ `}`,
1121
+ "",
1122
+ "// Declare module file FIX",
1123
+ `export {}`
1117
1124
  ].join("\n");
1118
1125
  }
1119
1126
  };
@@ -2091,6 +2098,18 @@ var storePlugin = definePlugin({
2091
2098
  stores: z10.array(ResourceIdSchema).optional()
2092
2099
  }).array()
2093
2100
  }),
2101
+ onTypeGen({ config }) {
2102
+ const types2 = new TypeGen("@awsless/awsless", "StoreResources");
2103
+ for (const stack of config.stacks) {
2104
+ const list3 = new TypeObject();
2105
+ for (const name of stack.stores || []) {
2106
+ const storeName = formatName(`${config.name}-${stack.name}-${name}`);
2107
+ list3.addType(name, `{ name: '${storeName}' }`);
2108
+ }
2109
+ types2.addType(stack.name, list3.toString());
2110
+ }
2111
+ return types2.toString();
2112
+ },
2094
2113
  onStack({ config, stack, stackConfig, bind }) {
2095
2114
  for (const id of stackConfig.stores || []) {
2096
2115
  const bucket = new Bucket(id, {
@@ -3850,6 +3869,18 @@ var searchPlugin = definePlugin({
3850
3869
  searchs: z18.array(ResourceIdSchema).optional()
3851
3870
  }).array()
3852
3871
  }),
3872
+ onTypeGen({ config }) {
3873
+ const gen = new TypeGen("@awsless/awsless", "SearchResources");
3874
+ for (const stack of config.stacks) {
3875
+ const list3 = new TypeObject();
3876
+ for (const id of stack.searchs || []) {
3877
+ const name = formatName(`${config.name}-${stack.name}-${id}`);
3878
+ list3.addType(name, `{ name: '${name}' }`);
3879
+ }
3880
+ gen.addType(stack.name, list3.toString());
3881
+ }
3882
+ return gen.toString();
3883
+ },
3853
3884
  onStack({ config, stack, stackConfig, bind }) {
3854
3885
  for (const id of stackConfig.searchs || []) {
3855
3886
  const collection = new Collection(id, {
@@ -3978,6 +4009,17 @@ var cachePlugin = definePlugin({
3978
4009
  ).optional()
3979
4010
  }).array()
3980
4011
  }),
4012
+ onTypeGen({ config }) {
4013
+ const gen = new TypeGen("@awsless/awsless", "CacheResources");
4014
+ for (const stack of config.stacks) {
4015
+ const list3 = new TypeObject();
4016
+ for (const name of Object.keys(stack.caches || {})) {
4017
+ list3.addType(name, `{ host: string, port:number }`);
4018
+ }
4019
+ gen.addType(stack.name, list3.toString());
4020
+ }
4021
+ return gen.toString();
4022
+ },
3981
4023
  onStack({ config, stack, stackConfig, bootstrap: bootstrap2, bind }) {
3982
4024
  for (const [id, props] of Object.entries(stackConfig.caches || {})) {
3983
4025
  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.39",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {