Skip to content
Snippets Groups Projects
Verified Commit daf062b2 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: commit save point

parent 18583969
Branches
Tags
No related merge requests found
Showing
with 49 additions and 366 deletions
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {AbstractConstraint} from "./abstract.mjs";
export {Valid}
......@@ -19,22 +16,7 @@ export {Valid}
*
* The valid constraint allows an always valid query to be performed. this constraint is mainly intended for testing.
*
* ```
* <script type="module">
* import {Valid} from '@schukai/monster/source/constraints/valid.mjs';
* new Valid();
* </script>
* ```
*
* @example
*
* import {Valid} from '@schukai/monster/source/constraints/valid.mjs';
*
* new Valid().isValid()
* .then(()=>console.log(true))
* .catch(()=>console.log(false));
* // ↦ true
*
* @externalExample ../../example/constraints/valid.mjs
* @license AGPLv3
* @since 1.3.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,8 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {isFunction, isObject, isString} from "../types/is.mjs";
import {validateString} from "../types/validate.mjs";
import {clone} from "../util/clone.mjs";
......@@ -29,87 +25,12 @@ const PARENT = '^';
* Either a simple definition `a.b.c` or a template `${a.b.c}` can be specified as the path.
* Key and value can be either a definition or a template. The key does not have to be defined.
*
* ```
* <script type="module">
* import {buildMap} from '@schukai/monster/source/data/buildmap.mjs';
* console.log(buildMap())
* </script>
* ```
*
* The templates determine the appearance of the keys and the value of the map. Either a single value `id` can be taken or a composite key `${id} ${name}` can be used.
* The templates determine the appearance of the keys and the value of the map. Either a single value
* `id` can be taken or a composite key `${id} ${name}` can be used.
*
* If you want to access values of the parent data set, you have to use the `^` character `${id} ${^.name}`.
*
* @example
*
* import {buildMap} from '@schukai/monster/source/data/buildmap.mjs';
* // a typical data structure as reported by an api
*
* let map;
* let obj = {
* "data": [
* {
* "id": 10,
* "name": "Cassandra",
* "address": {
* "street": "493-4105 Vulputate Street",
* "city": "Saumur",
* "zip": "52628"
* }
* },
* {
* "id": 20,
* "name": "Holly",
* "address": {
* "street": "1762 Eget Rd.",
* "city": "Schwalbach",
* "zip": "952340"
* }
* },
* {
* "id": 30,
* "name": "Guy",
* "address": {
* "street": "957-388 Sollicitudin Avenue",
* "city": "Panchià",
* "zip": "420729"
* }
* }
* ]
* };
*
* // The function is passed this data structure and with the help of the selector `'data.*'` the data to be considered are selected.
* // The key is given by a simple definition `'id'` and the value is given by a template `'${name} (${address.zip} ${address.city})'`.
* map = buildMap(obj, 'data.*', '${name} (${address.zip} ${address.city})', 'id');
* console.log(map);
*
* // ↦ Map(3) {
* // '10' => 'Cassandra (52628 Saumur)',
* // '20' => 'Holly (952340 Schwalbach)',
* // '30' => 'Guy (420729 Panchià)'
* // }
*
* // If no key is specified, the key from the selection, here the array index, is taken.
* map = buildMap(obj, 'data.*', '${name} (${address.zip} ${address.city})');
* console.log(map);
*
* // ↦ Map(3) {
* // '0' => 'Cassandra (52628 Saumur)',
* // '1' => 'Holly (952340 Schwalbach)',
* // '2' => 'Guy (420729 Panchià)'
* // }
*
* // a filter (function(value, key) {}) can be specified to accept only defined entries.
* map = buildMap(obj, 'data.*', '${name} (${address.zip} ${address.city})', 'id', function (value, key) {
* return (value['id'] >= 20) ? true : false
* });
* console.log(map);
*
* // ↦ Map(2) {
* // 20 => 'Holly (952340 Schwalbach)',
* // 30 => 'Guy (420729 Panchià)'
* // }
*
* @externalExample ../../example/data/buildmap.mjs
* @param {*} subject
* @param {string|Monster.Data~exampleSelectorCallback} selector
* @param {string} [valueTemplate]
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,8 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {isArray, isObject} from "../types/is.mjs";
import {Node} from "../types/node.mjs";
import {NodeList} from "../types/nodelist.mjs";
......@@ -39,13 +35,6 @@ const rootSymbol = Symbol('root');
/**
* With the help of the function `buildTree()`, nodes can be easily created from data objects.
*
* ```
* <script type="module">
* import {buildTree} from '@schukai/monster/source/data/buildtree.mjs';
* buildTree()
* </script>
* ```
*
* @param {*} subject
* @param {string|Monster.Data~exampleSelectorCallback} selector
* @param {string} idKey
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../constants.mjs";
import {Base} from "../types/base.mjs";
......@@ -32,24 +29,7 @@ const internalDataSymbol = Symbol('internalData');
/**
* The datasource class is the basis for dealing with different data sources.
* It provides a unified interface for accessing data
*
* ```
* <script type="module">
* import {Datasource} from '@schukai/monster/source/data/datasource.mjs';
* new Datasource()
* </script>
* ```
*
* @example
*
* import {Datasource} from '@schukai/monster/source/data/datasource.mjs'
*
* class MyDatasource extends Datasource {
*
* }
*
* const ds = new MyDatasource();
*
* @externalExample ../../example/data/datasource.mjs
* @license AGPLv3
* @since 1.22.0
* @copyright schukai GmbH
......
/**
* Namespace for datasources
*
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../../constants.mjs";
import {isObject} from "../../types/is.mjs";
import {Datasource} from "../datasource.mjs";
......@@ -20,27 +17,7 @@ export {RestAPI}
/**
* The RestAPI is a class that enables a REST API server.
*
* ```
* <script type="module">
* import {RestAPI} from '@schukai/monster/source/data/datasource/restapi.mjs';
* new RestAPI()
* </script>
* ```
*
* @example
*
* import {RestAPI} from '@schukai/monster/source/data/datasource/restapi.mjs';
*
* const ds = new RestAPI({
* url: 'https://httpbin.org/get'
* },{
* url: 'https://httpbin.org/post'
* });
*
* ds.set({flag:true})
* ds.write().then(()=>console.log('done'));
* ds.read().then(()=>console.log('done'));
*
* @externalExample ../../../example/data/storage/restapi.mjs
* @license AGPLv3
* @since 1.22.0
* @copyright schukai GmbH
......
/**
* Namespace for storages
*
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../../../constants.mjs";
export {WriteError}
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../../constants.mjs";
import {validateString} from "../../types/validate.mjs";
import {Datasource} from "../datasource.mjs";
......@@ -23,19 +20,6 @@ const storageObjectSymbol = Symbol('storageObject');
/**
* The class represents a record.
*
* ```
* <script type="module">
* import {Storage} from '@schukai/monster/source/data/datasource/storage.mjs';
* new Storage()
* </script>
* ```
*
* @example
*
* import {Storage} from '@schukai/monster/source/data/datasource/storage.mjs';
*
* new Datasource();
*
* @license AGPLv3
* @since 1.22.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../../../constants.mjs";
import {getGlobalObject} from "../../../types/global.mjs";
import {Datasource} from "../../datasource.mjs";
......@@ -18,13 +15,6 @@ export {LocalStorage}
/**
* The LocalStorage Datasource provides a data store in the browser localStorage.
*
* ```
* <script type="module">
* import {LocalStorage} from '@schukai/monster/source/data/datasource/storage/localstorage.mjs';
* new LocalStorage()
* </script>
* ```
*
* @license AGPLv3
* @since 1.22.0
* @copyright schukai GmbH
......
/**
* Namespace for storages
*
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {internalSymbol} from "../../../constants.mjs";
import {getGlobalObject} from "../../../types/global.mjs";
import {Datasource} from "../../datasource.mjs";
......@@ -18,13 +15,6 @@ export {SessionStorage}
/**
* The SessionStorage class provides a data source that uses the SessionStorage API on the client.
*
* ```
* <script type="module">
* import {SessionStorage} from '@schukai/monster/source/data/datasource/storage/sessionstorage.mjs';
* new SessionStorage()
* </script>
* ```
*
* @license AGPLv3
* @since 1.22.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,8 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {isArray, isObject} from "../types/is.mjs";
import {typeOf} from "../types/typeof.mjs";
......@@ -26,48 +22,7 @@ export {diff}
* </script>
* ```
*
* @example
*
* import {Diff} from '@schukai/monster/source/data/diff.mjs';
*
* // given are two objects x and y.
*
* let x = {
* a: 1,
* b: "Hello!"
* }
*
* let y = {
* a: 2,
* c: true
* }
*
* // These two objects can be compared with each other.
*
* console.log(Diff(x, y));
*
* // the result is then the following
*
* //
* // [
* // {
* // operator: 'update',
* // path: [ 'a' ],
* // first: { value: 1, type: 'number' },
* // second: { value: 2, type: 'number' }
* // },
* // {
* // operator: 'delete',
* // path: [ 'b' ],
* // first: { value: 'Hello!', type: 'string' }
* // },
* // {
* // operator: 'add',
* // path: [ 'c' ],
* // second: { value: true, type: 'boolean' }
* // }
* // ]
*
* @externalExample ../../example/data/diff.mjs
* @param {*} first
* @param {*} second
* @return {array}
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {isArray, isObject} from "../types/is.mjs";
import {typeOf} from "../types/typeof.mjs";
......@@ -17,13 +14,6 @@ export {extend}
* Extend copies all enumerable own properties from one or
* more source objects to a target object. It returns the modified target object.
*
* ```
* <script type="module">
* import {extend} from '@schukai/monster/source/data/extend.mjs';
* extend(a, b)
* </script>
* ```
*
* @param {object} target
* @param {object}
* @return {object}
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,7 +5,6 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from '../types/base.mjs';
import {isArray, isInteger, isObject, isPrimitive} from '../types/is.mjs';
import {Stack} from "../types/stack.mjs";
......@@ -32,13 +29,6 @@ const WILDCARD = '*';
/**
* Pathfinder is a class to find a path to an object.
*
* ```
* <script type="module">
* import {Pathfinder} from '@schukai/monster/source/data/pathfinder.mjs';
* console.log(new Pathfinder())
* </script>
* ```
*
* With the help of the pathfinder, values can be read and written from an object construct.
*
* ```
......@@ -74,54 +64,8 @@ const WILDCARD = '*';
* new Pathfinder(obj).setVia('a.b.0.c', true); // ↦ {a:{b:[{c:true}]}}
* ```
*
* @example
*
* import {Pathfinder} from '@schukai/monster/source/data/pathfinder.mjs';
*
* let value = new Pathfinder({
* a: {
* b: {
* f: [
* {
* g: false,
* }
* ],
* }
* }
* }).getVia("a.b.f.0.g");
*
* console.log(value);
* // ↦ false
*
* try {
* new Pathfinder({}).getVia("a.b.f.0.g");
* } catch(e) {
* console.log(e.toString());
* // ↦ Error: the journey is not at its end (b.f.0.g)
* }
*
* @example
*
* import {Pathfinder} from '@schukai/monster/source/data/pathfinder.mjs';
*
* let p = new Pathfinder({
* a: {
* x: [
* {c: 1}, {c: 2}
* ],
* y: true
* },
* b: {
* x: [
* {c: 1, d: false}, {c: 2}
* ],
* y: true
* },
* });
*
* let r = p.getVia("*.x.*.c");
* console.log(r);
*
* @externalExample ../../example/data/pathfinder-1.mjs
* @externalExample ../../example/data/pathfinder-2.mjs
* @license AGPLv3
* @since 1.4.0
* @copyright schukai GmbH
......
/**
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
* Node module: @schukai/monster
......@@ -7,47 +5,27 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Base} from '../types/base.mjs';
import {validateString} from '../types/validate.mjs';
import {Transformer} from './transformer.mjs';
export {Pipe}
/**
* @private
* @type {string}
*/
const DELIMITER = '|';
/**
* The pipe class makes it possible to combine several processing steps.
*
* ```
* <script type="module">
* import {Pipe} from '@schukai/monster/source/data/pipe.mjs';
* new Pipe()
* </script>
* ```
*
* A pipe consists of commands whose input and output are connected with the pipe symbol `|`.
*
* With the Pipe, processing steps can be combined. Here, the value of an object is accessed via the pathfinder (path command).
* the word is then converted to uppercase letters and a prefix Hello is added. the two backslash safe the space char.
*
* @example
* import {Pipe} from '@schukai/monster/source/data/pipe.mjs';
*
* let obj = {
* a: {
* b: {
* c: {
* d: "world"
* }
* }
* }
* }
*
* console.log(new Pipe('path:a.b.c.d | toupper | prefix:Hello\\ ').run(obj));
* // ↦ Hello WORLD
*
* @externalExample ../../example/data/pipe.mjs
* @license AGPLv3
* @since 1.5.0
* @copyright schukai GmbH
......@@ -56,7 +34,6 @@ const DELIMITER = '|';
class Pipe extends Base {
/**
*
* @param {string} pipe a pipe consists of commands whose input and output are connected with the pipe symbol `|`.
* @throws {TypeError}
*/
......@@ -72,7 +49,6 @@ class Pipe extends Base {
}
/**
*
* @param {string} name
* @param {function} callback
* @param {object} context
......
......@@ -27,13 +27,6 @@ export {Transformer}
/**
* The transformer class is a swiss army knife for manipulating values. especially in combination with the pipe, processing chains can be built up.
*
* ```
* <script type="module">
* import {Transformer} from '@schukai/monster/source/data/transformer.mjs';
* new Transformer()
* </script>
* ```
*
* A simple example is the conversion of all characters to lowercase. for this purpose the command `tolower` must be used.
*
* ```
......@@ -113,18 +106,7 @@ export {Transformer}
* global['crypto'] = new Crypto.Crypto();
* ```
*
* @example
*
* import {Transformer} from '@schukai/monster/source/data/transformer.mjs';
*
* const transformer = new Transformer("tolower")
*
* console.log(transformer.run("HELLO"))
* // ↦ hello
*
* console.log(transformer.run("WORLD"))
* // ↦ world
*
* @externalExample ../../example/data/transformer.mjs
* @license AGPLv3
* @since 1.5.0
* @copyright schukai GmbH
......
......@@ -31,6 +31,7 @@
"fs": "^0.0.1-security",
"graphviz": "^0.0.9",
"jsdoc": "^3.6.11",
"jsdoc-external-example": "github:volker-schukai/jsdoc-external-example",
"jsdoc-plantuml": "^1.0.2",
"jsdom": "^19.0.0",
"jsdom-global": "^3.0.2",
......
......@@ -10,10 +10,12 @@ specifiers:
create-polyfill-service-url: ^2.2.6
crypt: ^0.0.2
esbuild: ^0.14.53
examples-plugin-jsdoc: ^1.0.4
flow-bin: ^0.184.0
fs: ^0.0.1-security
graphviz: ^0.0.9
jsdoc: ^3.6.11
jsdoc-external-example: github:volker-schukai/jsdoc-external-example
jsdoc-plantuml: ^1.0.2
jsdom: ^19.0.0
jsdom-global: ^3.0.2
......@@ -34,10 +36,12 @@ devDependencies:
create-polyfill-service-url: 2.2.6
crypt: 0.0.2
esbuild: 0.14.53
examples-plugin-jsdoc: 1.0.4
flow-bin: 0.184.0
fs: 0.0.1-security
graphviz: 0.0.9
jsdoc: 3.6.11
jsdoc-external-example: github.com/volker-schukai/jsdoc-external-example/91fd194a706b54d6fe30f41aad9a0851c571b360
jsdoc-plantuml: 1.0.2_jsdoc@3.6.11
jsdom: 19.0.0
jsdom-global: 3.0.2_jsdom@19.0.0
......@@ -431,6 +435,11 @@ packages:
engines: {node: '>=0.4.0'}
dev: true
/acorn-walk/8.2.0:
resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==}
engines: {node: '>=0.4.0'}
dev: true
/acorn/7.4.1:
resolution: {integrity: sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==}
engines: {node: '>=0.4.0'}
......@@ -1241,6 +1250,12 @@ packages:
engines: {node: '>=6'}
dev: true
/examples-plugin-jsdoc/1.0.4:
resolution: {integrity: sha512-7B5Uq8uwnPplGjnuwlxzlKHR3clexNpacF0MmRKyYTrPJz84Q5Jw2UwgZhhjtnqjWUWw1pkl4UWknuqssCcdKg==}
dependencies:
vm2: 3.9.10
dev: true
/execa/4.1.0:
resolution: {integrity: sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==}
engines: {node: '>=10'}
......@@ -2848,6 +2863,15 @@ packages:
convert-source-map: 1.8.0
dev: true
/vm2/3.9.10:
resolution: {integrity: sha512-AuECTSvwu2OHLAZYhG716YzwodKCIJxB6u1zG7PgSQwIgAlEaoXH52bxdcvT8GkGjnYK7r7yWDW0m0sOsPuBjQ==}
engines: {node: '>=6.0'}
hasBin: true
dependencies:
acorn: 8.8.0
acorn-walk: 8.2.0
dev: true
/w3c-hr-time/1.0.2:
resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==}
dependencies:
......@@ -3101,3 +3125,9 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
dev: true
github.com/volker-schukai/jsdoc-external-example/91fd194a706b54d6fe30f41aad9a0851c571b360:
resolution: {tarball: https://codeload.github.com/volker-schukai/jsdoc-external-example/tar.gz/91fd194a706b54d6fe30f41aad9a0851c571b360}
name: jsdoc-external-example
version: 0.0.1
dev: true
......@@ -10,7 +10,8 @@
"plugins": [
"plugins/markdown",
"jsdoc-plantuml",
"plugins/summarize"
"plugins/summarize",
"jsdoc-external-example"
],
"sourceType": "module",
"opts": {
......@@ -18,7 +19,7 @@
"encoding": "utf8",
"destination": "../deployment/build/docs/",
"recurse": true,
"verbose": true,
"verbose": false,
"theme_opts": {
"default_theme": "dark",
"title": "Monster ",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment