@awsless/awsless 0.0.35 → 0.0.36

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,95 @@ 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
+ `declare module '${this.module}' {`,
1110
+ ` interface ${this.interfaceName} {`,
1111
+ ...Array.from(this.types.entries()).map(([propName, type]) => {
1112
+ return ` readonly ${camelCase(propName)}: ${type}`;
1113
+ }),
1114
+ ` }`,
1115
+ `}`
1116
+ ].join("\n");
1117
+ }
1118
+ };
1119
+ var TypeObject = class {
1120
+ types = /* @__PURE__ */ new Map();
1121
+ addType(name, type) {
1122
+ this.types.set(name, type);
1123
+ return this;
1124
+ }
1125
+ toString() {
1126
+ if (!this.types.size) {
1127
+ return "";
1128
+ }
1129
+ return [
1130
+ "{",
1131
+ ...Array.from(this.types.entries()).map(([propName, type]) => {
1132
+ return ` readonly ${camelCase(propName)}: ${type}`;
1133
+ }),
1134
+ " }"
1135
+ ].join("\n");
1136
+ }
1137
+ };
1138
+
1139
+ // src/plugins/function.ts
1052
1140
  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
1141
  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
1142
  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 +1271,33 @@ var schema = z6.object({
1183
1271
  ).optional()
1184
1272
  }).array()
1185
1273
  });
1274
+ var typeGenCode = `
1275
+ import { InvokeOptions } from '@awsless/lambda'
1276
+
1277
+ type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
1278
+ name: Name
1279
+ invoke: (event: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>) => ReturnType<Func>
1280
+ async: (event: Parameters<Func>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => ReturnType<Func>
1281
+ }`;
1186
1282
  var functionPlugin = definePlugin({
1187
1283
  name: "function",
1188
1284
  schema,
1189
1285
  onTypeGen({ config }) {
1190
- const imports = [];
1191
- const props = [];
1286
+ const types2 = new TypeGen("@awsless/awsless", "FunctionResources");
1287
+ types2.addCode(typeGenCode);
1192
1288
  for (const stack of config.stacks) {
1193
- const functions = [];
1289
+ const list3 = new TypeObject();
1194
1290
  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}`);
1291
+ const varName = camelCase2(`${stack.name}-${name}`);
1292
+ const funcName = formatName(`${config.name}-${stack.name}-${name}`);
1197
1293
  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}>`);
1294
+ const relFile = relative2(directories.types, file);
1295
+ types2.addImport(varName, relFile);
1296
+ list3.addType(name, `Invoke<'${funcName}', typeof ${varName}>`);
1201
1297
  }
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;
1298
+ types2.addType(stack.name, list3.toString());
1210
1299
  }
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
- );
1300
+ return types2.toString();
1231
1301
  },
1232
1302
  onStack(ctx) {
1233
1303
  const { config, stack } = ctx;
@@ -1628,6 +1698,18 @@ var queuePlugin = definePlugin({
1628
1698
  ).optional()
1629
1699
  }).array()
1630
1700
  }),
1701
+ onTypeGen({ config }) {
1702
+ const types2 = new TypeGen("@awsless/awsless", "QueueResources");
1703
+ for (const stack of config.stacks) {
1704
+ const list3 = new TypeObject();
1705
+ for (const name of Object.keys(stack.queues || {})) {
1706
+ const queueName = formatName(`${config.name}-${stack.name}-${name}`);
1707
+ list3.addType(name, `{ name: '${queueName}' }`);
1708
+ }
1709
+ types2.addType(stack.name, list3.toString());
1710
+ }
1711
+ return types2.toString();
1712
+ },
1631
1713
  onStack(ctx) {
1632
1714
  const { stack, config, stackConfig, bind } = ctx;
1633
1715
  for (const [id, functionOrProps] of Object.entries(stackConfig.queues || {})) {
@@ -1901,6 +1983,18 @@ var tablePlugin = definePlugin({
1901
1983
  ).optional()
1902
1984
  }).array()
1903
1985
  }),
1986
+ onTypeGen({ config }) {
1987
+ const types2 = new TypeGen("@awsless/awsless", "TableResources");
1988
+ for (const stack of config.stacks) {
1989
+ const list3 = new TypeObject();
1990
+ for (const name of Object.keys(stack.tables || {})) {
1991
+ const tableName = formatName(`${config.name}-${stack.name}-${name}`);
1992
+ list3.addType(name, `{ name: '${tableName}' }`);
1993
+ }
1994
+ types2.addType(stack.name, list3.toString());
1995
+ }
1996
+ return types2.toString();
1997
+ },
1904
1998
  onStack(ctx) {
1905
1999
  const { config, stack, stackConfig, bind } = ctx;
1906
2000
  for (const [id, props] of Object.entries(stackConfig.tables || {})) {
@@ -2087,6 +2181,16 @@ var topicPlugin = definePlugin({
2087
2181
  topics: z11.record(ResourceIdSchema, FunctionSchema).optional()
2088
2182
  }).array()
2089
2183
  }),
