Skip to content

Commit 4fda5cc

Browse files
committed
add initial files
1 parent ef08871 commit 4fda5cc

26 files changed

+274
-27
lines changed

javascriptv3/example_code/location-services/actions/batch-update-device-position.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const updateDevicePosParams = {
2121
},
2222
],
2323
};
24-
async function main() {
24+
export const main = async () => {
2525
try {
2626
const command = new BatchUpdateDevicePositionCommand(updateDevicePosParams);
2727
const response = await locationClient.send(command);
@@ -34,7 +34,7 @@ async function main() {
3434
} catch (error) {
3535
console.log("error ", error);
3636
}
37-
}
37+
};
3838

3939
// snippet-end:[location.JavaScript.device.batchUpdatePositionV3]
4040

javascriptv3/example_code/location-services/actions/calculate-distance-async.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import data from "./inputs.json" with { type: "json" };
1313
const region = "eu-west-1";
1414
const locationClient = new LocationClient({ region: region });
1515

16-
async function main() {
16+
export const main = async () => {
1717
const routeCalcParams = {
1818
CalculatorName: `${data.inputs.calculatorName}`,
1919
DeparturePosition: [-122.3321, 47.6062],
@@ -37,7 +37,7 @@ async function main() {
3737
return;
3838
}
3939
}
40-
}
40+
};
4141

4242
// snippet-end:[location.JavaScript.distance.createDistAsyncV3]
4343

javascriptv3/example_code/location-services/actions/calculate-route.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const calculateRouteParams = {
1919
TravelMode: "Car",
2020
DistanceUnit: "Kilometers",
2121
};
22-
async function main() {
22+
export const main = async () => {
2323
try {
2424
const command = new CalculateRouteCommand(calculateRouteParams);
2525
const response = await locationClient.send(command);
@@ -36,7 +36,7 @@ async function main() {
3636
return;
3737
}
3838
}
39-
}
39+
};
4040

4141
// snippet-end:[location.JavaScript.CalculateRouteV3]
4242

javascriptv3/example_code/location-services/actions/create-geofence-collection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import data from "./inputs.json" with { type: "json" };
1212

1313
const region = "eu-west-1";
1414

15-
async function main() {
15+
export const main = async () => {
1616
const geoFenceCollParams = {
1717
CollectionName: `${data.inputs.collectionName}`,
1818
};
@@ -30,7 +30,7 @@ async function main() {
3030
return;
3131
}
3232
}
33-
}
33+
};
3434

3535
// snippet-end:[location.JavaScript.geofence.createCollectionV3]
3636

javascriptv3/example_code/location-services/actions/create-map.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import data from "./inputs.json" with { type: "json" };
88

99
const region = "eu-west-1";
1010

11-
async function main() {
11+
export const main = async () => {
1212
const CreateMapCommandInput = {
1313
MapName: `${data.inputs.mapName}`,
1414
Configuration: { style: "VectorEsriNavigation" },
@@ -22,7 +22,7 @@ async function main() {
2222
console.error("Error creating map: ", error);
2323
throw error;
2424
}
25-
}
25+
};
2626

2727
// snippet-end:[location.JavaScript.map.createMapV3]
2828

javascriptv3/example_code/location-services/actions/create-route-calculator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import data from "./inputs.json" with { type: "json" };
1313
const region = "eu-west-1";
1414
const locationClient = new LocationClient({ region: region });
1515

16-
async function main() {
16+
export const main = async () => {
1717
const routeCalcParams = {
1818
CalculatorName: `${data.inputs.calculatorName}`,
1919
DataSource: "Esri",
@@ -34,7 +34,7 @@ async function main() {
3434
return;
3535
}
3636
}
37-
}
37+
};
3838

3939
// snippet-end:[location.JavaScript.routes.createRouteCalcV3]
4040

javascriptv3/example_code/location-services/actions/create-tracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import data from "./inputs.json" with { type: "json" };
88

99
const region = "eu-west-1";
1010

11-
async function main() {
11+
export const main = async () => {
1212
const createTrackerParams = {
1313
TrackerName: `${data.inputs.trackerName}`,
1414
};
@@ -22,7 +22,7 @@ async function main() {
2222
console.error("Error creating map: ", error);
2323
throw error;
2424
}
25-
}
25+
};
2626

2727
// snippet-end:[location.JavaScript.tracker.createTrackerV3]
2828

javascriptv3/example_code/location-services/actions/delete-geofence-collection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import data from "./inputs.json" with { type: "json" };
1212

1313
const region = "eu-west-1";
1414

15-
async function main() {
15+
export const main = async () => {
1616
const deleteGeofenceCollParams = {
1717
CollectionName: `${data.inputs.collectionName}`,
1818
};
@@ -31,7 +31,7 @@ async function main() {
3131
return;
3232
}
3333
}
34-
}
34+
};
3535

