Skip to content

Commit fc7c162

Browse files
fix: improved ui for rules tabs, refactored validation for rules
1 parent b7e4ba4 commit fc7c162

File tree

671 files changed

+19244
-6683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

671 files changed

+19244
-6683
lines changed

.github/workflows/pullRequests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ jobs:
132132
run: yarn --immutable
133133
- name: Build packages (full)
134134
run: yarn build
135+
- name: Check types for Cypress tests
136+
run: yarn cy:ts
135137
env:
136138
NODE_OPTIONS: '--max_old_space_size=4096'
137139
YARN_ENABLE_IMMUTABLE_INSTALLS: false

.github/workflows/wac/pullRequests.wac.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ export const pullRequests = createWorkflow({
211211
{
212212
name: "Build packages (full)",
213213
run: "yarn build"
214+
},
215+
{
216+
name: "Check types for Cypress tests",
217+
run: "yarn cy:ts"
214218
}
215219
]
216220
}),

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ lerna.json
4848

4949
# TODO remove after moving traffic splitting config to WPC
5050
gateway.*.json
51+
52+
packages/tasks/tpl/*

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
.webiny/**
99
packages/ui/src/RichTextEditor/editorjs/**
1010
lerna.json
11+
coverage/**

apps/api/fileManager/download/package.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/api/fileManager/download/src/index.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/api/fileManager/download/tsconfig.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

apps/api/fileManager/download/webiny.config.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

apps/api/fileManager/transform/package.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

apps/api/fileManager/transform/src/index.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

apps/api/fileManager/transform/tsconfig.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

apps/api/fileManager/transform/webiny.config.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

apps/api/graphql/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@webiny/api-apw": "0.0.0",
1313
"@webiny/api-apw-scheduler-so-ddb": "0.0.0",
1414
"@webiny/api-audit-logs": "0.0.0",
15+
"@webiny/api-background-tasks-ddb": "0.0.0",
1516
"@webiny/api-file-manager": "0.0.0",
1617
"@webiny/api-file-manager-ddb": "0.0.0",
1718
"@webiny/api-file-manager-s3": "0.0.0",
@@ -43,7 +44,8 @@
4344
"@webiny/handler-db": "0.0.0",
4445
"@webiny/handler-graphql": "0.0.0",
4546
"@webiny/handler-logs": "0.0.0",
46-
"@webiny/project-utils": "0.0.0"
47+
"@webiny/project-utils": "0.0.0",
48+
"@webiny/tasks": "0.0.0"
4749
},
4850
"devDependencies": {
4951
"@webiny/cli-plugin-deploy-pulumi": "0.0.0",

apps/api/graphql/src/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from "@webiny/api-file-manager";
2424
import { createFileManagerStorageOperations } from "@webiny/api-file-manager-ddb";
2525
import logsPlugins from "@webiny/handler-logs";
26-
import fileManagerS3 from "@webiny/api-file-manager-s3";
26+
import fileManagerS3, { createAssetDelivery } from "@webiny/api-file-manager-s3";
2727
import { createFormBuilder } from "@webiny/api-form-builder";
2828
import { createFormBuilderStorageOperations } from "@webiny/api-form-builder-so-ddb";
2929
import { createHeadlessCmsContext, createHeadlessCmsGraphQL } from "@webiny/api-headless-cms";
@@ -35,10 +35,11 @@ import { createStorageOperations as createApwSaStorageOperations } from "@webiny
3535
import { createAco } from "@webiny/api-aco";
3636
import { createAcoPageBuilderContext } from "@webiny/api-page-builder-aco";
3737
import { createAuditLogs } from "@webiny/api-audit-logs";
38-
39-
// Imports plugins created via scaffolding utilities.
38+
import { createBackgroundTasks } from "@webiny/api-background-tasks-ddb";
4039
import scaffoldsPlugins from "./plugins/scaffolds";
4140
import { createBenchmarkEnablePlugin } from "~/plugins/benchmarkEnable";
41+
import { createCountDynamoDbTask } from "~/plugins/countDynamoDbTask";
42+
import { createContinuingTask } from "~/plugins/continuingTask";
4243

4344
const debug = process.env.DEBUG === "true";
4445
const documentClient = getDocumentClient();
@@ -65,12 +66,14 @@ export const handler = createHandler({
6566
})
6667
}),
6768
createHeadlessCmsGraphQL(),
69+
createBackgroundTasks(),
6870
createFileManagerContext({
6971
storageOperations: createFileManagerStorageOperations({
7072
documentClient
7173
})
7274
}),
7375
createFileManagerGraphQL(),
76+
createAssetDelivery({ documentClient }),
7477
fileManagerS3(),
7578
prerenderingServicePlugins({
7679
eventBus: String(process.env.EVENT_BUS)
@@ -119,7 +122,9 @@ export const handler = createHandler({
119122
}
120123
});
121124
}),
122-
createAuditLogs()
125+
createAuditLogs(),
126+
createCountDynamoDbTask(),
127+
createContinuingTask()
123128
],
124129
debug
125130
});
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { createTaskDefinition } from "@webiny/tasks";
2+
import { Context } from "../types";
3+
import { ITaskResponseContinueOptions } from "@webiny/tasks/response/abstractions";
4+
5+
const MAX_RUNS = 5;
6+
7+
const getMaxRuns = (input?: string | number) => {
8+
const value = Number(input);
9+
if (isNaN(value)) {
10+
return MAX_RUNS;
11+
}
12+
return value > 0 && value < 50 ? value : MAX_RUNS;
13+
};
14+
15+
interface TaskValues {
16+
run?: number;
17+
maxRuns?: string | number;
18+
seconds?: number | string;
19+
}
20+
21+
const getOptions = (values: TaskValues): ITaskResponseContinueOptions | undefined => {
22+
if (!values.seconds || typeof values.seconds !== "number" || values.seconds < 1) {
23+
return undefined;
24+
}
25+
return {
26+
seconds: values.seconds
27+
};
28+
};
29+
30+
export const createContinuingTask = () => {
31+
return createTaskDefinition<Context, TaskValues>({
32+
id: "continuingTask",
33+
title: "Mock Continuing Task",
34+
description:
35+
"This is a mock task which will continue to run until it reaches the defined run limit.",
36+
async run(params) {
37+
const { response, isAborted, input } = params;
38+
const run = input.run || 0;
39+
const maxRuns = getMaxRuns(input.maxRuns);
40+
if (run >= maxRuns) {
41+
return response.done("Got to the run limit.");
42+
}
43+
if (isAborted()) {
44+
return response.aborted();
45+
}
46+
47+
await new Promise(resolve => setTimeout(resolve, 10000));
48+
49+
return response.continue(
50+
{
51+
...(input || {}),
52+
run: run + 1
53+
},
54+
getOptions(input)
55+
);
56+
}
57+
});
58+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { createTaskDefinition } from "@webiny/tasks";
2+
import { getDocumentClient } from "@webiny/aws-sdk/client-dynamodb";
3+
4+
export const createCountDynamoDbTask = () => {
5+
return createTaskDefinition({
6+
id: "countDdb",
7+
title: "Count DynamoDB",
8+
description: "Counts DynamoDB items.",
9+
run: async params => {
10+
const { response, isAborted, isCloseToTimeout } = params;
11+
if (isAborted()) {
12+
return response.aborted();
13+
} else if (isCloseToTimeout()) {
14+
return response.continue({});
15+
}
16+
const documentClient = getDocumentClient();
17+
18+
const results = await documentClient.scan({
19+
TableName: process.env.DB_TABLE
20+
});
21+
22+
return response.done(`Count: ${results.Count}`);
23+
}
24+
});
25+
};

apps/api/graphql/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FormBuilderContext } from "@webiny/api-form-builder/types";
77
import { CmsContext } from "@webiny/api-headless-cms/types";
88
import { AcoContext } from "@webiny/api-aco/types";
99
import { PbAcoContext } from "@webiny/api-page-builder-aco/types";
10+
import { Context as TasksContext } from "@webiny/tasks/types";
1011

1112
// When working with the `context` object (for example while defining a new GraphQL resolver function),
1213
// you can import this interface and assign it to it. This will give you full autocomplete functionality
@@ -23,4 +24,5 @@ export interface Context
2324
CmsContext,
2425
FormBuilderContext,
2526
AcoContext,
27+
TasksContext,
2628
PbAcoContext {}

apps/api/graphql/tsconfig.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@
112112
},
113113
{
114114
"path": "../../../packages/api-apw-scheduler-so-ddb"
115+
},
116+
{
117+
"path": "../../../packages/api-background-tasks-ddb/tsconfig.build.json"
118+
},
119+
{
120+
"path": "../../../packages/tasks/tsconfig.build.json"
115121
}
116122
],
117123
"compilerOptions": {
@@ -188,7 +194,11 @@
188194
"@webiny/handler-graphql/*": ["../../../packages/handler-graphql/src/*"],
189195
"@webiny/handler-graphql": ["../../../packages/handler-graphql/src"],
190196
"@webiny/handler-logs/*": ["../../../packages/handler-logs/src/*"],
191-
"@webiny/handler-logs": ["../../../packages/handler-logs/src"]
197+
"@webiny/handler-logs": ["../../../packages/handler-logs/src"],
198+
"@webiny/api-background-tasks-ddb/*": ["../../../packages/api-background-tasks-ddb/src/*"],
199+
"@webiny/api-background-tasks-ddb": ["../../../packages/api-background-tasks-ddb/src"],
200+
"@webiny/tasks/*": ["../../../packages/tasks/src/*"],
201+
"@webiny/tasks": ["../../../packages/tasks/src"]
192202
},
193203
"baseUrl": "."
194204
}

0 commit comments

Comments
 (0)