@digipair/skill-keycloak 0.45.7 → 0.48.3
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/index.cjs.js +31 -5
- package/index.esm.js +104 -10
- package/package.json +1 -1
- package/schema.fr.json +11 -8
- package/schema.json +11 -8
package/index.cjs.js
CHANGED
@@ -7,6 +7,7 @@ var require$$0 = require('buffer');
|
|
7
7
|
var require$$3 = require('stream');
|
8
8
|
var require$$5 = require('util');
|
9
9
|
var require$$2 = require('crypto');
|
10
|
+
var jsdom = require('jsdom');
|
10
11
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
12
13
|
|
@@ -5656,9 +5657,29 @@ let KeycloakService = class KeycloakService {
|
|
5656
5657
|
}
|
5657
5658
|
return output;
|
5658
5659
|
}
|
5660
|
+
async pins2html(pins, context) {
|
5661
|
+
const dom = new jsdom.JSDOM();
|
5662
|
+
const element = dom.window.document.createElement('section');
|
5663
|
+
await this.generateElementsFromPins(pins, element, {
|
5664
|
+
config: {
|
5665
|
+
VERSIONS: context.config.VERSIONS || {}
|
5666
|
+
},
|
5667
|
+
variables: context.variables || {},
|
5668
|
+
request: context.request || {}
|
5669
|
+
}, dom.window.document);
|
5670
|
+
return element.innerHTML;
|
5671
|
+
}
|
5672
|
+
async generateElementsFromPins(pinsList, parent, context, document) {
|
5673
|
+
for(let i = 0; i < pinsList.length; i++){
|
5674
|
+
const item = pinsList[i];
|
5675
|
+
await engine.generateElementFromPins(item, parent, context, document, {
|
5676
|
+
import: false
|
5677
|
+
});
|
5678
|
+
}
|
5679
|
+
}
|
5659
5680
|
async page(params, _pinsSettingsList, context) {
|
5660
5681
|
var _context_request_body;
|
5661
|
-
const { body,
|
5682
|
+
const { body, head, ssr = false, styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM, clientId = context.privates.KEYCLOAK_CLIENTID, factoryInitialize = [], browserInitialize = [], browserLoad = [], logged = [], unlogged = [], factoryUrl = context.privates.FACTORY_URL || process.env['FACTORY_URL'] || 'https://factory.digipair.ai' } = params;
|
5662
5683
|
const engineVersion = context.config.VERSIONS['@digipair/engine'] || 'latest';
|
5663
5684
|
const preparedData = {};
|
5664
5685
|
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
@@ -5687,10 +5708,12 @@ let KeycloakService = class KeycloakService {
|
|
5687
5708
|
<!DOCTYPE html>
|
5688
5709
|
<html style="${styleHtml}">
|
5689
5710
|
<head>
|
5690
|
-
|
5691
|
-
|
5692
|
-
|
5693
|
-
|
5711
|
+
${head ? await this.pins2html(head, context) : `
|
5712
|
+
<meta charset="UTF-8" />
|
5713
|
+
<title>Digipair</title>
|
5714
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
5715
|
+
<link rel="icon" type="image/x-icon" href="https://res.cloudinary.com/do87nxq3l/image/upload/fl_preserve_transparency/v1717769492/logo-digipair_oyvvxz.png?_s=public-apps">
|
5716
|
+
`}
|
5694
5717
|
</head>
|
5695
5718
|
<body style="${styleBody}">
|
5696
5719
|
<script type="module">
|
@@ -5765,6 +5788,7 @@ let KeycloakService = class KeycloakService {
|
|
5765
5788
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserInitialize', browserInitialize))}, context);
|
5766
5789
|
|
5767
5790
|
const pinsList = ${JSON.stringify(this.prepareBrowserPinsSettings('body', body))};
|
5791
|
+
document.querySelectorAll('body > [data-digipair-pins]').forEach((element) => element.remove()); // Remove SSR elements
|
5768
5792
|
for (let i = 0; i < pinsList.length; i++) {
|
5769
5793
|
const item = pinsList[i];
|
5770
5794
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} });
|
@@ -5774,6 +5798,8 @@ let KeycloakService = class KeycloakService {
|
|
5774
5798
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserLoad', browserLoad))}, context);
|
5775
5799
|
}, 1);
|
5776
5800
|
</script>
|
5801
|
+
|
5802
|
+
${ssr ? await this.pins2html(body, context) : ''}
|
5777
5803
|
</body>
|
5778
5804
|
</html>
|
5779
5805
|
`;
|
package/index.esm.js
CHANGED
@@ -2,6 +2,7 @@ import require$$0 from 'buffer';
|
|
2
2
|
import require$$3 from 'stream';
|
3
3
|
import require$$5 from 'util';
|
4
4
|
import require$$2 from 'crypto';
|
5
|
+
import { JSDOM } from 'jsdom';
|
5
6
|
|
6
7
|
function _extends() {
|
7
8
|
_extends = Object.assign || function assign(target) {
|
@@ -23904,14 +23905,14 @@ function indent(str, spaces) {
|
|
23904
23905
|
var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
|
23905
23906
|
// match is required
|
23906
23907
|
if (!match) {
|
23907
|
-
return
|
23908
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
|
23908
23909
|
v: nextMatch1
|
23909
23910
|
};
|
23910
23911
|
}
|
23911
23912
|
var token = match.token, offset = match.offset;
|
23912
23913
|
i1 += offset;
|
23913
23914
|
if (token === " ") {
|
23914
|
-
return
|
23915
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
|
23915
23916
|
}
|
23916
23917
|
tokens1 = _to_consumable_array$3(tokens1).concat([
|
23917
23918
|
token
|
@@ -23930,7 +23931,7 @@ function indent(str, spaces) {
|
|
23930
23931
|
if (contextKeys.some(function(el) {
|
23931
23932
|
return el.startsWith(name);
|
23932
23933
|
})) {
|
23933
|
-
return
|
23934
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
|
23934
23935
|
}
|
23935
23936
|
if (dateTimeIdentifiers.some(function(el) {
|
23936
23937
|
return el === name;
|
@@ -23949,9 +23950,9 @@ function indent(str, spaces) {
|
|
23949
23950
|
if (dateTimeIdentifiers.some(function(el) {
|
23950
23951
|
return el.startsWith(name);
|
23951
23952
|
})) {
|
23952
|
-
return
|
23953
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
|
23953
23954
|
}
|
23954
|
-
return
|
23955
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
|
23955
23956
|
v: nextMatch1
|
23956
23957
|
};
|
23957
23958
|
};
|
@@ -27939,6 +27940,74 @@ const executePinsList = async (pinsSettingsList, context)=>{
|
|
27939
27940
|
}
|
27940
27941
|
return previous;
|
27941
27942
|
};
|
27943
|
+
const generateElementFromPins = async (pinsSettings, parent, context, document = typeof window !== 'undefined' ? window.document : global.document, options = {
|
27944
|
+
import: true
|
27945
|
+
})=>{
|
27946
|
+
var _settings_conditions, _settings_conditions1;
|
27947
|
+
let settings = await preparePinsSettings(pinsSettings, context);
|
27948
|
+
const alias = _config.ALIAS.find((alias)=>settings.library.split(':')[0] === alias.name);
|
27949
|
+
if (alias) {
|
27950
|
+
settings = await preparePinsSettings(_extends({}, settings, alias), {
|
27951
|
+
settings
|
27952
|
+
});
|
27953
|
+
}
|
27954
|
+
if ((_settings_conditions = settings.conditions) == null ? void 0 : _settings_conditions.each) {
|
27955
|
+
for(let index = 0; index < settings.conditions.each.length; index++){
|
27956
|
+
const item = settings.conditions.each[index];
|
27957
|
+
await generateElementFromPins(_extends({}, pinsSettings, {
|
27958
|
+
conditions: _extends({}, pinsSettings.conditions, {
|
27959
|
+
each: undefined
|
27960
|
+
})
|
27961
|
+
}), parent, _extends({}, context, {
|
27962
|
+
item,
|
27963
|
+
index,
|
27964
|
+
parent: {
|
27965
|
+
item: context.item,
|
27966
|
+
index: context.index,
|
27967
|
+
parent: context.parent
|
27968
|
+
}
|
27969
|
+
}), document, options);
|
27970
|
+
}
|
27971
|
+
return;
|
27972
|
+
}
|
27973
|
+
if (typeof ((_settings_conditions1 = settings.conditions) == null ? void 0 : _settings_conditions1.if) !== 'undefined' && !settings.conditions.if) {
|
27974
|
+
return;
|
27975
|
+
}
|
27976
|
+
const element = document.createElement(pinsSettings.element);
|
27977
|
+
element.setAttribute('data-digipair-pins', '');
|
27978
|
+
const library = pinsSettings.library;
|
27979
|
+
if (options.import && library !== 'web' && !_config.LIBRARIES[library]) {
|
27980
|
+
const config = context.config || {};
|
27981
|
+
const version = (config.VERSIONS || {})[library] || 'latest';
|
27982
|
+
import(isRemoteVersion.test(version) ? `${version}` : `${_config.BASE_URL}/${library}@${version}/index.esm.js`);
|
27983
|
+
}
|
27984
|
+
Object.entries(settings.properties || {}).forEach(([key, value])=>{
|
27985
|
+
if (key === 'textContent') {
|
27986
|
+
element.textContent = value;
|
27987
|
+
} else if (key === 'innerHTML') {
|
27988
|
+
element.innerHTML = value;
|
27989
|
+
} else if (typeof value === 'string') {
|
27990
|
+
element.setAttribute(key, value);
|
27991
|
+
} else {
|
27992
|
+
element[key] = value;
|
27993
|
+
}
|
27994
|
+
});
|
27995
|
+
Object.entries(settings.events || {}).forEach(([key, pinsList])=>{
|
27996
|
+
element.addEventListener(key, (_event)=>{
|
27997
|
+
const event = _event;
|
27998
|
+
executePinsList(pinsList, _extends({}, context, {
|
27999
|
+
event: event.detail
|
28000
|
+
}));
|
28001
|
+
});
|
28002
|
+
});
|
28003
|
+
const pinsList = settings.pins || [];
|
28004
|
+
for(let i = 0; i < pinsList.length; i++){
|
28005
|
+
const item = pinsList[i];
|
28006
|
+
await generateElementFromPins(item, element, context, document, options);
|
28007
|
+
}
|
28008
|
+
parent == null ? void 0 : parent.appendChild(element);
|
28009
|
+
return element;
|
28010
|
+
};
|
27942
28011
|
const preparePinsSettings = async (settings, context)=>{
|
27943
28012
|
const localContext = _extends({}, context, {
|
27944
28013
|
variables: context.variables || {},
|
@@ -33588,9 +33657,29 @@ let KeycloakService = class KeycloakService {
|
|
33588
33657
|
}
|
33589
33658
|
return output;
|
33590
33659
|
}
|
33660
|
+
async pins2html(pins, context) {
|
33661
|
+
const dom = new JSDOM();
|
33662
|
+
const element = dom.window.document.createElement('section');
|
33663
|
+
await this.generateElementsFromPins(pins, element, {
|
33664
|
+
config: {
|
33665
|
+
VERSIONS: context.config.VERSIONS || {}
|
33666
|
+
},
|
33667
|
+
variables: context.variables || {},
|
33668
|
+
request: context.request || {}
|
33669
|
+
}, dom.window.document);
|
33670
|
+
return element.innerHTML;
|
33671
|
+
}
|
33672
|
+
async generateElementsFromPins(pinsList, parent, context, document) {
|
33673
|
+
for(let i = 0; i < pinsList.length; i++){
|
33674
|
+
const item = pinsList[i];
|
33675
|
+
await generateElementFromPins(item, parent, context, document, {
|
33676
|
+
import: false
|
33677
|
+
});
|
33678
|
+
}
|
33679
|
+
}
|
33591
33680
|
async page(params, _pinsSettingsList, context) {
|
33592
33681
|
var _context_request_body;
|
33593
|
-
const { body,
|
33682
|
+
const { body, head, ssr = false, styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM, clientId = context.privates.KEYCLOAK_CLIENTID, factoryInitialize = [], browserInitialize = [], browserLoad = [], logged = [], unlogged = [], factoryUrl = context.privates.FACTORY_URL || process.env['FACTORY_URL'] || 'https://factory.digipair.ai' } = params;
|
33594
33683
|
const engineVersion = context.config.VERSIONS['@digipair/engine'] || 'latest';
|
33595
33684
|
const preparedData = {};
|
33596
33685
|
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
@@ -33619,10 +33708,12 @@ let KeycloakService = class KeycloakService {
|
|
33619
33708
|
<!DOCTYPE html>
|
33620
33709
|
<html style="${styleHtml}">
|
33621
33710
|
<head>
|
33622
|
-
|
33623
|
-
|
33624
|
-
|
33625
|
-
|
33711
|
+
${head ? await this.pins2html(head, context) : `
|
33712
|
+
<meta charset="UTF-8" />
|
33713
|
+
<title>Digipair</title>
|
33714
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
33715
|
+
<link rel="icon" type="image/x-icon" href="https://res.cloudinary.com/do87nxq3l/image/upload/fl_preserve_transparency/v1717769492/logo-digipair_oyvvxz.png?_s=public-apps">
|
33716
|
+
`}
|
33626
33717
|
</head>
|
33627
33718
|
<body style="${styleBody}">
|
33628
33719
|
<script type="module">
|
@@ -33697,6 +33788,7 @@ let KeycloakService = class KeycloakService {
|
|
33697
33788
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserInitialize', browserInitialize))}, context);
|
33698
33789
|
|
33699
33790
|
const pinsList = ${JSON.stringify(this.prepareBrowserPinsSettings('body', body))};
|
33791
|
+
document.querySelectorAll('body > [data-digipair-pins]').forEach((element) => element.remove()); // Remove SSR elements
|
33700
33792
|
for (let i = 0; i < pinsList.length; i++) {
|
33701
33793
|
const item = pinsList[i];
|
33702
33794
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} });
|
@@ -33706,6 +33798,8 @@ let KeycloakService = class KeycloakService {
|
|
33706
33798
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserLoad', browserLoad))}, context);
|
33707
33799
|
}, 1);
|
33708
33800
|
</script>
|
33801
|
+
|
33802
|
+
${ssr ? await this.pins2html(body, context) : ''}
|
33709
33803
|
</body>
|
33710
33804
|
</html>
|
33711
33805
|
`;
|
package/package.json
CHANGED
package/schema.fr.json
CHANGED
@@ -127,21 +127,24 @@
|
|
127
127
|
}
|
128
128
|
},
|
129
129
|
{
|
130
|
-
"name": "
|
131
|
-
"summary": "
|
130
|
+
"name": "head",
|
131
|
+
"summary": "En tête",
|
132
132
|
"required": false,
|
133
|
-
"description": "
|
133
|
+
"description": "En tête de la page",
|
134
134
|
"schema": {
|
135
|
-
"type": "
|
135
|
+
"type": "array",
|
136
|
+
"items": {
|
137
|
+
"$ref": "https://schemas.digipair.ai/pinsSettings"
|
138
|
+
}
|
136
139
|
}
|
137
140
|
},
|
138
141
|
{
|
139
|
-
"name": "
|
140
|
-
"summary": "
|
142
|
+
"name": "ssr",
|
143
|
+
"summary": "Rendu coté serveur",
|
141
144
|
"required": false,
|
142
|
-
"description": "
|
145
|
+
"description": "Rendu coté serveur",
|
143
146
|
"schema": {
|
144
|
-
"type": "
|
147
|
+
"type": "boolean"
|
145
148
|
}
|
146
149
|
},
|
147
150
|
{
|
package/schema.json
CHANGED
@@ -127,21 +127,24 @@
|
|
127
127
|
}
|
128
128
|
},
|
129
129
|
{
|
130
|
-
"name": "
|
131
|
-
"summary": "
|
130
|
+
"name": "head",
|
131
|
+
"summary": "Header",
|
132
132
|
"required": false,
|
133
|
-
"description": "
|
133
|
+
"description": "Header of the page",
|
134
134
|
"schema": {
|
135
|
-
"type": "
|
135
|
+
"type": "array",
|
136
|
+
"items": {
|
137
|
+
"$ref": "https://schemas.digipair.ai/pinsSettings"
|
138
|
+
}
|
136
139
|
}
|
137
140
|
},
|
138
141
|
{
|
139
|
-
"name": "
|
140
|
-
"summary": "
|
142
|
+
"name": "ssr",
|
143
|
+
"summary": "Server Side Rendering",
|
141
144
|
"required": false,
|
142
|
-
"description": "
|
145
|
+
"description": "Server Side Rendering",
|
143
146
|
"schema": {
|
144
|
-
"type": "
|
147
|
+
"type": "boolean"
|
145
148
|
}
|
146
149
|
},
|
147
150
|
{
|