Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint-javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: "20.x"
node-version: "22.x"
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: npm i --prefix javascriptv3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"bootstrap": "^5.0.0-beta3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"react-scripts": "5.0.0",
"web-vitals": "^1.1.1"
},
"scripts": {
Expand All @@ -31,10 +31,13 @@
]
},
"devDependencies": {
"canvas": "^2.7.0",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.8.3"
"@testing-library/user-event": "^12.8.3",
"canvas": "^3.0.1"
},
"type": "module"
"type": "module",
"engines": {
"node": ">=22 <23"
}
}
18 changes: 16 additions & 2 deletions javascriptv3/example_code/cross-services/textract-react/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,19 @@ Resources:
textractcognitodemoidtextractcognitodemodomainEBB6899F:
Type: AWS::Cognito::UserPoolDomain
Properties:
Domain: textract-demo
Domain:
Fn::Join:
- '-'
- - textract-react
- Fn::Select:
- 4
- Fn::Split:
- '-'
- Fn::Select:
- 2
- Fn::Split:
- /
- Ref: AWS::StackId
UserPoolId:
Ref: textractcognitodemoidA350B90F
Metadata:
Expand Down Expand Up @@ -332,7 +344,9 @@ Outputs:
Value:
Fn::Join:
- ""
- - https://textract-demo.auth.
- - https://
- Ref: textractcognitodemoidtextractcognitodemodomainEBB6899F
- .auth.
- Ref: AWS::Region
- .amazoncognito.com/login?client_id=
- Ref: textractcognitodemoidtextractcognitodemoclientidB9ABA9D2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

import React, { useState, useEffect } from "react";
import { ImageLoader } from "./ImageLoader";
import { ImageDisplay } from "./ImageDisplay";
import { ExtractButtons } from "./ExtractButtons";
import { ExplorerCard } from "./ExplorerCard";
import { LoginCard } from "./LoginCard";
import { ImageLoader } from "./ImageLoader.js";
import { ImageDisplay } from "./ImageDisplay.js";
import { ExtractButtons } from "./ExtractButtons.js";
import { ExplorerCard } from "./ExplorerCard.js";
import { LoginCard } from "./LoginCard.js";

/**
* Main React application element. Includes panels for signing in, loading and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

export const Config = {
ConfigError:
"Demo resources not initialized. You must deploy AWS resources and demo elements before running this application. See the README for details.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import React, { useRef } from "react";
import { ExplorerTree } from "./ExplorerTree";
import { ExplorerTree } from "./ExplorerTree.js";

/**
* Displays output from Amazon Textract as a hierarchical tree of checkboxes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import React from "react";
import { ColorMap, FilterMap } from "./Utils";
import { ColorMap, FilterMap } from "./Utils.js";

/**
* An individual node that displays a block item from Amazon Textract as a checkbox.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import React, { useRef, useLayoutEffect } from "react";
import { ColorMap } from "./Utils";
import { ColorMap } from "./Utils.js";

/**
* Displays a PNG image formatted as a Base64 string and draws polygons on top of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import "bootstrap/dist/css/bootstrap.css";
import React from "react";
import ReactDOM from "react-dom";
import { Config } from "./Config";
import { awsFactory } from "./AwsFactory";
import App from "./App";
import TextractModel from "./TextractModel";
import { Config } from "./Config.js";
import { awsFactory } from "./AwsFactory.js";
import App from "./App.js";
import TextractModel from "./TextractModel.js";

const params = new URLSearchParams(window.location.hash.slice(1));
const idToken = params.get("id_token");
Expand Down
5 changes: 4 additions & 1 deletion javascriptv3/example_code/s3/tests/copy-object.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ describe("copy-object", () => {
});

it("should log a relevant error message if the object is in an archive tier", async () => {
send.mockRejectedValue(new ObjectNotInActiveTierError());
const error = new ObjectNotInActiveTierError();
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
send.mockRejectedValue(error);

const spy = vi.spyOn(console, "error");

Expand Down
4 changes: 4 additions & 0 deletions javascriptv3/example_code/s3/tests/create-bucket.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe("create-bucket", () => {

it("should log a relevant error message if a bucket already exists globally", async () => {
const error = new BucketAlreadyExists();
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
send.mockRejectedValue(error);

const spy = vi.spyOn(console, "error");
Expand All @@ -47,6 +49,8 @@ describe("create-bucket", () => {

it("should log a relevant error message if a bucket already exists in the users AWS account", async () => {
const error = new BucketAlreadyOwnedByYou();
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
send.mockRejectedValue(error);

const spy = vi.spyOn(console, "error");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe("delete-bucket-policy", () => {

it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -48,6 +50,8 @@ describe("delete-bucket-policy", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const { main } = await import("../actions/delete-bucket-website.js");
describe("delete-bucket-website", () => {
it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -36,6 +38,8 @@ describe("delete-bucket-website", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
4 changes: 4 additions & 0 deletions javascriptv3/example_code/s3/tests/delete-bucket.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe("delete-bucket", () => {

it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
send.mockRejectedValueOnce(error);

Expand All @@ -45,6 +47,8 @@ describe("delete-bucket", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
send.mockRejectedValueOnce(error);

Expand Down
4 changes: 4 additions & 0 deletions javascriptv3/example_code/s3/tests/delete-object.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe("delete-object", () => {

it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -49,6 +51,8 @@ describe("delete-object", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ describe("delete-objects", () => {

it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -51,6 +53,8 @@ describe("delete-objects", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ describe("get-bucket-acl", () => {

it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -51,6 +53,8 @@ describe("get-bucket-acl", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ describe("get-bucket-cors", () => {

it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -64,6 +66,8 @@ describe("get-bucket-cors", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe("get-bucket-policy", () => {

it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -48,6 +50,8 @@ describe("get-bucket-policy", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ describe("get-bucket-website", () => {

it("should log a relevant error when the bucket isn't configured as a website.", async () => {
const error = new S3ServiceException("Not such website configuration.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchWebsiteConfiguration";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -53,6 +55,8 @@ describe("get-bucket-website", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe("get-object-lock-configuration", () => {

it("should log a relevant error when the bucket doesn't exist", async () => {
const error = new S3ServiceException("The specified bucket does not exist");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "NoSuchBucket";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand All @@ -48,6 +50,8 @@ describe("get-object-lock-configuration", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
send.mockRejectedValueOnce(error);
Expand Down
7 changes: 6 additions & 1 deletion javascriptv3/example_code/s3/tests/get-object.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ describe("get-object", () => {
it("should log a relevant error message when the object key doesn't exist in the bucket", async () => {
const bucketName = "amzn-s3-demo-bucket";
const key = "foo";
send.mockRejectedValueOnce(new NoSuchKey());
const error = new NoSuchKey();
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
send.mockRejectedValueOnce(error);

const spy = vi.spyOn(console, "error");

Expand All @@ -51,6 +54,8 @@ describe("get-object", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
const key = "foo";
Expand Down
2 changes: 2 additions & 0 deletions javascriptv3/example_code/s3/tests/list-buckets.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe("list-buckets", () => {

it("should indicate a failure came from S3 when the error isn't generic", async () => {
const error = new S3ServiceException("Some S3 service exception.");
error.$fault = "server"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.$metadata = "metadata"; // Workaround until PR is released. https://github.com/smithy-lang/smithy-typescript/pull/1503
error.name = "ServiceException";
const bucketName = "amzn-s3-demo-bucket";
paginateListBuckets.mockImplementationOnce(
Expand Down
Loading
Loading