3636
// snippet-end:[location.JavaScript.geofence.deleteCollectionV3]
3737

javascriptv3/example_code/location-services/actions/delete-map.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import data from "./inputs.json" with { type: "json" };
1212

1313
const region = "eu-west-1";
1414

15-
async function main() {
15+
export const main = async () => {
1616
const deleteMapParams = {
1717
MapName: `${data.inputs.mapName}`,
1818
};
@@ -27,7 +27,7 @@ async function main() {
2727
return;
2828
}
2929
}
30-
}
30+
};
3131

3232
// snippet-end:[location.JavaScript.geofence.deleteMapV3]
3333

javascriptv3/example_code/location-services/actions/delete-route-calculator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import data from "./inputs.json" with { type: "json" };
1212

1313
const region = "eu-west-1";
1414

15-
async function main() {
15+
export const main = async () => {
1616
const deleteRouteCalculatorParams = {
1717
CalculatorName: `${data.inputs.calculatorName}`,
1818
};
@@ -31,7 +31,7 @@ async function main() {
3131
return;
3232
}
3333
}
34-
}
34+
};
3535

3636
// snippet-end:[location.JavaScript.calculator.deleteRouteCalculatorV3]
3737

javascriptv3/example_code/location-services/actions/delete-tracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import data from "./inputs.json" with { type: "json" };
1212

1313
const region = "eu-west-1";
1414

15-
async function main() {
15+
export const main = async () => {
1616
const deleteTrackerParams = {
1717
TrackerName: `${data.inputs.trackerName}`,
1818
};
@@ -27,7 +27,7 @@ async function main() {
2727
return;
2828
}
2929
}
30-
}
30+
};
3131

3232
// snippet-end:[location.JavaScript.tracker.deleteTrackerV3]
3333

javascriptv3/example_code/location-services/actions/get-device-position.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import data from "./inputs.json" with { type: "json" };
1212

1313
const region = "eu-west-1";
1414

15-
async function main() {
15+
export const main = async () => {
1616
const locationClient = new LocationClient({ region: region });
1717
const deviceId = `${data.inputs.deviceId}`;
1818
const trackerName = `${data.inputs.trackerName}`;
@@ -37,7 +37,7 @@ async function main() {
3737
}
3838
return;*/
3939
}
40-
}
40+
};
4141

4242
// snippet-end:[location.JavaScript.position.getDevicePositionV3]
4343

javascriptv3/example_code/location-services/actions/put-geofence.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import data from "./inputs.json" with { type: "json" };
1212

1313
const region = "eu-west-1";
1414
const locationClient = new LocationClient({ region: region });
15-
async function main() {
15+
export const main = async () => {
1616
const geoFenceGeoParams = {
1717
CollectionName: `${data.inputs.collectionName}`,
1818
GeofenceId: `${data.inputs.geoId}`,
@@ -38,7 +38,7 @@ async function main() {
3838
);
3939
return;
4040
}
41-
}
41+
};
4242

