@awsless/awsless 0.0.81 → 0.0.83
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 +29 -9
- package/dist/index.d.ts +8 -0
- package/dist/index.js +14 -6
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -2201,7 +2201,7 @@ var tablePlugin = definePlugin({
|
|
|
2201
2201
|
const list3 = new TypeObject();
|
|
2202
2202
|
for (const name of Object.keys(stack.tables || {})) {
|
|
2203
2203
|
const tableName = formatName(`${config.name}-${stack.name}-${name}`);
|
|
2204
|
-
list3.addType(name, tableName);
|
|
2204
|
+
list3.addType(name, `'${tableName}'`);
|
|
2205
2205
|
}
|
|
2206
2206
|
types2.addType(stack.name, list3.toString());
|
|
2207
2207
|
}
|
|
@@ -5725,6 +5725,7 @@ var UserPool = class extends Resource {
|
|
|
5725
5725
|
};
|
|
5726
5726
|
|
|
5727
5727
|
// src/plugins/auth.ts
|
|
5728
|
+
import { constantCase as constantCase10 } from "change-case";
|
|
5728
5729
|
var TriggersSchema = z25.object({
|
|
5729
5730
|
/** A pre jwt token generation AWS Lambda trigger. */
|
|
5730
5731
|
beforeToken: FunctionSchema.optional(),
|
|
@@ -5851,6 +5852,10 @@ var authPlugin = definePlugin({
|
|
|
5851
5852
|
auth: z25.record(
|
|
5852
5853
|
ResourceIdSchema,
|
|
5853
5854
|
z25.object({
|
|
5855
|
+
/** Give access to every function in this stack to your cognito instance.
|
|
5856
|
+
* @default false
|
|
5857
|
+
*/
|
|
5858
|
+
access: z25.boolean().default(false),
|
|
5854
5859
|
/** Specifies the configuration for AWS Lambda triggers. */
|
|
5855
5860
|
triggers: TriggersSchema.optional()
|
|
5856
5861
|
})
|
|
@@ -5860,12 +5865,33 @@ var authPlugin = definePlugin({
|
|
|
5860
5865
|
onTypeGen({ config }) {
|
|
5861
5866
|
const gen = new TypeGen("@awsless/awsless", "AuthResources");
|
|
5862
5867
|
for (const name of Object.keys(config.defaults.auth)) {
|
|
5863
|
-
|
|
5868
|
+
const authName = formatName(`${config.name}-${name}`);
|
|
5869
|
+
gen.addType(
|
|
5870
|
+
name,
|
|
5871
|
+
`{ readonly name: '${authName}', readonly userPoolId: string, readonly clientId: string }`
|
|
5872
|
+
);
|
|
5864
5873
|
}
|
|
5865
5874
|
return gen.toString();
|
|
5866
5875
|
},
|
|
5876
|
+
onStack({ bootstrap: bootstrap2, stackConfig, bind }) {
|
|
5877
|
+
for (const [id, props] of Object.entries(stackConfig.auth ?? {})) {
|
|
5878
|
+
if (props.access) {
|
|
5879
|
+
const userPoolId = bootstrap2.import(`auth-${id}-user-pool-id`);
|
|
5880
|
+
const clientId = bootstrap2.import(`auth-${id}-user-pool-id`);
|
|
5881
|
+
const name = constantCase10(id);
|
|
5882
|
+
bind((lambda) => {
|
|
5883
|
+
lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId);
|
|
5884
|
+
lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId);
|
|
5885
|
+
lambda.addPermissions({
|
|
5886
|
+
actions: ["cognito:*"],
|
|
5887
|
+
resources: ["*"]
|
|
5888
|
+
});
|
|
5889
|
+
});
|
|
5890
|
+
}
|
|
5891
|
+
}
|
|
5892
|
+
},
|
|
5867
5893
|
onApp(ctx) {
|
|
5868
|
-
const { config, bootstrap: bootstrap2
|
|
5894
|
+
const { config, bootstrap: bootstrap2 } = ctx;
|
|
5869
5895
|
for (const [id, props] of Object.entries(config.defaults.auth)) {
|
|
5870
5896
|
const functions = /* @__PURE__ */ new Map();
|
|
5871
5897
|
const triggers = {};
|
|
@@ -5916,12 +5942,6 @@ var authPlugin = definePlugin({
|
|
|
5916
5942
|
bootstrap2.add(lambda, permission);
|
|
5917
5943
|
}
|
|
5918
5944
|
}
|
|
5919
|
-
bind((lambda) => {
|
|
5920
|
-
lambda.addPermissions({
|
|
5921
|
-
actions: ["cognito:*"],
|
|
5922
|
-
resources: ["*"]
|
|
5923
|
-
});
|
|
5924
|
-
});
|
|
5925
5945
|
}
|
|
5926
5946
|
});
|
|
5927
5947
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5317,6 +5317,7 @@ declare const defaultPlugins: (Plugin<zod.ZodObject<{
|
|
|
5317
5317
|
}>>;
|
|
5318
5318
|
stacks: zod.ZodArray<zod.ZodObject<{
|
|
5319
5319
|
auth: zod.ZodOptional<zod.ZodRecord<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodObject<{
|
|
5320
|
+
access: zod.ZodDefault<zod.ZodBoolean>;
|
|
5320
5321
|
triggers: zod.ZodOptional<zod.ZodObject<{
|
|
5321
5322
|
beforeToken: zod.ZodOptional<zod.ZodUnion<[zod.ZodEffects<zod.ZodString, string, string>, zod.ZodObject<{
|
|
5322
5323
|
file: zod.ZodEffects<zod.ZodString, string, string>;
|
|
@@ -6573,6 +6574,7 @@ declare const defaultPlugins: (Plugin<zod.ZodObject<{
|
|
|
6573
6574
|
} | undefined;
|
|
6574
6575
|
}>>;
|
|
6575
6576
|
}, "strip", zod.ZodTypeAny, {
|
|
6577
|
+
access: boolean;
|
|
6576
6578
|
triggers?: {
|
|
6577
6579
|
beforeToken?: string | {
|
|
6578
6580
|
file: string;
|
|
@@ -6801,6 +6803,7 @@ declare const defaultPlugins: (Plugin<zod.ZodObject<{
|
|
|
6801
6803
|
} | undefined;
|
|
6802
6804
|
} | undefined;
|
|
6803
6805
|
}, {
|
|
6806
|
+
access?: boolean | undefined;
|
|
6804
6807
|
triggers?: {
|
|
6805
6808
|
beforeToken?: string | {
|
|
6806
6809
|
file: string;
|
|
@@ -7031,6 +7034,7 @@ declare const defaultPlugins: (Plugin<zod.ZodObject<{
|
|
|
7031
7034
|
}>>>;
|
|
7032
7035
|
}, "strip", zod.ZodTypeAny, {
|
|
7033
7036
|
auth?: Record<string, {
|
|
7037
|
+
access: boolean;
|
|
7034
7038
|
triggers?: {
|
|
7035
7039
|
beforeToken?: string | {
|
|
7036
7040
|
file: string;
|
|
@@ -7261,6 +7265,7 @@ declare const defaultPlugins: (Plugin<zod.ZodObject<{
|
|
|
7261
7265
|
}> | undefined;
|
|
7262
7266
|
}, {
|
|
7263
7267
|
auth?: Record<string, {
|
|
7268
|
+
access?: boolean | undefined;
|
|
7264
7269
|
triggers?: {
|
|
7265
7270
|
beforeToken?: string | {
|
|
7266
7271
|
file: string;
|
|
@@ -7493,6 +7498,7 @@ declare const defaultPlugins: (Plugin<zod.ZodObject<{
|
|
|
7493
7498
|
}, "strip", zod.ZodTypeAny, {
|
|
7494
7499
|
stacks: {
|
|
7495
7500
|
auth?: Record<string, {
|
|
7501
|
+
access: boolean;
|
|
7496
7502
|
triggers?: {
|
|
7497
7503
|
beforeToken?: string | {
|
|
7498
7504
|
file: string;
|
|
@@ -7974,6 +7980,7 @@ declare const defaultPlugins: (Plugin<zod.ZodObject<{
|
|
|
7974
7980
|
}, {
|
|
7975
7981
|
stacks: {
|
|
7976
7982
|
auth?: Record<string, {
|
|
7983
|
+
access?: boolean | undefined;
|
|
7977
7984
|
triggers?: {
|
|
7978
7985
|
beforeToken?: string | {
|
|
7979
7986
|
file: string;
|
|
@@ -11477,6 +11484,7 @@ declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (Stack
|
|
|
11477
11484
|
searchs?: string[] | undefined;
|
|
11478
11485
|
}) | (StackConfig$1 & {
|
|
11479
11486
|
auth?: Record<string, {
|
|
11487
|
+
access?: boolean | undefined;
|
|
11480
11488
|
triggers?: {
|
|
11481
11489
|
beforeToken?: string | {
|
|
11482
11490
|
file: string;
|
package/dist/index.js
CHANGED
|
@@ -60,12 +60,20 @@ var Function = /* @__PURE__ */ createProxy((stackName) => {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
// src/node/auth.ts
|
|
63
|
+
import { constantCase } from "change-case";
|
|
63
64
|
var getAuthName = getGlobalResourceName;
|
|
64
65
|
var Auth = /* @__PURE__ */ createProxy((name) => {
|
|
66
|
+
return getAuthProps(name);
|
|
67
|
+
});
|
|
68
|
+
var getAuthProps = (name) => {
|
|
69
|
+
const env = process.env;
|
|
70
|
+
const id = constantCase(name);
|
|
65
71
|
return {
|
|
66
|
-
name: getAuthName(name)
|
|
72
|
+
name: getAuthName(name),
|
|
73
|
+
userPoolId: env[`AUTH_${id}_USER_POOL_ID`],
|
|
74
|
+
clientId: env[`AUTH_${id}_CLIENT_ID`]
|
|
67
75
|
};
|
|
68
|
-
}
|
|
76
|
+
};
|
|
69
77
|
|
|
70
78
|
// src/node/table.ts
|
|
71
79
|
var getTableName = getLocalResourceName;
|
|
@@ -98,10 +106,10 @@ import {
|
|
|
98
106
|
sendMessage,
|
|
99
107
|
sendMessageBatch
|
|
100
108
|
} from "@awsless/sqs";
|
|
101
|
-
import { constantCase } from "change-case";
|
|
109
|
+
import { constantCase as constantCase2 } from "change-case";
|
|
102
110
|
var getQueueName = getLocalResourceName;
|
|
103
111
|
var getQueueUrl = (name, stack = STACK) => {
|
|
104
|
-
return process.env[`QUEUE_${
|
|
112
|
+
return process.env[`QUEUE_${constantCase2(stack)}_${constantCase2(name)}_URL`];
|
|
105
113
|
};
|
|
106
114
|
var Queue = /* @__PURE__ */ createProxy((stack) => {
|
|
107
115
|
return createProxy((queue) => {
|
|
@@ -130,9 +138,9 @@ var Queue = /* @__PURE__ */ createProxy((stack) => {
|
|
|
130
138
|
});
|
|
131
139
|
|
|
132
140
|
// src/node/cache.ts
|
|
133
|
-
import { constantCase as
|
|
141
|
+
import { constantCase as constantCase3 } from "change-case";
|
|
134
142
|
var getCacheProps = (name, stack = STACK) => {
|
|
135
|
-
const prefix = `CACHE_${
|
|
143
|
+
const prefix = `CACHE_${constantCase3(stack)}_${constantCase3(name)}`;
|
|
136
144
|
return {
|
|
137
145
|
host: process.env[`${prefix}_HOST`],
|
|
138
146
|
port: parseInt(process.env[`${prefix}_PORT`], 10)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.83",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@awsless/lambda": "^0.0.6",
|
|
28
28
|
"@awsless/sns": "^0.0.6",
|
|
29
|
-
"@awsless/
|
|
30
|
-
"@awsless/
|
|
29
|
+
"@awsless/sqs": "^0.0.6",
|
|
30
|
+
"@awsless/ssm": "^0.0.7"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@aws-sdk/client-cloudformation": "^3.369.0",
|