@awsless/awsless 0.0.217 → 0.0.218
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 +81 -10
- package/package.json +6 -6
package/dist/bin.js
CHANGED
|
@@ -4029,6 +4029,76 @@ var restFeature = defineFeature({
|
|
|
4029
4029
|
}
|
|
4030
4030
|
});
|
|
4031
4031
|
|
|
4032
|
+
// src/feature/task/index.ts
|
|
4033
|
+
import { camelCase as camelCase6 } from "change-case";
|
|
4034
|
+
import { relative as relative4 } from "path";
|
|
4035
|
+
import { Node as Node19, aws as aws19 } from "@awsless/formation";
|
|
4036
|
+
var typeGenCode7 = `
|
|
4037
|
+
import { InvokeOptions } from '@awsless/lambda'
|
|
4038
|
+
import type { Mock } from 'vitest'
|
|
4039
|
+
|
|
4040
|
+
type Func = (...args: any[]) => any
|
|
4041
|
+
|
|
4042
|
+
type Invoke<Name extends string, F extends Func> = {
|
|
4043
|
+
readonly name: Name
|
|
4044
|
+
(payload: Parameters<F>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>): Promise<void>
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
type MockHandle<F extends Func> = (payload: Parameters<F>[0]) => void | Promise<void> | Promise<Promise<void>>
|
|
4048
|
+
type MockBuilder<F extends Func> = (handle?: MockHandle<F>) => void
|
|
4049
|
+
type MockObject<F extends Func> = Mock<Parameters<F>, ReturnType<F>>
|
|
4050
|
+
`;
|
|
4051
|
+
var taskFeature = defineFeature({
|
|
4052
|
+
name: "task",
|
|
4053
|
+
async onTypeGen(ctx) {
|
|
4054
|
+
const types2 = new TypeFile("@awsless/awsless");
|
|
4055
|
+
const resources = new TypeObject(1);
|
|
4056
|
+
const mocks = new TypeObject(1);
|
|
4057
|
+
const mockResponses = new TypeObject(1);
|
|
4058
|
+
for (const stack of ctx.stackConfigs) {
|
|
4059
|
+
const resource2 = new TypeObject(2);
|
|
4060
|
+
const mock = new TypeObject(2);
|
|
4061
|
+
const mockResponse = new TypeObject(2);
|
|
4062
|
+
for (const [name, fileOrProps] of Object.entries(stack.functions || {})) {
|
|
4063
|
+
const varName = camelCase6(`${stack.name}-${name}`);
|
|
4064
|
+
const funcName = formatLocalResourceName(ctx.appConfig.name, stack.name, "task", name);
|
|
4065
|
+
const file = typeof fileOrProps === "string" ? fileOrProps : fileOrProps.file;
|
|
4066
|
+
const relFile = relative4(directories.types, file);
|
|
4067
|
+
types2.addImport(varName, relFile);
|
|
4068
|
+
resource2.addType(name, `Invoke<'${funcName}', typeof ${varName}>`);
|
|
4069
|
+
mock.addType(name, `MockBuilder<typeof ${varName}>`);
|
|
4070
|
+
mockResponse.addType(name, `MockObject<typeof ${varName}>`);
|
|
4071
|
+
}
|
|
4072
|
+
mocks.addType(stack.name, mock);
|
|
4073
|
+
resources.addType(stack.name, resource2);
|
|
4074
|
+
mockResponses.addType(stack.name, mockResponse);
|
|
4075
|
+
}
|
|
4076
|
+
types2.addCode(typeGenCode7);
|
|
4077
|
+
types2.addInterface("TaskResources", resources);
|
|
4078
|
+
types2.addInterface("TaskMock", mocks);
|
|
4079
|
+
types2.addInterface("TaskMockResponse", mockResponses);
|
|
4080
|
+
await ctx.write("task.d.ts", types2, true);
|
|
4081
|
+
},
|
|
4082
|
+
onStack(ctx) {
|
|
4083
|
+
for (const [id, props] of Object.entries(ctx.stackConfig.tasks ?? {})) {
|
|
4084
|
+
const group = new Node19(ctx.stack, "task", id);
|
|
4085
|
+
const { lambda, policy } = createLambdaFunction(group, ctx, "task", id, props.consumer);
|
|
4086
|
+
const invokeConfig = new aws19.lambda.EventInvokeConfig(group, "config", {
|
|
4087
|
+
functionArn: lambda.arn,
|
|
4088
|
+
retryAttempts: props.retryAttempts,
|
|
4089
|
+
onFailure: getGlobalOnFailure(ctx)
|
|
4090
|
+
});
|
|
4091
|
+
invokeConfig.dependsOn(policy);
|
|
4092
|
+
if (hasOnFailure(ctx.stackConfigs)) {
|
|
4093
|
+
policy.addStatement({
|
|
4094
|
+
actions: ["sqs:SendMessage", "sqs:GetQueueUrl"],
|
|
4095
|
+
resources: [getGlobalOnFailure(ctx)]
|
|
4096
|
+
});
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
});
|
|
4101
|
+
|
|
4032
4102
|
// src/feature/index.ts
|
|
4033
4103
|
var features = [
|
|
4034
4104
|
// 1
|
|
@@ -4047,9 +4117,10 @@ var features = [
|
|
|
4047
4117
|
topicFeature,
|
|
4048
4118
|
queueFeature,
|
|
4049
4119
|
storeFeature,
|
|
4120
|
+
cacheFeature,
|
|
4121
|
+
taskFeature,
|
|
4050
4122
|
testFeature,
|
|
4051
4123
|
cronFeature,
|
|
4052
|
-
cacheFeature,
|
|
4053
4124
|
httpFeature,
|
|
4054
4125
|
restFeature,
|
|
4055
4126
|
siteFeature
|
|
@@ -4367,20 +4438,20 @@ var config = (program2) => {
|
|
|
4367
4438
|
import { confirm as confirm3 } from "@clack/prompts";
|
|
4368
4439
|
|
|
4369
4440
|
// src/util/workspace.ts
|
|
4370
|
-
import { WorkSpace, aws as
|
|
4441
|
+
import { WorkSpace, aws as aws20, local } from "@awsless/formation";
|
|
4371
4442
|
import { minutes as minutes4 } from "@awsless/duration";
|
|
4372
4443
|
import { dirname as dirname8, join as join9 } from "path";
|
|
4373
4444
|
import { mkdir as mkdir2, readFile as readFile6, rm, writeFile as writeFile2 } from "fs/promises";
|
|
4374
4445
|
var createWorkSpace = (props) => {
|
|
4375
|
-
const lockProvider = new
|
|
4446
|
+
const lockProvider = new aws20.dynamodb.LockProvider({
|
|
4376
4447
|
...props,
|
|
4377
4448
|
tableName: "awsless-locks"
|
|
4378
4449
|
});
|
|
4379
|
-
const stateProvider = new
|
|
4450
|
+
const stateProvider = new aws20.s3.StateProvider({
|
|
4380
4451
|
...props,
|
|
4381
4452
|
bucket: "awsless-state"
|
|
4382
4453
|
});
|
|
4383
|
-
const cloudProviders =
|
|
4454
|
+
const cloudProviders = aws20.createCloudProviders({
|
|
4384
4455
|
...props,
|
|
4385
4456
|
timeout: minutes4(60)
|
|
4386
4457
|
});
|
|
@@ -4756,7 +4827,7 @@ var deploy = (program2) => {
|
|
|
4756
4827
|
};
|
|
4757
4828
|
|
|
4758
4829
|
// src/cli/command/diff.ts
|
|
4759
|
-
import { WorkSpace as WorkSpace2, aws as
|
|
4830
|
+
import { WorkSpace as WorkSpace2, aws as aws21 } from "@awsless/formation";
|
|
4760
4831
|
import chalk7 from "chalk";
|
|
4761
4832
|
var diff = (program2) => {
|
|
4762
4833
|
program2.command("diff").description("Diff your app with AWS").action(async (filters) => {
|
|
@@ -4768,12 +4839,12 @@ var diff = (program2) => {
|
|
|
4768
4839
|
const { app, builders } = createApp({ appConfig, stackConfigs, accountId }, filters);
|
|
4769
4840
|
await buildAssets(builders);
|
|
4770
4841
|
const workspace = new WorkSpace2({
|
|
4771
|
-
stateProvider: new
|
|
4842
|
+
stateProvider: new aws21.dynamodb.DynamoDBStateProvider({
|
|
4772
4843
|
credentials,
|
|
4773
4844
|
region,
|
|
4774
4845
|
tableName: "awsless-state"
|
|
4775
4846
|
}),
|
|
4776
|
-
cloudProviders:
|
|
4847
|
+
cloudProviders: aws21.createCloudProviders({
|
|
4777
4848
|
credentials,
|
|
4778
4849
|
region: appConfig.region
|
|
4779
4850
|
})
|
|
@@ -4829,7 +4900,7 @@ import { log as log9 } from "@clack/prompts";
|
|
|
4829
4900
|
|
|
4830
4901
|
// src/type-gen/generate.ts
|
|
4831
4902
|
import { mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
|
|
4832
|
-
import { dirname as dirname9, join as join11, relative as
|
|
4903
|
+
import { dirname as dirname9, join as join11, relative as relative5 } from "path";
|
|
4833
4904
|
var generateTypes = async (props) => {
|
|
4834
4905
|
const files = [];
|
|
4835
4906
|
await Promise.all(
|
|
@@ -4841,7 +4912,7 @@ var generateTypes = async (props) => {
|
|
|
4841
4912
|
const path = join11(directories.types, file);
|
|
4842
4913
|
if (code) {
|
|
4843
4914
|
if (include) {
|
|
4844
|
-
files.push(
|
|
4915
|
+
files.push(relative5(directories.root, path));
|
|
4845
4916
|
}
|
|
4846
4917
|
await mkdir4(dirname9(path), { recursive: true });
|
|
4847
4918
|
await writeFile4(path, code);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.218",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@awsless/lambda": "^0.0.18",
|
|
32
|
-
"@awsless/redis": "^0.0.12",
|
|
33
32
|
"@awsless/open-search": "^0.0.12",
|
|
33
|
+
"@awsless/redis": "^0.0.12",
|
|
34
34
|
"@awsless/s3": "^0.0.10",
|
|
35
35
|
"@awsless/sns": "^0.0.7",
|
|
36
36
|
"@awsless/sqs": "^0.0.7",
|
|
37
37
|
"@awsless/ssm": "^0.0.7",
|
|
38
|
-
"@awsless/
|
|
39
|
-
"@awsless/
|
|
38
|
+
"@awsless/validate": "^0.0.13",
|
|
39
|
+
"@awsless/weak-cache": "^0.0.1"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@aws-appsync/utils": "^1.5.0",
|
|
@@ -97,11 +97,11 @@
|
|
|
97
97
|
"wrap-ansi": "^8.1.0",
|
|
98
98
|
"zod": "^3.21.4",
|
|
99
99
|
"zod-to-json-schema": "^3.22.3",
|
|
100
|
+
"@awsless/duration": "^0.0.1",
|
|
100
101
|
"@awsless/formation": "^0.0.21",
|
|
101
102
|
"@awsless/graphql": "^0.0.9",
|
|
102
|
-
"@awsless/duration": "^0.0.1",
|
|
103
|
-
"@awsless/validate": "^0.0.13",
|
|
104
103
|
"@awsless/size": "^0.0.1",
|
|
104
|
+
"@awsless/validate": "^0.0.13",
|
|
105
105
|
"@awsless/code": "^0.0.10"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|