@awsless/awsless 0.0.593 → 0.0.595

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,6 +750,13 @@ 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
+ };
753
760
  var debug = (...parts) => {
754
761
  queue.push({
755
762
  date: /* @__PURE__ */ new Date(),
@@ -2346,8 +2353,8 @@ import { readFile as readFile2 } from "fs/promises";
2346
2353
  import { basename, dirname as dirname2, extname, join as join4 } from "path";
2347
2354
  var readConfig = async (file) => {
2348
2355
  try {
2349
- const json2 = await readFile2(file, "utf8");
2350
- const data = Bun.JSON5.parse(json2);
2356
+ const json3 = await readFile2(file, "utf8");
2357
+ const data = Bun.JSON5.parse(json3);
2351
2358
  return data;
2352
2359
  } catch (error) {
2353
2360
  if (error instanceof Error) {
@@ -3140,6 +3147,96 @@ var getGlobalOnFailure = (ctx) => {
3140
3147
  return ctx.shared.get("on-failure", "queue-arn");
3141
3148
  };
3142
3149
 
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
+
3143
3240
  // src/feature/function/build/zip.ts
3144
3241
  import { createReadStream } from "fs";
3145
3242
  import JSZip from "jszip";
@@ -3167,7 +3264,7 @@ import { toMebibytes as toMebibytes2 } from "@awsless/size";
3167
3264
  import { pascalCase } from "change-case";
3168
3265
 
3169
3266
  // src/util/cache.ts
3170
- import { createHash } from "node:crypto";
3267
+ import { createHash as createHash2 } from "node:crypto";
3171
3268
  import { createReadStream as createReadStream2 } from "node:fs";
3172
3269
  import { lstat as lstat2, readdir } from "node:fs/promises";
3173
3270
  import { join as join7 } from "node:path";
@@ -3177,11 +3274,11 @@ var generateCacheKey = async (directories2) => {
3177
3274
  for (const file of files) {
3178
3275
  hashes[file] = await createHashFromFile(file);
3179
3276
  }
3180
- return createHash("md5").update(JSON.stringify(hashes)).digest("hex");
3277
+ return createHash2("md5").update(JSON.stringify(hashes)).digest("hex");
3181
3278
  };
3182
3279
  var createHashFromFile = (file) => {
3183
3280
  return new Promise((resolve) => {
3184
- const hash = createHash("md5");
3281
+ const hash = createHash2("md5");
3185
3282
  const stream = createReadStream2(file);
3186
3283
  stream.on("data", (data) => hash.update(data));
3187
3284
  stream.on("end", () => resolve(hash.digest("hex")));
@@ -3205,9 +3302,9 @@ var listAllFiles = async (list3) => {
3205
3302
  };
3206
3303
 
3207
3304
  // src/util/id.ts
3208
- import { createHash as createHash2 } from "crypto";
3305
+ import { createHash as createHash3 } from "crypto";
3209
3306
  var shortId = (ns) => {
3210
- return createHash2("md5").update(ns).digest("hex").substring(0, 10);
3307
+ return createHash3("md5").update(ns).digest("hex").substring(0, 10);
3211
3308
  };
3212
3309
 
3213
3310
  // src/util/temp.ts
@@ -3268,76 +3365,6 @@ var zipBundle = async ({ directory }) => {
3268
3365
  });
3269
3366
  };
3270
3367
 
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
-
3341
3368
  // src/feature/function/util.ts
3342
3369
  var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
3343
3370
  let name;
@@ -3373,7 +3400,7 @@ var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
3373
3400
  const fingerprint = await generateFileHash(workspace, fileCode.file);
3374
3401
  return build3(fingerprint, async (write) => {
3375
3402
  const temp = await createTempFolder(`function--${name}`);
3376
- const bundle = await bundleTypeScriptWithBun({
3403
+ const bundle = await bundleTypeScript({
3377
3404
  file: fileCode.file,
3378
3405
  external: [
3379
3406
  ...fileCode.external ?? [],
@@ -4542,7 +4569,7 @@ import { camelCase as camelCase5, kebabCase as kebabCase6 } from "change-case";
4542
4569
  import { Group as Group13 } from "@terraforge/core";
4543
4570
  import { aws as aws14 } from "@terraforge/aws";
4544
4571
  import { mebibytes as mebibytes3 } from "@awsless/size";
4545
- import { dirname as dirname5, join as join10, relative as relative5 } from "path";
4572
+ import { dirname as dirname6, join as join10, relative as relative5 } from "path";
4546
4573
  import { fileURLToPath } from "node:url";
4547
4574
 
4548
4575
  // src/feature/function/prebuild.ts
@@ -4734,7 +4761,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
4734
4761
 
4735
4762
  // src/feature/rpc/index.ts
4736
4763
  import { toSeconds as toSeconds6 } from "@awsless/duration";
4737
- var __dirname = dirname5(fileURLToPath(import.meta.url));
4764
+ var __dirname = dirname6(fileURLToPath(import.meta.url));
4738
4765
  var rpcFeature = defineFeature({
4739
4766
  name: "rpc",
4740
4767
  async onTypeGen(ctx) {
@@ -5054,7 +5081,7 @@ var searchFeature = defineFeature({
5054
5081
  import { Group as Group15 } from "@terraforge/core";
5055
5082
  import { aws as aws16 } from "@terraforge/aws";
5056
5083
  import { glob as glob2 } from "glob";
5057
- import { dirname as dirname6, join as join11 } from "path";
5084
+ import { dirname as dirname7, join as join11 } from "path";
5058
5085
 
5059
5086
  // src/feature/site/util.ts
5060
5087
  import { contentType, lookup } from "mime-types";
@@ -5114,7 +5141,7 @@ var siteFeature = defineFeature({
5114
5141
  return build3(fingerprint, async (write) => {
5115
5142
  const credentialProvider = await getCredentials(ctx.appConfig.profile);
5116
5143
  const credentials = await credentialProvider();
5117
- const cwd = join11(directories.root, dirname6(ctx.stackConfig.file));
5144
+ const cwd = join11(directories.root, dirname7(ctx.stackConfig.file));
5118
5145
  const env = {
5119
5146
  // Pass the app config name
5120
5147
  APP: ctx.appConfig.name,
@@ -6141,12 +6168,12 @@ var layerFeature = defineFeature({
6141
6168
  // src/feature/image/index.ts
6142
6169
  import { Group as Group23 } from "@terraforge/core";
6143
6170
  import { aws as aws24 } from "@terraforge/aws";
6144
- import { join as join13, dirname as dirname7 } from "path";
6171
+ import { join as join13, dirname as dirname8 } from "path";
6145
6172
  import { mebibytes as mebibytes4 } from "@awsless/size";
6146
6173
  import { seconds as seconds7, toDays as toDays6 } from "@awsless/duration";
6147
6174
  import { fileURLToPath as fileURLToPath2 } from "url";
6148
6175
  import { glob as glob4 } from "glob";
6149
- var __dirname2 = dirname7(fileURLToPath2(import.meta.url));
6176
+ var __dirname2 = dirname8(fileURLToPath2(import.meta.url));
6150
6177
  var imageFeature = defineFeature({
6151
6178
  name: "image",
6152
6179
  onApp(ctx) {
@@ -6329,12 +6356,12 @@ var imageFeature = defineFeature({
6329
6356
  // src/feature/icon/index.ts
6330
6357
  import { Group as Group24 } from "@terraforge/core";
6331
6358
  import { aws as aws25 } from "@terraforge/aws";
6332
- import { join as join14, dirname as dirname8 } from "path";
6359
+ import { join as join14, dirname as dirname9 } from "path";
6333
6360
  import { mebibytes as mebibytes5 } from "@awsless/size";
6334
6361
  import { seconds as seconds8, toDays as toDays7 } from "@awsless/duration";
6335
6362
  import { fileURLToPath as fileURLToPath3 } from "url";
6336
6363
  import { glob as glob5 } from "glob";
6337
- var __dirname3 = dirname8(fileURLToPath3(import.meta.url));
6364
+ var __dirname3 = dirname9(fileURLToPath3(import.meta.url));
6338
6365
  var iconFeature = defineFeature({
6339
6366
  name: "icon",
6340
6367
  onStack(ctx) {
@@ -8627,7 +8654,7 @@ import wildstring3 from "wildstring";
8627
8654
  // src/build/__fingerprint.ts
8628
8655
  import { createHash as createHash6 } from "crypto";
8629
8656
  import { readdir as readdir4, readFile as readFile5, stat as stat4 } from "fs/promises";
8630
- import { basename as basename4, dirname as dirname9, extname as extname4, join as join17 } from "path";
8657
+ import { basename as basename4, dirname as dirname10, extname as extname4, join as join17 } from "path";
8631
8658
  import parseStaticImports from "parse-static-imports";
8632
8659
  var extensions = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
8633
8660
  var generateFileHashes = async (file, hashes) => {
@@ -8683,25 +8710,25 @@ var readFiles = async (files) => {
8683
8710
  };
8684
8711
  var findDependencies = async (file, code) => {
8685
8712
  const imports = await parseStaticImports(code);
8686
- return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join17(dirname9(file), value) : value);
8713
+ return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join17(dirname10(file), value) : value);
8687
8714
  };
8688
8715
 
8689
8716
  // src/cli/ui/complex/run-tests.ts
8690
8717
  import { parse as parse4, stringify } from "@awsless/json";
8691
8718
 
8692
8719
  // src/test/start.ts
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";
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";
8698
8725
  import { fileURLToPath as fileURLToPath4 } from "url";
8699
8726
  import { configDefaults } from "vitest/config";
8700
8727
  import { startVitest } from "vitest/node";
8701
8728
  var NullReporter = class {
8702
8729
  };
8703
8730
  var startTest = async (props) => {
8704
- const __dirname4 = dirname10(fileURLToPath4(import.meta.url));
8731
+ const __dirname4 = dirname11(fileURLToPath4(import.meta.url));
8705
8732
  const startTime = process.hrtime.bigint();
8706
8733
  process.noDeprecation = true;
8707
8734
  const vitest = await startVitest(
@@ -8748,10 +8775,10 @@ var startTest = async (props) => {
8748
8775
  {
8749
8776
  plugins: [
8750
8777
  // @ts-ignore
8751
- commonjs({ sourceMap: true }),
8778
+ commonjs2({ sourceMap: true }),
8752
8779
  // @ts-ignore
8753
- nodeResolve({ preferBuiltins: true }),
8754
- swc({
8780
+ nodeResolve2({ preferBuiltins: true }),
8781
+ swc2({
8755
8782
  jsc: {
8756
8783
  // baseUrl: dirname(input),
8757
8784
  minify: { sourceMap: true }
@@ -8759,7 +8786,7 @@ var startTest = async (props) => {
8759
8786
  sourceMaps: true
8760
8787
  }),
8761
8788
  // @ts-ignore
8762
- json()
8789
+ json2()
8763
8790
  ]
8764
8791
  }
8765
8792
  );
@@ -9278,7 +9305,7 @@ import { log as log20 } from "@awsless/clui";
9278
9305
 
9279
9306
  // src/type-gen/generate.ts
9280
9307
  import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
9281
- import { dirname as dirname11, join as join20, relative as relative7 } from "path";
9308
+ import { dirname as dirname12, join as join20, relative as relative7 } from "path";
9282
9309
  var generateTypes = async (props) => {
9283
9310
  const files = [];
9284
9311
  await Promise.all(
@@ -9292,7 +9319,7 @@ var generateTypes = async (props) => {
9292
9319
  if (include) {
9293
9320
  files.push(relative7(directories.root, path));
9294
9321
  }
9295
- await mkdir5(dirname11(path), { recursive: true });
9322
+ await mkdir5(dirname12(path), { recursive: true });
9296
9323
  await writeFile4(path, code);
9297
9324
  }
9298
9325
  }
@@ -9765,28 +9792,28 @@ var formatLog = (level, date, group, message) => {
9765
9792
  );
9766
9793
  };
9767
9794
  var parseJsonLog = (message) => {
9768
- let json2;
9795
+ let json3;
9769
9796
  try {
9770
- json2 = JSON.parse(message);
9797
+ json3 = JSON.parse(message);
9771
9798
  } catch (error) {
9772
9799
  }
9773
- if ("level" in json2 && typeof json2.level === "string" && "timestamp" in json2 && typeof json2.timestamp === "string" && "message" in json2) {
9800
+ if ("level" in json3 && typeof json3.level === "string" && "timestamp" in json3 && typeof json3.timestamp === "string" && "message" in json3) {
9774
9801
  return {
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)
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)
9778
9805
  };
9779
9806
  }
9780
- if ("type" in json2 && typeof json2.type === "string" && json2.type.startsWith("platform") && "time" in json2 && typeof json2.time === "string" && "record" in json2) {
9807
+ if ("type" in json3 && typeof json3.type === "string" && json3.type.startsWith("platform") && "time" in json3 && typeof json3.time === "string" && "record" in json3) {
9781
9808
  return {
9782
9809
  level: "SYSTEM",
9783
- message: JSON.stringify(json2.record, void 0, 2),
9784
- date: new Date(json2.time)
9810
+ message: JSON.stringify(json3.record, void 0, 2),
9811
+ date: new Date(json3.time)
9785
9812
  };
9786
9813
  }
9787
9814
  return {
9788
9815
  level: "INFO",
9789
- message: JSON.stringify(json2, void 0, 2)
9816
+ message: JSON.stringify(json3, void 0, 2)
9790
9817
  };
9791
9818
  };
9792
9819
 
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.593",
3
+ "version": "0.0.595",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -35,21 +35,21 @@
35
35
  "peerDependencies": {
36
36
  "@awsless/big-float": "^0.1.5",
37
37
  "@awsless/cloudwatch": "^0.0.1",
38
+ "@awsless/clui": "^0.0.8",
38
39
  "@awsless/duration": "^0.0.4",
40
+ "@awsless/iot": "^0.0.3",
39
41
  "@awsless/dynamodb": "^0.3.8",
40
42
  "@awsless/json": "^0.0.10",
41
- "@awsless/clui": "^0.0.8",
42
- "@awsless/iot": "^0.0.3",
43
43
  "@awsless/lambda": "^0.0.35",
44
- "@awsless/s3": "^0.0.21",
45
44
  "@awsless/mqtt": "^0.0.2",
45
+ "@awsless/s3": "^0.0.21",
46
46
  "@awsless/redis": "^0.0.14",
47
+ "@awsless/sqs": "^0.0.16",
47
48
  "@awsless/sns": "^0.0.10",
48
49
  "@awsless/open-search": "^0.0.21",
49
50
  "@awsless/validate": "^0.1.3",
50
51
  "@awsless/ssm": "^0.0.7",
51
- "@awsless/weak-cache": "^0.0.1",
52
- "@awsless/sqs": "^0.0.16"
52
+ "@awsless/weak-cache": "^0.0.1"
53
53
  },
54
54
  "dependencies": {
55
55
  "@arcanyx/cidr-slicer": "^0.3.0",
@@ -141,14 +141,14 @@
141
141
  "zod-to-json-schema": "^3.24.3",
142
142
  "@awsless/big-float": "^0.1.5",
143
143
  "@awsless/cloudwatch": "^0.0.1",
144
- "@awsless/clui": "^0.0.8",
145
144
  "@awsless/duration": "^0.0.4",
146
- "@awsless/scheduler": "^0.0.4",
147
145
  "@awsless/graphql": "^0.0.9",
148
146
  "@awsless/json": "^0.0.10",
149
- "@awsless/validate": "^0.1.3",
150
147
  "@awsless/size": "^0.0.2",
151
- "@awsless/ts-file-cache": "^0.0.12"
148
+ "@awsless/ts-file-cache": "^0.0.12",
149
+ "@awsless/scheduler": "^0.0.4",
150
+ "@awsless/validate": "^0.1.3",
151
+ "@awsless/clui": "^0.0.8"
152
152
  },
153
153
  "devDependencies": {
154
154
  "@node-rs/bcrypt": "^1.10.5",