@digipair/skill-web 0.4.30 → 0.5.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 +61 -7
- package/index.esm.js +61 -7
- package/package.json +1 -1
- package/schema.json +25 -2
package/index.cjs.js
CHANGED
|
@@ -23510,14 +23510,14 @@ function indent(str, spaces) {
|
|
|
23510
23510
|
var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
|
|
23511
23511
|
// match is required
|
|
23512
23512
|
if (!match) {
|
|
23513
|
-
return
|
|
23513
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
|
|
23514
23514
|
v: nextMatch1
|
|
23515
23515
|
};
|
|
23516
23516
|
}
|
|
23517
23517
|
var token = match.token, offset = match.offset;
|
|
23518
23518
|
i1 += offset;
|
|
23519
23519
|
if (token === " ") {
|
|
23520
|
-
return
|
|
23520
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
|
|
23521
23521
|
}
|
|
23522
23522
|
tokens1 = _to_consumable_array$1(tokens1).concat([
|
|
23523
23523
|
token
|
|
@@ -23536,7 +23536,7 @@ function indent(str, spaces) {
|
|
|
23536
23536
|
if (contextKeys.some(function(el) {
|
|
23537
23537
|
return el.startsWith(name);
|
|
23538
23538
|
})) {
|
|
23539
|
-
return
|
|
23539
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
|
|
23540
23540
|
}
|
|
23541
23541
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23542
23542
|
return el === name;
|
|
@@ -23555,9 +23555,9 @@ function indent(str, spaces) {
|
|
|
23555
23555
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23556
23556
|
return el.startsWith(name);
|
|
23557
23557
|
})) {
|
|
23558
|
-
return
|
|
23558
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
|
|
23559
23559
|
}
|
|
23560
|
-
return
|
|
23560
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
|
|
23561
23561
|
v: nextMatch1
|
|
23562
23562
|
};
|
|
23563
23563
|
};
|
|
@@ -27459,13 +27459,53 @@ const preparePinsSettings = async (settings, context)=>{
|
|
|
27459
27459
|
};
|
|
27460
27460
|
|
|
27461
27461
|
let WebService = class WebService {
|
|
27462
|
+
filteredWebPinsSettings(item, path) {
|
|
27463
|
+
if (Array.isArray(item)) {
|
|
27464
|
+
return item.map((subItem, subIndex)=>this.filteredWebPinsSettings(subItem, `${path}[${subIndex}]`));
|
|
27465
|
+
}
|
|
27466
|
+
if (typeof item !== 'object' || item === null) {
|
|
27467
|
+
return item;
|
|
27468
|
+
}
|
|
27469
|
+
if (item.library === '@digipair/skill-web' && item.element === 'executeFactory') {
|
|
27470
|
+
return {
|
|
27471
|
+
library: item.library,
|
|
27472
|
+
element: item.element,
|
|
27473
|
+
properties: {
|
|
27474
|
+
path
|
|
27475
|
+
}
|
|
27476
|
+
};
|
|
27477
|
+
}
|
|
27478
|
+
const result = {};
|
|
27479
|
+
Object.entries(item).forEach(([key, value])=>{
|
|
27480
|
+
result[key] = this.filteredWebPinsSettings(value, `${path}.${key}`);
|
|
27481
|
+
});
|
|
27482
|
+
return result;
|
|
27483
|
+
}
|
|
27484
|
+
findFactoryPinsSettings(path, body) {
|
|
27485
|
+
const pinsSettings = path.split('.').reduce((acc, key)=>{
|
|
27486
|
+
if (key.indexOf('[') !== -1) {
|
|
27487
|
+
const index = parseInt(key.match(/\d+/)[0]);
|
|
27488
|
+
return acc[key.split('[')[0]][index];
|
|
27489
|
+
}
|
|
27490
|
+
return acc[key];
|
|
27491
|
+
}, {
|
|
27492
|
+
body
|
|
27493
|
+
});
|
|
27494
|
+
return pinsSettings.properties.execute;
|
|
27495
|
+
}
|
|
27462
27496
|
async page(params, _pinsSettingsList, context) {
|
|
27497
|
+
var _context_request_body;
|
|
27463
27498
|
const { body, data = [], title = 'Digipair', favicon = 'https://www.digipair.ai/assets/images/favicon.ico', styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', libraries = {} } = params;
|
|
27464
27499
|
const engineVersion = libraries['@digipair/engine'] || 'latest';
|
|
27465
27500
|
const preparedData = {};
|
|
27501
|
+
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
|
27502
|
+
const pinsSettingsList = this.findFactoryPinsSettings(context.request.body.params.path, body);
|
|
27503
|
+
return await executePinsList(pinsSettingsList, _extends({}, context.request.body.context, context));
|
|
27504
|
+
}
|
|
27466
27505
|
for (const item of data){
|
|
27467
27506
|
preparedData[item.name] = await executePinsList(item.value, context);
|
|
27468
27507
|
}
|
|
27508
|
+
const preparedBody = body.map((item, index)=>this.filteredWebPinsSettings(item, `body[${index}]`));
|
|
27469
27509
|
const html = `
|
|
27470
27510
|
<!DOCTYPE html>
|
|
27471
27511
|
<html style=${styleHtml}>
|
|
@@ -27477,8 +27517,22 @@ let WebService = class WebService {
|
|
|
27477
27517
|
<body style=${styleBody}>
|
|
27478
27518
|
<script type="module">
|
|
27479
27519
|
import { config, generateElementFromPins } from '${baseUrl}/@digipair/engine@${engineVersion}/index.esm.js';
|
|
27520
|
+
|
|
27521
|
+
const skillWeb = {
|
|
27522
|
+
executeFactory: async (params, pinsSettingsList, context) => {
|
|
27523
|
+
const result = await fetch(window.location, {
|
|
27524
|
+
headers: {
|
|
27525
|
+
'content-type': 'application/json',
|
|
27526
|
+
},
|
|
27527
|
+
body: JSON.stringify({ type: 'DIGIPAIR_EXECUTE_FACTORY', params, pinsSettingsList, context }),
|
|
27528
|
+
method: 'POST',
|
|
27529
|
+
});
|
|
27530
|
+
|
|
27531
|
+
return await result.json();
|
|
27532
|
+
}
|
|
27533
|
+
};
|
|
27480
27534
|
|
|
27481
|
-
config.set('LIBRARIES',
|
|
27535
|
+
config.set('LIBRARIES', { '@digipair/skill-web': skillWeb, ...${JSON.stringify(libraries)} });
|
|
27482
27536
|
config.set('BASE_URL', '${baseUrl}');
|
|
27483
27537
|
|
|
27484
27538
|
const context = {
|
|
@@ -27488,7 +27542,7 @@ let WebService = class WebService {
|
|
|
27488
27542
|
const options = {
|
|
27489
27543
|
libraries: {},
|
|
27490
27544
|
};
|
|
27491
|
-
const pinsList = ${JSON.stringify(
|
|
27545
|
+
const pinsList = ${JSON.stringify(preparedBody)};
|
|
27492
27546
|
for (let i = 0; i < pinsList.length; i++) {
|
|
27493
27547
|
const item = pinsList[i];
|
|
27494
27548
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} }, options);
|
package/index.esm.js
CHANGED
|
@@ -23488,14 +23488,14 @@ function indent(str, spaces) {
|
|
|
23488
23488
|
var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
|
|
23489
23489
|
// match is required
|
|
23490
23490
|
if (!match) {
|
|
23491
|
-
return
|
|
23491
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
|
|
23492
23492
|
v: nextMatch1
|
|
23493
23493
|
};
|
|
23494
23494
|
}
|
|
23495
23495
|
var token = match.token, offset = match.offset;
|
|
23496
23496
|
i1 += offset;
|
|
23497
23497
|
if (token === " ") {
|
|
23498
|
-
return
|
|
23498
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
|
|
23499
23499
|
}
|
|
23500
23500
|
tokens1 = _to_consumable_array$1(tokens1).concat([
|
|
23501
23501
|
token
|
|
@@ -23514,7 +23514,7 @@ function indent(str, spaces) {
|
|
|
23514
23514
|
if (contextKeys.some(function(el) {
|
|
23515
23515
|
return el.startsWith(name);
|
|
23516
23516
|
})) {
|
|
23517
|
-
return
|
|
23517
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
|
|
23518
23518
|
}
|
|
23519
23519
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23520
23520
|
return el === name;
|
|
@@ -23533,9 +23533,9 @@ function indent(str, spaces) {
|
|
|
23533
23533
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23534
23534
|
return el.startsWith(name);
|
|
23535
23535
|
})) {
|
|
23536
|
-
return
|
|
23536
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
|
|
23537
23537
|
}
|
|
23538
|
-
return
|
|
23538
|
+
return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
|
|
23539
23539
|
v: nextMatch1
|
|
23540
23540
|
};
|
|
23541
23541
|
};
|
|
@@ -27437,13 +27437,53 @@ const preparePinsSettings = async (settings, context)=>{
|
|
|
27437
27437
|
};
|
|
27438
27438
|
|
|
27439
27439
|
let WebService = class WebService {
|
|
27440
|
+
filteredWebPinsSettings(item, path) {
|
|
27441
|
+
if (Array.isArray(item)) {
|
|
27442
|
+
return item.map((subItem, subIndex)=>this.filteredWebPinsSettings(subItem, `${path}[${subIndex}]`));
|
|
27443
|
+
}
|
|
27444
|
+
if (typeof item !== 'object' || item === null) {
|
|
27445
|
+
return item;
|
|
27446
|
+
}
|
|
27447
|
+
if (item.library === '@digipair/skill-web' && item.element === 'executeFactory') {
|
|
27448
|
+
return {
|
|
27449
|
+
library: item.library,
|
|
27450
|
+
element: item.element,
|
|
27451
|
+
properties: {
|
|
27452
|
+
path
|
|
27453
|
+
}
|
|
27454
|
+
};
|
|
27455
|
+
}
|
|
27456
|
+
const result = {};
|
|
27457
|
+
Object.entries(item).forEach(([key, value])=>{
|
|
27458
|
+
result[key] = this.filteredWebPinsSettings(value, `${path}.${key}`);
|
|
27459
|
+
});
|
|
27460
|
+
return result;
|
|
27461
|
+
}
|
|
27462
|
+
findFactoryPinsSettings(path, body) {
|
|
27463
|
+
const pinsSettings = path.split('.').reduce((acc, key)=>{
|
|
27464
|
+
if (key.indexOf('[') !== -1) {
|
|
27465
|
+
const index = parseInt(key.match(/\d+/)[0]);
|
|
27466
|
+
return acc[key.split('[')[0]][index];
|
|
27467
|
+
}
|
|
27468
|
+
return acc[key];
|
|
27469
|
+
}, {
|
|
27470
|
+
body
|
|
27471
|
+
});
|
|
27472
|
+
return pinsSettings.properties.execute;
|
|
27473
|
+
}
|
|
27440
27474
|
async page(params, _pinsSettingsList, context) {
|
|
27475
|
+
var _context_request_body;
|
|
27441
27476
|
const { body, data = [], title = 'Digipair', favicon = 'https://www.digipair.ai/assets/images/favicon.ico', styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', libraries = {} } = params;
|
|
27442
27477
|
const engineVersion = libraries['@digipair/engine'] || 'latest';
|
|
27443
27478
|
const preparedData = {};
|
|
27479
|
+
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
|
27480
|
+
const pinsSettingsList = this.findFactoryPinsSettings(context.request.body.params.path, body);
|
|
27481
|
+
return await executePinsList(pinsSettingsList, _extends({}, context.request.body.context, context));
|
|
27482
|
+
}
|
|
27444
27483
|
for (const item of data){
|
|
27445
27484
|
preparedData[item.name] = await executePinsList(item.value, context);
|
|
27446
27485
|
}
|
|
27486
|
+
const preparedBody = body.map((item, index)=>this.filteredWebPinsSettings(item, `body[${index}]`));
|
|
27447
27487
|
const html = `
|
|
27448
27488
|
<!DOCTYPE html>
|
|
27449
27489
|
<html style=${styleHtml}>
|
|
@@ -27455,8 +27495,22 @@ let WebService = class WebService {
|
|
|
27455
27495
|
<body style=${styleBody}>
|
|
27456
27496
|
<script type="module">
|
|
27457
27497
|
import { config, generateElementFromPins } from '${baseUrl}/@digipair/engine@${engineVersion}/index.esm.js';
|
|
27498
|
+
|
|
27499
|
+
const skillWeb = {
|
|
27500
|
+
executeFactory: async (params, pinsSettingsList, context) => {
|
|
27501
|
+
const result = await fetch(window.location, {
|
|
27502
|
+
headers: {
|
|
27503
|
+
'content-type': 'application/json',
|
|
27504
|
+
},
|
|
27505
|
+
body: JSON.stringify({ type: 'DIGIPAIR_EXECUTE_FACTORY', params, pinsSettingsList, context }),
|
|
27506
|
+
method: 'POST',
|
|
27507
|
+
});
|
|
27508
|
+
|
|
27509
|
+
return await result.json();
|
|
27510
|
+
}
|
|
27511
|
+
};
|
|
27458
27512
|
|
|
27459
|
-
config.set('LIBRARIES',
|
|
27513
|
+
config.set('LIBRARIES', { '@digipair/skill-web': skillWeb, ...${JSON.stringify(libraries)} });
|
|
27460
27514
|
config.set('BASE_URL', '${baseUrl}');
|
|
27461
27515
|
|
|
27462
27516
|
const context = {
|
|
@@ -27466,7 +27520,7 @@ let WebService = class WebService {
|
|
|
27466
27520
|
const options = {
|
|
27467
27521
|
libraries: {},
|
|
27468
27522
|
};
|
|
27469
|
-
const pinsList = ${JSON.stringify(
|
|
27523
|
+
const pinsList = ${JSON.stringify(preparedBody)};
|
|
27470
27524
|
for (let i = 0; i < pinsList.length; i++) {
|
|
27471
27525
|
const item = pinsList[i];
|
|
27472
27526
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} }, options);
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -7,7 +7,30 @@
|
|
|
7
7
|
"version": "0.1.0",
|
|
8
8
|
"x-icon": "🚀"
|
|
9
9
|
},
|
|
10
|
-
"paths": {
|
|
10
|
+
"paths": {
|
|
11
|
+
"/executeFactory": {
|
|
12
|
+
"post": {
|
|
13
|
+
"summary": "Dans la factory",
|
|
14
|
+
"description": "Exécution d'une liste de capacité dans la factory",
|
|
15
|
+
"tags": ["web"],
|
|
16
|
+
"metadata": [],
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"name": "execute",
|
|
20
|
+
"summary": "Exécuter",
|
|
21
|
+
"required": true,
|
|
22
|
+
"description": "Liste de capacité à exécuter",
|
|
23
|
+
"schema": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": {
|
|
26
|
+
"$ref": "https://www.pinser.world/schemas/pinsSettings"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
11
34
|
"components": {
|
|
12
35
|
"schemas": {
|
|
13
36
|
"dataAttribute": {
|
|
@@ -52,7 +75,7 @@
|
|
|
52
75
|
},
|
|
53
76
|
{
|
|
54
77
|
"name": "data",
|
|
55
|
-
"summary": "Préparation des données",
|
|
78
|
+
"summary": "Préparation des données depuis la factory",
|
|
56
79
|
"required": false,
|
|
57
80
|
"description": "Préparation des données backend à envoyer à la page",
|
|
58
81
|
"schema": {
|