skuba 0.0.0-beta-20231002015947
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/config/eslint.js +3 -0
- package/config/jest.js +1 -0
- package/config/prettier.d.ts +4 -0
- package/config/prettier.js +6 -0
- package/config/tsconfig.json +11 -0
- package/jest/moduleNameMapper.js +58 -0
- package/jest/moduleNameMapper.test.ts +64 -0
- package/jest/transform.js +50 -0
- package/jest/transform.test.ts +11 -0
- package/jest/tsConfig.js +26 -0
- package/jest-preset.js +40 -0
- package/lib/api/buildkite/annotate.d.ts +26 -0
- package/lib/api/buildkite/annotate.js +49 -0
- package/lib/api/buildkite/annotate.js.map +7 -0
- package/lib/api/buildkite/index.d.ts +3 -0
- package/lib/api/buildkite/index.js +32 -0
- package/lib/api/buildkite/index.js.map +7 -0
- package/lib/api/buildkite/md.d.ts +6 -0
- package/lib/api/buildkite/md.js +33 -0
- package/lib/api/buildkite/md.js.map +7 -0
- package/lib/api/git/commit.d.ts +15 -0
- package/lib/api/git/commit.js +52 -0
- package/lib/api/git/commit.js.map +7 -0
- package/lib/api/git/commitAllChanges.d.ts +19 -0
- package/lib/api/git/commitAllChanges.js +79 -0
- package/lib/api/git/commitAllChanges.js.map +7 -0
- package/lib/api/git/currentBranch.d.ts +10 -0
- package/lib/api/git/currentBranch.js +59 -0
- package/lib/api/git/currentBranch.js.map +7 -0
- package/lib/api/git/findRoot.d.ts +9 -0
- package/lib/api/git/findRoot.js +52 -0
- package/lib/api/git/findRoot.js.map +7 -0
- package/lib/api/git/getChangedFiles.d.ts +20 -0
- package/lib/api/git/getChangedFiles.js +63 -0
- package/lib/api/git/getChangedFiles.js.map +7 -0
- package/lib/api/git/index.d.ts +11 -0
- package/lib/api/git/index.js +58 -0
- package/lib/api/git/index.js.map +7 -0
- package/lib/api/git/log.d.ts +19 -0
- package/lib/api/git/log.js +71 -0
- package/lib/api/git/log.js.map +7 -0
- package/lib/api/git/pull.d.ts +35 -0
- package/lib/api/git/pull.js +69 -0
- package/lib/api/git/pull.js.map +7 -0
- package/lib/api/git/push.d.ts +43 -0
- package/lib/api/git/push.js +70 -0
- package/lib/api/git/push.js.map +7 -0
- package/lib/api/git/remote.d.ts +20 -0
- package/lib/api/git/remote.js +73 -0
- package/lib/api/git/remote.js.map +7 -0
- package/lib/api/git/reset.d.ts +12 -0
- package/lib/api/git/reset.js +62 -0
- package/lib/api/git/reset.js.map +7 -0
- package/lib/api/git/statusMatrix.d.ts +7 -0
- package/lib/api/git/statusMatrix.js +47 -0
- package/lib/api/git/statusMatrix.js.map +7 -0
- package/lib/api/github/checkRun.d.ts +44 -0
- package/lib/api/github/checkRun.js +81 -0
- package/lib/api/github/checkRun.js.map +7 -0
- package/lib/api/github/environment.d.ts +18 -0
- package/lib/api/github/environment.js +48 -0
- package/lib/api/github/environment.js.map +7 -0
- package/lib/api/github/index.d.ts +7 -0
- package/lib/api/github/index.js +48 -0
- package/lib/api/github/index.js.map +7 -0
- package/lib/api/github/issueComment.d.ts +59 -0
- package/lib/api/github/issueComment.js +83 -0
- package/lib/api/github/issueComment.js.map +7 -0
- package/lib/api/github/pullRequest.d.ts +21 -0
- package/lib/api/github/pullRequest.js +69 -0
- package/lib/api/github/pullRequest.js.map +7 -0
- package/lib/api/github/push.d.ts +79 -0
- package/lib/api/github/push.js +167 -0
- package/lib/api/github/push.js.map +7 -0
- package/lib/api/jest/index.d.ts +147 -0
- package/lib/api/jest/index.js +41 -0
- package/lib/api/jest/index.js.map +7 -0
- package/lib/api/net/compose.d.ts +4 -0
- package/lib/api/net/compose.js +50 -0
- package/lib/api/net/compose.js.map +7 -0
- package/lib/api/net/index.d.ts +1 -0
- package/lib/api/net/index.js +29 -0
- package/lib/api/net/index.js.map +7 -0
- package/lib/api/net/socket.d.ts +5 -0
- package/lib/api/net/socket.js +68 -0
- package/lib/api/net/socket.js.map +7 -0
- package/lib/api/net/waitFor.d.ts +22 -0
- package/lib/api/net/waitFor.js +40 -0
- package/lib/api/net/waitFor.js.map +7 -0
- package/lib/cli/adapter/eslint.d.ts +14 -0
- package/lib/cli/adapter/eslint.js +99 -0
- package/lib/cli/adapter/eslint.js.map +7 -0
- package/lib/cli/adapter/prettier.d.ts +52 -0
- package/lib/cli/adapter/prettier.js +176 -0
- package/lib/cli/adapter/prettier.js.map +7 -0
- package/lib/cli/build/args.d.ts +7 -0
- package/lib/cli/build/args.js +73 -0
- package/lib/cli/build/args.js.map +7 -0
- package/lib/cli/build/assets.d.ts +10 -0
- package/lib/cli/build/assets.js +107 -0
- package/lib/cli/build/assets.js.map +7 -0
- package/lib/cli/build/esbuild.d.ts +5 -0
- package/lib/cli/build/esbuild.js +98 -0
- package/lib/cli/build/esbuild.js.map +7 -0
- package/lib/cli/build/index.d.ts +1 -0
- package/lib/cli/build/index.js +83 -0
- package/lib/cli/build/index.js.map +7 -0
- package/lib/cli/build/tsc.d.ts +4 -0
- package/lib/cli/build/tsc.js +102 -0
- package/lib/cli/build/tsc.js.map +7 -0
- package/lib/cli/buildPackage.d.ts +1 -0
- package/lib/cli/buildPackage.js +69 -0
- package/lib/cli/buildPackage.js.map +7 -0
- package/lib/cli/configure/addEmptyExports.d.ts +6 -0
- package/lib/cli/configure/addEmptyExports.js +76 -0
- package/lib/cli/configure/addEmptyExports.js.map +7 -0
- package/lib/cli/configure/analyseConfiguration.d.ts +9 -0
- package/lib/cli/configure/analyseConfiguration.js +69 -0
- package/lib/cli/configure/analyseConfiguration.js.map +7 -0
- package/lib/cli/configure/analyseDependencies.d.ts +10 -0
- package/lib/cli/configure/analyseDependencies.js +136 -0
- package/lib/cli/configure/analyseDependencies.js.map +7 -0
- package/lib/cli/configure/analysis/diff.d.ts +1 -0
- package/lib/cli/configure/analysis/diff.js +45 -0
- package/lib/cli/configure/analysis/diff.js.map +7 -0
- package/lib/cli/configure/analysis/files.d.ts +1 -0
- package/lib/cli/configure/analysis/files.js +58 -0
- package/lib/cli/configure/analysis/files.js.map +7 -0
- package/lib/cli/configure/analysis/git.d.ts +1 -0
- package/lib/cli/configure/analysis/git.js +54 -0
- package/lib/cli/configure/analysis/git.js.map +7 -0
- package/lib/cli/configure/analysis/package.d.ts +13 -0
- package/lib/cli/configure/analysis/package.js +110 -0
- package/lib/cli/configure/analysis/package.js.map +7 -0
- package/lib/cli/configure/analysis/project.d.ts +3 -0
- package/lib/cli/configure/analysis/project.js +109 -0
- package/lib/cli/configure/analysis/project.js.map +7 -0
- package/lib/cli/configure/dependencies/index.d.ts +5 -0
- package/lib/cli/configure/dependencies/index.js +41 -0
- package/lib/cli/configure/dependencies/index.js.map +7 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.d.ts +2 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +59 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +7 -0
- package/lib/cli/configure/dependencies/seekKoala.d.ts +2 -0
- package/lib/cli/configure/dependencies/seekKoala.js +56 -0
- package/lib/cli/configure/dependencies/seekKoala.js.map +7 -0
- package/lib/cli/configure/dependencies/skuba.d.ts +2 -0
- package/lib/cli/configure/dependencies/skuba.js +52 -0
- package/lib/cli/configure/dependencies/skuba.js.map +7 -0
- package/lib/cli/configure/dependencies/skubaDeps.d.ts +2 -0
- package/lib/cli/configure/dependencies/skubaDeps.js +56 -0
- package/lib/cli/configure/dependencies/skubaDeps.js.map +7 -0
- package/lib/cli/configure/dependencies/skubaDive.d.ts +3 -0
- package/lib/cli/configure/dependencies/skubaDive.js +70 -0
- package/lib/cli/configure/dependencies/skubaDive.js.map +7 -0
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +9 -0
- package/lib/cli/configure/ensureTemplateCompletion.js +77 -0
- package/lib/cli/configure/ensureTemplateCompletion.js.map +7 -0
- package/lib/cli/configure/getEntryPoint.d.ts +11 -0
- package/lib/cli/configure/getEntryPoint.js +73 -0
- package/lib/cli/configure/getEntryPoint.js.map +7 -0
- package/lib/cli/configure/getProjectType.d.ts +9 -0
- package/lib/cli/configure/getProjectType.js +52 -0
- package/lib/cli/configure/getProjectType.js.map +7 -0
- package/lib/cli/configure/index.d.ts +1 -0
- package/lib/cli/configure/index.js +148 -0
- package/lib/cli/configure/index.js.map +7 -0
- package/lib/cli/configure/modules/eslint.d.ts +2 -0
- package/lib/cli/configure/modules/eslint.js +61 -0
- package/lib/cli/configure/modules/eslint.js.map +7 -0
- package/lib/cli/configure/modules/ignore.d.ts +2 -0
- package/lib/cli/configure/modules/ignore.js +40 -0
- package/lib/cli/configure/modules/ignore.js.map +7 -0
- package/lib/cli/configure/modules/index.d.ts +2 -0
- package/lib/cli/configure/modules/index.js +54 -0
- package/lib/cli/configure/modules/index.js.map +7 -0
- package/lib/cli/configure/modules/jest.d.ts +2 -0
- package/lib/cli/configure/modules/jest.js +86 -0
- package/lib/cli/configure/modules/jest.js.map +7 -0
- package/lib/cli/configure/modules/nodemon.d.ts +2 -0
- package/lib/cli/configure/modules/nodemon.js +30 -0
- package/lib/cli/configure/modules/nodemon.js.map +7 -0
- package/lib/cli/configure/modules/package.d.ts +2 -0
- package/lib/cli/configure/modules/package.js +117 -0
- package/lib/cli/configure/modules/package.js.map +7 -0
- package/lib/cli/configure/modules/prettier.d.ts +2 -0
- package/lib/cli/configure/modules/prettier.js +52 -0
- package/lib/cli/configure/modules/prettier.js.map +7 -0
- package/lib/cli/configure/modules/renovate.d.ts +3 -0
- package/lib/cli/configure/modules/renovate.js +69 -0
- package/lib/cli/configure/modules/renovate.js.map +7 -0
- package/lib/cli/configure/modules/serverless.d.ts +2 -0
- package/lib/cli/configure/modules/serverless.js +36 -0
- package/lib/cli/configure/modules/serverless.js.map +7 -0
- package/lib/cli/configure/modules/skubaDive.d.ts +2 -0
- package/lib/cli/configure/modules/skubaDive.js +72 -0
- package/lib/cli/configure/modules/skubaDive.js.map +7 -0
- package/lib/cli/configure/modules/tsconfig.d.ts +2 -0
- package/lib/cli/configure/modules/tsconfig.js +87 -0
- package/lib/cli/configure/modules/tsconfig.js.map +7 -0
- package/lib/cli/configure/modules/tslint.d.ts +2 -0
- package/lib/cli/configure/modules/tslint.js +30 -0
- package/lib/cli/configure/modules/tslint.js.map +7 -0
- package/lib/cli/configure/patchDockerfile.d.ts +1 -0
- package/lib/cli/configure/patchDockerfile.js +65 -0
- package/lib/cli/configure/patchDockerfile.js.map +7 -0
- package/lib/cli/configure/patchRenovateConfig.d.ts +1 -0
- package/lib/cli/configure/patchRenovateConfig.js +138 -0
- package/lib/cli/configure/patchRenovateConfig.js.map +7 -0
- package/lib/cli/configure/patchServerListener.d.ts +3 -0
- package/lib/cli/configure/patchServerListener.js +87 -0
- package/lib/cli/configure/patchServerListener.js.map +7 -0
- package/lib/cli/configure/processing/deleteFiles.d.ts +5 -0
- package/lib/cli/configure/processing/deleteFiles.js +31 -0
- package/lib/cli/configure/processing/deleteFiles.js.map +7 -0
- package/lib/cli/configure/processing/ignoreFile.d.ts +8 -0
- package/lib/cli/configure/processing/ignoreFile.js +74 -0
- package/lib/cli/configure/processing/ignoreFile.js.map +7 -0
- package/lib/cli/configure/processing/javascript.d.ts +2 -0
- package/lib/cli/configure/processing/javascript.js +38 -0
- package/lib/cli/configure/processing/javascript.js.map +7 -0
- package/lib/cli/configure/processing/json.d.ts +2 -0
- package/lib/cli/configure/processing/json.js +57 -0
- package/lib/cli/configure/processing/json.js.map +7 -0
- package/lib/cli/configure/processing/loadFiles.d.ts +5 -0
- package/lib/cli/configure/processing/loadFiles.js +31 -0
- package/lib/cli/configure/processing/loadFiles.js.map +7 -0
- package/lib/cli/configure/processing/module.d.ts +10 -0
- package/lib/cli/configure/processing/module.js +39 -0
- package/lib/cli/configure/processing/module.js.map +7 -0
- package/lib/cli/configure/processing/package.d.ts +73 -0
- package/lib/cli/configure/processing/package.js +85 -0
- package/lib/cli/configure/processing/package.js.map +7 -0
- package/lib/cli/configure/processing/prettier.d.ts +4 -0
- package/lib/cli/configure/processing/prettier.js +44 -0
- package/lib/cli/configure/processing/prettier.js.map +7 -0
- package/lib/cli/configure/processing/record.d.ts +11 -0
- package/lib/cli/configure/processing/record.js +65 -0
- package/lib/cli/configure/processing/record.js.map +7 -0
- package/lib/cli/configure/processing/typescript.d.ts +23 -0
- package/lib/cli/configure/processing/typescript.js +205 -0
- package/lib/cli/configure/processing/typescript.js.map +7 -0
- package/lib/cli/configure/refreshIgnoreFiles.d.ts +3 -0
- package/lib/cli/configure/refreshIgnoreFiles.js +78 -0
- package/lib/cli/configure/refreshIgnoreFiles.js.map +7 -0
- package/lib/cli/configure/types.d.ts +26 -0
- package/lib/cli/configure/types.js +17 -0
- package/lib/cli/configure/types.js.map +7 -0
- package/lib/cli/format.d.ts +1 -0
- package/lib/cli/format.js +74 -0
- package/lib/cli/format.js.map +7 -0
- package/lib/cli/help.d.ts +1 -0
- package/lib/cli/help.js +34 -0
- package/lib/cli/help.js.map +7 -0
- package/lib/cli/init/getConfig.d.ts +26 -0
- package/lib/cli/init/getConfig.js +286 -0
- package/lib/cli/init/getConfig.js.map +7 -0
- package/lib/cli/init/git.d.ts +7 -0
- package/lib/cli/init/git.js +82 -0
- package/lib/cli/init/git.js.map +7 -0
- package/lib/cli/init/index.d.ts +1 -0
- package/lib/cli/init/index.js +146 -0
- package/lib/cli/init/index.js.map +7 -0
- package/lib/cli/init/prompts.d.ts +45 -0
- package/lib/cli/init/prompts.js +97 -0
- package/lib/cli/init/prompts.js.map +7 -0
- package/lib/cli/init/types.d.ts +28 -0
- package/lib/cli/init/types.js +65 -0
- package/lib/cli/init/types.js.map +7 -0
- package/lib/cli/init/validation.d.ts +8 -0
- package/lib/cli/init/validation.js +43 -0
- package/lib/cli/init/validation.js.map +7 -0
- package/lib/cli/init/writePackageJson.d.ts +13 -0
- package/lib/cli/init/writePackageJson.js +58 -0
- package/lib/cli/init/writePackageJson.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/eslint.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/eslint.js +40 -0
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/index.d.ts +4 -0
- package/lib/cli/lint/annotate/buildkite/index.js +58 -0
- package/lib/cli/lint/annotate/buildkite/index.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/prettier.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/prettier.js +47 -0
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/tsc.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/tsc.js +45 -0
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +7 -0
- package/lib/cli/lint/annotate/github/eslint.d.ts +3 -0
- package/lib/cli/lint/annotate/github/eslint.js +45 -0
- package/lib/cli/lint/annotate/github/eslint.js.map +7 -0
- package/lib/cli/lint/annotate/github/index.d.ts +4 -0
- package/lib/cli/lint/annotate/github/index.js +63 -0
- package/lib/cli/lint/annotate/github/index.js.map +7 -0
- package/lib/cli/lint/annotate/github/prettier.d.ts +3 -0
- package/lib/cli/lint/annotate/github/prettier.js +39 -0
- package/lib/cli/lint/annotate/github/prettier.js.map +7 -0
- package/lib/cli/lint/annotate/github/tsc.d.ts +3 -0
- package/lib/cli/lint/annotate/github/tsc.js +63 -0
- package/lib/cli/lint/annotate/github/tsc.js.map +7 -0
- package/lib/cli/lint/annotate/index.d.ts +4 -0
- package/lib/cli/lint/annotate/index.js +36 -0
- package/lib/cli/lint/annotate/index.js.map +7 -0
- package/lib/cli/lint/autofix.d.ts +10 -0
- package/lib/cli/lint/autofix.js +214 -0
- package/lib/cli/lint/autofix.js.map +7 -0
- package/lib/cli/lint/eslint.d.ts +4 -0
- package/lib/cli/lint/eslint.js +55 -0
- package/lib/cli/lint/eslint.js.map +7 -0
- package/lib/cli/lint/external.d.ts +10 -0
- package/lib/cli/lint/external.js +117 -0
- package/lib/cli/lint/external.js.map +7 -0
- package/lib/cli/lint/index.d.ts +2 -0
- package/lib/cli/lint/index.js +51 -0
- package/lib/cli/lint/index.js.map +7 -0
- package/lib/cli/lint/internal.d.ts +1 -0
- package/lib/cli/lint/internal.js +64 -0
- package/lib/cli/lint/internal.js.map +7 -0
- package/lib/cli/lint/prettier.d.ts +4 -0
- package/lib/cli/lint/prettier.js +55 -0
- package/lib/cli/lint/prettier.js.map +7 -0
- package/lib/cli/lint/tsc.d.ts +2 -0
- package/lib/cli/lint/tsc.js +58 -0
- package/lib/cli/lint/tsc.js.map +7 -0
- package/lib/cli/lint/types.d.ts +34 -0
- package/lib/cli/lint/types.js +17 -0
- package/lib/cli/lint/types.js.map +7 -0
- package/lib/cli/node.d.ts +1 -0
- package/lib/cli/node.js +77 -0
- package/lib/cli/node.js.map +7 -0
- package/lib/cli/release.d.ts +1 -0
- package/lib/cli/release.js +32 -0
- package/lib/cli/release.js.map +7 -0
- package/lib/cli/start.d.ts +1 -0
- package/lib/cli/start.js +69 -0
- package/lib/cli/start.js.map +7 -0
- package/lib/cli/test/index.d.ts +1 -0
- package/lib/cli/test/index.js +36 -0
- package/lib/cli/test/index.js.map +7 -0
- package/lib/cli/test/reporters/github/annotations.d.ts +9 -0
- package/lib/cli/test/reporters/github/annotations.js +102 -0
- package/lib/cli/test/reporters/github/annotations.js.map +7 -0
- package/lib/cli/test/reporters/github/index.d.ts +5 -0
- package/lib/cli/test/reporters/github/index.js +75 -0
- package/lib/cli/test/reporters/github/index.js.map +7 -0
- package/lib/cli/test/reporters/prettier/index.d.ts +4 -0
- package/lib/cli/test/reporters/prettier/index.js +67 -0
- package/lib/cli/test/reporters/prettier/index.js.map +7 -0
- package/lib/cli/version.d.ts +1 -0
- package/lib/cli/version.js +34 -0
- package/lib/cli/version.js.map +7 -0
- package/lib/enquirer.d.js +2 -0
- package/lib/enquirer.d.js.map +7 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +51 -0
- package/lib/index.js.map +7 -0
- package/lib/skuba.d.ts +11 -0
- package/lib/skuba.js +53 -0
- package/lib/skuba.js.map +7 -0
- package/lib/utils/args.d.ts +43 -0
- package/lib/utils/args.js +114 -0
- package/lib/utils/args.js.map +7 -0
- package/lib/utils/command.d.ts +6 -0
- package/lib/utils/command.js +72 -0
- package/lib/utils/command.js.map +7 -0
- package/lib/utils/copy.d.ts +17 -0
- package/lib/utils/copy.js +105 -0
- package/lib/utils/copy.js.map +7 -0
- package/lib/utils/dir.d.ts +22 -0
- package/lib/utils/dir.js +91 -0
- package/lib/utils/dir.js.map +7 -0
- package/lib/utils/env.d.ts +5 -0
- package/lib/utils/env.js +29 -0
- package/lib/utils/env.js.map +7 -0
- package/lib/utils/error.d.ts +28 -0
- package/lib/utils/error.js +72 -0
- package/lib/utils/error.js.map +7 -0
- package/lib/utils/exec.d.ts +39 -0
- package/lib/utils/exec.js +163 -0
- package/lib/utils/exec.js.map +7 -0
- package/lib/utils/help.d.ts +1 -0
- package/lib/utils/help.js +34 -0
- package/lib/utils/help.js.map +7 -0
- package/lib/utils/logging.d.ts +27 -0
- package/lib/utils/logging.js +60 -0
- package/lib/utils/logging.js.map +7 -0
- package/lib/utils/logo.d.ts +9 -0
- package/lib/utils/logo.js +74 -0
- package/lib/utils/logo.js.map +7 -0
- package/lib/utils/manifest.d.ts +10 -0
- package/lib/utils/manifest.js +83 -0
- package/lib/utils/manifest.js.map +7 -0
- package/lib/utils/port.d.ts +2 -0
- package/lib/utils/port.js +48 -0
- package/lib/utils/port.js.map +7 -0
- package/lib/utils/template.d.ts +37 -0
- package/lib/utils/template.js +116 -0
- package/lib/utils/template.js.map +7 -0
- package/lib/utils/validation.d.ts +6 -0
- package/lib/utils/validation.js +44 -0
- package/lib/utils/validation.js.map +7 -0
- package/lib/utils/version.d.ts +13 -0
- package/lib/utils/version.js +89 -0
- package/lib/utils/version.js.map +7 -0
- package/lib/utils/wait.d.ts +17 -0
- package/lib/utils/wait.js +59 -0
- package/lib/utils/wait.js.map +7 -0
- package/lib/utils/worker.d.ts +20 -0
- package/lib/utils/worker.js +63 -0
- package/lib/utils/worker.js.map +7 -0
- package/lib/wrapper/function-arguments.d.js +2 -0
- package/lib/wrapper/function-arguments.d.js.map +7 -0
- package/lib/wrapper/functionHandler.d.ts +10 -0
- package/lib/wrapper/functionHandler.js +63 -0
- package/lib/wrapper/functionHandler.js.map +7 -0
- package/lib/wrapper/http.d.ts +20 -0
- package/lib/wrapper/http.js +79 -0
- package/lib/wrapper/http.js.map +7 -0
- package/lib/wrapper/index.d.ts +12 -0
- package/lib/wrapper/index.js +16 -0
- package/lib/wrapper/index.js.map +7 -0
- package/lib/wrapper/main.d.ts +1 -0
- package/lib/wrapper/main.js +47 -0
- package/lib/wrapper/main.js.map +7 -0
- package/lib/wrapper/requestListener.d.ts +11 -0
- package/lib/wrapper/requestListener.js +69 -0
- package/lib/wrapper/requestListener.js.map +7 -0
- package/package.json +170 -0
- package/template/base/.github/CODEOWNERS +1 -0
- package/template/base/.github/renovate.json5 +3 -0
- package/template/base/_.dockerignore +18 -0
- package/template/base/_.eslintignore +14 -0
- package/template/base/_.eslintrc.js +3 -0
- package/template/base/_.gitignore +23 -0
- package/template/base/_.prettierignore +8 -0
- package/template/base/_.prettierrc.js +1 -0
- package/template/base/jest.config.ts +15 -0
- package/template/base/jest.setup.ts +3 -0
- package/template/base/tsconfig.build.json +5 -0
- package/template/base/tsconfig.json +13 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +105 -0
- package/template/express-rest-api/.env +1 -0
- package/template/express-rest-api/.gantry/common.yml +20 -0
- package/template/express-rest-api/.gantry/dev.yml +8 -0
- package/template/express-rest-api/.gantry/prod.yml +8 -0
- package/template/express-rest-api/.nvmrc +1 -0
- package/template/express-rest-api/Dockerfile +37 -0
- package/template/express-rest-api/Dockerfile.dev-deps +11 -0
- package/template/express-rest-api/README.md +106 -0
- package/template/express-rest-api/docker-compose.yml +22 -0
- package/template/express-rest-api/gantry.apply.yml +120 -0
- package/template/express-rest-api/gantry.build.yml +15 -0
- package/template/express-rest-api/package.json +30 -0
- package/template/express-rest-api/skuba.template.js +49 -0
- package/template/express-rest-api/src/api/healthCheck.ts +11 -0
- package/template/express-rest-api/src/api/smokeTest.ts +8 -0
- package/template/express-rest-api/src/app.test.ts +9 -0
- package/template/express-rest-api/src/app.ts +14 -0
- package/template/express-rest-api/src/config.ts +57 -0
- package/template/express-rest-api/src/framework/logging.ts +17 -0
- package/template/express-rest-api/src/listen.ts +23 -0
- package/template/express-rest-api/src/register.ts +1 -0
- package/template/greeter/.buildkite/pipeline.yml +37 -0
- package/template/greeter/.nvmrc +1 -0
- package/template/greeter/Dockerfile +11 -0
- package/template/greeter/README.md +96 -0
- package/template/greeter/docker-compose.yml +22 -0
- package/template/greeter/package.json +24 -0
- package/template/greeter/skuba.template.js +16 -0
- package/template/greeter/src/app.test.ts +5 -0
- package/template/greeter/src/app.ts +4 -0
- package/template/koa-rest-api/.buildkite/pipeline.yml +105 -0
- package/template/koa-rest-api/.env +1 -0
- package/template/koa-rest-api/.gantry/common.yml +20 -0
- package/template/koa-rest-api/.gantry/dev.yml +11 -0
- package/template/koa-rest-api/.gantry/prod.yml +11 -0
- package/template/koa-rest-api/.nvmrc +1 -0
- package/template/koa-rest-api/Dockerfile +37 -0
- package/template/koa-rest-api/Dockerfile.dev-deps +11 -0
- package/template/koa-rest-api/README.md +111 -0
- package/template/koa-rest-api/docker-compose.yml +22 -0
- package/template/koa-rest-api/gantry.apply.yml +127 -0
- package/template/koa-rest-api/gantry.build.yml +15 -0
- package/template/koa-rest-api/package.json +47 -0
- package/template/koa-rest-api/skuba.template.js +49 -0
- package/template/koa-rest-api/src/api/healthCheck.ts +13 -0
- package/template/koa-rest-api/src/api/index.ts +10 -0
- package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +9 -0
- package/template/koa-rest-api/src/api/jobs/getJobs.ts +15 -0
- package/template/koa-rest-api/src/api/jobs/index.ts +10 -0
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +34 -0
- package/template/koa-rest-api/src/api/jobs/postJob.ts +19 -0
- package/template/koa-rest-api/src/api/smokeTest.ts +11 -0
- package/template/koa-rest-api/src/app.test.ts +21 -0
- package/template/koa-rest-api/src/app.ts +8 -0
- package/template/koa-rest-api/src/config.ts +57 -0
- package/template/koa-rest-api/src/framework/logging.ts +25 -0
- package/template/koa-rest-api/src/framework/metrics.ts +11 -0
- package/template/koa-rest-api/src/framework/middleware.ts +3 -0
- package/template/koa-rest-api/src/framework/server.test.ts +260 -0
- package/template/koa-rest-api/src/framework/server.ts +51 -0
- package/template/koa-rest-api/src/framework/validation.test.ts +72 -0
- package/template/koa-rest-api/src/framework/validation.ts +77 -0
- package/template/koa-rest-api/src/listen.ts +24 -0
- package/template/koa-rest-api/src/register.ts +1 -0
- package/template/koa-rest-api/src/storage/jobs.ts +28 -0
- package/template/koa-rest-api/src/testing/logging.ts +16 -0
- package/template/koa-rest-api/src/testing/metrics.ts +29 -0
- package/template/koa-rest-api/src/testing/server.ts +31 -0
- package/template/koa-rest-api/src/testing/types.ts +24 -0
- package/template/koa-rest-api/src/tracing.ts +56 -0
- package/template/koa-rest-api/src/types/jobs.ts +17 -0
- package/template/koa-rest-api/src/types/koa.ts +8 -0
- package/template/koa-rest-api/tsconfig.json +18 -0
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +98 -0
- package/template/lambda-sqs-worker/.env +1 -0
- package/template/lambda-sqs-worker/.nvmrc +1 -0
- package/template/lambda-sqs-worker/Dockerfile +12 -0
- package/template/lambda-sqs-worker/README.md +132 -0
- package/template/lambda-sqs-worker/docker-compose.yml +27 -0
- package/template/lambda-sqs-worker/package.json +44 -0
- package/template/lambda-sqs-worker/serverless.yml +202 -0
- package/template/lambda-sqs-worker/skuba.template.js +32 -0
- package/template/lambda-sqs-worker/src/app.test.ts +116 -0
- package/template/lambda-sqs-worker/src/app.ts +57 -0
- package/template/lambda-sqs-worker/src/config.ts +57 -0
- package/template/lambda-sqs-worker/src/framework/handler.test.ts +61 -0
- package/template/lambda-sqs-worker/src/framework/handler.ts +43 -0
- package/template/lambda-sqs-worker/src/framework/logging.ts +27 -0
- package/template/lambda-sqs-worker/src/framework/metrics.ts +14 -0
- package/template/lambda-sqs-worker/src/framework/validation.test.ts +84 -0
- package/template/lambda-sqs-worker/src/framework/validation.ts +10 -0
- package/template/lambda-sqs-worker/src/hooks.ts +96 -0
- package/template/lambda-sqs-worker/src/mapping/jobScorer.ts +22 -0
- package/template/lambda-sqs-worker/src/services/aws.ts +5 -0
- package/template/lambda-sqs-worker/src/services/jobScorer.test.ts +44 -0
- package/template/lambda-sqs-worker/src/services/jobScorer.ts +59 -0
- package/template/lambda-sqs-worker/src/services/pipelineEventSender.test.ts +40 -0
- package/template/lambda-sqs-worker/src/services/pipelineEventSender.ts +33 -0
- package/template/lambda-sqs-worker/src/testing/handler.ts +13 -0
- package/template/lambda-sqs-worker/src/testing/logging.ts +19 -0
- package/template/lambda-sqs-worker/src/testing/services.ts +28 -0
- package/template/lambda-sqs-worker/src/testing/types.ts +33 -0
- package/template/lambda-sqs-worker/src/types/jobScorer.ts +15 -0
- package/template/lambda-sqs-worker/src/types/pipelineEvents.ts +21 -0
- package/template/lambda-sqs-worker/tsconfig.json +13 -0
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +95 -0
- package/template/lambda-sqs-worker-cdk/.nvmrc +1 -0
- package/template/lambda-sqs-worker-cdk/Dockerfile +13 -0
- package/template/lambda-sqs-worker-cdk/cdk.json +25 -0
- package/template/lambda-sqs-worker-cdk/docker-compose.yml +28 -0
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +723 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +34 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +74 -0
- package/template/lambda-sqs-worker-cdk/infra/index.ts +14 -0
- package/template/lambda-sqs-worker-cdk/package.json +30 -0
- package/template/lambda-sqs-worker-cdk/shared/context-types.ts +21 -0
- package/template/lambda-sqs-worker-cdk/skuba.template.js +27 -0
- package/template/lambda-sqs-worker-cdk/src/app.ts +10 -0
- package/template/lambda-sqs-worker-cdk/tsconfig.json +13 -0
- package/template/oss-npm-package/.github/workflows/release.yml +36 -0
- package/template/oss-npm-package/.github/workflows/validate.yml +31 -0
- package/template/oss-npm-package/.nvmrc +1 -0
- package/template/oss-npm-package/LICENSE +21 -0
- package/template/oss-npm-package/README.md +128 -0
- package/template/oss-npm-package/_package.json +47 -0
- package/template/oss-npm-package/skuba.template.js +22 -0
- package/template/oss-npm-package/src/index.test.ts +5 -0
- package/template/oss-npm-package/src/index.ts +7 -0
- package/template/oss-npm-package/tsconfig.json +10 -0
- package/template/private-npm-package/.buildkite/pipeline.yml +5 -0
- package/template/private-npm-package/.nvmrc +1 -0
- package/template/private-npm-package/README.md +109 -0
- package/template/private-npm-package/_package.json +44 -0
- package/template/private-npm-package/skuba.template.js +24 -0
- package/template/private-npm-package/src/index.test.ts +5 -0
- package/template/private-npm-package/src/index.ts +7 -0
- package/template/private-npm-package/tsconfig.json +10 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
service: <%- serviceName %>
|
|
2
|
+
|
|
3
|
+
configValidationMode: error
|
|
4
|
+
|
|
5
|
+
params:
|
|
6
|
+
default:
|
|
7
|
+
datadogApiKeySecretArn: 'TODO: arn:aws:secretsmanager:${aws:region}:${aws:accountId}:secret:SECRET-NAME'
|
|
8
|
+
description: <%- description %>
|
|
9
|
+
dev:
|
|
10
|
+
deploymentBucket: 'TODO: deployment-bucket-name'
|
|
11
|
+
isProduction: false
|
|
12
|
+
prod:
|
|
13
|
+
deploymentBucket: 'TODO: deployment-bucket-name'
|
|
14
|
+
isProduction: true
|
|
15
|
+
|
|
16
|
+
custom:
|
|
17
|
+
datadog:
|
|
18
|
+
addLayers: false
|
|
19
|
+
apiKeySecretArn: ${param:datadogApiKeySecretArn}
|
|
20
|
+
enableDDLogs: false
|
|
21
|
+
# TODO: enable Datadog extension
|
|
22
|
+
enabled: false
|
|
23
|
+
exclude:
|
|
24
|
+
- WorkerPreHook
|
|
25
|
+
injectLogContext: false
|
|
26
|
+
version: ${env:VERSION}
|
|
27
|
+
prune:
|
|
28
|
+
automatic: true
|
|
29
|
+
number: 3
|
|
30
|
+
|
|
31
|
+
plugins:
|
|
32
|
+
- serverless-plugin-canary-deployments
|
|
33
|
+
- serverless-plugin-datadog
|
|
34
|
+
- serverless-prune-plugin
|
|
35
|
+
|
|
36
|
+
provider:
|
|
37
|
+
logRetentionInDays: 30
|
|
38
|
+
name: aws
|
|
39
|
+
region: ap-southeast-2
|
|
40
|
+
runtime: nodejs18.x
|
|
41
|
+
architecture: <%- lambdaServerlessArchitecture %>
|
|
42
|
+
deploymentMethod: direct
|
|
43
|
+
stackName: ${self:service}
|
|
44
|
+
stage: ${env:ENVIRONMENT}
|
|
45
|
+
deploymentBucket:
|
|
46
|
+
# Use a shared account-level bucket for Lambda bundles and other artefacts.
|
|
47
|
+
# This is easier to manage in terms of access, deployment, and tagging.
|
|
48
|
+
name: ${param:deploymentBucket}
|
|
49
|
+
environment:
|
|
50
|
+
NODE_ENV: production
|
|
51
|
+
# https://nodejs.org/api/cli.html#cli_node_options_options
|
|
52
|
+
NODE_OPTIONS: --enable-source-maps
|
|
53
|
+
iam:
|
|
54
|
+
role:
|
|
55
|
+
statements:
|
|
56
|
+
- Action:
|
|
57
|
+
- kms:Decrypt
|
|
58
|
+
- kms:GenerateDataKey*
|
|
59
|
+
Effect: Allow
|
|
60
|
+
Resource: !GetAtt EncryptionKey.Arn
|
|
61
|
+
- Action: lambda:InvokeFunction
|
|
62
|
+
Effect: Allow
|
|
63
|
+
Resource: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${self:functions.Worker.name}
|
|
64
|
+
- Action: secretsmanager:GetSecretValue
|
|
65
|
+
Effect: Allow
|
|
66
|
+
Resource: ${param:datadogApiKeySecretArn}-??????
|
|
67
|
+
- Action: sns:Publish
|
|
68
|
+
Effect: Allow
|
|
69
|
+
Resource: !Ref DestinationTopic
|
|
70
|
+
stackTags:
|
|
71
|
+
# TODO: add data classification tags
|
|
72
|
+
# https://rfc.skinfra.xyz/RFC019-AWS-Tagging-Standard.html#seekdataconsumers
|
|
73
|
+
# seek:data:consumers: internal
|
|
74
|
+
# https://rfc.skinfra.xyz/RFC019-AWS-Tagging-Standard.html#seekdatatypes
|
|
75
|
+
# seek:data:types:restricted: job-ads
|
|
76
|
+
seek:env:label: ${env:ENVIRONMENT}
|
|
77
|
+
seek:env:production: ${param:isProduction}
|
|
78
|
+
seek:owner:team: '<%- teamName %>'
|
|
79
|
+
seek:source:sha: ${env:BUILDKITE_COMMIT, 'na'}
|
|
80
|
+
seek:source:url: 'https://github.com/SEEK-Jobs/<%- repoName %>'
|
|
81
|
+
|
|
82
|
+
package:
|
|
83
|
+
patterns:
|
|
84
|
+
- '!**'
|
|
85
|
+
- lib/**
|
|
86
|
+
- node_modules/**
|
|
87
|
+
|
|
88
|
+
functions:
|
|
89
|
+
Worker:
|
|
90
|
+
name: ${self:service}
|
|
91
|
+
handler: lib/app.handler
|
|
92
|
+
description: ${param:description}
|
|
93
|
+
memorySize: 128
|
|
94
|
+
reservedConcurrency: 20
|
|
95
|
+
timeout: 30
|
|
96
|
+
deploymentSettings:
|
|
97
|
+
type: AllAtOnce
|
|
98
|
+
alias: Live
|
|
99
|
+
preTrafficHook: WorkerPreHook
|
|
100
|
+
environment:
|
|
101
|
+
ENVIRONMENT: ${env:ENVIRONMENT}
|
|
102
|
+
SERVICE: ${self:service}
|
|
103
|
+
VERSION: ${env:VERSION, 'local'}
|
|
104
|
+
|
|
105
|
+
DESTINATION_SNS_TOPIC_ARN: !Ref DestinationTopic
|
|
106
|
+
events:
|
|
107
|
+
- sqs:
|
|
108
|
+
arn: !GetAtt MessageQueue.Arn
|
|
109
|
+
batchSize: 1
|
|
110
|
+
WorkerPreHook:
|
|
111
|
+
name: ${self:functions.Worker.name}-pre-hook
|
|
112
|
+
handler: lib/hooks.pre
|
|
113
|
+
memorySize: 128
|
|
114
|
+
# This is generous because a timeout will hang the deployment
|
|
115
|
+
timeout: 300
|
|
116
|
+
environment:
|
|
117
|
+
FUNCTION_NAME_TO_INVOKE: ${self:functions.Worker.name}
|
|
118
|
+
|
|
119
|
+
resources:
|
|
120
|
+
# This becomes the Lambda application's description
|
|
121
|
+
Description: ${param:description}
|
|
122
|
+
|
|
123
|
+
Resources:
|
|
124
|
+
DeadLetterQueue:
|
|
125
|
+
Type: AWS::SQS::Queue
|
|
126
|
+
Properties:
|
|
127
|
+
MessageRetentionPeriod: 1209600
|
|
128
|
+
KmsDataKeyReusePeriodSeconds: 300
|
|
129
|
+
KmsMasterKeyId: !Ref EncryptionKey
|
|
130
|
+
QueueName: ${self:service}-dead-letters
|
|
131
|
+
|
|
132
|
+
MessageQueue:
|
|
133
|
+
Type: AWS::SQS::Queue
|
|
134
|
+
Properties:
|
|
135
|
+
MessageRetentionPeriod: 1209600
|
|
136
|
+
KmsDataKeyReusePeriodSeconds: 300
|
|
137
|
+
KmsMasterKeyId: !Ref EncryptionKey
|
|
138
|
+
QueueName: ${self:service}-messages
|
|
139
|
+
RedrivePolicy:
|
|
140
|
+
deadLetterTargetArn: !GetAtt DeadLetterQueue.Arn
|
|
141
|
+
maxReceiveCount: 3
|
|
142
|
+
VisibilityTimeout: 180
|
|
143
|
+
|
|
144
|
+
# MessageQueuePolicy:
|
|
145
|
+
# Type: AWS::SQS::QueuePolicy
|
|
146
|
+
# Properties:
|
|
147
|
+
# PolicyDocument:
|
|
148
|
+
# Version: '2012-10-17'
|
|
149
|
+
# Statement:
|
|
150
|
+
# - Action: sqs:SendMessage
|
|
151
|
+
# Condition:
|
|
152
|
+
# ArnEquals:
|
|
153
|
+
# aws:SourceArn: 'TODO: sourceSnsTopicArn'
|
|
154
|
+
# Effect: 'Allow'
|
|
155
|
+
# Principal:
|
|
156
|
+
# AWS: '*'
|
|
157
|
+
# Resource: '*'
|
|
158
|
+
# Queues:
|
|
159
|
+
# - !Ref MessageQueue
|
|
160
|
+
|
|
161
|
+
# TopicSubscription:
|
|
162
|
+
# Type: AWS::SNS::Subscription
|
|
163
|
+
# Properties:
|
|
164
|
+
# Endpoint: !GetAtt MessageQueue.Arn
|
|
165
|
+
# Protocol: sqs
|
|
166
|
+
# RawMessageDelivery: true
|
|
167
|
+
# TopicArn: 'TODO: sourceSnsTopicArn'
|
|
168
|
+
|
|
169
|
+
DestinationTopic:
|
|
170
|
+
Type: AWS::SNS::Topic
|
|
171
|
+
Properties:
|
|
172
|
+
KmsMasterKeyId: alias/aws/sns
|
|
173
|
+
TopicName: ${self:service}
|
|
174
|
+
|
|
175
|
+
EncryptionKey:
|
|
176
|
+
Type: AWS::KMS::Key
|
|
177
|
+
Properties:
|
|
178
|
+
Description: ${self:service}
|
|
179
|
+
EnableKeyRotation: true
|
|
180
|
+
KeyPolicy:
|
|
181
|
+
Version: '2012-10-17'
|
|
182
|
+
Statement:
|
|
183
|
+
- Sid: Admin access
|
|
184
|
+
Effect: Allow
|
|
185
|
+
Action: kms:*
|
|
186
|
+
Principal:
|
|
187
|
+
AWS: !Ref AWS::AccountId
|
|
188
|
+
Resource: '*'
|
|
189
|
+
- Sid: SNS compatibility
|
|
190
|
+
Effect: Allow
|
|
191
|
+
Action:
|
|
192
|
+
- kms:Decrypt
|
|
193
|
+
- kms:GenerateDataKey*
|
|
194
|
+
Principal:
|
|
195
|
+
Service: sns.amazonaws.com
|
|
196
|
+
Resource: '*'
|
|
197
|
+
|
|
198
|
+
EncryptionKeyAlias:
|
|
199
|
+
Type: AWS::KMS::Alias
|
|
200
|
+
Properties:
|
|
201
|
+
AliasName: alias/seek/${self:service}
|
|
202
|
+
TargetKeyId: !Ref EncryptionKey
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run `skuba configure` to finish templating and remove this file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
entryPoint: 'src/app.ts#handler',
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
name: 'serviceName',
|
|
10
|
+
message: 'Service slug',
|
|
11
|
+
initial: 'my-project',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'description',
|
|
15
|
+
message: 'Description',
|
|
16
|
+
initial: 'A project just for me',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'devBuildkiteQueueName',
|
|
20
|
+
message: 'Dev Buildkite queue',
|
|
21
|
+
initial: 'my-team-aws-account-dev:cicd',
|
|
22
|
+
validate: (value) => /^.+:.+$/.test(value),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'prodBuildkiteQueueName',
|
|
26
|
+
message: 'Prod Buildkite queue',
|
|
27
|
+
initial: 'my-team-aws-account-prod:cicd',
|
|
28
|
+
validate: (value) => /^.+:.+$/.test(value),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
type: 'application',
|
|
32
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { PublishCommand } from '@aws-sdk/client-sns';
|
|
2
|
+
|
|
3
|
+
import { metricsClient } from 'src/framework/metrics';
|
|
4
|
+
import { createCtx, createSqsEvent } from 'src/testing/handler';
|
|
5
|
+
import { logger } from 'src/testing/logging';
|
|
6
|
+
import { scoringService, sns } from 'src/testing/services';
|
|
7
|
+
import { chance, mockJobPublishedEvent } from 'src/testing/types';
|
|
8
|
+
|
|
9
|
+
import * as app from './app';
|
|
10
|
+
|
|
11
|
+
describe('app', () => {
|
|
12
|
+
it('exports a handler', () => expect(app).toHaveProperty('handler'));
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('handler', () => {
|
|
16
|
+
const ctx = createCtx();
|
|
17
|
+
|
|
18
|
+
const jobPublished = mockJobPublishedEvent({ entityId: chance.name() });
|
|
19
|
+
|
|
20
|
+
const score = chance.floating({ max: 1, min: 0 });
|
|
21
|
+
|
|
22
|
+
const distribution = jest
|
|
23
|
+
.spyOn(metricsClient, 'distribution')
|
|
24
|
+
.mockReturnValue();
|
|
25
|
+
|
|
26
|
+
beforeAll(logger.spy);
|
|
27
|
+
beforeAll(scoringService.spy);
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
scoringService.request.mockResolvedValue(score);
|
|
31
|
+
sns.publish.resolves({ MessageId: chance.guid({ version: 4 }) });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
logger.clear();
|
|
36
|
+
distribution.mockClear();
|
|
37
|
+
scoringService.clear();
|
|
38
|
+
sns.clear();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('handles one record', async () => {
|
|
42
|
+
const event = createSqsEvent([JSON.stringify(jobPublished)]);
|
|
43
|
+
|
|
44
|
+
await expect(app.handler(event, ctx)).resolves.toBeUndefined();
|
|
45
|
+
|
|
46
|
+
expect(scoringService.request).toHaveBeenCalledTimes(1);
|
|
47
|
+
|
|
48
|
+
expect(logger.error).not.toHaveBeenCalled();
|
|
49
|
+
|
|
50
|
+
expect(logger.debug.mock.calls).toEqual([
|
|
51
|
+
[{ count: 1 }, 'Received jobs'],
|
|
52
|
+
[{ snsMessageId: expect.any(String) }, 'Scored job'],
|
|
53
|
+
['Function succeeded'],
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
expect(distribution.mock.calls).toEqual([
|
|
57
|
+
['job.received', 1],
|
|
58
|
+
['job.scored', 1],
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
expect(sns.client).toReceiveCommandTimes(PublishCommand, 1);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('throws on invalid input', () => {
|
|
65
|
+
const event = createSqsEvent(['}']);
|
|
66
|
+
|
|
67
|
+
return expect(app.handler(event, ctx)).rejects.toThrow('Function failed');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('bubbles up scoring service error', async () => {
|
|
71
|
+
const err = Error(chance.sentence());
|
|
72
|
+
|
|
73
|
+
scoringService.request.mockRejectedValue(err);
|
|
74
|
+
|
|
75
|
+
const event = createSqsEvent([JSON.stringify(jobPublished)]);
|
|
76
|
+
|
|
77
|
+
await expect(app.handler(event, ctx)).rejects.toThrow('Function failed');
|
|
78
|
+
|
|
79
|
+
expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('bubbles up SNS error', async () => {
|
|
83
|
+
const err = Error(chance.sentence());
|
|
84
|
+
|
|
85
|
+
sns.publish.rejects(err);
|
|
86
|
+
|
|
87
|
+
const event = createSqsEvent([JSON.stringify(jobPublished)]);
|
|
88
|
+
|
|
89
|
+
await expect(app.handler(event, ctx)).rejects.toThrow('Function failed');
|
|
90
|
+
|
|
91
|
+
expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('throws on zero records', async () => {
|
|
95
|
+
const err = new Error('Received 0 records');
|
|
96
|
+
|
|
97
|
+
const event = createSqsEvent([]);
|
|
98
|
+
|
|
99
|
+
await expect(app.handler(event, ctx)).rejects.toThrow('Function failed');
|
|
100
|
+
|
|
101
|
+
expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('throws on multiple records', async () => {
|
|
105
|
+
const err = new Error('Received 2 records');
|
|
106
|
+
|
|
107
|
+
const event = createSqsEvent([
|
|
108
|
+
JSON.stringify(jobPublished),
|
|
109
|
+
JSON.stringify(jobPublished),
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
await expect(app.handler(event, ctx)).rejects.toThrow('Function failed');
|
|
113
|
+
|
|
114
|
+
expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import 'skuba-dive/register';
|
|
2
|
+
|
|
3
|
+
import type { SQSEvent } from 'aws-lambda';
|
|
4
|
+
|
|
5
|
+
import { createHandler } from 'src/framework/handler';
|
|
6
|
+
import { logger } from 'src/framework/logging';
|
|
7
|
+
import { metricsClient } from 'src/framework/metrics';
|
|
8
|
+
import { validateJson } from 'src/framework/validation';
|
|
9
|
+
import { scoreJobPublishedEvent, scoringService } from 'src/services/jobScorer';
|
|
10
|
+
import { sendPipelineEvent } from 'src/services/pipelineEventSender';
|
|
11
|
+
import { JobPublishedEventSchema } from 'src/types/pipelineEvents';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Tests connectivity to ensure appropriate access and network configuration.
|
|
15
|
+
*/
|
|
16
|
+
const smokeTest = async () => {
|
|
17
|
+
await Promise.all([scoringService.smokeTest(), sendPipelineEvent({}, true)]);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const handler = createHandler<SQSEvent>(async (event) => {
|
|
21
|
+
// Treat an empty object as our smoke test event.
|
|
22
|
+
if (!Object.keys(event).length) {
|
|
23
|
+
logger.debug('Received smoke test request');
|
|
24
|
+
return smokeTest();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const count = event.Records.length;
|
|
28
|
+
|
|
29
|
+
if (count !== 1) {
|
|
30
|
+
throw Error(`Received ${count} records`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
logger.debug({ count }, 'Received jobs');
|
|
34
|
+
|
|
35
|
+
metricsClient.distribution('job.received', event.Records.length);
|
|
36
|
+
|
|
37
|
+
const record = event.Records[0];
|
|
38
|
+
if (!record) {
|
|
39
|
+
throw new Error('Malformed SQS event with no records');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { body } = record;
|
|
43
|
+
|
|
44
|
+
// TODO: this throws an error, which will cause the Lambda function to retry
|
|
45
|
+
// the event and eventually send it to your dead-letter queue. If you don't
|
|
46
|
+
// trust your source to provide consistently well-formed input, consider
|
|
47
|
+
// catching and handling this error in code.
|
|
48
|
+
const publishedJob = validateJson(body, JobPublishedEventSchema);
|
|
49
|
+
|
|
50
|
+
const scoredJob = await scoreJobPublishedEvent(publishedJob);
|
|
51
|
+
|
|
52
|
+
const snsMessageId = await sendPipelineEvent(scoredJob);
|
|
53
|
+
|
|
54
|
+
logger.debug({ snsMessageId }, 'Scored job');
|
|
55
|
+
|
|
56
|
+
metricsClient.distribution('job.scored', 1);
|
|
57
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Env } from 'skuba-dive';
|
|
2
|
+
|
|
3
|
+
interface Config {
|
|
4
|
+
environment: Environment;
|
|
5
|
+
|
|
6
|
+
logLevel: string;
|
|
7
|
+
metrics: boolean;
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
|
|
11
|
+
destinationSnsTopicArn: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Environment = (typeof environments)[number];
|
|
15
|
+
|
|
16
|
+
const environments = ['local', 'test', 'dev', 'prod'] as const;
|
|
17
|
+
|
|
18
|
+
const environment = Env.oneOf(environments)('ENVIRONMENT');
|
|
19
|
+
|
|
20
|
+
/* istanbul ignore next: config verification makes more sense in a smoke test */
|
|
21
|
+
const configs: Record<Environment, () => Omit<Config, 'environment'>> = {
|
|
22
|
+
local: () => ({
|
|
23
|
+
logLevel: 'debug',
|
|
24
|
+
metrics: false,
|
|
25
|
+
name: '<%- serviceName %>',
|
|
26
|
+
version: 'local',
|
|
27
|
+
|
|
28
|
+
destinationSnsTopicArn: 'arn:aws:sns:us-east-2:123456789012:destination',
|
|
29
|
+
}),
|
|
30
|
+
|
|
31
|
+
test: () => ({
|
|
32
|
+
...configs.local(),
|
|
33
|
+
|
|
34
|
+
logLevel: Env.string('LOG_LEVEL', { default: 'silent' }),
|
|
35
|
+
version: 'test',
|
|
36
|
+
}),
|
|
37
|
+
|
|
38
|
+
dev: () => ({
|
|
39
|
+
...configs.prod(),
|
|
40
|
+
|
|
41
|
+
logLevel: 'debug',
|
|
42
|
+
}),
|
|
43
|
+
|
|
44
|
+
prod: () => ({
|
|
45
|
+
logLevel: 'info',
|
|
46
|
+
metrics: true,
|
|
47
|
+
name: Env.string('SERVICE'),
|
|
48
|
+
version: Env.string('VERSION'),
|
|
49
|
+
|
|
50
|
+
destinationSnsTopicArn: Env.string('DESTINATION_SNS_TOPIC_ARN'),
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const config: Config = {
|
|
55
|
+
...configs[environment](),
|
|
56
|
+
environment,
|
|
57
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createCtx } from 'src/testing/handler';
|
|
2
|
+
import { logger } from 'src/testing/logging';
|
|
3
|
+
import { chance } from 'src/testing/types';
|
|
4
|
+
|
|
5
|
+
import { createHandler } from './handler';
|
|
6
|
+
|
|
7
|
+
describe('createHandler', () => {
|
|
8
|
+
const ctx = createCtx();
|
|
9
|
+
const input = chance.paragraph();
|
|
10
|
+
|
|
11
|
+
beforeAll(logger.spy);
|
|
12
|
+
|
|
13
|
+
afterEach(logger.clear);
|
|
14
|
+
|
|
15
|
+
it('handles happy path', async () => {
|
|
16
|
+
const output = chance.paragraph();
|
|
17
|
+
|
|
18
|
+
const handler = createHandler((event) => {
|
|
19
|
+
expect(event).toBe(input);
|
|
20
|
+
|
|
21
|
+
logger.debug('Handler invoked');
|
|
22
|
+
|
|
23
|
+
return Promise.resolve(output);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await expect(handler(input, ctx)).resolves.toBe(output);
|
|
27
|
+
|
|
28
|
+
expect(logger.error).not.toHaveBeenCalled();
|
|
29
|
+
|
|
30
|
+
expect(logger.debug.mock.calls).toEqual([
|
|
31
|
+
['Handler invoked'],
|
|
32
|
+
['Function succeeded'],
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('handles async error', async () => {
|
|
37
|
+
const err = Error(chance.sentence());
|
|
38
|
+
|
|
39
|
+
const handler = createHandler(() => Promise.reject(err));
|
|
40
|
+
|
|
41
|
+
await expect(handler(input, ctx)).rejects.toThrow('Function failed');
|
|
42
|
+
|
|
43
|
+
expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
|
|
44
|
+
|
|
45
|
+
expect(logger.debug).not.toHaveBeenCalled();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('handles sync error', async () => {
|
|
49
|
+
const err = Error(chance.sentence());
|
|
50
|
+
|
|
51
|
+
const handler = createHandler(() => {
|
|
52
|
+
throw err;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await expect(handler(input, ctx)).rejects.toThrow('Function failed');
|
|
56
|
+
|
|
57
|
+
expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
|
|
58
|
+
|
|
59
|
+
expect(logger.debug).not.toHaveBeenCalled();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { datadog } from 'datadog-lambda-js';
|
|
2
|
+
|
|
3
|
+
import { config } from 'src/config';
|
|
4
|
+
import { logger, loggerContext } from 'src/framework/logging';
|
|
5
|
+
|
|
6
|
+
interface LambdaContext {
|
|
7
|
+
awsRequestId: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type Handler<Event, Output> = (
|
|
11
|
+
event: Event,
|
|
12
|
+
ctx: LambdaContext,
|
|
13
|
+
) => Promise<Output>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Conditionally applies the Datadog wrapper to a Lambda handler.
|
|
17
|
+
*
|
|
18
|
+
* This also "fixes" its broken type definitions.
|
|
19
|
+
*/
|
|
20
|
+
const withDatadog = <Event, Output = unknown>(
|
|
21
|
+
fn: Handler<Event, Output>,
|
|
22
|
+
): Handler<Event, Output> =>
|
|
23
|
+
// istanbul ignore next
|
|
24
|
+
config.metrics ? (datadog(fn) as Handler<Event, Output>) : fn;
|
|
25
|
+
|
|
26
|
+
export const createHandler = <Event, Output = unknown>(
|
|
27
|
+
fn: (event: Event) => Promise<Output>,
|
|
28
|
+
) =>
|
|
29
|
+
withDatadog<Event>((event, { awsRequestId }) =>
|
|
30
|
+
loggerContext.run({ awsRequestId }, async () => {
|
|
31
|
+
try {
|
|
32
|
+
const output = await fn(event);
|
|
33
|
+
|
|
34
|
+
logger.debug('Function succeeded');
|
|
35
|
+
|
|
36
|
+
return output;
|
|
37
|
+
} catch (err) {
|
|
38
|
+
logger.error({ err }, 'Function failed');
|
|
39
|
+
|
|
40
|
+
throw new Error('Function failed');
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
|
+
|
|
3
|
+
import createLogger from '@seek/logger';
|
|
4
|
+
|
|
5
|
+
import { config } from 'src/config';
|
|
6
|
+
|
|
7
|
+
interface LoggerContext {
|
|
8
|
+
awsRequestId: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const loggerContext = new AsyncLocalStorage<LoggerContext>();
|
|
12
|
+
|
|
13
|
+
export const logger = createLogger({
|
|
14
|
+
base: {
|
|
15
|
+
environment: config.environment,
|
|
16
|
+
version: config.version,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
level: config.logLevel,
|
|
20
|
+
|
|
21
|
+
mixin: () => ({ ...loggerContext.getStore() }),
|
|
22
|
+
|
|
23
|
+
name: config.name,
|
|
24
|
+
|
|
25
|
+
transport:
|
|
26
|
+
config.environment === 'local' ? { target: 'pino-pretty' } : undefined,
|
|
27
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { sendDistributionMetric } from 'datadog-lambda-js';
|
|
2
|
+
|
|
3
|
+
import { config } from 'src/config';
|
|
4
|
+
|
|
5
|
+
const prefix = `${config.name}.`;
|
|
6
|
+
|
|
7
|
+
export const metricsClient = {
|
|
8
|
+
distribution: (
|
|
9
|
+
...[name, ...rest]: Parameters<typeof sendDistributionMetric>
|
|
10
|
+
) =>
|
|
11
|
+
config.metrics
|
|
12
|
+
? sendDistributionMetric(`${prefix}${name}`, ...rest)
|
|
13
|
+
: undefined,
|
|
14
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IdDescriptionSchema,
|
|
3
|
+
chance,
|
|
4
|
+
mockIdDescription,
|
|
5
|
+
} from 'src/testing/types';
|
|
6
|
+
|
|
7
|
+
import { validateJson } from './validation';
|
|
8
|
+
|
|
9
|
+
describe('validateJson', () => {
|
|
10
|
+
const idDescription = mockIdDescription();
|
|
11
|
+
|
|
12
|
+
it('permits valid input', () => {
|
|
13
|
+
const input = JSON.stringify(idDescription);
|
|
14
|
+
|
|
15
|
+
expect(validateJson(input, IdDescriptionSchema)).toStrictEqual(
|
|
16
|
+
idDescription,
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('filters additional properties', () => {
|
|
21
|
+
const input = JSON.stringify({ ...idDescription, hacker: chance.name() });
|
|
22
|
+
|
|
23
|
+
expect(validateJson(input, IdDescriptionSchema)).toStrictEqual(
|
|
24
|
+
idDescription,
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('blocks mistyped prop', () => {
|
|
29
|
+
const input = JSON.stringify({ ...idDescription, id: null });
|
|
30
|
+
|
|
31
|
+
expect(() => validateJson(input, IdDescriptionSchema))
|
|
32
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
33
|
+
"[
|
|
34
|
+
{
|
|
35
|
+
"code": "invalid_type",
|
|
36
|
+
"expected": "string",
|
|
37
|
+
"received": "null",
|
|
38
|
+
"path": [
|
|
39
|
+
"id"
|
|
40
|
+
],
|
|
41
|
+
"message": "Expected string, received null"
|
|
42
|
+
}
|
|
43
|
+
]"
|
|
44
|
+
`);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('blocks missing prop', () => {
|
|
48
|
+
const input = '{}';
|
|
49
|
+
|
|
50
|
+
expect(() => validateJson(input, IdDescriptionSchema))
|
|
51
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
52
|
+
"[
|
|
53
|
+
{
|
|
54
|
+
"code": "invalid_type",
|
|
55
|
+
"expected": "string",
|
|
56
|
+
"received": "undefined",
|
|
57
|
+
"path": [
|
|
58
|
+
"id"
|
|
59
|
+
],
|
|
60
|
+
"message": "Required"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"code": "invalid_type",
|
|
64
|
+
"expected": "string",
|
|
65
|
+
"received": "undefined",
|
|
66
|
+
"path": [
|
|
67
|
+
"description"
|
|
68
|
+
],
|
|
69
|
+
"message": "Required"
|
|
70
|
+
}
|
|
71
|
+
]"
|
|
72
|
+
`);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('blocks invalid JSON', () => {
|
|
76
|
+
const input = '}';
|
|
77
|
+
|
|
78
|
+
expect(() =>
|
|
79
|
+
validateJson(input, IdDescriptionSchema),
|
|
80
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
81
|
+
`"Unexpected token } in JSON at position 0"`,
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
});
|