@digipair/skill-web 0.4.29 → 0.5.0
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 +64 -7
- package/index.esm.js +59 -2
- 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 tokens = tokens1, nextMatch = nextMatch1, i = i1, {
|
|
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 tokens = tokens1, nextMatch = nextMatch1, i = i1, "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 tokens = tokens1, nextMatch = nextMatch1, i = i1, "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 tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
|
|
23559
23559
|
}
|
|
23560
|
-
return
|
|
23560
|
+
return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
|
|
23561
23561
|
v: nextMatch1
|
|
23562
23562
|
};
|
|
23563
23563
|
};
|
|
@@ -27459,13 +27459,54 @@ 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
|
+
console.log('findFactoryPinsSettings final', path, pinsSettings.properties.execute);
|
|
27495
|
+
return pinsSettings.properties.execute;
|
|
27496
|
+
}
|
|
27462
27497
|
async page(params, _pinsSettingsList, context) {
|
|
27498
|
+
var _context_request_body;
|
|
27463
27499
|
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
27500
|
const engineVersion = libraries['@digipair/engine'] || 'latest';
|
|
27465
27501
|
const preparedData = {};
|
|
27502
|
+
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
|
27503
|
+
const pinsSettingsList = this.findFactoryPinsSettings(context.request.body.params.path, body);
|
|
27504
|
+
return await executePinsList(pinsSettingsList, _extends({}, context.request.body.context, context));
|
|
27505
|
+
}
|
|
27466
27506
|
for (const item of data){
|
|
27467
27507
|
preparedData[item.name] = await executePinsList(item.value, context);
|
|
27468
27508
|
}
|
|
27509
|
+
const preparedBody = body.map((item, index)=>this.filteredWebPinsSettings(item, `body[${index}]`));
|
|
27469
27510
|
const html = `
|
|
27470
27511
|
<!DOCTYPE html>
|
|
27471
27512
|
<html style=${styleHtml}>
|
|
@@ -27477,8 +27518,24 @@ let WebService = class WebService {
|
|
|
27477
27518
|
<body style=${styleBody}>
|
|
27478
27519
|
<script type="module">
|
|
27479
27520
|
import { config, generateElementFromPins } from '${baseUrl}/@digipair/engine@${engineVersion}/index.esm.js';
|
|
27521
|
+
|
|
27522
|
+
const skillWeb = {
|
|
27523
|
+
executeFactory: async (params, pinsSettingsList, context) => {
|
|
27524
|
+
console.log('executeFactory', params, pinsSettingsList, context);
|
|
27525
|
+
|
|
27526
|
+
const result = await fetch(window.location, {
|
|
27527
|
+
headers: {
|
|
27528
|
+
'content-type': 'application/json',
|
|
27529
|
+
},
|
|
27530
|
+
body: JSON.stringify({ type: 'DIGIPAIR_EXECUTE_FACTORY', params, pinsSettingsList, context }),
|
|
27531
|
+
method: 'POST',
|
|
27532
|
+
});
|
|
27533
|
+
|
|
27534
|
+
return await result.json();
|
|
27535
|
+
}
|
|
27536
|
+
};
|
|
27480
27537
|
|
|
27481
|
-
config.set('LIBRARIES',
|
|
27538
|
+
config.set('LIBRARIES', { '@digipair/skill-web': skillWeb, ...${JSON.stringify(libraries)} });
|
|
27482
27539
|
config.set('BASE_URL', '${baseUrl}');
|
|
27483
27540
|
|
|
27484
27541
|
const context = {
|
|
@@ -27488,7 +27545,7 @@ let WebService = class WebService {
|
|
|
27488
27545
|
const options = {
|
|
27489
27546
|
libraries: {},
|
|
27490
27547
|
};
|
|
27491
|
-
const pinsList = ${JSON.stringify(
|
|
27548
|
+
const pinsList = ${JSON.stringify(preparedBody)};
|
|
27492
27549
|
for (let i = 0; i < pinsList.length; i++) {
|
|
27493
27550
|
const item = pinsList[i];
|
|
27494
27551
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} }, options);
|
package/index.esm.js
CHANGED
|
@@ -27437,13 +27437,54 @@ 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
|
+
console.log('findFactoryPinsSettings final', path, pinsSettings.properties.execute);
|
|
27473
|
+
return pinsSettings.properties.execute;
|
|
27474
|
+
}
|
|
27440
27475
|
async page(params, _pinsSettingsList, context) {
|
|
27476
|
+
var _context_request_body;
|
|
27441
27477
|
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
27478
|
const engineVersion = libraries['@digipair/engine'] || 'latest';
|
|
27443
27479
|
const preparedData = {};
|
|
27480
|
+
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
|
27481
|
+
const pinsSettingsList = this.findFactoryPinsSettings(context.request.body.params.path, body);
|
|
27482
|
+
return await executePinsList(pinsSettingsList, _extends({}, context.request.body.context, context));
|
|
27483
|
+
}
|
|
27444
27484
|
for (const item of data){
|
|
27445
27485
|
preparedData[item.name] = await executePinsList(item.value, context);
|
|
27446
27486
|
}
|
|
27487
|
+
const preparedBody = body.map((item, index)=>this.filteredWebPinsSettings(item, `body[${index}]`));
|
|
27447
27488
|
const html = `
|
|
27448
27489
|
<!DOCTYPE html>
|
|
27449
27490
|
<html style=${styleHtml}>
|
|
@@ -27455,8 +27496,24 @@ let WebService = class WebService {
|
|
|
27455
27496
|
<body style=${styleBody}>
|
|
27456
27497
|
<script type="module">
|
|
27457
27498
|
import { config, generateElementFromPins } from '${baseUrl}/@digipair/engine@${engineVersion}/index.esm.js';
|
|
27499
|
+
|
|
27500
|
+
const skillWeb = {
|
|
27501
|
+
executeFactory: async (params, pinsSettingsList, context) => {
|
|
27502
|
+
console.log('executeFactory', params, pinsSettingsList, context);
|
|
27503
|
+
|
|
27504
|
+
const result = await fetch(window.location, {
|
|
27505
|
+
headers: {
|
|
27506
|
+
'content-type': 'application/json',
|
|
27507
|
+
},
|
|
27508
|
+
body: JSON.stringify({ type: 'DIGIPAIR_EXECUTE_FACTORY', params, pinsSettingsList, context }),
|
|
27509
|
+
method: 'POST',
|
|
27510
|
+
});
|
|
27511
|
+
|
|
27512
|
+
return await result.json();
|
|
27513
|
+
}
|
|
27514
|
+
};
|
|
27458
27515
|
|
|
27459
|
-
config.set('LIBRARIES',
|
|
27516
|
+
config.set('LIBRARIES', { '@digipair/skill-web': skillWeb, ...${JSON.stringify(libraries)} });
|
|
27460
27517
|
config.set('BASE_URL', '${baseUrl}');
|
|
27461
27518
|
|
|
27462
27519
|
const context = {
|
|
@@ -27466,7 +27523,7 @@ let WebService = class WebService {
|
|
|
27466
27523
|
const options = {
|
|
27467
27524
|
libraries: {},
|
|
27468
27525
|
};
|
|
27469
|
-
const pinsList = ${JSON.stringify(
|
|
27526
|
+
const pinsList = ${JSON.stringify(preparedBody)};
|
|
27470
27527
|
for (let i = 0; i < pinsList.length; i++) {
|
|
27471
27528
|
const item = pinsList[i];
|
|
27472
27529
|
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": {
|