@transcend-io/cli 6.9.0 → 6.10.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 +88 -12
- package/build/cli-request-upload.js +1 -1
- package/build/cli-request-upload.js.map +1 -1
- package/build/cli-upload-consent-preferences.js +2 -2
- package/build/cli-upload-consent-preferences.js.map +1 -1
- package/build/cli-upload-preferences.d.ts +3 -0
- package/build/cli-upload-preferences.d.ts.map +1 -0
- package/build/cli-upload-preferences.js +79 -0
- package/build/cli-upload-preferences.js.map +1 -0
- package/build/consent-manager/index.d.ts +1 -0
- package/build/consent-manager/index.d.ts.map +1 -1
- package/build/consent-manager/index.js +1 -0
- package/build/consent-manager/index.js.map +1 -1
- package/build/consent-manager/{uploadConsentPreferences.d.ts → uploadConsents.d.ts} +2 -2
- package/build/consent-manager/uploadConsents.d.ts.map +1 -0
- package/build/consent-manager/{uploadConsentPreferences.js → uploadConsents.js} +4 -4
- package/build/consent-manager/uploadConsents.js.map +1 -0
- package/build/graphql/createSombraGotInstance.d.ts.map +1 -1
- package/build/graphql/createSombraGotInstance.js.map +1 -1
- package/build/graphql/fetchAllPreferenceTopics.d.ts +28 -0
- package/build/graphql/fetchAllPreferenceTopics.d.ts.map +1 -0
- package/build/graphql/fetchAllPreferenceTopics.js +32 -0
- package/build/graphql/fetchAllPreferenceTopics.js.map +1 -0
- package/build/graphql/fetchAllPurposes.d.ts +25 -0
- package/build/graphql/fetchAllPurposes.d.ts.map +1 -0
- package/build/graphql/fetchAllPurposes.js +36 -0
- package/build/graphql/fetchAllPurposes.js.map +1 -0
- package/build/graphql/fetchConsentManagerId.d.ts +0 -7
- package/build/graphql/fetchConsentManagerId.d.ts.map +1 -1
- package/build/graphql/fetchConsentManagerId.js +1 -12
- package/build/graphql/fetchConsentManagerId.js.map +1 -1
- package/build/graphql/gqls/consentManager.d.ts +0 -1
- package/build/graphql/gqls/consentManager.d.ts.map +1 -1
- package/build/graphql/gqls/consentManager.js +1 -12
- package/build/graphql/gqls/consentManager.js.map +1 -1
- package/build/graphql/gqls/index.d.ts +2 -0
- package/build/graphql/gqls/index.d.ts.map +1 -1
- package/build/graphql/gqls/index.js +2 -0
- package/build/graphql/gqls/index.js.map +1 -1
- package/build/graphql/gqls/preferenceTopic.d.ts +2 -0
- package/build/graphql/gqls/preferenceTopic.d.ts.map +1 -0
- package/build/graphql/gqls/preferenceTopic.js +33 -0
- package/build/graphql/gqls/preferenceTopic.js.map +1 -0
- package/build/graphql/gqls/purpose.d.ts +2 -0
- package/build/graphql/gqls/purpose.d.ts.map +1 -0
- package/build/graphql/gqls/purpose.js +35 -0
- package/build/graphql/gqls/purpose.js.map +1 -0
- package/build/graphql/index.d.ts +2 -0
- package/build/graphql/index.d.ts.map +1 -1
- package/build/graphql/index.js +2 -0
- package/build/graphql/index.js.map +1 -1
- package/build/graphql/syncConsentManager.js +2 -1
- package/build/graphql/syncConsentManager.js.map +1 -1
- package/build/graphql/syncCookies.js +1 -1
- package/build/graphql/syncCookies.js.map +1 -1
- package/build/graphql/syncDataFlows.js +2 -2
- package/build/graphql/syncDataFlows.js.map +1 -1
- package/build/preference-management/checkIfPendingPreferenceUpdatesAreNoOp.d.ts +19 -0
- package/build/preference-management/checkIfPendingPreferenceUpdatesAreNoOp.d.ts.map +1 -0
- package/build/preference-management/checkIfPendingPreferenceUpdatesAreNoOp.js +56 -0
- package/build/preference-management/checkIfPendingPreferenceUpdatesAreNoOp.js.map +1 -0
- package/build/preference-management/checkIfPendingPreferenceUpdatesCauseConflict.d.ts +20 -0
- package/build/preference-management/checkIfPendingPreferenceUpdatesCauseConflict.d.ts.map +1 -0
- package/build/preference-management/checkIfPendingPreferenceUpdatesCauseConflict.js +58 -0
- package/build/preference-management/checkIfPendingPreferenceUpdatesCauseConflict.js.map +1 -0
- package/build/preference-management/codecs.d.ts +369 -0
- package/build/preference-management/codecs.d.ts.map +1 -0
- package/build/preference-management/codecs.js +122 -0
- package/build/preference-management/codecs.js.map +1 -0
- package/build/preference-management/getPreferenceUpdatesFromRow.d.ts +37 -0
- package/build/preference-management/getPreferenceUpdatesFromRow.d.ts.map +1 -0
- package/build/preference-management/getPreferenceUpdatesFromRow.js +144 -0
- package/build/preference-management/getPreferenceUpdatesFromRow.js.map +1 -0
- package/build/preference-management/getPreferencesForIdentifiers.d.ts +21 -0
- package/build/preference-management/getPreferencesForIdentifiers.d.ts.map +1 -0
- package/build/preference-management/getPreferencesForIdentifiers.js +113 -0
- package/build/preference-management/getPreferencesForIdentifiers.js.map +1 -0
- package/build/preference-management/index.d.ts +12 -0
- package/build/preference-management/index.d.ts.map +1 -0
- package/build/preference-management/index.js +28 -0
- package/build/preference-management/index.js.map +1 -0
- package/build/preference-management/parsePreferenceAndPurposeValuesFromCsv.d.ts +17 -0
- package/build/preference-management/parsePreferenceAndPurposeValuesFromCsv.d.ts.map +1 -0
- package/build/preference-management/parsePreferenceAndPurposeValuesFromCsv.js +86 -0
- package/build/preference-management/parsePreferenceAndPurposeValuesFromCsv.js.map +1 -0
- package/build/preference-management/parsePreferenceIdentifiersFromCsv.d.ts +18 -0
- package/build/preference-management/parsePreferenceIdentifiersFromCsv.d.ts.map +1 -0
- package/build/preference-management/parsePreferenceIdentifiersFromCsv.js +97 -0
- package/build/preference-management/parsePreferenceIdentifiersFromCsv.js.map +1 -0
- package/build/preference-management/parsePreferenceManagementCsv.d.ts +25 -0
- package/build/preference-management/parsePreferenceManagementCsv.d.ts.map +1 -0
- package/build/preference-management/parsePreferenceManagementCsv.js +145 -0
- package/build/preference-management/parsePreferenceManagementCsv.js.map +1 -0
- package/build/preference-management/parsePreferenceTimestampsFromCsv.d.ts +16 -0
- package/build/preference-management/parsePreferenceTimestampsFromCsv.d.ts.map +1 -0
- package/build/preference-management/parsePreferenceTimestampsFromCsv.js +65 -0
- package/build/preference-management/parsePreferenceTimestampsFromCsv.js.map +1 -0
- package/build/preference-management/tests/checkIfPendingPreferenceUpdatesAreNoOp.test.d.ts +2 -0
- package/build/preference-management/tests/checkIfPendingPreferenceUpdatesAreNoOp.test.d.ts.map +1 -0
- package/build/preference-management/tests/checkIfPendingPreferenceUpdatesAreNoOp.test.js +408 -0
- package/build/preference-management/tests/checkIfPendingPreferenceUpdatesAreNoOp.test.js.map +1 -0
- package/build/preference-management/tests/checkIfPendingPreferenceUpdatesCauseConflict.test.d.ts +2 -0
- package/build/preference-management/tests/checkIfPendingPreferenceUpdatesCauseConflict.test.d.ts.map +1 -0
- package/build/preference-management/tests/checkIfPendingPreferenceUpdatesCauseConflict.test.js +428 -0
- package/build/preference-management/tests/checkIfPendingPreferenceUpdatesCauseConflict.test.js.map +1 -0
- package/build/preference-management/tests/getPreferenceUpdatesFromRow.test.d.ts +2 -0
- package/build/preference-management/tests/getPreferenceUpdatesFromRow.test.d.ts.map +1 -0
- package/build/preference-management/tests/getPreferenceUpdatesFromRow.test.js +549 -0
- package/build/preference-management/tests/getPreferenceUpdatesFromRow.test.js.map +1 -0
- package/build/preference-management/uploadPreferenceManagementPreferencesInteractive.d.ts +33 -0
- package/build/preference-management/uploadPreferenceManagementPreferencesInteractive.d.ts.map +1 -0
- package/build/preference-management/uploadPreferenceManagementPreferencesInteractive.js +166 -0
- package/build/preference-management/uploadPreferenceManagementPreferencesInteractive.js.map +1 -0
- package/build/requests/bulkRestartRequests.js +2 -2
- package/build/requests/bulkRestartRequests.js.map +1 -1
- package/build/requests/mapColumnsToAttributes.d.ts.map +1 -1
- package/build/requests/mapColumnsToAttributes.js +1 -3
- package/build/requests/mapColumnsToAttributes.js.map +1 -1
- package/build/requests/mapColumnsToIdentifiers.d.ts.map +1 -1
- package/build/requests/mapColumnsToIdentifiers.js +1 -3
- package/build/requests/mapColumnsToIdentifiers.js.map +1 -1
- package/build/requests/mapCsvColumnsToApi.d.ts.map +1 -1
- package/build/requests/mapCsvColumnsToApi.js +1 -3
- package/build/requests/mapCsvColumnsToApi.js.map +1 -1
- package/build/requests/mapRequestEnumValues.d.ts.map +1 -1
- package/build/requests/mapRequestEnumValues.js +6 -6
- package/build/requests/mapRequestEnumValues.js.map +1 -1
- package/build/requests/uploadPrivacyRequestsFromCsv.js +3 -3
- package/build/requests/uploadPrivacyRequestsFromCsv.js.map +1 -1
- package/build/tsbuildinfo +1 -1
- package/package.json +6 -3
- package/build/consent-manager/uploadConsentPreferences.d.ts.map +0 -1
- package/build/consent-manager/uploadConsentPreferences.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPreferenceUpdatesFromRow.js","sourceRoot":"","sources":["../../src/preference-management/getPreferenceUpdatesFromRow.ts"],"names":[],"mappings":";;;AAAA,+DAGqC;AAErC,yDAAiD;AAEjD,0CAA6C;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,2BAA2B,CAAC,EAC1C,GAAG,EACH,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,GAUjB;IAGC,yDAAyD;IACzD,MAAM,MAAM,GAER,EAAE,CAAC;IAEP,gEAAgE;IAChE,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,OAAO,CACzC,CAAC,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE;QACtD,8BAA8B;QAC9B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACnC,MAAM,IAAI,KAAK,CACb,yBAAyB,OAAO,eAAe,YAAY,CAAC,IAAI,CAC9D,IAAI,CACL,EAAE,CACJ,CAAC;SACH;QAED,8DAA8D;QAC9D,IAAI,UAAU,EAAE;YACd,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,CAC3C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,OAAO,CAAC,YAAY,KAAK,OAAO,CACnE,CAAC;YACF,IAAI,CAAC,eAAe,EAAE;gBACpB,MAAM,aAAa,GAAG,gBAAgB;qBACnC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enceQueryResponseItem } from '@transcend-io/privacy-types';
|
|
2
|
+
import type { Got } from 'got';
|
|
3
|
+
/**
|
|
4
|
+
* Grab the current consent preference values for a list of identifiers
|
|
5
|
+
*
|
|
6
|
+
* @param sombra - Backend to make API call to
|
|
7
|
+
* @param options - Options
|
|
8
|
+
* @returns Plaintext context information
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPreferencesForIdentifiers(sombra: Got, { identifiers, partitionKey, skipLogging, }: {
|
|
11
|
+
/** The list of identifiers to look up */
|
|
12
|
+
identifiers: {
|
|
13
|
+
/** The value of the identifier */
|
|
14
|
+
value: string;
|
|
15
|
+
}[];
|
|
16
|
+
/** The partition key to look up */
|
|
17
|
+
partitionKey: string;
|
|
18
|
+
/** Whether to skip logging */
|
|
19
|
+
skipLogging?: boolean;
|
|
20
|
+
}): Promise<PreferenceQueryResponseItem[]>;
|
|
21
|
+
//# sourceMappingURL=getPreferencesForIdentifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPreferencesForIdentifiers.d.ts","sourceRoot":"","sources":["../../src/preference-management/getPreferencesForIdentifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAqB/B;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,GAAG,EACX,EACE,WAAW,EACX,YAAY,EACZ,WAAmB,GACpB,EAAE;IACD,yCAAyC;IACzC,WAAW,EAAE;QACX,kCAAkC;QAClC,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GACA,OAAO,CAAC,2BAA2B,EAAE,CAAC,CA8ExC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getPreferencesForIdentifiers = void 0;
|
|
30
|
+
const privacy_types_1 = require("@transcend-io/privacy-types");
|
|
31
|
+
const colors_1 = __importDefault(require("colors"));
|
|
32
|
+
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
33
|
+
const chunk_1 = __importDefault(require("lodash/chunk"));
|
|
34
|
+
const type_utils_1 = require("@transcend-io/type-utils");
|
|
35
|
+
const t = __importStar(require("io-ts"));
|
|
36
|
+
const bluebird_1 = require("bluebird");
|
|
37
|
+
const logger_1 = require("../logger");
|
|
38
|
+
const PreferenceRecordsQueryResponse = t.intersection([
|
|
39
|
+
t.type({
|
|
40
|
+
nodes: t.array(privacy_types_1.PreferenceQueryResponseItem),
|
|
41
|
+
}),
|
|
42
|
+
t.partial({
|
|
43
|
+
/** The base64 encoded(PreferenceStorePaginationKey) cursor for pagination */
|
|
44
|
+
cursor: t.string,
|
|
45
|
+
}),
|
|
46
|
+
]);
|
|
47
|
+
const MSGS = ['ETIMEDOUT', '504 Gateway Time-out', 'Task timed out after'];
|
|
48
|
+
/**
|
|
49
|
+
* Grab the current consent preference values for a list of identifiers
|
|
50
|
+
*
|
|
51
|
+
* @param sombra - Backend to make API call to
|
|
52
|
+
* @param options - Options
|
|
53
|
+
* @returns Plaintext context information
|
|
54
|
+
*/
|
|
55
|
+
async function getPreferencesForIdentifiers(sombra, { identifiers, partitionKey, skipLogging = false, }) {
|
|
56
|
+
const results = [];
|
|
57
|
+
const groupedIdentifiers = (0, chunk_1.default)(identifiers, 100);
|
|
58
|
+
// create a new progress bar instance and use shades_classic theme
|
|
59
|
+
const t0 = new Date().getTime();
|
|
60
|
+
const progressBar = new cli_progress_1.default.SingleBar({}, cli_progress_1.default.Presets.shades_classic);
|
|
61
|
+
if (!skipLogging) {
|
|
62
|
+
progressBar.start(identifiers.length, 0);
|
|
63
|
+
}
|
|
64
|
+
let total = 0;
|
|
65
|
+
await (0, bluebird_1.map)(groupedIdentifiers, async (group) => {
|
|
66
|
+
var _a;
|
|
67
|
+
// Make the request with retry logic
|
|
68
|
+
let attempts = 0;
|
|
69
|
+
const maxAttempts = 3;
|
|
70
|
+
while (attempts < maxAttempts) {
|
|
71
|
+
try {
|
|
72
|
+
// eslint-disable-next-line no-await-in-loop
|
|
73
|
+
const rawResult = await sombra
|
|
74
|
+
.post(`v1/preferences/${partitionKey}/query`, {
|
|
75
|
+
json: {
|
|
76
|
+
filter: {
|
|
77
|
+
identifiers: group,
|
|
78
|
+
},
|
|
79
|
+
limit: group.length,
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
.json();
|
|
83
|
+
const result = (0, type_utils_1.decodeCodec)(PreferenceRecordsQueryResponse, rawResult);
|
|
84
|
+
results.push(...result.nodes);
|
|
85
|
+
total += group.length;
|
|
86
|
+
progressBar.update(total);
|
|
87
|
+
break; // Exit loop if successful
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
attempts += 1;
|
|
91
|
+
const msg = ((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.body) || (err === null || err === void 0 ? void 0 : err.message) || '';
|
|
92
|
+
if (attempts >= maxAttempts ||
|
|
93
|
+
!MSGS.some((errorMessage) => msg.includes(errorMessage))) {
|
|
94
|
+
throw new Error(`Received an error from server after ${attempts} attempts: ${msg}`);
|
|
95
|
+
}
|
|
96
|
+
logger_1.logger.warn(colors_1.default.yellow(`[RETRYING FAILED REQUEST - Attempt ${attempts}] ` +
|
|
97
|
+
`Failed to fetch ${group.length} user preferences from partition ${partitionKey}: ${msg}`));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
concurrency: 40,
|
|
102
|
+
});
|
|
103
|
+
progressBar.stop();
|
|
104
|
+
const t1 = new Date().getTime();
|
|
105
|
+
const totalTime = t1 - t0;
|
|
106
|
+
if (!skipLogging) {
|
|
107
|
+
// Log completion time
|
|
108
|
+
logger_1.logger.info(colors_1.default.green(`Completed download in "${totalTime / 1000}" seconds.`));
|
|
109
|
+
}
|
|
110
|
+
return results;
|
|
111
|
+
}
|
|
112
|
+
exports.getPreferencesForIdentifiers = getPreferencesForIdentifiers;
|
|
113
|
+
//# sourceMappingURL=getPreferencesForIdentifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPreferencesForIdentifiers.js","sourceRoot":"","sources":["../../src/preference-management/getPreferencesForIdentifiers.ts"],"names":[],"mappings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IAEF,WAAW,CAAC,IAAI,EAAE,CAAC;IACnB,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,CAAC;IAE1B,IAAI,CAAC,WAAW,EAAE;QAChB,sBAAsB;QACtB,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,KAAK,CAAC,0BAA0B,SAAS,GAAG,IAAI,YAAY,CAAC,CACrE,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AA/FD,oEA+FC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './uploadPreferenceManagementPreferencesInteractive';
|
|
2
|
+
export * from './codecs';
|
|
3
|
+
export * from './getPreferencesForIdentifiers';
|
|
4
|
+
export * from './parsePreferenceManagementCsv';
|
|
5
|
+
export * from './getPreferenceUpdatesFromRow';
|
|
6
|
+
export * from './parsePreferenceManagementCsv';
|
|
7
|
+
export * from './parsePreferenceIdentifiersFromCsv';
|
|
8
|
+
export * from './parsePreferenceTimestampsFromCsv';
|
|
9
|
+
export * from './parsePreferenceAndPurposeValuesFromCsv';
|
|
10
|
+
export * from './checkIfPendingPreferenceUpdatesAreNoOp';
|
|
11
|
+
export * from './checkIfPendingPreferenceUpdatesCauseConflict';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/preference-management/index.ts"],"names":[],"mappings":"AAAA,cAAc,oDAAoD,CAAC;AACnE,cAAc,UAAU,CAAC;AACzB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,gDAAgD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./uploadPreferenceManagementPreferencesInteractive"), exports);
|
|
18
|
+
__exportStar(require("./codecs"), exports);
|
|
19
|
+
__exportStar(require("./getPreferencesForIdentifiers"), exports);
|
|
20
|
+
__exportStar(require("./parsePreferenceManagementCsv"), exports);
|
|
21
|
+
__exportStar(require("./getPreferenceUpdatesFromRow"), exports);
|
|
22
|
+
__exportStar(require("./parsePreferenceManagementCsv"), exports);
|
|
23
|
+
__exportStar(require("./parsePreferenceIdentifiersFromCsv"), exports);
|
|
24
|
+
__exportStar(require("./parsePreferenceTimestampsFromCsv"), exports);
|
|
25
|
+
__exportStar(require("./parsePreferenceAndPurposeValuesFromCsv"), exports);
|
|
26
|
+
__exportStar(require("./checkIfPendingPreferenceUpdatesAreNoOp"), exports);
|
|
27
|
+
__exportStar(require("./checkIfPendingPreferenceUpdatesCauseConflict"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/preference-management/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qFAAmE;AACnE,2CAAyB;AACzB,iEAA+C;AAC/C,iEAA+C;AAC/C,gEAA8C;AAC9C,iEAA+C;AAC/C,sEAAoD;AACpD,qEAAmD;AACnD,2EAAyD;AACzD,2EAAyD;AACzD,iFAA+D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FileMetadataState } from './codecs';
|
|
2
|
+
import { PreferenceTopic } from '../graphql';
|
|
3
|
+
/**
|
|
4
|
+
* Parse out the purpose.enabled and preference values from a CSV file
|
|
5
|
+
*
|
|
6
|
+
* @param preferences - List of preferences
|
|
7
|
+
* @param currentState - The current file metadata state for parsing this list
|
|
8
|
+
* @param options - Options
|
|
9
|
+
* @returns The updated file metadata state
|
|
10
|
+
*/
|
|
11
|
+
export declare function parsePreferenceAndPurposeValuesFromCsv(preferences: Record<string, string>[], currentState: FileMetadataState, { purposeSlugs, preferenceTopics, }: {
|
|
12
|
+
/** The purpose slugs that are allowed to be updated */
|
|
13
|
+
purposeSlugs: string[];
|
|
14
|
+
/** The preference topics */
|
|
15
|
+
preferenceTopics: PreferenceTopic[];
|
|
16
|
+
}): Promise<FileMetadataState>;
|
|
17
|
+
//# sourceMappingURL=parsePreferenceAndPurposeValuesFromCsv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePreferenceAndPurposeValuesFromCsv.d.ts","sourceRoot":"","sources":["../../src/preference-management/parsePreferenceAndPurposeValuesFromCsv.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI7C;;;;;;;GAOG;AACH,wBAAsB,sCAAsC,CAC1D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EACrC,YAAY,EAAE,iBAAiB,EAC/B,EACE,YAAY,EACZ,gBAAgB,GACjB,EAAE;IACD,uDAAuD;IACvD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,4BAA4B;IAC5B,gBAAgB,EAAE,eAAe,EAAE,CAAC;CACrC,GACA,OAAO,CAAC,iBAAiB,CAAC,CAiF5B"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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.parsePreferenceAndPurposeValuesFromCsv = void 0;
|
|
7
|
+
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
8
|
+
const colors_1 = __importDefault(require("colors"));
|
|
9
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
|
+
const difference_1 = __importDefault(require("lodash/difference"));
|
|
11
|
+
const logger_1 = require("../logger");
|
|
12
|
+
const bluebird_1 = require("bluebird");
|
|
13
|
+
/* eslint-disable no-param-reassign */
|
|
14
|
+
/**
|
|
15
|
+
* Parse out the purpose.enabled and preference values from a CSV file
|
|
16
|
+
*
|
|
17
|
+
* @param preferences - List of preferences
|
|
18
|
+
* @param currentState - The current file metadata state for parsing this list
|
|
19
|
+
* @param options - Options
|
|
20
|
+
* @returns The updated file metadata state
|
|
21
|
+
*/
|
|
22
|
+
async function parsePreferenceAndPurposeValuesFromCsv(preferences, currentState, { purposeSlugs, preferenceTopics, }) {
|
|
23
|
+
// Determine columns to map
|
|
24
|
+
const columnNames = (0, uniq_1.default)(preferences.map((x) => Object.keys(x)).flat());
|
|
25
|
+
// Determine the columns that could potentially be used for identifier
|
|
26
|
+
const otherColumns = (0, difference_1.default)(columnNames, [
|
|
27
|
+
...(currentState.identifierColumn ? [currentState.identifierColumn] : []),
|
|
28
|
+
...(currentState.timestampColum ? [currentState.timestampColum] : []),
|
|
29
|
+
]);
|
|
30
|
+
if (otherColumns.length === 0) {
|
|
31
|
+
throw new Error('No other columns to process');
|
|
32
|
+
}
|
|
33
|
+
// The purpose and preferences to map to
|
|
34
|
+
const purposeNames = [
|
|
35
|
+
...purposeSlugs,
|
|
36
|
+
...preferenceTopics.map((x) => `${x.purpose.trackingType}->${x.slug}`),
|
|
37
|
+
];
|
|
38
|
+
// Ensure all columns are accounted for
|
|
39
|
+
await (0, bluebird_1.mapSeries)(otherColumns, async (col) => {
|
|
40
|
+
// Determine the unique values to map in this column
|
|
41
|
+
const uniqueValues = (0, uniq_1.default)(preferences.map((x) => x[col]));
|
|
42
|
+
// Map the column to a purpose
|
|
43
|
+
let purposeMapping = currentState.columnToPurposeName[col];
|
|
44
|
+
if (purposeMapping) {
|
|
45
|
+
logger_1.logger.info(colors_1.default.magenta(`Column "${col}" is associated with purpose "${purposeMapping.purpose}"`));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const { purposeName } = await inquirer_1.default.prompt([
|
|
49
|
+
{
|
|
50
|
+
name: 'purposeName',
|
|
51
|
+
message: `Choose the purpose that column ${col} is associated with`,
|
|
52
|
+
type: 'list',
|
|
53
|
+
default: purposeNames[0],
|
|
54
|
+
choices: purposeNames,
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
const [purposeSlug, preferenceSlug] = purposeName.split('->');
|
|
58
|
+
purposeMapping = {
|
|
59
|
+
purpose: purposeSlug,
|
|
60
|
+
preference: preferenceSlug || null,
|
|
61
|
+
valueMapping: {},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// map each value to the purpose value
|
|
65
|
+
await (0, bluebird_1.mapSeries)(uniqueValues, async (value) => {
|
|
66
|
+
if (purposeMapping.valueMapping[value] !== undefined) {
|
|
67
|
+
logger_1.logger.info(colors_1.default.magenta(`Value "${value}" is associated with purpose value "${purposeMapping.valueMapping[value]}"`));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const { purposeValue } = await inquirer_1.default.prompt([
|
|
71
|
+
{
|
|
72
|
+
name: 'purposeValue',
|
|
73
|
+
message: `Choose the purpose value for value "${value}" associated with purpose "${purposeMapping.purpose}"`,
|
|
74
|
+
type: 'confirm',
|
|
75
|
+
default: value !== 'false',
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
purposeMapping.valueMapping[value] = purposeValue;
|
|
79
|
+
});
|
|
80
|
+
currentState.columnToPurposeName[col] = purposeMapping;
|
|
81
|
+
});
|
|
82
|
+
return currentState;
|
|
83
|
+
}
|
|
84
|
+
exports.parsePreferenceAndPurposeValuesFromCsv = parsePreferenceAndPurposeValuesFromCsv;
|
|
85
|
+
/* eslint-enable no-param-reassign */
|
|
86
|
+
//# sourceMappingURL=parsePreferenceAndPurposeValuesFromCsv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePreferenceAndPurposeValuesFromCsv.js","sourceRoot":"","sources":["../../src/preference-management/parsePreferenceAndPurposeValuesFromCsv.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA+B;AAC/B,oDAA4B;AAC5B,wDAAgC;AAChC,mEAA2C;AAE3C,sCAAmC;AACnC,uCAAqC;AAGrC,sCAAsC;AAEtC;;;;;;;GAOG;AACI,KAAK,UAAU,sCAAsC,CAC1D,WAAqC,EACrC,YAA+B,EAC/B,EACE,YAAY,EACZ,gBAAgB,GAMjB;IAED,2BAA2B;IAC3B,MAAM,WAAW,GAAG,IAAA,cAAI,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAExE,sEAAsE;IACtE,MAAM,YAAY,GAAG,IAAA,oBAAU,EAAC,WAAW,EAAE;QAC3C,GAAG,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,C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,cAAc,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC9D,cAAc,GAAG;gBACf,OAAO,EAAE,WAAW;gBACpB,UAAU,EAAE,cAAc,IAAI,IAAI;gBAClC,YAAY,EAAE,EAAE;aACjB,CAAC;SACH;QAED,sCAAsC;QACtC,MAAM,IAAA,oBAAS,EAAC,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YAC5C,IAAI,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE;gBACpD,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,OAAO,CACZ,UAAU,KAAK,uCAAuC,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAC5F,CACF,CAAC;gBACF,OAAO;aACR;YACD,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAG3C;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE,uCAAuC,KAAK,8BAA8B,cAAc,CAAC,OAAO,GAAG;oBAC5G,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,KAAK,KAAK,OAAO;iBAC3B;aACF,CAAC,CAAC;YACH,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC;AA7FD,wFA6FC;AACD,qCAAqC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FileMetadataState } from './codecs';
|
|
2
|
+
/**
|
|
3
|
+
* Parse identifiers from a CSV list of preferences
|
|
4
|
+
*
|
|
5
|
+
* Ensures that all rows have a valid identifier
|
|
6
|
+
* and that all identifiers are unique.
|
|
7
|
+
*
|
|
8
|
+
* @param preferences - List of preferences
|
|
9
|
+
* @param currentState - The current file metadata state for parsing this list
|
|
10
|
+
* @returns The updated file metadata state
|
|
11
|
+
*/
|
|
12
|
+
export declare function parsePreferenceIdentifiersFromCsv(preferences: Record<string, string>[], currentState: FileMetadataState): Promise<{
|
|
13
|
+
/** The updated state */
|
|
14
|
+
currentState: FileMetadataState;
|
|
15
|
+
/** The updated preferences */
|
|
16
|
+
preferences: Record<string, string>[];
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=parsePreferenceIdentifiersFromCsv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePreferenceIdentifiersFromCsv.d.ts","sourceRoot":"","sources":["../../src/preference-management/parsePreferenceIdentifiersFromCsv.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAM7C;;;;;;;;;GASG;AACH,wBAAsB,iCAAiC,CACrD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EACrC,YAAY,EAAE,iBAAiB,GAC9B,OAAO,CAAC;IACT,wBAAwB;IACxB,YAAY,EAAE,iBAAiB,CAAC;IAChC,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CACvC,CAAC,CA6GD"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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.parsePreferenceIdentifiersFromCsv = void 0;
|
|
7
|
+
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
8
|
+
const groupBy_1 = __importDefault(require("lodash/groupBy"));
|
|
9
|
+
const colors_1 = __importDefault(require("colors"));
|
|
10
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
11
|
+
const difference_1 = __importDefault(require("lodash/difference"));
|
|
12
|
+
const logger_1 = require("../logger");
|
|
13
|
+
const helpers_1 = require("../helpers");
|
|
14
|
+
/* eslint-disable no-param-reassign */
|
|
15
|
+
/**
|
|
16
|
+
* Parse identifiers from a CSV list of preferences
|
|
17
|
+
*
|
|
18
|
+
* Ensures that all rows have a valid identifier
|
|
19
|
+
* and that all identifiers are unique.
|
|
20
|
+
*
|
|
21
|
+
* @param preferences - List of preferences
|
|
22
|
+
* @param currentState - The current file metadata state for parsing this list
|
|
23
|
+
* @returns The updated file metadata state
|
|
24
|
+
*/
|
|
25
|
+
async function parsePreferenceIdentifiersFromCsv(preferences, currentState) {
|
|
26
|
+
// Determine columns to map
|
|
27
|
+
const columnNames = (0, uniq_1.default)(preferences.map((x) => Object.keys(x)).flat());
|
|
28
|
+
// Determine the columns that could potentially be used for identifier
|
|
29
|
+
const remainingColumnsForIdentifier = (0, difference_1.default)(columnNames, [
|
|
30
|
+
...(currentState.identifierColumn ? [currentState.identifierColumn] : []),
|
|
31
|
+
...Object.keys(currentState.columnToPurposeName),
|
|
32
|
+
]);
|
|
33
|
+
// Determine the identifier column to work off of
|
|
34
|
+
if (!currentState.identifierColumn) {
|
|
35
|
+
const { identifierName } = await inquirer_1.default.prompt([
|
|
36
|
+
{
|
|
37
|
+
name: 'identifierName',
|
|
38
|
+
message: 'Choose the column that will be used as the identifier to upload consent preferences by',
|
|
39
|
+
type: 'list',
|
|
40
|
+
default: remainingColumnsForIdentifier.find((col) => col.toLowerCase().includes('email')) || remainingColumnsForIdentifier[0],
|
|
41
|
+
choices: remainingColumnsForIdentifier,
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
currentState.identifierColumn = identifierName;
|
|
45
|
+
}
|
|
46
|
+
logger_1.logger.info(colors_1.default.magenta(`Using identifier column "${currentState.identifierColumn}"`));
|
|
47
|
+
// Validate that the identifier column is present for all rows and unique
|
|
48
|
+
const identifierColumnsMissing = preferences
|
|
49
|
+
.map((pref, ind) => (pref[currentState.identifierColumn] ? null : [ind]))
|
|
50
|
+
.filter((x) => !!x)
|
|
51
|
+
.flat();
|
|
52
|
+
if (identifierColumnsMissing.length > 0) {
|
|
53
|
+
const msg = `The identifier column "${currentState.identifierColumn}" is missing a value for the following rows: ${identifierColumnsMissing.join(', ')}`;
|
|
54
|
+
logger_1.logger.warn(colors_1.default.yellow(msg));
|
|
55
|
+
// Ask user if they would like to skip rows missing an identifier
|
|
56
|
+
const skip = await (0, helpers_1.inquirerConfirmBoolean)({
|
|
57
|
+
message: 'Would you like to skip rows missing an identifier?',
|
|
58
|
+
});
|
|
59
|
+
if (!skip) {
|
|
60
|
+
throw new Error(msg);
|
|
61
|
+
}
|
|
62
|
+
// Filter out rows missing an identifier
|
|
63
|
+
const previous = preferences.length;
|
|
64
|
+
preferences = preferences.filter((pref) => pref[currentState.identifierColumn]);
|
|
65
|
+
logger_1.logger.info(colors_1.default.yellow(`Skipped ${previous - preferences.length} rows missing an identifier`));
|
|
66
|
+
}
|
|
67
|
+
logger_1.logger.info(colors_1.default.magenta(`The identifier column "${currentState.identifierColumn}" is present for all rows`));
|
|
68
|
+
// Validate that all identifiers are unique
|
|
69
|
+
const rowsByUserId = (0, groupBy_1.default)(preferences, currentState.identifierColumn);
|
|
70
|
+
const duplicateIdentifiers = Object.entries(rowsByUserId).filter(([, rows]) => rows.length > 1);
|
|
71
|
+
if (duplicateIdentifiers.length > 0) {
|
|
72
|
+
const msg = `The identifier column "${currentState.identifierColumn}" has duplicate values for the following rows: ${duplicateIdentifiers
|
|
73
|
+
.slice(0, 10)
|
|
74
|
+
.map(([userId, rows]) => `${userId} (${rows.length})`)
|
|
75
|
+
.join('\n')}`;
|
|
76
|
+
logger_1.logger.warn(colors_1.default.yellow(msg));
|
|
77
|
+
// Ask user if they would like to take the most recent update
|
|
78
|
+
// for each duplicate identifier
|
|
79
|
+
const skip = await (0, helpers_1.inquirerConfirmBoolean)({
|
|
80
|
+
message: 'Would you like to automatically take the latest update?',
|
|
81
|
+
});
|
|
82
|
+
if (!skip) {
|
|
83
|
+
throw new Error(msg);
|
|
84
|
+
}
|
|
85
|
+
preferences = Object.entries(rowsByUserId)
|
|
86
|
+
.map(([, rows]) => {
|
|
87
|
+
const sorted = rows.sort((a, b) => new Date(b[currentState.timestampColum]).getTime() -
|
|
88
|
+
new Date(a[currentState.timestampColum]).getTime());
|
|
89
|
+
return sorted[0];
|
|
90
|
+
})
|
|
91
|
+
.filter((x) => x);
|
|
92
|
+
}
|
|
93
|
+
return { currentState, preferences };
|
|
94
|
+
}
|
|
95
|
+
exports.parsePreferenceIdentifiersFromCsv = parsePreferenceIdentifiersFromCsv;
|
|
96
|
+
/* eslint-enable no-param-reassign */
|
|
97
|
+
//# sourceMappingURL=parsePreferenceIdentifiersFromCsv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePreferenceIdentifiersFromCsv.js","sourceRoot":"","sources":["../../src/preference-management/parsePreferenceIdentifiersFromCsv.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA+B;AAC/B,6DAAqC;AACrC,oDAA4B;AAC5B,wDAAgC;AAChC,mEAA2C;AAE3C,sCAAmC;AACnC,wCAAoD;AAEpD,sCAAsC;AAEtC;;;;;;;;;GASG;AACI,KAAK,UAAU,iCAAiC,CACrD,WAAqC,EACrC,YAA+B;IAO/B,2BAA2B;IAC3B,MAAM,WAAW,GAAG,IAAA,cAAI,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAExE,sEAAsE;IACtE,MAAM,6BAA6B,GAAG,IAAA,oBAAU,EAAC,WAAW,EAAE;QAC5D,GAAG,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,GAAG,MAAM,CAAC,IAAI,CAA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AC,CAAC;QAEhC,6DAA6D;QAC7D,gCAAgC;QAChC,MAAM,IAAI,GAAG,MAAM,IAAA,gCAAsB,EAAC;YACxC,OAAO,EAAE,yDAAyD;SACnE,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;SACtB;QACD,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;aACvC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE;YAChB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CACtB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,cAAe,CAAC,CAAC,CAAC,OAAO,EAAE;gBACnD,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,cAAe,CAAC,CAAC,CAAC,OAAO,EAAE,CACtD,CAAC;YACF,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;KACrB;IAED,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AACvC,CAAC;AArHD,8EAqHC;AACD,qCAAqC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PersistedState } from '@transcend-io/persisted-state';
|
|
2
|
+
import type { Got } from 'got';
|
|
3
|
+
import { PreferenceState } from './codecs';
|
|
4
|
+
import { PreferenceTopic } from '../graphql';
|
|
5
|
+
/**
|
|
6
|
+
* Parse a file into the cache
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* @param options - Options
|
|
10
|
+
* @param cache - The cache to store the parsed file in
|
|
11
|
+
* @returns The cache with the parsed file
|
|
12
|
+
*/
|
|
13
|
+
export declare function parsePreferenceManagementCsvWithCache({ file, sombra, purposeSlugs, preferenceTopics, partitionKey, }: {
|
|
14
|
+
/** File to parse */
|
|
15
|
+
file: string;
|
|
16
|
+
/** The purpose slugs that are allowed to be updated */
|
|
17
|
+
purposeSlugs: string[];
|
|
18
|
+
/** The preference topics */
|
|
19
|
+
preferenceTopics: PreferenceTopic[];
|
|
20
|
+
/** Sombra got instance */
|
|
21
|
+
sombra: Got;
|
|
22
|
+
/** Partition key */
|
|
23
|
+
partitionKey: string;
|
|
24
|
+
}, cache: PersistedState<typeof PreferenceState>): Promise<void>;
|
|
25
|
+
//# sourceMappingURL=parsePreferenceManagementCsv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePreferenceManagementCsv.d.ts","sourceRoot":"","sources":["../../src/preference-management/parsePreferenceManagementCsv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAI/B,OAAO,EAAqB,eAAe,EAAE,MAAM,UAAU,CAAC;AAI9D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQ7C;;;;;;;GAOG;AACH,wBAAsB,qCAAqC,CACzD,EACE,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,YAAY,GACb,EAAE;IACD,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,4BAA4B;IAC5B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,0BAA0B;IAC1B,MAAM,EAAE,GAAG,CAAC;IACZ,oBAAoB;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,EACD,KAAK,EAAE,cAAc,CAAC,OAAO,eAAe,CAAC,GAC5C,OAAO,CAAC,IAAI,CAAC,CAgIf"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.parsePreferenceManagementCsvWithCache = void 0;
|
|
30
|
+
const keyBy_1 = __importDefault(require("lodash/keyBy"));
|
|
31
|
+
const t = __importStar(require("io-ts"));
|
|
32
|
+
const colors_1 = __importDefault(require("colors"));
|
|
33
|
+
const logger_1 = require("../logger");
|
|
34
|
+
const requests_1 = require("../requests");
|
|
35
|
+
const getPreferencesForIdentifiers_1 = require("./getPreferencesForIdentifiers");
|
|
36
|
+
const getPreferenceUpdatesFromRow_1 = require("./getPreferenceUpdatesFromRow");
|
|
37
|
+
const parsePreferenceTimestampsFromCsv_1 = require("./parsePreferenceTimestampsFromCsv");
|
|
38
|
+
const parsePreferenceIdentifiersFromCsv_1 = require("./parsePreferenceIdentifiersFromCsv");
|
|
39
|
+
const parsePreferenceAndPurposeValuesFromCsv_1 = require("./parsePreferenceAndPurposeValuesFromCsv");
|
|
40
|
+
const checkIfPendingPreferenceUpdatesAreNoOp_1 = require("./checkIfPendingPreferenceUpdatesAreNoOp");
|
|
41
|
+
const checkIfPendingPreferenceUpdatesCauseConflict_1 = require("./checkIfPendingPreferenceUpdatesCauseConflict");
|
|
42
|
+
/**
|
|
43
|
+
* Parse a file into the cache
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
* @param options - Options
|
|
47
|
+
* @param cache - The cache to store the parsed file in
|
|
48
|
+
* @returns The cache with the parsed file
|
|
49
|
+
*/
|
|
50
|
+
async function parsePreferenceManagementCsvWithCache({ file, sombra, purposeSlugs, preferenceTopics, partitionKey, }, cache) {
|
|
51
|
+
// Start the timer
|
|
52
|
+
const t0 = new Date().getTime();
|
|
53
|
+
// Get the current metadata
|
|
54
|
+
const fileMetadata = cache.getValue('fileMetadata');
|
|
55
|
+
// Read in the file
|
|
56
|
+
logger_1.logger.info(colors_1.default.magenta(`Reading in file: "${file}"`));
|
|
57
|
+
let preferences = (0, requests_1.readCsv)(file, t.record(t.string, t.string));
|
|
58
|
+
// start building the cache, can use previous cache as well
|
|
59
|
+
let currentState = {
|
|
60
|
+
columnToPurposeName: {},
|
|
61
|
+
pendingSafeUpdates: {},
|
|
62
|
+
pendingConflictUpdates: {},
|
|
63
|
+
skippedUpdates: {},
|
|
64
|
+
// Load in the last fetched time
|
|
65
|
+
...(fileMetadata[file] || {}),
|
|
66
|
+
lastFetchedAt: new Date().toISOString(),
|
|
67
|
+
};
|
|
68
|
+
// Validate that all timestamps are present in the file
|
|
69
|
+
currentState = await (0, parsePreferenceTimestampsFromCsv_1.parsePreferenceTimestampsFromCsv)(preferences, currentState);
|
|
70
|
+
fileMetadata[file] = currentState;
|
|
71
|
+
await cache.setValue(fileMetadata, 'fileMetadata');
|
|
72
|
+
// Validate that all identifiers are present and unique
|
|
73
|
+
const result = await (0, parsePreferenceIdentifiersFromCsv_1.parsePreferenceIdentifiersFromCsv)(preferences, currentState);
|
|
74
|
+
currentState = result.currentState;
|
|
75
|
+
preferences = result.preferences;
|
|
76
|
+
fileMetadata[file] = currentState;
|
|
77
|
+
await cache.setValue(fileMetadata, 'fileMetadata');
|
|
78
|
+
// Ensure all other columns are mapped to purpose and preference
|
|
79
|
+
// slug values
|
|
80
|
+
currentState = await (0, parsePreferenceAndPurposeValuesFromCsv_1.parsePreferenceAndPurposeValuesFromCsv)(preferences, currentState, {
|
|
81
|
+
preferenceTopics,
|
|
82
|
+
purposeSlugs,
|
|
83
|
+
});
|
|
84
|
+
fileMetadata[file] = currentState;
|
|
85
|
+
await cache.setValue(fileMetadata, 'fileMetadata');
|
|
86
|
+
// Grab existing preference store records
|
|
87
|
+
const identifiers = preferences.map((pref) => pref[currentState.identifierColumn]);
|
|
88
|
+
const existingConsentRecords = await (0, getPreferencesForIdentifiers_1.getPreferencesForIdentifiers)(sombra, {
|
|
89
|
+
identifiers: identifiers.map((x) => ({ value: x })),
|
|
90
|
+
partitionKey,
|
|
91
|
+
});
|
|
92
|
+
const consentRecordByIdentifier = (0, keyBy_1.default)(existingConsentRecords, 'userId');
|
|
93
|
+
// Clear out previous updates
|
|
94
|
+
currentState.pendingConflictUpdates = {};
|
|
95
|
+
currentState.pendingSafeUpdates = {};
|
|
96
|
+
currentState.skippedUpdates = {};
|
|
97
|
+
// Process each row
|
|
98
|
+
preferences.forEach((pref) => {
|
|
99
|
+
// Grab unique Id for the user
|
|
100
|
+
const userId = pref[currentState.identifierColumn];
|
|
101
|
+
// determine updates for user
|
|
102
|
+
const pendingUpdates = (0, getPreferenceUpdatesFromRow_1.getPreferenceUpdatesFromRow)({
|
|
103
|
+
row: pref,
|
|
104
|
+
columnToPurposeName: currentState.columnToPurposeName,
|
|
105
|
+
preferenceTopics,
|
|
106
|
+
purposeSlugs,
|
|
107
|
+
});
|
|
108
|
+
// Grab current state of the update
|
|
109
|
+
const currentConsentRecord = consentRecordByIdentifier[userId];
|
|
110
|
+
// Check if the update can be skipped
|
|
111
|
+
// this is the case if a record exists, and the purpose
|
|
112
|
+
// and preference values are all in sync
|
|
113
|
+
if (currentConsentRecord &&
|
|
114
|
+
(0, checkIfPendingPreferenceUpdatesAreNoOp_1.checkIfPendingPreferenceUpdatesAreNoOp)({
|
|
115
|
+
currentConsentRecord,
|
|
116
|
+
pendingUpdates,
|
|
117
|
+
preferenceTopics,
|
|
118
|
+
})) {
|
|
119
|
+
currentState.skippedUpdates[userId] = pref;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// Determine if there are any conflicts
|
|
123
|
+
if (currentConsentRecord &&
|
|
124
|
+
(0, checkIfPendingPreferenceUpdatesCauseConflict_1.checkIfPendingPreferenceUpdatesCauseConflict)({
|
|
125
|
+
currentConsentRecord,
|
|
126
|
+
pendingUpdates,
|
|
127
|
+
preferenceTopics,
|
|
128
|
+
})) {
|
|
129
|
+
currentState.pendingConflictUpdates[userId] = {
|
|
130
|
+
row: pref,
|
|
131
|
+
record: currentConsentRecord,
|
|
132
|
+
};
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Add to pending updates
|
|
136
|
+
currentState.pendingSafeUpdates[userId] = pref;
|
|
137
|
+
});
|
|
138
|
+
// Read in the file
|
|
139
|
+
fileMetadata[file] = currentState;
|
|
140
|
+
await cache.setValue(fileMetadata, 'fileMetadata');
|
|
141
|
+
const t1 = new Date().getTime();
|
|
142
|
+
logger_1.logger.info(colors_1.default.green(`Successfully pre-processed file: "${file}" in ${(t1 - t0) / 1000}s`));
|
|
143
|
+
}
|
|
144
|
+
exports.parsePreferenceManagementCsvWithCache = parsePreferenceManagementCsvWithCache;
|
|
145
|
+
//# sourceMappingURL=parsePreferenceManagementCsv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePreferenceManagementCsv.js","sourceRoot":"","sources":["../../src/preference-management/parsePreferenceManagementCsv.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yDAAiC;AACjC,yCAA2B;AAC3B,oDAA4B;AAE5B,sCAAmC;AACnC,0CAAsC;AACtC,iFAA8E;AAE9E,+EAA4E;AAC5E,yFAAsF;AACtF,2FAAwF;AACxF,qGAAkG;AAClG,qGAAkG;AAClG,iHAA8G;AAE9G;;;;;;;GAOG;AACI,KAAK,UAAU,qCAAqC,CACzD,EACE,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,YAAY,GAYb,EACD,KAA6C;IAE7C,kBAAkB;IAClB,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAEhC,2BAA2B;IAC3B,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEpD,mBAAmB;IACnB,eAAM,CAAC,IAAI,CAAC,gBAAM,CAAC,OAAO,CAAC,qBAAqB,IAAI,GAAG,CAAC,CAAC,CAAC;IAC1D,IAAI,WAAW,GAAG,IAAA,kBAAO,EAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAE9D,2DAA2D;IAC3D,IAAI,YAAY,GAAsB;QACpC,mBAAmB,EAAE,EAAE;QACvB,kBAAkB,EAAE,EAAE;QACtB,sBAAsB,EAAE,EAAE;QAC1B,cAAc,EAAE,EAAE;QAClB,gCAAgC;QAChC,GAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAgC;QAC7D,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACxC,CAAC;IAEF,uDAAuD;IACvD,YAAY,GAAG,MAAM,IAAA,mEAAgC,EACnD,WA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