diff --git a/dynamodb/index.js b/dynamodb/index.js index 1464ef8..e81dd35 100644 --- a/dynamodb/index.js +++ b/dynamodb/index.js @@ -1,4 +1,4 @@ -import { util } from '..'; +import { util } from '../index.js'; // TODO: consistentRead // TODO: projection diff --git a/package.json b/package.json index 49a2d09..b3c55a5 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "scripts": { "test:aws": "NODE_OPTIONS=\"--experimental-vm-modules\" TEST_TARGET=AWS_CLOUD jest -u", "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --ci", - "evaluate": "node ./scripts/evaluate.js ./scripts/testcode.js" + "evaluate": "node ./scripts/evaluate.js ./scripts/testcode.js", + "coverage": "node --experimental-specifier-resolution=node ./scripts/coverage.mjs" }, "repository": { "type": "git", diff --git a/scripts/coverage.mjs b/scripts/coverage.mjs new file mode 100644 index 0000000..1a56966 --- /dev/null +++ b/scripts/coverage.mjs @@ -0,0 +1,64 @@ +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)); +