@awsless/awsless 0.0.599 → 0.0.600

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
@@ -826,6 +826,7 @@ var AuthDefaultSchema = z9.record(
826
826
  // .optional()
827
827
  // .describe('The email configuration for sending messages.'),
828
828
  // secret: z.boolean().default(false).describe('Specifies whether you want to generate a client secret.'),
829
+ groups: z9.string().array().default([]).describe("Specifies a list of groups that a user can belong to."),
829
830
  username: z9.object({
830
831
  // emailAlias: z.boolean().default(true).describe('Allow the user email to be used as username.'),
831
832
  caseSensitive: z9.boolean().default(false).describe(
@@ -1084,11 +1085,11 @@ var FunctionDefaultSchema = z15.object({
1084
1085
  // container
1085
1086
  warm: WarmSchema.default(0),
1086
1087
  vpc: VPCSchema.default(false),
1087
- log: LogSchema.default(true).transform((log27) => ({
1088
- retention: log27.retention ?? days(7),
1089
- level: "level" in log27 ? log27.level : "error",
1090
- system: "system" in log27 ? log27.system : "warn",
1091
- format: "format" in log27 ? log27.format : "json"
1088
+ log: LogSchema.default(true).transform((log28) => ({
1089
+ retention: log28.retention ?? days(7),
1090
+ level: "level" in log28 ? log28.level : "error",
1091
+ system: "system" in log28 ? log28.system : "warn",
1092
+ format: "format" in log28 ? log28.format : "json"
1092
1093
  })),
1093
1094
  timeout: TimeoutSchema.default("10 seconds"),
1094
1095
  memorySize: MemorySizeSchema.default("128 MB"),
@@ -1616,8 +1617,8 @@ var InstanceDefaultSchema = z25.object({
1616
1617
  permissions: PermissionsSchema2.optional(),
1617
1618
  healthCheck: HealthCheckSchema.optional(),
1618
1619
  // restartPolicy: RestartPolicySchema.default({ enabled: true }),
1619
- log: LogSchema2.default(true).transform((log27) => ({
1620
- retention: log27.retention ?? days4(7)
1620
+ log: LogSchema2.default(true).transform((log28) => ({
1621
+ retention: log28.retention ?? days4(7)
1621
1622
  }))
1622
1623
  }).default({});
1623
1624
 
@@ -2738,6 +2739,12 @@ var authFeature = defineFeature({
2738
2739
  explicitAuthFlows: ["ALLOW_USER_SRP_AUTH", "ALLOW_REFRESH_TOKEN_AUTH"],
2739
2740
  preventUserExistenceErrors: "ENABLED"
2740
2741
  });
2742
+ for (const name2 of props.groups) {
2743
+ new aws2.cognito.UserGroup(group, name2, {
2744
+ name: name2,
2745
+ userPoolId: userPool.id
2746
+ });
2747
+ }
2741
2748
  ctx.bind(`AUTH_${constantCase2(id)}_USER_POOL_ID`, userPool.id);
2742
2749
  ctx.bind(`AUTH_${constantCase2(id)}_CLIENT_ID`, client.id);
2743
2750
  ctx.shared.add("auth", "user-pool-arn", id, userPool.arn);
@@ -6528,7 +6535,7 @@ var buildExecutable = async (input, outputPath, architecture) => {
6528
6535
  }
6529
6536
  if (!result.success) {
6530
6537
  throw new ExpectedError(`Executable build failed:
6531
- ${result.logs?.map((log27) => log27.message).join("\n")}`);
6538
+ ${result.logs?.map((log28) => log28.message).join("\n")}`);
6532
6539
  }
6533
6540
  const file = await readFile4(filePath);
6534
6541
  return {
@@ -8821,10 +8828,10 @@ var startTest = async (props) => {
8821
8828
  tests.push(entry);
8822
8829
  if ("task" in test2) {
8823
8830
  const task2 = test2.task;
8824
- for (const log27 of task2.logs ?? []) {
8831
+ for (const log28 of task2.logs ?? []) {
8825
8832
  entry.logs.push({
8826
- time: log27.time,
8827
- text: log27.content
8833
+ time: log28.time,
8834
+ text: log28.content
8828
8835
  });
8829
8836
  }
8830
8837
  }
@@ -8892,7 +8899,7 @@ var logTestLogs = (event) => {
8892
8899
  ].join(" "),
8893
8900
  color.line(icon.dot)
8894
8901
  );
8895
- log16.message(test2.logs.map((log27) => log27.text).join("\n"));
8902
+ log16.message(test2.logs.map((log28) => log28.text).join("\n"));
8896
8903
  }
8897
8904
  }
8898
8905
  };
@@ -9109,11 +9116,13 @@ var deploy = (program2) => {
9109
9116
 
9110
9117
  // src/cli/command/auth/user/create.ts
9111
9118
  import {
9119
+ AdminAddUserToGroupCommand,
9112
9120
  AdminCreateUserCommand,
9113
9121
  AdminSetUserPasswordCommand,
9114
- CognitoIdentityProviderClient
9122
+ CognitoIdentityProviderClient,
9123
+ UsernameExistsException
9115
9124
  } from "@aws-sdk/client-cognito-identity-provider";
9116
- import { prompt as prompt8 } from "@awsless/clui";
9125
+ import { log as log19, prompt as prompt8 } from "@awsless/clui";
9117
9126
  var create = (program2) => {
9118
9127
  program2.command("create").argument("[name]", "The name of the auth instance").description("Create an user for your userpool").action(async (name) => {
9119
9128
  await layout("auth user create", async ({ appConfig, stackConfigs }) => {
@@ -9134,24 +9143,31 @@ var create = (program2) => {
9134
9143
  }))
9135
9144
  });
9136
9145
  }
9137
- if (!(name in appConfig.defaults.auth)) {
9146
+ const props = appConfig.defaults.auth[name];
9147
+ if (!props) {
9138
9148
  throw new ExpectedError(`Provided auth name doesn't exist inside your app config.`);
9139
9149
  }
9140
- const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
9141
- const { workspace } = await createWorkSpace({
9142
- credentials,
9143
- accountId,
9144
- profile,
9145
- region
9150
+ const userPoolId = await log19.task({
9151
+ initialMessage: "Loading auth userpool...",
9152
+ successMessage: "Done loading auth userpool.",
9153
+ errorMessage: "Failed loading auth userpool.",
9154
+ async task() {
9155
+ const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
9156
+ const { workspace } = await createWorkSpace({
9157
+ credentials,
9158
+ accountId,
9159
+ profile,
9160
+ region
9161
+ });
9162
+ await workspace.hydrate(app);
9163
+ try {
9164
+ return await shared.entry("auth", `user-pool-id`, name);
9165
+ } catch (_) {
9166
+ throw new ExpectedError(`The auth userpool hasn't been deployed yet.`);
9167
+ }
9168
+ }
9146
9169
  });
9147
- await workspace.hydrate(app);
9148
- let userPoolId;
9149
- try {
9150
- userPoolId = await shared.entry("auth", `user-pool-id`, name);
9151
- } catch (_) {
9152
- throw new ExpectedError(`The auth userpool hasn't been deployed yet.`);
9153
- }
9154
- const user2 = await prompt8.text({
9170
+ const username = await prompt8.text({
9155
9171
  message: "Username:",
9156
9172
  validate(value) {
9157
9173
  if (!value) {
@@ -9160,35 +9176,84 @@ var create = (program2) => {
9160
9176
  return;
9161
9177
  }
9162
9178
  });
9163
- const pass = await prompt8.password({
9179
+ const password = await prompt8.password({
9164
9180
  message: "Password:",
9165
9181
  validate(value) {
9166
9182
  if (!value) {
9167
9183
  return "Required";
9168
9184
  }
9185
+ if (value.length < props.password.minLength) {
9186
+ return `Min length is ${props.password.minLength}`;
9187
+ }
9188
+ if (props.password.lowercase && value.toUpperCase() === value) {
9189
+ return `Should include lowercase characters`;
9190
+ }
9191
+ if (props.password.uppercase && value.toLowerCase() === value) {
9192
+ return `Should include uppercase characters`;
9193
+ }
9194
+ if (props.password.numbers && !/\d/.test(value)) {
9195
+ return `Should include numbers`;
9196
+ }
9197
+ if (props.password.symbols && !/[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/.test(value)) {
9198
+ return `Should include symbols`;
9199
+ }
9169
9200
  return;
9170
9201
  }
9171
9202
  });
9203
+ let groups = [];
9204
+ if (props.groups.length > 0) {
9205
+ groups = await prompt8.multiSelect({
9206
+ message: "Groups:",
9207
+ required: false,
9208
+ options: props.groups.map((g) => ({
9209
+ value: g
9210
+ }))
9211
+ });
9212
+ }
9172
9213
  const client = new CognitoIdentityProviderClient({
9173
9214
  region,
9174
9215
  credentials
9175
9216
  });
9176
- await client.send(
9177
- new AdminCreateUserCommand({
9178
- UserPoolId: userPoolId,
9179
- Username: user2.toString(),
9180
- TemporaryPassword: pass.toString()
9181
- })
9182
- );
9183
- await client.send(
9184
- new AdminSetUserPasswordCommand({
9185
- UserPoolId: userPoolId,
9186
- Username: user2.toString(),
9187
- Password: pass.toString(),
9188
- Permanent: true
9189
- })
9190
- );
9191
- return "User created.";
9217
+ await log19.task({
9218
+ initialMessage: "Creating user...",
9219
+ successMessage: "User created.",
9220
+ errorMessage: "Failed creating user.",
9221
+ async task() {
9222
+ try {
9223
+ await client.send(
9224
+ new AdminCreateUserCommand({
9225
+ UserPoolId: userPoolId,
9226
+ Username: username,
9227
+ TemporaryPassword: password
9228
+ })
9229
+ );
9230
+ } catch (error) {
9231
+ if (error instanceof UsernameExistsException) {
9232
+ throw new ExpectedError("User already exists");
9233
+ }
9234
+ throw error;
9235
+ }
9236
+ await client.send(
9237
+ new AdminSetUserPasswordCommand({
9238
+ UserPoolId: userPoolId,
9239
+ Username: username,
9240
+ Password: password,
9241
+ Permanent: true
9242
+ })
9243
+ );
9244
+ if (groups.length > 0) {
9245
+ for (const group of groups) {
9246
+ await client.send(
9247
+ new AdminAddUserToGroupCommand({
9248
+ UserPoolId: userPoolId,
9249
+ Username: username,
9250
+ GroupName: group
9251
+ })
9252
+ );
9253
+ }
9254
+ }
9255
+ }
9256
+ });
9192
9257
  });
9193
9258
  });
9194
9259
  };
@@ -9208,7 +9273,7 @@ var auth = (program2) => {
9208
9273
  };
9209
9274
 
9210
9275
  // src/cli/command/bind.ts
9211
- import { log as log19 } from "@awsless/clui";
9276
+ import { log as log20 } from "@awsless/clui";
9212
9277
  import { constantCase as constantCase15 } from "change-case";
9213
9278
  import { spawn } from "child_process";
9214
9279
  var bind = (program2) => {
@@ -9231,9 +9296,9 @@ var bind = (program2) => {
9231
9296
  env[name] = await value;
9232
9297
  }
9233
9298
  if (Object.keys(env).length > 0) {
9234
- log19.list("Bind Env", env);
9299
+ log20.list("Bind Env", env);
9235
9300
  } else {
9236
- log19.warning("No bindings available.");
9301
+ log20.warning("No bindings available.");
9237
9302
  }
9238
9303
  const configList = opts.config ?? [];
9239
9304
  const configs = {};
@@ -9241,7 +9306,7 @@ var bind = (program2) => {
9241
9306
  configs[`CONFIG_${constantCase15(name)}`] = name;
9242
9307
  }
9243
9308
  if (configList.length ?? 0 > 0) {
9244
- log19.note("Bind Config", configList.map((v) => color.label(constantCase15(v))).join("\n"));
9309
+ log20.note("Bind Config", configList.map((v) => color.label(constantCase15(v))).join("\n"));
9245
9310
  }
9246
9311
  if (commands9.length === 0) {
9247
9312
  return "No command to execute.";
@@ -9300,7 +9365,7 @@ var watchConfig = async (options, resolve, reject) => {
9300
9365
  };
9301
9366
 
9302
9367
  // src/cli/ui/complex/build-types.ts
9303
- import { log as log20 } from "@awsless/clui";
9368
+ import { log as log21 } from "@awsless/clui";
9304
9369
 
9305
9370
  // src/type-gen/generate.ts
9306
9371
  import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
@@ -9334,7 +9399,7 @@ var generateTypes = async (props) => {
9334
9399
  // src/cli/ui/complex/build-types.ts
9335
9400
  var buildTypes = async (props) => {
9336
9401
  await generateTypes(props);
9337
- log20.step("Done generating type definition files.");
9402
+ log21.step("Done generating type definition files.");
9338
9403
  };
9339
9404
 
9340
9405
  // src/cli/command/dev.ts
@@ -9358,7 +9423,7 @@ var dev = (program2) => {
9358
9423
  };
9359
9424
 
9360
9425
  // src/cli/command/resources.ts
9361
- import { log as log21 } from "@awsless/clui";
9426
+ import { log as log22 } from "@awsless/clui";
9362
9427
  import chalk4 from "chalk";
9363
9428
  import wildstring5 from "wildstring";
9364
9429
  var resources = (program2) => {
@@ -9401,9 +9466,9 @@ var resources = (program2) => {
9401
9466
  continue;
9402
9467
  }
9403
9468
  }
9404
- log21.step(chalk4.magenta(stack.name));
9469
+ log22.step(chalk4.magenta(stack.name));
9405
9470
  if (stack.resources.length) {
9406
- log21.message(
9471
+ log22.message(
9407
9472
  stack.resources.map((r) => {
9408
9473
  return [
9409
9474
  //
@@ -9414,7 +9479,7 @@ var resources = (program2) => {
9414
9479
  }).join("\n")
9415
9480
  );
9416
9481
  } else {
9417
- log21.message(color.line(`(empty)`));
9482
+ log22.message(color.line(`(empty)`));
9418
9483
  }
9419
9484
  }
9420
9485
  });
@@ -9585,7 +9650,7 @@ var types = (program2) => {
9585
9650
  };
9586
9651
 
9587
9652
  // src/cli/command/domain/list.ts
9588
- import { log as log22 } from "@awsless/clui";
9653
+ import { log as log23 } from "@awsless/clui";
9589
9654
  var list2 = (program2) => {
9590
9655
  program2.command("list").description("List all domains").action(async () => {
9591
9656
  await layout("domain list", async ({ appConfig, stackConfigs }) => {
@@ -9607,7 +9672,7 @@ var list2 = (program2) => {
9607
9672
  });
9608
9673
  await workspace.hydrate(app);
9609
9674
  for (const zone of domainZones) {
9610
- log22.step(
9675
+ log23.step(
9611
9676
  [
9612
9677
  //
9613
9678
  color.label.green(await zone.name),
@@ -9615,14 +9680,14 @@ var list2 = (program2) => {
9615
9680
  color.dim(await zone.id)
9616
9681
  ].join(" ")
9617
9682
  );
9618
- log22.message((await zone.nameServers).join("\n"));
9683
+ log23.message((await zone.nameServers).join("\n"));
9619
9684
  }
9620
9685
  });
9621
9686
  });
9622
9687
  };
9623
9688
 
9624
9689
  // src/cli/command/domain/deploy.ts
9625
- import { log as log23 } from "@awsless/clui";
9690
+ import { log as log24 } from "@awsless/clui";
9626
9691
  var deploy2 = (program2) => {
9627
9692
  program2.command("deploy").description("Deploy the domain zones to AWS").action(async () => {
9628
9693
  await layout("domain deploy", async ({ appConfig, stackConfigs }) => {
@@ -9642,7 +9707,7 @@ var deploy2 = (program2) => {
9642
9707
  profile,
9643
9708
  region
9644
9709
  });
9645
- await log23.task({
9710
+ await log24.task({
9646
9711
  initialMessage: "Deploying the domain zones to AWS...",
9647
9712
  successMessage: "Done deploying the domain zones to AWS.",
9648
9713
  errorMessage: "Failed deploying the domain zones to AWS.",
@@ -9651,7 +9716,7 @@ var deploy2 = (program2) => {
9651
9716
  }
9652
9717
  });
9653
9718
  for (const zone of domainZones) {
9654
- log23.step(
9719
+ log24.step(
9655
9720
  [
9656
9721
  //
9657
9722
  color.label.green(await zone.name),
@@ -9659,7 +9724,7 @@ var deploy2 = (program2) => {
9659
9724
  color.dim(await zone.id)
9660
9725
  ].join(" ")
9661
9726
  );
9662
- log23.message((await zone.nameServers).join("\n"));
9727
+ log24.message((await zone.nameServers).join("\n"));
9663
9728
  }
9664
9729
  });
9665
9730
  });
@@ -9678,7 +9743,7 @@ var domain = (program2) => {
9678
9743
 
9679
9744
  // src/cli/command/logs.ts
9680
9745
  import { CloudWatchLogsClient, StartLiveTailCommand } from "@aws-sdk/client-cloudwatch-logs";
9681
- import { log as log24 } from "@awsless/clui";
9746
+ import { log as log25 } from "@awsless/clui";
9682
9747
  import { aws as aws30 } from "@terraforge/aws";
9683
9748
  import chalk5 from "chalk";
9684
9749
  import chunk2 from "chunk";
@@ -9720,7 +9785,7 @@ var logs = (program2) => {
9720
9785
  process.once("SIGINT", () => {
9721
9786
  abort.abort();
9722
9787
  });
9723
- const streams = await log24.task({
9788
+ const streams = await log25.task({
9724
9789
  initialMessage: "Connecting to the log stream...",
9725
9790
  errorMessage: "Failed to connect to the log stream.",
9726
9791
  async task(ctx) {
@@ -9777,7 +9842,7 @@ var formatLog = (level, date, group, message) => {
9777
9842
  SYSTEM: chalk5.blue
9778
9843
  };
9779
9844
  const levelColor = levels[level] ?? chalk5.cyan;
9780
- log24.message(
9845
+ log25.message(
9781
9846
  [
9782
9847
  [
9783
9848
  //
@@ -9819,7 +9884,7 @@ var parseJsonLog = (message) => {
9819
9884
  // src/cli/command/image/clear-cache.ts
9820
9885
  import { CloudFrontClient as CloudFrontClient2, CreateInvalidationCommand as CreateInvalidationCommand2 } from "@aws-sdk/client-cloudfront";
9821
9886
  import { DeleteObjectsCommand, ListObjectsV2Command, S3Client as S3Client3 } from "@aws-sdk/client-s3";
9822
- import { Cancelled as Cancelled2, log as log25, prompt as prompt12 } from "@awsless/clui";
9887
+ import { Cancelled as Cancelled2, log as log26, prompt as prompt12 } from "@awsless/clui";
9823
9888
  import { randomUUID } from "crypto";
9824
9889
  var clearCache = (program2) => {
9825
9890
  program2.command("clear-cache").argument("[stack]", "The stack name of the image proxy").argument("[name]", "The name of the image proxy").description("Clears the cache of the image proxy").action(async (stack, name) => {
@@ -9891,7 +9956,7 @@ var clearCache = (program2) => {
9891
9956
  region: "us-east-1"
9892
9957
  });
9893
9958
  let totalDeleted = 0;
9894
- await log25.task({
9959
+ await log26.task({
9895
9960
  initialMessage: "Clearing cache...",
9896
9961
  successMessage: "Cache successfully cleared.",
9897
9962
  task: async () => {
@@ -9953,7 +10018,7 @@ var image = (program2) => {
9953
10018
  // src/cli/command/icon/clear-cache.ts
9954
10019
  import { CloudFrontClient as CloudFrontClient3, CreateInvalidationCommand as CreateInvalidationCommand3 } from "@aws-sdk/client-cloudfront";
9955
10020
  import { DeleteObjectsCommand as DeleteObjectsCommand2, ListObjectsV2Command as ListObjectsV2Command2, S3Client as S3Client4 } from "@aws-sdk/client-s3";
9956
- import { Cancelled as Cancelled3, log as log26, prompt as prompt13 } from "@awsless/clui";
10021
+ import { Cancelled as Cancelled3, log as log27, prompt as prompt13 } from "@awsless/clui";
9957
10022
  import { randomUUID as randomUUID2 } from "crypto";
9958
10023
  var clearCache2 = (program2) => {
9959
10024
  program2.command("clear-cache").argument("[stack]", "The stack name of the icon proxy").argument("[name]", "The name of the icon proxy").description("Clears the cache of the icon proxy").action(async (stack, name) => {
@@ -10025,7 +10090,7 @@ var clearCache2 = (program2) => {
10025
10090
  region: "us-east-1"
10026
10091
  });
10027
10092
  let totalDeleted = 0;
10028
- await log26.task({
10093
+ await log27.task({
10029
10094
  initialMessage: "Clearing cache...",
10030
10095
  successMessage: "Cache successfully cleared.",
10031
10096
  task: async () => {
@@ -64,6 +64,7 @@ var AuthDefaultSchema = z5.record(
64
64
  // .optional()
65
65
  // .describe('The email configuration for sending messages.'),
66
66
  // secret: z.boolean().default(false).describe('Specifies whether you want to generate a client secret.'),
67
+ groups: z5.string().array().default([]).describe("Specifies a list of groups that a user can belong to."),
67
68
  username: z5.object({
68
69
  // emailAlias: z.boolean().default(true).describe('Allow the user email to be used as username.'),
69
70
  caseSensitive: z5.boolean().default(false).describe(
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.599",
3
+ "version": "0.0.600",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -35,20 +35,20 @@
35
35
  "peerDependencies": {
36
36
  "@awsless/big-float": "^0.1.5",
37
37
  "@awsless/cloudwatch": "^0.0.1",
38
- "@awsless/duration": "^0.0.4",
39
38
  "@awsless/clui": "^0.0.8",
40
- "@awsless/iot": "^0.0.3",
41
39
  "@awsless/dynamodb": "^0.3.8",
42
- "@awsless/lambda": "^0.0.35",
40
+ "@awsless/duration": "^0.0.4",
43
41
  "@awsless/json": "^0.0.10",
42
+ "@awsless/iot": "^0.0.3",
43
+ "@awsless/open-search": "^0.0.21",
44
+ "@awsless/lambda": "^0.0.35",
44
45
  "@awsless/redis": "^0.0.14",
46
+ "@awsless/s3": "^0.0.21",
45
47
  "@awsless/sns": "^0.0.10",
46
48
  "@awsless/sqs": "^0.0.16",
47
- "@awsless/validate": "^0.1.3",
48
- "@awsless/open-search": "^0.0.21",
49
49
  "@awsless/ssm": "^0.0.7",
50
- "@awsless/s3": "^0.0.21",
51
50
  "@awsless/weak-cache": "^0.0.1",
51
+ "@awsless/validate": "^0.1.3",
52
52
  "@awsless/mqtt": "^0.0.2"
53
53
  },
54
54
  "dependencies": {
@@ -142,12 +142,12 @@
142
142
  "@awsless/big-float": "^0.1.5",
143
143
  "@awsless/cloudwatch": "^0.0.1",
144
144
  "@awsless/duration": "^0.0.4",
145
+ "@awsless/graphql": "^0.0.9",
145
146
  "@awsless/json": "^0.0.10",
146
- "@awsless/scheduler": "^0.0.4",
147
147
  "@awsless/size": "^0.0.2",
148
148
  "@awsless/validate": "^0.1.3",
149
+ "@awsless/scheduler": "^0.0.4",
149
150
  "@awsless/clui": "^0.0.8",
150
- "@awsless/graphql": "^0.0.9",
151
151
  "@awsless/ts-file-cache": "^0.0.12"
152
152
  },
153
153
  "devDependencies": {