├── docs ├── .direnv ├── static │ ├── diagrams │ │ ├── .direnv │ │ ├── overview.png │ │ ├── pipeline.png │ │ ├── web_client.png │ │ ├── macie_workflow.png │ │ ├── overview_client.png │ │ ├── overview_readable.png │ │ ├── client_interaction.png │ │ ├── overview_translation.png │ │ ├── stepfunction_errors.png │ │ ├── translate_workflow.png │ │ ├── stepfunction_main_overview.png │ │ ├── stepfunction_translate_overview.png │ │ ├── stepfunction_translation_overview.png │ │ ├── attr.py │ │ ├── README.md │ │ ├── flake.nix │ │ ├── stepfunction_errors.py │ │ ├── flake.lock │ │ ├── stepfunction_main_overview.py │ │ ├── stepfunction_translation_overview.py │ │ ├── macie_workflow.py │ │ ├── translate_workflow.py │ │ ├── stepfunction_translate_overview.py │ │ ├── pipeline.py │ │ ├── web_client.py │ │ └── client_interaction.py │ └── img │ │ ├── client_login_both.png │ │ ├── client_multi_lang.png │ │ ├── cloud_shell_icon.png │ │ ├── feature_readable.png │ │ ├── console_cloudshell.png │ │ ├── feature_translation.png │ │ ├── client_readable_create.png │ │ ├── client_readable_history.png │ │ ├── client_translation_create.png │ │ ├── console_cloudshell_macie.png │ │ └── client_translation_history.png ├── .gitignore ├── layouts │ └── shortcodes │ │ └── info.html ├── archetypes │ └── default.md ├── go.mod ├── go.sum ├── content │ └── docs │ │ ├── readable │ │ ├── post-install │ │ │ └── _index.md │ │ ├── configuration │ │ │ ├── _index.md │ │ │ └── options.md │ │ ├── prerequisites │ │ │ ├── _index.md │ │ │ └── model-access.md │ │ ├── architecture │ │ │ ├── services.md │ │ │ ├── _index.md │ │ │ └── bedrock.md │ │ └── _index.md │ │ ├── _separator-101-reference.md │ │ ├── _separator-200-features.md │ │ ├── _separator-001-getting-started.md │ │ ├── shared │ │ ├── configuration │ │ │ └── _index.md │ │ ├── post-install │ │ │ ├── _index.md │ │ │ ├── web-ui.md │ │ │ ├── domain.md │ │ │ ├── cognito-first-user.md │ │ │ └── saml-provider.md │ │ ├── architecture │ │ │ ├── services.md │ │ │ ├── help-info.md │ │ │ ├── _index.md │ │ │ ├── api-auth.md │ │ │ └── web-ui.md │ │ ├── _index.md │ │ └── prerequisites │ │ │ ├── _index.md │ │ │ ├── account.md │ │ │ ├── cloudshell.md │ │ │ ├── saml-provider.md │ │ │ ├── github-token.md │ │ │ └── domain.md │ │ ├── translation │ │ ├── configuration │ │ │ ├── _index.md │ │ │ ├── customisation.md │ │ │ └── options.md │ │ ├── architecture │ │ │ ├── step-functions │ │ │ │ ├── callback.md │ │ │ │ ├── translate.md │ │ │ │ ├── errors.md │ │ │ │ ├── pii.md │ │ │ │ ├── main.md │ │ │ │ └── _index.md │ │ │ ├── _index.md │ │ │ ├── services.md │ │ │ ├── scaling.md │ │ │ ├── job-info.md │ │ │ └── content-upload-download.md │ │ ├── prerequisites │ │ │ ├── _index.md │ │ │ ├── ai-services.md │ │ │ └── macie.md │ │ └── _index.md │ │ ├── _index.md │ │ ├── faq.md │ │ ├── prerequisites.md │ │ └── installation.md ├── flake.nix ├── README.md ├── flake.lock └── hugo.yaml ├── website ├── .direnv ├── public │ ├── robots.txt │ ├── image-placeholder.png │ ├── manifest.json │ ├── FcDocument.svg │ └── index.html ├── eslint.config.js ├── src │ ├── util │ │ ├── returnArrayOfType.tsx │ │ ├── getPageJobId.tsx │ │ ├── getPrintStyle.tsx │ │ ├── formatJobNameId.tsx │ │ ├── signOut.tsx │ │ ├── orderArrayByKey.tsx │ │ ├── configureS3Bucket.tsx │ │ ├── formatJobNameId.test.tsx │ │ ├── orderArrayByKey.test.tsx │ │ ├── i18n.tsx │ │ ├── returnArrayOfType.test.tsx │ │ ├── getPresignedUrl.tsx │ │ ├── putObjectS3.tsx │ │ ├── sortDataByKey.tsx │ │ ├── sortDataByKey.test.tsx │ │ ├── readableCreateJob.tsx │ │ ├── getPageJobId.test.tsx │ │ ├── getPrintStyle.test.tsx │ │ ├── aws-exports.tsx │ │ ├── amplifyConfigure.tsx │ │ └── formatTimestamp.tsx │ ├── enums.tsx │ ├── page │ │ ├── readable │ │ │ ├── util │ │ │ │ ├── groupItemsByParent.tsx │ │ │ │ ├── groupItemsByParent.test.tsx │ │ │ │ └── describeS3Key.tsx │ │ │ ├── enums.tsx │ │ │ ├── hooks │ │ │ │ ├── useReadableJobs.tsx │ │ │ │ └── useGetPresignedUrl.tsx │ │ │ ├── history.tsx │ │ │ ├── viewPreview.tsx │ │ │ ├── viewPrintButton.tsx │ │ │ └── print │ │ │ │ ├── tableWithImageLeft.tsx │ │ │ │ └── tableWithImageRight.tsx │ │ ├── help │ │ │ └── help.tsx │ │ └── translation │ │ │ ├── util │ │ │ ├── getBrowserLanguage.tsx │ │ │ ├── isDirectTranslationEligible.tsx │ │ │ ├── downloadFile.tsx │ │ │ ├── describeS3Key.tsx │ │ │ └── translateDocument.tsx │ │ │ ├── new.tsx │ │ │ ├── quick.tsx │ │ │ ├── hooks │ │ │ └── useTranslationJobs.tsx │ │ │ ├── history.tsx │ │ │ ├── newFormSavingJob.tsx │ │ │ └── newFormOriginalLanguage.tsx │ ├── graphql │ │ └── .graphqlconfig.yml │ ├── index.tsx │ ├── sampleData │ │ └── sampleFooterLinks.json │ ├── App.tsx │ ├── hooks │ │ └── useFederatedSignIn.tsx │ └── appRoutes.tsx ├── flake.nix ├── flake.lock ├── .prettierrc.json5 ├── README.md └── package.json ├── infrastructure ├── .direnv ├── .prettierrc.json ├── lambda │ ├── utilSplit │ │ ├── package.json │ │ ├── package-lock.json │ │ └── index.ts │ ├── utilTrim │ │ ├── package.json │ │ ├── package-lock.json │ │ └── index.ts │ ├── decodeS3Key │ │ ├── package.json │ │ ├── package-lock.json │ │ └── index.ts │ ├── parseTerminologies │ │ ├── package.json │ │ ├── package-lock.json │ │ └── index.ts │ ├── utilRegexReplace │ │ ├── package.json │ │ ├── package-lock.json │ │ └── index.ts │ ├── passLogToEventBridge │ │ ├── package.json │ │ ├── package-lock.json │ │ └── index.ts │ ├── docToHtml │ │ ├── package.json │ │ └── index.ts │ ├── htmlToMd │ │ ├── package.json │ │ ├── index.ts │ │ └── package-lock.json │ ├── unmarshallDdb │ │ ├── package.json │ │ └── index.ts │ ├── invokeBedrock │ │ ├── package.json │ │ └── index.ts │ ├── invokeBedrockSaveToS3 │ │ └── package.json │ └── appsyncMutationRequest │ │ └── package.json ├── cdk.context.json ├── lib │ ├── features │ │ ├── translation │ │ │ └── enum.ts │ │ └── readable │ │ │ ├── defaults │ │ │ ├── printStyle1.ddb.json │ │ │ ├── text.amazon-nova-v1-pro.ddb.json │ │ │ ├── text.amazon-nova-v2-lite.ddb.json │ │ │ ├── text.mistral-mistral-7b-instruct.ddb.json │ │ │ ├── text.anthropic-claude-4-5-haiku.ddb.json │ │ │ ├── image.stabilityai-stablediffusion-3.ddb.json │ │ │ └── image.stabilityai-stablediffusion.ddb.json │ │ │ └── enum.ts │ ├── types.ts │ └── pipeline-app-stage.ts ├── .npmignore ├── .prettierignore ├── flake.nix ├── test │ ├── decodeS3Key.test.ts │ ├── unmarshallDdb.test.ts │ └── utilTrim.test.ts ├── .eslintrc.cjs ├── flake.lock ├── tsconfig.json ├── cdk.json ├── jest.config.ts ├── bin │ └── doctran.ts ├── package.json └── util │ └── loadConfig.ts ├── util ├── getOptions │ ├── .direnv │ ├── package.json │ ├── flake.nix │ ├── README.md │ └── flake.lock └── installer │ ├── .direnv │ ├── src │ ├── util │ │ ├── textStyles.ts │ │ ├── parameterStore.ts │ │ └── getAccountDetails.ts │ ├── awsconfig.ts │ ├── prerequisites.ts │ ├── configuration │ │ ├── common.misc.ts │ │ ├── app.cognito.saml.ts │ │ ├── app.cognito.ts │ │ ├── pipeline.approvals.ts │ │ ├── app.translation.ts │ │ ├── app.webUi.ts │ │ ├── common.development.ts │ │ └── app.cognito.local.ts │ ├── main.ts │ ├── deploy │ │ └── deploy.ts │ └── parameters.ts │ ├── flake.nix │ ├── flake.lock │ ├── install.sh │ ├── package.json │ └── README.md ├── .vscode ├── extensions.json ├── settings.json └── launch.json ├── .njsscan ├── CODE_OF_CONDUCT.md ├── .editorconfig ├── CHANGELOG.md ├── .gitignore ├── LICENSE ├── .github └── workflows │ └── release.yml └── README.md /docs/.direnv: -------------------------------------------------------------------------------- 1 | use flake -------------------------------------------------------------------------------- /website/.direnv: -------------------------------------------------------------------------------- 1 | use flake -------------------------------------------------------------------------------- /infrastructure/.direnv: -------------------------------------------------------------------------------- 1 | use flake -------------------------------------------------------------------------------- /util/getOptions/.direnv: -------------------------------------------------------------------------------- 1 | use flake -------------------------------------------------------------------------------- /util/installer/.direnv: -------------------------------------------------------------------------------- 1 | use flake -------------------------------------------------------------------------------- /docs/static/diagrams/.direnv: -------------------------------------------------------------------------------- 1 | use flake -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | .sass-cache 3 | .jekyll-metadata 4 | -------------------------------------------------------------------------------- /infrastructure/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": true 3 | } 4 | -------------------------------------------------------------------------------- /infrastructure/lambda/utilSplit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /infrastructure/lambda/utilTrim/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /infrastructure/lambda/decodeS3Key/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /infrastructure/lambda/parseTerminologies/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /infrastructure/lambda/utilRegexReplace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /infrastructure/lambda/passLogToEventBridge/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /util/installer/src/util/textStyles.ts: -------------------------------------------------------------------------------- 1 | export const BOLD = '\x1b[1m'; 2 | export const RESET = '\x1b[0m'; -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "esbenp.prettier-vscode" 4 | ] 5 | } -------------------------------------------------------------------------------- /website/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /docs/layouts/shortcodes/info.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/static/diagrams/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/overview.png -------------------------------------------------------------------------------- /docs/static/diagrams/pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/pipeline.png -------------------------------------------------------------------------------- /docs/static/diagrams/web_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/web_client.png -------------------------------------------------------------------------------- /infrastructure/lambda/docToHtml/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "mammoth": "^1.11.0" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /infrastructure/lambda/htmlToMd/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "turndown": "^7.2.0" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /docs/static/img/client_login_both.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/client_login_both.png -------------------------------------------------------------------------------- /docs/static/img/client_multi_lang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/client_multi_lang.png -------------------------------------------------------------------------------- /docs/static/img/cloud_shell_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/cloud_shell_icon.png -------------------------------------------------------------------------------- /docs/static/img/feature_readable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/feature_readable.png -------------------------------------------------------------------------------- /website/public/image-placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/website/public/image-placeholder.png -------------------------------------------------------------------------------- /docs/archetypes/default.md: -------------------------------------------------------------------------------- 1 | +++ 2 | title = '{{ replace .File.ContentBaseName "-" " " | title }}' 3 | date = {{ .Date }} 4 | draft = true 5 | +++ 6 | -------------------------------------------------------------------------------- /docs/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/aws-samples/document-translation 2 | 3 | go 1.21 4 | 5 | require github.com/imfing/hextra v0.8.4 // indirect 6 | -------------------------------------------------------------------------------- /docs/static/diagrams/macie_workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/macie_workflow.png -------------------------------------------------------------------------------- /docs/static/diagrams/overview_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/overview_client.png -------------------------------------------------------------------------------- /docs/static/img/console_cloudshell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/console_cloudshell.png -------------------------------------------------------------------------------- /docs/static/img/feature_translation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/feature_translation.png -------------------------------------------------------------------------------- /infrastructure/cdk.context.json: -------------------------------------------------------------------------------- 1 | { 2 | "acknowledged-issue-numbers": [ 3 | 21902, 4 | 32775, 5 | 34293, 6 | 34892 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /docs/static/diagrams/overview_readable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/overview_readable.png -------------------------------------------------------------------------------- /docs/static/img/client_readable_create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/client_readable_create.png -------------------------------------------------------------------------------- /docs/static/diagrams/client_interaction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/client_interaction.png -------------------------------------------------------------------------------- /docs/static/diagrams/overview_translation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/overview_translation.png -------------------------------------------------------------------------------- /docs/static/diagrams/stepfunction_errors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/stepfunction_errors.png -------------------------------------------------------------------------------- /docs/static/diagrams/translate_workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/translate_workflow.png -------------------------------------------------------------------------------- /docs/static/img/client_readable_history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/client_readable_history.png -------------------------------------------------------------------------------- /docs/static/img/client_translation_create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/client_translation_create.png -------------------------------------------------------------------------------- /docs/static/img/console_cloudshell_macie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/console_cloudshell_macie.png -------------------------------------------------------------------------------- /infrastructure/lambda/unmarshallDdb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "@aws-sdk/util-dynamodb": "^3.437.0" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /infrastructure/lambda/utilSplit/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "utilSplit", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /infrastructure/lambda/utilTrim/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "utilTrim", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /docs/static/img/client_translation_history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/img/client_translation_history.png -------------------------------------------------------------------------------- /infrastructure/lambda/decodeS3Key/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "decodeS3Key", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /docs/static/diagrams/stepfunction_main_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/stepfunction_main_overview.png -------------------------------------------------------------------------------- /infrastructure/lambda/utilRegexReplace/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "utilRegexReplace", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /infrastructure/lambda/parseTerminologies/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parseTerminologies", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /.njsscan: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | --- 5 | - ignore-rules: 6 | - generic_error_disclosure -------------------------------------------------------------------------------- /docs/static/diagrams/stepfunction_translate_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/stepfunction_translate_overview.png -------------------------------------------------------------------------------- /docs/go.sum: -------------------------------------------------------------------------------- 1 | github.com/imfing/hextra v0.8.4 h1:cR4asr0TeDlqHPHLdTpMQJOjVeXnq8nfLMzcF0pld+w= 2 | github.com/imfing/hextra v0.8.4/go.mod h1:cEfel3lU/bSx7lTE/+uuR4GJaphyOyiwNR3PTqFTXpI= 3 | -------------------------------------------------------------------------------- /docs/static/diagrams/stepfunction_translation_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/document-translation/HEAD/docs/static/diagrams/stepfunction_translation_overview.png -------------------------------------------------------------------------------- /infrastructure/lambda/passLogToEventBridge/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "passMacieLogToEventBridge", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": {} 6 | } 7 | -------------------------------------------------------------------------------- /infrastructure/lambda/invokeBedrock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "@aws-sdk/client-bedrock-runtime": "^3.654.0", 5 | "@aws-sdk/util-dynamodb": "^3.437.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /website/eslint.config.js: -------------------------------------------------------------------------------- 1 | import eslintConfigPrettier from "eslint-config-prettier"; 2 | 3 | export default [ 4 | { 5 | extends: ["react-app", "react-app/jest"], 6 | }, 7 | eslintConfigPrettier, 8 | ]; 9 | -------------------------------------------------------------------------------- /docs/static/diagrams/attr.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | graph = { 5 | # "fontsize": "45", 6 | # "bgcolor": "transparent" 7 | } -------------------------------------------------------------------------------- /infrastructure/lib/features/translation/enum.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | export enum Feature { 5 | PREFIX = "translation", 6 | } 7 | -------------------------------------------------------------------------------- /infrastructure/.npmignore: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | *.ts 5 | !*.d.ts 6 | 7 | # CDK asset staging directory 8 | .cdk.staging 9 | cdk.out 10 | -------------------------------------------------------------------------------- /infrastructure/lambda/invokeBedrockSaveToS3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "@aws-sdk/client-bedrock-runtime": "^3.654.0", 5 | "@aws-sdk/client-s3": "^3.654.0", 6 | "@aws-sdk/util-dynamodb": "^3.437.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /infrastructure/.prettierignore: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | # NODE 5 | node_modules/ 6 | 7 | # CDK 8 | cdk.out/ 9 | .cdk.staging 10 | *.js 11 | *.d.ts 12 | 13 | # JEST 14 | coverage/ -------------------------------------------------------------------------------- /docs/content/docs/readable/post-install/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post Install 3 | weight: 4 4 | --- 5 | 6 | Congratulations on deploying this project. There are a few final pieces to cover. 7 | 8 | {{< cards >}} 9 | {{< card link="models" title="Models Creation" >}} 10 | {{< /cards >}} -------------------------------------------------------------------------------- /infrastructure/lambda/utilSplit/index.ts: -------------------------------------------------------------------------------- 1 | interface Event { 2 | string: string; 3 | splitter: string; 4 | } 5 | 6 | export const handler = async (event: Event): Promise => { 7 | const { string, splitter } = event; 8 | const split = string.split(splitter); 9 | return split; 10 | }; 11 | -------------------------------------------------------------------------------- /infrastructure/lambda/utilTrim/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | interface event { 5 | string: string; 6 | } 7 | 8 | export const handler = async (event: event) => { 9 | return event.string.trim(); 10 | }; 11 | -------------------------------------------------------------------------------- /website/src/util/returnArrayOfType.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | export function returnArrayOfType(allObjects: any[], typeToReturn: string) { 5 | return allObjects.filter((object) => object.type === typeToReturn); 6 | } 7 | -------------------------------------------------------------------------------- /docs/content/docs/_separator-101-reference.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Reference 3 | weight: 101 4 | sidebar: 5 | separator: true 6 | _build: 7 | render: never 8 | excludeSearch: true 9 | --- 10 | 11 | -------------------------------------------------------------------------------- /docs/content/docs/_separator-200-features.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Features 3 | weight: 201 4 | sidebar: 5 | separator: true 6 | _build: 7 | render: never 8 | excludeSearch: true 9 | --- 10 | 11 | -------------------------------------------------------------------------------- /docs/static/diagrams/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## Overview 4 | 5 | This folder holds all the source files related to the documentation site diagrams/architectures. They are created in Python and generated with [Diagrams](https://diagrams.mingrammer.com/). 6 | 7 | ## Commands 8 | 9 | - Create diagram: `python web_client.py` -------------------------------------------------------------------------------- /docs/content/docs/readable/configuration/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Configuration 3 | weight: 3 4 | --- 5 | 6 | 10 | 11 | {{< cards >}} 12 | {{< card link="options" title="Options" >}} 13 | {{< /cards >}} -------------------------------------------------------------------------------- /docs/content/docs/_separator-001-getting-started.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Getting Started 3 | weight: 001 4 | sidebar: 5 | separator: true 6 | _build: 7 | render: never 8 | excludeSearch: true 9 | --- 10 | 11 | -------------------------------------------------------------------------------- /docs/content/docs/shared/configuration/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Configuration 3 | weight: 3 4 | --- 5 | 6 | 10 | 11 | {{< cards >}} 12 | {{< card link="options" title="Options" >}} 13 | {{< /cards >}} 14 | -------------------------------------------------------------------------------- /website/src/util/getPageJobId.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | export function getPageJobId() { 5 | const queryParameters = new URLSearchParams(window.location.search); 6 | const jobId = queryParameters.get("jobId"); 7 | return jobId; 8 | } 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /infrastructure/lambda/appsyncMutationRequest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "@aws-crypto/sha256-js": "5.1.0" 5 | }, 6 | "devDependencies": { 7 | "@aws-sdk/credential-provider-node": "^3.421.0", 8 | "@aws-sdk/protocol-http": "^3.374.0", 9 | "@aws-sdk/signature-v4": "^3.374.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /infrastructure/lambda/unmarshallDdb/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | import { unmarshall } from "@aws-sdk/util-dynamodb"; 5 | 6 | export const handler = async (event: any) => { 7 | const result = unmarshall(event); 8 | return result; 9 | }; 10 | -------------------------------------------------------------------------------- /website/src/util/getPrintStyle.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | export function getPrintStyle() { 5 | const queryParameters = new URLSearchParams(window.location.search); 6 | const printStyle = queryParameters.get("printStyle"); 7 | return printStyle; 8 | } 9 | -------------------------------------------------------------------------------- /infrastructure/lambda/decodeS3Key/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | export const handler = (event, context, callback) => { 5 | const decoded = decodeURIComponent(event.payload); 6 | const result = decoded.replace(/\+/g, " "); 7 | callback(null, result); 8 | }; 9 | -------------------------------------------------------------------------------- /util/getOptions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "getoptions", 3 | "main": "./src/index.ts", 4 | "dependencies": { 5 | "@aws-sdk/client-ssm": "^3.637.0", 6 | "fs": "^0.0.1-security", 7 | "ts-node": "^10.9.2" 8 | }, 9 | "devDependencies": { 10 | "@types/node": "^22.5.2" 11 | }, 12 | "scripts": { 13 | "start": "ts-node ./src/index.ts" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /docs/content/docs/readable/prerequisites/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Prerequisite 3 | weight: 2 4 | excludeSearch: true 5 | --- 6 | 7 | 11 | 12 | {{< cards >}} 13 | {{< card link="model-access" title="Model Access" >}} 14 | {{< /cards >}} 15 | -------------------------------------------------------------------------------- /docs/content/docs/translation/configuration/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Configuration 3 | weight: 3 4 | --- 5 | 6 | 10 | 11 | {{< cards >}} 12 | {{< card link="options" title="Options" >}} 13 | {{< card link="customisation" title="Customisation" >}} 14 | {{< /cards >}} -------------------------------------------------------------------------------- /website/src/util/formatJobNameId.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import React from "react"; 4 | 5 | export function formatJobNameId(name: string, id: string) { 6 | return ( 7 | 8 | {name} 9 |
10 | {id} 11 |
12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /website/src/util/signOut.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import React from "react"; 4 | 5 | import { signOut } from "@aws-amplify/auth"; 6 | 7 | export default function SignOut() { 8 | const handleSignOut = async () => { 9 | await signOut(); 10 | }; 11 | handleSignOut(); 12 | 13 | return <>; 14 | } 15 | -------------------------------------------------------------------------------- /infrastructure/lambda/htmlToMd/index.ts: -------------------------------------------------------------------------------- 1 | import TurndownService from "turndown"; 2 | 3 | export const handler = async (event: { html: string }): Promise => { 4 | const turndownService = new TurndownService({ 5 | headingStyle: "atx", 6 | codeBlockStyle: "fenced", 7 | bulletListMarker: "-", 8 | }); 9 | const markdown = turndownService.turndown(event.html); 10 | return markdown; 11 | }; 12 | -------------------------------------------------------------------------------- /website/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "DocumentTranslation", 3 | "name": "Translate documents into other languages", 4 | "icons": [ 5 | { 6 | "src": "/FcDocument.svg", 7 | "type": "image/svg+xml", 8 | "sizes": "any", 9 | "purpose": "any" 10 | } 11 | ], 12 | "start_url": ".", 13 | "display": "standalone", 14 | "theme_color": "#000000", 15 | "background_color": "#ffffff" 16 | } 17 | -------------------------------------------------------------------------------- /website/src/util/orderArrayByKey.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | export function orderArrayByKey(array: Record[], key: string) { 5 | return array.sort((a, b) => { 6 | if (a[key] < b[key]) { 7 | return -1; 8 | } 9 | if (a[key] > b[key]) { 10 | return 1; 11 | } 12 | return 0; 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /docs/content/docs/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Documentation 3 | cascade: 4 | type: docs 5 | --- 6 | 7 | {{< cards >}} 8 | {{< card link="installation" title="Installation" icon="cloud-upload" >}} 9 | {{< card link="https://github.com/aws-samples/document-translation" title="View it on GitHub" icon="external-link" >}} 10 | {{< card link="architecture" title="Architecture" icon="chip" >}} 11 | {{< /cards >}} 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | # EditorConfig is awesome: https://EditorConfig.org 5 | 6 | # top-most EditorConfig file 7 | root = true 8 | 9 | # Unix-style newlines with a newline ending every file 10 | [*] 11 | end_of_line = lf 12 | insert_final_newline = true 13 | 14 | # tab indentation 15 | [*] 16 | indent_style = tab -------------------------------------------------------------------------------- /docs/content/docs/translation/architecture/step-functions/callback.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Callback 3 | weight: 4 4 | --- 5 | 6 | 10 | 11 | The Callback StepFuction is triggered by completion of the Translate job. This StepFunction instructs the paused Translation StepFunction to continue for a particular job ID. -------------------------------------------------------------------------------- /docs/content/docs/shared/post-install/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post Install 3 | weight: 4 4 | --- 5 | 6 | Congratulations on deploying this project. There are a few final pieces to cover. 7 | 8 | {{< cards >}} 9 | {{< card link="cognito-first-user" title="Cognito First User" >}} 10 | {{< card link="saml-provider" title="SAML Provider Update" >}} 11 | {{< card link="web-ui" title="Web UI" >}} 12 | {{< /cards >}} 13 | -------------------------------------------------------------------------------- /website/src/enums.tsx: -------------------------------------------------------------------------------- 1 | export const S3KeyTypes: Record = { 2 | OBJECT: "OBJECT", 3 | USER_OBJECT: "USER_OBJECT", 4 | SCOPE_USER_OBJECT: "SCOPE_USER_OBJECT", 5 | }; 6 | 7 | export const S3Scopes: Record = { 8 | PRIVATE: "private", 9 | }; 10 | 11 | export const VisualModes = { 12 | AUTO: "auto", 13 | LIGHT: "light", 14 | DARK: "dark", 15 | }; 16 | export type VisualMode = (typeof VisualModes)[keyof typeof VisualModes]; 17 | -------------------------------------------------------------------------------- /docs/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Docs Development"; 3 | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small"; 5 | 6 | outputs = { 7 | self, 8 | nixpkgs, 9 | }: let 10 | pkgs = import nixpkgs { system ="x86_64-linux"; }; 11 | in { 12 | devShells.x86_64-linux.default = pkgs.mkShell { 13 | packages = with pkgs; [ 14 | hugo 15 | go 16 | # Optional 17 | bat 18 | ]; 19 | shellHook = ''bat ./README.md''; 20 | }; 21 | }; 22 | } -------------------------------------------------------------------------------- /docs/content/docs/translation/architecture/step-functions/translate.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Translate 3 | weight: 2 4 | --- 5 | 6 | 10 | 11 | The Translate StepFuction is triggered by the Main StepFunction. This StepFunction performs translations on uploaded documents. 12 | 13 | ![Translate StepFunction Overview](/diagrams/stepfunction_translate_overview.png) -------------------------------------------------------------------------------- /infrastructure/lambda/parseTerminologies/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | export const handler = (event, context, callback) => { 5 | console.log("EVENT:", event); 6 | const resultList: string[] = []; 7 | for (const terminology of event.terminologies) { 8 | resultList.push(terminology.Name); 9 | } 10 | console.log("RESULT:", resultList); 11 | callback(null, resultList); 12 | }; 13 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[javascript]": { 3 | "editor.defaultFormatter": "esbenp.prettier-vscode" 4 | }, 5 | "[javascriptreact]": { 6 | "editor.defaultFormatter": "esbenp.prettier-vscode" 7 | }, 8 | "[json]": { 9 | "editor.defaultFormatter": "esbenp.prettier-vscode" 10 | }, 11 | "[typescript]": { 12 | "editor.defaultFormatter": "esbenp.prettier-vscode" 13 | }, 14 | "[typescriptreact]": { 15 | "editor.defaultFormatter": "esbenp.prettier-vscode" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /docs/content/docs/shared/architecture/services.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Services 3 | weight: 1 4 | --- 5 | 6 | 10 | 11 | - [AWS AppSync](https://aws.amazon.com/appsync/) 12 | - [AWS CloudFront](https://aws.amazon.com/cloudfront/) 13 | - [AWS Cognito](https://aws.amazon.com/cognito/) 14 | - [AWS S3](https://aws.amazon.com/s3/) 15 | - [AWS Web Application Firewall](https://aws.amazon.com/waf/) -------------------------------------------------------------------------------- /util/installer/src/awsconfig.ts: -------------------------------------------------------------------------------- 1 | import { getAccountId, getRegionId } from "./util/getAccountDetails"; 2 | 3 | export interface AwsConfig { 4 | account: string; 5 | region: string; 6 | } 7 | 8 | export const getAwsConfig = async (): Promise => { 9 | const awsConfig = { 10 | account: await getAccountId(), 11 | region: await getRegionId(), 12 | }; 13 | return awsConfig; 14 | }; 15 | 16 | const main = async () => console.log(await getAwsConfig()); 17 | if (require.main === module) main(); 18 | -------------------------------------------------------------------------------- /docs/content/docs/faq.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: FAQ 3 | weight: 103 4 | --- 5 | 6 | 10 | 11 | As this app includes multiple modules the FAQ is split across those respective modules. If you intend to enable a feature the FAQ for that feature will apply, if not, it can be ignored. 12 | 13 | {{< cards >}} 14 | {{< card link="../translation/faq" title="Document Translation FAQ" icon="translate" >}} 15 | {{< /cards >}} -------------------------------------------------------------------------------- /docs/static/diagrams/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Diagrams Development"; 3 | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11-small"; 5 | 6 | outputs = { 7 | self, 8 | nixpkgs, 9 | }: let 10 | pkgs = import nixpkgs { system ="x86_64-linux"; }; 11 | in { 12 | devShells.x86_64-linux.default = pkgs.mkShell { 13 | packages = with pkgs; [ 14 | python3 15 | python311Packages.diagrams 16 | # Optional 17 | bat 18 | ]; 19 | shellHook = ''bat ./README.md''; 20 | }; 21 | }; 22 | } -------------------------------------------------------------------------------- /infrastructure/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "CDK Development"; 3 | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small"; 5 | 6 | outputs = { 7 | self, 8 | nixpkgs, 9 | }: let 10 | pkgs = import nixpkgs { system ="x86_64-linux"; }; 11 | in { 12 | devShells.x86_64-linux.default = pkgs.mkShell { 13 | packages = with pkgs; [ 14 | nodejs_22 15 | awscli2 16 | # Optional 17 | bat 18 | ]; 19 | shellHook = ''bat --style=plain --paging=never ./README.md''; 20 | }; 21 | }; 22 | } -------------------------------------------------------------------------------- /docs/content/docs/translation/prerequisites/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Prerequisites 3 | weight: 2 4 | excludeSearch: true 5 | --- 6 | 7 | 11 | 12 | Before performing the installation there are important steps to review and optionally complete. 13 | 14 | {{< cards >}} 15 | {{< card link="ai-services" title="AI Services" >}} 16 | {{< card link="macie" title="Amazon Macie" >}} 17 | {{< /cards >}} 18 | -------------------------------------------------------------------------------- /docs/content/docs/shared/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Shared 3 | weight: 210 4 | excludeSearch: true 5 | --- 6 | 7 | {{< cards >}} 8 | {{< card link="architecture" title="Architecture" icon="cube-transparent" >}} 9 | {{< card link="prerequisites" title="Prerequisite" icon="clipboard-check" >}} 10 | {{< card link="configuration" title="Configuration" icon="terminal" >}} 11 | {{< card link="post-install" title="Post Install" icon="view-grid-add" >}} 12 | 13 | {{< /cards >}} -------------------------------------------------------------------------------- /docs/content/docs/shared/prerequisites/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Prerequisite 3 | weight: 2 4 | excludeSearch: true 5 | --- 6 | 7 | 11 | 12 | {{< cards >}} 13 | {{< card link="account" title="Workload Account" >}} 14 | {{< card link="cloudshell" title="CloudShell" >}} 15 | {{< card link="domain" title="Custom Domain" >}} 16 | {{< card link="saml-provider" title="SAML Provider" >}} 17 | {{< /cards >}} 18 | -------------------------------------------------------------------------------- /docs/content/docs/readable/architecture/services.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Services 3 | weight: 1 4 | --- 5 | 6 | 10 | 11 | - [Amazon Bedrock](https://aws.amazon.com/bedrock/) 12 | - [AWS AppSync](https://aws.amazon.com/appsync/) 13 | - [AWS DynamoDB](https://aws.amazon.com/dynamodb/) 14 | - [AWS Lambda](https://aws.amazon.com/lambda/) 15 | - [AWS S3](https://aws.amazon.com/s3/) 16 | - [AWS StepFunctions](https://aws.amazon.com/step-functions/) -------------------------------------------------------------------------------- /website/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "React Development"; 3 | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small"; 5 | 6 | outputs = { 7 | self, 8 | nixpkgs, 9 | }: let 10 | pkgs = import nixpkgs { system ="x86_64-linux"; }; 11 | in { 12 | devShells.x86_64-linux.default = pkgs.mkShell { 13 | packages = with pkgs; [ 14 | nodejs_22 15 | awscli2 16 | jq 17 | gnused 18 | # Optional 19 | bat 20 | ]; 21 | shellHook = ''bat --style=plain --paging=never ./README.md''; 22 | }; 23 | }; 24 | } -------------------------------------------------------------------------------- /website/src/page/readable/util/groupItemsByParent.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | interface Item { 5 | id: string; 6 | name: string; 7 | parent: string; 8 | } 9 | 10 | export function groupItemsByParent(items: Item[]) { 11 | const groupedItems: { [key: string]: Item[] } = {}; 12 | items.forEach((item) => { 13 | groupedItems[item.parent] = groupedItems[item.parent] || []; 14 | groupedItems[item.parent].push(item); 15 | }); 16 | return groupedItems; 17 | } 18 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## Overview 4 | 5 | This folder holds all the source files related to the documentation site. The site is a static website hosted by GitHub Pages. The rendering is handled by Hugo via a GitHub actions workflow. Hugo has a development server for use whilst updating documentation allowing you to preview your changes ahead of pushing them upstream. 6 | 7 | ## Update Go Modules (Theme) 8 | ```sh 9 | hugo mod get -u 10 | hugo mod tidy 11 | ``` 12 | 13 | ## Commands 14 | 15 | - Start Hugo dev server: `hugo server --disableFastRender` -------------------------------------------------------------------------------- /website/public/FcDocument.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/src/util/configureS3Bucket.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { amplifyConfigureAppend } from "./amplifyConfigure"; 4 | 5 | export async function configureS3Bucket(bucketKey: string) { 6 | const cfnOutputs = require("../cfnOutputs.json"); 7 | 8 | const storageConfig = { 9 | Storage: { 10 | S3: { 11 | bucket: cfnOutputs[bucketKey], 12 | region: cfnOutputs.awsRegion, 13 | }, 14 | }, 15 | }; 16 | amplifyConfigureAppend(storageConfig); 17 | } 18 | -------------------------------------------------------------------------------- /docs/content/docs/readable/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Simply Readable 3 | weight: 230 4 | excludeSearch: true 5 | --- 6 | 7 | {{< cards >}} 8 | {{< card link="architecture" title="Architecture" icon="cube-transparent" >}} 9 | 10 | {{< card link="configuration" title="Configuration" icon="terminal" >}} 11 | {{< card link="post-install" title="Post Install" icon="view-grid-add" >}} 12 | 13 | {{< /cards >}} -------------------------------------------------------------------------------- /docs/content/docs/translation/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Document Translation 3 | weight: 220 4 | excludeSearch: true 5 | --- 6 | 7 | {{< cards >}} 8 | {{< card link="architecture" title="Architecture" icon="cube-transparent" >}} 9 | {{< card link="prerequisites" title="Prerequisite" icon="clipboard-check" >}} 10 | {{< card link="configuration" title="Configuration" icon="terminal" >}} 11 | 12 | {{< card link="faq" title="FAQ" icon="information-circle" >}} 13 | {{< /cards >}} -------------------------------------------------------------------------------- /website/src/util/formatJobNameId.test.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import { formatJobNameId } from "./formatJobNameId"; 4 | 5 | describe("formatJobNameId", () => { 6 | test("formats job name and ID correctly", () => { 7 | const jobName = "Job Name"; 8 | const jobId = "job-id"; 9 | 10 | const formattedJobNameId = formatJobNameId(jobName, jobId); 11 | 12 | expect(formattedJobNameId).toEqual( 13 | 14 | Job Name 15 |
16 | job-id 17 |
18 | ); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "chrome", 9 | "request": "launch", 10 | "name": "Launch Chrome against localhost", 11 | "url": "http://localhost:3000", 12 | "webRoot": "${workspaceFolder}/website/src" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /docs/static/diagrams/stepfunction_errors.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | import os 5 | from diagrams import Diagram 6 | from diagrams.aws.integration import SF, Eventbridge 7 | 8 | import attr 9 | 10 | name = os.path.splitext(os.path.basename(__file__))[0] 11 | name_human = name.replace("_", " ").capitalize() 12 | 13 | with Diagram(name_human, filename=name, show=False, graph_attr=attr.graph): 14 | SF("Non successful state") >> Eventbridge("Failure Event") >> SF("Mark as not Success") -------------------------------------------------------------------------------- /website/src/util/orderArrayByKey.test.tsx: -------------------------------------------------------------------------------- 1 | import { orderArrayByKey } from "./orderArrayByKey"; 2 | 3 | describe("orderArrayByKey", () => { 4 | test("orders array correctly based on the specified key", () => { 5 | const data = [ 6 | { id: 3, name: "Item 3" }, 7 | { id: 1, name: "Item 1" }, 8 | { id: 2, name: "Item 2" }, 9 | ]; 10 | 11 | const orderedData = orderArrayByKey(data, "id"); 12 | 13 | expect(orderedData).toEqual([ 14 | { id: 1, name: "Item 1" }, 15 | { id: 2, name: "Item 2" }, 16 | { id: 3, name: "Item 3" }, 17 | ]); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /docs/content/docs/prerequisites.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Prerequisites 3 | weight: 002 4 | --- 5 | 6 | 10 | 11 | As this app includes multiple modules the prerequisites is split across those respective modules. If you intend to enable a feature the prerequisites for that feature will apply, if not, it can be ignored. 12 | 13 | {{< cards >}} 14 | {{< card link="../translation/prerequisites" title="Document Translation Prerequisites" icon="translate" >}} 15 | {{< /cards >}} -------------------------------------------------------------------------------- /infrastructure/test/decodeS3Key.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | import LambdaTester from "lambda-tester"; 5 | import { handler as myHandler } from "../lambda/decodeS3Key/index"; 6 | 7 | describe("handler", function () { 8 | it("test success", async function () { 9 | await LambdaTester(myHandler) 10 | .event({ payload: "foo+bar_lemon-%28pie%29+%26+cake" }) 11 | .expectResult((result) => { 12 | expect(result).toEqual("foo bar_lemon-(pie) & cake"); 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /website/src/graphql/.graphqlconfig.yml: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | projects: 5 | Codegen Project: 6 | schemaPath: schema.graphql 7 | includes: 8 | - ./**/*.ts 9 | excludes: 10 | - ./amplify/** 11 | extensions: 12 | amplify: 13 | codeGenTarget: typescript 14 | generatedFileName: "" 15 | apiId: null 16 | frontend: javascript 17 | framework: react 18 | maxDepth: 2 19 | extensions: 20 | amplify: 21 | version: 3 22 | -------------------------------------------------------------------------------- /docs/content/docs/shared/post-install/web-ui.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Access Web UI 3 | weight: 3 4 | --- 5 | 6 | 10 | 11 | {{< callout type="error" >}} 12 | This step is **required**. 13 | {{< /callout >}} 14 | 15 | - Navigate to the [CloudFormation Console](https://console.aws.amazon.com/cloudformation/home) 16 | - Select the app stack (E.g. `DocTran-main-app`) 17 | - Select the "Outputs" tab 18 | - Navigate to the URL outputted by the for value `appHostedUrl`. -------------------------------------------------------------------------------- /docs/content/docs/translation/architecture/step-functions/errors.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Errors 3 | weight: 5 4 | --- 5 | 6 | 10 | 11 | If there is a failure of StepFunctions for a particular job then the Errors StepFunction will execute. This is triggered by an EventBridge notification using the default AWS bus. The responsibility of the StepFunction is to present non successful states back to the user. 12 | 13 | ![Macie Workflow](/diagrams/stepfunction_errors.png) -------------------------------------------------------------------------------- /util/installer/src/prerequisites.ts: -------------------------------------------------------------------------------- 1 | import { Config } from "../../../infrastructure/lib/types"; 2 | import fs from "fs/promises"; 3 | 4 | import { prereqTranslation } from "./deploy/prereq.translationPii"; 5 | 6 | export const prerequisites = async (config: Config) => { 7 | if (config.app.translation.pii.enable) { 8 | await prereqTranslation(); 9 | } 10 | }; 11 | 12 | const main = async () => { 13 | const config: Config = JSON.parse(await fs.readFile("config.json", "utf8")); 14 | await prerequisites(config); 15 | console.log("Completed"); 16 | }; 17 | if (require.main === module) main(); 18 | -------------------------------------------------------------------------------- /docs/content/docs/shared/architecture/help-info.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Help Info 3 | --- 4 | 5 | 9 | 10 | This is a simple feature to provide "Help Information" to your end users. The Web UI has this built in and the data can be called into other clients you wish to use. This feature is required. 11 | 12 | Help Information is data provided from an AWS DynamoDB table and presented in the Web UI. The data provided is customisable by your organisation to best suit your use case and users. 13 | -------------------------------------------------------------------------------- /infrastructure/lib/features/readable/defaults/printStyle1.ddb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": { 3 | "S": "Default-Example-Print-Style-01" 4 | }, 5 | "name": { 6 | "S": "Example Table With Large Format Text" 7 | }, 8 | "css": { 9 | "SS": [ 10 | "table { border-collapse: collapse; }", 11 | "td { border: solid 1px black; margin: 0; padding: 1rem; min-height: 1px; }", 12 | "img { max-width: 256px; max-height: 256px; width: 256px; height: 256px; }", 13 | "p { font-size: 2rem; line-height: 2rem; font-weight: bold; }" 14 | ] 15 | }, 16 | "type": { 17 | "S": "tableWithImageLeft" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /infrastructure/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | module.exports = { 5 | extends: [ 6 | "eslint:recommended", 7 | "plugin:@typescript-eslint/recommended", 8 | "plugin:@typescript-eslint/recommended-requiring-type-checking", 9 | "prettier", 10 | ], 11 | parser: "@typescript-eslint/parser", 12 | parserOptions: { 13 | tsconfigRootDir: __dirname, 14 | project: ["./tsconfig.json"], 15 | }, 16 | plugins: ["@typescript-eslint"], 17 | root: true, 18 | ignorePatterns: ["**/*.d.ts", "**/*.js"], 19 | }; 20 | -------------------------------------------------------------------------------- /website/flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1718955215, 6 | "narHash": "sha256-3vNXv4zrblZFobrxz1P3RwLpHl6X3/GzfArdTxq0+nI=", 7 | "owner": "NixOS", 8 | "repo": "nixpkgs", 9 | "rev": "201ed88e66f7f34d5c74e46d2e4399cc4bea1501", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "NixOS", 14 | "ref": "nixos-24.05-small", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /website/src/index.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import "./static/index.css"; 4 | 5 | import React from "react"; 6 | import { createRoot } from "react-dom/client"; 7 | import { BrowserRouter } from "react-router-dom"; 8 | 9 | import App from "./App"; 10 | 11 | const container = document.getElementById("root"); 12 | if (!container) throw new Error("Failed to find the root element"); 13 | const root = createRoot(container); 14 | root.render( 15 | 16 | 17 | 18 | 19 | 20 | ); 21 | -------------------------------------------------------------------------------- /website/src/util/i18n.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { initReactI18next } from "react-i18next"; 4 | 5 | import i18n from "i18next"; 6 | import LanguageDetector from "i18next-browser-languagedetector"; 7 | import Backend from "i18next-xhr-backend"; 8 | 9 | const fallbackLanguage = ["en"]; 10 | 11 | i18n 12 | .use(Backend) 13 | .use(LanguageDetector) 14 | .use(initReactI18next) 15 | .init({ 16 | fallbackLng: fallbackLanguage, 17 | debug: false, 18 | interpolation: { 19 | escapeValue: false, 20 | }, 21 | }); 22 | 23 | export default i18n; 24 | -------------------------------------------------------------------------------- /website/src/util/returnArrayOfType.test.tsx: -------------------------------------------------------------------------------- 1 | import { returnArrayOfType } from "./returnArrayOfType"; 2 | 3 | describe("returnArrayOfType", () => { 4 | test("returns array of objects with the specified type", () => { 5 | const data = [ 6 | { type: "type1", value: "Value 1" }, 7 | { type: "type2", value: "Value 2" }, 8 | { type: "type1", value: "Value 3" }, 9 | { type: "type3", value: "Value 4" }, 10 | ]; 11 | 12 | const filteredData = returnArrayOfType(data, "type1"); 13 | 14 | expect(filteredData).toEqual([ 15 | { type: "type1", value: "Value 1" }, 16 | { type: "type1", value: "Value 3" }, 17 | ]); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /util/getOptions/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "CDK Development"; 3 | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small"; 5 | 6 | outputs = { 7 | self, 8 | nixpkgs, 9 | }: let 10 | pkgs = import nixpkgs { system ="x86_64-linux"; }; 11 | in { 12 | devShells.x86_64-linux.default = pkgs.mkShell { 13 | packages = with pkgs; [ 14 | nodejs_22 15 | # Optional 16 | bat 17 | jq 18 | ]; 19 | shellHook = '' 20 | echo "" 21 | echo "package.json scripts" 22 | echo "" 23 | cat package.json | jq .scripts 24 | echo "" 25 | bat --style=plain --paging=never ./README.md 26 | echo "" 27 | ''; 28 | }; 29 | }; 30 | } -------------------------------------------------------------------------------- /util/installer/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Installer Development"; 3 | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small"; 5 | 6 | outputs = { 7 | self, 8 | nixpkgs, 9 | }: let 10 | pkgs = import nixpkgs { system ="x86_64-linux"; }; 11 | in { 12 | devShells.x86_64-linux.default = pkgs.mkShell { 13 | packages = with pkgs; [ 14 | nodejs_22 15 | # Optional 16 | bat 17 | jq 18 | ]; 19 | shellHook = '' 20 | echo "" 21 | echo "package.json scripts" 22 | echo "" 23 | cat package.json | jq .scripts 24 | echo "" 25 | bat --style=plain --paging=never ./README.md 26 | echo "" 27 | ''; 28 | }; 29 | }; 30 | } -------------------------------------------------------------------------------- /util/getOptions/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | The getOptions runs in the CodePipeline to pull the SSM Parameter Store config and generate a config.json. The config.json is then used aas an input into the CDK deployment. This util can be run directly. 4 | 5 | To pull the correct SSM Parameter Store values we must set the `INSTANCE_NAME` that is used in the prefix. By default this is `main`. 6 | 7 | ``` 8 | export INSTANCE_NAME="main" 9 | npm run start 10 | ``` 11 | 12 | The CodePipeline synth step copies the result of this util into the CDK working directory (/infrastructure). 13 | 14 | ```sh 15 | cp ./config.json ../../infrastructure/config.json && cat ../../infrastructure/config.json 16 | ``` -------------------------------------------------------------------------------- /website/src/sampleData/sampleFooterLinks.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "prefix": "Framework:", 4 | "url": "https://reactjs.org/", 5 | "text": "React" 6 | }, 7 | { 8 | "prefix": "Icons:", 9 | "url": "https://github.com/icons8/flat-color-icons", 10 | "text": "Flat Color Icons" 11 | }, 12 | { 13 | "prefix": "UI:", 14 | "url": "https://ui.docs.amplify.aws/s", 15 | "text": "Amplify" 16 | }, 17 | { 18 | "prefix": "Translation:", 19 | "url": "https://aws.amazon.com/", 20 | "text": "Amazon Translate" 21 | }, 22 | { 23 | "prefix": "Prefix", 24 | "url": "/", 25 | "text": "link-text", 26 | "suffix": "suffix" 27 | }, 28 | { 29 | "url": "/url-with-no-text" 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Changelog 7 | All notable changes to this project will be documented in this file. 8 | 9 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 10 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 11 | 12 | ## [1.1.0] 13 | - Capability to specify custom domain/URL 14 | - Redirect HTTP requests to HTTPS 15 | - Limit request methods to GET & HEAD 16 | - MIME type filtering for OS file chooser 17 | - Fixed various spelling mistakes in documentation 18 | 19 | ## [1.0.0] 20 | - Initial release -------------------------------------------------------------------------------- /docs/flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1727076372, 6 | "narHash": "sha256-gXIWudYhY/4LjQPvrGn9lN4fbHjw/mf1mb9KKJK//4I=", 7 | "owner": "NixOS", 8 | "repo": "nixpkgs", 9 | "rev": "7ca0f93c530406c1610defff0b9bf643333cf992", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "NixOS", 14 | "ref": "nixos-24.05-small", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /website/src/util/getPresignedUrl.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { getUrl } from "@aws-amplify/storage"; 4 | 5 | import { configureS3Bucket } from "./configureS3Bucket"; 6 | 7 | interface Props { 8 | path: string; 9 | bucketKey: string; 10 | } 11 | 12 | export async function getPresignedUrl(props: Props) { 13 | try { 14 | configureS3Bucket(props.bucketKey); 15 | const result = await getUrl({ 16 | path: props.path, 17 | options: { 18 | expiresIn: 60, 19 | }, 20 | }); 21 | return result.url.href; 22 | } catch (error) { 23 | console.log("Error getting URL:", error); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /infrastructure/flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1718955215, 6 | "narHash": "sha256-3vNXv4zrblZFobrxz1P3RwLpHl6X3/GzfArdTxq0+nI=", 7 | "owner": "NixOS", 8 | "repo": "nixpkgs", 9 | "rev": "201ed88e66f7f34d5c74e46d2e4399cc4bea1501", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "NixOS", 14 | "ref": "nixos-24.05-small", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /util/getOptions/flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1725198597, 6 | "narHash": "sha256-w3sjCEbnc242ByJ18uebzgjFZY3QU7dZhmLwPsJIZJs=", 7 | "owner": "NixOS", 8 | "repo": "nixpkgs", 9 | "rev": "3524b030c839db4ea4ba16737789c6fb8a1769c6", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "NixOS", 14 | "ref": "nixos-24.05-small", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /util/installer/flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1723626050, 6 | "narHash": "sha256-m/F9UP00sC61CYNFVdmKIKuTX+m1Ooz+xCN22B//RY4=", 7 | "owner": "NixOS", 8 | "repo": "nixpkgs", 9 | "rev": "acbbdd548480497585a19bd735b16ffd096dfe57", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "NixOS", 14 | "ref": "nixos-24.05-small", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /docs/static/diagrams/flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1707943532, 6 | "narHash": "sha256-xuBmO9fvjzD3z9++tZuZovhKLwwvU0tMT1rOQN0MtzQ=", 7 | "owner": "NixOS", 8 | "repo": "nixpkgs", 9 | "rev": "a94892ad746fbdbe498553a76f898490a85900dd", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "NixOS", 14 | "ref": "nixos-23.11-small", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /docs/content/docs/shared/architecture/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Architecture 3 | weight: 1 4 | --- 5 | 6 | 10 | 11 | {{< cards >}} 12 | {{< card link="services" title="Services" >}} 13 | {{< card link="api-auth" title="API & Authentication" >}} 14 | {{< card link="help-info" title="Help Info" >}} 15 | {{< card link="web-ui" title="Web UI" >}} 16 | {{< /cards >}} 17 | 18 | This overview shows how the shared components are interconnected. For an overview of all features please refer to the [overview architecture]({{< ref "docs/architecture" >}}). 19 | 20 | ![Overview](/diagrams/overview_client.png) -------------------------------------------------------------------------------- /website/src/util/putObjectS3.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { uploadData } from "@aws-amplify/storage"; 4 | 5 | import { configureS3Bucket } from "./configureS3Bucket"; 6 | 7 | interface Props { 8 | path: string; 9 | file: File; 10 | bucketKey: string; 11 | } 12 | 13 | export async function putObjectS3(props: Props) { 14 | try { 15 | configureS3Bucket(props.bucketKey); 16 | const result = await uploadData({ 17 | path: props.path, 18 | data: props.file, 19 | }).result; 20 | console.log("putObjectS3 | result:", result); 21 | } catch (error) { 22 | console.log("Error uploading object:", error); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docs/content/docs/translation/architecture/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Architecture 3 | weight: 1 4 | excludeSearch: true 5 | --- 6 | 7 | 11 | 12 | {{< cards >}} 13 | {{< card link="./services" title="Services" >}} 14 | {{< card link="./step-functions" title="Step Functions" >}} 15 | {{< card link="./scaling" title="Scaling" >}} 16 | {{< /cards >}} 17 | 18 | This overview shows how this feature is interconnected with the shared components. For an overview of all features please refer to the [overview architecture]({{< ref "docs/architecture" >}}). 19 | 20 | ![Overview](/diagrams/overview_translation.png) -------------------------------------------------------------------------------- /infrastructure/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2018", 4 | "module": "commonjs", 5 | "lib": ["es2018"], 6 | "declaration": true, 7 | "strict": true, 8 | "noImplicitAny": false, 9 | "strictNullChecks": true, 10 | "noImplicitThis": true, 11 | "alwaysStrict": true, 12 | "noUnusedLocals": false, 13 | "noUnusedParameters": false, 14 | "noImplicitReturns": false, 15 | "noFallthroughCasesInSwitch": false, 16 | "inlineSourceMap": true, 17 | "inlineSources": true, 18 | "experimentalDecorators": true, 19 | "strictPropertyInitialization": false, 20 | "typeRoots": ["./node_modules/@types"], 21 | "esModuleInterop": true 22 | }, 23 | "exclude": ["node_modules", "cdk.out"] 24 | } 25 | -------------------------------------------------------------------------------- /docs/content/docs/readable/prerequisites/model-access.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Model Access 3 | --- 4 | 5 | 9 | 10 | Before using the Amazon Bedrock service we must first gain access to the appropriate models. This can be done via the Amazon Bedrock console for the chosen region. Which models you choose is down to you. 11 | 12 | Please review [Amazon Bedrock]({{< ref "docs/readable/architecture/bedrock" >}}) for models supported by this app. 13 | 14 | Please follow the [Amazon Bedrock documentation for Model Access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) to enable the models in your AWS Account. -------------------------------------------------------------------------------- /infrastructure/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node --prefer-ts-exts bin/doctran.ts", 3 | "watch": { 4 | "include": ["**"], 5 | "exclude": [ 6 | "README.md", 7 | "cdk*.json", 8 | "**/*.d.ts", 9 | "**/*.js", 10 | "tsconfig.json", 11 | "package*.json", 12 | "yarn.lock", 13 | "node_modules", 14 | "test" 15 | ] 16 | }, 17 | "context": { 18 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, 19 | "@aws-cdk/core:stackRelativeExports": true, 20 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true, 21 | "@aws-cdk/aws-lambda:recognizeVersionProps": true, 22 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, 23 | "@aws-cdk/core:target-partitions": ["aws", "aws-cn"] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /infrastructure/lib/features/readable/defaults/text.amazon-nova-v1-pro.ddb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": { 3 | "S": "Default-Example-Text-Amazon-Nova-v1-Pro" 4 | }, 5 | "name": { 6 | "S": "Example Simplifier (Amazon-Nova-v1-Pro)" 7 | }, 8 | "type": { 9 | "S": "text" 10 | }, 11 | "default": { 12 | "BOOL": false 13 | }, 14 | "text": { 15 | "M": { 16 | "modelId": { 17 | "S": "amazon.nova-pro-v1:0" 18 | }, 19 | "parameters": { 20 | "M": {} 21 | }, 22 | "prePrompt": { 23 | "S": "Simplify the following text so it can be easily understood by those with a low reading age. Use short sentences, explain any abbreviations or words that can have two meanings, and separate the sentences into new lines." 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/content/docs/shared/post-install/domain.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom Domain 3 | weight: 5 4 | --- 5 | 6 | 10 | 11 | Once the app is deployed you will need to update your DNS provider (AWS Route 53) to point the custom domain to the CloudFront distribution. 12 | 13 | - Navigate to AWS Route 53 14 | - Create an `A` record for your custom domain 15 | - Toggle the `Alias` option 16 | - Select `CloudFront Distribution` 17 | - Select the distribution created 18 | 19 | The distribution URL can be verified from the CloudFormation stack `DocTran--App` outputs. The AWS Cloudfront URL with a structure of `abcdefg1234567.cloudfront.net`. 20 | -------------------------------------------------------------------------------- /docs/content/docs/translation/architecture/step-functions/pii.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: PII 3 | weight: 3 4 | --- 5 | 6 | 10 | 11 | The Pii StepFunction job is created by the Main StepFunction. Whilst it is processing the Main StepFunction is paused and waits for a callback. This callback token is stored within the DB. 12 | 13 | When Macie completes the detection job it will publish a log. This log is used to trigger a Lambda function to parse the log and start the Callback StepFunction. The responsibility of the Lambda function is to determine the job id that relates to this detection job. 14 | 15 | ![Macie Workflow](/diagrams/macie_workflow.png) -------------------------------------------------------------------------------- /website/.prettierrc.json5: -------------------------------------------------------------------------------- 1 | { 2 | plugins: ["@trivago/prettier-plugin-sort-imports"], 3 | arrowParens: "always", 4 | bracketSpacing: true, 5 | endOfLine: "lf", 6 | semi: true, 7 | useTabs: true, 8 | trailingComma: "es5", 9 | importOrder: [ 10 | // Non JS/TS files 11 | "^(.*).css", 12 | "^(.*).json", 13 | // JS/TS files 14 | "^[@]?react(.*)$", 15 | "^[@]?cloudscape-design/(.*)$", 16 | "^[@]?aws-amplify/(.*)$", 17 | "^(.*)/graphql/(.*)$", 18 | "^(.*)/hooks/(.*)$", 19 | "^(.*)/util/(.*)$", 20 | // Current or root 21 | "^[./](.*)$", 22 | // Else 23 | "^(.*)$", 24 | ], 25 | importOrderSeparation: true, 26 | importOrderSortSpecifiers: true, 27 | importOrderCaseInsensitive: true, 28 | importOrderGroupNamespaceSpecifiers: true, 29 | } 30 | -------------------------------------------------------------------------------- /infrastructure/lib/features/readable/defaults/text.amazon-nova-v2-lite.ddb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": { 3 | "S": "Default-Example-Text-Amazon-Nova-v2-Lite-GLOBAL" 4 | }, 5 | "name": { 6 | "S": "Example Simplifier (Amazon-Nova-v2-Pro-GLOBAL)" 7 | }, 8 | "type": { 9 | "S": "text" 10 | }, 11 | "default": { 12 | "BOOL": false 13 | }, 14 | "text": { 15 | "M": { 16 | "modelId": { 17 | "S": "eu.amazon.nova-2-lite-v1:0" 18 | }, 19 | "parameters": { 20 | "M": {} 21 | }, 22 | "prePrompt": { 23 | "S": "Simplify the following text so it can be easily understood by those with a low reading age. Use short sentences, explain any abbreviations or words that can have two meanings, and separate the sentences into new lines." 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /infrastructure/lib/features/readable/defaults/text.mistral-mistral-7b-instruct.ddb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": { 3 | "S": "Default-Example-Text-Mistral-7b-Instruct" 4 | }, 5 | "name": { 6 | "S": "Example Simplifier (Mistral 7b Instruct)" 7 | }, 8 | "type": { 9 | "S": "text" 10 | }, 11 | "default": { 12 | "BOOL": false 13 | }, 14 | "text": { 15 | "M": { 16 | "modelId": { 17 | "S": "mistral.mistral-7b-instruct-v0:2" 18 | }, 19 | "parameters": { 20 | "M": {} 21 | }, 22 | "prePrompt": { 23 | "S": "Simplify the following text so it can be easily understood by those with a low reading age. Use short sentences, explain any abbreviations or words that can have two meanings, and separate the sentences into new lines." 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /util/installer/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clone the repository 4 | echo "Cloning the repository..." 5 | git clone https://github.com/aws-samples/document-translation.git 6 | cd "document-translation" || exit 7 | 8 | # Set the working directory 9 | WORKDIR=$(pwd) 10 | INSTALLERDIR="${WORKDIR}/util/installer" 11 | INFRADIR="${WORKDIR}/infrastructure" 12 | 13 | # See https://github.com/aws-samples/document-translation/issues/93 14 | export UV_USE_IO_URING=0 15 | 16 | # Install dependencies 17 | echo "Installing dependencies for CDK infrastructure..." 18 | cd "${INFRADIR}" || exit 19 | npm install 20 | 21 | # Run the installer 22 | echo "Installing dependencies for installer..." 23 | cd "${INSTALLERDIR}" || exit 24 | echo "Running installer..." 25 | npm install 26 | npm run wizard 27 | -------------------------------------------------------------------------------- /website/src/util/sortDataByKey.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | interface Data { 5 | [key: string]: any; 6 | } 7 | 8 | // Sorts an array of data objects in descending order by the "createdAt" property 9 | export default function sortDataByKey( 10 | priKey: string, 11 | secKey: string, 12 | data: Data 13 | ) { 14 | data.sort((a: Data, b: Data) => { 15 | if (a[priKey] < b[priKey]) return 1; // sort second object first 16 | if (b[priKey] < a[priKey]) return -1; // sort first object first 17 | if (a[secKey] < b[secKey]) return -1; // sort first object first 18 | if (b[secKey] < a[secKey]) return 1; // sort second object first 19 | return 0; // equal objects 20 | }); 21 | return data; 22 | } 23 | -------------------------------------------------------------------------------- /infrastructure/lib/features/readable/defaults/text.anthropic-claude-4-5-haiku.ddb.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": { 3 | "S": "Default-Example-Text-Anthropic-Claude-4-5-EU" 4 | }, 5 | "name": { 6 | "S": "Example Simplifier (Anthropic-Claude-4-5-EU)" 7 | }, 8 | "type": { 9 | "S": "text" 10 | }, 11 | "default": { 12 | "BOOL": false 13 | }, 14 | "text": { 15 | "M": { 16 | "modelId": { 17 | "S": "eu.anthropic.claude-haiku-4-5-20251001-v1:0" 18 | }, 19 | "parameters": { 20 | "M": {} 21 | }, 22 | "prePrompt": { 23 | "S": "Simplify the following text so it can be easily understood by those with a low reading age. Use short sentences, explain any abbreviations or words that can have two meanings, and separate the sentences into new lines." 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /util/installer/src/configuration/common.misc.ts: -------------------------------------------------------------------------------- 1 | import { input } from "@inquirer/prompts"; 2 | import { CommonMiscOptions } from "./options"; 3 | import { BOLD, RESET } from "../util/textStyles" 4 | 5 | const theme = { 6 | prefix: "Common - Misc: ", 7 | }; 8 | 9 | const showInstruction = () => { 10 | console.log(` 11 | ${BOLD}# Common - Misc Configuration${RESET} 12 | `); 13 | }; 14 | 15 | export const getCommonMiscOptions = async (): Promise => { 16 | showInstruction(); 17 | 18 | let answers: CommonMiscOptions = { 19 | common: { 20 | instance: { 21 | name: await input({ 22 | message: "Instance Name (branch from before v3.x.x)", 23 | required: true, 24 | default: "main", 25 | theme, 26 | }), 27 | }, 28 | }, 29 | }; 30 | 31 | return answers; 32 | }; 33 | -------------------------------------------------------------------------------- /website/src/page/readable/util/groupItemsByParent.test.tsx: -------------------------------------------------------------------------------- 1 | import { groupItemsByParent } from "./groupItemsByParent"; 2 | 3 | describe("groupItemsByParent", () => { 4 | test("groups items correctly", () => { 5 | const items = [ 6 | { id: 1, name: "3.1", parent: 3 }, 7 | { id: 2, name: "1.2", parent: 1 }, 8 | { id: 3, name: "1.3", parent: 1 }, 9 | { id: 4, name: "2.4", parent: 2 }, 10 | { id: 5, name: "3.5", parent: 3 }, 11 | ]; 12 | 13 | const groupedItems = groupItemsByParent(items); 14 | 15 | expect(groupedItems).toEqual({ 16 | 3: [ 17 | { id: 1, name: "3.1", parent: 3 }, 18 | { id: 5, name: "3.5", parent: 3 }, 19 | ], 20 | 1: [ 21 | { id: 2, name: "1.2", parent: 1 }, 22 | { id: 3, name: "1.3", parent: 1 }, 23 | ], 24 | 2: [{ id: 4, name: "2.4", parent: 2 }], 25 | }); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /website/src/page/help/help.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import "@cloudscape-design/global-styles/index.css"; 4 | 5 | import React from "react"; 6 | import { useTranslation } from "react-i18next"; 7 | 8 | import { 9 | ContentLayout, 10 | Header, 11 | SpaceBetween, 12 | } from "@cloudscape-design/components"; 13 | 14 | import HelpItems from "./helpItems"; 15 | 16 | export default function Help() { 17 | const { t } = useTranslation(); 18 | 19 | return ( 20 | <> 21 | 24 |
25 | {t("help_title")} 26 |
27 | 28 | } 29 | > 30 | 31 |
32 | 33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /website/src/util/sortDataByKey.test.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import testFunction from "./sortDataByKey"; 4 | 5 | describe("sortDataByCreatedAt", function () { 6 | const data = [ 7 | { id: 1, createdAt: new Date("2022-01-01") }, 8 | { id: 2, createdAt: new Date("2022-01-01") }, 9 | { id: 3, createdAt: new Date("2023-03-01") }, 10 | { id: 4, createdAt: new Date("2022-02-01") }, 11 | ]; 12 | 13 | const successData = [ 14 | { id: 3, createdAt: new Date("2023-03-01") }, 15 | { id: 4, createdAt: new Date("2022-02-01") }, 16 | { id: 1, createdAt: new Date("2022-01-01") }, 17 | { id: 2, createdAt: new Date("2022-01-01") }, 18 | ]; 19 | 20 | test("test success", () => { 21 | expect(testFunction("createdAt", "id", data)).toEqual(successData); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /infrastructure/lambda/htmlToMd/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "htmlToMd", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "turndown": "^7.2.0" 9 | } 10 | }, 11 | "node_modules/@mixmark-io/domino": { 12 | "version": "2.2.0", 13 | "resolved": "https://registry.npmjs.org/@mixmark-io/domino/-/domino-2.2.0.tgz", 14 | "integrity": "sha512-Y28PR25bHXUg88kCV7nivXrP2Nj2RueZ3/l/jdx6J9f8J4nsEGcgX0Qe6lt7Pa+J79+kPiJU3LguR6O/6zrLOw==" 15 | }, 16 | "node_modules/turndown": { 17 | "version": "7.2.0", 18 | "resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.0.tgz", 19 | "integrity": "sha512-eCZGBN4nNNqM9Owkv9HAtWRYfLA4h909E/WGAWWBpmB275ehNhZyk87/Tpvjbp0jjNl9XwCsbe6bm6CqFsgD+A==", 20 | "dependencies": { 21 | "@mixmark-io/domino": "^2.2.0" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /docs/content/docs/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Installation 3 | weight: 003 4 | --- 5 | 6 | 10 | 11 | {{< callout type="info" >}} 12 | Installation typically takes between 30-60 minutes. 13 | {{< /callout >}} 14 | 15 | ## Prerequisite 16 | 17 | A [GitHub Token]({{< ref "docs/shared/prerequisites/github-token" >}}) is required for this app. 18 | 19 | ## Install 20 | 21 | From the [AWS CloudShell]({{< ref "docs/shared/prerequisites/cloudshell" >}}) run the install script. 22 | 23 | ```sh 24 | # Download the install script 25 | wget https://raw.githubusercontent.com/aws-samples/document-translation/main/util/installer/install.sh 26 | 27 | # Make the script executable 28 | chmod +x ./install.sh 29 | 30 | # Run the install script 31 | ./install.sh 32 | ``` 33 | -------------------------------------------------------------------------------- /website/src/page/translation/util/getBrowserLanguage.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import i18n from "i18next"; 4 | 5 | interface Item { 6 | value: string; 7 | label: string; 8 | } 9 | const languagesSource: Array = require("../languagesSource.json"); 10 | 11 | export function getBrowserLanguage() { 12 | const fallbackLanguage = "en"; 13 | function getLanguage() { 14 | return ( 15 | i18n.language || 16 | (typeof window !== "undefined" && window.localStorage.i18nextLng) || 17 | fallbackLanguage 18 | ); 19 | } 20 | const language = getLanguage(); 21 | const isLanguageSupported = languagesSource.find( 22 | (item: Item) => item.value === language 23 | ); 24 | if (isLanguageSupported) { 25 | return language; 26 | } else { 27 | return fallbackLanguage; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /website/src/page/translation/new.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import "@cloudscape-design/global-styles/index.css"; 4 | 5 | import React from "react"; 6 | import { useTranslation } from "react-i18next"; 7 | 8 | import { 9 | ContentLayout, 10 | Header, 11 | SpaceBetween, 12 | } from "@cloudscape-design/components"; 13 | 14 | import NewForm from "./newForm"; 15 | 16 | export default function TranslationNew() { 17 | const { t } = useTranslation(); 18 | 19 | return ( 20 | <> 21 | 24 |
25 | {t("translation_new_title")} 26 |
27 | 28 | } 29 | > 30 | 31 |
32 | 33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /util/installer/src/main.ts: -------------------------------------------------------------------------------- 1 | import { deploy } from "./deploy/deploy"; 2 | import { monitorCodepipeline } from "./deploy/monitor.codepipeline"; 3 | 4 | import { getConfigurationOptions } from "./options"; 5 | import { prerequisites } from "./prerequisites"; 6 | import { getAwsConfig } from "./awsconfig"; 7 | import { saveConfigToParameterStore } from "./parameters"; 8 | 9 | const main = async () => { 10 | const awsConfig = await getAwsConfig(); 11 | console.log("AwsConfig:", awsConfig); 12 | 13 | const config = await getConfigurationOptions(); 14 | 15 | prerequisites(config); 16 | 17 | await saveConfigToParameterStore(config); 18 | const outputsPath: string = await deploy({ 19 | config, 20 | awsConfig, 21 | }); 22 | 23 | await monitorCodepipeline( 24 | config.common.instance.name, 25 | `../../infrastructure/${outputsPath}`, 26 | awsConfig.region 27 | ); 28 | }; 29 | 30 | main(); 31 | -------------------------------------------------------------------------------- /docs/content/docs/readable/architecture/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Architecture 3 | weight: 1 4 | --- 5 | 6 | 10 | 11 | The documentation here covers the Simply Readable feature specifically. Please review the [Architecture Overview]({{< ref "docs/architecture" >}}) to see an overview of all features and shared components (E.g. authentication & api). 12 | 13 | {{< cards >}} 14 | {{< card link="./services" title="Services" icon="cloud" >}} 15 | {{< card link="./bedrock" title="Amazon Bedrock" icon="cube-transparent" >}} 16 | {{< /cards >}} 17 | 18 | This overview shows how this feature is interconnected with the shared components. For an overview of all features please refer to the [overview architecture]({{< ref "docs/architecture" >}}). 19 | 20 | ![Overview](/diagrams/overview_readable.png) -------------------------------------------------------------------------------- /docs/content/docs/translation/architecture/services.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Services 3 | weight: 1 4 | --- 5 | 6 | 10 | 11 | - [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/) 12 | - [Amazon Macie](https://aws.amazon.com/macie/) 13 | - [Amazon Translate](https://aws.amazon.com/translate/) 14 | - [AWS AppSync](https://aws.amazon.com/appsync/) 15 | - [AWS CloudFront](https://aws.amazon.com/cloudfront/) 16 | - [AWS Cognito](https://aws.amazon.com/cognito/) 17 | - [AWS DynamoDB](https://aws.amazon.com/dynamodb/) 18 | - [AWS EventBridge](https://aws.amazon.com/eventbridge/) 19 | - [AWS Lambda](https://aws.amazon.com/lambda/) 20 | - [AWS S3](https://aws.amazon.com/s3/) 21 | - [AWS StepFunctions](https://aws.amazon.com/step-functions/) 22 | - [AWS Web Application Firewall](https://aws.amazon.com/waf/) -------------------------------------------------------------------------------- /docs/static/diagrams/stepfunction_main_overview.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | import os 5 | from diagrams import Diagram 6 | from diagrams.aws.database import DDB, DynamodbTable 7 | from diagrams.aws.integration import SF 8 | from diagrams.aws.ml import Translate 9 | 10 | import attr 11 | 12 | name = os.path.splitext(os.path.basename(__file__))[0] 13 | name_human = name.replace("_", " ").capitalize() 14 | 15 | with Diagram(name_human, filename=name, show=False, graph_attr=attr.graph): 16 | sf_main = SF("Main") 17 | sf_translate = SF("Translate") 18 | sf_pii = SF("Pii") 19 | sf_tag = SF("Tag") 20 | 21 | db_jobs = DDB("Jobs") 22 | 23 | DynamodbTable("Table Stream") >> sf_main 24 | 25 | sf_main >> sf_translate 26 | sf_main >> sf_pii 27 | sf_main >> sf_tag 28 | sf_main >> db_jobs 29 | -------------------------------------------------------------------------------- /docs/content/docs/translation/configuration/customisation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Customisation 3 | weight: 2 4 | --- 5 | 6 | 10 | 11 | {{< callout type="info" >}} 12 | This step is **optional**. 13 | {{< /callout >}} 14 | 15 | You can customise various elements of this application to fit your unique requirements. This includes the aspects listed below. For all of the customisation options you must commit the appropriate file to your git repository. 16 | 17 | ## Custom Terminology 18 | 19 | Custom Terminology is an optional feature. 20 | 21 | ```sh 22 | aws translate \ 23 | import-terminology \ 24 | --merge-strategy OVERWRITE \ 25 | --terminology-data Format=CSV,Directionality=UNI \ 26 | # Language code 27 | --name fr \ 28 | # Your custom terminology file 29 | --data-file fileb://./fr.csv 30 | ``` 31 | -------------------------------------------------------------------------------- /docs/static/diagrams/stepfunction_translation_overview.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | import os 5 | from diagrams import Diagram 6 | from diagrams.aws.database import DDB, DynamodbTable 7 | from diagrams.aws.integration import SF 8 | from diagrams.aws.ml import Translate 9 | 10 | import attr 11 | 12 | name = os.path.splitext(os.path.basename(__file__))[0] 13 | name_human = name.replace("_", " ").capitalize() 14 | 15 | with Diagram(name_human, filename=name, show=False, graph_attr=attr.graph): 16 | sf_main = SF("Main") 17 | sf_translate = SF("Translate") 18 | sf_pii = SF("Pii") 19 | sf_tag = SF("Tag") 20 | 21 | db_jobs = DDB("Jobs") 22 | 23 | DynamodbTable("Table Stream") >> sf_main 24 | 25 | sf_main >> sf_translate 26 | sf_main >> sf_pii 27 | sf_main >> sf_tag 28 | sf_main >> db_jobs 29 | -------------------------------------------------------------------------------- /website/src/page/translation/quick.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import "@cloudscape-design/global-styles/index.css"; 4 | 5 | import React from "react"; 6 | import { useTranslation } from "react-i18next"; 7 | 8 | import { 9 | ContentLayout, 10 | Header, 11 | SpaceBetween, 12 | } from "@cloudscape-design/components"; 13 | 14 | import Form from "./quickForm"; 15 | 16 | export default function TranslationQuick() { 17 | const { t } = useTranslation(); 18 | 19 | return ( 20 | <> 21 | 24 |
28 | {t("translation_quick_text_title")} 29 |
30 | 31 | } 32 | > 33 |
34 | 35 | 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /infrastructure/jest.config.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | /* 5 | * For a detailed explanation regarding each configuration property and type check, visit: 6 | * https://jestjs.io/docs/configuration 7 | */ 8 | 9 | export default { 10 | // Automatically clear mock calls, instances, contexts and results before every test 11 | clearMocks: true, 12 | 13 | // Indicates whether the coverage information should be collected while executing the test 14 | collectCoverage: true, 15 | 16 | // The directory where Jest should output its coverage files 17 | coverageDirectory: "coverage", 18 | 19 | // Indicates which provider should be used to instrument code for coverage 20 | coverageProvider: "v8", 21 | 22 | // A map from regular expressions to paths to transformers 23 | // transform: undefined, 24 | transform: { 25 | "\\.[jt]sx?$": "ts-jest", 26 | }, 27 | }; 28 | -------------------------------------------------------------------------------- /docs/content/docs/translation/architecture/scaling.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Scaling 3 | --- 4 | 5 | 9 | 10 | The architecture is designed to reduce scaling constraints where possible, such as using serverless services and an event driven workflow. 11 | 12 | A constraint to be aware of is the "Concurrent batch translation jobs" per account for the Amazon Translate service. The default value is `10`. This application handles more than this value by queueing the jobs to be processed. Queueing increases the time for translations to complete when there is more than 10 concurrent translation jobs active. 13 | 14 | This service quota is an [adjustable value](https://docs.aws.amazon.com/general/latest/gr/translate-service.html) and can be increased through a [quota increase request](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html). 15 | -------------------------------------------------------------------------------- /docs/static/diagrams/macie_workflow.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | import os 5 | from diagrams import Diagram 6 | from diagrams.aws.storage import S3 7 | from diagrams.aws.security import Macie 8 | from diagrams.aws.integration import SF 9 | from diagrams.aws.compute import Lambda 10 | from diagrams.aws.management import Cloudwatch 11 | 12 | import attr 13 | 14 | name = os.path.splitext(os.path.basename(__file__))[0] 15 | name_human = name.replace("_", " ").capitalize() 16 | 17 | with Diagram(name_human, filename=name, show=False, graph_attr=attr.graph): 18 | sf_main = SF("Pii") 19 | sf_CallbackSend = SF("Callback") 20 | macie = Macie("PII Detection") 21 | lambda_parseMacieResult = Lambda("Parse Macie Result") 22 | 23 | sf_main >> macie 24 | 25 | macie >> Cloudwatch("Job Complete Log Subscription") >> lambda_parseMacieResult >> sf_CallbackSend 26 | -------------------------------------------------------------------------------- /docs/static/diagrams/translate_workflow.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | import os 5 | from diagrams import Diagram 6 | from diagrams.aws.storage import S3 7 | from diagrams.aws.integration import SF 8 | from diagrams.aws.ml import Translate 9 | from diagrams.aws.compute import Lambda 10 | 11 | import attr 12 | 13 | name = os.path.splitext(os.path.basename(__file__))[0] 14 | name_human = name.replace("_", " ").capitalize() 15 | 16 | with Diagram(name_human, filename=name, show=False, graph_attr=attr.graph): 17 | sf_translate = SF("Translate") 18 | sf_CallbackSend = SF("Callback") 19 | translate = Translate("Document Translation") 20 | lambda_passS3EventToStepFunction = Lambda("Pass S3 Event to StepFunction") 21 | content = S3("Content") 22 | 23 | sf_translate >> translate 24 | 25 | translate >> content >> lambda_passS3EventToStepFunction >> sf_CallbackSend 26 | -------------------------------------------------------------------------------- /website/src/util/readableCreateJob.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import { generateClient } from "@aws-amplify/api"; 4 | import { fetchAuthSession } from "@aws-amplify/auth"; 5 | 6 | const features = require("../features.json"); 7 | let readableCreateJob: string | null = null; 8 | if (features.readable) { 9 | readableCreateJob = require("../graphql/mutations").readableCreateJob; 10 | } 11 | 12 | export async function CreateJob() { 13 | const client = generateClient({ authMode: "userPool" }); 14 | 15 | try { 16 | if (readableCreateJob) { 17 | const authSession = await fetchAuthSession(); 18 | const response = await client.graphql({ 19 | query: readableCreateJob, 20 | variables: { 21 | identity: authSession.identityId, 22 | }, 23 | }); 24 | 25 | return await response.data.readableCreateJob.id; 26 | } 27 | } catch (error) { 28 | throw error; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | # NODE 5 | node_modules/ 6 | 7 | # DIAGRAMS 8 | __pycache__/ 9 | 10 | # CDK 11 | cdk.out/ 12 | .cdk.staging 13 | infrastructure/**/*.js 14 | infrastructure/**/*.d.ts 15 | 16 | # CFN 17 | cfnOutputs.json 18 | 19 | # FEATURES 20 | features.json 21 | features.json.tmp 22 | 23 | # APPSYNC 24 | schema.graphql 25 | mutations.js 26 | queries.js 27 | subscriptions.js 28 | mutations.ts 29 | queries.ts 30 | subscriptions.ts 31 | 32 | # REACT 33 | build/ 34 | dist/ 35 | 36 | # MISC 37 | .DS_Store 38 | .env.local 39 | .env.development.local 40 | .env.test.local 41 | .env.production.local 42 | 43 | npm-debug.log* 44 | yarn-debug.log* 45 | yarn-error.log* 46 | 47 | # JEST 48 | coverage/ 49 | 50 | # DOCS 51 | # DOCS | HUGO 52 | .hugo_build.lock 53 | docs/public 54 | 55 | # Config 56 | util/**/config.json 57 | infrastructure/**/config.json 58 | infrastructure/**/cloudformation-outputs.json -------------------------------------------------------------------------------- /website/src/util/getPageJobId.test.tsx: -------------------------------------------------------------------------------- 1 | import { getPageJobId } from "./getPageJobId"; 2 | 3 | // Set the Jest environment to use JSDOM 4 | jest.config = { 5 | testEnvironment: "jest-environment-jsdom", 6 | }; 7 | 8 | describe("getPageJobId", () => { 9 | let originalLocation: Location; 10 | 11 | beforeEach(() => { 12 | // Save the original window.location object 13 | originalLocation = window.location; 14 | 15 | // Mock the window.location.search property 16 | Object.defineProperty(window, "location", { 17 | value: { 18 | search: "?jobId=job-123", 19 | }, 20 | writable: true, 21 | }); 22 | }); 23 | 24 | afterEach(() => { 25 | // Restore the original window.location object 26 | Object.defineProperty(window, "location", { 27 | value: originalLocation, 28 | writable: true, 29 | }); 30 | }); 31 | 32 | test("retrieves job ID correctly from URL query parameters", () => { 33 | const jobId = getPageJobId(); 34 | expect(jobId).toBe("job-123"); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /util/installer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "installer", 3 | "main": "./src/main.ts", 4 | "dependencies": { 5 | "@aws-cdk/cli-lib-alpha": "^2.1016.1-alpha.0", 6 | "@aws-sdk/client-cloudformation": "^3.631.0", 7 | "@aws-sdk/client-cloudwatch-logs": "^3.631.0", 8 | "@aws-sdk/client-codepipeline": "^3.631.0", 9 | "@aws-sdk/client-macie2": "^3.631.0", 10 | "@aws-sdk/client-secrets-manager": "^3.631.0", 11 | "@aws-sdk/client-ssm": "^3.637.0", 12 | "commander": "^12.1.0", 13 | "inquirer": "^12.10.0", 14 | "ts-node": "^10.9.2" 15 | }, 16 | "scripts": { 17 | "wizard": "ts-node ./src/main.ts", 18 | "awsconfig": "ts-node src/awsconfig.ts", 19 | "options": "ts-node src/options.ts", 20 | "prereq": "ts-node src/prerequisites.ts", 21 | "parameters": "ts-node src/parameters.ts", 22 | "parameters_deploy": "ts-node src/parameters.ts && ts-node src/deploy/deploy.ts", 23 | "deploy": "ts-node src/deploy/deploy.ts", 24 | "monitor": "ts-node src/deploy/monitor.codepipeline.ts" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /website/src/page/readable/enums.tsx: -------------------------------------------------------------------------------- 1 | export const ItemValues: Record = { 2 | TEXT: "text", 3 | IMAGE: "image", 4 | METADATA: "metadata", 5 | }; 6 | 7 | export const ItemStatus: Record = { 8 | PROCESSING: "processing", 9 | COMPLETED: "completed", 10 | UPDATED: "updated", 11 | GENERATE: "generate", 12 | FAILED_UNRECOGNISEDMODEL: "failed_unrecognisedModel", 13 | }; 14 | 15 | export const ItemKeys: Record = { 16 | CREATEDAT: "createdAt", 17 | ID: "id", 18 | IDENTITY: "identity", 19 | INPUT: "input", 20 | ITEMID: "itemId", 21 | MODELID: "modelId", 22 | NAME: "name", 23 | ORDER: "order", 24 | OUTPUT: "output", 25 | PARENT: "parent", 26 | STATUS: "status", 27 | TYPE: "type", 28 | UPDATEDAT: "updatedAt", 29 | }; 30 | 31 | export const PrintStyles: Record = { 32 | TABLEWITHIMAGELEFT: "tableWithImageLeft", 33 | TABLEWITHIMAGERIGHT: "tableWithImageRight", 34 | TABLEWITHIMAGEALTERNATINGSIDE: "tableWithImageAlternatingSide", 35 | }; 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | 18 | -------------------------------------------------------------------------------- /website/src/util/getPrintStyle.test.tsx: -------------------------------------------------------------------------------- 1 | import { getPrintStyle } from "./getPrintStyle"; 2 | 3 | // Set the Jest environment to use JSDOM 4 | jest.config = { 5 | testEnvironment: "jest-environment-jsdom", 6 | }; 7 | 8 | describe("getPrintStyle", () => { 9 | let originalLocation: Location; 10 | 11 | beforeEach(() => { 12 | // Save the original window.location object 13 | originalLocation = window.location; 14 | 15 | // Mock the window.location.search property 16 | Object.defineProperty(window, "location", { 17 | value: { 18 | search: "?printStyle=print", 19 | }, 20 | writable: true, 21 | }); 22 | }); 23 | 24 | afterEach(() => { 25 | // Restore the original window.location object 26 | Object.defineProperty(window, "location", { 27 | value: originalLocation, 28 | writable: true, 29 | }); 30 | }); 31 | 32 | test("retrieves print style correctly from URL query parameters", () => { 33 | const printStyle = getPrintStyle(); 34 | expect(printStyle).toBe("print"); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /infrastructure/test/unmarshallDdb.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | 4 | import { handler as myHandler } from "../lambda/unmarshallDdb/index"; 5 | 6 | interface testData { 7 | name: string; 8 | payload: { 9 | id: { S: string }; 10 | order: { N: string }; 11 | }; 12 | result: { 13 | id: string; 14 | order: number; 15 | }; 16 | } 17 | 18 | // TEST DATA 19 | const testSuccess: testData[] = [ 20 | { 21 | name: "Simple string", 22 | payload: { 23 | id: { 24 | S: "01234567-abcd-efgh-ijkl-891011121314", 25 | }, 26 | order: { 27 | N: "1", 28 | }, 29 | }, 30 | result: { 31 | id: "01234567-abcd-efgh-ijkl-891011121314", 32 | order: 1, 33 | }, 34 | }, 35 | ]; 36 | 37 | // SUCCESS 38 | testSuccess.forEach((item) => { 39 | describe("handler", function () { 40 | test(item.name, async function () { 41 | await expect(myHandler(item.payload)).resolves.toEqual(item.result); 42 | }); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /docs/content/docs/shared/architecture/api-auth.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: API & Auth 3 | --- 4 | 5 | 9 | 10 | The API used by this app is AWS AppSync which provides a GraphQL API. Authentication against the API is handled with AWS Cognito which provides user management and/or integration into a SAML 2.0 provider (E.g. Azure AD). 11 | 12 | Out of the box the API does not have any methods/actions available, nor any authentication. These are added by the specific features when enabled, following a code first schema defintion, implemented by the AWS CDK. 13 | 14 | Today all features require authentication. Some scope permissions down to individual users to access their particular jobs/data. Others are broader and allow any authenticated user to pull the information (E.g. Help-Info). 15 | 16 | The AWS AppSync is protected by an AWS Web Application Firewall. This uses the AWS managed ruleset called `AWSManagedRulesCommonRuleSet`. 17 | -------------------------------------------------------------------------------- /docs/content/docs/shared/post-install/cognito-first-user.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Cognito First User 3 | weight: 1 4 | --- 5 | 6 | 10 | 11 | {{< callout type="warning" >}} 12 | This step is **conditional**. 13 | 14 | - If you have chosen to use Cognito Local Users this step is **required**. 15 | - If not this step can be **skipped**. 16 | {{< /callout >}} 17 | 18 | [Amazon Cognito](https://aws.amazon.com/cognito/) provides an identity store that scales to millions of users and offers advanced security features to protect your consumers and business. 19 | 20 | - Navigate to the [AWS Cognito Console](https://console.aws.amazon.com/cognito/v2/home) 21 | - Select the appropriate "User pool name" 22 | - Select "Create user" in the "Users" section on the "Users" tab 23 | - Complete the form as appropriate 24 | - Note: If you specify a password it will be emailed to the user email in plain text. 25 | - Select "Create user" -------------------------------------------------------------------------------- /docs/static/diagrams/stepfunction_translate_overview.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | import os 5 | from diagrams import Diagram 6 | from diagrams.aws.storage import S3 7 | from diagrams.aws.database import DDB, DynamodbTable 8 | from diagrams.aws.security import Macie 9 | from diagrams.aws.integration import SF 10 | from diagrams.aws.ml import Translate 11 | 12 | import attr 13 | 14 | name = os.path.splitext(os.path.basename(__file__))[0] 15 | name_human = name.replace("_", " ").capitalize() 16 | 17 | with Diagram(name_human, filename=name, show=False, graph_attr=attr.graph): 18 | sf_main = SF("Main") 19 | sf_translate = SF("Translate") 20 | translate = Translate("Amazon Translate") 21 | 22 | db_jobs = DDB("Jobs") 23 | content = S3("Content") 24 | 25 | DynamodbTable("Table Stream") >> sf_main 26 | 27 | sf_main >> sf_translate 28 | sf_translate >> translate 29 | sf_translate >> db_jobs 30 | sf_translate >> content 31 | -------------------------------------------------------------------------------- /docs/hugo.yaml: -------------------------------------------------------------------------------- 1 | baseURL: https://aws-samples.github.io/document-translation/ 2 | languageCode: en-gb 3 | title: Document Transformation 4 | 5 | module: 6 | imports: 7 | - path: github.com/imfing/hextra 8 | 9 | params: 10 | navbar: 11 | displayTitle: true 12 | displayLogo: false 13 | editURL: 14 | enable: true 15 | base: "https://github.com/aws-samples/document-translation/tree/main/docs" 16 | page: 17 | width: wide 18 | 19 | markup: 20 | goldmark: 21 | renderer: 22 | unsafe: true 23 | 24 | menu: 25 | main: 26 | - name: Installation 27 | pageRef: /docs/installation/ 28 | weight: 1 29 | - name: FAQ 30 | pageRef: /docs/faq/ 31 | weight: 2 32 | - name: Documentation 33 | pageRef: /docs/ 34 | weight: 3 35 | # Push to end 36 | - name: Search 37 | weight: 98 38 | params: 39 | type: search 40 | - name: GitHub 41 | weight: 99 42 | url: "https://github.com/aws-samples/document-translation" 43 | params: 44 | icon: github -------------------------------------------------------------------------------- /docs/content/docs/translation/architecture/step-functions/main.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Main 3 | weight: 1 4 | --- 5 | 6 | 10 | 11 | The Main StepFuction is triggered by the DynamoDB Job table stream when a new job is created. This StepFunction orchestrates the task specific StepFunctions. 12 | 13 | ![Main StepFunction Overview](/diagrams/stepfunction_main_overview.png) 14 | 15 | The Translate job is created by the Main StepFunction. Whilst it is processing the Main StepFunction is paused and waits for a callback. This callback token is stored within the DB. 16 | 17 | When Translate completes the translation it will push the translated document into the S3 bucket. An S3 event notification triggers a Lambda function to parse the notification and start the Callback StepFunction. The responsibility of the Lambda function is to determine the job id that relates to this output document. 18 | 19 | ![Translate Workflow](/diagrams/translate_workflow.png) -------------------------------------------------------------------------------- /website/src/App.tsx: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | import React from "react"; 4 | import { Suspense } from "react"; 5 | 6 | import { AppLayout } from "@cloudscape-design/components"; 7 | 8 | import { useFederatedSignIn } from "./hooks/useFederatedSignIn"; 9 | 10 | import { amplifyConfigure } from "./util/amplifyConfigure"; 11 | import "./util/i18n"; 12 | 13 | import AppRoutes from "./appRoutes"; 14 | import Footer from "./page/partial/footer"; 15 | import SideNavigation from "./page/partial/sideNavigation"; 16 | import TopNavigation from "./page/partial/topNavigation"; 17 | 18 | export default function App() { 19 | amplifyConfigure(); 20 | const currentUser = useFederatedSignIn(); 21 | 22 | return ( 23 | <> 24 | 25 | 26 | } 28 | toolsHide 29 | content={} 30 | > 31 |