@awsless/cli 0.0.46-local.44 → 0.0.46-local.45

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.
Files changed (2) hide show
  1. package/dist/bin.js +91 -6
  2. package/package.json +16 -16
package/dist/bin.js CHANGED
@@ -152670,10 +152670,94 @@ class TypeObject {
152670
152670
  }
152671
152671
  }
152672
152672
 
152673
+ // src/feature/auth/dev.ts
152674
+ import {
152675
+ CognitoIdentityProviderClient,
152676
+ ListUserPoolClientsCommand,
152677
+ ListUserPoolsCommand
152678
+ } from "@aws-sdk/client-cognito-identity-provider";
152679
+ var authOnDev = async (ctx) => {
152680
+ const ids = Object.keys(ctx.appConfig.auth ?? {});
152681
+ if (ids.length === 0) {
152682
+ return;
152683
+ }
152684
+ const pools = await ctx.keep("auth:pull", [...ids].sort().join(","), async () => {
152685
+ const values = {};
152686
+ try {
152687
+ ctx.log(`Resolving ${ids.length} auth userpool${ids.length === 1 ? "" : "s"} from Cognito...`);
152688
+ const credentials2 = await getCredentials(ctx.appConfig.profile);
152689
+ const client = new CognitoIdentityProviderClient({
152690
+ region: ctx.appConfig.region,
152691
+ credentials: credentials2
152692
+ });
152693
+ let timer;
152694
+ const timeout = new Promise((_3, reject) => {
152695
+ timer = setTimeout(() => reject(new Error("the lookup timed out after 15s")), 15000);
152696
+ });
152697
+ const resolve2 = async () => {
152698
+ const poolIdsByName = {};
152699
+ let token;
152700
+ do {
152701
+ const result = await client.send(new ListUserPoolsCommand({
152702
+ MaxResults: 60,
152703
+ NextToken: token
152704
+ }));
152705
+ for (const pool of result.UserPools ?? []) {
152706
+ if (pool.Name && pool.Id) {
152707
+ poolIdsByName[pool.Name] = pool.Id;
152708
+ }
152709
+ }
152710
+ token = result.NextToken;
152711
+ } while (token);
152712
+ for (const id of ids) {
152713
+ const name = formatGlobalResourceName({
152714
+ appName: ctx.appConfig.name,
152715
+ resourceType: "auth",
152716
+ resourceName: id
152717
+ });
152718
+ const userPoolId = poolIdsByName[name];
152719
+ if (!userPoolId) {
152720
+ ctx.log(`The auth userpool "${id}" isn't deployed yet - its login won't work locally.`);
152721
+ continue;
152722
+ }
152723
+ const clients = await client.send(new ListUserPoolClientsCommand({
152724
+ UserPoolId: userPoolId,
152725
+ MaxResults: 60
152726
+ }));
152727
+ const appClient = clients.UserPoolClients?.find((client2) => client2.ClientName === name) ?? clients.UserPoolClients?.[0];
152728
+ if (!appClient?.ClientId) {
152729
+ ctx.log(`The auth userpool "${id}" has no client - its login won't work locally.`);
152730
+ continue;
152731
+ }
152732
+ values[id] = {
152733
+ userPoolId,
152734
+ clientId: appClient.ClientId
152735
+ };
152736
+ }
152737
+ };
152738
+ await Promise.race([resolve2(), timeout]).finally(() => clearTimeout(timer));
152739
+ } catch (error3) {
152740
+ debug("Auth userpool lookup failed", error3);
152741
+ ctx.log(`Couldn't resolve the auth userpools from Cognito (${error3 instanceof Error ? error3.message : String(error3)}) - logins won't work locally.`);
152742
+ }
152743
+ return { value: values, stop: () => {} };
152744
+ });
152745
+ for (const [id, pool] of Object.entries(pools)) {
152746
+ ctx.addEnv(`AUTH_${constantCase(id)}_USER_POOL_ID`, pool.userPoolId);
152747
+ ctx.addEnv(`AUTH_${constantCase(id)}_CLIENT_ID`, pool.clientId);
152748
+ ctx.registerResource({
152749
+ kind: "auth",
152750
+ id,
152751
+ detail: pool.userPoolId
152752
+ });
152753
+ }
152754
+ };
152755
+
152673
152756
  // src/feature/auth/index.ts
152674
152757
  import { toDays as toDays4, toHours } from "@awsless/duration";
152675
152758
  var authFeature = defineFeature({
152676
152759
  name: "auth",
152760
+ onDev: authOnDev,
152677
152761
  async onTypeGen(ctx) {
152678
152762
  const gen = new TypeFile("awsless");
152679
152763
  const resources = new TypeObject(1);
@@ -164585,7 +164669,7 @@ import {
164585
164669
  AdminAddUserToGroupCommand,
164586
164670
  AdminCreateUserCommand,
164587
164671
  AdminSetUserPasswordCommand,
164588
- CognitoIdentityProviderClient,
164672
+ CognitoIdentityProviderClient as CognitoIdentityProviderClient2,
164589
164673
  UsernameExistsException
164590
164674
  } from "@aws-sdk/client-cognito-identity-provider";
164591
164675
  var create = (program3) => {
@@ -164724,7 +164808,7 @@ var create = (program3) => {
164724
164808
  }))
164725
164809
  });
164726
164810
  }
