@pexip-engage-public/plugin 1.0.16 → 1.0.18
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/CHANGELOG.md +13 -0
- package/dist/configuration-parser/hash-parser.d.ts +1 -1
- package/dist/configuration-parser/hash-parser.d.ts.map +1 -1
- package/dist/configuration-parser/hash-parser.js +1 -1
- package/dist/configuration-parser/hash-parser.js.map +1 -1
- package/dist/configuration-parser/html-parser.d.ts +1 -1
- package/dist/configuration-parser/html-parser.d.ts.map +1 -1
- package/dist/configuration-parser/html-parser.js +2 -2
- package/dist/configuration-parser/html-parser.js.map +1 -1
- package/dist/configuration-parser/index.d.ts +5 -16
- package/dist/configuration-parser/index.d.ts.map +1 -1
- package/dist/configuration-parser/index.js +8 -52
- package/dist/configuration-parser/index.js.map +1 -1
- package/dist/configuration-parser/js-parser.d.ts +78 -30
- package/dist/configuration-parser/js-parser.d.ts.map +1 -1
- package/dist/configuration-parser/js-parser.js +143 -38
- package/dist/configuration-parser/js-parser.js.map +1 -1
- package/dist/configuration-parser/migrate-legacy-configuration.d.ts +15 -0
- package/dist/configuration-parser/migrate-legacy-configuration.d.ts.map +1 -0
- package/dist/configuration-parser/migrate-legacy-configuration.js +59 -0
- package/dist/configuration-parser/migrate-legacy-configuration.js.map +1 -0
- package/dist/configuration-parser-legacy/LegacyParser.utils.d.ts.map +1 -1
- package/dist/configuration-parser-legacy/LegacyParser.utils.js +6 -1
- package/dist/configuration-parser-legacy/LegacyParser.utils.js.map +1 -1
- package/dist/constants.d.ts +0 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -5
- package/dist/constants.js.map +1 -1
- package/dist/encoding.d.ts +1 -1
- package/dist/encoding.d.ts.map +1 -1
- package/dist/encoding.js +1 -1
- package/dist/encoding.js.map +1 -1
- package/dist/events/event-types.d.ts +1 -1
- package/dist/events/event-types.d.ts.map +1 -1
- package/dist/instance/PluginInstance.d.ts +42 -112
- package/dist/instance/PluginInstance.d.ts.map +1 -1
- package/dist/instance/PluginInstance.js +46 -78
- package/dist/instance/PluginInstance.js.map +1 -1
- package/dist/instance/dispatchEvent.d.ts.map +1 -1
- package/dist/instance/dispatchEvent.js +0 -3
- package/dist/instance/dispatchEvent.js.map +1 -1
- package/dist/instance/index.d.ts +21 -11
- package/dist/instance/index.d.ts.map +1 -1
- package/dist/instance/index.js +14 -14
- package/dist/instance/index.js.map +1 -1
- package/package.json +4 -3
- package/src/configuration-parser/hash-parser.ts +2 -2
- package/src/configuration-parser/html-parser.ts +3 -3
- package/src/configuration-parser/index.ts +13 -87
- package/src/configuration-parser/js-parser.ts +252 -76
- package/src/configuration-parser/migrate-legacy-configuration.ts +95 -0
- package/src/configuration-parser-legacy/LegacyParser.utils.ts +7 -1
- package/src/constants.ts +0 -6
- package/src/encoding.ts +1 -1
- package/src/events/event-types.ts +1 -9
- package/src/instance/PluginInstance.ts +52 -93
- package/src/instance/dispatchEvent.ts +0 -5
- package/src/instance/index.ts +40 -28
|
@@ -1,62 +1,180 @@
|
|
|
1
|
+
import type { MeetingType } from "@pexip-engage-public/graphql";
|
|
2
|
+
|
|
1
3
|
import type { PluginConfiguration } from "../configuration/PluginConfiguration.current.js";
|
|
2
|
-
import { isValidConfiguration } from "../configuration-parser-legacy/utils.js";
|
|
3
4
|
import { logger } from "../logger.js";
|
|
4
5
|
|
|
6
|
+
function isValidConfiguration(configuration: unknown): configuration is object {
|
|
7
|
+
return typeof configuration === "object" && configuration !== null;
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
export const jsParser = {
|
|
6
11
|
encode(config: PluginConfiguration): JSConfig {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const result: JSConfig["config"] = {
|
|
13
|
+
version: config.version,
|
|
14
|
+
flow: config.flow,
|
|
15
|
+
intent: config.intent as any,
|
|
16
|
+
language: config.language as any,
|
|
17
|
+
employee: {
|
|
18
|
+
ids: config["employee-ids"],
|
|
19
|
+
type: config["employee-type"] as any,
|
|
20
|
+
},
|
|
21
|
+
application: {
|
|
22
|
+
scroll: config["application-scroll"] as any,
|
|
23
|
+
timeZoneSelection: config["application-time_zone_selection"] as any,
|
|
24
|
+
// timetable_ui: config["application-timetable_ui"],
|
|
25
|
+
theme: config["application-theme"],
|
|
26
|
+
},
|
|
27
|
+
customer: {
|
|
28
|
+
company: config["customer-company"],
|
|
29
|
+
customerNumber: config["customer-customer_number"],
|
|
30
|
+
email: config["customer-email"],
|
|
31
|
+
existing: config["customer-existing"],
|
|
32
|
+
externalId: config["customer-external_id"],
|
|
33
|
+
firstName: config["customer-first_name"],
|
|
34
|
+
id: config["customer-id"],
|
|
35
|
+
language: config["customer-language"],
|
|
36
|
+
lastName: config["customer-last_name"],
|
|
37
|
+
location: {
|
|
38
|
+
city: config["customer-location-city"],
|
|
39
|
+
countryCode: config["customer-location-country_code"],
|
|
40
|
+
geolocation: {
|
|
41
|
+
latitude: config["customer-location-geolocation-latitude"] as any,
|
|
42
|
+
longitude: config["customer-location-geolocation-longitude"] as any,
|
|
43
|
+
},
|
|
44
|
+
postalCode: config["customer-location-postal_code"],
|
|
45
|
+
timeZone: config["customer-location-time_zone"],
|
|
46
|
+
state: config["customer-location-state"],
|
|
47
|
+
street1: config["customer-location-street1"],
|
|
48
|
+
street2: config["customer-location-street2"],
|
|
49
|
+
},
|
|
50
|
+
phoneNumber: config["customer-phone_number"],
|
|
51
|
+
timeZone: config["customer-time_zone"],
|
|
52
|
+
},
|
|
53
|
+
leadSegment: {
|
|
54
|
+
id: config["lead_segment-id"],
|
|
55
|
+
type: config["lead_segment-type"] as any,
|
|
56
|
+
},
|
|
57
|
+
listing: {
|
|
58
|
+
id: config["listing-id"],
|
|
59
|
+
type: config["listing-type"] as any,
|
|
60
|
+
},
|
|
61
|
+
location: {
|
|
62
|
+
formattedAddress: config["location-formatted_address"],
|
|
63
|
+
},
|
|
64
|
+
meetingTypes: config["meeting_types"] as any,
|
|
65
|
+
oauth: {
|
|
66
|
+
resourceCode: config["oauth-resource_code"],
|
|
67
|
+
},
|
|
68
|
+
office: {
|
|
69
|
+
ids: config["office-ids"],
|
|
70
|
+
type: config["office-type"] as any,
|
|
71
|
+
},
|
|
72
|
+
searchCountries: config["search_countries"],
|
|
73
|
+
session: {
|
|
74
|
+
id: config["session-id"],
|
|
75
|
+
sourceTags: config["session-source_tags"],
|
|
76
|
+
status: config["session-status"] as any,
|
|
77
|
+
},
|
|
78
|
+
subject: {
|
|
79
|
+
ids: config["subject-ids"],
|
|
80
|
+
type: config["subject-type"] as any,
|
|
81
|
+
},
|
|
82
|
+
subjectGroup: {
|
|
83
|
+
ids: config["subject_group-ids"],
|
|
84
|
+
type: config["subject_group-type"] as any,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
17
87
|
|
|
18
|
-
return { config: result };
|
|
88
|
+
return { config: prune(result) };
|
|
19
89
|
},
|
|
20
|
-
decode(jsConfig?: unknown): PluginConfiguration {
|
|
21
|
-
if (!jsConfig) return
|
|
90
|
+
decode(jsConfig?: unknown): PluginConfiguration | null {
|
|
91
|
+
if (!jsConfig) return null;
|
|
22
92
|
|
|
23
93
|
try {
|
|
24
94
|
if (!isValidConfiguration(jsConfig))
|
|
25
95
|
throw new Error("Invalid configuration passed, expected an object.");
|
|
26
96
|
|
|
27
97
|
if (jsConfig && "config" in jsConfig && isValidConfiguration(jsConfig.config)) {
|
|
28
|
-
|
|
98
|
+
const config = jsConfig.config as NonNullable<JSConfig["config"]>;
|
|
99
|
+
|
|
100
|
+
const result: PluginConfiguration = {
|
|
101
|
+
version: config.version,
|
|
102
|
+
flow: config.flow,
|
|
103
|
+
intent: config.intent,
|
|
104
|
+
language: config.language,
|
|
105
|
+
"employee-ids": config.employee?.ids,
|
|
106
|
+
"employee-type": config.employee?.type,
|
|
107
|
+
"application-scroll": config.application?.scroll,
|
|
108
|
+
"application-time_zone_selection": config.application?.timeZoneSelection,
|
|
109
|
+
// "application-timetable_ui": config.application?.timetableUI,
|
|
110
|
+
"application-theme": config.application?.theme,
|
|
111
|
+
"customer-company": config.customer?.company,
|
|
112
|
+
"customer-customer_number": config.customer?.customerNumber,
|
|
113
|
+
"customer-email": config.customer?.email,
|
|
114
|
+
"customer-existing": config.customer?.existing,
|
|
115
|
+
"customer-external_id": config.customer?.externalId,
|
|
116
|
+
"customer-first_name": config.customer?.firstName,
|
|
117
|
+
"customer-id": config.customer?.id,
|
|
118
|
+
"customer-language": config.customer?.language,
|
|
119
|
+
"customer-last_name": config.customer?.lastName,
|
|
120
|
+
"customer-location-city": config.customer?.location?.city,
|
|
121
|
+
"customer-location-country_code": config.customer?.location?.countryCode,
|
|
122
|
+
"customer-location-geolocation-latitude":
|
|
123
|
+
config.customer?.location?.geolocation?.latitude,
|
|
124
|
+
"customer-location-geolocation-longitude":
|
|
125
|
+
config.customer?.location?.geolocation?.longitude,
|
|
126
|
+
"customer-location-postal_code": config.customer?.location?.postalCode,
|
|
127
|
+
"customer-location-time_zone": config.customer?.location?.timeZone,
|
|
128
|
+
"customer-location-state": config.customer?.location?.state,
|
|
129
|
+
"customer-location-street1": config.customer?.location?.street1,
|
|
130
|
+
"customer-location-street2": config.customer?.location?.street2,
|
|
131
|
+
"customer-phone_number": config.customer?.phoneNumber,
|
|
132
|
+
"customer-time_zone": config.customer?.timeZone,
|
|
133
|
+
"lead_segment-id": config.leadSegment?.id,
|
|
134
|
+
"lead_segment-type": config.leadSegment?.type,
|
|
135
|
+
"listing-id": config.listing?.id,
|
|
136
|
+
"listing-type": config.listing?.type,
|
|
137
|
+
"location-formatted_address": config.location?.formattedAddress,
|
|
138
|
+
meeting_types: config.meetingTypes,
|
|
139
|
+
"oauth-resource_code": config.oauth?.resourceCode,
|
|
140
|
+
"office-ids": config.office?.ids,
|
|
141
|
+
"office-type": config.office?.type,
|
|
142
|
+
search_countries: config.searchCountries,
|
|
143
|
+
"session-id": config.session?.id,
|
|
144
|
+
"session-source_tags": config.session?.sourceTags,
|
|
145
|
+
"session-status": config.session?.status,
|
|
146
|
+
"subject-ids": config.subject?.ids,
|
|
147
|
+
"subject-type": config.subject?.type,
|
|
148
|
+
"subject_group-ids": config.subjectGroup?.ids,
|
|
149
|
+
"subject_group-type": config.subjectGroup?.type,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return prune(result);
|
|
29
153
|
} else {
|
|
30
|
-
return
|
|
154
|
+
return null;
|
|
31
155
|
}
|
|
32
156
|
} catch (err) {
|
|
33
157
|
logger.error("Failed to parse JS config:", jsConfig);
|
|
34
158
|
logger.error("JS ERROR:", err);
|
|
35
159
|
|
|
36
|
-
return
|
|
160
|
+
return null;
|
|
37
161
|
}
|
|
38
162
|
},
|
|
39
163
|
};
|
|
40
164
|
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
result: Record<any, any> = {},
|
|
45
|
-
) {
|
|
46
|
-
for (let key in inputObject) {
|
|
47
|
-
let value = inputObject[key];
|
|
48
|
-
let newKey = current ? `${current}-${key}` : key;
|
|
165
|
+
function prune<T>(obj: T): T {
|
|
166
|
+
for (let key in obj) {
|
|
167
|
+
const value = obj[key];
|
|
49
168
|
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
} else if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
result[newKey] = value;
|
|
169
|
+
if (value === null || value === undefined) {
|
|
170
|
+
delete obj[key];
|
|
171
|
+
} else if (typeof value === "object") {
|
|
172
|
+
prune(value);
|
|
173
|
+
if (Object.keys(value).length === 0) delete obj[key];
|
|
56
174
|
}
|
|
57
175
|
}
|
|
58
176
|
|
|
59
|
-
return
|
|
177
|
+
return obj;
|
|
60
178
|
}
|
|
61
179
|
|
|
62
180
|
type StringConfig = string | null;
|
|
@@ -65,91 +183,149 @@ type BooleanConfig = StringConfig | boolean;
|
|
|
65
183
|
|
|
66
184
|
export interface JSConfig {
|
|
67
185
|
config?: {
|
|
68
|
-
version
|
|
186
|
+
version?: "1.0.0";
|
|
187
|
+
/**
|
|
188
|
+
* A sequence of characters that indicates the order of steps to be shown. The following characters are supported:
|
|
189
|
+
* - `S`: Subject. The step that allows the customer to pick a subject.
|
|
190
|
+
* - `O`: Office. The step that allows the customer to pick an office.
|
|
191
|
+
* - `M`: Meeting type. The step that allows the customer to pick a meeting type.
|
|
192
|
+
* - `E`: Employee. The step that allows the customer to pick an employee.
|
|
193
|
+
* - `T`: Timetable. The step that allows the customer to suggest one or more time slots for their appointment.
|
|
194
|
+
* - `Q`: Questions. The step that allows the customer to answer any addition questions specific to the chosen subject.
|
|
195
|
+
* - `C`: Customer. The step that allows the customer to provide his/her contact information.
|
|
196
|
+
* - `*`: [locked]. Indicate that the step is locked and can not be edited. This means that a value must be provided.
|
|
197
|
+
*
|
|
198
|
+
* Currently, the following constraints must always be met:
|
|
199
|
+
* - The following characters must always be present: `T`, `Q`, `C`.
|
|
200
|
+
* - No other characters than those listed above may be used.
|
|
201
|
+
* - When `S` is not present, it is mandatory that an external mechanism will provide the `config.subject.id` + `config.subject.type` configuration option instead.
|
|
202
|
+
* - When `O` is not present, it is mandatory that an external mechanism will provide the `config.office.id` + `config.office.type`configuration option instead.
|
|
203
|
+
* - If `S` or `O` are present, they can never occur at a position after `T`.
|
|
204
|
+
* - If `S` is present, it can never occur at a position after `Q`.
|
|
205
|
+
*
|
|
206
|
+
* By default the value `SMOTQC` will be assumed. This will be the case if no value was provided or if the provided value fails these constraints.
|
|
207
|
+
* @default "SMOTQC"
|
|
208
|
+
*/
|
|
69
209
|
flow?: StringConfig;
|
|
70
|
-
intent?:
|
|
71
|
-
|
|
210
|
+
intent?:
|
|
211
|
+
| "schedule"
|
|
212
|
+
| "reschedule"
|
|
213
|
+
| "invite"
|
|
214
|
+
| "edit"
|
|
215
|
+
| "cancel"
|
|
216
|
+
| "complete"
|
|
217
|
+
| "reject"
|
|
218
|
+
| null;
|
|
219
|
+
/**
|
|
220
|
+
* An RFC 5646-compatible language tag.
|
|
221
|
+
*
|
|
222
|
+
* This will cause the plugin to be displayed in the specified language, unless the language is unavailable.
|
|
223
|
+
*
|
|
224
|
+
* In that case, a best-effort fallback will be performed with increasingly more generic variants of the specified language or finally 'en' if no variants of the specified language are available.
|
|
225
|
+
*/
|
|
226
|
+
language?:
|
|
227
|
+
| "da"
|
|
228
|
+
| "de"
|
|
229
|
+
| "el"
|
|
230
|
+
| "en"
|
|
231
|
+
| "en-GB"
|
|
232
|
+
| "en-US"
|
|
233
|
+
| "es"
|
|
234
|
+
| "fr"
|
|
235
|
+
| "no"
|
|
236
|
+
| "nl"
|
|
237
|
+
| "pl"
|
|
238
|
+
| null;
|
|
72
239
|
employee?: {
|
|
73
240
|
ids?: StringArrayConfig;
|
|
74
|
-
type?:
|
|
241
|
+
type?: "id" | "externalId" | null;
|
|
75
242
|
};
|
|
76
243
|
application?: {
|
|
244
|
+
/**
|
|
245
|
+
* Used to set scroll top value when navigating steps
|
|
246
|
+
* @default -90
|
|
247
|
+
*/
|
|
77
248
|
scroll?: "disabled" | number | null;
|
|
78
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Used to enable timezone selection when the meeting type is video or phone.
|
|
251
|
+
* @default "enable"
|
|
252
|
+
*/
|
|
253
|
+
timeZoneSelection?: "enable" | "disable" | null;
|
|
254
|
+
// /**
|
|
255
|
+
// * Used to decide wether to show month of week timetable view
|
|
256
|
+
// * @experimental
|
|
257
|
+
// * @default "week"
|
|
258
|
+
// */
|
|
259
|
+
// timetableUI?: "week" | "month" | null;
|
|
79
260
|
theme?: string | null;
|
|
80
261
|
};
|
|
81
262
|
customer?: {
|
|
82
263
|
// TODO camelcase?
|
|
83
264
|
company?: StringConfig;
|
|
84
|
-
|
|
85
|
-
date_of_birth?: StringConfig;
|
|
265
|
+
customerNumber?: StringConfig;
|
|
86
266
|
email?: StringConfig;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
267
|
+
existing?: BooleanConfig;
|
|
268
|
+
externalId?: StringConfig;
|
|
269
|
+
firstName?: StringConfig;
|
|
90
270
|
id?: StringConfig;
|
|
91
|
-
is_existing?: BooleanConfig;
|
|
92
271
|
language?: StringConfig;
|
|
93
|
-
|
|
272
|
+
lastName?: StringConfig;
|
|
94
273
|
location?: {
|
|
95
274
|
city?: StringConfig;
|
|
96
|
-
|
|
97
|
-
geolocation?:
|
|
98
|
-
|
|
275
|
+
countryCode?: StringConfig;
|
|
276
|
+
geolocation?: {
|
|
277
|
+
latitude: StringConfig;
|
|
278
|
+
longitude: StringConfig;
|
|
279
|
+
};
|
|
280
|
+
postalCode?: StringConfig;
|
|
281
|
+
timeZone?: StringConfig;
|
|
99
282
|
state?: StringConfig;
|
|
100
|
-
|
|
283
|
+
street1?: StringConfig;
|
|
284
|
+
street2?: StringConfig;
|
|
101
285
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
preferred_office_id?: StringConfig;
|
|
105
|
-
timezone?: StringConfig;
|
|
286
|
+
phoneNumber?: StringConfig;
|
|
287
|
+
timeZone?: StringConfig;
|
|
106
288
|
};
|
|
107
289
|
leadSegment?: {
|
|
108
290
|
id?: StringConfig;
|
|
109
|
-
type?:
|
|
291
|
+
type?: "id" | "code" | null;
|
|
110
292
|
};
|
|
111
293
|
listing?: {
|
|
112
294
|
id?: StringConfig;
|
|
113
|
-
type?:
|
|
295
|
+
type?: "id" | "externalId" | null;
|
|
114
296
|
};
|
|
115
297
|
location?: {
|
|
116
|
-
|
|
298
|
+
formattedAddress?: StringConfig;
|
|
117
299
|
};
|
|
118
|
-
meetingTypes?:
|
|
300
|
+
meetingTypes?: MeetingType[] | MeetingType | null;
|
|
119
301
|
oauth?: {
|
|
302
|
+
/** A resource_code of an existing appointment. This will allow you to complete or change an appointment. This parameter is mostly used by redirects from external sources (e.g. e-mails) and should usually not be provided manually. */
|
|
120
303
|
resourceCode?: StringConfig;
|
|
121
304
|
};
|
|
122
305
|
office?: {
|
|
123
306
|
ids?: StringArrayConfig;
|
|
124
|
-
type?:
|
|
307
|
+
type?: "id" | "externalId" | null;
|
|
125
308
|
};
|
|
309
|
+
/**
|
|
310
|
+
* The country that should be used for searching locations. Should be a two letter ISO 3166-1 country code.
|
|
311
|
+
*
|
|
312
|
+
* You can provide a maximum of 5 comma-separated countries.
|
|
313
|
+
*/
|
|
126
314
|
searchCountries?: StringArrayConfig;
|
|
127
315
|
session?: {
|
|
128
316
|
id?: StringConfig;
|
|
317
|
+
/** Pass source tags seperated with a semi-colon. */
|
|
129
318
|
sourceTags?: StringArrayConfig;
|
|
130
|
-
|
|
319
|
+
/** Used to enable/disable tracking of events in the plugin for insights about conversion. @default "default" */
|
|
320
|
+
status?: "default" | "disabled" | null;
|
|
131
321
|
};
|
|
132
322
|
subject?: {
|
|
133
323
|
ids?: StringArrayConfig;
|
|
134
|
-
type?:
|
|
324
|
+
type?: "id" | "externalId" | null;
|
|
135
325
|
};
|
|
136
|
-
|
|
137
|
-
|
|
326
|
+
subjectGroup?: {
|
|
327
|
+
ids?: StringArrayConfig;
|
|
328
|
+
type?: "id" | "externalId" | null;
|
|
138
329
|
};
|
|
139
330
|
};
|
|
140
331
|
}
|
|
141
|
-
|
|
142
|
-
function setValue(target: Record<string, any>, keys: string[], value: unknown) {
|
|
143
|
-
let targetObj = target;
|
|
144
|
-
const [lastKey] = keys.splice(-1, 1);
|
|
145
|
-
|
|
146
|
-
for (const key of keys) {
|
|
147
|
-
if (!targetObj[key]) {
|
|
148
|
-
targetObj[key] = {};
|
|
149
|
-
}
|
|
150
|
-
targetObj = targetObj[key];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
//@ts-expect-error
|
|
154
|
-
targetObj[lastKey] = value;
|
|
155
|
-
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { migrateConfiguration } from "../configuration/migration.js";
|
|
2
|
+
import type { PluginConfiguration } from "../configuration/PluginConfiguration.current.js";
|
|
3
|
+
import { parsePluginConfigurationV1 } from "../configuration-parser-legacy/Parser.js";
|
|
4
|
+
import { logger } from "../logger.js";
|
|
5
|
+
|
|
6
|
+
import { hashParser } from "./hash-parser.js";
|
|
7
|
+
import { htmlParser } from "./html-parser.js";
|
|
8
|
+
import { CONFIG_VERSION, type ConfigurationProps } from "./index.js";
|
|
9
|
+
import { type JSConfig, jsParser } from "./js-parser.js";
|
|
10
|
+
|
|
11
|
+
const parser = { js: jsParser, hash: hashParser, html: htmlParser };
|
|
12
|
+
|
|
13
|
+
export function migrateLegacyConfiguration(args: ConfigurationProps) {
|
|
14
|
+
const v1Config = parsePluginConfigurationV1({
|
|
15
|
+
element: args.element,
|
|
16
|
+
hash: args.hash,
|
|
17
|
+
href: args.browser.href,
|
|
18
|
+
browserTimeZone: args.browser.timeZone,
|
|
19
|
+
options: args.options,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return createMigration(v1Config);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createMigration(result: ReturnType<typeof parsePluginConfigurationV1>): {
|
|
26
|
+
migrationInstructions: {
|
|
27
|
+
dom: string | null;
|
|
28
|
+
hash: string | null;
|
|
29
|
+
js: JSConfig | null;
|
|
30
|
+
};
|
|
31
|
+
config: PluginConfiguration;
|
|
32
|
+
domConfig: PluginConfiguration | null;
|
|
33
|
+
hashConfig: PluginConfiguration | null;
|
|
34
|
+
jsConfig: PluginConfiguration | null;
|
|
35
|
+
} {
|
|
36
|
+
const data = {
|
|
37
|
+
config: migrateConfiguration(result.config) ?? { version: CONFIG_VERSION },
|
|
38
|
+
domConfig: migrateConfiguration(result.domConfig),
|
|
39
|
+
hashConfig: migrateConfiguration(result.hashConfig),
|
|
40
|
+
jsConfig: migrateConfiguration(result.jsConfig),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const migrationInstructions = {
|
|
44
|
+
dom: data.domConfig
|
|
45
|
+
? `<div class="pexip-engage-plugin"\n ${parser.html
|
|
46
|
+
.encode(data.domConfig)
|
|
47
|
+
.join("\n ")}\n></div>`
|
|
48
|
+
: null,
|
|
49
|
+
hash: data.hashConfig ? parser.hash.encode(data.hashConfig) : null,
|
|
50
|
+
js: data.jsConfig ? parser.js.encode(data.jsConfig) : null,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
logDeprecationWarning(migrationInstructions);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...data,
|
|
57
|
+
migrationInstructions,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function logDeprecationWarning({
|
|
62
|
+
dom,
|
|
63
|
+
hash,
|
|
64
|
+
js,
|
|
65
|
+
}: {
|
|
66
|
+
dom: string | null;
|
|
67
|
+
js: JSConfig | null;
|
|
68
|
+
hash: string | null;
|
|
69
|
+
}) {
|
|
70
|
+
if (dom || hash || js) {
|
|
71
|
+
logger.group("DEPRECATED CONFIGURATION");
|
|
72
|
+
|
|
73
|
+
if (dom) {
|
|
74
|
+
try {
|
|
75
|
+
logger.warn(
|
|
76
|
+
"Detected unsupported DOM config. Please update your DOM element to:\n",
|
|
77
|
+
dom.replaceAll("\n ", ""),
|
|
78
|
+
);
|
|
79
|
+
} catch (err) {}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (hash) {
|
|
83
|
+
logger.warn("Detected deprecated hash config. Please update your hash to:\n%o", hash);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (js) {
|
|
87
|
+
logger.warn(
|
|
88
|
+
"Detected deprecated JS config. Please update your JS to:\n%o",
|
|
89
|
+
`PexipEngage.Plugin(element, ${JSON.stringify(js)})`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
logger.groupEnd();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { PluginConfigurationV0 } from "../configuration/PluginConfiguration.v0.ts";
|
|
2
|
-
import {
|
|
2
|
+
import { TOKEN } from "../constants.js";
|
|
3
3
|
|
|
4
4
|
import type { LegacyPluginHashConfiguration } from "./LegacyParser.js";
|
|
5
5
|
import { sanitize } from "./utils.js";
|
|
6
6
|
|
|
7
|
+
const DEPRECATED_TOKEN = {
|
|
8
|
+
LOCK: "#",
|
|
9
|
+
OFFICE: "L",
|
|
10
|
+
START: "'",
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
7
13
|
export function legacyHashToPluginInputConfiguration(
|
|
8
14
|
config: LegacyPluginHashConfiguration,
|
|
9
15
|
): PluginConfigurationV0 {
|
package/src/constants.ts
CHANGED
package/src/encoding.ts
CHANGED
|
@@ -26,7 +26,7 @@ export function decodeURIParameters<T>(str: string): T {
|
|
|
26
26
|
|
|
27
27
|
const CONFIGURATION_SEARCH_PARAM_KEY = "configuration.pexip";
|
|
28
28
|
|
|
29
|
-
export const
|
|
29
|
+
export const pluginSearchParams = {
|
|
30
30
|
encode(config: PluginConfiguration): URLSearchParams {
|
|
31
31
|
const searchParams = new URLSearchParams();
|
|
32
32
|
searchParams.set(CONFIGURATION_SEARCH_PARAM_KEY, encodeURIParameters(config));
|
|
@@ -26,15 +26,7 @@ export interface StepShownMessage {
|
|
|
26
26
|
| "meeting-type";
|
|
27
27
|
subject?: { id: string; title?: string };
|
|
28
28
|
office?: { id: string; title?: string };
|
|
29
|
-
meetingType?:
|
|
30
|
-
| "video"
|
|
31
|
-
| "phone"
|
|
32
|
-
| "on_location"
|
|
33
|
-
| "office"
|
|
34
|
-
| "VIDEO"
|
|
35
|
-
| "PHONE"
|
|
36
|
-
| "ON_LOCATION"
|
|
37
|
-
| "OFFICE";
|
|
29
|
+
meetingType?: "VIDEO" | "PHONE" | "ON_LOCATION" | "OFFICE";
|
|
38
30
|
employee?: { id: string; firstName?: string | null; lastName?: string | null };
|
|
39
31
|
};
|
|
40
32
|
}
|