@awsless/awsless 0.0.114 → 0.0.116

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
@@ -1333,20 +1333,29 @@ import { relative as relative2 } from "path";
1333
1333
 
1334
1334
  // src/util/type-gen.ts
1335
1335
  import { mkdir, writeFile } from "fs/promises";
1336
- import { join as join4, relative } from "path";
1336
+ import { dirname as dirname3, join as join4, relative } from "path";
1337
1337
  import { camelCase, constantCase as constantCase3 } from "change-case";
1338
1338
  var generateResourceTypes = async (config2) => {
1339
1339
  const plugins = [...defaultPlugins, ...config2.plugins || []];
1340
1340
  const files = [];
1341
- for (const plugin of plugins) {
1342
- const code = plugin.onTypeGen?.({ config: config2 });
1343
- if (code) {
1344
- const file = join4(directories.types, `${plugin.name}.d.ts`);
1345
- files.push(relative(directories.root, file));
1346
- await mkdir(directories.types, { recursive: true });
1347
- await writeFile(file, code);
1348
- }
1349
- }
1341
+ await Promise.all(
1342
+ plugins.map((plugin) => {
1343
+ return plugin.onTypeGen?.({
1344
+ config: config2,
1345
+ async write(file, data, include = false) {
1346
+ const code = data?.toString("utf8");
1347
+ const path = join4(directories.types, file);
1348
+ if (code) {
1349
+ if (include) {
1350
+ files.push(relative(directories.root, path));
1351
+ }
1352
+ await mkdir(dirname3(path), { recursive: true });
1353
+ await writeFile(path, code);
1354
+ }
1355
+ }
1356
+ });
1357
+ })
1358
+ );
1350
1359
  if (files.length) {
1351
1360
  const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
1352
1361
  await writeFile(join4(directories.root, `awsless.d.ts`), code);
@@ -1390,7 +1399,10 @@ var TypeGen = class {
1390
1399
  ...[
1391
1400
  "// Imports",
1392
1401
  ...Array.from(this.imports.entries()).map(([varName, path]) => {
1393
- return `import ${camelCase(varName)} from '${path}'`;
1402
+ if (typeof varName === "string") {
1403
+ return `import ${camelCase(varName)} from '${path}'`;
1404
+ }
1405
+ return `import { ${Object.entries(varName).map(([key, alias]) => `${key} as ${camelCase(alias)}`).join(", ")} } from '${path}'`;
1394
1406
  }),
1395
1407
  ""
1396
1408
  ]
@@ -1685,7 +1697,7 @@ type MockObject<F extends Func> = Mock<Parameters<F>, ReturnType<F>>
1685
1697
  var functionPlugin = definePlugin({
1686
1698
  name: "function",
1687
1699
  schema,
1688
- onTypeGen({ config: config2 }) {
1700
+ async onTypeGen({ config: config2, write }) {
1689
1701
  const types2 = new TypeGen("@awsless/awsless");
1690
1702
  const resources = new TypeObject(1);
1691
1703
  const mocks = new TypeObject(1);
@@ -1712,7 +1724,7 @@ var functionPlugin = definePlugin({
1712
1724
  types2.addInterface("FunctionResources", resources);
1713
1725
  types2.addInterface("FunctionMock", mocks);
1714
1726
  types2.addInterface("FunctionMockResponse", mockResponses);
1715
- return types2.toString();
1727
+ await write("function.d.ts", types2, true);
1716
1728
  },
1717
1729
  onStack(ctx) {
1718
1730
  const { config: config2, stack } = ctx;
@@ -2096,7 +2108,7 @@ var queuePlugin = definePlugin({
2096
2108
  ).optional()
2097
2109
  }).array()
2098
2110
  }),
2099
- onTypeGen({ config: config2 }) {
2111
+ async onTypeGen({ config: config2, write }) {
2100
2112
  const gen = new TypeGen("@awsless/awsless");
2101
2113
  const resources = new TypeObject(1);
2102
2114
  const mocks = new TypeObject(1);
@@ -2123,7 +2135,7 @@ var queuePlugin = definePlugin({
2123
2135
  gen.addInterface("QueueResources", resources);
2124
2136
  gen.addInterface("QueueMock", mocks);
2125
2137
  gen.addInterface("QueueMockResponse", mockResponses);
2126
- return gen.toString();
2138
+ await write("queue.d.ts", gen, true);
2127
2139
  },
2128
2140
  onStack(ctx) {
2129
2141
  const { stack, config: config2, stackConfig, bind } = ctx;
@@ -2396,7 +2408,7 @@ var tablePlugin = definePlugin({
2396
2408
  ).optional()
2397
2409
  }).array()
2398
2410
  }),
2399
- onTypeGen({ config: config2 }) {
2411
+ async onTypeGen({ config: config2, write }) {
2400
2412
  const gen = new TypeGen("@awsless/awsless");
2401
2413
  const resources = new TypeObject(1);
2402
2414
  for (const stack of config2.stacks) {
@@ -2408,7 +2420,7 @@ var tablePlugin = definePlugin({
2408
2420
  resources.addType(stack.name, list3);
2409
2421
  }
2410
2422
  gen.addInterface("TableResources", resources);
2411
- return gen.toString();
2423
+ await write("table.d.ts", gen, true);
2412
2424
  },
2413
2425
  onStack(ctx) {
2414
2426
  const { config: config2, stack, stackConfig, bind } = ctx;
@@ -2530,7 +2542,7 @@ var storePlugin = definePlugin({
2530
2542
  stores: z10.array(ResourceIdSchema).optional()
2531
2543
  }).array()
2532
2544
  }),
2533
- onTypeGen({ config: config2 }) {
2545
+ async onTypeGen({ config: config2, write }) {
2534
2546
  const gen = new TypeGen("@awsless/awsless");
2535
2547
  const resources = new TypeObject(1);
2536
2548
  for (const stack of config2.stacks) {
@@ -2542,7 +2554,7 @@ var storePlugin = definePlugin({
2542
2554
  resources.addType(stack.name, list3);
2543
2555
  }
2544
2556
  gen.addInterface("StoreResources", resources);
2545
- return gen.toString();
2557
+ await write("store.d.ts", gen, true);
2546
2558
  },
2547
2559
  onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind }) {
2548
2560
  for (const id of stackConfig.stores || []) {
@@ -2701,7 +2713,7 @@ var topicPlugin = definePlugin({
2701
2713
  }
2702
2714
  })
2703
2715
  }),
2704
- onTypeGen({ config: config2 }) {
2716
+ async onTypeGen({ config: config2, write }) {
2705
2717
  const gen = new TypeGen("@awsless/awsless");
2706
2718
  const resources = new TypeObject(1);
2707
2719
  const mocks = new TypeObject(1);
@@ -2718,7 +2730,7 @@ var topicPlugin = definePlugin({
2718
2730
  gen.addInterface("TopicResources", resources);
2719
2731
  gen.addInterface("TopicMock", mocks);
2720
2732
  gen.addInterface("TopicMockResponse", mockResponses);
2721
- return gen.toString();
2733
+ await write("topic.d.ts", gen, true);
2722
2734
  },
2723
2735
  onApp({ config: config2, bootstrap: bootstrap2 }) {
2724
2736
  for (const stack of config2.stacks) {
@@ -3070,7 +3082,7 @@ import { swc as swc2, minify as swcMinify2 } from "rollup-plugin-swc3";
3070
3082
  import json2 from "@rollup/plugin-json";
3071
3083
  import commonjs2 from "@rollup/plugin-commonjs";
3072
3084
  import nodeResolve2 from "@rollup/plugin-node-resolve";
3073
- import { dirname as dirname3 } from "path";
3085
+ import { dirname as dirname4 } from "path";
3074
3086
  var rollupResolver = ({ minify = true } = {}) => {
3075
3087
  return async (input) => {
3076
3088
  const bundle = await rollup2({
@@ -3093,7 +3105,7 @@ var rollupResolver = ({ minify = true } = {}) => {
3093
3105
  // minify,
3094
3106
  // module: true,
3095
3107
  jsc: {
3096
- baseUrl: dirname3(input),
3108
+ baseUrl: dirname4(input),
3097
3109
  minify: { sourceMap: true }
3098
3110
  },
3099
3111
  sourceMaps: true
@@ -3341,6 +3353,10 @@ var DomainNameApiAssociation = class extends Resource {
3341
3353
 
3342
3354
  // src/plugins/graphql.ts
3343
3355
  import { basename as basename2 } from "path";
3356
+ import { mergeTypeDefs as mergeTypeDefs2 } from "@graphql-tools/merge";
3357
+ import { generate } from "@awsless/graphql";
3358
+ import { buildSchema, print as print2 } from "graphql";
3359
+ import { readFile as readFile4 } from "fs/promises";
3344
3360
  var defaultResolver = Code2.fromInline(
3345
3361
  "graphql-default-resolver",
3346
3362
  `
@@ -3357,6 +3373,17 @@ export function response(ctx) {
3357
3373
  `
3358
3374
  );
3359
3375
  var resolverCache = /* @__PURE__ */ new Map();
3376
+ var scalarSchema = `
3377
+ scalar AWSDate
3378
+ scalar AWSTime
3379
+ scalar AWSDateTime
3380
+ scalar AWSTimestamp
3381
+ scalar AWSEmail
3382
+ scalar AWSJSON
3383
+ scalar AWSURL
3384
+ scalar AWSPhone
3385
+ scalar AWSIPAddress
3386
+ `;
3360
3387
  var graphqlPlugin = definePlugin({
3361
3388
  name: "graphql",
3362
3389
  schema: z15.object({
@@ -3399,7 +3426,51 @@ var graphqlPlugin = definePlugin({
3399
3426
  ).optional()
3400
3427
  }).array()
3401
3428
  }),
3402
- onTypeGen({ config: config2 }) {
3429
+ async onTypeGen({ config: config2, write }) {
3430
+ const types2 = new TypeGen("@awsless/awsless");
3431
+ const resources = new TypeObject(1);
3432
+ const apis = /* @__PURE__ */ new Map();
3433
+ for (const stack of config2.stacks) {
3434
+ for (const id of Object.keys(stack.graphql || {})) {
3435
+ apis.set(id, []);
3436
+ }
3437
+ }
3438
+ for (const stack of config2.stacks) {
3439
+ for (const [id, props] of Object.entries(stack.graphql || {})) {
3440
+ if (props.schema) {
3441
+ apis.get(id)?.push(...[props.schema].flat());
3442
+ }
3443
+ }
3444
+ }
3445
+ for (const [id, files] of apis) {
3446
+ const sources = await Promise.all(
3447
+ files.map((file) => {
3448
+ return readFile4(file, "utf8");
3449
+ })
3450
+ );
3451
+ if (sources.length) {
3452
+ const defs = mergeTypeDefs2([scalarSchema, ...sources]);
3453
+ const schema2 = buildSchema(print2(defs));
3454
+ const output = generate(schema2, {
3455
+ scalarTypes: {
3456
+ AWSDate: "string",
3457
+ AWSTime: "string",
3458
+ AWSDateTime: "string",
3459
+ AWSTimestamp: "number",
3460
+ AWSEmail: "string",
3461
+ AWSJSON: "string",
3462
+ AWSURL: "string",
3463
+ AWSPhone: "string",
3464
+ AWSIPAddress: "string"
3465
+ }
3466
+ });
3467
+ await write(`graphql/${id}.d.ts`, output);
3468
+ types2.addImport({ Schema: id }, `./graphql/${id}.d.ts`);
3469
+ resources.addConst(id, id);
3470
+ }
3471
+ }
3472
+ types2.addInterface("GraphQL", resources);
3473
+ await write("graphql.d.ts", types2, true);
3403
3474
  },
3404
3475
  onApp(ctx) {
3405
3476
  const { config: config2, bootstrap: bootstrap2 } = ctx;
@@ -4478,7 +4549,7 @@ var httpPlugin = definePlugin({
4478
4549
  http: z18.record(ResourceIdSchema, z18.record(RouteSchema, FunctionSchema)).optional()
4479
4550
  }).array()
4480
4551
  }),
4481
- onTypeGen({ config: config2 }) {
4552
+ async onTypeGen({ config: config2, write }) {
4482
4553
  const types2 = new TypeGen("@awsless/awsless");
4483
4554
  const resources = new TypeObject(1);
4484
4555
  const api = {};
@@ -4527,7 +4598,7 @@ var httpPlugin = definePlugin({
4527
4598
  ];
4528
4599
  code.map((code2) => types2.addCode(code2));
4529
4600
  types2.addInterface("HTTP", resources);
4530
- return types2.toString();
4601
+ await write("http.d.ts", types2, true);
4531
4602
  },
4532
4603
  onApp({ config: config2, bootstrap: bootstrap2 }) {
4533
4604
  if (Object.keys(config2.defaults?.http || {}).length === 0) {
@@ -4654,7 +4725,7 @@ var searchPlugin = definePlugin({
4654
4725
  searchs: z19.array(ResourceIdSchema).optional()
4655
4726
  }).array()
4656
4727
  }),
4657
- onTypeGen({ config: config2 }) {
4728
+ async onTypeGen({ config: config2, write }) {
4658
4729
  const gen = new TypeGen("@awsless/awsless");
4659
4730
  const resources = new TypeObject(1);
4660
4731
  for (const stack of config2.stacks) {
@@ -4666,7 +4737,7 @@ var searchPlugin = definePlugin({
4666
4737
  resources.addType(stack.name, list3);
4667
4738
  }
4668
4739
  gen.addInterface("SearchResources", resources);
4669
- return gen.toString();
4740
+ await write("search.d.ts", gen, true);
4670
4741
  },
4671
4742
  onStack({ config: config2, stack, stackConfig, bind }) {
4672
4743
  for (const id of stackConfig.searchs || []) {
@@ -4808,7 +4879,7 @@ var cachePlugin = definePlugin({
4808
4879
  ).optional()
4809
4880
  }).array()
4810
4881
  }),
4811
- onTypeGen({ config: config2 }) {
4882
+ async onTypeGen({ config: config2, write }) {
4812
4883
  const gen = new TypeGen("@awsless/awsless");
4813
4884
  const resources = new TypeObject(1);
4814
4885
  for (const stack of config2.stacks) {
@@ -4820,7 +4891,7 @@ var cachePlugin = definePlugin({
4820
4891
  }
4821
4892
  gen.addCode(typeGenCode4);
4822
4893
  gen.addInterface("CacheResources", resources);
4823
- return gen.toString();
4894
+ await write("cache.d.ts", gen, true);
4824
4895
  },
4825
4896
  onStack({ config: config2, stack, stackConfig, bootstrap: bootstrap2, bind }) {
4826
4897
  for (const [id, props] of Object.entries(stackConfig.caches || {})) {
@@ -5232,7 +5303,7 @@ var configPlugin = definePlugin({
5232
5303
  configs: z23.array(ConfigNameSchema).optional()
5233
5304
  }).array()
5234
5305
  }),
5235
- onTypeGen({ config: config2 }) {
5306
+ async onTypeGen({ config: config2, write }) {
5236
5307
  const gen = new TypeGen("@awsless/awsless");
5237
5308
  const resources = new TypeObject(0, false);
5238
5309
  for (const stack of config2.stacks) {
@@ -5241,7 +5312,7 @@ var configPlugin = definePlugin({
5241
5312
  }
5242
5313
  }
5243
5314
  gen.addInterface("ConfigResources", resources.toString());
5244
- return gen.toString();
5315
+ await write("config.d.ts", gen, true);
5245
5316
  },
5246
5317
  onStack({ bind, config: config2, stackConfig }) {
5247
5318
  const configs = stackConfig.configs;
@@ -6423,7 +6494,7 @@ var authPlugin = definePlugin({
6423
6494
  ).optional()
6424
6495
  }).array()
6425
6496
  }),
6426
- onTypeGen({ config: config2 }) {
6497
+ async onTypeGen({ config: config2, write }) {
6427
6498
  const gen = new TypeGen("@awsless/awsless");
6428
6499
  const resources = new TypeObject(1);
6429
6500
  for (const name of Object.keys(config2.defaults.auth)) {
@@ -6434,7 +6505,7 @@ var authPlugin = definePlugin({
6434
6505
  );
6435
6506
  }
6436
6507
  gen.addInterface("AuthResources", resources);
6437
- return gen.toString();
6508
+ await write("auth.d.ts", gen, true);
6438
6509
  },
6439
6510
  onStack({ bootstrap: bootstrap2, stackConfig, bind }) {
6440
6511
  for (const [id, props] of Object.entries(stackConfig.auth ?? {})) {
@@ -6796,7 +6867,7 @@ import { rollup as rollup3, watch } from "rollup";
6796
6867
  import { swc as swc3 } from "rollup-plugin-swc3";
6797
6868
  import replace from "rollup-plugin-replace";
6798
6869
  import { EventIterator } from "event-iterator";
6799
- import { dirname as dirname4, join as join6 } from "path";
6870
+ import { dirname as dirname5, join as join6 } from "path";
6800
6871
  import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
6801
6872
  var importFile = async (path) => {
6802
6873
  const bundle = await rollup3({
@@ -6807,13 +6878,13 @@ var importFile = async (path) => {
6807
6878
  plugins: [
6808
6879
  // @ts-ignore
6809
6880
  replace({
6810
- __dirname: (id) => `'${dirname4(id)}'`
6881
+ __dirname: (id) => `'${dirname5(id)}'`
6811
6882
  // 'defineStackConfig({': (id: string) => `defineStackConfig({ cwd: '${dirname(id)}',`,
6812
6883
  }),
6813
6884
  swc3({
6814
6885
  minify: false,
6815
6886
  jsc: {
6816
- baseUrl: dirname4(path)
6887
+ baseUrl: dirname5(path)
6817
6888
  }
6818
6889
  })
6819
6890
  ]
@@ -6844,13 +6915,13 @@ var watchFile = (path) => {
6844
6915
  plugins: [
6845
6916
  // @ts-ignore
6846
6917
  replace({
6847
- __dirname: (id) => `'${dirname4(id)}'`
6918
+ __dirname: (id) => `'${dirname5(id)}'`
6848
6919
  // 'defineStackConfig({': (id: string) => `defineStackConfig({ cwd: '${dirname(id)}',`,
6849
6920
  }),
6850
6921
  swc3({
6851
6922
  minify: false,
6852
6923
  jsc: {
6853
- baseUrl: dirname4(path)
6924
+ baseUrl: dirname5(path)
6854
6925
  }
6855
6926
  })
6856
6927
  ]
@@ -7552,7 +7623,7 @@ var layout = async (cb) => {
7552
7623
  };
7553
7624
 
7554
7625
  // src/cli/ui/complex/builder.ts
7555
- import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
7626
+ import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
7556
7627
 
7557
7628
  // src/cli/ui/layout/flex-line.ts
7558
7629
  var stripEscapeCode = (str) => {
@@ -7575,7 +7646,7 @@ var flexLine = (term, left, right, reserveSpace = 0) => {
7575
7646
  };
7576
7647
 
7577
7648
  // src/cli/ui/complex/builder.ts
7578
- import { dirname as dirname5, join as join8 } from "path";
7649
+ import { dirname as dirname6, join as join8 } from "path";
7579
7650
  var assetBuilder = (app) => {
7580
7651
  return async (term) => {
7581
7652
  const assets = [];
@@ -7647,7 +7718,7 @@ var assetBuilder = (app) => {
7647
7718
  const getFingerPrint = async () => {
7648
7719
  let value;
7649
7720
  try {
7650
- value = await readFile4(getFullPath("FINGER_PRINT"), "utf8");
7721
+ value = await readFile5(getFullPath("FINGER_PRINT"), "utf8");
7651
7722
  } catch (_) {
7652
7723
  return void 0;
7653
7724
  }
@@ -7661,12 +7732,12 @@ var assetBuilder = (app) => {
7661
7732
  return;
7662
7733
  }
7663
7734
  const file = getFullPath("FINGER_PRINT");
7664
- const basepath = dirname5(file);
7735
+ const basepath = dirname6(file);
7665
7736
  await mkdir3(basepath, { recursive: true });
7666
7737
  await writeFile3(file, fingerprint);
7667
7738
  await cb(async (file2, data2) => {
7668
7739
  const fullpath = getFullPath(file2);
7669
- const basepath2 = dirname5(fullpath);
7740
+ const basepath2 = dirname6(fullpath);
7670
7741
  await mkdir3(basepath2, { recursive: true });
7671
7742
  await writeFile3(fullpath, data2);
7672
7743
  });
@@ -7678,7 +7749,7 @@ var assetBuilder = (app) => {
7678
7749
  }
7679
7750
  return Promise.all(
7680
7751
  files.map((file) => {
7681
- return readFile4(getFullPath(file));
7752
+ return readFile5(getFullPath(file));
7682
7753
  })
7683
7754
  );
7684
7755
  }
@@ -8269,7 +8340,7 @@ var status = (program2) => {
8269
8340
  };
8270
8341
 
8271
8342
  // src/cli/ui/complex/publisher.ts
8272
- import { readFile as readFile5 } from "fs/promises";
8343
+ import { readFile as readFile6 } from "fs/promises";
8273
8344
  import { join as join10 } from "path";
8274
8345
  import { GetObjectCommand, ObjectCannedACL as ObjectCannedACL2, PutObjectCommand as PutObjectCommand2, S3Client as S3Client2, StorageClass as StorageClass2 } from "@aws-sdk/client-s3";
8275
8346
  var assetPublisher = (config2, app) => {
@@ -8289,13 +8360,13 @@ var assetPublisher = (config2, app) => {
8289
8360
  };
8290
8361
  await asset.publish?.({
8291
8362
  async read(fingerprint, files) {
8292
- const prev = await readFile5(getFullPath("FINGER_PRINT"), "utf8");
8363
+ const prev = await readFile6(getFullPath("FINGER_PRINT"), "utf8");
8293
8364
  if (prev !== fingerprint) {
8294
8365
  throw new TypeError(`Outdated fingerprint: ${fingerprint}`);
8295
8366
  }
8296
8367
  return Promise.all(
8297
8368
  files.map((file) => {
8298
- return readFile5(getFullPath(file));
8369
+ return readFile6(getFullPath(file));
8299
8370
  })
8300
8371
  );
8301
8372
  },
@@ -8357,7 +8428,7 @@ import commonjs3 from "@rollup/plugin-commonjs";
8357
8428
  import nodeResolve3 from "@rollup/plugin-node-resolve";
8358
8429
  import { swc as swc4 } from "rollup-plugin-swc3";
8359
8430
  import { getSuites, getTests } from "@vitest/runner/utils";
8360
- import { basename as basename3, dirname as dirname6, extname as extname2, join as join11, relative as relative5 } from "path";
8431
+ import { basename as basename3, dirname as dirname7, extname as extname2, join as join11, relative as relative5 } from "path";
8361
8432
 
8362
8433
  // src/cli/ui/layout/text-box.ts
8363
8434
  import wrapAnsi3 from "wrap-ansi";
@@ -8367,7 +8438,7 @@ var textWrap = (text, width, { indent = 0, skipFirstLine = false, ...rest } = {}
8367
8438
  };
8368
8439
 
8369
8440
  // src/cli/ui/complex/tester.ts
8370
- import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
8441
+ import { mkdir as mkdir6, readFile as readFile7, writeFile as writeFile5 } from "fs/promises";
8371
8442
  import json3 from "@rollup/plugin-json";
8372
8443
  var CustomReporter = class {
8373
8444
  interval;
@@ -8450,7 +8521,7 @@ var singleTester = (stack, dir, filters) => {
8450
8521
  return path;
8451
8522
  }
8452
8523
  const name = basename3(rel, ext);
8453
- const base = dirname6(rel);
8524
+ const base = dirname7(rel);
8454
8525
  const start = base === "." ? "" : style.placeholder(base + "/");
8455
8526
  return `${start}${name}${style.placeholder(ext)}`;
8456
8527
  };
@@ -8562,7 +8633,7 @@ var singleTester = (stack, dir, filters) => {
8562
8633
  const line2 = new Signal([]);
8563
8634
  term.out.write(line2);
8564
8635
  if (exists && !process.env.NO_CACHE) {
8565
- const raw = await readFile6(file, { encoding: "utf8" });
8636
+ const raw = await readFile7(file, { encoding: "utf8" });
8566
8637
  const data2 = JSON.parse(raw);
8567
8638
  if (data2.fingerprint === fingerprint) {
8568
8639
  line2.set(formatOutput({ ...data2, width: term.out.width(), duration: timer(), cached: true }));
package/dist/index.d.ts CHANGED
@@ -11149,6 +11149,28 @@ declare class Function$1 extends Resource {
11149
11149
 
11150
11150
  type Binding = (lambda: Function$1) => void;
11151
11151
 
11152
+ declare class TypeGen {
11153
+ readonly module: string;
11154
+ protected codes: Set<string>;
11155
+ protected interfaces: Map<string, string>;
11156
+ protected imports: Map<string | Record<string, string>, string>;
11157
+ constructor(module: string);
11158
+ addImport(varName: string | Record<string, string>, path: string): this;
11159
+ addCode(code: string): this;
11160
+ addInterface(name: string, type: string | TypeObject): this;
11161
+ toString(): string | undefined;
11162
+ }
11163
+ declare class TypeObject {
11164
+ readonly level: number;
11165
+ readonly readonly: boolean;
11166
+ protected types: Map<string, string>;
11167
+ constructor(level: number, readonly?: boolean);
11168
+ add(name: string, type: string | TypeObject): this;
11169
+ addType(name: string, type: string | TypeObject): this;
11170
+ addConst(name: string, type: string | TypeObject): this;
11171
+ toString(): string;
11172
+ }
11173
+
11152
11174
  type ExtendedConfigOutput<S extends AnyZodObject | undefined = undefined> = S extends AnyZodObject ? BaseConfig & z.output<S> : BaseConfig;
11153
11175
  type ExtendedConfigInput<S extends AnyZodObject | undefined = undefined> = S extends AnyZodObject ? AppConfigInput & z.input<S> : AppConfigInput;
11154
11176
  type StackContext<S extends AnyZodObject | undefined = undefined> = {
@@ -11171,13 +11193,14 @@ type AppContext<S extends AnyZodObject | undefined = undefined> = {
11171
11193
  };
11172
11194
  type TypeGenContext<S extends AnyZodObject | undefined = undefined> = {
11173
11195
  config: ExtendedConfigOutput<S>;
11196
+ write: (file: string, data?: TypeGen | Buffer | string, include?: boolean) => Promise<void>;
11174
11197
  };
11175
11198
  type Plugin<S extends AnyZodObject | undefined = undefined> = {
11176
11199
  name: string;
11177
11200
  schema?: S;
11178
11201
  onApp?: (context: AppContext<S>) => void;
11179
11202
  onStack?: (context: StackContext<S>) => void;
11180
- onTypeGen?: (context: TypeGenContext<S>) => string | void;
11203
+ onTypeGen?: (context: TypeGenContext<S>) => void | Promise<void>;
11181
11204
  };
11182
11205
  declare const definePlugin: <S extends AnyZodObject | undefined = undefined>(plugin: Plugin<S>) => Plugin<S>;
11183
11206
 
@@ -11277,6 +11300,9 @@ declare const createHttpClient: <S extends Partial<Record<Method, Routes>>>(fetc
11277
11300
  post<P_2 extends keyof S["POST"]>(routeKey: Extract<P_2, string>, props?: Props<GetRoute<S, "POST", P_2>> | undefined): Promise<GetRoute<S, "POST", P_2>["response"]>;
11278
11301
  };
11279
11302
 
11303
+ interface GraphQL {
11304
+ }
11305
+
11280
11306
  type FunctionProps<H extends Handler<S>, S extends BaseSchema> = {
11281
11307
  handle: H;
11282
11308
  schema?: S;
@@ -12137,4 +12163,4 @@ declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (Stack
12137
12163
  });
12138
12164
  declare const defineAppConfig: (config: AppConfig | AppConfigFactory<AppConfig>) => CombinedDefaultPluginsConfigInput | AppConfigFactory<CombinedDefaultPluginsConfigInput>;
12139
12165
 
12140
- export { APP, AppConfig, Auth, AuthResources, Cache, CacheResources, Config, ConfigResources, CronProps, Fn, Function, FunctionMock, FunctionMockResponse, FunctionProps, FunctionResources, HTTP, HttpFetcher, Plugin, Queue, QueueMock, QueueMockResponse, QueueProps, QueueResources, STACK, Search, SearchResources, StackConfig, Store, StoreResources, Table, TableResources, Topic, TopicMock, TopicMockResponse, TopicProps, TopicResources, createHttpClient, createHttpFetcher, cron, defineAppConfig, definePlugin, defineStackConfig, func, getAuthName, getAuthProps, getCacheProps, getConfigName, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getStoreName, getTableName, getTopicName, mockFunction, mockQueue, mockTopic, queue, topic };
12166
+ export { APP, AppConfig, Auth, AuthResources, Cache, CacheResources, Config, ConfigResources, CronProps, Fn, Function, FunctionMock, FunctionMockResponse, FunctionProps, FunctionResources, GraphQL, HTTP, HttpFetcher, Plugin, Queue, QueueMock, QueueMockResponse, QueueProps, QueueResources, STACK, Search, SearchResources, StackConfig, Store, StoreResources, Table, TableResources, Topic, TopicMock, TopicMockResponse, TopicProps, TopicResources, createHttpClient, createHttpFetcher, cron, defineAppConfig, definePlugin, defineStackConfig, func, getAuthName, getAuthProps, getCacheProps, getConfigName, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getStoreName, getTableName, getTopicName, mockFunction, mockQueue, mockTopic, queue, topic };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.114",
3
+ "version": "0.0.116",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -78,6 +78,7 @@
78
78
  "vitest": "^0.34.6",
79
79
  "wrap-ansi": "^8.1.0",
80
80
  "zod": "^3.21.4",
81
+ "@awsless/graphql": "^0.0.3",
81
82
  "@awsless/code": "^0.0.10"
82
83
  },
83
84
  "scripts": {