-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.ts
63 lines (58 loc) · 1.88 KB
/
run.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { handler } from "./src";
import { AppSyncResolverEvent } from "aws-lambda/trigger/appsync-resolver";
import { createDatabaseTunnel } from "../shared/database/local/databaseTunnel";
import prompts from "prompts";
import { DatabaseOperation } from "../shared/graphql/operations";
import { getYourEmail } from "../shared/local/yourEmail";
import { CreateItemInput, EditItemInput } from "../shared/graphql/graphql";
(async () => {
const baseInput = {
identity: { resolverContext: { userEmail: await getYourEmail() } },
};
const sampleInputs: Partial<Record<DatabaseOperation, unknown>> = {
listItems: { pinboardId: "63206" },
searchMentionableUsers: { prefix: "a" },
claimItem: { itemId: "1667" },
getGroupPinboardIds: {},
getItemCounts: { pinboardIds: ["65183"] },
createItem: {
input: {
type: "message-only",
pinboardId: "63206",
message: "DB testing",
} as CreateItemInput,
},
editItem: {
itemId: "2352",
input: {
message: "DB testing MODIFIED",
payload: JSON.stringify({ blah: "payload added" }),
type: "testing",
} as EditItemInput,
},
deleteItem: { itemId: "2352" },
getMyUser: {},
visitTourStep: { tourStepId: "testing" },
};
await createDatabaseTunnel();
// noinspection InfiniteLoopJS
while (
// eslint-disable-next-line no-constant-condition
true
) {
const { inputPayload } = await prompts({
type: "select",
name: "inputPayload",
message: "Operation?",
choices: Object.entries(sampleInputs).map(([operation, sampleInput]) => ({
title: operation,
value: {
...baseInput,
arguments: sampleInput,
info: { fieldName: operation },
} as AppSyncResolverEvent<unknown, unknown>,
})),
});
console.log(JSON.stringify(await handler(inputPayload), null, 2));
}
})();