@pexip-engage-public/plugin 1.1.17 → 1.1.19

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +18 -2
  2. package/dist/configuration/PluginConfiguration.schema.d.ts +149 -149
  3. package/dist/configuration/PluginConfiguration.schema.d.ts.map +1 -1
  4. package/dist/configuration/PluginConfiguration.schema.js +55 -55
  5. package/dist/configuration/PluginConfiguration.schema.js.map +1 -1
  6. package/dist/configuration/migration.js +16 -16
  7. package/dist/configuration/migration.js.map +1 -1
  8. package/dist/configuration-parser/hash-parser.d.ts +1 -1
  9. package/dist/configuration-parser/hash-parser.d.ts.map +1 -1
  10. package/dist/configuration-parser/hash-parser.js +3 -3
  11. package/dist/configuration-parser/hash-parser.js.map +1 -1
  12. package/dist/configuration-parser/html-parser.d.ts +1 -1
  13. package/dist/configuration-parser/html-parser.d.ts.map +1 -1
  14. package/dist/configuration-parser/html-parser.js +3 -3
  15. package/dist/configuration-parser/html-parser.js.map +1 -1
  16. package/dist/configuration-parser/index.d.ts +6 -6
  17. package/dist/configuration-parser/index.js +2 -2
  18. package/dist/configuration-parser/index.js.map +1 -1
  19. package/dist/configuration-parser/js-parser.d.ts +1 -1
  20. package/dist/configuration-parser/js-parser.d.ts.map +1 -1
  21. package/dist/configuration-parser/js-parser.js +87 -87
  22. package/dist/configuration-parser/js-parser.js.map +1 -1
  23. package/dist/configuration-parser/migrate-legacy-configuration.js +3 -3
  24. package/dist/configuration-parser/migrate-legacy-configuration.js.map +1 -1
  25. package/dist/configuration-parser-legacy/LegacyParser.d.ts.map +1 -1
  26. package/dist/configuration-parser-legacy/LegacyParser.js +62 -62
  27. package/dist/configuration-parser-legacy/LegacyParser.js.map +1 -1
  28. package/dist/configuration-parser-legacy/LegacyParser.utils.js +23 -23
  29. package/dist/configuration-parser-legacy/LegacyParser.utils.js.map +1 -1
  30. package/dist/configuration-parser-legacy/ModernParser.js +8 -8
  31. package/dist/configuration-parser-legacy/ModernParser.js.map +1 -1
  32. package/dist/configuration-parser-legacy/Parser.js +1 -1
  33. package/dist/configuration-parser-legacy/Parser.js.map +1 -1
  34. package/dist/configuration-parser-legacy/tests/LegacyDomParser.test.js +20 -20
  35. package/dist/configuration-parser-legacy/tests/LegacyDomParser.test.js.map +1 -1
  36. package/dist/configuration-parser-legacy/tests/LegacyLocationHashParser.test.js +26 -26
  37. package/dist/configuration-parser-legacy/tests/LegacyLocationHashParser.test.js.map +1 -1
  38. package/dist/configuration-parser-legacy/tests/LegacyParser.test.js +4 -4
  39. package/dist/configuration-parser-legacy/tests/LegacyParser.test.js.map +1 -1
  40. package/dist/constants.d.ts +1 -1
  41. package/dist/constants.js +1 -1
  42. package/dist/encoding.d.ts +1 -1
  43. package/dist/encoding.d.ts.map +1 -1
  44. package/dist/encoding.js +5 -5
  45. package/dist/encoding.js.map +1 -1
  46. package/dist/events/event-types.d.ts +1 -1
  47. package/dist/events/event-types.d.ts.map +1 -1
  48. package/dist/instance/PluginInstance.d.ts +10 -10
  49. package/dist/instance/PluginInstance.d.ts.map +1 -1
  50. package/dist/instance/PluginInstance.js +29 -29
  51. package/dist/instance/PluginInstance.js.map +1 -1
  52. package/dist/instance/index.d.ts.map +1 -1
  53. package/dist/instance/index.js +3 -3
  54. package/dist/instance/index.js.map +1 -1
  55. package/dist/logger.d.ts +3 -3
  56. package/dist/logger.d.ts.map +1 -1
  57. package/dist/logger.js +9 -9
  58. package/dist/logger.js.map +1 -1
  59. package/dist/state/PluginState.schema.d.ts +451 -451
  60. package/dist/state/PluginState.schema.d.ts.map +1 -1
  61. package/dist/state/PluginState.schema.js +48 -48
  62. package/dist/state/PluginState.schema.js.map +1 -1
  63. package/dist/state/schemas.d.ts +13 -13
  64. package/dist/state/schemas.js +9 -9
  65. package/dist/state/schemas.js.map +1 -1
  66. package/package.json +6 -6
  67. package/src/configuration/PluginConfiguration.schema.ts +59 -60
  68. package/src/configuration/migration.ts +16 -16
  69. package/src/configuration-parser/hash-parser.ts +3 -3
  70. package/src/configuration-parser/html-parser.ts +3 -3
  71. package/src/configuration-parser/index.ts +2 -2
  72. package/src/configuration-parser/js-parser.ts +94 -94
  73. package/src/configuration-parser/migrate-legacy-configuration.ts +4 -4
  74. package/src/configuration-parser-legacy/LegacyParser.ts +63 -62
  75. package/src/configuration-parser-legacy/LegacyParser.utils.ts +24 -24
  76. package/src/configuration-parser-legacy/ModernParser.ts +8 -8
  77. package/src/configuration-parser-legacy/Parser.ts +1 -1
  78. package/src/configuration-parser-legacy/tests/LegacyDomParser.test.ts +20 -20
  79. package/src/configuration-parser-legacy/tests/LegacyLocationHashParser.test.ts +29 -29
  80. package/src/configuration-parser-legacy/tests/LegacyParser.test.ts +4 -4
  81. package/src/constants.ts +1 -1
  82. package/src/encoding.ts +6 -6
  83. package/src/events/event-types.ts +1 -2
  84. package/src/instance/PluginInstance.ts +30 -31
  85. package/src/instance/index.ts +3 -3
  86. package/src/logger.ts +9 -9
  87. package/src/state/PluginState.schema.ts +53 -53
  88. package/src/state/schemas.ts +9 -9