2184
+ onTypeGen({ config }) {
2185
+ const gen = new TypeGen("@awsless/awsless", "TopicResources");
2186
+ for (const stack of config.stacks) {
2187
+ for (const topic of Object.keys(stack.topics || {})) {
2188
+ const name = formatName(`${config.name}-${topic}`);
2189
+ gen.addType(topic, `{ name: '${name}' }`);
2190
+ }
2191
+ }
2192
+ return gen.toString();
2193
+ },
2090
2194
  onApp({ config, bootstrap: bootstrap2, bind }) {
2091
2195
  const allTopicNames = config.stacks.map((stack) => {
2092
2196
  return Object.keys(stack.topics || {});
@@ -2251,7 +2355,7 @@ var toArray = (value) => {
2251
2355
  };
2252
2356
 
2253
2357
  // src/plugins/graphql.ts
2254
- import { paramCase as paramCase4 } from "change-case";
2358
+ import { paramCase as paramCase3 } from "change-case";
2255
2359
 
2256
2360
  // src/formation/resource/appsync/graphql-api.ts
2257
2361
  import { constantCase as constantCase3 } from "change-case";
@@ -2684,7 +2788,7 @@ var graphqlPlugin = definePlugin({
2684
2788
  const apiId = bootstrap2.import(`graphql-${id}`);
2685
2789
  for (const [typeAndField, functionProps] of Object.entries(props.resolvers || {})) {
2686
2790
  const [typeName, fieldName] = typeAndField.split(/[\s]+/g);
2687
- const entryId = paramCase4(`${id}-${typeName}-${fieldName}`);
2791
+ const entryId = paramCase3(`${id}-${typeName}-${fieldName}`);
2688
2792
  const lambda = toLambdaFunction(ctx, `graphql-${entryId}`, functionProps);
2689
2793
  const source = new AppsyncEventSource(entryId, lambda, {
2690
2794
  apiId,
@@ -4141,7 +4245,7 @@ var toApp = async (config, filters) => {
4141
4245
  };
4142
4246
 
4143
4247
  // src/config.ts
4144
- import { join as join3 } from "path";
4248
+ import { join as join4 } from "path";
4145
4249
 
4146
4250
  // src/util/account.ts
4147
4251
  import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
@@ -4225,11 +4329,12 @@ var AppSchema = z23.object({
4225
4329
  });
4226
4330
 
4227
4331
  // src/util/import.ts
4228
- import { rollup as rollup2 } from "rollup";
4332
+ import { rollup as rollup2, watch } from "rollup";
4229
4333
  import { swc as swc2 } from "rollup-plugin-swc3";
4230
4334
  import replace from "rollup-plugin-replace";
4231
- import { dirname as dirname2, join as join2 } from "path";
4232
- import { mkdir, writeFile } from "fs/promises";
4335
+ import { EventIterator } from "event-iterator";
4336
+ import { dirname as dirname2, join as join3 } from "path";
4337
+ import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
4233
4338
  var importFile = async (path) => {
4234
4339
  const bundle = await rollup2({
4235
4340
  input: path,
@@ -4248,18 +4353,73 @@ var importFile = async (path) => {
4248
4353
  })
4249
4354
  ]
4250
4355
  });
4251
- const outputFile = join2(directories.cache, "config.js");
4356
+ const outputFile = join3(directories.cache, "config.js");
4252
4357
  const result = await bundle.generate({
4253
4358
  format: "esm",
4254
4359
  exports: "default"
4255
4360
  });
4256
4361
  const output = result.output[0];
4257
4362
  const code = output.code;
4258
- await mkdir(directories.cache, { recursive: true });
4259
- await writeFile(outputFile, code);
4363
+ await mkdir2(directories.cache, { recursive: true });
4364
+ await writeFile2(outputFile, code);
4260
4365
  debug("Save config file:", style.info(outputFile));
4261
4366
  return import(outputFile);
4262
4367
  };
4368
+ var watchFile = (path) => {
4369
+ return new EventIterator((queue2) => {
4370
+ const watcher = watch({
4371
+ watch: {
4372
+ skipWrite: true
4373
+ },
4374
+ input: path,
4375
+ onwarn: (error) => {
4376
+ debugError(error.message);
4377
+ },
4378
+ plugins: [
4379
+ replace({
4380
+ __dirname: (id) => `'${dirname2(id)}'`
4381
+ }),
4382
+ swc2({
4383
+ minify: false,
4384
+ jsc: {
4385
+ baseUrl: dirname2(path)
4386
+ }
4387
+ })
4388
+ ]
4389
+ });
4390
+ let resume;
4391
+ queue2.on("lowWater", () => {
4392
+ resume?.(true);
4393
+ });
4394
+ watcher.on("close", queue2.stop);
4395
+ watcher.on("event", async (event) => {
4396
+ if (event.code === "ERROR") {
4397
+ queue2.fail(new Error(event.error.message));
4398
+ }
4399
+ if (event.code === "BUNDLE_END") {
4400
+ const result = await event.result.generate({
4401
+ format: "esm",
4402
+ exports: "default"
4403
+ });
4404
+ event.result.close();
4405
+ const output = result.output[0];
4406
+ const code = output.code;
4407
+ const outputFile = join3(directories.cache, "config.js");
4408
+ await mkdir2(directories.cache, { recursive: true });
4409
+ await writeFile2(outputFile, code);
4410
+ debug("Save config file:", style.info(outputFile));
4411
+ const config = await import(`${outputFile}?${Date.now()}`);
4412
+ queue2.push(config);
4413
+ }
4414
+ });
4415
+ return () => {
4416
+ watcher.close();
4417
+ };
4418
+ }, {
4419
+ highWaterMark: 1,
4420
+ lowWaterMark: 0
4421
+ });
4422
+ };
4263
4423
 
4264
4424
  // src/config.ts
4265
4425
  var importConfig = async (options) => {
@@ -4269,7 +4429,7 @@ var importConfig = async (options) => {
4269
4429
  setRoot(root2);
4270
4430
  debug("CWD:", style.info(root2));
4271
4431
  debug("Import config file");
4272
- const fileName = join3(root2, configFile);
4432
+ const fileName = join4(root2, configFile);
4273
4433
  const module = await importFile(fileName);
4274
4434
  const appConfig = typeof module.default === "function" ? await module.default(options) : module.default;
4275
4435
  debug("Validate config file");
@@ -4295,6 +4455,40 @@ var importConfig = async (options) => {
4295
4455
  credentials
4296
4456
  };
4297
4457
  };
4458
+ var watchConfig = async function* (options) {
4459
+ debug("Find the root directory");
4460
+ const configFile = options.configFile || "awsless.config.ts";
4461
+ const root2 = await findRootDir(process.cwd(), configFile);
4462
+ setRoot(root2);
4463
+ debug("CWD:", style.info(root2));
4464
+ debug("Import config file");
4465
+ const fileName = join4(root2, configFile);
4466
+ for await (const module of watchFile(fileName)) {
4467
+ const appConfig = typeof module.default === "function" ? await module.default(options) : module.default;
4468
+ debug("Validate config file");
4469
+ const plugins = [
4470
+ ...defaultPlugins,
4471
+ ...appConfig.plugins || []
4472
+ ];
4473
+ let schema2 = AppSchema;
4474
+ for (const plugin of plugins) {
4475
+ if (plugin.schema) {
4476
+ schema2 = schema2.and(plugin.schema);
4477
+ }
4478
+ }
4479
+ const config = await schema2.parseAsync(appConfig);
4480
+ debug("Load credentials", style.info(config.profile));
4481
+ const credentials = getCredentials(config.profile);
4482
+ debug("Load AWS account ID");
4483
+ const account = await getAccountId(credentials, config.region);
4484
+ debug("Account ID:", style.info(account));
4485
+ yield {
4486
+ ...config,
4487
+ account,
4488
+ credentials
4489
+ };
4490
+ }
4491
+ };
4298
4492
 
4299
4493
  // src/cli/ui/layout/basic.ts
4300
4494
  var br = () => {
@@ -4770,7 +4964,7 @@ var layout = async (cb) => {
4770
4964
  };
4771
4965
 
4772
4966
  // src/cli/ui/complex/builder.ts
4773
- import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
4967
+ import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
4774
4968
 
4775
4969
  // src/cli/ui/layout/flex-line.ts
4776
4970
  var stripEscapeCode = (str) => {
@@ -4793,7 +4987,7 @@ var flexLine = (term, left, right, reserveSpace = 0) => {
4793
4987
  };
4794
4988
 
4795
4989
  // src/cli/ui/complex/builder.ts
4796
- import { dirname as dirname3, join as join4 } from "path";
4990
+ import { dirname as dirname3, join as join5 } from "path";
4797
4991
  var assetBuilder = (app) => {
4798
4992
  return async (term) => {
4799
4993
  const assets = [];
@@ -4856,10 +5050,10 @@ var assetBuilder = (app) => {
4856
5050
  try {
4857
5051
  const data = await asset.build({
4858
5052
  async write(file, data2) {
4859
- const fullpath = join4(directories.asset, asset.type, app.name, stack.name, asset.id, file);
5053
+ const fullpath = join5(directories.asset, asset.type, app.name, stack.name, asset.id, file);
4860
5054
  const basepath = dirname3(fullpath);
4861
- await mkdir2(basepath, { recursive: true });
4862
- await writeFile2(fullpath, data2);
5055
+ await mkdir3(basepath, { recursive: true });
5056
+ await writeFile3(fullpath, data2);
4863
5057
  }
4864
5058
  });
4865
5059
  details.set({
@@ -4883,7 +5077,7 @@ var assetBuilder = (app) => {
4883
5077
  };
4884
5078
 
4885
5079
  // src/util/cleanup.ts
4886
- import { mkdir as mkdir3, rm } from "fs/promises";
5080
+ import { mkdir as mkdir4, rm } from "fs/promises";
4887
5081
  var cleanUp = async () => {
4888
5082
  debug("Clean up template, cache, and asset files");
4889
5083
  const paths = [
@@ -4897,52 +5091,28 @@ var cleanUp = async () => {
4897
5091
  force: true,
4898
5092
  maxRetries: 2
4899
5093
  })));
4900
- await Promise.all(paths.map((path) => mkdir3(path, {
5094
+ await Promise.all(paths.map((path) => mkdir4(path, {
4901
5095
  recursive: true
4902
5096
  })));
4903
5097
  };
4904
5098
 
4905
5099
  // src/cli/ui/complex/template.ts
4906
- import { mkdir as mkdir4, writeFile as writeFile3 } from "fs/promises";
4907
- import { join as join5 } from "path";
5100
+ import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
5101
+ import { join as join6 } from "path";
4908
5102
  var templateBuilder = (app) => {
4909
5103
  return async (term) => {
4910
5104
  const done = term.out.write(loadingDialog("Building stack templates..."));
4911
5105
  await Promise.all(app.stacks.map(async (stack) => {
4912
5106
  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);
5107
+ const path = join6(directories.template, app.name);
5108
+ const file = join6(path, `${stack.name}.json`);
5109
+ await mkdir5(path, { recursive: true });
5110
+ await writeFile4(file, template);
4917
5111
  }));
4918
5112
  done("Done building stack templates");
4919
5113
  };
4920
5114
  };
4921
5115
 
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
5116
  // src/cli/ui/complex/types.ts
4947
5117
  var typesGenerator = (config) => {
4948
5118
  return async (term) => {
@@ -4995,7 +5165,7 @@ var shouldDeployBootstrap = async (client, stack) => {
4995
5165
  // src/formation/client.ts
4996
5166
  import { CloudFormationClient, CreateStackCommand, DeleteStackCommand, DescribeStackEventsCommand, DescribeStacksCommand, GetTemplateCommand, OnFailure, TemplateStage, UpdateStackCommand, ValidateTemplateCommand, waitUntilStackCreateComplete, waitUntilStackDeleteComplete, waitUntilStackUpdateComplete } from "@aws-sdk/client-cloudformation";
4997
5167
  import { S3Client, PutObjectCommand, ObjectCannedACL, StorageClass } from "@aws-sdk/client-s3";
4998
- import { paramCase as paramCase5 } from "change-case";
5168
+ import { paramCase as paramCase4 } from "change-case";
4999
5169
  var StackClient = class {
5000
5170
  constructor(app, account, region, credentials) {
5001
5171
  this.app = app;
@@ -5028,7 +5198,7 @@ var StackClient = class {
5028
5198
  };
5029
5199
  }
5030
5200
  stackName(stackName) {
5031
- return paramCase5(`${this.app.name}-${stackName}`);
5201
+ return paramCase4(`${this.app.name}-${stackName}`);
5032
5202
  }
5033
5203
  tags(stack) {
5034
5204
  const tags = [];
@@ -5734,6 +5904,19 @@ var types = (program2) => {
5734
5904
  });
5735
5905
  };
5736
5906
 
5907
+ // src/cli/command/dev.ts
5908
+ var dev = (program2) => {
5909
+ program2.command("dev").description("Start the development service").action(async () => {
5910
+ await layout(async (_, write) => {
5911
+ const options = program2.optsWithGlobals();
5912
+ for await (const config of watchConfig(options)) {
5913
+ await cleanUp();
5914
+ await write(typesGenerator(config));
5915
+ }
5916
+ });
5917
+ });
5918
+ };
5919
+
5737
5920
  // src/cli/program.ts
5738
5921
  var program = new Command();
5739
5922
  program.name(logo().join("").replace(/\s+/, ""));
@@ -5755,6 +5938,7 @@ var commands2 = [
5755
5938
  types,
5756
5939
  build,
5757
5940
  deploy,
5941
+ dev,
5758
5942
  secrets,
5759
5943
  test
5760
5944
  // 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 };