4343
// snippet-end:[location.JavaScript.geofence.putV3]
4444

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { describe, it } from "vitest";
5+
import { main } from "../actions/batch-update-device-position.js";
6+
import data from "../actions/inputs.json";
7+
8+
describe("test batch-update-device-position", () => {
9+
it(
10+
"should not re-throw service exceptions",
11+
async () => {
12+
await main({
13+
TrackerName: `${data.inputs.trackerName}`,
14+
Updates: [
15+
{
16+
DeviceId: `${data.inputs.deviceId}`,
17+
SampleTime: new Date(),
18+
Position: [-122.4194, 37.7749],
19+
},
20+
],
21+
});
22+
},
23+
{ timeout: 600000 },
24+
);
25+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { describe, it } from "vitest";
5+
import { main } from "../actions/calculate-distance-async.js";
6+
import data from "../actions/inputs.json";
7+
8+
describe("test calculate-distance-async", () => {
9+
it(
10+
"should not re-throw service exceptions",
11+
async () => {
12+
await main({
13+
CalculatorName: `${data.inputs.calculatorName}`,
14+
DeparturePosition: [-122.3321, 47.6062],
15+
DestinationPosition: [-123.1216, 49.2827],
16+
TravelMode: "Car",
17+
DistanceUnit: "Kilometers",
18+
});
19+
},
20+
{ timeout: 600000 },
21+
);
22+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { describe, it } from "vitest";
5+
import { main } from "../actions/calculate-route.js";
6+
import data from "../actions/inputs.json";
7+
8+
describe("test calculate-route", () => {
9+
it(
10+
"should not re-throw service exceptions",
11+
async () => {
12+
await main({
13+
CalculatorName: `${data.inputs.calculatorName}`,
14+
DeparturePosition: [-122.3321, 47.6062],
15+
DestinationPosition: [-123.1216, 49.2827],
16+
TravelMode: "Car",
17+
DistanceUnit: "Kilometers",
18+
});
19+
},
20+
{ timeout: 600000 },
21+
);
22+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { describe, it } from "vitest";
5+
import { main } from "../actions/create-geofence-collection.js";
6+
import data from "../actions/inputs.json";
7+
8+
describe("test create-geofence-collection", () => {
9+
it(
10+
"should not re-throw service exceptions",
11+
async () => {
12+
await main({
13+
MapName: `${data.inputs.mapName}`,
14+
Configuration: { style: "VectorEsriNavigation" },
15+
});
16+
},
17+
{ timeout: 600000 },
18+
);
19+
});

javascriptv3/example_code/location-services/tests/create-map.integration.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { describe, it } from "vitest";
55
import { main } from "../actions/create-map.js";
66
import data from "../actions/inputs.json";
77

8-
describe("test copy-object-conditional-request-if-match", () => {
8+
describe("test create-map", () => {
99
it(
1010
"should not re-throw service exceptions",
1111
async () => {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { describe, it } from "vitest";
5+
import { main } from "../actions/create-route-calculator.js";
6+
import data from "../actions/inputs.json";
7+
8+
describe("test create-route-calculator", () => {
9+
it(
10+
"should not re-throw service exceptions",
11+
async () => {
12+
await main({
13+
CalculatorName: `${data.inputs.calculatorName}`,
14+
DataSource: "Esri",
15+
});
16+
},
17+
{ timeout: 600000 },
18+
);
19+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { describe, it } from "vitest";
5+
import { main } from "../actions/create-tracker.js";
6+
import data from "../actions/inputs.json";
7+
8+
describe("test create-tracker", () => {
9+
it(
10+
"should not re-throw service exceptions",
11+
async () => {
12+
await main({
13+
TrackerName: `${data.inputs.trackerName}`,
14+
});
15+
},
16+
{ timeout: 600000 },
17+
);
18+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { describe, it } from "vitest";
5+
import { main } from "../actions/delete-geofence-collection.js";
6+
import data from "../actions/inputs.json";
7+
8+
describe("test delete-geofence-collection", () => {
9+
it(
10+
"should not re-throw service exceptions",
11+
async () => {
12+
await main({
13+
CollectionName: `${data.inputs.collectionName}`,
14+
});
15+
},
16+
{ timeout: 600000 },
17+
);
18+
});

0 commit comments

Comments
 (0)