@@ -7,19 +7,13 @@ export function migrateConfiguration(config: PluginConfigurationV0): PluginConfi
7
7
  const { geolocation, meetingTypes, timezoneSelection } = runMigrations(config);
8
8
 
9
9
  const migrated: PluginConfiguration = {
10
- version: "1.0.0",
11
- flow: config.flow ?? undefined,
12
- intent: config.intent ?? undefined,
13
- language: config.language ?? undefined,
14
- "employee-ids": config["employee-ids"] ?? undefined,
15
- "employee-type": config["employee-type"] ?? undefined,
16
10
  "application-office_search": config["application-office_search"] ?? undefined,
11
+ "application-recaptcha": undefined,
17
12
  "application-scroll": config["application-scroll"] ?? undefined,
18
- "application-time_zone_selection": timezoneSelection ?? undefined,
19
13
  "application-theme": config["application-theme"] ?? undefined,
20
- "application-recaptcha": undefined,
21
- "browser-time_zone": config["browser-timezone"] ?? undefined,
14
+ "application-time_zone_selection": timezoneSelection ?? undefined,
22
15
  "browser-href": config.source_href ?? undefined,
16
+ "browser-time_zone": config["browser-timezone"] ?? undefined,
23
17
  "customer-company": config["customer-company"] ?? undefined,
24
18
  "customer-customer_number": config["customer-customer_number"] ?? undefined,
25
19
  "customer-email": config["customer-email"] ?? undefined,
@@ -34,18 +28,25 @@ export function migrateConfiguration(config: PluginConfigurationV0): PluginConfi
34
28
  "customer-location-geolocation-latitude": geolocation?.latitude ?? undefined,
35
29
  "customer-location-geolocation-longitude": geolocation?.longitude ?? undefined,
36
30
  "customer-location-postal_code": config["customer-location-postal_code"] ?? undefined,
37
- "customer-location-time_zone": undefined,
38
31
  "customer-location-state": config["customer-location-state"] ?? undefined,
39
32
  "customer-location-street1": config["customer-location-street_1"] ?? undefined,
40
33
  "customer-location-street2": undefined,
34
+ "customer-location-time_zone": undefined,
41
35
  "customer-phone_number": config["customer-phone_number"] ?? undefined,
42
36
  "customer-time_zone": config["customer-timezone"] ?? undefined,
37
+ "employee-ids": config["employee-ids"] ?? undefined,
38
+ "employee-type": config["employee-type"] ?? undefined,
39
+ flow: config.flow ?? undefined,
40
+ intent: config.intent ?? undefined,
41
+ language: config.language ?? undefined,
43
42
  "lead_segment-id": config["lead_segment-id"] ?? undefined,
44
43
  "lead_segment-type": config["lead_segment-type"] ?? undefined,
45
44
  "listing-id": config["listing-id"] ?? undefined,
46
45
  "listing-type": config["listing-type"] ?? undefined,
47
46
  "location-formatted_address": config["location-initial_search"] ?? undefined,
48
47
  meeting_types: meetingTypes ?? undefined,
48
+ message_for_customer: config.message_for_customer ?? undefined,
49
+ metadata: undefined,
49
50
  "oauth-resource_code": config["oauth-resource_code"] ?? undefined,
50
51
  "office-ids": config["office-ids"] ?? undefined,
51
52
  "office-type": config["office-type"] ?? undefined,
@@ -53,15 +54,14 @@ export function migrateConfiguration(config: PluginConfigurationV0): PluginConfi
53
54
  "session-id": config["session-id"] ?? undefined,
54
55
  "session-source_tags": config["session-source_tags"] ?? undefined,
55
56
  "session-status": config["session-status"] ?? undefined,
56
- "subject-ids": config["subject-ids"] ?? undefined,
57
- "subject-type": config["subject-type"] ?? undefined,
58
- message_for_customer: config.message_for_customer ?? undefined,
59
- metadata: undefined,
60
57
  "subject_group-ids": undefined,
61
58
  "subject_group-type": undefined,
62
59
  subject_questions: undefined,
63
- "timetable-view": undefined,
60
+ "subject-ids": config["subject-ids"] ?? undefined,
61
+ "subject-type": config["subject-type"] ?? undefined,
64
62
  "timetable-meeting_type_selector": undefined,
63
+ "timetable-view": undefined,
64
+ version: "1.0.0",
65
65
  };
