-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Motivation We should be transparent about which functions are covered and which aren't. This helps our users understand our current status, and indicate that we are not 100% complete with our implementation. To aid with this process, I have created #19 which lists the functions we support, and encourage users to list/upvote their suggestions. In turn, to support this I have added a script to capture the functions we implement, and to print them out to the console. We may automate this procedure in the process if it gets too arduous. The example output from this script can be seen in the ["Currently implemented functions"](https://github.com/localstack/appsync-utils/issues/19#user-content-#currently-implemented-functions) section of the linked issue. # Changes * Add script to capture feature coverage by introspecting the utilities library. * Fix a relative import issue when using the script
- Loading branch information
Showing
3 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { util } from '..'; | ||
import { util } from '../index.js'; | ||
|
||
// TODO: consistentRead | ||
// TODO: projection | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
|