-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathcreate-schema-mapping.js
More file actions
75 lines (67 loc) · 1.82 KB
/
create-schema-mapping.js
File metadata and controls
75 lines (67 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// snippet-start:[entity-resolution.JavaScriptv3.create-schema-mapping]
//The default inputs for this demo are read from the ../inputs.json.
import { fileURLToPath } from "node:url";
import {
CreateSchemaMappingCommand,
EntityResolutionClient,
} from "@aws-sdk/client-entityresolution";
import data from "../inputs.json" with { type: "json" };
const region = "eu-west-1";
const erClient = new EntityResolutionClient({ region: region });
export const main = async () => {
const createSchemaMappingParamsJson = {
schemaName: `${data.inputs.schemaNameJson}`,
mappedInputFields: [
{
fieldName: "id",
type: "UNIQUE_ID",
},
{
fieldName: "name",
type: "NAME",
},
{
fieldName: "email",
type: "EMAIL_ADDRESS",
},
],
};
const createSchemaMappingParamsCSV = {
schemaName: `${data.inputs.schemaNameCSV}`,
mappedInputFields: [
{
fieldName: "id",
type: "UNIQUE_ID",
},
{
fieldName: "name",
type: "NAME",
},
{
fieldName: "email",
type: "EMAIL_ADDRESS",
},
{
fieldName: "phone",
type: "PROVIDER_ID",
subType: "STRING",
},
],
};
try {
const command = new CreateSchemaMappingCommand(
createSchemaMappingParamsJson,
);
const response = await erClient.send(command);
console.log("The JSON schema mapping name is ", response.schemaName);
} catch (error) {
console.log("error ", error.message);
}
};
// snippet-end:[entity-resolution.JavaScriptv3.create-schema-mapping]
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main();
}