@digipair/skill-keycloak 0.45.7 → 0.48.1
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
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,40 @@ let KeycloakService = class KeycloakService {
|
|
5656
5657
|
}
|
5657
5658
|
return output;
|
5658
5659
|
}
|
5660
|
+
async pins2html(pins) {
|
5661
|
+
const dom = new jsdom.JSDOM();
|
5662
|
+
const element = dom.window.document.createElement('section');
|
5663
|
+
await this.generateElementsFromPins(pins, element, dom);
|
5664
|
+
return element.innerHTML;
|
5665
|
+
}
|
5666
|
+
async generateElementsFromPins(pinsList, parent, dom) {
|
5667
|
+
for(let i = 0; i < pinsList.length; i++){
|
5668
|
+
const item = pinsList[i];
|
5669
|
+
await this.generateElementFromPins(item, parent, dom);
|
5670
|
+
}
|
5671
|
+
}
|
5672
|
+
async generateElementFromPins(pinsSettings, parent, dom) {
|
5673
|
+
const element = dom.window.document.createElement(pinsSettings.element);
|
5674
|
+
element.setAttribute('data-ssr', '1');
|
5675
|
+
const settings = pinsSettings;
|
5676
|
+
Object.entries(settings.properties || {}).forEach(([key, value])=>{
|
5677
|
+
if (key === 'textContent') {
|
5678
|
+
element.textContent = value;
|
5679
|
+
} else if (key === 'innerHTML') {
|
5680
|
+
element.innerHTML = value;
|
5681
|
+
} else if (typeof value === 'string') {
|
5682
|
+
element.setAttribute(key, value);
|
5683
|
+
} else {
|
5684
|
+
element[key] = value;
|
5685
|
+
}
|
5686
|
+
});
|
5687
|
+
const pinsList = settings.pins || [];
|
5688
|
+
await this.generateElementsFromPins(pinsList, element, dom);
|
5689
|
+
parent.appendChild(element);
|
5690
|
+
}
|
5659
5691
|
async page(params, _pinsSettingsList, context) {
|
5660
5692
|
var _context_request_body;
|
5661
|
-
const { body,
|
5693
|
+
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
5694
|
const engineVersion = context.config.VERSIONS['@digipair/engine'] || 'latest';
|
5663
5695
|
const preparedData = {};
|
5664
5696
|
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
@@ -5687,10 +5719,12 @@ let KeycloakService = class KeycloakService {
|
|
5687
5719
|
<!DOCTYPE html>
|
5688
5720
|
<html style="${styleHtml}">
|
5689
5721
|
<head>
|
5690
|
-
|
5691
|
-
|
5692
|
-
|
5693
|
-
|
5722
|
+
${head ? await this.pins2html(head) : `
|
5723
|
+
<meta charset="UTF-8" />
|
5724
|
+
<title>Digipair</title>
|
5725
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
5726
|
+
<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">
|
5727
|
+
`}
|
5694
5728
|
</head>
|
5695
5729
|
<body style="${styleBody}">
|
5696
5730
|
<script type="module">
|
@@ -5765,6 +5799,7 @@ let KeycloakService = class KeycloakService {
|
|
5765
5799
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserInitialize', browserInitialize))}, context);
|
5766
5800
|
|
5767
5801
|
const pinsList = ${JSON.stringify(this.prepareBrowserPinsSettings('body', body))};
|
5802
|
+
document.querySelectorAll('body > [data-ssr]').forEach((element) => element.remove()); // Remove SSR elements
|
5768
5803
|
for (let i = 0; i < pinsList.length; i++) {
|
5769
5804
|
const item = pinsList[i];
|
5770
5805
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} });
|
@@ -5774,6 +5809,8 @@ let KeycloakService = class KeycloakService {
|
|
5774
5809
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserLoad', browserLoad))}, context);
|
5775
5810
|
}, 1);
|
5776
5811
|
</script>
|
5812
|
+
|
5813
|
+
${ssr ? await this.pins2html(body) : ''}
|
5777
5814
|
</body>
|
5778
5815
|
</html>
|
5779
5816
|
`;
|
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, tokens = tokens1, nextMatch = nextMatch1, {
|
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, tokens = tokens1, nextMatch = nextMatch1, "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, tokens = tokens1, nextMatch = nextMatch1, "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, tokens = tokens1, nextMatch = nextMatch1, "continue";
|
23953
23954
|
}
|
23954
|
-
return
|
23955
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
|
23955
23956
|
v: nextMatch1
|
23956
23957
|
};
|
23957
23958
|
};
|
@@ -33588,9 +33589,40 @@ let KeycloakService = class KeycloakService {
|
|
33588
33589
|
}
|
33589
33590
|
return output;
|
33590
33591
|
}
|
33592
|
+
async pins2html(pins) {
|
33593
|
+
const dom = new JSDOM();
|
33594
|
+
const element = dom.window.document.createElement('section');
|
33595
|
+
await this.generateElementsFromPins(pins, element, dom);
|
33596
|
+
return element.innerHTML;
|
33597
|
+
}
|
33598
|
+
async generateElementsFromPins(pinsList, parent, dom) {
|
33599
|
+
for(let i = 0; i < pinsList.length; i++){
|
33600
|
+
const item = pinsList[i];
|
33601
|
+
await this.generateElementFromPins(item, parent, dom);
|
33602
|
+
}
|
33603
|
+
}
|
33604
|
+
async generateElementFromPins(pinsSettings, parent, dom) {
|
33605
|
+
const element = dom.window.document.createElement(pinsSettings.element);
|
33606
|
+
element.setAttribute('data-ssr', '1');
|
33607
|
+
const settings = pinsSettings;
|
33608
|
+
Object.entries(settings.properties || {}).forEach(([key, value])=>{
|
33609
|
+
if (key === 'textContent') {
|
33610
|
+
element.textContent = value;
|
33611
|
+
} else if (key === 'innerHTML') {
|
33612
|
+
element.innerHTML = value;
|
33613
|
+
} else if (typeof value === 'string') {
|
33614
|
+
element.setAttribute(key, value);
|
33615
|
+
} else {
|
33616
|
+
element[key] = value;
|
33617
|
+
}
|
33618
|
+
});
|
33619
|
+
const pinsList = settings.pins || [];
|
33620
|
+
await this.generateElementsFromPins(pinsList, element, dom);
|
33621
|
+
parent.appendChild(element);
|
33622
|
+
}
|
33591
33623
|
async page(params, _pinsSettingsList, context) {
|
33592
33624
|
var _context_request_body;
|
33593
|
-
const { body,
|
33625
|
+
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
33626
|
const engineVersion = context.config.VERSIONS['@digipair/engine'] || 'latest';
|
33595
33627
|
const preparedData = {};
|
33596
33628
|
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
@@ -33619,10 +33651,12 @@ let KeycloakService = class KeycloakService {
|
|
33619
33651
|
<!DOCTYPE html>
|
33620
33652
|
<html style="${styleHtml}">
|
33621
33653
|
<head>
|
33622
|
-
|
33623
|
-
|
33624
|
-
|
33625
|
-
|
33654
|
+
${head ? await this.pins2html(head) : `
|
33655
|
+
<meta charset="UTF-8" />
|
33656
|
+
<title>Digipair</title>
|
33657
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
33658
|
+
<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">
|
33659
|
+
`}
|
33626
33660
|
</head>
|
33627
33661
|
<body style="${styleBody}">
|
33628
33662
|
<script type="module">
|
@@ -33697,6 +33731,7 @@ let KeycloakService = class KeycloakService {
|
|
33697
33731
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserInitialize', browserInitialize))}, context);
|
33698
33732
|
|
33699
33733
|
const pinsList = ${JSON.stringify(this.prepareBrowserPinsSettings('body', body))};
|
33734
|
+
document.querySelectorAll('body > [data-ssr]').forEach((element) => element.remove()); // Remove SSR elements
|
33700
33735
|
for (let i = 0; i < pinsList.length; i++) {
|
33701
33736
|
const item = pinsList[i];
|
33702
33737
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} });
|
@@ -33706,6 +33741,8 @@ let KeycloakService = class KeycloakService {
|
|
33706
33741
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserLoad', browserLoad))}, context);
|
33707
33742
|
}, 1);
|
33708
33743
|
</script>
|
33744
|
+
|
33745
|
+
${ssr ? await this.pins2html(body) : ''}
|
33709
33746
|
</body>
|
33710
33747
|
</html>
|
33711
33748
|
`;
|
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
|
{
|
File without changes
|
File without changes
|