@digipair/skill-web 0.112.3 → 0.114.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/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # skill-test
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build skill-web` to build the library.
@@ -1,27 +1,10 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var engine = require('@digipair/engine');
6
4
  var jsdom = require('jsdom');
7
5
  var promises = require('fs/promises');
8
6
  var require$$1 = require('path');
9
7
 
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
13
-
14
- function _extends() {
15
- _extends = Object.assign || function assign(target) {
16
- for(var i = 1; i < arguments.length; i++){
17
- var source = arguments[i];
18
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
19
- }
20
- return target;
21
- };
22
- return _extends.apply(this, arguments);
23
- }
24
-
25
8
  var mimeTypes = {};
26
9
 
27
10
  var require$$0 = {
@@ -10746,141 +10729,141 @@ var require$$0 = {
10746
10729
  */
10747
10730
 
10748
10731
  (function (exports) {
10749
- /**
10750
- * Module dependencies.
10751
- * @private
10752
- */ var db = mimeDb;
10753
- var extname = require$$1__default["default"].extname;
10754
- /**
10755
- * Module variables.
10756
- * @private
10757
- */ var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
10758
- var TEXT_TYPE_REGEXP = /^text\//i;
10759
- /**
10760
- * Module exports.
10761
- * @public
10762
- */ exports.charset = charset;
10763
- exports.charsets = {
10764
- lookup: charset
10765
- };
10766
- exports.contentType = contentType;
10767
- exports.extension = extension;
10768
- exports.extensions = Object.create(null);
10769
- exports.lookup = lookup;
10770
- exports.types = Object.create(null);
10771
- // Populate the extensions/types maps
10772
- populateMaps(exports.extensions, exports.types);
10773
- /**
10774
- * Get the default charset for a MIME type.
10775
- *
10776
- * @param {string} type
10777
- * @return {boolean|string}
10778
- */ function charset(type) {
10779
- if (!type || typeof type !== "string") {
10780
- return false;
10781
- }
10782
- // TODO: use media-typer
10783
- var match = EXTRACT_TYPE_REGEXP.exec(type);
10784
- var mime = match && db[match[1].toLowerCase()];
10785
- if (mime && mime.charset) {
10786
- return mime.charset;
10787
- }
10788
- // default text/* to utf-8
10789
- if (match && TEXT_TYPE_REGEXP.test(match[1])) {
10790
- return "UTF-8";
10791
- }
10792
- return false;
10793
- }
10794
- /**
10795
- * Create a full Content-Type header given a MIME type or extension.
10796
- *
10797
- * @param {string} str
10798
- * @return {boolean|string}
10799
- */ function contentType(str) {
10800
- // TODO: should this even be in this module?
10801
- if (!str || typeof str !== "string") {
10802
- return false;
10803
- }
10804
- var mime = str.indexOf("/") === -1 ? exports.lookup(str) : str;
10805
- if (!mime) {
10806
- return false;
10807
- }
10808
- // TODO: use content-type or other module
10809
- if (mime.indexOf("charset") === -1) {
10810
- var _$charset = exports.charset(mime);
10811
- if (_$charset) mime += "; charset=" + _$charset.toLowerCase();
10812
- }
10813
- return mime;
10814
- }
10815
- /**
10816
- * Get the default extension for a MIME type.
10817
- *
10818
- * @param {string} type
10819
- * @return {boolean|string}
10820
- */ function extension(type) {
10821
- if (!type || typeof type !== "string") {
10822
- return false;
10823
- }
10824
- // TODO: use media-typer
10825
- var match = EXTRACT_TYPE_REGEXP.exec(type);
10826
- // get extensions
10827
- var exts = match && exports.extensions[match[1].toLowerCase()];
10828
- if (!exts || !exts.length) {
10829
- return false;
10830
- }
10831
- return exts[0];
10832
- }
10833
- /**
10834
- * Lookup the MIME type for a file path/extension.
10835
- *
10836
- * @param {string} path
10837
- * @return {boolean|string}
10838
- */ function lookup(path) {
10839
- if (!path || typeof path !== "string") {
10840
- return false;
10841
- }
10842
- // get the extension ("ext" or ".ext" or full path)
10843
- var _$extension = extname("x." + path).toLowerCase().substr(1);
10844
- if (!_$extension) {
10845
- return false;
10846
- }
10847
- return exports.types[_$extension] || false;
10848
- }
10849
- /**
10850
- * Populate the extensions and types maps.
10851
- * @private
10852
- */ function populateMaps(extensions, types) {
10853
- // source preference (least -> most)
10854
- var preference = [
10855
- "nginx",
10856
- "apache",
10857
- undefined,
10858
- "iana"
10859
- ];
10860
- Object.keys(db).forEach(function forEachMimeType(type) {
10861
- var mime = db[type];
10862
- var exts = mime.extensions;
10863
- if (!exts || !exts.length) {
10864
- return;
10865
- }
10866
- // mime -> extensions
10867
- extensions[type] = exts;
10868
- // extension -> mime
10869
- for(var i = 0; i < exts.length; i++){
10870
- var _$extension = exts[i];
10871
- if (types[_$extension]) {
10872
- var from = preference.indexOf(db[types[_$extension]].source);
10873
- var to = preference.indexOf(mime.source);
10874
- if (types[_$extension] !== "application/octet-stream" && (from > to || from === to && types[_$extension].substr(0, 12) === "application/")) {
10875
- continue;
10876
- }
10877
- }
10878
- // set the extension -> mime
10879
- types[_$extension] = type;
10880
- }
10881
- });
10882
- }
10883
- }(mimeTypes));
10732
+ /**
10733
+ * Module dependencies.
10734
+ * @private
10735
+ */ var db = mimeDb;
10736
+ var extname = require$$1.extname;
10737
+ /**
10738
+ * Module variables.
10739
+ * @private
10740
+ */ var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
10741
+ var TEXT_TYPE_REGEXP = /^text\//i;
10742
+ /**
10743
+ * Module exports.
10744
+ * @public
10745
+ */ exports.charset = charset;
10746
+ exports.charsets = {
10747
+ lookup: charset
10748
+ };
10749
+ exports.contentType = contentType;
10750
+ exports.extension = extension;
10751
+ exports.extensions = Object.create(null);
10752
+ exports.lookup = lookup;
10753
+ exports.types = Object.create(null);
10754
+ // Populate the extensions/types maps
10755
+ populateMaps(exports.extensions, exports.types);
10756
+ /**
10757
+ * Get the default charset for a MIME type.
10758
+ *
10759
+ * @param {string} type
10760
+ * @return {boolean|string}
10761
+ */ function charset(type) {
10762
+ if (!type || typeof type !== 'string') {
10763
+ return false;
10764
+ }
10765
+ // TODO: use media-typer
10766
+ var match = EXTRACT_TYPE_REGEXP.exec(type);
10767
+ var mime = match && db[match[1].toLowerCase()];
10768
+ if (mime && mime.charset) {
10769
+ return mime.charset;
10770
+ }
10771
+ // default text/* to utf-8
10772
+ if (match && TEXT_TYPE_REGEXP.test(match[1])) {
10773
+ return 'UTF-8';
10774
+ }
10775
+ return false;
10776
+ }
10777
+ /**
10778
+ * Create a full Content-Type header given a MIME type or extension.
10779
+ *
10780
+ * @param {string} str
10781
+ * @return {boolean|string}
10782
+ */ function contentType(str) {
10783
+ // TODO: should this even be in this module?
10784
+ if (!str || typeof str !== 'string') {
10785
+ return false;
10786
+ }
10787
+ var mime = str.indexOf('/') === -1 ? exports.lookup(str) : str;
10788
+ if (!mime) {
10789
+ return false;
10790
+ }
10791
+ // TODO: use content-type or other module
10792
+ if (mime.indexOf('charset') === -1) {
10793
+ var _$charset = exports.charset(mime);
10794
+ if (_$charset) mime += '; charset=' + _$charset.toLowerCase();
10795
+ }
10796
+ return mime;
10797
+ }
10798
+ /**
10799
+ * Get the default extension for a MIME type.
10800
+ *
10801
+ * @param {string} type
10802
+ * @return {boolean|string}
10803
+ */ function extension(type) {
10804
+ if (!type || typeof type !== 'string') {
10805
+ return false;
10806
+ }
10807
+ // TODO: use media-typer
10808
+ var match = EXTRACT_TYPE_REGEXP.exec(type);
10809
+ // get extensions
10810
+ var exts = match && exports.extensions[match[1].toLowerCase()];
10811
+ if (!exts || !exts.length) {
10812
+ return false;
10813
+ }
10814
+ return exts[0];
10815
+ }
10816
+ /**
10817
+ * Lookup the MIME type for a file path/extension.
10818
+ *
10819
+ * @param {string} path
10820
+ * @return {boolean|string}
10821
+ */ function lookup(path) {
10822
+ if (!path || typeof path !== 'string') {
10823
+ return false;
10824
+ }
10825
+ // get the extension ("ext" or ".ext" or full path)
10826
+ var _$extension = extname('x.' + path).toLowerCase().substr(1);
10827
+ if (!_$extension) {
10828
+ return false;
10829
+ }
10830
+ return exports.types[_$extension] || false;
10831
+ }
10832
+ /**
10833
+ * Populate the extensions and types maps.
10834
+ * @private
10835
+ */ function populateMaps(extensions, types) {
10836
+ // source preference (least -> most)
10837
+ var preference = [
10838
+ 'nginx',
10839
+ 'apache',
10840
+ undefined,
10841
+ 'iana'
10842
+ ];
10843
+ Object.keys(db).forEach(function forEachMimeType(type) {
10844
+ var mime = db[type];
10845
+ var exts = mime.extensions;
10846
+ if (!exts || !exts.length) {
10847
+ return;
10848
+ }
10849
+ // mime -> extensions
10850
+ extensions[type] = exts;
10851
+ // extension -> mime
10852
+ for(var i = 0; i < exts.length; i++){
10853
+ var _$extension = exts[i];
10854
+ if (types[_$extension]) {
10855
+ var from = preference.indexOf(db[types[_$extension]].source);
10856
+ var to = preference.indexOf(mime.source);
10857
+ if (types[_$extension] !== 'application/octet-stream' && (from > to || from === to && types[_$extension].substr(0, 12) === 'application/')) {
10858
+ continue;
10859
+ }
10860
+ }
10861
+ // set the extension -> mime
10862
+ types[_$extension] = type;
10863
+ }
10864
+ });
10865
+ }
10866
+ } (mimeTypes));
10884
10867
 
10885
10868
  let WebService = class WebService {
10886
10869
  filteredWebPinsSettings(item, path) {
@@ -10922,11 +10905,16 @@ let WebService = class WebService {
10922
10905
  return preparedPinsSettings;
10923
10906
  }
10924
10907
  mergeConttext(context, newContext) {
10925
- const output = _extends({}, context);
10908
+ const output = {
10909
+ ...context
10910
+ };
10926
10911
  for(const key in newContext){
10927
10912
  if (Object.prototype.hasOwnProperty.call(newContext, key)) {
10928
10913
  if (key !== 'protected' && typeof newContext[key] === 'object' && newContext[key] !== null && !Array.isArray(newContext[key]) && Object.prototype.hasOwnProperty.call(context, key)) {
10929
- output[key] = _extends({}, context[key], newContext[key]);
10914
+ output[key] = {
10915
+ ...context[key],
10916
+ ...newContext[key]
10917
+ };
10930
10918
  } else if (typeof newContext[key] !== 'undefined') {
10931
10919
  output[key] = newContext[key];
10932
10920
  }
@@ -10955,7 +10943,6 @@ let WebService = class WebService {
10955
10943
  }
10956
10944
  }
10957
10945
  async page(params, _pinsSettingsList, context) {
10958
- var _context_request_body;
10959
10946
  const { body, head, ssr = true, styleHtml = '', styleBody = '', factoryInitialize = [], browserInitialize = [], browserLoad = [], confirmBeforeUnload = 'false' } = params;
10960
10947
  const engineVersion = context.config.VERSIONS['@digipair/engine'] || 'latest';
10961
10948
  const preparedData = {};
@@ -10984,10 +10971,9 @@ let WebService = class WebService {
10984
10971
  status: 'not found'
10985
10972
  };
10986
10973
  }
10987
- if (context.config.VERSIONS[library]) {
10988
- var _infos_keywords, _infos_keywords1;
10974
+ if (library === '@digipair/engine' || context.config.VERSIONS[library]) {
10989
10975
  const infos = require(`${library}/package.json`);
10990
- if (!(((_infos_keywords = infos.keywords) == null ? void 0 : _infos_keywords.indexOf('digipair')) >= 0 && ((_infos_keywords1 = infos.keywords) == null ? void 0 : _infos_keywords1.indexOf('web')) >= 0)) {
10976
+ if (!(infos.keywords?.indexOf('digipair') >= 0 && infos.keywords?.indexOf('web') >= 0)) {
10991
10977
  context.protected.res.status(404);
10992
10978
  return {
10993
10979
  status: 'not found'
@@ -11007,14 +10993,13 @@ let WebService = class WebService {
11007
10993
  }
11008
10994
  return result;
11009
10995
  }
11010
- if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
10996
+ if (context.request.method === 'POST' && context.request.body?.type === 'DIGIPAIR_EXECUTE_FACTORY') {
11011
10997
  const param = context.request.body.params.path.split('[')[0];
11012
10998
  const pinsSettingsList = this.findFactoryPinsSettings(context.request.body.params.path, params[param]);
11013
10999
  return JSON.stringify(await engine.executePinsList(pinsSettingsList, this.mergeConttext(context.request.body.context, context), `${context.request.body.params.path}.execute`));
11014
11000
  }
11015
11001
  const path = context.protected.req.path.replace(/\/$/g, '');
11016
- var _context_request_headers_xforwardedproto;
11017
- const baseUrl = ((_context_request_headers_xforwardedproto = context.request.headers['x-forwarded-proto']) != null ? _context_request_headers_xforwardedproto : context.protected.req.protocol) + '://' + context.request.headers.host + (context.request.params.length <= 0 || context.request.params[0] === '' ? path : path.substring(0, path.length - context.request.params.join('/').length - 1)) + '/__digipair_www__';
11002
+ const baseUrl = (context.request.headers['x-forwarded-proto'] ?? context.protected.req.protocol) + '://' + context.request.headers.host + (context.request.params.length <= 0 || context.request.params[0] === '' ? path : path.substring(0, path.length - context.request.params.join('/').length - 1)) + '/__digipair_www__';
11018
11003
  await engine.executePinsList(factoryInitialize, context, `${context.__PATH__}.factoryInitialize`);
11019
11004
  const html = `
11020
11005
  <!DOCTYPE html>