@awsless/awsless 0.0.35 → 0.0.37

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
@@ -998,7 +998,7 @@ var hasOnFailure = (config) => {
998
998
  };
999
999
 
1000
1000
  // src/plugins/function.ts
1001
- import { camelCase, paramCase as paramCase3 } from "change-case";
1001
+ import { camelCase as camelCase2 } from "change-case";
1002
1002
 
1003
1003
  // src/util/path.ts
1004
1004
  import { lstat } from "fs/promises";
@@ -1048,7 +1048,96 @@ var fileExist = async (file) => {
1048
1048
  };
1049
1049
 
1050
1050
  // src/plugins/function.ts
1051
- import { relative } from "path";
1051
+ import { relative as relative2 } from "path";
1052
+
1053
+ // src/util/type-gen.ts
1054
+ import { mkdir, writeFile } from "fs/promises";
1055
+ import { join as join2, relative } from "path";
1056
+ import { camelCase } from "change-case";
1057
+ var generateResourceTypes = async (config) => {
1058
+ const plugins = [
1059
+ ...defaultPlugins,
1060
+ ...config.plugins || []
1061
+ ];
1062
+ const files = [];
1063
+ for (const plugin of plugins) {
1064
+ const code = plugin.onTypeGen?.({ config });
1065
+ if (code) {
1066
+ const file = join2(directories.types, `${plugin.name}.d.ts`);
1067
+ files.push(relative(directories.root, file));
1068
+ await mkdir(directories.types, { recursive: true });
1069
+ await writeFile(file, code);
1070
+ }
1071
+ }
1072
+ if (files.length) {
1073
+ const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
1074
+ await writeFile(join2(directories.root, `awsless.d.ts`), code);
1075
+ }
1076
+ };
1077
+ var TypeGen = class {
1078
+ constructor(module, interfaceName) {
1079
+ this.module = module;
1080
+ this.interfaceName = interfaceName;
1081
+ }
1082
+ codes = /* @__PURE__ */ new Set();
1083
+ types = /* @__PURE__ */ new Map();
1084
+ imports = /* @__PURE__ */ new Map();
1085
+ addImport(varName, path) {
1086
+ this.imports.set(varName, path);
1087
+ return this;
1088
+ }
1089
+ addCode(code) {
1090
+ this.codes.add(code);
1091
+ return this;
1092
+ }
1093
+ addType(name, type) {
1094
+ if (type) {
1095
+ this.types.set(name, type);
1096
+ }
1097
+ return this;
1098
+ }
1099
+ toString() {
1100
+ if (this.types.size === 0) {
1101
+ return;
1102
+ }
1103
+ const imports = Array.from(this.imports.entries()).map(([varName, path]) => {
1104
+ return `import ${camelCase(varName)} from '${path}'`;
1105
+ }).join("\n");
1106
+ return [
1107
+ imports,
1108
+ ...Array.from(this.codes),
1109
+ `export {}`,
1110
+ `declare module '${this.module}' {`,
1111
+ ` interface ${this.interfaceName} {`,
1112
+ ...Array.from(this.types.entries()).map(([propName, type]) => {
1113
+ return ` readonly ${camelCase(propName)}: ${type}`;
1114
+ }),
1115
+ ` }`,
1116
+ `}`
1117
+ ].join("\n");
1118
+ }
1119
+ };
1120
+ var TypeObject = class {
1121
+ types = /* @__PURE__ */ new Map();
1122
+ addType(name, type) {
1123
+ this.types.set(name, type);
1124
+ return this;
1125
+ }
1126
+ toString() {
1127
+ if (!this.types.size) {
1128
+ return "";
1129
+ }
1130
+ return [
1131
+ "{",
1132
+ ...Array.from(this.types.entries()).map(([propName, type]) => {
1133
+ return ` readonly ${camelCase(propName)}: ${type}`;
1134
+ }),
1135
+ " }"
1136
+ ].join("\n");
1137
+ }
1138
+ };
1139
+
1140
+ // src/plugins/function.ts
1052
1141
  var MemorySizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum memory size is 10 GB");
1053
1142
  var TimeoutSchema = DurationSchema.refine(durationMin(Duration.seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(Duration.minutes(15)), "Maximum timeout duration is 15 minutes");
1054
1143
  var EphemeralStorageSizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(512)), "Minimum ephemeral storage size is 512 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum ephemeral storage size is 10 GB");