66
66
 
67
67
  // remove all undefined values.
@@ -74,13 +74,13 @@ function runMigrations(config: PluginConfigurationV0) {
74
74
  const geolocation = latitude && longitude ? { latitude, longitude } : null;
75
75
 
76
76
  return {
77
- timezoneSelection: migrateTimeZoneSelection(config["application-timezone_selection"]),
78
77
  geolocation: geolocation,
79
78
  meetingTypes: config.meeting_types
80
79
  ? Array.isArray(config.meeting_types)
81
80
  ? config.meeting_types.map(migrateMeetingType)
82
81
  : migrateMeetingType(config.meeting_types)
83
82
  : null,
83
+ timezoneSelection: migrateTimeZoneSelection(config["application-timezone_selection"]),
84
84
  };
85
85
  }
86
86
 
@@ -3,9 +3,6 @@ import { decodeURIParameters, encodeURIParameters } from "../encoding.js";
3
3
 
4
4
  export const HASH_PREFIX = "#pexip-";
5
5
  export const hashParser = {
6
- encode(value: PluginConfiguration): string {
7
- return HASH_PREFIX + encodeURIParameters(value);
8
- },
9
6
  decode(hash?: string | null): PluginConfiguration | null {
10
7
  if (!hash || !hash.startsWith(HASH_PREFIX)) return null;
11
8
 
@@ -15,4 +12,7 @@ export const hashParser = {
15
12
 
16
13
  return configuration;
17
14
  },
15
+ encode(value: PluginConfiguration): string {
16
+ return HASH_PREFIX + encodeURIParameters(value);
17
+ },
18
18
  };
@@ -10,9 +10,6 @@ export type HTMLConfig = {
10
10
  };
11
11
 
12
12
  export const htmlParser = {
13
- encode(config: PluginConfiguration): string[] {
14
- return Object.entries(config).map(([key, value]) => `${ATTR_PREFIX}${key}="${value}"`);
15
- },
16
13
  decode(element?: HTMLElement | null): PluginConfiguration | null {
17
14
  try {
18
15
  if (!element) return null;
@@ -33,4 +30,7 @@ export const htmlParser = {
33
30
  return null;
34
31
  }
35
32
  },
33
+ encode(config: PluginConfiguration): string[] {
34
+ return Object.entries(config).map(([key, value]) => `${ATTR_PREFIX}${key}="${value}"`);
35
+ },
36
36
  };
@@ -7,7 +7,7 @@ import { jsParser } from "./js-parser.js";
7
7
 
8
8
  // import { migrateLegacyConfiguration } from './migrate-legacy-configuration.js';
9
9
  export const CONFIG_VERSION: Exclude<PluginConfiguration["version"], undefined> = "1.0.0";
10
- export const parser = { js: jsParser, hash: hashParser, html: htmlParser };
10
+ export const parser = { hash: hashParser, html: htmlParser, js: jsParser };
11
11
  export { HASH_PREFIX } from "./hash-parser.js";
12
12
  export { ATTR_PREFIX } from "./html-parser.js";
13
13
  export type { JSConfig } from "./js-parser.js";
@@ -55,8 +55,8 @@ function parse({ browser, element, hash, options }: ConfigurationProps) {
55
55
  ...hashConfig,
56
56
  ...jsConfig,
57
57
  "browser-href": browser.href,
58
- "browser-time_zone": browser.timeZone,
59
58
  "browser-legacy-mode": browser.legacyMode ? "enabled" : undefined,
59
+ "browser-time_zone": browser.timeZone,
60
60
  };
61
61
 
62
62
  const meetingTypes = config.meeting_types;
@@ -1,5 +1,5 @@
1
- import type { MeetingType } from "@pexip-engage-public/graphql";
2
1
  import { safeJSONParse } from "@pexip-engage/utils/safe-json-parse";
2
+ import type { MeetingType } from "@pexip-engage-public/graphql";
3
3
  import type { PluginConfiguration } from "../configuration/PluginConfiguration.current.js";
4
4
  import { logger } from "../logger.js";
5
5
 
@@ -8,25 +8,98 @@ function isValidConfiguration(configuration: unknown): configuration is object {
8
8
  }
9
9
 
10
10
  export const jsParser = {
11
+ decode(jsConfig?: unknown): PluginConfiguration | null {
12
+ if (!jsConfig) return null;
13
+
14
+ try {
15
+ if (!isValidConfiguration(jsConfig))
16
+ throw new Error("Invalid configuration passed, expected an object.");
17
+
18
+ if (jsConfig && "config" in jsConfig && isValidConfiguration(jsConfig.config)) {
19
+ const config = jsConfig.config as NonNullable<JSConfig["config"]>;
20
+
21
+ const result: PluginConfiguration = {
22
+ "application-customer_location_search": config.application?.customerLocationSearch,
23
+ "application-recaptcha": config.application?.recaptcha,
24
+ "application-scroll": config.application?.scroll,
25
+ "application-theme": config.application?.theme,
26
+ "application-time_zone_selection": config.application?.timeZoneSelection,
27
+ "customer-company": config.customer?.company,
28
+ "customer-customer_number": config.customer?.customerNumber,
29
+ "customer-email": config.customer?.email,
30
+ "customer-existing": config.customer?.existing,
31
+ "customer-external_id": config.customer?.externalId,
32
+ "customer-first_name": config.customer?.firstName,
33
+ "customer-id": config.customer?.id,
34
+ "customer-language": config.customer?.language,
35
+ "customer-last_name": config.customer?.lastName,
36
+ "customer-location-city": config.customer?.location?.city,
37
+ "customer-location-country_code": config.customer?.location?.countryCode,
38
+ "customer-location-geolocation-latitude":
39
+ config.customer?.location?.geolocation?.latitude,
40
+ "customer-location-geolocation-longitude":
41
+ config.customer?.location?.geolocation?.longitude,
42
+ "customer-location-postal_code": config.customer?.location?.postalCode,
43
+ "customer-location-state": config.customer?.location?.state,
44
+ "customer-location-street1": config.customer?.location?.street1,
45
+ "customer-location-street2": config.customer?.location?.street2,
46
+ "customer-location-time_zone": config.customer?.location?.timeZone,
47
+ "customer-phone_number": config.customer?.phoneNumber,
48
+ "customer-time_zone": config.customer?.timeZone,
49
+ "employee-ids": config.employee?.ids,
50
+ "employee-type": config.employee?.type,
51
+ flow: config.flow,
52
+ intent: config.intent,
53
+ language: config.language,
54
+ "lead_segment-id": config.leadSegment?.id,
55
+ "lead_segment-type": config.leadSegment?.type,
56
+ "listing-id": config.listing?.id,
57
+ "listing-type": config.listing?.type,
58
+ "location-formatted_address": config.location?.formattedAddress,
59
+ meeting_types: config.meetingTypes,
60
+ message_for_customer: config.messageForCustomer,
61
+ metadata: config.metadata ? JSON.stringify(config.metadata) : undefined,
62
+ "oauth-resource_code": config.oauth?.resourceCode,
63
+ "office-ids": config.office?.ids,
64
+ "office-type": config.office?.type,
65
+ search_countries: config.searchCountries,
66
+ "session-id": config.session?.id,
67
+ "session-source_tags": config.session?.sourceTags,
68
+ "session-status": config.session?.status,
69
+ "subject_group-ids": config.subjectGroup?.ids,
70
+ "subject_group-type": config.subjectGroup?.type,
71
+ subject_questions: config?.subjectQuestions
72
+ ? JSON.stringify(config.subjectQuestions)
73
+ : undefined,
74
+ "subject-ids": config.subject?.ids,
75
+ "subject-type": config.subject?.type,
76
+ "timetable-meeting_type_selector": config.timetable?.meetingTypeSelector,
77
+ "timetable-view": config.timetable?.view,
78
+ version: config.version,
79
+ };
80
+
81
+ return prune(result);
82
+ }
83
+
84
+ return null;
85
+ } catch (err) {
86
+ logger.error("Failed to parse JS config:", jsConfig);
87
+ logger.error("JS ERROR:", err);
88
+
89
+ return null;
90
+ }
91
+ },
11
92
  encode(config: PluginConfiguration): JSConfig {
12
93
  const metadata = config.metadata ? safeJSONParse(config.metadata) : undefined;
13
94
 
14
95
  const result: JSConfig["config"] = {
15
- version: config.version,
16
- flow: config.flow,
17
- intent: config.intent as any,
18
- language: config.language as any,
19
- employee: {
20
- ids: config["employee-ids"],
21
- type: config["employee-type"] as any,
22
- },
23
96
  application: {
97
+ customerLocationSearch: config["application-customer_location_search"] as any,
24
98
  officeSearch: config["application-office_search"] as any,
99
+ recaptcha: config["application-recaptcha"] as any,
25
100
  scroll: config["application-scroll"] as any,
26
- customerLocationSearch: config["application-customer_location_search"] as any,
27
- timeZoneSelection: config["application-time_zone_selection"] as any,
28
101
  theme: config["application-theme"],
29
- recaptcha: config["application-recaptcha"] as any,
102
+ timeZoneSelection: config["application-time_zone_selection"] as any,
30
103
  },
31
104
  customer: {
32
105
  company: config["customer-company"],
@@ -46,14 +119,21 @@ export const jsParser = {
46
119
  longitude: config["customer-location-geolocation-longitude"] as any,
47
120
  },
48
121
  postalCode: config["customer-location-postal_code"],
49
- timeZone: config["customer-location-time_zone"],
50
122
  state: config["customer-location-state"],
51
123
  street1: config["customer-location-street1"],
52
124
  street2: config["customer-location-street2"],
125
+ timeZone: config["customer-location-time_zone"],
53
126
  },
54
127
  phoneNumber: config["customer-phone_number"],
55
128
  timeZone: config["customer-time_zone"],
56
129
  },
130
+ employee: {
131
+ ids: config["employee-ids"],
132
+ type: config["employee-type"] as any,
133
+ },
134
+ flow: config.flow,
135
+ intent: config.intent as any,
136
+ language: config.language as any,
57
137
  leadSegment: {
58
138
  id: config["lead_segment-id"],
59
139
  type: config["lead_segment-type"] as any,
@@ -96,91 +176,11 @@ export const jsParser = {
96
176
  meetingTypeSelector: config["timetable-meeting_type_selector"] as any,
97
177
  view: config["timetable-view"] as any,
98
178
  },
179
+ version: config.version,
99
180
  };
100
181
 
101
182
  return { config: prune(result) };
102
183
  },
103
- decode(jsConfig?: unknown): PluginConfiguration | null {
104
- if (!jsConfig) return null;
105
-
106
- try {
107
- if (!isValidConfiguration(jsConfig))
108
- throw new Error("Invalid configuration passed, expected an object.");
109
-
110
- if (jsConfig && "config" in jsConfig && isValidConfiguration(jsConfig.config)) {
111
- const config = jsConfig.config as NonNullable<JSConfig["config"]>;
112
-
113
- const result: PluginConfiguration = {
114
- version: config.version,
115
- flow: config.flow,
116
- intent: config.intent,
117
- language: config.language,
118
- "employee-ids": config.employee?.ids,
119
- "employee-type": config.employee?.type,
120
- "application-customer_location_search": config.application?.customerLocationSearch,
121
- "application-scroll": config.application?.scroll,
122
- "application-time_zone_selection": config.application?.timeZoneSelection,
123
- "application-theme": config.application?.theme,
124
- "application-recaptcha": config.application?.recaptcha,
125
- "customer-company": config.customer?.company,
126
- "customer-customer_number": config.customer?.customerNumber,
127
- "customer-email": config.customer?.email,
128
- "customer-existing": config.customer?.existing,
129
- "customer-external_id": config.customer?.externalId,
130
- "customer-first_name": config.customer?.firstName,
131
- "customer-id": config.customer?.id,
132
- "customer-language": config.customer?.language,
133
- "customer-last_name": config.customer?.lastName,
134
- "customer-location-city": config.customer?.location?.city,
135
- "customer-location-country_code": config.customer?.location?.countryCode,
136
- "customer-location-geolocation-latitude":
137
- config.customer?.location?.geolocation?.latitude,
138
- "customer-location-geolocation-longitude":
139
- config.customer?.location?.geolocation?.longitude,
140
- "customer-location-postal_code": config.customer?.location?.postalCode,
141
- "customer-location-time_zone": config.customer?.location?.timeZone,
142
- "customer-location-state": config.customer?.location?.state,
143
- "customer-location-street1": config.customer?.location?.street1,
144
- "customer-location-street2": config.customer?.location?.street2,
145
- "customer-phone_number": config.customer?.phoneNumber,
146
- "customer-time_zone": config.customer?.timeZone,
147
- "lead_segment-id": config.leadSegment?.id,
148
- "lead_segment-type": config.leadSegment?.type,
149
- "listing-id": config.listing?.id,
150
- "listing-type": config.listing?.type,
151
- "location-formatted_address": config.location?.formattedAddress,
152
- meeting_types: config.meetingTypes,
153
- message_for_customer: config.messageForCustomer,
154
- metadata: config.metadata ? JSON.stringify(config.metadata) : undefined,
155
- "oauth-resource_code": config.oauth?.resourceCode,
156
- "office-ids": config.office?.ids,
157
- "office-type": config.office?.type,
158
- search_countries: config.searchCountries,
159
- "session-id": config.session?.id,
160
- "session-source_tags": config.session?.sourceTags,
161
- "session-status": config.session?.status,
162
- "subject-ids": config.subject?.ids,
163
- "subject-type": config.subject?.type,
164
- "subject_group-ids": config.subjectGroup?.ids,
165
- "subject_group-type": config.subjectGroup?.type,
166
- subject_questions: config?.subjectQuestions
167
- ? JSON.stringify(config.subjectQuestions)
168
- : undefined,
169
- "timetable-meeting_type_selector": config.timetable?.meetingTypeSelector,
170
- "timetable-view": config.timetable?.view,
171
- };
172
-
173
- return prune(result);
174
- }
175
-
176
- return null;
177
- } catch (err) {
178
- logger.error("Failed to parse JS config:", jsConfig);
179
- logger.error("JS ERROR:", err);
180
-
181
- return null;
182
- }
183
- },
184
184
  };
185
185
 
186
186
  function prune<T>(obj: T): T {
@@ -1,6 +1,6 @@
1
- import { parsePluginConfigurationV1 } from "../configuration-parser-legacy/Parser.js";
2
- import type { PluginConfiguration } from "../configuration/PluginConfiguration.current.js";
3
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
4
  import { logger } from "../logger.js";
5
5
 
6
6
  import { hashParser } from "./hash-parser.js";
@@ -8,14 +8,14 @@ import { htmlParser } from "./html-parser.js";
8
8
  import { CONFIG_VERSION, type ConfigurationProps } from "./index.js";
9
9
  import { type JSConfig, jsParser } from "./js-parser.js";
10
10
 
11
- const parser = { js: jsParser, hash: hashParser, html: htmlParser };
11
+ const parser = { hash: hashParser, html: htmlParser, js: jsParser };
12
12
 
13
13
  export function migrateLegacyConfiguration(args: ConfigurationProps) {
14
14
  const v1Config = parsePluginConfigurationV1({
15
+ browserTimeZone: args.browser.timeZone,
15
16
  element: args.element,
16
17
  hash: args.hash,
17
18
  href: args.browser.href,
18
- browserTimeZone: args.browser.timeZone,
19
19
  options: args.options,
20
20
  });
21
21
 
@@ -5,6 +5,7 @@ import { logger } from "../logger.js";
5
5
 
6
6
  import { legacyHashToPluginInputConfiguration } from "./LegacyParser.utils.js";
7
7
  import { sanitize } from "./utils.js";
8
+
8
9
  interface LegacyParseParams {
9
10
  element?: HTMLElement | null;
10
11
  hash?: string | null;
@@ -42,63 +43,63 @@ export function parseDOMParams(element?: HTMLElement | null): LegacyPluginHashCo
42
43
  }
43
44
 
44
45
  const configuration = sanitize<LegacyPluginHashConfiguration>({
45
- /** OAUTH */
46
- rco: getAttribute("oauth.resource_code"),
46
+ act: getAttribute("intent") ?? getAttribute("hints.intent"),
47
47
  // token: getAttribute("oauth.token"),
48
48
  /** SESSION */
49
49
  cas: getAttribute("session.status"),
50
- sid: getAttribute("session.id"),
51
- sst: getAttribute("session.source_tags"),
50
+ cci: getAttribute("customer.location.city"),
51
+ ccn: getAttribute("customer.customer_number"),
52
+ cco: getAttribute("customer.location.country"),
52
53
  /** CUSTOMER */
53
54
  ccom: getAttribute("customer.company"),
54
- ccn: getAttribute("customer.customer_number"),
55
55
  cdob: getAttribute("customer.date_of_birth"),
56
- cem: getAttribute("customer.email"),
57
56
  ceid: getAttribute("customer.external_id"),
57
+ cem: getAttribute("customer.email"),
58
58
  cfn: getAttribute("customer.first_name"),
59
+ cgl: getAttribute("customer.location.geolocation"),
59
60
  cgr: getAttribute("customer.gender"),
60
61
  cid: getAttribute("customer.id"),
61
62
  cie: getAttribute("customer.is_existing"),
62
- clng: getAttribute("customer.language"),
63
63
  cln: getAttribute("customer.last_name"),
64
- cgl: getAttribute("customer.location.geolocation"),
65
- cci: getAttribute("customer.location.city"),
66
- cco: getAttribute("customer.location.country"),
64
+ clng: getAttribute("customer.language"),
65
+ /** HINTS */
66
+ con: getAttribute("hints.contacts"),
67
67
  cpc: getAttribute("customer.location.postal_code"),
68
- csa: getAttribute("customer.location.state"),
69
- cst: getAttribute("customer.location.street_1"),
70
- cpn: getAttribute("customer.phone_number"),
71
68
  cpci: getAttribute("customer.preferred_contact_id"),
69
+ cpn: getAttribute("customer.phone_number"),
72
70
  cpoi: getAttribute("customer.preferred_office_id"),
71
+ csa: getAttribute("customer.location.state"),
72
+ cst: getAttribute("customer.location.street_1"),
73
73
  ctz: getAttribute("customer.timezone"),
74
- /** APPOINTMENT */
75
- off: getAttribute("appointment.office_id"),
76
- sub: getAttribute("appointment.subject_id"),
77
- lis: getAttribute("appointment.listing_id"),
74
+ eco: getAttribute("hints.external_employee_ids"),
75
+ eli: getAttribute("external_listing_id"),
76
+ eof: getAttribute("external_office_id"),
78
77
  /** EXTERNAL */
79
78
  esb: getAttribute("external_subject_id"),
80
- eof: getAttribute("external_office_id"),
81
- eli: getAttribute("external_listing_id"),
82
- lsc: getAttribute("lead_segment_code"),
83
- /** HINTS */
84
- con: getAttribute("hints.contacts"),
85
- eco: getAttribute("hints.external_employee_ids"),
86
- act: getAttribute("intent") ?? getAttribute("hints.intent"),
87
- lng: getAttribute("language"),
88
- mty: getAttribute("meeting_types"),
89
- /** APPLICATION */
90
- scr: getAttribute("application.scroll"),
91
79
  ets: getAttribute("application.timezone_selection"),
80
+ flo: getAttribute("flow"),
81
+ lci: getAttribute("location.city"),
82
+ lco: getAttribute("location.country"),
92
83
  /** LOCATION */
93
84
  lfa: getAttribute("location.formatted_address"),
94
85
  lgl: getAttribute("location.geolocation"),
95
- lci: getAttribute("location.city"),
96
- lco: getAttribute("location.country"),
86
+ lis: getAttribute("appointment.listing_id"),
87
+ lng: getAttribute("language"),
97
88
  lpc: getAttribute("location.postal_code"),
98
89
  lsa: getAttribute("location.state"),
90
+ lsc: getAttribute("lead_segment_code"),
99
91
  lst: getAttribute("location.street_1"),
92
+ mty: getAttribute("meeting_types"),
93
+ /** APPOINTMENT */
94
+ off: getAttribute("appointment.office_id"),
95
+ /** OAUTH */
96
+ rco: getAttribute("oauth.resource_code"),
100
97
  sco: getAttribute("searchCountry") ?? getAttribute("search.country"),
101
- flo: getAttribute("flow"),
98
+ /** APPLICATION */
99
+ scr: getAttribute("application.scroll"),
100
+ sid: getAttribute("session.id"),
101
+ sst: getAttribute("session.source_tags"),
102
+ sub: getAttribute("appointment.subject_id"),
102
103
  });
103
104
 
104
105
  return configuration;
@@ -134,62 +135,62 @@ export function parseJSConfigParams(
134
135
  if (!config) return {};
135
136
 
136
137
  const configuration = sanitize<LegacyPluginHashConfiguration>({
137
- /** OAUTH */
138
- rco: config.oauth?.resource_code,
138
+ act: config.intent ?? config.hints?.intent,
139
139
  /** SESSION */
140
140
  cas: config.session?.status,
141
- sid: config.session?.id,
142
- sst: config.session?.source_tags,
141
+ cci: config.customer?.location?.city,
142
+ ccn: config.customer?.customer_number,
143
+ cco: config.customer?.location?.country,
143
144
  /** CUSTOMER */
144
145
  ccom: config.customer?.company,
145
- ccn: config.customer?.customer_number,
146
146
  cdob: config.customer?.date_of_birth,
147
- cem: config.customer?.email,
148
147
  ceid: config.customer?.external_id,
148
+ cem: config.customer?.email,
149
149
  cfn: config.customer?.first_name,
150
+ cgl: config.customer?.location?.geolocation,
150
151
  cgr: config.customer?.gender,
151
152
  cid: config.customer?.id,
152
153
  cie: config.customer?.is_existing?.toString(),
153
- clng: config.customer?.language,
154
154
  cln: config.customer?.last_name,
155
- cgl: config.customer?.location?.geolocation,
156
- cci: config.customer?.location?.city,
157
- cco: config.customer?.location?.country,
155
+ clng: config.customer?.language,
156
+ /** HINTS */
157
+ con: config.hints?.contacts,
158
158
  cpc: config.customer?.location?.postal_code,
159
- csa: config.customer?.location?.state,
160
- cst: config.customer?.location?.street_1,
161
- cpn: config.customer?.phone_number,
162
159
  cpci: config.customer?.preferred_contact_id,
160
+ cpn: config.customer?.phone_number,
163
161
  cpoi: config.customer?.preferred_office_id,
162
+ csa: config.customer?.location?.state,
163
+ cst: config.customer?.location?.street_1,
164
164
  ctz: config.customer?.timezone,
165
- /** APPOINTMENT */
166
- off: config.appointment?.office_id,
167
- sub: config.appointment?.subject_id,
168
- lis: config.appointment?.listing_id,
165
+ eco: config.hints?.external_employee_ids,
166
+ eli: config.external_listing_id,
167
+ eof: config.external_office_id,
169
168
  /** EXTERNAL */
170
169
  esb: config.external_subject_id,
171
- eof: config.external_office_id,
172
- eli: config.external_listing_id,
173
- lsc: config.lead_segment_code,
174
- /** HINTS */
175
- con: config.hints?.contacts,
176
- eco: config.hints?.external_employee_ids,
177
- act: config.intent ?? config.hints?.intent,
178
- lng: config.language,
179
- mty: config.meeting_types,
180
- /** APPLICATION */
181
- scr: config.application?.scroll,
182
170
  ets: config.application?.timezone_selection,
171
+ flo: config.flow,
172
+ lci: config.location?.city,
173
+ lco: config.location?.country,
183
174
  /** LOCATION */
184
175
  lfa: config.location?.formatted_address,
185
176
  lgl: config.location?.geolocation,
186
- lci: config.location?.city,
187
- lco: config.location?.country,
177
+ lis: config.appointment?.listing_id,
178
+ lng: config.language,
188
179
  lpc: config.location?.postal_code,
189
180
  lsa: config.location?.state,
181
+ lsc: config.lead_segment_code,
190
182
  lst: config.location?.street_1,
183
+ mty: config.meeting_types,
184
+ /** APPOINTMENT */
185
+ off: config.appointment?.office_id,
186
+ /** OAUTH */
187
+ rco: config.oauth?.resource_code,
191
188
  sco: config.searchCountry ?? config.search?.country,
192
- flo: config.flow,
189
+ /** APPLICATION */
190
+ scr: config.application?.scroll,
191
+ sid: config.session?.id,
192
+ sst: config.session?.source_tags,
193
+ sub: config.appointment?.subject_id,
193
194
  });
194
195
 
195
196
  return configuration;
@@ -14,23 +14,12 @@ export function legacyHashToPluginInputConfiguration(
14
14
  config: LegacyPluginHashConfiguration,
15
15
  ): PluginConfigurationV0 {
16
16
  return sanitize<PluginConfigurationV0>({
17
- version: undefined,
18
- flow: transformDeprecatedTokens(insertMeetingTypeStepInFlow(config.flo)),
19
- intent: config.act as any,
20
- "subject-ids": config.sub ?? config.esb,
21
- "subject-type": config.sub ? "id" : config.esb ? "externalId" : undefined,
22
- "office-ids": config.off ?? config.eof,
23
- "office-type": config.off ? "id" : config.eof ? "externalId" : undefined,
24
- "listing-id": config.lis ?? config.eli,
25
- "listing-type": config.lis ? "id" : config.eli ? "externalId" : undefined,
26
- "employee-ids": config.con ?? config.eco,
27
- "employee-type": config.con ? "id" : config.eco ? "externalId" : undefined,
28
- "lead_segment-id": config.lsc,
29
- "lead_segment-type": config.lsc ? "code" : undefined,
30
- "oauth-resource_code": config.rco,
31
- "session-status": config.cas,
32
- "session-id": config.sid,
33
- "session-source_tags": config.sst,
17
+ "application-office_search": undefined,
18
+ "application-scroll":
19
+ config.scr === "disable_initial_scroll_on_schedule" ? "disabled" : undefined,
20
+ "application-theme": undefined,
21
+ "application-timezone_selection": config.ets,
22
+ "browser-timezone": undefined,
34
23
  "customer-company": config.ccom,
35
24
  "customer-customer_number": config.ccn,
36
25
  "customer-date_of_birth": config.cdob,
@@ -52,18 +41,29 @@ export function legacyHashToPluginInputConfiguration(
52
41
  "customer-preferred_contact_id": config.cpci,
53
42
  "customer-preferred_office_id": config.cpoi,
54
43
  "customer-timezone": config.ctz,
44
+ "employee-ids": config.con ?? config.eco,
45
+ "employee-type": config.con ? "id" : config.eco ? "externalId" : undefined,
46
+ flow: transformDeprecatedTokens(insertMeetingTypeStepInFlow(config.flo)),
47
+ intent: config.act as any,
55
48
  language: config.lng,
49
+ "lead_segment-id": config.lsc,
50
+ "lead_segment-type": config.lsc ? "code" : undefined,
51
+ "listing-id": config.lis ?? config.eli,
52
+ "listing-type": config.lis ? "id" : config.eli ? "externalId" : undefined,
53
+ "location-initial_search": config.lfa,
56
54
  meeting_types: config.mty,
57
55
  message_for_customer: undefined,
58
- "application-office_search": undefined,
59
- "application-scroll":
60
- config.scr === "disable_initial_scroll_on_schedule" ? "disabled" : undefined,
61
- "application-timezone_selection": config.ets,
62
- "application-theme": undefined,
63
- "location-initial_search": config.lfa,
56
+ "oauth-resource_code": config.rco,
57
+ "office-ids": config.off ?? config.eof,
58
+ "office-type": config.off ? "id" : config.eof ? "externalId" : undefined,
64
59
  search_countries: config.sco,
60
+ "session-id": config.sid,
61
+ "session-source_tags": config.sst,
62
+ "session-status": config.cas,
65
63
  source_href: undefined,
66
- "browser-timezone": undefined,
64
+ "subject-ids": config.sub ?? config.esb,
65
+ "subject-type": config.sub ? "id" : config.esb ? "externalId" : undefined,
66
+ version: undefined,
67
67
  });
68
68
  }
69
69