@transcend-io/cli 4.11.1 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -14
- package/build/cli-request-upload.d.ts +3 -0
- package/build/cli-request-upload.d.ts.map +1 -0
- package/build/cli-request-upload.js +57 -0
- package/build/cli-request-upload.js.map +1 -0
- package/build/codecs.d.ts +32 -0
- package/build/codecs.d.ts.map +1 -1
- package/build/graphql/fetchAllAttributeKeys.d.ts +15 -0
- package/build/graphql/fetchAllAttributeKeys.d.ts.map +1 -0
- package/build/graphql/fetchAllAttributeKeys.js +32 -0
- package/build/graphql/fetchAllAttributeKeys.js.map +1 -0
- package/build/graphql/gqls/attributeKey.d.ts +2 -0
- package/build/graphql/gqls/attributeKey.d.ts.map +1 -0
- package/build/graphql/gqls/attributeKey.js +19 -0
- package/build/graphql/gqls/attributeKey.js.map +1 -0
- package/build/graphql/gqls/enricher.d.ts +10 -0
- package/build/graphql/gqls/enricher.d.ts.map +1 -1
- package/build/graphql/gqls/enricher.js +11 -1
- package/build/graphql/gqls/enricher.js.map +1 -1
- package/build/graphql/gqls/index.d.ts +1 -0
- package/build/graphql/gqls/index.d.ts.map +1 -1
- package/build/graphql/gqls/index.js +1 -0
- package/build/graphql/gqls/index.js.map +1 -1
- package/build/graphql/index.d.ts +1 -0
- package/build/graphql/index.d.ts.map +1 -1
- package/build/graphql/index.js +1 -0
- package/build/graphql/index.js.map +1 -1
- package/build/requests/constants.d.ts +267 -1
- package/build/requests/constants.d.ts.map +1 -1
- package/build/requests/constants.js +85 -2
- package/build/requests/constants.js.map +1 -1
- package/build/requests/filterRows.d.ts +10 -0
- package/build/requests/filterRows.d.ts.map +1 -0
- package/build/requests/filterRows.js +61 -0
- package/build/requests/filterRows.js.map +1 -0
- package/build/requests/fuzzyMatchColumns.d.ts +3 -2
- package/build/requests/fuzzyMatchColumns.d.ts.map +1 -1
- package/build/requests/fuzzyMatchColumns.js +4 -2
- package/build/requests/fuzzyMatchColumns.js.map +1 -1
- package/build/requests/index.d.ts +12 -3
- package/build/requests/index.d.ts.map +1 -1
- package/build/requests/index.js +12 -3
- package/build/requests/index.js.map +1 -1
- package/build/requests/mapColumnsToAttributes.d.ts +20 -0
- package/build/requests/mapColumnsToAttributes.d.ts.map +1 -0
- package/build/requests/mapColumnsToAttributes.js +46 -0
- package/build/requests/mapColumnsToAttributes.js.map +1 -0
- package/build/requests/mapColumnsToIdentifiers.d.ts +20 -0
- package/build/requests/mapColumnsToIdentifiers.d.ts.map +1 -0
- package/build/requests/mapColumnsToIdentifiers.js +48 -0
- package/build/requests/mapColumnsToIdentifiers.js.map +1 -0
- package/build/requests/mapCsvColumnsToApi.d.ts +16 -0
- package/build/requests/mapCsvColumnsToApi.d.ts.map +1 -0
- package/build/requests/mapCsvColumnsToApi.js +44 -0
- package/build/requests/mapCsvColumnsToApi.js.map +1 -0
- package/build/requests/mapCsvRowsToRequestInputs.d.ts +68 -0
- package/build/requests/mapCsvRowsToRequestInputs.d.ts.map +1 -0
- package/build/requests/mapCsvRowsToRequestInputs.js +127 -0
- package/build/requests/mapCsvRowsToRequestInputs.js.map +1 -0
- package/build/requests/mapEnumValues.d.ts +14 -0
- package/build/requests/mapEnumValues.d.ts.map +1 -0
- package/build/requests/mapEnumValues.js +42 -0
- package/build/requests/mapEnumValues.js.map +1 -0
- package/build/requests/mapRequestEnumValues.d.ts +21 -0
- package/build/requests/mapRequestEnumValues.d.ts.map +1 -0
- package/build/requests/mapRequestEnumValues.js +46 -0
- package/build/requests/mapRequestEnumValues.js.map +1 -0
- package/build/requests/submitPrivacyRequest.d.ts +5468 -0
- package/build/requests/submitPrivacyRequest.d.ts.map +1 -0
- package/build/requests/submitPrivacyRequest.js +98 -0
- package/build/requests/submitPrivacyRequest.js.map +1 -0
- package/build/requests/tests/mapCsvRowsToRequestInputs.test.d.ts +1 -0
- package/build/requests/tests/mapCsvRowsToRequestInputs.test.d.ts.map +1 -0
- package/build/requests/tests/mapCsvRowsToRequestInputs.test.js +3 -0
- package/build/requests/tests/mapCsvRowsToRequestInputs.test.js.map +1 -0
- package/build/requests/uploadPrivacyRequestsFromCsv.d.ts +32 -0
- package/build/requests/uploadPrivacyRequestsFromCsv.d.ts.map +1 -0
- package/build/requests/uploadPrivacyRequestsFromCsv.js +139 -0
- package/build/requests/uploadPrivacyRequestsFromCsv.js.map +1 -0
- package/build/tsbuildinfo +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
+
import { CachedFileState } from './constants';
|
|
3
|
+
/**
|
|
4
|
+
* Mapping from identifier name to request input parameter
|
|
5
|
+
*/
|
|
6
|
+
export declare type IdentifierNameMap = {
|
|
7
|
+
[k in string]: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Create a mapping from the identifier names that can be included
|
|
11
|
+
* at request submission, to the names of the columns that map to those
|
|
12
|
+
* identifiers.
|
|
13
|
+
*
|
|
14
|
+
* @param client - GraphQL client
|
|
15
|
+
* @param columnNames - The set of all column names
|
|
16
|
+
* @param cached - Cached state of this mapping
|
|
17
|
+
* @returns Mapping from identifier name to column name
|
|
18
|
+
*/
|
|
19
|
+
export declare function mapColumnsToIdentifiers(client: GraphQLClient, columnNames: string[], cached: CachedFileState): Promise<IdentifierNameMap>;
|
|
20
|
+
//# sourceMappingURL=mapColumnsToIdentifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapColumnsToIdentifiers.d.ts","sourceRoot":"","sources":["../../src/requests/mapColumnsToIdentifiers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,oBAAY,iBAAiB,GAAG;KAC7B,CAAC,IAAI,MAAM,GAAG,MAAM;CACtB,CAAC;AAKF;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,MAAM,EAAE,EACrB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAwC5B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mapColumnsToIdentifiers = void 0;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
const graphql_1 = require("../graphql");
|
|
9
|
+
const fuzzyMatchColumns_1 = require("./fuzzyMatchColumns");
|
|
10
|
+
/** These are uploaded at the top level of the request */
|
|
11
|
+
const IDENTIFIER_BLOCK_LIST = ['email', 'coreIdentifier'];
|
|
12
|
+
/**
|
|
13
|
+
* Create a mapping from the identifier names that can be included
|
|
14
|
+
* at request submission, to the names of the columns that map to those
|
|
15
|
+
* identifiers.
|
|
16
|
+
*
|
|
17
|
+
* @param client - GraphQL client
|
|
18
|
+
* @param columnNames - The set of all column names
|
|
19
|
+
* @param cached - Cached state of this mapping
|
|
20
|
+
* @returns Mapping from identifier name to column name
|
|
21
|
+
*/
|
|
22
|
+
async function mapColumnsToIdentifiers(client, columnNames, cached) {
|
|
23
|
+
// Grab the initializer
|
|
24
|
+
const { initializer } = await (0, graphql_1.makeGraphQLRequest)(client, graphql_1.INITIALIZER);
|
|
25
|
+
// Determine the columns that should be mapped
|
|
26
|
+
const columnQuestions = initializer.identifiers.filter(({ name }) => !cached.identifierNames[name] && !IDENTIFIER_BLOCK_LIST.includes(name));
|
|
27
|
+
// Skip mapping when everything is mapped
|
|
28
|
+
const identifierNameMap = columnQuestions.length === 0
|
|
29
|
+
? {}
|
|
30
|
+
: // prompt questions to map columns
|
|
31
|
+
await inquirer_1.default.prompt(columnQuestions.map(({ name }) => {
|
|
32
|
+
const matches = (0, fuzzyMatchColumns_1.fuzzyMatchColumns)(columnNames, name, false);
|
|
33
|
+
return {
|
|
34
|
+
name,
|
|
35
|
+
message: `Choose the column that will be used to map in the identifier: ${name}`,
|
|
36
|
+
type: 'list',
|
|
37
|
+
default: matches[0],
|
|
38
|
+
choices: matches,
|
|
39
|
+
};
|
|
40
|
+
}));
|
|
41
|
+
Object.entries(identifierNameMap).forEach(([k, v]) => {
|
|
42
|
+
// eslint-disable-next-line no-param-reassign
|
|
43
|
+
cached.identifierNames[k] = v;
|
|
44
|
+
});
|
|
45
|
+
return identifierNameMap;
|
|
46
|
+
}
|
|
47
|
+
exports.mapColumnsToIdentifiers = mapColumnsToIdentifiers;
|
|
48
|
+
//# sourceMappingURL=mapColumnsToIdentifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapColumnsToIdentifiers.js","sourceRoot":"","sources":["../../src/requests/mapColumnsToIdentifiers.ts"],"names":[],"mappings":";;;;;;AACA,wDAAgC;AAChC,wCAA0E;AAE1E,2DAAwD;AASxD,yDAAyD;AACzD,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAE1D;;;;;;;;;GASG;AACI,KAAK,UAAU,uBAAuB,CAC3C,MAAqB,EACrB,WAAqB,EACrB,MAAuB;IAEvB,uBAAuB;IACvB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,4BAAkB,EAG7C,MAAM,EAAE,qBAAW,CAAC,CAAC;IAExB,8CAA8C;IAC9C,MAAM,eAAe,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CACpD,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CACX,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,CACzE,CAAC;IAEF,yCAAyC;IACzC,MAAM,iBAAiB,GACrB,eAAe,CAAC,MAAM,KAAK,CAAC;QAC1B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,kCAAkC;YAClC,MAAM,kBAAQ,CAAC,MAAM,CAKnB,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC/B,MAAM,OAAO,GAAG,IAAA,qCAAiB,EAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;gBAC5D,OAAO;oBACL,IAAI;oBACJ,OAAO,EAAE,iEAAiE,IAAI,EAAE;oBAChF,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;oBACnB,OAAO,EAAE,OAAO;iBACjB,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;IACR,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QACnD,6CAA6C;QAC7C,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AA5CD,0DA4CC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ColumnName, CachedFileState } from './constants';
|
|
2
|
+
/**
|
|
3
|
+
* Mapping from column name to request input parameter
|
|
4
|
+
*/
|
|
5
|
+
export declare type ColumnNameMap = {
|
|
6
|
+
[k in ColumnName]?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Determine the mapping between columns in CSV
|
|
10
|
+
*
|
|
11
|
+
* @param columnNames - The set of column names
|
|
12
|
+
* @param cached - The cached file state used to map DSR inputs
|
|
13
|
+
* @returns The column name mapping
|
|
14
|
+
*/
|
|
15
|
+
export declare function mapCsvColumnsToApi(columnNames: string[], cached: CachedFileState): Promise<ColumnNameMap>;
|
|
16
|
+
//# sourceMappingURL=mapCsvColumnsToApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapCsvColumnsToApi.d.ts","sourceRoot":"","sources":["../../src/requests/mapCsvColumnsToApi.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,eAAe,EAGhB,MAAM,aAAa,CAAC;AAGrB;;GAEG;AACH,oBAAY,aAAa,GAAG;KACzB,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,MAAM;CAC3B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EAAE,EACrB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,aAAa,CAAC,CAuCxB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mapCsvColumnsToApi = void 0;
|
|
7
|
+
const type_utils_1 = require("@transcend-io/type-utils");
|
|
8
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
9
|
+
const startCase_1 = __importDefault(require("lodash/startCase"));
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
const fuzzyMatchColumns_1 = require("./fuzzyMatchColumns");
|
|
12
|
+
/**
|
|
13
|
+
* Determine the mapping between columns in CSV
|
|
14
|
+
*
|
|
15
|
+
* @param columnNames - The set of column names
|
|
16
|
+
* @param cached - The cached file state used to map DSR inputs
|
|
17
|
+
* @returns The column name mapping
|
|
18
|
+
*/
|
|
19
|
+
async function mapCsvColumnsToApi(columnNames, cached) {
|
|
20
|
+
// Determine the columns that should be mapped
|
|
21
|
+
const columnQuestions = (0, type_utils_1.getValues)(constants_1.ColumnName).filter((name) => !cached.columnNames[name]);
|
|
22
|
+
// Skip mapping when everything is mapped
|
|
23
|
+
const columnNameMap = columnQuestions.length === 0
|
|
24
|
+
? {}
|
|
25
|
+
: // prompt questions to map columns
|
|
26
|
+
await inquirer_1.default.prompt(columnQuestions.map((name) => {
|
|
27
|
+
const field = (0, startCase_1.default)(name.replace('ColumnName', ''));
|
|
28
|
+
const matches = (0, fuzzyMatchColumns_1.fuzzyMatchColumns)(columnNames, field, constants_1.IS_REQUIRED[name], !!constants_1.CAN_APPLY_IN_BULK[name]);
|
|
29
|
+
return {
|
|
30
|
+
name,
|
|
31
|
+
message: `Choose the column that will be used to map in the field: ${field}`,
|
|
32
|
+
type: 'list',
|
|
33
|
+
default: matches[0],
|
|
34
|
+
choices: matches,
|
|
35
|
+
};
|
|
36
|
+
}));
|
|
37
|
+
(0, type_utils_1.getEntries)(columnNameMap).forEach(([k, v]) => {
|
|
38
|
+
// eslint-disable-next-line no-param-reassign
|
|
39
|
+
cached.columnNames[k] = v;
|
|
40
|
+
});
|
|
41
|
+
return columnNameMap;
|
|
42
|
+
}
|
|
43
|
+
exports.mapCsvColumnsToApi = mapCsvColumnsToApi;
|
|
44
|
+
//# sourceMappingURL=mapCsvColumnsToApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapCsvColumnsToApi.js","sourceRoot":"","sources":["../../src/requests/mapCsvColumnsToApi.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAiE;AACjE,wDAAgC;AAChC,iEAAyC;AACzC,2CAKqB;AACrB,2DAAwD;AASxD;;;;;;GAMG;AACI,KAAK,UAAU,kBAAkB,CACtC,WAAqB,EACrB,MAAuB;IAEvB,8CAA8C;IAC9C,MAAM,eAAe,GAAG,IAAA,sBAAS,EAAC,sBAAU,CAAC,CAAC,MAAM,CAClD,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CACpC,CAAC;IAEF,yCAAyC;IACzC,MAAM,aAAa,GACjB,eAAe,CAAC,MAAM,KAAK,CAAC;QAC1B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,kCAAkC;YAClC,MAAM,kBAAQ,CAAC,MAAM,CAKnB,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC3B,MAAM,KAAK,GAAG,IAAA,mBAAS,EAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;gBACxD,MAAM,OAAO,GAAG,IAAA,qCAAiB,EAC/B,WAAW,EACX,KAAK,EACL,uBAAW,CAAC,IAAI,CAAC,EACjB,CAAC,CAAC,6BAAiB,CAAC,IAAI,CAAC,CAC1B,CAAC;gBACF,OAAO;oBACL,IAAI;oBACJ,OAAO,EAAE,4DAA4D,KAAK,EAAE;oBAC5E,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;oBACnB,OAAO,EAAE,OAAO;iBACjB,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;IAER,IAAA,uBAAU,EAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QAC3C,6CAA6C;QAC7C,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,OAAO,aAAa,CAAC;AACvB,CAAC;AA1CD,gDA0CC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { LanguageKey } from '@transcend-io/internationalization';
|
|
2
|
+
import { CompletedRequestStatus, RequestAction, IdentifierType } from '@transcend-io/privacy-types';
|
|
3
|
+
import { ObjByString } from '@transcend-io/type-utils';
|
|
4
|
+
import { CachedFileState } from './constants';
|
|
5
|
+
import { ColumnNameMap } from './mapCsvColumnsToApi';
|
|
6
|
+
import type { AttributeInput } from './parseAttributesFromString';
|
|
7
|
+
import { AttributeNameMap } from './mapColumnsToAttributes';
|
|
8
|
+
import { IdentifierNameMap } from './mapColumnsToIdentifiers';
|
|
9
|
+
/**
|
|
10
|
+
* Shape of additional identifiers
|
|
11
|
+
*/
|
|
12
|
+
export declare type AttestedExtraIdentifiers = {
|
|
13
|
+
[k in IdentifierType]?: {
|
|
14
|
+
/** Name of identifier */
|
|
15
|
+
name?: string;
|
|
16
|
+
/** Value of identifier */
|
|
17
|
+
value: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
export interface PrivacyRequestInput {
|
|
21
|
+
/** Email of user */
|
|
22
|
+
email: string;
|
|
23
|
+
/** Extra identifiers */
|
|
24
|
+
attestedExtraIdentifiers: AttestedExtraIdentifiers;
|
|
25
|
+
/** Core identifier for user */
|
|
26
|
+
coreIdentifier: string;
|
|
27
|
+
/** Action type being submitted */
|
|
28
|
+
requestType: RequestAction;
|
|
29
|
+
/** Type of data subject */
|
|
30
|
+
subjectType: string;
|
|
31
|
+
/** Attribute inputs */
|
|
32
|
+
attributes?: AttributeInput[];
|
|
33
|
+
/** The status that the request should be created as */
|
|
34
|
+
status?: CompletedRequestStatus;
|
|
35
|
+
/** The time that the request was created */
|
|
36
|
+
createdAt?: Date;
|
|
37
|
+
/** Data silo IDs to submit for */
|
|
38
|
+
dataSiloIds?: string[];
|
|
39
|
+
/** Language key to map to */
|
|
40
|
+
locale?: LanguageKey;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Transform the identifier value based on type
|
|
44
|
+
*
|
|
45
|
+
* @param identifierValue - Value of identifier
|
|
46
|
+
* @param identifierType - Type of identifier
|
|
47
|
+
* @returns Post-processed identifier
|
|
48
|
+
*/
|
|
49
|
+
export declare function normalizeIdentifierValue(identifierValue: string, identifierType: IdentifierType): string;
|
|
50
|
+
/**
|
|
51
|
+
* Take the raw rows in a CSV upload, and map those rows to the request
|
|
52
|
+
* input shape that can be passed to the Transcend API to submit a privacy
|
|
53
|
+
* request.
|
|
54
|
+
*
|
|
55
|
+
* @param requestInputs - CSV of requests to be uploaded
|
|
56
|
+
* @param cached - The cached set of mapping values
|
|
57
|
+
* @param options - Options
|
|
58
|
+
* @returns [raw input, request input] list
|
|
59
|
+
*/
|
|
60
|
+
export declare function mapCsvRowsToRequestInputs(requestInputs: ObjByString[], cached: CachedFileState, { columnNameMap, identifierNameMap, attributeNameMap, }: {
|
|
61
|
+
/** Mapping of column names */
|
|
62
|
+
columnNameMap: ColumnNameMap;
|
|
63
|
+
/** Mapping of identifier names */
|
|
64
|
+
identifierNameMap: IdentifierNameMap;
|
|
65
|
+
/** Mapping of attribute names */
|
|
66
|
+
attributeNameMap: AttributeNameMap;
|
|
67
|
+
}): [Record<string, string>, PrivacyRequestInput][];
|
|
68
|
+
//# sourceMappingURL=mapCsvRowsToRequestInputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapCsvRowsToRequestInputs.d.ts","sourceRoot":"","sources":["../../src/requests/mapCsvRowsToRequestInputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAEL,sBAAsB,EACtB,aAAa,EACb,cAAc,EACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,eAAe,EAKhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;GAEG;AACH,oBAAY,wBAAwB,GAAG;KACpC,CAAC,IAAI,cAAc,CAAC,CAAC,EAAE;QACtB,yBAAyB;QACzB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,0BAA0B;QAC1B,KAAK,EAAE,MAAM,CAAC;KACf,EAAE;CACJ,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,+BAA+B;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,mCAAmC;IACnC,WAAW,EAAE,aAAa,CAAC;IAC3B,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B,uDAAuD;IACvD,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,cAAc,GAC7B,MAAM,CAaR;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,WAAW,EAAE,EAC5B,MAAM,EAAE,eAAe,EACvB,EACE,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GACjB,EAAE;IACD,8BAA8B;IAC9B,aAAa,EAAE,aAAa,CAAC;IAC7B,kCAAkC;IAClC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,iCAAiC;IACjC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,GACA,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC,EAAE,CA2GjD"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapCsvRowsToRequestInputs = exports.normalizeIdentifierValue = void 0;
|
|
4
|
+
const privacy_types_1 = require("@transcend-io/privacy-types");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const splitCsvToList_1 = require("./splitCsvToList");
|
|
7
|
+
/**
|
|
8
|
+
* Transform the identifier value based on type
|
|
9
|
+
*
|
|
10
|
+
* @param identifierValue - Value of identifier
|
|
11
|
+
* @param identifierType - Type of identifier
|
|
12
|
+
* @returns Post-processed identifier
|
|
13
|
+
*/
|
|
14
|
+
function normalizeIdentifierValue(identifierValue, identifierType) {
|
|
15
|
+
// Lowercase email
|
|
16
|
+
if (identifierType === privacy_types_1.IdentifierType.Email) {
|
|
17
|
+
return identifierValue.toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
// Normalize phone number
|
|
20
|
+
if (identifierType === privacy_types_1.IdentifierType.Phone) {
|
|
21
|
+
return identifierValue
|
|
22
|
+
.replace(privacy_types_1.NORMALIZE_PHONE_NUMBER, '')
|
|
23
|
+
.replace(/[A-Za-z]/g, '');
|
|
24
|
+
}
|
|
25
|
+
return identifierValue;
|
|
26
|
+
}
|
|
27
|
+
exports.normalizeIdentifierValue = normalizeIdentifierValue;
|
|
28
|
+
/**
|
|
29
|
+
* Take the raw rows in a CSV upload, and map those rows to the request
|
|
30
|
+
* input shape that can be passed to the Transcend API to submit a privacy
|
|
31
|
+
* request.
|
|
32
|
+
*
|
|
33
|
+
* @param requestInputs - CSV of requests to be uploaded
|
|
34
|
+
* @param cached - The cached set of mapping values
|
|
35
|
+
* @param options - Options
|
|
36
|
+
* @returns [raw input, request input] list
|
|
37
|
+
*/
|
|
38
|
+
function mapCsvRowsToRequestInputs(requestInputs, cached, { columnNameMap, identifierNameMap, attributeNameMap, }) {
|
|
39
|
+
// map the CSV to request input
|
|
40
|
+
const getMappedName = (attribute) => cached.columnNames[attribute] || columnNameMap[attribute];
|
|
41
|
+
return requestInputs.map((input) => {
|
|
42
|
+
// The extra identifiers to upload for this request
|
|
43
|
+
const attestedExtraIdentifiers = {};
|
|
44
|
+
Object.entries(identifierNameMap)
|
|
45
|
+
// filter out skipped identifiers
|
|
46
|
+
.filter(([, columnName]) => columnName !== constants_1.NONE)
|
|
47
|
+
.forEach(([identifierName, columnName]) => {
|
|
48
|
+
// Determine the identifier type being specified
|
|
49
|
+
const identifierType = Object.values(privacy_types_1.IdentifierType).includes(identifierName)
|
|
50
|
+
? identifierName
|
|
51
|
+
: privacy_types_1.IdentifierType.Custom;
|
|
52
|
+
// Only add the identifier if the value exists
|
|
53
|
+
const identifierValue = input[columnName];
|
|
54
|
+
if (identifierValue) {
|
|
55
|
+
// Initialize
|
|
56
|
+
if (!attestedExtraIdentifiers[identifierType]) {
|
|
57
|
+
attestedExtraIdentifiers[identifierType] = [];
|
|
58
|
+
}
|
|
59
|
+
// Add the identifier
|
|
60
|
+
attestedExtraIdentifiers[identifierType].push({
|
|
61
|
+
value: normalizeIdentifierValue(identifierValue, identifierType),
|
|
62
|
+
name: identifierName,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// The extra attributes to upload for this request
|
|
67
|
+
const attributes = [];
|
|
68
|
+
Object.entries(attributeNameMap)
|
|
69
|
+
// filter out skipped attributes
|
|
70
|
+
.filter(([, columnName]) => columnName !== constants_1.NONE)
|
|
71
|
+
.forEach(([attributeName, columnName]) => {
|
|
72
|
+
// Only add the identifier if the value exists
|
|
73
|
+
const attributeValueString = input[columnName];
|
|
74
|
+
if (attributeValueString) {
|
|
75
|
+
// Add the attribute
|
|
76
|
+
attributes.push({
|
|
77
|
+
values: (0, splitCsvToList_1.splitCsvToList)(attributeValueString),
|
|
78
|
+
key: attributeName,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const requestTypeColumn = getMappedName(constants_1.ColumnName.RequestType);
|
|
83
|
+
const dataSubjectTypeColumn = getMappedName(constants_1.ColumnName.SubjectType);
|
|
84
|
+
return [
|
|
85
|
+
input,
|
|
86
|
+
{
|
|
87
|
+
email: input[getMappedName(constants_1.ColumnName.Email)],
|
|
88
|
+
attestedExtraIdentifiers,
|
|
89
|
+
attributes,
|
|
90
|
+
coreIdentifier: input[getMappedName(constants_1.ColumnName.CoreIdentifier)],
|
|
91
|
+
requestType: requestTypeColumn === constants_1.BULK_APPLY
|
|
92
|
+
? cached.requestTypeToRequestAction[constants_1.BLANK]
|
|
93
|
+
: cached.requestTypeToRequestAction[input[requestTypeColumn]],
|
|
94
|
+
subjectType: dataSubjectTypeColumn === constants_1.BULK_APPLY
|
|
95
|
+
? cached.subjectTypeToSubjectName[constants_1.BLANK]
|
|
96
|
+
: cached.subjectTypeToSubjectName[input[dataSubjectTypeColumn]],
|
|
97
|
+
...(getMappedName(constants_1.ColumnName.Locale) !== constants_1.NONE &&
|
|
98
|
+
input[getMappedName(constants_1.ColumnName.Locale)]
|
|
99
|
+
? {
|
|
100
|
+
locale: cached.languageToLocale[input[getMappedName(constants_1.ColumnName.Locale)]],
|
|
101
|
+
}
|
|
102
|
+
: {}),
|
|
103
|
+
...(getMappedName(constants_1.ColumnName.RequestStatus) !== constants_1.NONE &&
|
|
104
|
+
cached.statusToRequestStatus[input[getMappedName(constants_1.ColumnName.RequestStatus)]] !== constants_1.NONE &&
|
|
105
|
+
input[getMappedName(constants_1.ColumnName.RequestStatus)]
|
|
106
|
+
? {
|
|
107
|
+
status: cached.statusToRequestStatus[input[getMappedName(constants_1.ColumnName.RequestStatus)]],
|
|
108
|
+
}
|
|
109
|
+
: {}),
|
|
110
|
+
...(getMappedName(constants_1.ColumnName.CreatedAt) !== constants_1.NONE &&
|
|
111
|
+
input[getMappedName(constants_1.ColumnName.CreatedAt)]
|
|
112
|
+
? {
|
|
113
|
+
createdAt: new Date(input[getMappedName(constants_1.ColumnName.CreatedAt)]),
|
|
114
|
+
}
|
|
115
|
+
: {}),
|
|
116
|
+
...(getMappedName(constants_1.ColumnName.DataSiloIds) !== constants_1.NONE &&
|
|
117
|
+
input[getMappedName(constants_1.ColumnName.DataSiloIds)]
|
|
118
|
+
? {
|
|
119
|
+
dataSiloIds: (0, splitCsvToList_1.splitCsvToList)(input[getMappedName(constants_1.ColumnName.DataSiloIds)]),
|
|
120
|
+
}
|
|
121
|
+
: {}),
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
exports.mapCsvRowsToRequestInputs = mapCsvRowsToRequestInputs;
|
|
127
|
+
//# sourceMappingURL=mapCsvRowsToRequestInputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapCsvRowsToRequestInputs.js","sourceRoot":"","sources":["../../src/requests/mapCsvRowsToRequestInputs.ts"],"names":[],"mappings":";;;AACA,+DAKqC;AAGrC,2CAMqB;AAErB,qDAAkD;AAwClD;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,eAAuB,EACvB,cAA8B;IAE9B,kBAAkB;IAClB,IAAI,cAAc,KAAK,8BAAc,CAAC,KAAK,EAAE;QAC3C,OAAO,eAAe,CAAC,WAAW,EAAE,CAAC;KACtC;IAED,yBAAyB;IACzB,IAAI,cAAc,KAAK,8BAAc,CAAC,KAAK,EAAE;QAC3C,OAAO,eAAe;aACnB,OAAO,CAAC,sCAAsB,EAAE,EAAE,CAAC;aACnC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;KAC7B;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAhBD,4DAgBC;AAED;;;;;;;;;GASG;AACH,SAAgB,yBAAyB,CACvC,aAA4B,EAC5B,MAAuB,EACvB,EACE,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GAQjB;IAED,+BAA+B;IAC/B,MAAM,aAAa,GAAG,CAAC,SAAqB,EAAU,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,SAAS,CAAE,CAAC;IAC7D,OAAO,aAAa,CAAC,GAAG,CACtB,CAAC,KAAK,EAAiD,EAAE;QACvD,mDAAmD;QACnD,MAAM,wBAAwB,GAA6B,EAAE,CAAC;QAC9D,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;YAC/B,iCAAiC;aAChC,MAAM,CAAC,CAA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KAAK,CAAC,aAAa,CAAC,sBAAU,CAAC,aAAa,CAAC,CAAC;oBAC5C,CAAC,CAAC;wBACE,MAAM,EAAE,MAAM,CAAC,qBAAqB,CAClC,KAAK,CAAC,aAAa,CAAC,sBAAU,CAAC,aAAa,CAAC,CAAC,CACrB;qBAC5B;oBACH,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,aAAa,CAAC,sBAAU,CAAC,SAAS,CAAC,KAAK,gBAAI;oBAChD,KAAK,CAAC,aAAa,CAAC,sBAAU,CAAC,SAAS,CAAC,CAAC;oBACxC,CAAC,CAAC;wBACE,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,sBAAU,CAAC,SAAS,CAAC,CAAC,CAAC;qBAChE;oBACH,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,aAAa,CAAC,sBAAU,CAAC,WAAW,CAAC,KAAK,gBAAI;oBAClD,KAAK,CAAC,aAAa,CAAC,sBAAU,CAAC,WAAW,CAAC,CAAC;oBAC1C,CAAC,CAAC;wBACE,WAAW,EAAE,IAAA,+BAAc,EACzB,KAAK,CAAC,aAAa,CAAC,sBAAU,CAAC,WAAW,CAAC,CAAC,CAC7C;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AA1HD,8DA0HC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a set of inputs to a set of outputs
|
|
3
|
+
*
|
|
4
|
+
* @param csvInputs - Input list
|
|
5
|
+
* @param expectedOutputs - Output list
|
|
6
|
+
* @param cache - Cache
|
|
7
|
+
* @returns Mapping from row to enum value
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapEnumValues<TValue extends string>(csvInputs: string[], expectedOutputs: TValue[], cache: {
|
|
10
|
+
[k in string]: TValue;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
[k in string]: TValue;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=mapEnumValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapEnumValues.d.ts","sourceRoot":"","sources":["../../src/requests/mapEnumValues.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,MAAM,SAAS,MAAM,EACvD,SAAS,EAAE,MAAM,EAAE,EACnB,eAAe,EAAE,MAAM,EAAE,EACzB,KAAK,EAAE;KAAG,CAAC,IAAI,MAAM,GAAG,MAAM;CAAE,GAC/B,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,GAAG,MAAM;CAAE,CAAC,CA6BpC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mapEnumValues = void 0;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
9
|
+
const type_utils_1 = require("@transcend-io/type-utils");
|
|
10
|
+
const fuzzyMatchColumns_1 = require("./fuzzyMatchColumns");
|
|
11
|
+
/**
|
|
12
|
+
* Map a set of inputs to a set of outputs
|
|
13
|
+
*
|
|
14
|
+
* @param csvInputs - Input list
|
|
15
|
+
* @param expectedOutputs - Output list
|
|
16
|
+
* @param cache - Cache
|
|
17
|
+
* @returns Mapping from row to enum value
|
|
18
|
+
*/
|
|
19
|
+
async function mapEnumValues(csvInputs, expectedOutputs, cache) {
|
|
20
|
+
inquirer_1.default.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
|
|
21
|
+
const inputs = csvInputs
|
|
22
|
+
.map((item) => item || '<blank>')
|
|
23
|
+
.filter((value) => !cache[value]);
|
|
24
|
+
if (inputs.length === 0) {
|
|
25
|
+
return cache;
|
|
26
|
+
}
|
|
27
|
+
const result = await inquirer_1.default.prompt(inputs.map((value) => ({
|
|
28
|
+
name: value,
|
|
29
|
+
message: `Map value of: ${value}`,
|
|
30
|
+
type: 'autocomplete',
|
|
31
|
+
default: expectedOutputs.find((x) => (0, fuzzyMatchColumns_1.fuzzySearch)(value, x)),
|
|
32
|
+
source: (answersSoFar, input) => !input
|
|
33
|
+
? expectedOutputs
|
|
34
|
+
: expectedOutputs.filter((x) => typeof x === 'string' && (0, fuzzyMatchColumns_1.fuzzySearch)(input, x)),
|
|
35
|
+
})));
|
|
36
|
+
return {
|
|
37
|
+
...cache,
|
|
38
|
+
...(0, type_utils_1.apply)(result, (r) => typeof r === 'string' ? r : Object.values(r)[0]),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.mapEnumValues = mapEnumValues;
|
|
42
|
+
//# sourceMappingURL=mapEnumValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapEnumValues.js","sourceRoot":"","sources":["../../src/requests/mapEnumValues.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,gGAA8D;AAC9D,yDAA8D;AAC9D,2DAAkD;AAElD;;;;;;;GAOG;AACI,KAAK,UAAU,aAAa,CACjC,SAAmB,EACnB,eAAyB,EACzB,KAAgC;IAEhC,kBAAQ,CAAC,cAAc,CAAC,cAAc,EAAE,sCAAkB,CAAC,CAAC;IAE5D,MAAM,MAAM,GAAG,SAAS;SACrB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,SAAS,CAAC;SAChC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,KAAK,CAAC;KACd;IACD,MAAM,MAAM,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAClC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrB,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,iBAAiB,KAAK,EAAE;QACjC,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,+BAAW,EAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC3D,MAAM,EAAE,CAAC,YAAyB,EAAE,KAAa,EAAE,EAAE,CACnD,CAAC,KAAK;YACJ,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,eAAe,CAAC,MAAM,CACpB,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,IAAA,+BAAW,EAAC,KAAK,EAAE,CAAC,CAAC,CACtD;KACR,CAAC,CAAC,CACJ,CAAC;IACF,OAAO;QACL,GAAG,KAAK;QACR,GAAG,IAAA,kBAAK,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CACrB,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,CAAY,CAAC,CAAC,CAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAY,CACxE;KACF,CAAC;AACJ,CAAC;AAjCD,sCAiCC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GraphQLClient } from 'graphql-request';
|
|
2
|
+
import type { PersistedState } from '@transcend-io/persisted-state';
|
|
3
|
+
import { ObjByString } from '@transcend-io/type-utils';
|
|
4
|
+
import { CachedState } from './constants';
|
|
5
|
+
import { ColumnNameMap } from './mapCsvColumnsToApi';
|
|
6
|
+
/**
|
|
7
|
+
* Map the values in a CSV to the enum values in Transcend
|
|
8
|
+
*
|
|
9
|
+
* @param client - GraphQL client
|
|
10
|
+
* @param requests - Set of privacy requests
|
|
11
|
+
* @param options - Options
|
|
12
|
+
*/
|
|
13
|
+
export declare function mapRequestEnumValues(client: GraphQLClient, requests: ObjByString[], { fileName, state, columnNameMap, }: {
|
|
14
|
+
/** Name of fileName to be cached */
|
|
15
|
+
fileName: string;
|
|
16
|
+
/** State value to write cache to */
|
|
17
|
+
state: PersistedState<typeof CachedState>;
|
|
18
|
+
/** Mapping of column names */
|
|
19
|
+
columnNameMap: ColumnNameMap;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=mapRequestEnumValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapRequestEnumValues.d.ts","sourceRoot":"","sources":["../../src/requests/mapRequestEnumValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAMpE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAoB,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,WAAW,EAAE,EACvB,EACE,QAAQ,EACR,KAAK,EACL,aAAa,GACd,EAAE;IACD,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,KAAK,EAAE,cAAc,CAAC,OAAO,WAAW,CAAC,CAAC;IAC1C,8BAA8B;IAC9B,aAAa,EAAE,aAAa,CAAC;CAC9B,GACA,OAAO,CAAC,IAAI,CAAC,CAsDf"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapRequestEnumValues = void 0;
|
|
4
|
+
const privacy_types_1 = require("@transcend-io/privacy-types");
|
|
5
|
+
const internationalization_1 = require("@transcend-io/internationalization");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
const graphql_1 = require("../graphql");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const mapEnumValues_1 = require("./mapEnumValues");
|
|
10
|
+
const getUniqueValuesForColumn_1 = require("./getUniqueValuesForColumn");
|
|
11
|
+
/**
|
|
12
|
+
* Map the values in a CSV to the enum values in Transcend
|
|
13
|
+
*
|
|
14
|
+
* @param client - GraphQL client
|
|
15
|
+
* @param requests - Set of privacy requests
|
|
16
|
+
* @param options - Options
|
|
17
|
+
*/
|
|
18
|
+
async function mapRequestEnumValues(client, requests, { fileName, state, columnNameMap, }) {
|
|
19
|
+
// Current cache value
|
|
20
|
+
const cached = state.getValue(fileName);
|
|
21
|
+
// Get mapped value
|
|
22
|
+
const getMappedName = (attribute) => cached.columnNames[attribute] || columnNameMap[attribute];
|
|
23
|
+
// Fetch all data subjects in the organization
|
|
24
|
+
const { internalSubjects } = await (0, graphql_1.makeGraphQLRequest)(client, graphql_1.DATA_SUBJECTS);
|
|
25
|
+
logger_1.logger.info('Determine mapping for request action');
|
|
26
|
+
const requestTypeToRequestAction = await (0, mapEnumValues_1.mapEnumValues)((0, getUniqueValuesForColumn_1.getUniqueValuesForColumn)(requests, getMappedName(constants_1.ColumnName.RequestType)), Object.values(privacy_types_1.RequestAction), cached.requestTypeToRequestAction || {});
|
|
27
|
+
cached.requestTypeToRequestAction = requestTypeToRequestAction;
|
|
28
|
+
state.setValue(cached, fileName);
|
|
29
|
+
logger_1.logger.info('Determine mapping for subject');
|
|
30
|
+
const subjectTypeToSubjectName = await (0, mapEnumValues_1.mapEnumValues)((0, getUniqueValuesForColumn_1.getUniqueValuesForColumn)(requests, getMappedName(constants_1.ColumnName.SubjectType)), internalSubjects.map(({ type }) => type), cached.subjectTypeToSubjectName || {});
|
|
31
|
+
cached.subjectTypeToSubjectName = subjectTypeToSubjectName;
|
|
32
|
+
state.setValue(cached, fileName);
|
|
33
|
+
logger_1.logger.info('Determine mapping for locale');
|
|
34
|
+
const languageToLocale = await (0, mapEnumValues_1.mapEnumValues)((0, getUniqueValuesForColumn_1.getUniqueValuesForColumn)(requests, getMappedName(constants_1.ColumnName.Locale)), Object.values(internationalization_1.LanguageKey), cached.languageToLocale || {});
|
|
35
|
+
cached.languageToLocale = languageToLocale;
|
|
36
|
+
state.setValue(cached, fileName);
|
|
37
|
+
logger_1.logger.info('Determine mapping for request status');
|
|
38
|
+
const requestStatusColumn = getMappedName(constants_1.ColumnName.RequestStatus);
|
|
39
|
+
const statusToRequestStatus = requestStatusColumn === constants_1.NONE
|
|
40
|
+
? {}
|
|
41
|
+
: await (0, mapEnumValues_1.mapEnumValues)((0, getUniqueValuesForColumn_1.getUniqueValuesForColumn)(requests, requestStatusColumn), [...Object.values(privacy_types_1.CompletedRequestStatus), constants_1.NONE], cached.statusToRequestStatus || {});
|
|
42
|
+
cached.statusToRequestStatus = statusToRequestStatus;
|
|
43
|
+
state.setValue(cached, fileName);
|
|
44
|
+
}
|
|
45
|
+
exports.mapRequestEnumValues = mapRequestEnumValues;
|
|
46
|
+
//# sourceMappingURL=mapRequestEnumValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapRequestEnumValues.js","sourceRoot":"","sources":["../../src/requests/mapRequestEnumValues.ts"],"names":[],"mappings":";;;AAEA,+DAGqC;AACrC,6EAAiE;AAEjE,sCAAmC;AACnC,wCAA4E;AAC5E,2CAA4D;AAC5D,mDAAgD;AAEhD,yEAAsE;AAEtE;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CACxC,MAAqB,EACrB,QAAuB,EACvB,EACE,QAAQ,EACR,KAAK,EACL,aAAa,GAQd;IAED,sBAAsB;IACtB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAExC,mBAAmB;IACnB,MAAM,aAAa,GAAG,CAAC,SAAqB,EAAU,EAAE,CACtD,MAAM,CAAC,WAAW,CAAC,SAAS,C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