@@ -1183,51 +1272,33 @@ var schema = z6.object({
1183
1272
  ).optional()
1184
1273
  }).array()
1185
1274
  });
1275
+ var typeGenCode = `
1276
+ import { InvokeOptions } from '@awsless/lambda'
1277
+
1278
+ type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
1279
+ name: Name
1280
+ invoke: (event: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>) => ReturnType<Func>
1281
+ async: (event: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1282
+ }`;
1186
1283
  var functionPlugin = definePlugin({
1187
1284
  name: "function",
1188
1285
  schema,
1189
1286
  onTypeGen({ config }) {
1190
- const imports = [];
1191
- const props = [];
1287
+ const types2 = new TypeGen("@awsless/awsless", "FunctionResources");
1288
+ types2.addCode(typeGenCode);
1192
1289
  for (const stack of config.stacks) {
1193
- const functions = [];
1290
+ const list3 = new TypeObject();
1194
1291
  for (const [name, fileOrProps] of Object.entries(stack.functions || {})) {
1195
- const varName = camelCase(`${stack.name}-${name}`);
1196
- const funcName = paramCase3(`${config.name}-${stack.name}--${name}`);
1292
+ const varName = camelCase2(`${stack.name}-${name}`);
1293
+ const funcName = formatName(`${config.name}-${stack.name}-${name}`);
1197
1294
  const file = typeof fileOrProps === "string" ? fileOrProps : fileOrProps.file;
1198
- const relFile = relative(directories.types, file);
1199
- imports.push(`import ${varName} from '${relFile}'`);
1200
- functions.push(` readonly ${camelCase(name)}: Invoke<'${funcName}', typeof ${varName}>`);
1295
+ const relFile = relative2(directories.types, file);
1296
+ types2.addImport(varName, relFile);
1297
+ list3.addType(name, `Invoke<'${funcName}', typeof ${varName}>`);
1201
1298
  }
1202
- if (functions.length > 0) {
1203
- props.push(` readonly ${camelCase(stack.name)}: {
1204
- ${functions.join("\n")}
1205
- }`);
1206
- }
1207
- }
1208
- if (imports.length === 0) {
1209
- return;
1299
+ types2.addType(stack.name, list3.toString());
1210
1300
  }
1211
- return (
1212
- /* TS */
1213
- `
1214
- ${imports.join("\n")}
1215
-
1216
- import { InvokeOptions } from '@awsless/lambda'
1217
-
1218
- type Options = Omit<InvokeOptions, 'name' | 'payload'>
1219
-
1220
- type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
1221
- name: Name
1222
- invoke: (event: Parameters<Func>[0], options?: Options) => ReturnType<Func>
1223
- }
1224
-
1225
- declare module '@awsless/awsless' {
1226
- interface FunctionResources {
1227
- ${props.join("\n")}
1228
- }
1229
- }`
1230
- );
1301
+ return types2.toString();
1231
1302
  },
1232
1303
  onStack(ctx) {
1233
1304
  const { config, stack } = ctx;
@@ -1628,6 +1699,18 @@ var queuePlugin = definePlugin({
1628
1699
  ).optional()
1629
1700
  }).array()
1630
1701
  }),
1702
+ onTypeGen({ config }) {
1703
+ const types2 = new TypeGen("@awsless/awsless", "QueueResources");
1704
+ for (const stack of config.stacks) {
1705
+ const list3 = new TypeObject();
1706
+ for (const name of Object.keys(stack.queues || {})) {
1707
+ const queueName = formatName(`${config.name}-${stack.name}-${name}`);
1708
+ list3.addType(name, `{ name: '${queueName}' }`);
1709
+ }
1710
+ types2.addType(stack.name, list3.toString());
1711
+ }
1712
+ return types2.toString();
1713
+ },
1631
1714
  onStack(ctx) {
1632
1715
  const { stack, config, stackConfig, bind } = ctx;
1633
1716
  for (const [id, functionOrProps] of Object.entries(stackConfig.queues || {})) {
@@ -1901,6 +1984,18 @@ var tablePlugin = definePlugin({
1901
1984
  ).optional()
1902
1985
  }).array()
1903
1986
  }),
