@awsless/awsless 0.0.77 → 0.0.79

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.js CHANGED
@@ -1525,9 +1525,9 @@ var typeGenCode = `
1525
1525
  import { InvokeOptions } from '@awsless/lambda'
1526
1526
 
1527
1527
  type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
1528
- name: Name
1528
+ readonly name: Name
1529
+ readonly async: (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1529
1530
  (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>): ReturnType<Func>
1530
- async: (payload: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1531
1531
  }`;
1532
1532
  var functionPlugin = definePlugin({
1533
1533
  name: "function",
@@ -1616,8 +1616,12 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
1616
1616
  resources: ["*"]
1617
1617
  });
1618
1618
  }
1619
- ctx.bind((other) => {
1620
- other.addPermissions(lambda.permissions);
1619
+ lambda.addPermissions({
1620
+ actions: [
1621
+ "lambda:InvokeFunction",
1622
+ "lambda:InvokeAsync"
1623
+ ],
1624
+ resources: ["*"]
1621
1625
  });
1622
1626
  return lambda;
1623
1627
  };
@@ -1800,8 +1804,8 @@ import { SendMessageOptions, SendMessageBatchOptions, BatchItem } from '@awsless
1800
1804
  type Payload<Func extends (...args: any[]) => any> = Parameters<Func>[0]['Records'][number]['body']
1801
1805
 
1802
1806
  type Send<Name extends string, Func extends (...args: any[]) => any> = {
1803
- name: Name
1804
- batch(items:BatchItem<Payload<Func>>[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
1807
+ readonly name: Name
1808
+ readonly batch(items:BatchItem<Payload<Func>>[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
1805
1809
  (payload: Payload<Func>, options?: Omit<SendMessageOptions, 'queue' | 'payload'>): Promise<void>
1806
1810
  }`;
1807
1811
  var queuePlugin = definePlugin({
@@ -2197,7 +2201,7 @@ var tablePlugin = definePlugin({
2197
2201
  const list3 = new TypeObject();
2198
2202
  for (const name of Object.keys(stack.tables || {})) {
2199
2203
  const tableName = formatName(`${config.name}-${stack.name}-${name}`);
2200
- list3.addType(name, `{ name: '${tableName}' }`);
2204
+ list3.addType(name, `{ readonly name: '${tableName}' }`);
2201
2205
  }
2202
2206
  types2.addType(stack.name, list3.toString());
2203
2207
  }
@@ -2329,7 +2333,7 @@ var storePlugin = definePlugin({
2329
2333
  const list3 = new TypeObject();
2330
2334
  for (const name of stack.stores || []) {
2331
2335
  const storeName = formatName(`${config.name}-${stack.name}-${name}`);
2332
- list3.addType(name, `{ name: '${storeName}' }`);
2336
+ list3.addType(name, `{ readonly name: '${storeName}' }`);
2333
2337
  }
2334
2338
  types2.addType(stack.name, list3.toString());
2335
2339
  }
@@ -2428,8 +2432,8 @@ var typeGenCode3 = `
2428
2432
  import { PublishOptions } from '@awsless/sns'
2429
2433
 
2430
2434
  type Publish<Name extends string> = {
2431
- name: Name
2432
- (payload: unknown, options?: Omit<PublishOptions, 'topic' | 'payload'>): Promise<void>
2435
+ readonly name: Name
2436
+ readonly (payload: unknown, options?: Omit<PublishOptions, 'topic' | 'payload'>): Promise<void>
2433
2437
  }`;
2434
2438
  var topicPlugin = definePlugin({
2435
2439
  name: "topic",
@@ -4152,7 +4156,7 @@ var searchPlugin = definePlugin({
4152
4156
  const list3 = new TypeObject();
4153
4157
  for (const id of stack.searchs || []) {
4154
4158
  const name = formatName(`${config.name}-${stack.name}-${id}`);
4155
- list3.addType(name, `{ name: '${name}' }`);
4159
+ list3.addType(name, `{ readonly name: '${name}' }`);
4156
4160
  }
4157
4161
  gen.addType(stack.name, list3.toString());
4158
4162
  }
@@ -4292,7 +4296,7 @@ var cachePlugin = definePlugin({
4292
4296
  for (const stack of config.stacks) {
4293
4297
  const list3 = new TypeObject();
4294
4298
  for (const name of Object.keys(stack.caches || {})) {
4295
- list3.addType(name, `{ host: string, port: number }`);
4299
+ list3.addType(name, `{ readonly host: string, readonly port: number }`);
4296
4300
  }
4297
4301
  gen.addType(stack.name, list3.toString());
4298
4302
  }
@@ -5835,7 +5839,7 @@ var authPlugin = definePlugin({
5835
5839
  onTypeGen({ config }) {
5836
5840
  const gen = new TypeGen("@awsless/awsless", "AuthResources");
5837
5841
  for (const name of Object.keys(config.defaults.auth)) {
5838
- gen.addType(name, `{ name: '${formatName(name)}' }`);
5842
+ gen.addType(name, `{ readonly name: '${formatName(`${config.name}-${name}`)}' }`);
5839
5843
  }
5840
5844
  return gen.toString();
5841
5845
  },
@@ -6271,7 +6275,7 @@ var importConfig = async (options) => {
6271
6275
  credentials
6272
6276
  };
6273
6277
  };
6274
- var watchConfig = async function* (options) {
6278
+ var watchConfig = async (options, resolve, reject) => {
6275
6279
  debug("Find the root directory");
6276
6280
  const configFile = options.configFile || "awsless.config.ts";
6277
6281
  const root2 = await findRootDir(process.cwd(), configFile);
@@ -6297,20 +6301,22 @@ var watchConfig = async function* (options) {
6297
6301
  config = await schema2.parseAsync(appConfig);
6298
6302
  } catch (error) {
6299
6303
  if (error instanceof z30.ZodError) {
6300
- throw new ConfigError(error, appConfig);
6304
+ reject(new ConfigError(error, appConfig));
6305
+ continue;
6301
6306
  }
6302
- throw error;
6307
+ reject(error);
6308
+ continue;
6303
6309
  }
6304
6310
  debug("Load credentials", style.info(config.profile));
6305
6311
  const credentials = getCredentials(config.profile);
6306
6312
  debug("Load AWS account ID");
6307
6313
  const account = await getAccountId(credentials, config.region);
6308
6314
  debug("Account ID:", style.info(account));
6309
- yield {
6315
+ resolve({
6310
6316
  ...config,
6311
6317
  account,
6312
6318
  credentials
6313
- };
6319
+ });
6314
6320
  }
6315
6321
  };
6316
6322
 
@@ -7813,10 +7819,20 @@ var dev = (program2) => {
7813
7819
  program2.command("dev").description("Start the development service").action(async () => {
7814
7820
  await layout(async (_, write) => {
7815
7821
  const options = program2.optsWithGlobals();
7816
- for await (const config of watchConfig(options)) {
7822
+ await watchConfig(options, async (config) => {
7817
7823
  await cleanUp();
7818
7824
  await write(typesGenerator(config));
7819
- }
7825
+ }, (error) => {
7826
+ if (error instanceof ConfigError) {
7827
+ write(zodError(error.error, error.data));
7828
+ } else if (error instanceof Error) {
7829
+ write(dialog("error", [error.message]));
7830
+ } else if (typeof error === "string") {
7831
+ write(dialog("error", [error]));
7832
+ } else {
7833
+ write(dialog("error", [JSON.stringify(error)]));
7834
+ }
7835
+ });
7820
7836
  });
7821
7837
  });
7822
7838
  };
package/dist/index.d.ts CHANGED
@@ -8489,6 +8489,11 @@ interface FunctionResources {
8489
8489
  }
8490
8490
  declare const Function: FunctionResources;
8491
8491
 
8492
+ declare const getAuthName: <N extends string>(name: N) => `app-${N}`;
8493
+ interface AuthResources {
8494
+ }
8495
+ declare const Auth: AuthResources;
8496
+
8492
8497
  declare const getTableName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
8493
8498
  interface TableResources {
8494
8499
  }
@@ -9097,4 +9102,4 @@ declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (Stack
9097
9102
  });
9098
9103
  declare const defineAppConfig: (config: AppConfig | AppConfigFactory<AppConfig>) => CombinedDefaultPluginsConfigInput | AppConfigFactory<CombinedDefaultPluginsConfigInput>;
9099
9104
 
9100
- export { APP, AppConfig, Cache, CacheResources, Config, ConfigResources, Function, FunctionResources, Plugin, Queue, QueueResources, STACK, Search, SearchResources, StackConfig, Store, StoreResources, Table, TableResources, Topic, TopicResources, defineAppConfig, definePlugin, defineStackConfig, getCacheProps, getConfigName, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getStoreName, getTableName, getTopicName };
9105
+ export { APP, AppConfig, Auth, AuthResources, Cache, CacheResources, Config, ConfigResources, Function, FunctionResources, Plugin, Queue, QueueResources, STACK, Search, SearchResources, StackConfig, Store, StoreResources, Table, TableResources, Topic, TopicResources, defineAppConfig, definePlugin, defineStackConfig, getAuthName, getCacheProps, getConfigName, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getStoreName, getTableName, getTopicName };
package/dist/index.js CHANGED
@@ -59,6 +59,14 @@ var Function = /* @__PURE__ */ createProxy((stackName) => {
59
59
  });
60
60
  });
61
61
 
62
+ // src/node/auth.ts
63
+ var getAuthName = getGlobalResourceName;
64
+ var Auth = /* @__PURE__ */ createProxy((name) => {
65
+ return {
66
+ name: getAuthName(name)
67
+ };
68
+ });
69
+
62
70
  // src/node/table.ts
63
71
  var getTableName = getLocalResourceName;
64
72
  var Table = /* @__PURE__ */ createProxy((stack) => {
@@ -209,6 +217,7 @@ var defineAppConfig = (config) => {
209
217
  };
210
218
  export {
211
219
  APP,
220
+ Auth,
212
221
  Cache,
213
222
  Config,
214
223
  Function,
@@ -221,6 +230,7 @@ export {
221
230
  defineAppConfig,
222
231
  definePlugin,
223
232
  defineStackConfig,
233
+ getAuthName,
224
234
  getCacheProps,
225
235
  getConfigName,
226
236
  getFunctionName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -26,8 +26,8 @@
26
26
  "peerDependencies": {
27
27
  "@awsless/lambda": "^0.0.6",
28
28
  "@awsless/sns": "^0.0.6",
29
- "@awsless/sqs": "^0.0.6",
30
- "@awsless/ssm": "^0.0.7"
29
+ "@awsless/ssm": "^0.0.7",
30
+ "@awsless/sqs": "^0.0.6"
31
31
  },
32
32
  "dependencies": {
33
33
  "@aws-sdk/client-cloudformation": "^3.369.0",