-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcoverage.mjs
64 lines (55 loc) · 1.64 KB
/
coverage.mjs
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 { util } from '../index.js';
import * as rds from '../rds/index.js';
import * as dynamodb from '../dynamodb/index.js';
class Namespace {
constructor(name, obj) {
this.name = name;
this.obj = obj;
}
};
const partialImplementations = {
'util.appendError': {
message: "the function exists but errors are not yet captured",
},
};
// ns must be a Namespace type
function evaluateNamespace(ns) {
for (const [key, value] of Object.entries(ns.obj)) {
switch (typeof value) {
case 'function': {
const qualifiedName = `${ns.name}.${key}`;
let message = `* \`${qualifiedName}\``;
if (partialImplementations[qualifiedName] !== undefined) {
const partialDescription = partialImplementations[qualifiedName].message;
message = `${message} _(partial, ${partialDescription})_`;
} else {
};
console.log(message);
break;
};
case "object": {
const newNs = new Namespace(`${ns.name}.${key}`, value);
evaluateNamespace(newNs);
break;
};
default: {
console.error(`Unhandled type ${typeof value}`);
break;
};
}
}
}
function printImportMessage(text) {
console.log(`
Assuming the following import:
\`\`\`javascript
${text}
\`\`\`
`);
}
printImportMessage(`import { util } from '@aws-appsync/utils'`);
evaluateNamespace(new Namespace("util", util));
printImportMessage(`import * as rds from '@aws-appsync/utils/rds'`);
evaluateNamespace(new Namespace("rds", rds));
printImportMessage(`import * as dynamodb from '@aws-appsync/utils/dynamodb'`);
evaluateNamespace(new Namespace("dynamodb", dynamodb));