1987
+ onTypeGen({ config }) {
1988
+ const types2 = new TypeGen("@awsless/awsless", "TableResources");
1989
+ for (const stack of config.stacks) {
1990
+ const list3 = new TypeObject();
1991
+ for (const name of Object.keys(stack.tables || {})) {
1992
+ const tableName = formatName(`${config.name}-${stack.name}-${name}`);
1993
+ list3.addType(name, `{ name: '${tableName}' }`);
1994
+ }
1995
+ types2.addType(stack.name, list3.toString());
1996
+ }
1997
+ return types2.toString();
1998
+ },
1904
1999
  onStack(ctx) {
1905
2000
  const { config, stack, stackConfig, bind } = ctx;
1906
2001
  for (const [id, props] of Object.entries(stackConfig.tables || {})) {
@@ -2087,6 +2182,16 @@ var topicPlugin = definePlugin({
2087
2182
  topics: z11.record(ResourceIdSchema, FunctionSchema).optional()
2088
2183
  }).array()
2089
2184
  }),
2185
+ onTypeGen({ config }) {
2186
+ const gen = new TypeGen("@awsless/awsless", "TopicResources");
2187
+ for (const stack of config.stacks) {
2188
+ for (const topic of Object.keys(stack.topics || {})) {
2189
+ const name = formatName(`${config.name}-${topic}`);
2190
+ gen.addType(topic, `{ name: '${name}' }`);
2191
+ }
2192
+ }
2193
+ return gen.toString();
2194
+ },
2090
2195
  onApp({ config, bootstrap: bootstrap2, bind }) {
2091
2196
  const allTopicNames = config.stacks.map((stack) => {
2092
2197
  return Object.keys(stack.topics || {});
@@ -2251,7 +2356,7 @@ var toArray = (value) => {
2251
2356
  };
2252
2357
 
2253
2358
  // src/plugins/graphql.ts
2254
- import { paramCase as paramCase4 } from "change-case";
2359
+ import { paramCase as paramCase3 } from "change-case";
2255
2360
 
2256
2361
  // src/formation/resource/appsync/graphql-api.ts
2257
2362
  import { constantCase as constantCase3 } from "change-case";
@@ -2684,7 +2789,7 @@ var graphqlPlugin = definePlugin({
2684
2789
  const apiId = bootstrap2.import(`graphql-${id}`);
2685
2790
  for (const [typeAndField, functionProps] of Object.entries(props.resolvers || {})) {
2686
2791
  const [typeName, fieldName] = typeAndField.split(/[\s]+/g);
2687
- const entryId = paramCase4(`${id}-${typeName}-${fieldName}`);
2792
+ const entryId = paramCase3(`${id}-${typeName}-${fieldName}`);
2688
2793
  const lambda = toLambdaFunction(ctx, `graphql-${entryId}`, functionProps);
2689
2794
  const source = new AppsyncEventSource(entryId, lambda, {
2690
2795
  apiId,
@@ -4141,7 +4246,7 @@ var toApp = async (config, filters) => {
4141
4246
  };
4142
4247
 
4143
4248
  // src/config.ts
4144
- import { join as join3 } from "path";
4249
+ import { join as join4 } from "path";
4145
4250
 
4146
4251
  // src/util/account.ts
4147
4252
  import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
@@ -4225,11 +4330,12 @@ var AppSchema = z23.object({
4225
4330
  });
4226
4331
 
4227
4332
  // src/util/import.ts
4228
- import { rollup as rollup2 } from "rollup";
4333
+ import { rollup as rollup2, watch } from "rollup";
4229
4334
  import { swc as swc2 } from "rollup-plugin-swc3";
4230
4335
  import replace from "rollup-plugin-replace";
4231
- import { dirname as dirname2, join as join2 } from "path";
4232
- import { mkdir, writeFile } from "fs/promises";
4336
+ import { EventIterator } from "event-iterator";
4337
+ import { dirname as dirname2, join as join3 } from "path";
4338
+ import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
4233
4339
  var importFile = async (path) => {
4234
4340
  const bundle = await rollup2({
4235
4341
  input: path,
@@ -4248,18 +4354,73 @@ var importFile = async (path) => {
4248
4354
  })
4249
4355
  ]
4250
4356
  });
4251
- const outputFile = join2(directories.cache, "config.js");
4357
+ const outputFile = join3(directories.cache, "config.js");
4252
4358
  const result = await bundle.generate({
4253
4359
  format: "esm",
4254
4360
  exports: "default"
4255
4361
  });
4256
4362
  const output = result.output[0];
4257
4363
  const code = output.code;
4258
- await mkdir(directories.cache, { recursive: true });
4259
- await writeFile(outputFile, code);
4364
+ await mkdir2(directories.cache, { recursive: true });
4365
+ await writeFile2(outputFile, code);
4260
4366
  debug("Save config file:", style.info(outputFile));
4261
4367
  return import(outputFile);
4262
4368
  };
4369
+ var watchFile = (path) => {
4370
+ return new EventIterator((queue2) => {
4371
+ const watcher = watch({
4372
+ watch: {
4373
+ skipWrite: true
4374
+ },
4375
+ input: path,
4376
+ onwarn: (error) => {
4377
+ debugError(error.message);
4378
+ },
4379
+ plugins: [
4380
+ replace({
4381
+ __dirname: (id) => `'${dirname2(id)}'`
4382
+ }),
4383
+ swc2({
4384
+ minify: false,
4385
+ jsc: {
4386
+ baseUrl: dirname2(path)
4387
+ }
4388
+ })
4389
+ ]
4390
+ });
4391
+ let resume;
4392
+ queue2.on("lowWater", () => {
4393
+ resume?.(true);
4394
+ });
4395
+ watcher.on("close", queue2.stop);
4396
+ watcher.on("event", async (event) => {
4397
+ if (event.code === "ERROR") {
4398
+ queue2.fail(new Error(event.error.message));
4399
+ }
4400
+ if (event.code === "BUNDLE_END") {
4401
+ const result = await event.result.generate({
4402
+ format: "esm",
4403
+ exports: "default"
4404
+ });
4405
+ event.result.close();
4406
+ const output = result.output[0];
4407
+ const code = output.code;
4408
+ const outputFile = join3(directories.cache, "config.js");
4409
+ await mkdir2(directories.cache, { recursive: true });
4410
+ await writeFile2(outputFile, code);
4411
+ debug("Save config file:", style.info(outputFile));
4412
+ const config = await import(`${outputFile}?${Date.now()}`);
4413
+ queue2.push(config);
4414
+ }
4415
+ });
4416
+ return () => {
4417
+ watcher.close();
4418
+ };
4419
+ }, {
4420
+ highWaterMark: 1,
4421
+ lowWaterMark: 0
4422
+ });
4423
+ };
4263
4424
 
4264
4425
  // src/config.ts
4265
4426
  var importConfig = async (options) => {
@@ -4269,7 +4430,7 @@ var importConfig = async (options) => {
4269
4430
  setRoot(root2);
4270
4431
  debug("CWD:", style.info(root2));
4271
4432
  debug("Import config file");
4272
- const fileName = join3(root2, configFile);
4433
+ const fileName = join4(root2, configFile);
4273
4434
  const module = await importFile(fileName);
4274
4435
  const appConfig = typeof module.default === "function" ? await module.default(options) : module.default;
4275
4436
  debug("Validate config file");
@@ -4295,6 +4456,40 @@ var importConfig = async (options) => {
4295
4456
  credentials
4296
4457
  };
4297
4458
  };
4459
+ var watchConfig = async function* (options) {
4460
+ debug("Find the root directory");
4461
+ const configFile = options.configFile || "awsless.config.ts";
4462
+ const root2 = await findRootDir(process.cwd(), configFile);
4463
+ setRoot(root2);
4464
+ debug("CWD:", style.info(root2));
4465
+ debug("Import config file");
4466
+ const fileName = join4(root2, configFile);
4467
+ for await (const module of watchFile(fileName)) {
4468
+ const appConfig = typeof module.default === "function" ? await module.default(options) : module.default;
4469
+ debug("Validate config file");
4470
+ const plugins = [
4471
+ ...defaultPlugins,
4472
+ ...appConfig.plugins || []
4473
+ ];
4474
+ let schema2 = AppSchema;
4475
+ for (const plugin of plugins) {
4476
+ if (plugin.schema) {
4477
+ schema2 = schema2.and(plugin.schema);
4478
+ }
4479
+ }
4480
+ const config = await schema2.parseAsync(appConfig);
4481
+ debug("Load credentials", style.info(config.profile));
4482
+ const credentials = getCredentials(config.profile);
4483
+ debug("Load AWS account ID");
4484
+ const account = await getAccountId(credentials, config.region);
4485
+ debug("Account ID:", style.info(account));
4486
+ yield {
4487
+ ...config,
4488
+ account,
4489
+ credentials
4490
+ };
4491
+ }
4492
+ };
4298
4493
 
4299
4494
  // src/cli/ui/layout/basic.ts
4300
4495
  var br = () => {
@@ -4770,7 +4965,7 @@ var layout = async (cb) => {
4770
4965
  };
4771
4966
 
4772
4967
  // src/cli/ui/complex/builder.ts
4773
- import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
4968
+ import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
4774
4969
 
4775
4970
  // src/cli/ui/layout/flex-line.ts
4776
4971
  var stripEscapeCode = (str) => {
@@ -4793,7 +4988,7 @@ var flexLine = (term, left, right, reserveSpace = 0) => {
4793
4988
  };
4794
4989
 
4795
4990
  // src/cli/ui/complex/builder.ts
4796
- import { dirname as dirname3, join as join4 } from "path";
4991
+ import { dirname as dirname3, join as join5 } from "path";
4797
4992
  var assetBuilder = (app) => {
4798
4993
  return async (term) => {
4799
4994
  const assets = [];
@@ -4856,10 +5051,10 @@ var assetBuilder = (app) => {
4856
5051
  try {
4857
5052
  const data = await asset.build({
4858
5053
  async write(file, data2) {
4859
- const fullpath = join4(directories.asset, asset.type, app.name, stack.name, asset.id, file);
5054
+ const fullpath = join5(directories.asset, asset.type, app.name, stack.name, asset.id, file);
4860
5055
  const basepath = dirname3(fullpath);
4861
- await mkdir2(basepath, { recursive: true });
4862
- await writeFile2(fullpath, data2);
5056
+ await mkdir3(basepath, { recursive: true });
5057
+ await writeFile3(fullpath, data2);
4863
5058
  }
4864
5059
  });
4865
5060
  details.set({
@@ -4883,7 +5078,7 @@ var assetBuilder = (app) => {
4883
5078
  };
4884
5079
 
4885
5080
  // src/util/cleanup.ts
4886
- import { mkdir as mkdir3, rm } from "fs/promises";
5081
+ import { mkdir as mkdir4, rm } from "fs/promises";
4887
5082
  var cleanUp = async () => {
4888
5083
  debug("Clean up template, cache, and asset files");
4889
5084
  const paths = [
@@ -4897,52 +5092,28 @@ var cleanUp = async () => {
4897
5092
  force: true,
4898
5093
  maxRetries: 2
4899
5094
  })));
4900
- await Promise.all(paths.map((path) => mkdir3(path, {
5095
+ await Promise.all(paths.map((path) => mkdir4(path, {
4901
5096
  recursive: true
4902
5097
  })));
4903
5098
  };
4904
5099
 
4905
5100
  // src/cli/ui/complex/template.ts
4906
- import { mkdir as mkdir4, writeFile as writeFile3 } from "fs/promises";
4907
- import { join as join5 } from "path";
5101
+ import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
5102
+ import { join as join6 } from "path";
4908
5103
  var templateBuilder = (app) => {
4909
5104
  return async (term) => {
4910
5105
  const done = term.out.write(loadingDialog("Building stack templates..."));
4911
5106
  await Promise.all(app.stacks.map(async (stack) => {
4912
5107
  const template = stack.toString(true);
4913
- const path = join5(directories.template, app.name);
4914
- const file = join5(path, `${stack.name}.json`);
4915
- await mkdir4(path, { recursive: true });
4916
- await writeFile3(file, template);
5108
+ const path = join6(directories.template, app.name);
5109
+ const file = join6(path, `${stack.name}.json`);
5110
+ await mkdir5(path, { recursive: true });
5111
+ await writeFile4(file, template);
4917
5112
  }));
4918
5113
  done("Done building stack templates");
4919
5114
  };
4920
5115
  };
4921
5116
 
4922
- // src/util/type-gen.ts
4923
- import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
4924
- import { join as join6, relative as relative2 } from "path";
4925
- var generateResourceTypes = async (config) => {
4926
- const plugins = [
4927
- ...defaultPlugins,
4928
- ...config.plugins || []
4929
- ];
4930
- const files = [];
4931
- for (const plugin of plugins) {
4932
- const code = plugin.onTypeGen?.({ config });
4933
- if (code) {
4934
- const file = join6(directories.types, `${plugin.name}.d.ts`);
4935
- files.push(relative2(directories.root, file));
4936
- await mkdir5(directories.types, { recursive: true });
4937
- await writeFile4(file, code);
4938
- }
4939
- }
4940
- if (files.length) {
4941
- const code = files.map((file) => `import '${file}';`).join("\n");
4942
- await writeFile4(join6(directories.root, `awsless.d.ts`), code);
4943
- }
4944
- };
4945
-
4946
5117
  // src/cli/ui/complex/types.ts
4947
5118
  var typesGenerator = (config) => {
4948
5119
  return async (term) => {
@@ -4995,7 +5166,7 @@ var shouldDeployBootstrap = async (client, stack) => {
4995
5166
  // src/formation/client.ts
4996
5167
  import { CloudFormationClient, CreateStackCommand, DeleteStackCommand, DescribeStackEventsCommand, DescribeStacksCommand, GetTemplateCommand, OnFailure, TemplateStage, UpdateStackCommand, ValidateTemplateCommand, waitUntilStackCreateComplete, waitUntilStackDeleteComplete, waitUntilStackUpdateComplete } from "@aws-sdk/client-cloudformation";
4997
5168
  import { S3Client, PutObjectCommand, ObjectCannedACL, StorageClass } from "@aws-sdk/client-s3";
4998
- import { paramCase as paramCase5 } from "change-case";
5169
+ import { paramCase as paramCase4 } from "change-case";
4999
5170
  var StackClient = class {
5000
5171
  constructor(app, account, region, credentials) {
5001
5172
  this.app = app;
@@ -5028,7 +5199,7 @@ var StackClient = class {
5028
5199
  };
5029
5200
  }
5030
5201
  stackName(stackName) {
5031
- return paramCase5(`${this.app.name}-${stackName}`);
5202
+ return paramCase4(`${this.app.name}-${stackName}`);
5032
5203
  }
5033
5204
  tags(stack) {
5034
5205
  const tags = [];
@@ -5734,6 +5905,19 @@ var types = (program2) => {
5734
5905
  });
5735
5906
  };
5736
5907
 
5908
+ // src/cli/command/dev.ts
5909
+ var dev = (program2) => {
5910
+ program2.command("dev").description("Start the development service").action(async () => {
5911
+ await layout(async (_, write) => {
5912
+ const options = program2.optsWithGlobals();
5913
+ for await (const config of watchConfig(options)) {
5914
+ await cleanUp();
5915
+ await write(typesGenerator(config));
5916
+ }
5917
+ });
5918
+ });
5919
+ };
5920
+
5737
5921
  // src/cli/program.ts
5738
5922
  var program = new Command();
5739
5923
  program.name(logo().join("").replace(/\s+/, ""));
@@ -5755,6 +5939,7 @@ var commands2 = [
5755
5939
  types,
5756
5940
  build,
5757
5941
  deploy,
5942
+ dev,
5758
5943
  secrets,
5759
5944
  test
5760
5945
  // diff,
package/dist/index.cjs CHANGED
@@ -21,7 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  Function: () => Function,
24
+ Queue: () => Queue,
24
25
  Table: () => Table,
26
+ Topic: () => Topic,
25
27
  defineAppConfig: () => defineAppConfig,
26
28
  definePlugin: () => definePlugin,
27
29
  defineStackConfig: () => defineStackConfig,
@@ -53,8 +55,6 @@ var getGlobalResourceName = (name) => {
53
55
  };
54
56
  var getSearchName = getLocalResourceName;
55
57
  var getStoreName = getLocalResourceName;
56
- var getQueueName = getLocalResourceName;
57
- var getTopicName = getGlobalResourceName;
58
58
  var getSecretName = (name) => {
59
59
  return `/.awsless/${APP}/${name}`;
60
60
  };
@@ -86,14 +86,26 @@ var createProxy = (cb) => {
86
86
  var getFunctionName = (stack, name) => {
87
87
  return getLocalResourceName(name, stack);
88
88
  };
89
- var Function = createProxy((stack) => {
90
- return createProxy((name) => {
91
- return (event, options = {}) => {
92
- return (0, import_lambda.invoke)({
93
- ...options,
94
- name: getFunctionName(stack, name),
95
- payload: event
96
- });
89
+ var Function = createProxy((stackName) => {
90
+ return createProxy((funcName) => {
91
+ const name = getFunctionName(stackName, funcName);
92
+ return {
93
+ name,
94
+ invoke(payload, options = {}) {
95
+ return (0, import_lambda.invoke)({
96
+ ...options,
97
+ name,
98
+ payload
99
+ });
100
+ },
101
+ async(payload, options = {}) {
102
+ return (0, import_lambda.invoke)({
103
+ ...options,
104
+ name,
105
+ payload,
106
+ type: "Event"
107
+ });
108
+ }
97
109
  };
98
110
  });
99
111
  });
@@ -102,7 +114,33 @@ var Function = createProxy((stack) => {
102
114
  var getTableName = getLocalResourceName;
103
115
  var Table = createProxy((stack) => {
104
116
  return createProxy((name) => {
105
- return getTableName(name, stack);
117
+ return {
118
+ name: getTableName(name, stack)
119
+ };
120
+ });
121
+ });
122
+
123
+ // src/node/topic.ts
124
+ var getTopicName = getGlobalResourceName;
125
+ var Topic = createProxy((topic) => {
126
+ const name = getTopicName(topic);
127
+ return {
128
+ name
129
+ // publish(payload:unknown) {
130
+ // }
131
+ };
132
+ });
133
+
134
+ // src/node/queue.ts
135
+ var getQueueName = getLocalResourceName;
136
+ var Queue = createProxy((stack) => {
137
+ return createProxy((queue) => {
138
+ const name = getQueueName(queue, stack);
139
+ return {
140
+ name
141
+ // sendMessage(payload:unknown) {
142
+ // }
143
+ };
106
144
  });
107
145
  });
108
146
 
@@ -116,7 +154,9 @@ var defineAppConfig = (config) => {
116
154
  // Annotate the CommonJS export names for ESM import in node:
117
155
  0 && (module.exports = {
118
156
  Function,
157
+ Queue,
119
158
  Table,
159
+ Topic,
120
160
  defineAppConfig,
121
161
  definePlugin,
122
162
  defineStackConfig,
package/dist/index.d.ts CHANGED
@@ -2474,8 +2474,6 @@ declare const getLocalResourceName: <N extends string, S extends string = "stack
2474
2474
  declare const getGlobalResourceName: <N extends string>(name: N) => `app-${N}`;
2475
2475
  declare const getSearchName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2476
2476
  declare const getStoreName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2477
- declare const getQueueName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2478
- declare const getTopicName: <N extends string>(name: N) => `app-${N}`;
2479
2477
  declare const getSecretName: (name: string) => string;
2480
2478
  declare const getCacheProps: (name: string, stack?: "stack") => {
2481
2479
  readonly host: string;
@@ -2492,6 +2490,16 @@ interface TableResources {
2492
2490
  }
2493
2491
  declare const Table: TableResources;
2494
2492
 
2493
+ declare const getTopicName: <N extends string>(name: N) => `app-${N}`;
2494
+ interface TopicResources {
2495
+ }
2496
+ declare const Topic: {};
2497
+
2498
+ declare const getQueueName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
2499
+ interface QueueResources {
2500
+ }
2501
+ declare const Queue: {};
2502
+
2495
2503
  type AppConfig = CombinedDefaultPluginsConfigInput;
2496
2504
  type StackConfig = CombinedDefaultPluginsConfigInput['stacks'][number];
2497
2505
  declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (StackConfig$1 & {
@@ -2710,4 +2718,4 @@ declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (Stack
2710
2718
  });
2711
2719
  declare const defineAppConfig: (config: AppConfig | AppConfigFactory<AppConfig>) => CombinedDefaultPluginsConfigInput | AppConfigFactory<CombinedDefaultPluginsConfigInput>;
2712
2720
 
2713
- export { AppConfig, Function, FunctionResources, Plugin, StackConfig, Table, defineAppConfig, definePlugin, defineStackConfig, getCacheProps, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getSecretName, getStoreName, getTableName, getTopicName };
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 };