@awsless/awsless 0.0.163 → 0.0.165
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/README.MD +2 -0
- package/dist/app.json +1 -1
- package/dist/bin.js +55 -49
- package/dist/features/cognito-client-secret/bundle.zip +0 -0
- package/dist/features/delete-bucket/bundle.zip +0 -0
- package/dist/features/delete-hosted-zone/bundle.zip +0 -0
- package/dist/features/global-exports/bundle.zip +0 -0
- package/dist/features/invalidate-cache/bundle.zip +0 -0
- package/dist/features/upload-bucket-asset/bundle.zip +0 -0
- package/dist/index.d.ts +287 -0
- package/dist/json.js +3 -4
- package/dist/stack.json +1 -1
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -1352,6 +1352,9 @@ import { relative as relative2 } from "path";
|
|
|
1352
1352
|
var isFunctionProps = (input) => {
|
|
1353
1353
|
return typeof input === "string" || typeof input.file === "string";
|
|
1354
1354
|
};
|
|
1355
|
+
var toFunctionProps = (fileOrProps) => {
|
|
1356
|
+
return typeof fileOrProps === "string" ? { file: fileOrProps } : fileOrProps;
|
|
1357
|
+
};
|
|
1355
1358
|
var typeGenCode = `
|
|
1356
1359
|
import { InvokeOptions, InvokeResponse } from '@awsless/lambda'
|
|
1357
1360
|
import type { PartialDeep } from 'type-fest'
|
|
@@ -1427,7 +1430,10 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
|
|
|
1427
1430
|
const config2 = ctx.config;
|
|
1428
1431
|
const stack = ctx.stack ?? ctx.bootstrap;
|
|
1429
1432
|
const bootstrap2 = ctx.bootstrap;
|
|
1430
|
-
const props =
|
|
1433
|
+
const props = {
|
|
1434
|
+
...config2.app.defaults?.function,
|
|
1435
|
+
...toFunctionProps(fileOrProps)
|
|
1436
|
+
};
|
|
1431
1437
|
const lambda = new Function(id, {
|
|
1432
1438
|
name: `${config2.app.name}-${stack.name}-${id}`,
|
|
1433
1439
|
code: Code.fromFile(
|
|
@@ -1758,47 +1764,50 @@ var authPlugin = definePlugin({
|
|
|
1758
1764
|
gen.addInterface("AuthResources", resources);
|
|
1759
1765
|
await write("auth.d.ts", gen, true);
|
|
1760
1766
|
},
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
// const userPoolId = bootstrap.import(`auth-${id}-user-pool-id`)
|
|
1765
|
-
// const clientId = bootstrap.import(`auth-${id}-client-id`)
|
|
1766
|
-
// const name = constantCase(id)
|
|
1767
|
-
// bind(lambda => {
|
|
1768
|
-
// lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId)
|
|
1769
|
-
// lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId)
|
|
1770
|
-
// if (config.app.defaults.auth?.[id]?.secret) {
|
|
1771
|
-
// const clientSecret = bootstrap.import(`auth-${id}-client-secret`)
|
|
1772
|
-
// lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret)
|
|
1773
|
-
// }
|
|
1774
|
-
// lambda.addPermissions({
|
|
1775
|
-
// actions: ['cognito:*'],
|
|
1776
|
-
// resources: ['*'],
|
|
1777
|
-
// })
|
|
1778
|
-
// })
|
|
1779
|
-
// }
|
|
1780
|
-
// }
|
|
1781
|
-
// },
|
|
1782
|
-
onStack({ config: config2, bootstrap: bootstrap2, bind: bind2 }) {
|
|
1783
|
-
for (const [id, props] of Object.entries(config2.app.defaults.auth)) {
|
|
1784
|
-
bind2((lambda) => {
|
|
1785
|
-
const userPoolArn = bootstrap2.import(`auth-${id}-user-pool-arn`);
|
|
1767
|
+
onStack({ config: config2, bootstrap: bootstrap2, stackConfig, bind: bind2 }) {
|
|
1768
|
+
for (const [id, props] of Object.entries(stackConfig.auth ?? {})) {
|
|
1769
|
+
if (props.access) {
|
|
1786
1770
|
const userPoolId = bootstrap2.import(`auth-${id}-user-pool-id`);
|
|
1787
1771
|
const clientId = bootstrap2.import(`auth-${id}-client-id`);
|
|
1788
1772
|
const name = constantCase6(id);
|
|
1789
|
-
lambda
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1773
|
+
bind2((lambda) => {
|
|
1774
|
+
lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId);
|
|
1775
|
+
lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId);
|
|
1776
|
+
if (config2.app.defaults.auth?.[id]?.secret) {
|
|
1777
|
+
const clientSecret = bootstrap2.import(`auth-${id}-client-secret`);
|
|
1778
|
+
lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret);
|
|
1779
|
+
}
|
|
1780
|
+
lambda.addPermissions({
|
|
1781
|
+
actions: ["cognito:*"],
|
|
1782
|
+
resources: ["*"]
|
|
1783
|
+
});
|
|
1798
1784
|
});
|
|
1799
|
-
}
|
|
1785
|
+
}
|
|
1800
1786
|
}
|
|
1801
1787
|
},
|
|
1788
|
+
// onStack({ config, bootstrap, bind }) {
|
|
1789
|
+
// // Give access to every lambda function in our app to our cognito instance.
|
|
1790
|
+
// for (const [id, props] of Object.entries(config.app.defaults.auth)) {
|
|
1791
|
+
// bind(lambda => {
|
|
1792
|
+
// const userPoolArn = bootstrap.import(`auth-${id}-user-pool-arn`)
|
|
1793
|
+
// const userPoolId = bootstrap.import(`auth-${id}-user-pool-id`)
|
|
1794
|
+
// const clientId = bootstrap.import(`auth-${id}-client-id`)
|
|
1795
|
+
// const name = constantCase(id)
|
|
1796
|
+
// lambda.addEnvironment(`AUTH_${name}_USER_POOL_ID`, userPoolId)
|
|
1797
|
+
// lambda.addEnvironment(`AUTH_${name}_CLIENT_ID`, clientId)
|
|
1798
|
+
// // lambda.addEnvironment(`AWSLESS_PUBLIC_AUTH_${name}_USER_POOL_ID`, userPoolId)
|
|
1799
|
+
// // lambda.addEnvironment(`AWSLESS_PUBLIC_AUTH_${name}_CLIENT_ID`, clientId)
|
|
1800
|
+
// if (props.secret) {
|
|
1801
|
+
// const clientSecret = bootstrap.import(`auth-${id}-client-secret`)
|
|
1802
|
+
// lambda.addEnvironment(`AUTH_${name}_CLIENT_SECRET`, clientSecret)
|
|
1803
|
+
// }
|
|
1804
|
+
// lambda.addPermissions({
|
|
1805
|
+
// actions: ['cognito:*'],
|
|
1806
|
+
// resources: [userPoolArn],
|
|
1807
|
+
// })
|
|
1808
|
+
// })
|
|
1809
|
+
// }
|
|
1810
|
+
// },
|
|
1802
1811
|
onApp(ctx) {
|
|
1803
1812
|
const { config: config2, bootstrap: bootstrap2 } = ctx;
|
|
1804
1813
|
if (Object.keys(config2.app.defaults.auth).length === 0) {
|
|
@@ -3267,8 +3276,12 @@ var graphqlPlugin = definePlugin({
|
|
|
3267
3276
|
for (const [typeName, fields] of Object.entries(props.resolvers || {})) {
|
|
3268
3277
|
for (const [fieldName, resolverProps] of Object.entries(fields || {})) {
|
|
3269
3278
|
const props2 = isFunctionProps(resolverProps) ? { consumer: resolverProps } : resolverProps;
|
|
3270
|
-
const entryId = paramCase4(`${id}-${
|
|
3271
|
-
const
|
|
3279
|
+
const entryId = paramCase4(`${id}-${typeName}-${fieldName}`);
|
|
3280
|
+
const funcId = paramCase4(`${id}-${shortId(`${typeName}-${fieldName}`)}`);
|
|
3281
|
+
const lambda = toLambdaFunction(ctx, `graphql-${funcId}`, {
|
|
3282
|
+
description: entryId,
|
|
3283
|
+
...toFunctionProps(props2.consumer)
|
|
3284
|
+
});
|
|
3272
3285
|
const resolver = props2.resolver ?? defaultProps?.resolver;
|
|
3273
3286
|
let code = defaultResolver;
|
|
3274
3287
|
if (resolver) {
|
|
@@ -5830,6 +5843,7 @@ var VPCSchema = z7.boolean().describe("Put the function inside your global VPC."
|
|
|
5830
5843
|
var MinifySchema = z7.boolean().describe("Minify the function code.");
|
|
5831
5844
|
var HandlerSchema = z7.string().describe("The name of the exported method within your code that Lambda calls to run your function.");
|
|
5832
5845
|
var FileSchema = LocalFileSchema.describe("The file path of the function code.");
|
|
5846
|
+
var DescriptionSchema = z7.string().describe("A description of the function.");
|
|
5833
5847
|
var LogRetentionSchema = DurationSchema.refine(durationMin(Duration.days(1)), "Minimum log retention is 1 day");
|
|
5834
5848
|
var LogSchema = z7.union([
|
|
5835
5849
|
z7.boolean(),
|
|
@@ -5853,6 +5867,7 @@ var FunctionSchema = z7.union([
|
|
|
5853
5867
|
LocalFileSchema,
|
|
5854
5868
|
z7.object({
|
|
5855
5869
|
file: FileSchema,
|
|
5870
|
+
description: DescriptionSchema.optional(),
|
|
5856
5871
|
handler: HandlerSchema.optional(),
|
|
5857
5872
|
minify: MinifySchema.optional(),
|
|
5858
5873
|
warm: WarmSchema.optional(),
|
|
@@ -5909,10 +5924,7 @@ var TriggersSchema = z8.object({
|
|
|
5909
5924
|
var AuthSchema = z8.record(
|
|
5910
5925
|
ResourceIdSchema,
|
|
5911
5926
|
z8.object({
|
|
5912
|
-
|
|
5913
|
-
// .boolean()
|
|
5914
|
-
// .default(false)
|
|
5915
|
-
// .describe('Give access to every function in this stack to your cognito instance.'),
|
|
5927
|
+
access: z8.boolean().default(false).describe("Give access to every function in this stack to your cognito instance."),
|
|
5916
5928
|
triggers: TriggersSchema.optional()
|
|
5917
5929
|
})
|
|
5918
5930
|
).optional().describe("Define the auth triggers in your stack.");
|
|
@@ -8669,13 +8681,7 @@ var del2 = (program2) => {
|
|
|
8669
8681
|
label: stack.name,
|
|
8670
8682
|
task: async (update) => {
|
|
8671
8683
|
update("deleting...");
|
|
8672
|
-
|
|
8673
|
-
await client.delete(stack.name, stack.region);
|
|
8674
|
-
} catch (error) {
|
|
8675
|
-
debugError(error);
|
|
8676
|
-
update("failed");
|
|
8677
|
-
throw error;
|
|
8678
|
-
}
|
|
8684
|
+
await client.delete(stack.name, stack.region);
|
|
8679
8685
|
update("deleted");
|
|
8680
8686
|
return "done";
|
|
8681
8687
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|