@pexip-engage-public/plugin 1.0.0-canary-20231031112431
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 +11 -0
- package/dist/configuration/PluginConfiguration.current.d.ts +52 -0
- package/dist/configuration/PluginConfiguration.current.d.ts.map +1 -0
- package/dist/configuration/PluginConfiguration.current.js +1 -0
- package/dist/configuration/PluginConfiguration.schema.d.ts +489 -0
- package/dist/configuration/PluginConfiguration.schema.d.ts.map +1 -0
- package/dist/configuration/PluginConfiguration.schema.js +121 -0
- package/dist/configuration/PluginConfiguration.v0.d.ts +51 -0
- package/dist/configuration/PluginConfiguration.v0.d.ts.map +1 -0
- package/dist/configuration/PluginConfiguration.v0.js +1 -0
- package/dist/configuration/PluginConfiguration.v1.d.ts +51 -0
- package/dist/configuration/PluginConfiguration.v1.d.ts.map +1 -0
- package/dist/configuration/PluginConfiguration.v1.js +1 -0
- package/dist/configuration/index.d.ts +2 -0
- package/dist/configuration/index.d.ts.map +1 -0
- package/dist/configuration/index.js +1 -0
- package/dist/configuration/migration.d.ts +6 -0
- package/dist/configuration/migration.d.ts.map +1 -0
- package/dist/configuration/migration.js +84 -0
- package/dist/configuration-parser/LegacyParser.d.ts +196 -0
- package/dist/configuration-parser/LegacyParser.d.ts.map +1 -0
- package/dist/configuration-parser/LegacyParser.js +165 -0
- package/dist/configuration-parser/LegacyParser.utils.d.ts +88 -0
- package/dist/configuration-parser/LegacyParser.utils.d.ts.map +1 -0
- package/dist/configuration-parser/LegacyParser.utils.js +255 -0
- package/dist/configuration-parser/ModernParser.d.ts +99 -0
- package/dist/configuration-parser/ModernParser.d.ts.map +1 -0
- package/dist/configuration-parser/ModernParser.js +48 -0
- package/dist/configuration-parser/ModernParser.utils.d.ts +6 -0
- package/dist/configuration-parser/ModernParser.utils.d.ts.map +1 -0
- package/dist/configuration-parser/ModernParser.utils.js +28 -0
- package/dist/configuration-parser/Parser.d.ts +28 -0
- package/dist/configuration-parser/Parser.d.ts.map +1 -0
- package/dist/configuration-parser/Parser.js +33 -0
- package/dist/configuration-parser/hash-parser.d.ts +7 -0
- package/dist/configuration-parser/hash-parser.d.ts.map +1 -0
- package/dist/configuration-parser/hash-parser.js +13 -0
- package/dist/configuration-parser/html-parser.d.ts +13 -0
- package/dist/configuration-parser/html-parser.d.ts.map +1 -0
- package/dist/configuration-parser/html-parser.js +23 -0
- package/dist/configuration-parser/index.d.ts +48 -0
- package/dist/configuration-parser/index.d.ts.map +1 -0
- package/dist/configuration-parser/index.js +86 -0
- package/dist/configuration-parser/js-parser.d.ts +84 -0
- package/dist/configuration-parser/js-parser.d.ts.map +1 -0
- package/dist/configuration-parser/js-parser.js +56 -0
- package/dist/configuration-parser/tests/LegacyDomParser.test.d.ts +2 -0
- package/dist/configuration-parser/tests/LegacyDomParser.test.d.ts.map +1 -0
- package/dist/configuration-parser/tests/LegacyDomParser.test.js +151 -0
- package/dist/configuration-parser/tests/LegacyLocationHashParser.test.d.ts +2 -0
- package/dist/configuration-parser/tests/LegacyLocationHashParser.test.d.ts.map +1 -0
- package/dist/configuration-parser/tests/LegacyLocationHashParser.test.js +86 -0
- package/dist/configuration-parser/tests/LegacyParser.test.d.ts +2 -0
- package/dist/configuration-parser/tests/LegacyParser.test.d.ts.map +1 -0
- package/dist/configuration-parser/tests/LegacyParser.test.js +104 -0
- package/dist/configuration-parser/tests/test-utils.d.ts +4 -0
- package/dist/configuration-parser/tests/test-utils.d.ts.map +1 -0
- package/dist/configuration-parser/tests/test-utils.js +10 -0
- package/dist/configuration-parser/utils.d.ts +18 -0
- package/dist/configuration-parser/utils.d.ts.map +1 -0
- package/dist/configuration-parser/utils.js +44 -0
- package/dist/configuration-parser-legacy/LegacyParser.d.ts +196 -0
- package/dist/configuration-parser-legacy/LegacyParser.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/LegacyParser.js +162 -0
- package/dist/configuration-parser-legacy/LegacyParser.utils.d.ts +8 -0
- package/dist/configuration-parser-legacy/LegacyParser.utils.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/LegacyParser.utils.js +88 -0
- package/dist/configuration-parser-legacy/ModernParser.d.ts +97 -0
- package/dist/configuration-parser-legacy/ModernParser.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/ModernParser.js +96 -0
- package/dist/configuration-parser-legacy/Parser.d.ts +20 -0
- package/dist/configuration-parser-legacy/Parser.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/Parser.js +20 -0
- package/dist/configuration-parser-legacy/tests/LegacyDomParser.test.d.ts +2 -0
- package/dist/configuration-parser-legacy/tests/LegacyDomParser.test.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/tests/LegacyDomParser.test.js +151 -0
- package/dist/configuration-parser-legacy/tests/LegacyLocationHashParser.test.d.ts +2 -0
- package/dist/configuration-parser-legacy/tests/LegacyLocationHashParser.test.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/tests/LegacyLocationHashParser.test.js +86 -0
- package/dist/configuration-parser-legacy/tests/LegacyParser.test.d.ts +2 -0
- package/dist/configuration-parser-legacy/tests/LegacyParser.test.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/tests/LegacyParser.test.js +104 -0
- package/dist/configuration-parser-legacy/tests/test-utils.d.ts +4 -0
- package/dist/configuration-parser-legacy/tests/test-utils.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/tests/test-utils.js +10 -0
- package/dist/configuration-parser-legacy/utils.d.ts +14 -0
- package/dist/configuration-parser-legacy/utils.d.ts.map +1 -0
- package/dist/configuration-parser-legacy/utils.js +24 -0
- package/dist/constants.d.ts +22 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +50 -0
- package/dist/encoding.d.ts +8 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/encoding.js +33 -0
- package/dist/events/conversion-analytics.d.ts +120 -0
- package/dist/events/conversion-analytics.d.ts.map +1 -0
- package/dist/events/conversion-analytics.js +10 -0
- package/dist/events/event-types.d.ts +152 -0
- package/dist/events/event-types.d.ts.map +1 -0
- package/dist/events/event-types.js +1 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +1 -0
- package/dist/events/utils.d.ts +2 -0
- package/dist/events/utils.d.ts.map +1 -0
- package/dist/events/utils.js +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/instance/PexipEngagePluginFrame.d.ts +8 -0
- package/dist/instance/PexipEngagePluginFrame.d.ts.map +1 -0
- package/dist/instance/PexipEngagePluginFrame.js +39 -0
- package/dist/instance/PluginInstance.d.ts +138 -0
- package/dist/instance/PluginInstance.d.ts.map +1 -0
- package/dist/instance/PluginInstance.js +328 -0
- package/dist/instance/dispatchEvent.d.ts +24 -0
- package/dist/instance/dispatchEvent.d.ts.map +1 -0
- package/dist/instance/dispatchEvent.js +5 -0
- package/dist/instance/hooks.d.ts +17 -0
- package/dist/instance/hooks.d.ts.map +1 -0
- package/dist/instance/hooks.js +1 -0
- package/dist/instance/index.d.ts +19 -0
- package/dist/instance/index.d.ts.map +1 -0
- package/dist/instance/index.js +30 -0
- package/dist/logger.d.ts +10 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +24 -0
- package/dist/state/PluginState.schema.d.ts +943 -0
- package/dist/state/PluginState.schema.d.ts.map +1 -0
- package/dist/state/PluginState.schema.js +52 -0
- package/dist/state/index.d.ts +4 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +2 -0
- package/dist/state/schemas.d.ts +169 -0
- package/dist/state/schemas.d.ts.map +1 -0
- package/dist/state/schemas.js +85 -0
- package/dist/state/utils.d.ts +7 -0
- package/dist/state/utils.d.ts.map +1 -0
- package/dist/state/utils.js +22 -0
- package/package.json +66 -0
- package/src/@types/iframe-resizer.iframeResizer.d.ts +211 -0
- package/src/@types/reset.d.ts +1 -0
- package/src/configuration/PluginConfiguration.current.ts +51 -0
- package/src/configuration/PluginConfiguration.schema.ts +133 -0
- package/src/configuration/PluginConfiguration.v0.ts +50 -0
- package/src/configuration/index.ts +1 -0
- package/src/configuration/migration.ts +95 -0
- package/src/configuration-parser/hash-parser.ts +18 -0
- package/src/configuration-parser/html-parser.ts +35 -0
- package/src/configuration-parser/index.ts +134 -0
- package/src/configuration-parser/js-parser.ts +153 -0
- package/src/configuration-parser-legacy/LegacyParser.ts +376 -0
- package/src/configuration-parser-legacy/LegacyParser.utils.ts +104 -0
- package/src/configuration-parser-legacy/ModernParser.ts +213 -0
- package/src/configuration-parser-legacy/Parser.ts +44 -0
- package/src/configuration-parser-legacy/tests/LegacyDomParser.test.ts +168 -0
- package/src/configuration-parser-legacy/tests/LegacyLocationHashParser.test.ts +96 -0
- package/src/configuration-parser-legacy/tests/LegacyParser.test.ts +117 -0
- package/src/configuration-parser-legacy/tests/test-utils.ts +16 -0
- package/src/configuration-parser-legacy/utils.ts +30 -0
- package/src/constants.ts +61 -0
- package/src/encoding.ts +42 -0
- package/src/events/event-types.ts +126 -0
- package/src/events/index.ts +1 -0
- package/src/instance/PexipEngagePluginFrame.ts +48 -0
- package/src/instance/PluginInstance.ts +429 -0
- package/src/instance/dispatchEvent.ts +34 -0
- package/src/instance/hooks.ts +17 -0
- package/src/instance/index.ts +54 -0
- package/src/logger.ts +25 -0
- package/src/state/PluginState.schema.ts +67 -0
- package/src/state/index.ts +11 -0
- package/src/state/schemas.ts +97 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { decodeURIParameters as legacyDecodeURIParameters } from "skedify-uri-encoding";
|
|
2
|
+
import { logger } from "../logger.js";
|
|
3
|
+
import {
|
|
4
|
+
legacyHashToPluginInputConfiguration,
|
|
5
|
+
logDeprecationWarnings,
|
|
6
|
+
} from "./LegacyParser.utils.js";
|
|
7
|
+
import { sanitize } from "./utils.js";
|
|
8
|
+
export function parse({ element, hash, options }) {
|
|
9
|
+
const domConfig = parseDOMParams(element);
|
|
10
|
+
const hashConfig = parseSkedifyURIHashParams(hash);
|
|
11
|
+
const jsConfig = parseJSConfigParams(options);
|
|
12
|
+
logDeprecationWarnings({ dom: domConfig, hash: hashConfig, js: jsConfig });
|
|
13
|
+
return {
|
|
14
|
+
domConfig: legacyHashToPluginInputConfiguration(domConfig),
|
|
15
|
+
hashConfig: legacyHashToPluginInputConfiguration(hashConfig),
|
|
16
|
+
jsConfig: legacyHashToPluginInputConfiguration(jsConfig),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const ATTR_PREFIX = "skedify:";
|
|
20
|
+
export function parseDOMParams(element) {
|
|
21
|
+
if (!element) return {};
|
|
22
|
+
function getAttribute(name) {
|
|
23
|
+
const value = element?.getAttribute(ATTR_PREFIX + name)?.trim();
|
|
24
|
+
return value || undefined;
|
|
25
|
+
}
|
|
26
|
+
const configuration = sanitize({
|
|
27
|
+
/** OAUTH */
|
|
28
|
+
rco: getAttribute("oauth.resource_code"),
|
|
29
|
+
// token: getAttribute("oauth.token"),
|
|
30
|
+
/** SESSION */
|
|
31
|
+
cas: getAttribute("session.status"),
|
|
32
|
+
sid: getAttribute("session.id"),
|
|
33
|
+
sst: getAttribute("session.source_tags"),
|
|
34
|
+
/** CUSTOMER */
|
|
35
|
+
ccom: getAttribute("customer.company"),
|
|
36
|
+
ccn: getAttribute("customer.customer_number"),
|
|
37
|
+
cdob: getAttribute("customer.date_of_birth"),
|
|
38
|
+
cem: getAttribute("customer.email"),
|
|
39
|
+
ceid: getAttribute("customer.external_id"),
|
|
40
|
+
cfn: getAttribute("customer.first_name"),
|
|
41
|
+
cgr: getAttribute("customer.gender"),
|
|
42
|
+
cid: getAttribute("customer.id"),
|
|
43
|
+
cie: getAttribute("customer.is_existing"),
|
|
44
|
+
clng: getAttribute("customer.language"),
|
|
45
|
+
cln: getAttribute("customer.last_name"),
|
|
46
|
+
cgl: getAttribute("customer.location.geolocation"),
|
|
47
|
+
cci: getAttribute("customer.location.city"),
|
|
48
|
+
cco: getAttribute("customer.location.country"),
|
|
49
|
+
cpc: getAttribute("customer.location.postal_code"),
|
|
50
|
+
csa: getAttribute("customer.location.state"),
|
|
51
|
+
cst: getAttribute("customer.location.street_1"),
|
|
52
|
+
cpn: getAttribute("customer.phone_number"),
|
|
53
|
+
cpci: getAttribute("customer.preferred_contact_id"),
|
|
54
|
+
cpoi: getAttribute("customer.preferred_office_id"),
|
|
55
|
+
ctz: getAttribute("customer.timezone"),
|
|
56
|
+
/** APPOINTMENT */
|
|
57
|
+
off: getAttribute("appointment.office_id"),
|
|
58
|
+
sub: getAttribute("appointment.subject_id"),
|
|
59
|
+
lis: getAttribute("appointment.listing_id"),
|
|
60
|
+
/** EXTERNAL */
|
|
61
|
+
esb: getAttribute("external_subject_id"),
|
|
62
|
+
eof: getAttribute("external_office_id"),
|
|
63
|
+
eli: getAttribute("external_listing_id"),
|
|
64
|
+
lsc: getAttribute("lead_segment_code"),
|
|
65
|
+
/** HINTS */
|
|
66
|
+
con: getAttribute("hints.contacts"),
|
|
67
|
+
eco: getAttribute("hints.external_employee_ids"),
|
|
68
|
+
act: getAttribute("intent") ?? getAttribute("hints.intent"),
|
|
69
|
+
lng: getAttribute("language"),
|
|
70
|
+
mty: getAttribute("meeting_types"),
|
|
71
|
+
/** APPLICATION */
|
|
72
|
+
scr: getAttribute("application.scroll"),
|
|
73
|
+
ets: getAttribute("application.timezone_selection"),
|
|
74
|
+
/** LOCATION */
|
|
75
|
+
lfa: getAttribute("location.formatted_address"),
|
|
76
|
+
lgl: getAttribute("location.geolocation"),
|
|
77
|
+
lci: getAttribute("location.city"),
|
|
78
|
+
lco: getAttribute("location.country"),
|
|
79
|
+
lpc: getAttribute("location.postal_code"),
|
|
80
|
+
lsa: getAttribute("location.state"),
|
|
81
|
+
lst: getAttribute("location.street_1"),
|
|
82
|
+
sco: getAttribute("searchCountry") ?? getAttribute("search.country"),
|
|
83
|
+
flo: getAttribute("flow"),
|
|
84
|
+
});
|
|
85
|
+
return configuration;
|
|
86
|
+
}
|
|
87
|
+
const HASH_PREFIX = "#skedify";
|
|
88
|
+
export function parseSkedifyURIHashParams(hash) {
|
|
89
|
+
if (!hash?.startsWith(HASH_PREFIX)) return {};
|
|
90
|
+
const encodedParams = hash.slice(HASH_PREFIX.length);
|
|
91
|
+
try {
|
|
92
|
+
// TODO probably want to validate this?
|
|
93
|
+
const configuration = sanitize(legacyDecodeURIParameters(encodedParams));
|
|
94
|
+
return configuration;
|
|
95
|
+
} catch (err) {
|
|
96
|
+
logger.error(
|
|
97
|
+
"We could not decode the given configuration. Configuration is ignored.",
|
|
98
|
+
err instanceof Error ? err.message : undefined,
|
|
99
|
+
);
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function parseJSConfigParams(config) {
|
|
104
|
+
if (!config) return {};
|
|
105
|
+
const configuration = sanitize({
|
|
106
|
+
/** OAUTH */
|
|
107
|
+
rco: config.oauth?.resource_code,
|
|
108
|
+
// token: getAttribute("oauth.token"),
|
|
109
|
+
/** SESSION */
|
|
110
|
+
cas: config.session?.status,
|
|
111
|
+
sid: config.session?.id,
|
|
112
|
+
sst: config.session?.source_tags,
|
|
113
|
+
/** CUSTOMER */
|
|
114
|
+
ccom: config.customer?.company,
|
|
115
|
+
ccn: config.customer?.customer_number,
|
|
116
|
+
cdob: config.customer?.date_of_birth,
|
|
117
|
+
cem: config.customer?.email,
|
|
118
|
+
ceid: config.customer?.external_id,
|
|
119
|
+
cfn: config.customer?.first_name,
|
|
120
|
+
cgr: config.customer?.gender,
|
|
121
|
+
cid: config.customer?.id,
|
|
122
|
+
cie: config.customer?.is_existing?.toString(),
|
|
123
|
+
clng: config.customer?.language,
|
|
124
|
+
cln: config.customer?.last_name,
|
|
125
|
+
cgl: config.customer?.location?.geolocation,
|
|
126
|
+
cci: config.customer?.location?.city,
|
|
127
|
+
cco: config.customer?.location?.country,
|
|
128
|
+
cpc: config.customer?.location?.postal_code,
|
|
129
|
+
csa: config.customer?.location?.state,
|
|
130
|
+
cst: config.customer?.location?.street_1,
|
|
131
|
+
cpn: config.customer?.phone_number,
|
|
132
|
+
cpci: config.customer?.preferred_contact_id,
|
|
133
|
+
cpoi: config.customer?.preferred_office_id,
|
|
134
|
+
ctz: config.customer?.timezone,
|
|
135
|
+
/** APPOINTMENT */
|
|
136
|
+
off: config.appointment?.office_id,
|
|
137
|
+
sub: config.appointment?.subject_id,
|
|
138
|
+
lis: config.appointment?.listing_id,
|
|
139
|
+
/** EXTERNAL */
|
|
140
|
+
esb: config.external_subject_id,
|
|
141
|
+
eof: config.external_office_id,
|
|
142
|
+
eli: config.external_listing_id,
|
|
143
|
+
lsc: config.lead_segment_code,
|
|
144
|
+
/** HINTS */
|
|
145
|
+
con: config.hints?.contacts,
|
|
146
|
+
eco: config.hints?.external_employee_ids,
|
|
147
|
+
act: config.intent ?? config.hints?.intent,
|
|
148
|
+
lng: config.language,
|
|
149
|
+
mty: config.meeting_types,
|
|
150
|
+
/** APPLICATION */
|
|
151
|
+
scr: config.application?.scroll,
|
|
152
|
+
ets: config.application?.timezone_selection,
|
|
153
|
+
/** LOCATION */
|
|
154
|
+
lfa: config.location?.formatted_address,
|
|
155
|
+
lgl: config.location?.geolocation,
|
|
156
|
+
lci: config.location?.city,
|
|
157
|
+
lco: config.location?.country,
|
|
158
|
+
lpc: config.location?.postal_code,
|
|
159
|
+
lsa: config.location?.state,
|
|
160
|
+
lst: config.location?.street_1,
|
|
161
|
+
sco: config.searchCountry ?? config.search?.country,
|
|
162
|
+
flo: config.flow,
|
|
163
|
+
});
|
|
164
|
+
return configuration;
|
|
165
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { PluginConfiguration } from "../../src/configuration/index.ts";
|
|
2
|
+
import type { LegacyPluginHashConfiguration } from "./LegacyParser.ts";
|
|
3
|
+
import { type JSConfig } from "./ModernParser.ts";
|
|
4
|
+
export declare function legacyHashToPluginInputConfiguration(
|
|
5
|
+
config: LegacyPluginHashConfiguration,
|
|
6
|
+
): PluginConfiguration;
|
|
7
|
+
export declare function logDeprecationWarnings(params: CreateMigrationInstructions): void;
|
|
8
|
+
interface CreateMigrationInstructions {
|
|
9
|
+
dom: LegacyPluginHashConfiguration | null;
|
|
10
|
+
js: LegacyPluginHashConfiguration | null;
|
|
11
|
+
hash: LegacyPluginHashConfiguration | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function createMigrationInstructions({
|
|
14
|
+
dom,
|
|
15
|
+
hash,
|
|
16
|
+
js,
|
|
17
|
+
}: CreateMigrationInstructions): {
|
|
18
|
+
dom: {
|
|
19
|
+
unsupported:
|
|
20
|
+
| ("lgl" | "lci" | "lco" | "lpc" | "lsa" | "lst")[]
|
|
21
|
+
| (
|
|
22
|
+
| "location.geolocation"
|
|
23
|
+
| "location.city"
|
|
24
|
+
| "location.country"
|
|
25
|
+
| "location.postal_code"
|
|
26
|
+
| "location.state"
|
|
27
|
+
| "location.street_1"
|
|
28
|
+
)[]
|
|
29
|
+
| (
|
|
30
|
+
| "skedify:location.geolocation"
|
|
31
|
+
| "skedify:location.city"
|
|
32
|
+
| "skedify:location.country"
|
|
33
|
+
| "skedify:location.postal_code"
|
|
34
|
+
| "skedify:location.state"
|
|
35
|
+
| "skedify:location.street_1"
|
|
36
|
+
)[]
|
|
37
|
+
| null;
|
|
38
|
+
migration: any[] | null;
|
|
39
|
+
} | null;
|
|
40
|
+
hash: {
|
|
41
|
+
migration: string;
|
|
42
|
+
unsupported:
|
|
43
|
+
| ("lgl" | "lci" | "lco" | "lpc" | "lsa" | "lst")[]
|
|
44
|
+
| (
|
|
45
|
+
| "location.geolocation"
|
|
46
|
+
| "location.city"
|
|
47
|
+
| "location.country"
|
|
48
|
+
| "location.postal_code"
|
|
49
|
+
| "location.state"
|
|
50
|
+
| "location.street_1"
|
|
51
|
+
)[]
|
|
52
|
+
| (
|
|
53
|
+
| "skedify:location.geolocation"
|
|
54
|
+
| "skedify:location.city"
|
|
55
|
+
| "skedify:location.country"
|
|
56
|
+
| "skedify:location.postal_code"
|
|
57
|
+
| "skedify:location.state"
|
|
58
|
+
| "skedify:location.street_1"
|
|
59
|
+
)[]
|
|
60
|
+
| null;
|
|
61
|
+
} | null;
|
|
62
|
+
js: {
|
|
63
|
+
unsupported:
|
|
64
|
+
| ("lgl" | "lci" | "lco" | "lpc" | "lsa" | "lst")[]
|
|
65
|
+
| (
|
|
66
|
+
| "location.geolocation"
|
|
67
|
+
| "location.city"
|
|
68
|
+
| "location.country"
|
|
69
|
+
| "location.postal_code"
|
|
70
|
+
| "location.state"
|
|
71
|
+
| "location.street_1"
|
|
72
|
+
)[]
|
|
73
|
+
| (
|
|
74
|
+
| "skedify:location.geolocation"
|
|
75
|
+
| "skedify:location.city"
|
|
76
|
+
| "skedify:location.country"
|
|
77
|
+
| "skedify:location.postal_code"
|
|
78
|
+
| "skedify:location.state"
|
|
79
|
+
| "skedify:location.street_1"
|
|
80
|
+
)[]
|
|
81
|
+
| null;
|
|
82
|
+
migration: JSConfig;
|
|
83
|
+
} | null;
|
|
84
|
+
};
|
|
85
|
+
export declare function insertMeetingTypeStepInFlow(flow?: string): string | undefined;
|
|
86
|
+
export declare function transformDeprecatedTokens(flow?: string): string | undefined;
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=LegacyParser.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegacyParser.utils.d.ts","sourceRoot":"","sources":["../../src/configuration-parser/LegacyParser.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAIrE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAmC,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGnF,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,6BAA6B,GACpC,mBAAmB,CAkDrB;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,2BAA2B,QA2CzE;AAED,UAAU,2BAA2B;IACnC,GAAG,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC1C,EAAE,EAAE,6BAA6B,GAAG,IAAI,CAAC;IACzC,IAAI,EAAE,6BAA6B,GAAG,IAAI,CAAC;CAC5C;AAED,wBAAgB,2BAA2B,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,2BAA2B;;;;;;;;;;;;;EAMzF;AAuJD,wBAAgB,2BAA2B,CAAC,IAAI,CAAC,EAAE,MAAM,sBA2BxD;AAED,wBAAgB,yBAAyB,CAAC,IAAI,CAAC,EAAE,MAAM,sBAatD"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { DEPRECATED_TOKEN, TOKEN } from "../constants.js";
|
|
2
|
+
import { logger } from "../logger.js";
|
|
3
|
+
import { ATTR_PREFIX, encodeConfigAsHash } from "./ModernParser.js";
|
|
4
|
+
import { sanitize } from "./utils.js";
|
|
5
|
+
export function legacyHashToPluginInputConfiguration(config) {
|
|
6
|
+
return sanitize({
|
|
7
|
+
flow: transformDeprecatedTokens(insertMeetingTypeStepInFlow(config.flo)),
|
|
8
|
+
intent: config.act,
|
|
9
|
+
"subject-ids": config.sub ?? config.esb,
|
|
10
|
+
"subject-type": config.sub ? "id" : config.esb ? "externalId" : undefined,
|
|
11
|
+
"office-ids": config.off ?? config.eof,
|
|
12
|
+
"office-type": config.off ? "id" : config.eof ? "externalId" : undefined,
|
|
13
|
+
"listing-id": config.lis ?? config.eli,
|
|
14
|
+
"listing-type": config.lis ? "id" : config.eli ? "externalId" : undefined,
|
|
15
|
+
"employee-ids": config.con ?? config.eco,
|
|
16
|
+
"employee-type": config.con ? "id" : config.eco ? "externalId" : undefined,
|
|
17
|
+
"lead_segment-id": config.lsc,
|
|
18
|
+
"lead_segment-type": config.lsc ? "code" : undefined,
|
|
19
|
+
"oauth-resource_code": config.rco,
|
|
20
|
+
"session-status": config.cas,
|
|
21
|
+
"session-id": config.sid,
|
|
22
|
+
"session-source_tags": config.sst,
|
|
23
|
+
"customer-company": config.ccom,
|
|
24
|
+
"customer-customer_number": config.ccn,
|
|
25
|
+
"customer-date_of_birth": config.cdob,
|
|
26
|
+
"customer-email": config.cem,
|
|
27
|
+
"customer-external_id": config.ceid,
|
|
28
|
+
"customer-first_name": config.cfn,
|
|
29
|
+
"customer-gender": config.cgr,
|
|
30
|
+
"customer-id": config.cid,
|
|
31
|
+
"customer-is_existing": config.cie,
|
|
32
|
+
"customer-language": config.clng,
|
|
33
|
+
"customer-last_name": config.cln,
|
|
34
|
+
"customer-location-city": config.cci,
|
|
35
|
+
"customer-location-country": config.cco,
|
|
36
|
+
"customer-location-geolocation": config.cgl,
|
|
37
|
+
"customer-location-postal_code": config.cpc,
|
|
38
|
+
"customer-location-state": config.csa,
|
|
39
|
+
"customer-location-street_1": config.cst,
|
|
40
|
+
"customer-phone_number": config.cpn,
|
|
41
|
+
"customer-preferred_contact_id": config.cpci,
|
|
42
|
+
"customer-preferred_office_id": config.cpoi,
|
|
43
|
+
"customer-timezone": config.ctz,
|
|
44
|
+
language: config.lng,
|
|
45
|
+
meeting_types: config.mty,
|
|
46
|
+
"application-scroll":
|
|
47
|
+
config.scr === "disable_initial_scroll_on_schedule" ? "disabled" : undefined,
|
|
48
|
+
"application-timezone_selection": config.ets,
|
|
49
|
+
"application-theme": undefined,
|
|
50
|
+
"location-initial_search": config.lfa,
|
|
51
|
+
search_countries: config.sco,
|
|
52
|
+
source_href: undefined,
|
|
53
|
+
"browser-timezone": undefined,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function logDeprecationWarnings(params) {
|
|
57
|
+
const { dom, hash, js } = createMigrationInstructions(params);
|
|
58
|
+
if (dom || hash || js) {
|
|
59
|
+
logger.group("DEPRECATED CONFIGURATION");
|
|
60
|
+
if (dom) {
|
|
61
|
+
const { migration, unsupported } = dom;
|
|
62
|
+
if (unsupported) {
|
|
63
|
+
logger.warn(`DOM: Following keys are not supported anymore:\n${unsupported.join(", ")}`);
|
|
64
|
+
}
|
|
65
|
+
if (migration) {
|
|
66
|
+
logger.warn(
|
|
67
|
+
"Detected unsupported DOM config. Please update your DOM element to:\n%o",
|
|
68
|
+
`<div class="pexip-engage-plugin" ${migration.join(" ")}></div>`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (hash) {
|
|
73
|
+
const { migration, unsupported } = hash;
|
|
74
|
+
if (unsupported) {
|
|
75
|
+
logger.warn(`Hash: Following keys are not supported anymore:\n${unsupported.join(", ")}`);
|
|
76
|
+
}
|
|
77
|
+
logger.warn("Detected deprecated hash config. Please update your hash to:\n%o", migration);
|
|
78
|
+
}
|
|
79
|
+
if (js) {
|
|
80
|
+
const { migration, unsupported } = js;
|
|
81
|
+
if (unsupported) {
|
|
82
|
+
logger.warn(`JS: Following keys are not supported anymore:\n${unsupported.join(", ")}`);
|
|
83
|
+
}
|
|
84
|
+
logger.warn(
|
|
85
|
+
"Detected deprecated JS config. Please update your JS to:\n%o",
|
|
86
|
+
`PexipEngage.Plugin(element, ${JSON.stringify(migration)})`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
logger.groupEnd();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export function createMigrationInstructions({ dom, hash, js }) {
|
|
93
|
+
return {
|
|
94
|
+
dom: dom && createDOMParamWarnings(dom),
|
|
95
|
+
hash: hash && createHashParamWarnings(hash),
|
|
96
|
+
js: js && createJSParamWarning(js),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function createDOMParamWarnings(hashConfig) {
|
|
100
|
+
if (Object.keys(hashConfig).length === 0) return null;
|
|
101
|
+
const unsupported = getUnsupportedKeys(hashConfig, "html");
|
|
102
|
+
const config = legacyHashToPluginInputConfiguration(hashConfig);
|
|
103
|
+
const migrations = Object.entries(config)
|
|
104
|
+
.map(([key, value]) => value && `${ATTR_PREFIX}${key}="${value}"`)
|
|
105
|
+
.filter(Boolean);
|
|
106
|
+
const migration = migrations.length === 0 ? null : migrations;
|
|
107
|
+
if (!unsupported && !migration) return null;
|
|
108
|
+
return { unsupported, migration };
|
|
109
|
+
}
|
|
110
|
+
function createHashParamWarnings(hashConfig) {
|
|
111
|
+
if (Object.keys(hashConfig).length === 0) return null;
|
|
112
|
+
const unsupported = getUnsupportedKeys(hashConfig, "hash");
|
|
113
|
+
const config = legacyHashToPluginInputConfiguration(hashConfig);
|
|
114
|
+
const modernHash = encodeConfigAsHash(config);
|
|
115
|
+
return { migration: modernHash, unsupported };
|
|
116
|
+
}
|
|
117
|
+
function createJSParamWarning(hashConfig) {
|
|
118
|
+
if (Object.keys(hashConfig).length === 0) return null;
|
|
119
|
+
const unsupported = getUnsupportedKeys(hashConfig, "js");
|
|
120
|
+
const config = legacyHashToPluginInputConfiguration(hashConfig);
|
|
121
|
+
const jsConfig = sanitize({
|
|
122
|
+
config: {
|
|
123
|
+
flow: config.flow,
|
|
124
|
+
intent: config.intent,
|
|
125
|
+
language: config.language,
|
|
126
|
+
employee: {
|
|
127
|
+
ids: config["employee-ids"],
|
|
128
|
+
type: config["employee-type"],
|
|
129
|
+
},
|
|
130
|
+
application: {
|
|
131
|
+
scroll: config["application-scroll"],
|
|
132
|
+
timezoneSelection: config["application-timezone_selection"],
|
|
133
|
+
theme: config["application-theme"],
|
|
134
|
+
},
|
|
135
|
+
customer: {
|
|
136
|
+
company: config["customer-company"],
|
|
137
|
+
customer_number: config["customer-customer_number"],
|
|
138
|
+
date_of_birth: config["customer-date_of_birth"],
|
|
139
|
+
email: config["customer-email"],
|
|
140
|
+
external_id: config["customer-external_id"],
|
|
141
|
+
first_name: config["customer-first_name"],
|
|
142
|
+
gender: config["customer-gender"],
|
|
143
|
+
id: config["customer-id"],
|
|
144
|
+
is_existing: config["customer-is_existing"],
|
|
145
|
+
language: config["customer-language"],
|
|
146
|
+
last_name: config["customer-last_name"],
|
|
147
|
+
location: {
|
|
148
|
+
city: config["customer-location-city"],
|
|
149
|
+
country: config["customer-location-country"],
|
|
150
|
+
geolocation: config["customer-location-geolocation"],
|
|
151
|
+
postal_code: config["customer-location-postal_code"],
|
|
152
|
+
state: config["customer-location-state"],
|
|
153
|
+
street_1: config["customer-location-street_1"],
|
|
154
|
+
},
|
|
155
|
+
phone_number: config["customer-phone_number"],
|
|
156
|
+
preferred_contact_id: config["customer-preferred_contact_id"],
|
|
157
|
+
preferred_office_id: config["customer-preferred_office_id"],
|
|
158
|
+
timezone: config["customer-timezone"],
|
|
159
|
+
},
|
|
160
|
+
leadSegment: {
|
|
161
|
+
id: config["lead_segment-id"],
|
|
162
|
+
type: config["lead_segment-type"],
|
|
163
|
+
},
|
|
164
|
+
listing: {
|
|
165
|
+
id: config["listing-id"],
|
|
166
|
+
type: config["listing-type"],
|
|
167
|
+
},
|
|
168
|
+
location: {
|
|
169
|
+
initialSearch: config["location-initial_search"],
|
|
170
|
+
},
|
|
171
|
+
meetingTypes: config["meeting_types"],
|
|
172
|
+
oauth: {
|
|
173
|
+
resourceCode: config["oauth-resource_code"],
|
|
174
|
+
},
|
|
175
|
+
office: {
|
|
176
|
+
ids: config["office-ids"],
|
|
177
|
+
type: config["office-type"],
|
|
178
|
+
},
|
|
179
|
+
searchCountries: config["search_countries"],
|
|
180
|
+
session: {
|
|
181
|
+
id: config["session-id"],
|
|
182
|
+
sourceTags: config["session-source_tags"],
|
|
183
|
+
status: config["session-status"],
|
|
184
|
+
},
|
|
185
|
+
subject: {
|
|
186
|
+
ids: config["subject-ids"],
|
|
187
|
+
type: config["subject-type"],
|
|
188
|
+
},
|
|
189
|
+
timetable: {},
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
unsupported,
|
|
194
|
+
migration: jsConfig,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const UNSUPPORTED_HASH_KEY_TO_JS = {
|
|
198
|
+
lgl: "location.geolocation",
|
|
199
|
+
lci: "location.city",
|
|
200
|
+
lco: "location.country",
|
|
201
|
+
lpc: "location.postal_code",
|
|
202
|
+
lsa: "location.state",
|
|
203
|
+
lst: "location.street_1",
|
|
204
|
+
};
|
|
205
|
+
const UNSUPPORTED_HASH_KEY_TO_HTML = {
|
|
206
|
+
lgl: "skedify:location.geolocation",
|
|
207
|
+
lci: "skedify:location.city",
|
|
208
|
+
lco: "skedify:location.country",
|
|
209
|
+
lpc: "skedify:location.postal_code",
|
|
210
|
+
lsa: "skedify:location.state",
|
|
211
|
+
lst: "skedify:location.street_1",
|
|
212
|
+
};
|
|
213
|
+
const UNSUPPORTED_KEYS = ["lgl", "lci", "lco", "lpc", "lsa", "lst"];
|
|
214
|
+
function getUnsupportedKeys(hashConfig, type) {
|
|
215
|
+
const unsupported = Object.keys(hashConfig).filter((key) => UNSUPPORTED_KEYS.includes(key));
|
|
216
|
+
if (unsupported.length === 0) return null;
|
|
217
|
+
if (type === "hash") return unsupported;
|
|
218
|
+
if (type === "js") return unsupported.map((hash) => UNSUPPORTED_HASH_KEY_TO_JS[hash]);
|
|
219
|
+
if (type === "html") return unsupported.map((hash) => UNSUPPORTED_HASH_KEY_TO_HTML[hash]);
|
|
220
|
+
return unsupported;
|
|
221
|
+
}
|
|
222
|
+
export function insertMeetingTypeStepInFlow(flow) {
|
|
223
|
+
if (!flow) return undefined;
|
|
224
|
+
const tokens = flow.split("");
|
|
225
|
+
const MEETING_TYPE_IDX = tokens.indexOf(TOKEN.MEETING_TYPE);
|
|
226
|
+
if (MEETING_TYPE_IDX !== -1) return flow;
|
|
227
|
+
function getIndexToInsert(tokenIndex) {
|
|
228
|
+
const previousTokenIndex = tokenIndex - 1;
|
|
229
|
+
const isLocked = tokens[previousTokenIndex] === DEPRECATED_TOKEN.LOCK;
|
|
230
|
+
// We should insert M before the lock token.
|
|
231
|
+
return isLocked ? previousTokenIndex : tokenIndex;
|
|
232
|
+
}
|
|
233
|
+
// MeetingType is a separate required step, so inject it before Office or Subject
|
|
234
|
+
// when it's not present.
|
|
235
|
+
const OFFICE_IDX = tokens.indexOf(TOKEN.OFFICE);
|
|
236
|
+
const SUBJECT_IDX = tokens.indexOf(TOKEN.SUBJECT);
|
|
237
|
+
if (OFFICE_IDX !== -1) {
|
|
238
|
+
tokens.splice(getIndexToInsert(OFFICE_IDX), 0, TOKEN.MEETING_TYPE);
|
|
239
|
+
} else if (SUBJECT_IDX !== -1) {
|
|
240
|
+
tokens.splice(getIndexToInsert(SUBJECT_IDX), 0, TOKEN.MEETING_TYPE);
|
|
241
|
+
}
|
|
242
|
+
return tokens.join("");
|
|
243
|
+
}
|
|
244
|
+
export function transformDeprecatedTokens(flow) {
|
|
245
|
+
if (!flow) return undefined;
|
|
246
|
+
return flow
|
|
247
|
+
.split("")
|
|
248
|
+
.map((token) => {
|
|
249
|
+
if (token === DEPRECATED_TOKEN.LOCK) return TOKEN.LOCK;
|
|
250
|
+
if (token === DEPRECATED_TOKEN.OFFICE) return TOKEN.OFFICE;
|
|
251
|
+
if (token === DEPRECATED_TOKEN.START) return "";
|
|
252
|
+
return token;
|
|
253
|
+
})
|
|
254
|
+
.join("");
|
|
255
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { PluginConfiguration } from "../../src/configuration/index.ts";
|
|
2
|
+
interface ModernParseParams {
|
|
3
|
+
element?: HTMLElement | null;
|
|
4
|
+
hash?: string | null;
|
|
5
|
+
options?: JSConfig | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function parse({ element, hash, options }: ModernParseParams): {
|
|
8
|
+
domConfig: PluginConfiguration;
|
|
9
|
+
hashConfig: PluginConfiguration;
|
|
10
|
+
jsConfig: PluginConfiguration;
|
|
11
|
+
};
|
|
12
|
+
export declare const HASH_PREFIX = "#pexip-";
|
|
13
|
+
export declare function encodeConfigAsHash(value: PluginConfiguration): string;
|
|
14
|
+
export declare function decodeConfigHash(hash?: string | null): PluginConfiguration;
|
|
15
|
+
export declare const ATTR_PREFIX = "data-pexip-";
|
|
16
|
+
export type HTMLConfig = {
|
|
17
|
+
[key in keyof PluginConfiguration as `${typeof ATTR_PREFIX}${key}`]: Exclude<
|
|
18
|
+
PluginConfiguration[key],
|
|
19
|
+
string[] | null | boolean
|
|
20
|
+
>;
|
|
21
|
+
};
|
|
22
|
+
type StringConfig = string | null;
|
|
23
|
+
type StringArrayConfig = StringConfig | string[];
|
|
24
|
+
type BooleanConfig = StringConfig | boolean;
|
|
25
|
+
export interface JSConfig {
|
|
26
|
+
config?: {
|
|
27
|
+
flow?: StringConfig;
|
|
28
|
+
intent?: StringConfig;
|
|
29
|
+
language?: StringConfig;
|
|
30
|
+
employee?: {
|
|
31
|
+
ids?: StringArrayConfig;
|
|
32
|
+
type?: StringConfig;
|
|
33
|
+
};
|
|
34
|
+
application?: {
|
|
35
|
+
scroll?: "disabled" | number | null;
|
|
36
|
+
timezoneSelection?: StringConfig;
|
|
37
|
+
theme?: string | null;
|
|
38
|
+
};
|
|
39
|
+
customer?: {
|
|
40
|
+
company?: StringConfig;
|
|
41
|
+
customer_number?: StringConfig;
|
|
42
|
+
date_of_birth?: StringConfig;
|
|
43
|
+
email?: StringConfig;
|
|
44
|
+
external_id?: StringConfig;
|
|
45
|
+
first_name?: StringConfig;
|
|
46
|
+
gender?: StringConfig;
|
|
47
|
+
id?: StringConfig;
|
|
48
|
+
is_existing?: BooleanConfig;
|
|
49
|
+
language?: StringConfig;
|
|
50
|
+
last_name?: StringConfig;
|
|
51
|
+
location?: {
|
|
52
|
+
city?: StringConfig;
|
|
53
|
+
country?: StringConfig;
|
|
54
|
+
geolocation?: StringConfig;
|
|
55
|
+
postal_code?: StringConfig;
|
|
56
|
+
state?: StringConfig;
|
|
57
|
+
street_1?: StringConfig;
|
|
58
|
+
};
|
|
59
|
+
phone_number?: StringConfig;
|
|
60
|
+
preferred_contact_id?: StringConfig;
|
|
61
|
+
preferred_office_id?: StringConfig;
|
|
62
|
+
timezone?: StringConfig;
|
|
63
|
+
};
|
|
64
|
+
leadSegment?: {
|
|
65
|
+
id?: StringConfig;
|
|
66
|
+
type?: StringConfig;
|
|
67
|
+
};
|
|
68
|
+
listing?: {
|
|
69
|
+
id?: StringConfig;
|
|
70
|
+
type?: StringConfig;
|
|
71
|
+
};
|
|
72
|
+
location?: {
|
|
73
|
+
initialSearch?: StringConfig;
|
|
74
|
+
};
|
|
75
|
+
meetingTypes?: StringArrayConfig;
|
|
76
|
+
oauth?: {
|
|
77
|
+
resourceCode?: StringConfig;
|
|
78
|
+
};
|
|
79
|
+
office?: {
|
|
80
|
+
ids?: StringArrayConfig;
|
|
81
|
+
type?: StringConfig;
|
|
82
|
+
};
|
|
83
|
+
searchCountries?: StringArrayConfig;
|
|
84
|
+
session?: {
|
|
85
|
+
id?: StringConfig;
|
|
86
|
+
sourceTags?: StringArrayConfig;
|
|
87
|
+
status?: StringConfig;
|
|
88
|
+
};
|
|
89
|
+
subject?: {
|
|
90
|
+
ids?: StringArrayConfig;
|
|
91
|
+
type?: StringConfig;
|
|
92
|
+
};
|
|
93
|
+
timetable?: {
|
|
94
|
+
startDate?: StringConfig;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=ModernParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModernParser.d.ts","sourceRoot":"","sources":["../../src/configuration-parser/ModernParser.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { decodeURIParameters, encodeURIParameters, sanitize } from "./utils.js";
|
|
2
|
+
export function parse({ element, hash, options }) {
|
|
3
|
+
return {
|
|
4
|
+
domConfig: parseDOMParams(element),
|
|
5
|
+
hashConfig: decodeConfigHash(hash),
|
|
6
|
+
jsConfig: parseJSParams(options),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export const HASH_PREFIX = "#pexip-";
|
|
10
|
+
export function encodeConfigAsHash(value) {
|
|
11
|
+
return HASH_PREFIX + encodeURIParameters(value);
|
|
12
|
+
}
|
|
13
|
+
export function decodeConfigHash(hash) {
|
|
14
|
+
if (!hash || !hash.startsWith(HASH_PREFIX)) return {};
|
|
15
|
+
const value = hash.slice(HASH_PREFIX.length);
|
|
16
|
+
const configuration = decodeURIParameters(value);
|
|
17
|
+
return configuration;
|
|
18
|
+
}
|
|
19
|
+
export const ATTR_PREFIX = "data-pexip-";
|
|
20
|
+
function parseDOMParams(element) {
|
|
21
|
+
if (!element) return {};
|
|
22
|
+
const attributes = element.getAttributeNames().filter((name) => name.startsWith(ATTR_PREFIX));
|
|
23
|
+
const object = {};
|
|
24
|
+
for (const attribute of attributes) {
|
|
25
|
+
const key = attribute.replace(ATTR_PREFIX, "");
|
|
26
|
+
object[key] = element.getAttribute(attribute)?.trim() || undefined;
|
|
27
|
+
}
|
|
28
|
+
return sanitize(object);
|
|
29
|
+
}
|
|
30
|
+
function parseJSParams(jsConfig) {
|
|
31
|
+
if (!jsConfig?.config) return {};
|
|
32
|
+
const { config } = jsConfig;
|
|
33
|
+
return sanitize(objectToDashConfig(config));
|
|
34
|
+
}
|
|
35
|
+
function objectToDashConfig(inputObject, current, result = {}) {
|
|
36
|
+
for (let key in inputObject) {
|
|
37
|
+
let value = inputObject[key];
|
|
38
|
+
let newKey = current ? `${current}-${key}` : key;
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
result[newKey] = value;
|
|
41
|
+
} else if (value && typeof value === "object") {
|
|
42
|
+
objectToDashConfig(value, newKey, result);
|
|
43
|
+
} else {
|
|
44
|
+
result[newKey] = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PluginConfiguration } from "../../src/configuration/index.ts";
|
|
2
|
+
import { type JSConfig } from "./ModernParser.ts";
|
|
3
|
+
export declare function configToHash(config: PluginConfiguration): PluginConfiguration;
|
|
4
|
+
export declare function configToHtml(config: PluginConfiguration): string[];
|
|
5
|
+
export declare function configToJS(config: PluginConfiguration): JSConfig;
|
|
6
|
+
//# sourceMappingURL=ModernParser.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModernParser.utils.d.ts","sourceRoot":"","sources":["../../src/configuration-parser/ModernParser.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE/D,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAE7E;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAElE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,mBAAmB,GAAG,QAAQ,CAWhE"}
|