164727
- const client = new CognitoIdentityProviderClient({
164811
+ const client = new CognitoIdentityProviderClient2({
164728
164812
  region,
164729
164813
  credentials: credentials2
164730
164814
  });
@@ -164773,7 +164857,7 @@ import {
164773
164857
  AdminListGroupsForUserCommand,
164774
164858
  AdminRemoveUserFromGroupCommand,
164775
164859
  AdminSetUserPasswordCommand as AdminSetUserPasswordCommand2,
164776
- CognitoIdentityProviderClient as CognitoIdentityProviderClient2,
164860
+ CognitoIdentityProviderClient as CognitoIdentityProviderClient3,
164777
164861
  UserNotFoundException
164778
164862
  } from "@aws-sdk/client-cognito-identity-provider";
164779
164863
  var update = (program3) => {
@@ -164861,7 +164945,7 @@ var update = (program3) => {
164861
164945
  }
164862
164946
  });
164863
164947
  }
164864
- const client = new CognitoIdentityProviderClient2({
164948
+ const client = new CognitoIdentityProviderClient3({
164865
164949
  region,
164866
164950
  credentials: credentials2
164867
164951
  });
@@ -164992,7 +165076,7 @@ var update = (program3) => {
164992
165076
  // src/cli/command/auth/user/delete.ts
164993
165077
  import {
164994
165078
  AdminDeleteUserCommand,
164995
- CognitoIdentityProviderClient as CognitoIdentityProviderClient3,
165079
+ CognitoIdentityProviderClient as CognitoIdentityProviderClient4,
164996
165080
  UserNotFoundException as UserNotFoundException2
164997
165081
  } from "@aws-sdk/client-cognito-identity-provider";
164998
165082
  var del10 = (program3) => {
@@ -165069,7 +165153,7 @@ var del10 = (program3) => {
165069
165153
  throw new Cancelled;
165070
165154
  }
165071
165155
  }
165072
- const client = new CognitoIdentityProviderClient3({
165156
+ const client = new CognitoIdentityProviderClient4({
165073
165157
  region,
165074
165158
  credentials: credentials2
165075
165159
  });
@@ -166756,6 +166840,7 @@ const GROUPS = [
166756
166840
  ['search', 'Searches'],
166757
166841
  ['store', 'Stores'],
166758
166842
  ['config', 'Config'],
166843
+ ['auth', 'Auth'],
166759
166844
  ['email', 'Emails'],
166760
166845
  ['route', 'Routes'],
166761
166846
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/cli",
3
- "version": "0.0.46-local.44",
3
+ "version": "0.0.46-local.45",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -38,19 +38,19 @@
38
38
  "@opensearch-project/opensearch": "^2.13.0",
39
39
  "rolldown": "1.2.1",
40
40
  "vitest": "4.1.10",
41
- "@awsless/ts-file-cache": "^0.0.16",
42
- "@awsless/dynamodb-server": "^0.1.8"
41
+ "@awsless/dynamodb-server": "^0.1.8",
42
+ "@awsless/ts-file-cache": "^0.0.16"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@awsless/big-float": "^0.1.7",
46
+ "@awsless/s3": "^0.0.22",
46
47
  "@awsless/duration": "^0.0.4",
48
+ "@awsless/validate": "^0.1.7",
47
49
  "@awsless/lambda": "^0.0.47",
48
50
  "@awsless/dynamodb": "^0.3.22",
49
- "@awsless/s3": "^0.0.22",
50
- "@awsless/json": "^0.0.11",
51
51
  "@awsless/weak-cache": "^0.0.1",
52
52
  "awsless": "^0.0.15-local.11",
53
- "@awsless/validate": "^0.1.7"
53
+ "@awsless/json": "^0.0.11"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@aws-sdk/client-cloudformation": "^3.369.0",
@@ -120,25 +120,25 @@
120
120
  "zip-a-folder": "^3.1.6",
121
121
  "zod": "^3.24.2",
122
122
  "zod-to-json-schema": "^3.24.3",
123
+ "@awsless/big-float": "^0.1.7",
123
124
  "@awsless/cloudwatch": "^0.0.1",
124
125
  "@awsless/clui": "^0.0.9",
125
- "@awsless/big-float": "^0.1.7",
126
- "@awsless/iot": "^0.0.5",
127
126
  "@awsless/duration": "^0.0.4",
128
- "@awsless/dynamodb": "^0.3.22",
129
127
  "@awsless/json": "^0.0.11",
130
- "@awsless/open-search": "^0.0.26",
128
+ "@awsless/lambda": "^0.0.47",
131
129
  "@awsless/redis": "^0.1.13",
132
- "@awsless/s3": "^0.0.22",
133
130
  "@awsless/size": "^0.0.2",
131
+ "@awsless/iot": "^0.0.5",
132
+ "@awsless/open-search": "^0.0.26",
133
+ "@awsless/s3": "^0.0.22",
134
+ "@awsless/dynamodb": "^0.3.22",
134
135
  "@awsless/sns": "^0.0.11",
135
- "@awsless/ssm": "^0.0.8",
136
- "@awsless/lambda": "^0.0.47",
136
+ "@awsless/scheduler": "^0.0.5",
137
+ "@awsless/sqs": "^0.0.24",
137
138
  "@awsless/validate": "^0.1.7",
138
139
  "@awsless/weak-cache": "^0.0.1",
139
- "@awsless/sqs": "^0.0.24",
140
- "@awsless/scheduler": "^0.0.5",
141
- "awsless": "^0.0.15-local.11"
140
+ "awsless": "^0.0.15-local.11",
141
+ "@awsless/ssm": "^0.0.8"
142
142
  },
143
143
  "scripts": {
144
144
  "test": "bun cli/build-handlers.ts && pnpm vitest",