@awsless/awsless 0.0.592 → 0.0.593

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
@@ -750,13 +750,6 @@ import { basename as basename2, dirname as dirname3, join as join5 } from "path"
750
750
 
751
751
  // src/cli/debug.ts
752
752
  var queue = [];
753
- var debugError = (error) => {
754
- queue.push({
755
- date: /* @__PURE__ */ new Date(),
756
- type: color.error.dim("error"),
757
- message: typeof error === "string" ? error : error instanceof Error ? color.error(error.message || "") : JSON.stringify(error)
758
- });
759
- };
760
753
  var debug = (...parts) => {
761
754
  queue.push({
762
755
  date: /* @__PURE__ */ new Date(),
@@ -2353,8 +2346,8 @@ import { readFile as readFile2 } from "fs/promises";
2353
2346
  import { basename, dirname as dirname2, extname, join as join4 } from "path";
2354
2347
  var readConfig = async (file) => {
2355
2348
  try {
2356
- const json3 = await readFile2(file, "utf8");
2357
- const data = Bun.JSON5.parse(json3);
2349
+ const json2 = await readFile2(file, "utf8");
2350
+ const data = Bun.JSON5.parse(json2);
2358
2351
  return data;
2359
2352
  } catch (error) {
2360
2353
  if (error instanceof Error) {
@@ -3147,96 +3140,6 @@ var getGlobalOnFailure = (ctx) => {
3147
3140
  return ctx.shared.get("on-failure", "queue-arn");
3148
3141
  };
3149
3142
 
3150
- // src/feature/function/build/typescript/bundle.ts
3151
- import commonjs from "@rollup/plugin-commonjs";
3152
- import json from "@rollup/plugin-json";
3153
- import nodeResolve from "@rollup/plugin-node-resolve";
3154
- import { createHash } from "crypto";
3155
- import { dirname as dirname5 } from "path";
3156
- import { rollup } from "rollup";
3157
- import natives from "rollup-plugin-natives";
3158
- import { importAsString } from "rollup-plugin-string-import";
3159
- import { swc, minify as swcMinify } from "rollup-plugin-swc3";
3160
- var bundleTypeScript = async ({
3161
- format: format2 = "esm",
3162
- minify = true,
3163
- file,
3164
- nativeDir,
3165
- external,
3166
- importAsString: importAsStringList
3167
- }) => {
3168
- const bundle = await rollup({
3169
- input: file,
3170
- external: (importee) => {
3171
- return importee.startsWith("@aws-sdk") || importee.startsWith("aws-sdk") || external?.includes(importee);
3172
- },
3173
- onwarn: (error) => {
3174
- debugError(error.message);
3175
- },
3176
- treeshake: {
3177
- preset: "smallest",
3178
- moduleSideEffects: (id) => file === id
3179
- },
3180
- plugins: [
3181
- commonjs({ sourceMap: true }),
3182
- nodeResolve({ preferBuiltins: true }),
3183
- // @ts-ignore
3184
- nativeDir ? natives({
3185
- copyTo: nativeDir,
3186
- targetEsm: format2 === "esm",
3187
- sourcemap: true
3188
- }) : void 0,
3189
- swc({
3190
- // minify,
3191
- // module: true,
3192
- jsc: {
3193
- baseUrl: dirname5(file),
3194
- minify: { sourceMap: true }
3195
- },
3196
- sourceMaps: true
3197
- }),
3198
- minify ? swcMinify({
3199
- module: format2 === "esm",
3200
- sourceMap: true,
3201
- compress: true
3202
- }) : void 0,
3203
- json(),
3204
- importAsStringList ? importAsString({
3205
- include: importAsStringList
3206
- }) : void 0
3207
- ]
3208
- });
3209
- const ext = format2 === "esm" ? "mjs" : "js";
3210
- const result = await bundle.generate({
3211
- format: format2,
3212
- sourcemap: "hidden",
3213
- exports: "auto",
3214
- manualChunks: {},
3215
- entryFileNames: `index.${ext}`,
3216
- chunkFileNames: `[name].${ext}`
3217
- });
3218
- const hash = createHash("sha1");
3219
- const files = [];
3220
- for (const item of result.output) {
3221
- if (item.type !== "chunk") {
3222
- continue;
3223
- }
3224
- const code = Buffer.from(item.code, "utf8");
3225
- const map = item.map ? Buffer.from(item.map.toString(), "utf8") : void 0;
3226
- item.map?.version;
3227
- hash.update(code);
3228
- files.push({
3229
- name: item.fileName,
3230
- code,
3231
- map
3232
- });
3233
- }
3234
- return {
3235
- hash: hash.digest("hex"),
3236
- files
3237
- };
3238
- };
3239
-
3240
3143
  // src/feature/function/build/zip.ts
3241
3144
  import { createReadStream } from "fs";
3242
3145
  import JSZip from "jszip";
@@ -3264,7 +3167,7 @@ import { toMebibytes as toMebibytes2 } from "@awsless/size";
3264
3167
  import { pascalCase } from "change-case";
3265
3168
 
3266
3169
  // src/util/cache.ts
3267
- import { createHash as createHash2 } from "node:crypto";
3170
+ import { createHash } from "node:crypto";
3268
3171
  import { createReadStream as createReadStream2 } from "node:fs";
3269
3172
  import { lstat as lstat2, readdir } from "node:fs/promises";
3270
3173
  import { join as join7 } from "node:path";
@@ -3274,11 +3177,11 @@ var generateCacheKey = async (directories2) => {
3274
3177
  for (const file of files) {
3275
3178
  hashes[file] = await createHashFromFile(file);
3276
3179
  }
3277
- return createHash2("md5").update(JSON.stringify(hashes)).digest("hex");
3180
+ return createHash("md5").update(JSON.stringify(hashes)).digest("hex");
3278
3181
  };
3279
3182
  var createHashFromFile = (file) => {
3280
3183
  return new Promise((resolve) => {
3281
- const hash = createHash2("md5");
3184
+ const hash = createHash("md5");
3282
3185
  const stream = createReadStream2(file);
3283
3186
  stream.on("data", (data) => hash.update(data));
3284
3187
  stream.on("end", () => resolve(hash.digest("hex")));
@@ -3302,9 +3205,9 @@ var listAllFiles = async (list3) => {
3302
3205
  };
3303
3206
 
3304
3207
  // src/util/id.ts
3305
- import { createHash as createHash3 } from "crypto";
3208
+ import { createHash as createHash2 } from "crypto";
3306
3209
  var shortId = (ns) => {
3307
- return createHash3("md5").update(ns).digest("hex").substring(0, 10);
3210
+ return createHash2("md5").update(ns).digest("hex").substring(0, 10);
3308
3211
  };
3309
3212
 
3310
3213
  // src/util/temp.ts
@@ -3365,6 +3268,76 @@ var zipBundle = async ({ directory }) => {
3365
3268
  });
3366
3269
  };
3367
3270
 
3271
+ // src/feature/function/build/typescript/bun.ts
3272
+ import { minify as swcMinify } from "@swc/core";
3273
+ import { createHash as createHash3 } from "crypto";
3274
+ var bundleTypeScriptWithBun = async ({
3275
+ format: format2 = "esm",
3276
+ minify = true,
3277
+ file,
3278
+ nativeDir,
3279
+ external,
3280
+ importAsString: importAsStringList
3281
+ }) => {
3282
+ const build3 = await Bun.build({
3283
+ entrypoints: [file],
3284
+ target: "node",
3285
+ format: format2,
3286
+ sourcemap: "none",
3287
+ // sourcemap: 'external',
3288
+ // minify: false,
3289
+ external: ["@aws-sdk/*", "aws-sdk", ...external ?? []],
3290
+ naming: {
3291
+ entry: `index.js`,
3292
+ chunk: `[name].js`
3293
+ },
3294
+ plugins: [
3295
+ {
3296
+ name: "string-loader",
3297
+ setup(build4) {
3298
+ if (importAsStringList) {
3299
+ build4.onLoad({ filter: new RegExp(importAsStringList.join("|")) }, async (args) => {
3300
+ return {
3301
+ contents: `export default ${JSON.stringify(await Bun.file(args.path).text())};`,
3302
+ loader: "js"
3303
+ };
3304
+ });
3305
+ }
3306
+ }
3307
+ }
3308
+ // nativesPlugin(nativeDir),
3309
+ ]
3310
+ });
3311
+ if (!build3.success) {
3312
+ throw new Error("Bun build error");
3313
+ }
3314
+ const hash = createHash3("sha1");
3315
+ const files = [];
3316
+ for await (const artifact of build3.outputs) {
3317
+ if (artifact.kind === "asset" || artifact.kind === "sourcemap") {
3318
+ continue;
3319
+ }
3320
+ const originalCode = await artifact.text();
3321
+ const { code } = await swcMinify(originalCode, {
3322
+ toplevel: true,
3323
+ module: true,
3324
+ compress: true,
3325
+ mangle: true,
3326
+ sourceMap: false
3327
+ });
3328
+ hash.update(code);
3329
+ files.push({
3330
+ name: artifact.path.split("/").pop(),
3331
+ code: Buffer.from(code)
3332
+ // map: map ? Buffer.from(map) : undefined,
3333
+ });
3334
+ }
3335
+ return {
3336
+ hash: hash.digest("hex"),
3337
+ files
3338
+ };
3339
+ };
3340
+
3368
3341
  // src/feature/function/util.ts
3369
3342
  var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
3370
3343
  let name;
@@ -3400,7 +3373,7 @@ var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
3400
3373
  const fingerprint = await generateFileHash(workspace, fileCode.file);
3401
3374
  return build3(fingerprint, async (write) => {
3402
3375
  const temp = await createTempFolder(`function--${name}`);
3403
- const bundle = await bundleTypeScript({
3376
+ const bundle = await bundleTypeScriptWithBun({
3404
3377
  file: fileCode.file,
3405
3378
  external: [
3406
3379
  ...fileCode.external ?? [],
@@ -4569,7 +4542,7 @@ import { camelCase as camelCase5, kebabCase as kebabCase6 } from "change-case";
4569
4542
  import { Group as Group13 } from "@terraforge/core";
4570
4543
  import { aws as aws14 } from "@terraforge/aws";
4571
4544
  import { mebibytes as mebibytes3 } from "@awsless/size";
4572
- import { dirname as dirname6, join as join10, relative as relative5 } from "path";
4545
+ import { dirname as dirname5, join as join10, relative as relative5 } from "path";
4573
4546
  import { fileURLToPath } from "node:url";
4574
4547
 
4575
4548
  // src/feature/function/prebuild.ts
@@ -4761,7 +4734,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
4761
4734
 
4762
4735
  // src/feature/rpc/index.ts
4763
4736
  import { toSeconds as toSeconds6 } from "@awsless/duration";
4764
- var __dirname = dirname6(fileURLToPath(import.meta.url));
4737
+ var __dirname = dirname5(fileURLToPath(import.meta.url));
4765
4738
  var rpcFeature = defineFeature({
4766
4739
  name: "rpc",
4767
4740
  async onTypeGen(ctx) {
@@ -5081,7 +5054,7 @@ var searchFeature = defineFeature({
5081
5054
  import { Group as Group15 } from "@terraforge/core";
5082
5055
  import { aws as aws16 } from "@terraforge/aws";
5083
5056
  import { glob as glob2 } from "glob";
5084
- import { dirname as dirname7, join as join11 } from "path";
5057
+ import { dirname as dirname6, join as join11 } from "path";
5085
5058
 
5086
5059
  // src/feature/site/util.ts
5087
5060
  import { contentType, lookup } from "mime-types";
@@ -5141,7 +5114,7 @@ var siteFeature = defineFeature({
5141
5114
  return build3(fingerprint, async (write) => {
5142
5115
  const credentialProvider = await getCredentials(ctx.appConfig.profile);
5143
5116
  const credentials = await credentialProvider();
5144
- const cwd = join11(directories.root, dirname7(ctx.stackConfig.file));
5117
+ const cwd = join11(directories.root, dirname6(ctx.stackConfig.file));
5145
5118
  const env = {
5146
5119
  // Pass the app config name
5147
5120
  APP: ctx.appConfig.name,
@@ -6168,12 +6141,12 @@ var layerFeature = defineFeature({
6168
6141
  // src/feature/image/index.ts
6169
6142
  import { Group as Group23 } from "@terraforge/core";
6170
6143
  import { aws as aws24 } from "@terraforge/aws";
6171
- import { join as join13, dirname as dirname8 } from "path";
6144
+ import { join as join13, dirname as dirname7 } from "path";
6172
6145
  import { mebibytes as mebibytes4 } from "@awsless/size";
6173
6146
  import { seconds as seconds7, toDays as toDays6 } from "@awsless/duration";
6174
6147
  import { fileURLToPath as fileURLToPath2 } from "url";
6175
6148
  import { glob as glob4 } from "glob";
6176
- var __dirname2 = dirname8(fileURLToPath2(import.meta.url));
6149
+ var __dirname2 = dirname7(fileURLToPath2(import.meta.url));
6177
6150
  var imageFeature = defineFeature({
6178
6151
  name: "image",
6179
6152
  onApp(ctx) {
@@ -6356,12 +6329,12 @@ var imageFeature = defineFeature({
6356
6329
  // src/feature/icon/index.ts
6357
6330
  import { Group as Group24 } from "@terraforge/core";
6358
6331
  import { aws as aws25 } from "@terraforge/aws";
6359
- import { join as join14, dirname as dirname9 } from "path";
6332
+ import { join as join14, dirname as dirname8 } from "path";
6360
6333
  import { mebibytes as mebibytes5 } from "@awsless/size";
6361
6334
  import { seconds as seconds8, toDays as toDays7 } from "@awsless/duration";
6362
6335
  import { fileURLToPath as fileURLToPath3 } from "url";
6363
6336
  import { glob as glob5 } from "glob";
6364
- var __dirname3 = dirname9(fileURLToPath3(import.meta.url));
6337
+ var __dirname3 = dirname8(fileURLToPath3(import.meta.url));
6365
6338
  var iconFeature = defineFeature({
6366
6339
  name: "icon",
6367
6340
  onStack(ctx) {
@@ -8654,7 +8627,7 @@ import wildstring3 from "wildstring";
8654
8627
  // src/build/__fingerprint.ts
8655
8628
  import { createHash as createHash6 } from "crypto";
8656
8629
  import { readdir as readdir4, readFile as readFile5, stat as stat4 } from "fs/promises";
8657
- import { basename as basename4, dirname as dirname10, extname as extname4, join as join17 } from "path";
8630
+ import { basename as basename4, dirname as dirname9, extname as extname4, join as join17 } from "path";
8658
8631
  import parseStaticImports from "parse-static-imports";
8659
8632
  var extensions = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
8660
8633
  var generateFileHashes = async (file, hashes) => {
@@ -8710,25 +8683,25 @@ var readFiles = async (files) => {
8710
8683
  };
8711
8684
  var findDependencies = async (file, code) => {
8712
8685
  const imports = await parseStaticImports(code);
8713
- return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join17(dirname10(file), value) : value);
8686
+ return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join17(dirname9(file), value) : value);
8714
8687
  };
8715
8688
 
8716
8689
  // src/cli/ui/complex/run-tests.ts
8717
8690
  import { parse as parse4, stringify } from "@awsless/json";
8718
8691
 
8719
8692
  // src/test/start.ts
8720
- import commonjs2 from "@rollup/plugin-commonjs";
8721
- import json2 from "@rollup/plugin-json";
8722
- import nodeResolve2 from "@rollup/plugin-node-resolve";
8723
- import { dirname as dirname11, join as join18 } from "path";
8724
- import { swc as swc2 } from "rollup-plugin-swc3";
8693
+ import commonjs from "@rollup/plugin-commonjs";
8694
+ import json from "@rollup/plugin-json";
8695
+ import nodeResolve from "@rollup/plugin-node-resolve";
8696
+ import { dirname as dirname10, join as join18 } from "path";
8697
+ import { swc } from "rollup-plugin-swc3";
8725
8698
  import { fileURLToPath as fileURLToPath4 } from "url";
8726
8699
  import { configDefaults } from "vitest/config";
8727
8700
  import { startVitest } from "vitest/node";
8728
8701
  var NullReporter = class {
8729
8702
  };
8730
8703
  var startTest = async (props) => {
8731
- const __dirname4 = dirname11(fileURLToPath4(import.meta.url));
8704
+ const __dirname4 = dirname10(fileURLToPath4(import.meta.url));
8732
8705
  const startTime = process.hrtime.bigint();
8733
8706
  process.noDeprecation = true;
8734
8707
  const vitest = await startVitest(
@@ -8775,10 +8748,10 @@ var startTest = async (props) => {
8775
8748
  {
8776
8749
  plugins: [
8777
8750
  // @ts-ignore
8778
- commonjs2({ sourceMap: true }),
8751
+ commonjs({ sourceMap: true }),
8779
8752
  // @ts-ignore
8780
- nodeResolve2({ preferBuiltins: true }),
8781
- swc2({
8753
+ nodeResolve({ preferBuiltins: true }),
8754
+ swc({
8782
8755
  jsc: {
8783
8756
  // baseUrl: dirname(input),
8784
8757
  minify: { sourceMap: true }
@@ -8786,7 +8759,7 @@ var startTest = async (props) => {
8786
8759
  sourceMaps: true
8787
8760
  }),
8788
8761
  // @ts-ignore
8789
- json2()
8762
+ json()
8790
8763
  ]
8791
8764
  }
8792
8765
  );
@@ -9305,7 +9278,7 @@ import { log as log20 } from "@awsless/clui";
9305
9278
 
9306
9279
  // src/type-gen/generate.ts
9307
9280
  import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
9308
- import { dirname as dirname12, join as join20, relative as relative7 } from "path";
9281
+ import { dirname as dirname11, join as join20, relative as relative7 } from "path";
9309
9282
  var generateTypes = async (props) => {
9310
9283
  const files = [];
9311
9284
  await Promise.all(
@@ -9319,7 +9292,7 @@ var generateTypes = async (props) => {
9319
9292
  if (include) {
9320
9293
  files.push(relative7(directories.root, path));
9321
9294
  }
9322
- await mkdir5(dirname12(path), { recursive: true });
9295
+ await mkdir5(dirname11(path), { recursive: true });
9323
9296
  await writeFile4(path, code);
9324
9297
  }
9325
9298
  }
@@ -9792,28 +9765,28 @@ var formatLog = (level, date, group, message) => {
9792
9765
  );
9793
9766
  };
9794
9767
  var parseJsonLog = (message) => {
9795
- let json3;
9768
+ let json2;
9796
9769
  try {
9797
- json3 = JSON.parse(message);
9770
+ json2 = JSON.parse(message);
9798
9771
  } catch (error) {
9799
9772
  }
9800
- if ("level" in json3 && typeof json3.level === "string" && "timestamp" in json3 && typeof json3.timestamp === "string" && "message" in json3) {
9773
+ if ("level" in json2 && typeof json2.level === "string" && "timestamp" in json2 && typeof json2.timestamp === "string" && "message" in json2) {
9801
9774
  return {
9802
- level: json3.level,
9803
- message: typeof json3.message === "string" ? json3.message : JSON.stringify(json3.message, void 0, 2),
9804
- date: new Date(json3.timestamp)
9775
+ level: json2.level,
9776
+ message: typeof json2.message === "string" ? json2.message : JSON.stringify(json2.message, void 0, 2),
9777
+ date: new Date(json2.timestamp)
9805
9778
  };
9806
9779
  }
9807
- if ("type" in json3 && typeof json3.type === "string" && json3.type.startsWith("platform") && "time" in json3 && typeof json3.time === "string" && "record" in json3) {
9780
+ if ("type" in json2 && typeof json2.type === "string" && json2.type.startsWith("platform") && "time" in json2 && typeof json2.time === "string" && "record" in json2) {
9808
9781
  return {
9809
9782
  level: "SYSTEM",
9810
- message: JSON.stringify(json3.record, void 0, 2),
9811
- date: new Date(json3.time)
9783
+ message: JSON.stringify(json2.record, void 0, 2),
9784
+ date: new Date(json2.time)
9812
9785
  };
9813
9786
  }
9814
9787
  return {
9815
9788
  level: "INFO",
9816
- message: JSON.stringify(json3, void 0, 2)
9789
+ message: JSON.stringify(json2, void 0, 2)
9817
9790
  };
9818
9791
  };
9819
9792
 
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.592",
3
+ "version": "0.0.593",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -33,23 +33,23 @@
33
33
  ]
34
34
  },
35
35
  "peerDependencies": {
36
- "@awsless/cloudwatch": "^0.0.1",
37
36
  "@awsless/big-float": "^0.1.5",
38
- "@awsless/clui": "^0.0.8",
37
+ "@awsless/cloudwatch": "^0.0.1",
39
38
  "@awsless/duration": "^0.0.4",
40
39
  "@awsless/dynamodb": "^0.3.8",
41
40
  "@awsless/json": "^0.0.10",
41
+ "@awsless/clui": "^0.0.8",
42
42
  "@awsless/iot": "^0.0.3",
43
- "@awsless/mqtt": "^0.0.2",
44
- "@awsless/open-search": "^0.0.21",
45
43
  "@awsless/lambda": "^0.0.35",
46
44
  "@awsless/s3": "^0.0.21",
45
+ "@awsless/mqtt": "^0.0.2",
47
46
  "@awsless/redis": "^0.0.14",
48
- "@awsless/sqs": "^0.0.16",
49
47
  "@awsless/sns": "^0.0.10",
48
+ "@awsless/open-search": "^0.0.21",
50
49
  "@awsless/validate": "^0.1.3",
50
+ "@awsless/ssm": "^0.0.7",
51
51
  "@awsless/weak-cache": "^0.0.1",
52
- "@awsless/ssm": "^0.0.7"
52
+ "@awsless/sqs": "^0.0.16"
53
53
  },
54
54
  "dependencies": {
55
55
  "@arcanyx/cidr-slicer": "^0.3.0",
@@ -143,12 +143,12 @@
143
143
  "@awsless/cloudwatch": "^0.0.1",
144
144
  "@awsless/clui": "^0.0.8",
145
145
  "@awsless/duration": "^0.0.4",
146
+ "@awsless/scheduler": "^0.0.4",
146
147
  "@awsless/graphql": "^0.0.9",
147
148
  "@awsless/json": "^0.0.10",
149
+ "@awsless/validate": "^0.1.3",
148
150
  "@awsless/size": "^0.0.2",
149
- "@awsless/scheduler": "^0.0.4",
150
- "@awsless/ts-file-cache": "^0.0.12",
151
- "@awsless/validate": "^0.1.3"
151
+ "@awsless/ts-file-cache": "^0.0.12"
152
152
  },
153
153
  "devDependencies": {
154
154
  "@node-rs/bcrypt": "^1.10.5",