@transcend-io/cli 6.9.0 → 6.11.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/codecs.d.ts +12 -0
- package/build/codecs.d.ts.map +1 -1
- package/build/codecs.js +2 -0
- package/build/codecs.js.map +1 -1
- 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/pullTranscendConfiguration.d.ts.map +1 -1
- package/build/graphql/pullTranscendConfiguration.js +2 -1
- package/build/graphql/pullTranscendConfiguration.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,369 @@
|
|
|
1
|
+
import * as t from 'io-ts';
|
|
2
|
+
export declare const PurposeRowMapping: t.TypeC<{
|
|
3
|
+
/**
|
|
4
|
+
* The slug or trackingType of the purpose to map to
|
|
5
|
+
*
|
|
6
|
+
* e.g. `Marketing`
|
|
7
|
+
*/
|
|
8
|
+
purpose: t.StringC;
|
|
9
|
+
/**
|
|
10
|
+
* If the column maps to a preference instead of a purpose
|
|
11
|
+
* this is the slug of the purpose.
|
|
12
|
+
*
|
|
13
|
+
* null value indicates that this column maps to the true/false
|
|
14
|
+
* value of the purpose
|
|
15
|
+
*/
|
|
16
|
+
preference: t.UnionC<[t.StringC, t.NullC]>;
|
|
17
|
+
/**
|
|
18
|
+
* The mapping between each row value and purpose/preference value.
|
|
19
|
+
*
|
|
20
|
+
* e.g. for a boolean preference or purpose
|
|
21
|
+
* {
|
|
22
|
+
* 'true': true,
|
|
23
|
+
* 'false': false,
|
|
24
|
+
* '': true,
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* or for a single or multi select preference
|
|
28
|
+
* {
|
|
29
|
+
* '': true,
|
|
30
|
+
* 'value1': 'Value1',
|
|
31
|
+
* 'value2': 'Value2',
|
|
32
|
+
* }
|
|
33
|
+
*/
|
|
34
|
+
valueMapping: t.RecordC<t.StringC, t.UnionC<[t.StringC, t.BooleanC, t.NullC]>>;
|
|
35
|
+
}>;
|
|
36
|
+
/** Override type */
|
|
37
|
+
export type PurposeRowMapping = t.TypeOf<typeof PurposeRowMapping>;
|
|
38
|
+
export declare const FileMetadataState: t.IntersectionC<[t.TypeC<{
|
|
39
|
+
/**
|
|
40
|
+
* Definition of how to map each column in the CSV to
|
|
41
|
+
* the relevant purpose and preference definitions in transcend
|
|
42
|
+
*/
|
|
43
|
+
columnToPurposeName: t.RecordC<t.StringC, t.TypeC<{
|
|
44
|
+
/**
|
|
45
|
+
* The slug or trackingType of the purpose to map to
|
|
46
|
+
*
|
|
47
|
+
* e.g. `Marketing`
|
|
48
|
+
*/
|
|
49
|
+
purpose: t.StringC;
|
|
50
|
+
/**
|
|
51
|
+
* If the column maps to a preference instead of a purpose
|
|
52
|
+
* this is the slug of the purpose.
|
|
53
|
+
*
|
|
54
|
+
* null value indicates that this column maps to the true/false
|
|
55
|
+
* value of the purpose
|
|
56
|
+
*/
|
|
57
|
+
preference: t.UnionC<[t.StringC, t.NullC]>;
|
|
58
|
+
/**
|
|
59
|
+
* The mapping between each row value and purpose/preference value.
|
|
60
|
+
*
|
|
61
|
+
* e.g. for a boolean preference or purpose
|
|
62
|
+
* {
|
|
63
|
+
* 'true': true,
|
|
64
|
+
* 'false': false,
|
|
65
|
+
* '': true,
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* or for a single or multi select preference
|
|
69
|
+
* {
|
|
70
|
+
* '': true,
|
|
71
|
+
* 'value1': 'Value1',
|
|
72
|
+
* 'value2': 'Value2',
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
valueMapping: t.RecordC<t.StringC, t.UnionC<[t.StringC, t.BooleanC, t.NullC]>>;
|
|
76
|
+
}>>;
|
|
77
|
+
/** Last time the file was last parsed at */
|
|
78
|
+
lastFetchedAt: t.StringC;
|
|
79
|
+
/**
|
|
80
|
+
* Mapping of userId to the rows in the file that need to be uploaded
|
|
81
|
+
* These uploads are overwriting non-existent preferences and are safe
|
|
82
|
+
*/
|
|
83
|
+
pendingSafeUpdates: t.RecordC<t.StringC, t.RecordC<t.StringC, t.StringC>>;
|
|
84
|
+
/**
|
|
85
|
+
* Mapping of userId to the rows in the file that need to be uploaded
|
|
86
|
+
* these records have conflicts with existing consent preferences
|
|
87
|
+
*/
|
|
88
|
+
pendingConflictUpdates: t.RecordC<t.StringC, t.TypeC<{
|
|
89
|
+
record: t.IntersectionC<[t.TypeC<{
|
|
90
|
+
userId: t.StringC;
|
|
91
|
+
partition: t.StringC;
|
|
92
|
+
timestamp: t.StringC;
|
|
93
|
+
}>, t.TypeC<{
|
|
94
|
+
system: t.IntersectionC<[t.TypeC<{
|
|
95
|
+
decryptionStatus: t.KeyofC<{
|
|
96
|
+
ERROR: unknown;
|
|
97
|
+
DECRYPTED: unknown;
|
|
98
|
+
}>;
|
|
99
|
+
}>, t.PartialC<{
|
|
100
|
+
updatedAt: t.StringC;
|
|
101
|
+
}>]>;
|
|
102
|
+
consentManagement: t.PartialC<{
|
|
103
|
+
usp: t.UnionC<[t.StringC, t.NullC]>;
|
|
104
|
+
gpp: t.UnionC<[t.StringC, t.NullC]>;
|
|
105
|
+
tcf: t.UnionC<[t.StringC, t.NullC]>;
|
|
106
|
+
airgapVersion: t.UnionC<[t.StringC, t.NullC]>;
|
|
107
|
+
}>;
|
|
108
|
+
purposes: t.ArrayC<t.IntersectionC<[t.TypeC<{
|
|
109
|
+
purpose: t.StringC;
|
|
110
|
+
enabled: t.BooleanC;
|
|
111
|
+
}>, t.PartialC<{
|
|
112
|
+
preferences: t.ArrayC<t.TypeC<{
|
|
113
|
+
topic: t.StringC;
|
|
114
|
+
choice: t.PartialC<{
|
|
115
|
+
booleanValue: t.UnionC<[t.BooleanC, t.NullC]>;
|
|
116
|
+
selectValue: t.UnionC<[t.StringC, t.NullC]>;
|
|
117
|
+
selectValues: t.UnionC<[t.ArrayC<t.StringC>, t.NullC]>;
|
|
118
|
+
}>;
|
|
119
|
+
}>>;
|
|
120
|
+
}>]>>;
|
|
121
|
+
}>, t.PartialC<{
|
|
122
|
+
metadata: t.ArrayC<t.TypeC<{
|
|
123
|
+
key: t.StringC;
|
|
124
|
+
value: t.StringC;
|
|
125
|
+
}>>;
|
|
126
|
+
metadataTimestamp: t.StringC;
|
|
127
|
+
}>]>;
|
|
128
|
+
row: t.RecordC<t.StringC, t.StringC>;
|
|
129
|
+
}>>;
|
|
130
|
+
/**
|
|
131
|
+
* Mapping of userId to the rows in the file that can be skipped because
|
|
132
|
+
* their preferences are already in the store
|
|
133
|
+
*/
|
|
134
|
+
skippedUpdates: t.RecordC<t.StringC, t.RecordC<t.StringC, t.StringC>>;
|
|
135
|
+
}>, t.PartialC<{
|
|
136
|
+
/** Determine which column name in file maps to consent record identifier to upload on */
|
|
137
|
+
identifierColumn: t.StringC;
|
|
138
|
+
/** Determine which column name in file maps to the timestamp */
|
|
139
|
+
timestampColum: t.StringC;
|
|
140
|
+
}>]>;
|
|
141
|
+
/** Override type */
|
|
142
|
+
export type FileMetadataState = t.TypeOf<typeof FileMetadataState>;
|
|
143
|
+
/** Persist this data between runs of the script */
|
|
144
|
+
export declare const PreferenceState: t.TypeC<{
|
|
145
|
+
/**
|
|
146
|
+
* Store a cache of previous files read in
|
|
147
|
+
*/
|
|
148
|
+
fileMetadata: t.RecordC<t.StringC, t.IntersectionC<[t.TypeC<{
|
|
149
|
+
/**
|
|
150
|
+
* Definition of how to map each column in the CSV to
|
|
151
|
+
* the relevant purpose and preference definitions in transcend
|
|
152
|
+
*/
|
|
153
|
+
columnToPurposeName: t.RecordC<t.StringC, t.TypeC<{
|
|
154
|
+
/**
|
|
155
|
+
* The slug or trackingType of the purpose to map to
|
|
156
|
+
*
|
|
157
|
+
* e.g. `Marketing`
|
|
158
|
+
*/
|
|
159
|
+
purpose: t.StringC;
|
|
160
|
+
/**
|
|
161
|
+
* If the column maps to a preference instead of a purpose
|
|
162
|
+
* this is the slug of the purpose.
|
|
163
|
+
*
|
|
164
|
+
* null value indicates that this column maps to the true/false
|
|
165
|
+
* value of the purpose
|
|
166
|
+
*/
|
|
167
|
+
preference: t.UnionC<[t.StringC, t.NullC]>;
|
|
168
|
+
/**
|
|
169
|
+
* The mapping between each row value and purpose/preference value.
|
|
170
|
+
*
|
|
171
|
+
* e.g. for a boolean preference or purpose
|
|
172
|
+
* {
|
|
173
|
+
* 'true': true,
|
|
174
|
+
* 'false': false,
|
|
175
|
+
* '': true,
|
|
176
|
+
* }
|
|
177
|
+
*
|
|
178
|
+
* or for a single or multi select preference
|
|
179
|
+
* {
|
|
180
|
+
* '': true,
|
|
181
|
+
* 'value1': 'Value1',
|
|
182
|
+
* 'value2': 'Value2',
|
|
183
|
+
* }
|
|
184
|
+
*/
|
|
185
|
+
valueMapping: t.RecordC<t.StringC, t.UnionC<[t.StringC, t.BooleanC, t.NullC]>>;
|
|
186
|
+
}>>;
|
|
187
|
+
/** Last time the file was last parsed at */
|
|
188
|
+
lastFetchedAt: t.StringC;
|
|
189
|
+
/**
|
|
190
|
+
* Mapping of userId to the rows in the file that need to be uploaded
|
|
191
|
+
* These uploads are overwriting non-existent preferences and are safe
|
|
192
|
+
*/
|
|
193
|
+
pendingSafeUpdates: t.RecordC<t.StringC, t.RecordC<t.StringC, t.StringC>>;
|
|
194
|
+
/**
|
|
195
|
+
* Mapping of userId to the rows in the file that need to be uploaded
|
|
196
|
+
* these records have conflicts with existing consent preferences
|
|
197
|
+
*/
|
|
198
|
+
pendingConflictUpdates: t.RecordC<t.StringC, t.TypeC<{
|
|
199
|
+
record: t.IntersectionC<[t.TypeC<{
|
|
200
|
+
userId: t.StringC;
|
|
201
|
+
partition: t.StringC;
|
|
202
|
+
timestamp: t.StringC;
|
|
203
|
+
}>, t.TypeC<{
|
|
204
|
+
system: t.IntersectionC<[t.TypeC<{
|
|
205
|
+
decryptionStatus: t.KeyofC<{
|
|
206
|
+
ERROR: unknown;
|
|
207
|
+
DECRYPTED: unknown;
|
|
208
|
+
}>;
|
|
209
|
+
}>, t.PartialC<{
|
|
210
|
+
updatedAt: t.StringC;
|
|
211
|
+
}>]>;
|
|
212
|
+
consentManagement: t.PartialC<{
|
|
213
|
+
usp: t.UnionC<[t.StringC, t.NullC]>;
|
|
214
|
+
gpp: t.UnionC<[t.StringC, t.NullC]>;
|
|
215
|
+
tcf: t.UnionC<[t.StringC, t.NullC]>;
|
|
216
|
+
airgapVersion: t.UnionC<[t.StringC, t.NullC]>;
|
|
217
|
+
}>;
|
|
218
|
+
purposes: t.ArrayC<t.IntersectionC<[t.TypeC<{
|
|
219
|
+
purpose: t.StringC;
|
|
220
|
+
enabled: t.BooleanC;
|
|
221
|
+
}>, t.PartialC<{
|
|
222
|
+
preferences: t.ArrayC<t.TypeC<{
|
|
223
|
+
topic: t.StringC;
|
|
224
|
+
choice: t.PartialC<{
|
|
225
|
+
booleanValue: t.UnionC<[t.BooleanC, t.NullC]>;
|
|
226
|
+
selectValue: t.UnionC<[t.StringC, t.NullC]>;
|
|
227
|
+
selectValues: t.UnionC<[t.ArrayC<t.StringC>, t.NullC]>;
|
|
228
|
+
}>;
|
|
229
|
+
}>>;
|
|
230
|
+
}>]>>;
|
|
231
|
+
}>, t.PartialC<{
|
|
232
|
+
metadata: t.ArrayC<t.TypeC<{
|
|
233
|
+
key: t.StringC;
|
|
234
|
+
value: t.StringC;
|
|
235
|
+
}>>;
|
|
236
|
+
metadataTimestamp: t.StringC;
|
|
237
|
+
}>]>;
|
|
238
|
+
row: t.RecordC<t.StringC, t.StringC>;
|
|
239
|
+
}>>;
|
|
240
|
+
/**
|
|
241
|
+
* Mapping of userId to the rows in the file that can be skipped because
|
|
242
|
+
* their preferences are already in the store
|
|
243
|
+
*/
|
|
244
|
+
skippedUpdates: t.RecordC<t.StringC, t.RecordC<t.StringC, t.StringC>>;
|
|
245
|
+
}>, t.PartialC<{
|
|
246
|
+
/** Determine which column name in file maps to consent record identifier to upload on */
|
|
247
|
+
identifierColumn: t.StringC;
|
|
248
|
+
/** Determine which column name in file maps to the timestamp */
|
|
249
|
+
timestampColum: t.StringC;
|
|
250
|
+
}>]>>;
|
|
251
|
+
/**
|
|
252
|
+
* The set of successful uploads to Transcend
|
|
253
|
+
* Mapping from userId to the upload metadata
|
|
254
|
+
*/
|
|
255
|
+
failingUpdates: t.RecordC<t.StringC, t.TypeC<{
|
|
256
|
+
/** Time upload ran at */
|
|
257
|
+
uploadedAt: t.StringC;
|
|
258
|
+
/** Attempts to upload that resulted in an error */
|
|
259
|
+
error: t.StringC;
|
|
260
|
+
/** The update body */
|
|
261
|
+
update: t.IntersectionC<[t.TypeC<{
|
|
262
|
+
userId: t.StringC;
|
|
263
|
+
partition: t.StringC;
|
|
264
|
+
timestamp: t.StringC;
|
|
265
|
+
}>, t.PartialC<{
|
|
266
|
+
purposes: t.ArrayC<t.IntersectionC<[t.IntersectionC<[t.TypeC<{
|
|
267
|
+
purpose: t.StringC;
|
|
268
|
+
enabled: t.BooleanC;
|
|
269
|
+
}>, t.PartialC<{
|
|
270
|
+
preferences: t.ArrayC<t.TypeC<{
|
|
271
|
+
topic: t.StringC;
|
|
272
|
+
choice: t.PartialC<{
|
|
273
|
+
booleanValue: t.UnionC<[t.BooleanC, t.NullC]>;
|
|
274
|
+
selectValue: t.UnionC<[t.StringC, t.NullC]>;
|
|
275
|
+
selectValues: t.UnionC<[t.ArrayC<t.StringC>, t.NullC]>;
|
|
276
|
+
}>;
|
|
277
|
+
}>>;
|
|
278
|
+
}>]>, t.PartialC<{
|
|
279
|
+
attributes: t.ArrayC<t.TypeC<{
|
|
280
|
+
key: t.StringC;
|
|
281
|
+
values: t.ArrayC<t.StringC>;
|
|
282
|
+
}>>;
|
|
283
|
+
workflowSettings: t.PartialC<{
|
|
284
|
+
attributes: t.ArrayC<t.TypeC<{
|
|
285
|
+
key: t.StringC;
|
|
286
|
+
values: t.ArrayC<t.StringC>;
|
|
287
|
+
}>>;
|
|
288
|
+
dataSiloIds: t.ArrayC<t.StringC>;
|
|
289
|
+
emailReceiptTemplateId: t.StringC;
|
|
290
|
+
ignoreDataSiloIds: t.ArrayC<t.StringC>;
|
|
291
|
+
isSilent: t.BooleanC;
|
|
292
|
+
isTest: t.BooleanC;
|
|
293
|
+
skipSendingReceipt: t.BooleanC;
|
|
294
|
+
skipWaitingPeriod: t.BooleanC;
|
|
295
|
+
skipWorkflowTrigger: t.BooleanC;
|
|
296
|
+
}>;
|
|
297
|
+
locale: t.StringC;
|
|
298
|
+
}>]>>;
|
|
299
|
+
consentManagement: t.PartialC<{
|
|
300
|
+
usp: t.UnionC<[t.StringC, t.NullC]>;
|
|
301
|
+
gpp: t.UnionC<[t.StringC, t.NullC]>;
|
|
302
|
+
tcf: t.UnionC<[t.StringC, t.NullC]>;
|
|
303
|
+
airgapVersion: t.UnionC<[t.StringC, t.NullC]>;
|
|
304
|
+
}>;
|
|
305
|
+
locale: t.StringC;
|
|
306
|
+
metadata: t.ArrayC<t.TypeC<{
|
|
307
|
+
key: t.StringC;
|
|
308
|
+
value: t.UnionC<[t.StringC, t.NullC]>;
|
|
309
|
+
}>>;
|
|
310
|
+
}>]>;
|
|
311
|
+
}>>;
|
|
312
|
+
/**
|
|
313
|
+
* The set of pending uploads to Transcend
|
|
314
|
+
* Mapping from userId to the upload metadata
|
|
315
|
+
*/
|
|
316
|
+
pendingUpdates: t.RecordC<t.StringC, t.IntersectionC<[t.TypeC<{
|
|
317
|
+
userId: t.StringC;
|
|
318
|
+
partition: t.StringC;
|
|
319
|
+
timestamp: t.StringC;
|
|
320
|
+
}>, t.PartialC<{
|
|
321
|
+
purposes: t.ArrayC<t.IntersectionC<[t.IntersectionC<[t.TypeC<{
|
|
322
|
+
purpose: t.StringC;
|
|
323
|
+
enabled: t.BooleanC;
|
|
324
|
+
}>, t.PartialC<{
|
|
325
|
+
preferences: t.ArrayC<t.TypeC<{
|
|
326
|
+
topic: t.StringC;
|
|
327
|
+
choice: t.PartialC<{
|
|
328
|
+
booleanValue: t.UnionC<[t.BooleanC, t.NullC]>;
|
|
329
|
+
selectValue: t.UnionC<[t.StringC, t.NullC]>;
|
|
330
|
+
selectValues: t.UnionC<[t.ArrayC<t.StringC>, t.NullC]>;
|
|
331
|
+
}>;
|
|
332
|
+
}>>;
|
|
333
|
+
}>]>, t.PartialC<{
|
|
334
|
+
attributes: t.ArrayC<t.TypeC<{
|
|
335
|
+
key: t.StringC;
|
|
336
|
+
values: t.ArrayC<t.StringC>;
|
|
337
|
+
}>>;
|
|
338
|
+
workflowSettings: t.PartialC<{
|
|
339
|
+
attributes: t.ArrayC<t.TypeC<{
|
|
340
|
+
key: t.StringC;
|
|
341
|
+
values: t.ArrayC<t.StringC>;
|
|
342
|
+
}>>;
|
|
343
|
+
dataSiloIds: t.ArrayC<t.StringC>;
|
|
344
|
+
emailReceiptTemplateId: t.StringC;
|
|
345
|
+
ignoreDataSiloIds: t.ArrayC<t.StringC>;
|
|
346
|
+
isSilent: t.BooleanC;
|
|
347
|
+
isTest: t.BooleanC;
|
|
348
|
+
skipSendingReceipt: t.BooleanC;
|
|
349
|
+
skipWaitingPeriod: t.BooleanC;
|
|
350
|
+
skipWorkflowTrigger: t.BooleanC;
|
|
351
|
+
}>;
|
|
352
|
+
locale: t.StringC;
|
|
353
|
+
}>]>>;
|
|
354
|
+
consentManagement: t.PartialC<{
|
|
355
|
+
usp: t.UnionC<[t.StringC, t.NullC]>;
|
|
356
|
+
gpp: t.UnionC<[t.StringC, t.NullC]>;
|
|
357
|
+
tcf: t.UnionC<[t.StringC, t.NullC]>;
|
|
358
|
+
airgapVersion: t.UnionC<[t.StringC, t.NullC]>;
|
|
359
|
+
}>;
|
|
360
|
+
locale: t.StringC;
|
|
361
|
+
metadata: t.ArrayC<t.TypeC<{
|
|
362
|
+
key: t.StringC;
|
|
363
|
+
value: t.UnionC<[t.StringC, t.NullC]>;
|
|
364
|
+
}>>;
|
|
365
|
+
}>]>>;
|
|
366
|
+
}>;
|
|
367
|
+
/** Override type */
|
|
368
|
+
export type PreferenceState = t.TypeOf<typeof PreferenceState>;
|
|
369
|
+
//# sourceMappingURL=codecs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../src/preference-management/codecs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,eAAO,MAAM,iBAAiB;IAC5B;;;;OAIG;;IAEH;;;;;;OAMG;;IAEH;;;;;;;;;;;;;;;;OAgBG;;EAEH,CAAC;AAEH,oBAAoB;AACpB,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,eAAO,MAAM,iBAAiB;IAE1B;;;OAGG;;QA1CL;;;;WAIG;;QAEH;;;;;;WAMG;;QAEH;;;;;;;;;;;;;;;;WAgBG;;;IAcD,4CAA4C;;IAE5C;;;OAGG;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAQH;;;OAGG;;;IAIH,0FAA0F;;IAE1F,iEAAiE;;IAGnE,CAAC;AAEH,oBAAoB;AACpB,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,mDAAmD;AACnD,eAAO,MAAM,eAAe;IAC1B;;OAEG;;QA5CD;;;WAGG;;YA1CL;;;;eAIG;;YAEH;;;;;;eAMG;;YAEH;;;;;;;;;;;;;;;;eAgBG;;;QAcD,4CAA4C;;QAE5C;;;WAGG;;QAEH;;;WAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAQH;;;WAGG;;;QAIH,0FAA0F;;QAE1F,iEAAiE;;;IAcnE;;;OAGG;;QAIC,yBAAyB;;QAEzB,mDAAmD;;QAEnD,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAI1B;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAC;AAEH,oBAAoB;AACpB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.PreferenceState = exports.FileMetadataState = exports.PurposeRowMapping = void 0;
|
|
27
|
+
const privacy_types_1 = require("@transcend-io/privacy-types");
|
|
28
|
+
const t = __importStar(require("io-ts"));
|
|
29
|
+
exports.PurposeRowMapping = t.type({
|
|
30
|
+
/**
|
|
31
|
+
* The slug or trackingType of the purpose to map to
|
|
32
|
+
*
|
|
33
|
+
* e.g. `Marketing`
|
|
34
|
+
*/
|
|
35
|
+
purpose: t.string,
|
|
36
|
+
/**
|
|
37
|
+
* If the column maps to a preference instead of a purpose
|
|
38
|
+
* this is the slug of the purpose.
|
|
39
|
+
*
|
|
40
|
+
* null value indicates that this column maps to the true/false
|
|
41
|
+
* value of the purpose
|
|
42
|
+
*/
|
|
43
|
+
preference: t.union([t.string, t.null]),
|
|
44
|
+
/**
|
|
45
|
+
* The mapping between each row value and purpose/preference value.
|
|
46
|
+
*
|
|
47
|
+
* e.g. for a boolean preference or purpose
|
|
48
|
+
* {
|
|
49
|
+
* 'true': true,
|
|
50
|
+
* 'false': false,
|
|
51
|
+
* '': true,
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* or for a single or multi select preference
|
|
55
|
+
* {
|
|
56
|
+
* '': true,
|
|
57
|
+
* 'value1': 'Value1',
|
|
58
|
+
* 'value2': 'Value2',
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
valueMapping: t.record(t.string, t.union([t.string, t.boolean, t.null])),
|
|
62
|
+
});
|
|
63
|
+
exports.FileMetadataState = t.intersection([
|
|
64
|
+
t.type({
|
|
65
|
+
/**
|
|
66
|
+
* Definition of how to map each column in the CSV to
|
|
67
|
+
* the relevant purpose and preference definitions in transcend
|
|
68
|
+
*/
|
|
69
|
+
columnToPurposeName: t.record(t.string, exports.PurposeRowMapping),
|
|
70
|
+
/** Last time the file was last parsed at */
|
|
71
|
+
lastFetchedAt: t.string,
|
|
72
|
+
/**
|
|
73
|
+
* Mapping of userId to the rows in the file that need to be uploaded
|
|
74
|
+
* These uploads are overwriting non-existent preferences and are safe
|
|
75
|
+
*/
|
|
76
|
+
pendingSafeUpdates: t.record(t.string, t.record(t.string, t.string)),
|
|
77
|
+
/**
|
|
78
|
+
* Mapping of userId to the rows in the file that need to be uploaded
|
|
79
|
+
* these records have conflicts with existing consent preferences
|
|
80
|
+
*/
|
|
81
|
+
pendingConflictUpdates: t.record(t.string, t.type({
|
|
82
|
+
record: privacy_types_1.PreferenceQueryResponseItem,
|
|
83
|
+
row: t.record(t.string, t.string),
|
|
84
|
+
})),
|
|
85
|
+
/**
|
|
86
|
+
* Mapping of userId to the rows in the file that can be skipped because
|
|
87
|
+
* their preferences are already in the store
|
|
88
|
+
*/
|
|
89
|
+
skippedUpdates: t.record(t.string, t.record(t.string, t.string)),
|
|
90
|
+
}),
|
|
91
|
+
t.partial({
|
|
92
|
+
/** Determine which column name in file maps to consent record identifier to upload on */
|
|
93
|
+
identifierColumn: t.string,
|
|
94
|
+
/** Determine which column name in file maps to the timestamp */
|
|
95
|
+
timestampColum: t.string,
|
|
96
|
+
}),
|
|
97
|
+
]);
|
|
98
|
+
/** Persist this data between runs of the script */
|
|
99
|
+
exports.PreferenceState = t.type({
|
|
100
|
+
/**
|
|
101
|
+
* Store a cache of previous files read in
|
|
102
|
+
*/
|
|
103
|
+
fileMetadata: t.record(t.string, exports.FileMetadataState),
|
|
104
|
+
/**
|
|
105
|
+
* The set of successful uploads to Transcend
|
|
106
|
+
* Mapping from userId to the upload metadata
|
|
107
|
+
*/
|
|
108
|
+
failingUpdates: t.record(t.string, t.type({
|
|
109
|
+
/** Time upload ran at */
|
|
110
|
+
uploadedAt: t.string,
|
|
111
|
+
/** Attempts to upload that resulted in an error */
|
|
112
|
+
error: t.string,
|
|
113
|
+
/** The update body */
|
|
114
|
+
update: privacy_types_1.PreferenceUpdateItem,
|
|
115
|
+
})),
|
|
116
|
+
/**
|
|
117
|
+
* The set of pending uploads to Transcend
|
|
118
|
+
* Mapping from userId to the upload metadata
|
|
119
|
+
*/
|
|
120
|
+
pendingUpdates: t.record(t.string, privacy_types_1.PreferenceUpdateItem),
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../src/preference-management/codecs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAGqC;AACrC,yCAA2B;AAEd,QAAA,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC;IACtC;;;;OAIG;IACH,OAAO,EAAE,CAAC,CAAC,MAAM;IACjB;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACvC;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;CACzE,CAAC,CAAC;AAKU,QAAA,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC9C,CAAC,CAAC,IAAI,CAAC;QACL;;;WAGG;QACH,mBAAmB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,yBAAiB,CAAC;QAC1D,4CAA4C;QAC5C,aAAa,EAAE,CAAC,CAAC,MAAM;QACvB;;;WAGG;QACH,kBAAkB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QACpE;;;WAGG;QACH,sBAAsB,EAAE,CAAC,CAAC,MAAM,CAC9B,CAAC,CAAC,MAAM,EACR,CAAC,CAAC,IAAI,CAAC;YACL,MAAM,EAAE,2CAA2B;YACnC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;SAClC,CAAC,CACH;QACD;;;WAGG;QACH,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;KACjE,CAAC;IACF,CAAC,CAAC,OAAO,CAAC;QACR,0FAA0F;QAC1F,gBAAgB,EAAE,CAAC,CAAC,MAAM;QAC1B,iEAAiE;QACjE,cAAc,EAAE,CAAC,CAAC,MAAM;KACzB,CAAC;CACH,CAAC,CAAC;AAKH,mDAAmD;AACtC,QAAA,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC;;OAEG;IACH,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,yBAAiB,CAAC;IACnD;;;OAGG;IACH,cAAc,EAAE,CAAC,CAAC,MAAM,CACtB,CAAC,CAAC,MAAM,EACR,CAAC,CAAC,IAAI,CAAC;QACL,yBAAyB;QACzB,UAAU,EAAE,CAAC,CAAC,MAAM;QACpB,mDAAmD;QACnD,KAAK,EAAE,CAAC,CAAC,MAAM;QACf,sBAAsB;QACtB,MAAM,EAAE,oCAAoB;KAC7B,CAAC,CACH;IACD;;;OAGG;IACH,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,oCAAoB,CAAC;CACzD,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PreferenceStorePurposeResponse } from '@transcend-io/privacy-types';
|
|
2
|
+
import { PurposeRowMapping } from './codecs';
|
|
3
|
+
import { PreferenceTopic } from '../graphql';
|
|
4
|
+
/**
|
|
5
|
+
* Parse an arbitrary object to the Transcend PUT /v1/preference update shape
|
|
6
|
+
* by using a mapping of column names to purpose/preference slugs.
|
|
7
|
+
*
|
|
8
|
+
* columnToPurposeName looks like:
|
|
9
|
+
* {
|
|
10
|
+
* 'my_purpose': 'Marketing',
|
|
11
|
+
* 'has_topic_1': 'Marketing->BooleanPreference1',
|
|
12
|
+
* 'has_topic_2': 'Marketing->BooleanPreference2'
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* row looks like:
|
|
16
|
+
* {
|
|
17
|
+
* 'my_purpose': 'true',
|
|
18
|
+
* 'has_topic_1': 'true',
|
|
19
|
+
* 'has_topic_2': 'false'
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* @param options - Options
|
|
23
|
+
* @returns The parsed row
|
|
24
|
+
*/
|
|
25
|
+
export declare function getPreferenceUpdatesFromRow({ row, columnToPurposeName, purposeSlugs, preferenceTopics, }: {
|
|
26
|
+
/** Row to parse */
|
|
27
|
+
row: Record<string, string>;
|
|
28
|
+
/** Mapping from column name ot row */
|
|
29
|
+
columnToPurposeName: Record<string, PurposeRowMapping>;
|
|
30
|
+
/** The set of allowed purpose slugs */
|
|
31
|
+
purposeSlugs: string[];
|
|
32
|
+
/** The preference topics */
|
|
33
|
+
preferenceTopics: PreferenceTopic[];
|
|
34
|
+
}): {
|
|
35
|
+
[k in string]: Omit<PreferenceStorePurposeResponse, 'purpose'>;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=getPreferenceUpdatesFromRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPreferenceUpdatesFromRow.d.ts","sourceRoot":"","sources":["../../src/preference-management/getPreferenceUpdatesFromRow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAE/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,GAAG,EACH,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,GACjB,EAAE;IACD,mBAAmB;IACnB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,sCAAsC;IACtC,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACvD,uCAAuC;IACvC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,4BAA4B;IAC5B,gBAAgB,EAAE,eAAe,EAAE,CAAC;CACrC,GAAG;KACD,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,8BAA8B,EAAE,SAAS,CAAC;CAC/D,CAqJA"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPreferenceUpdatesFromRow = void 0;
|
|
4
|
+
const privacy_types_1 = require("@transcend-io/privacy-types");
|
|
5
|
+
const type_utils_1 = require("@transcend-io/type-utils");
|
|
6
|
+
const requests_1 = require("../requests");
|
|
7
|
+
/**
|
|
8
|
+
* Parse an arbitrary object to the Transcend PUT /v1/preference update shape
|
|
9
|
+
* by using a mapping of column names to purpose/preference slugs.
|
|
10
|
+
*
|
|
11
|
+
* columnToPurposeName looks like:
|
|
12
|
+
* {
|
|
13
|
+
* 'my_purpose': 'Marketing',
|
|
14
|
+
* 'has_topic_1': 'Marketing->BooleanPreference1',
|
|
15
|
+
* 'has_topic_2': 'Marketing->BooleanPreference2'
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* row looks like:
|
|
19
|
+
* {
|
|
20
|
+
* 'my_purpose': 'true',
|
|
21
|
+
* 'has_topic_1': 'true',
|
|
22
|
+
* 'has_topic_2': 'false'
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @param options - Options
|
|
26
|
+
* @returns The parsed row
|
|
27
|
+
*/
|
|
28
|
+
function getPreferenceUpdatesFromRow({ row, columnToPurposeName, purposeSlugs, preferenceTopics, }) {
|
|
29
|
+
// Create a result object to store the parsed preferences
|
|
30
|
+
const result = {};
|
|
31
|
+
// Iterate over each column and map to the purpose or preference
|
|
32
|
+
Object.entries(columnToPurposeName).forEach(([columnName, { purpose, preference, valueMapping }]) => {
|
|
33
|
+
// Ensure the purpose is valid
|
|
34
|
+
if (!purposeSlugs.includes(purpose)) {
|
|
35
|
+
throw new Error(`Invalid purpose slug: ${purpose}, expected: ${purposeSlugs.join(', ')}`);
|
|
36
|
+
}
|
|
37
|
+
// CHeck if parsing a preference or just the top level purpose
|
|
38
|
+
if (preference) {
|
|
39
|
+
const preferenceTopic = preferenceTopics.find((x) => x.slug === preference && x.purpose.trackingType === purpose);
|
|
40
|
+
if (!preferenceTopic) {
|
|
41
|
+
const allowedTopics = preferenceTopics
|
|
42
|
+
.filter((x) => x.purpose.trackingType === purpose)
|
|
43
|
+
.map((x) => x.slug);
|
|
44
|
+
throw new Error(`Invalid preference slug: ${preference} for purpose: ${purpose}. ` +
|
|
45
|
+
`Allowed preference slugs for purpose are: ${allowedTopics.join(',')}`);
|
|
46
|
+
}
|
|
47
|
+
// If parsing preferences, default to an empty array
|
|
48
|
+
if (!result[purpose]) {
|
|
49
|
+
result[purpose] = {
|
|
50
|
+
preferences: [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (!result[purpose].preferences) {
|
|
54
|
+
result[purpose].preferences = [];
|
|
55
|
+
}
|
|
56
|
+
// The value to parse
|
|
57
|
+
const rawValue = row[columnName];
|
|
58
|
+
const rawMapping = valueMapping[rawValue];
|
|
59
|
+
const trimmedMapping = typeof rawMapping === 'string' ? rawMapping.trim() || null : null;
|
|
60
|
+
// handle each type of preference
|
|
61
|
+
switch (preferenceTopic.type) {
|
|
62
|
+
case privacy_types_1.PreferenceTopicType.Boolean:
|
|
63
|
+
if (typeof rawMapping !== 'boolean') {
|
|
64
|
+
throw new Error(`Invalid value for boolean preference: ${preference}, expected boolean, got: ${rawValue}`);
|
|
65
|
+
}
|
|
66
|
+
result[purpose].preferences.push({
|
|
67
|
+
topic: preference,
|
|
68
|
+
choice: {
|
|
69
|
+
booleanValue: rawMapping,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
break;
|
|
73
|
+
case privacy_types_1.PreferenceTopicType.Select:
|
|
74
|
+
if (typeof rawMapping !== 'string' && rawMapping !== null) {
|
|
75
|
+
throw new Error(`Invalid value for select preference: ${preference}, expected string or null, got: ${rawValue}`);
|
|
76
|
+
}
|
|
77
|
+
if (trimmedMapping &&
|
|
78
|
+
!preferenceTopic.preferenceOptionValues
|
|
79
|
+
.map(({ slug }) => slug)
|
|
80
|
+
.includes(trimmedMapping)) {
|
|
81
|
+
throw new Error(`Invalid value for select preference: ${preference}, expected one of: ` +
|
|
82
|
+
`${preferenceTopic.preferenceOptionValues
|
|
83
|
+
.map(({ slug }) => slug)
|
|
84
|
+
.join(', ')}, got: ${rawValue}`);
|
|
85
|
+
}
|
|
86
|
+
// Update preferences
|
|
87
|
+
result[purpose].preferences.push({
|
|
88
|
+
topic: preference,
|
|
89
|
+
choice: {
|
|
90
|
+
selectValue: trimmedMapping,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
break;
|
|
94
|
+
case privacy_types_1.PreferenceTopicType.MultiSelect:
|
|
95
|
+
if (typeof rawValue !== 'string') {
|
|
96
|
+
throw new Error(`Invalid value for multi select preference: ${preference}, expected string, got: ${rawValue}`);
|
|
97
|
+
}
|
|
98
|
+
// Update preferences
|
|
99
|
+
result[purpose].preferences.push({
|
|
100
|
+
topic: preference,
|
|
101
|
+
choice: {
|
|
102
|
+
selectValues: (0, requests_1.splitCsvToList)(rawValue)
|
|
103
|
+
.map((val) => {
|
|
104
|
+
const result = valueMapping[val];
|
|
105
|
+
if (typeof result !== 'string') {
|
|
106
|
+
throw new Error(`Invalid value for multi select preference: ${preference}, ` +
|
|
107
|
+
`expected one of: ${preferenceTopic.preferenceOptionValues
|
|
108
|
+
.map(({ slug }) => slug)
|
|
109
|
+
.join(', ')}, got: ${val}`);
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
})
|
|
113
|
+
.sort((a, b) => a.localeCompare(b)),
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
throw new Error(`Unknown preference type: ${preferenceTopic.type}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else if (!result[purpose]) {
|
|
122
|
+
// Handle updating top level purpose for the first time
|
|
123
|
+
result[purpose] = {
|
|
124
|
+
enabled: valueMapping[row[columnName]] === true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Handle updating top level purpose but preserve preference updates
|
|
129
|
+
result[purpose].enabled = valueMapping[row[columnName]] === true;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
// Ensure that enabled is provided
|
|
133
|
+
return (0, type_utils_1.apply)(result, (x, purposeName) => {
|
|
134
|
+
if (typeof x.enabled !== 'boolean') {
|
|
135
|
+
throw new Error(`No mapping provided for purpose.enabled=true/false value: ${purposeName}`);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...x,
|
|
139
|
+
enabled: x.enabled,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
exports.getPreferenceUpdatesFromRow = getPreferenceUpdatesFromRow;
|
|
144
|
+
//# sourceMappingURL=getPreferenceUpdatesFromRow.js.map
|