@serenity-js/core 2.32.4 → 3.0.0-rc.3
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/CHANGELOG.md +76 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/io/ErrorSerialiser.js +4 -1
- package/lib/io/ErrorSerialiser.js.map +1 -1
- package/lib/io/asyncMap.d.ts +8 -0
- package/lib/io/asyncMap.js +18 -0
- package/lib/io/asyncMap.js.map +1 -0
- package/lib/io/format.d.ts +37 -0
- package/lib/io/format.js +49 -0
- package/lib/io/format.js.map +1 -0
- package/lib/io/formatted.d.ts +5 -1
- package/lib/io/formatted.js +6 -13
- package/lib/io/formatted.js.map +1 -1
- package/lib/io/index.d.ts +2 -1
- package/lib/io/index.js +2 -1
- package/lib/io/index.js.map +1 -1
- package/lib/io/inspected.d.ts +9 -1
- package/lib/io/inspected.js +50 -14
- package/lib/io/inspected.js.map +1 -1
- package/lib/model/Timestamp.d.ts +4 -2
- package/lib/model/Timestamp.js +8 -2
- package/lib/model/Timestamp.js.map +1 -1
- package/lib/screenplay/Question.d.ts +6 -83
- package/lib/screenplay/Question.js +14 -98
- package/lib/screenplay/Question.js.map +1 -1
- package/lib/screenplay/actor/Actor.js +2 -2
- package/lib/screenplay/actor/Actor.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -1
- package/lib/screenplay/index.js +1 -1
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/model/Adapter.d.ts +8 -0
- package/lib/{io/collections/reducible.js → screenplay/model/Adapter.js} +1 -1
- package/lib/screenplay/model/Adapter.js.map +1 -0
- package/lib/screenplay/model/createAdapter.d.ts +3 -0
- package/lib/screenplay/model/createAdapter.js +112 -0
- package/lib/screenplay/model/createAdapter.js.map +1 -0
- package/lib/screenplay/model/index.d.ts +2 -0
- package/lib/screenplay/{tasks → model}/index.js +2 -1
- package/lib/screenplay/model/index.js.map +1 -0
- package/lib/screenplay/questions/Expectation.d.ts +11 -0
- package/lib/screenplay/questions/Expectation.js +18 -1
- package/lib/screenplay/questions/Expectation.js.map +1 -1
- package/lib/screenplay/questions/List.d.ts +22 -191
- package/lib/screenplay/questions/List.js +162 -208
- package/lib/screenplay/questions/List.js.map +1 -1
- package/lib/screenplay/questions/Note.d.ts +10 -0
- package/lib/screenplay/questions/Note.js +17 -1
- package/lib/screenplay/questions/Note.js.map +1 -1
- package/lib/screenplay/questions/index.d.ts +0 -3
- package/lib/screenplay/questions/index.js +0 -5
- package/lib/screenplay/questions/index.js.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +2 -1
- package/src/io/ErrorSerialiser.ts +5 -1
- package/src/io/asyncMap.ts +18 -0
- package/src/io/format.ts +46 -0
- package/src/io/formatted.ts +7 -15
- package/src/io/index.ts +2 -1
- package/src/io/inspected.ts +66 -14
- package/src/model/Timestamp.ts +10 -2
- package/src/screenplay/Question.ts +21 -119
- package/src/screenplay/actor/Actor.ts +2 -2
- package/src/screenplay/index.ts +1 -1
- package/src/screenplay/model/Adapter.ts +14 -0
- package/src/screenplay/model/createAdapter.ts +142 -0
- package/src/screenplay/model/index.ts +2 -0
- package/src/screenplay/questions/Expectation.ts +20 -1
- package/src/screenplay/questions/List.ts +228 -232
- package/src/screenplay/questions/Note.ts +21 -1
- package/src/screenplay/questions/index.ts +0 -3
- package/lib/io/collections/index.d.ts +0 -2
- package/lib/io/collections/index.js +0 -15
- package/lib/io/collections/index.js.map +0 -1
- package/lib/io/collections/mappable.d.ts +0 -52
- package/lib/io/collections/mappable.js +0 -28
- package/lib/io/collections/mappable.js.map +0 -1
- package/lib/io/collections/reducible.d.ts +0 -16
- package/lib/io/collections/reducible.js.map +0 -1
- package/lib/screenplay/questions/Property.d.ts +0 -91
- package/lib/screenplay/questions/Property.js +0 -99
- package/lib/screenplay/questions/Property.js.map +0 -1
- package/lib/screenplay/questions/Transform.d.ts +0 -31
- package/lib/screenplay/questions/Transform.js +0 -46
- package/lib/screenplay/questions/Transform.js.map +0 -1
- package/lib/screenplay/questions/lists/ArrayListAdapter.d.ts +0 -88
- package/lib/screenplay/questions/lists/ArrayListAdapter.js +0 -152
- package/lib/screenplay/questions/lists/ArrayListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/ListAdapter.d.ts +0 -20
- package/lib/screenplay/questions/lists/ListAdapter.js +0 -3
- package/lib/screenplay/questions/lists/ListAdapter.js.map +0 -1
- package/lib/screenplay/questions/lists/index.d.ts +0 -2
- package/lib/screenplay/questions/lists/index.js +0 -15
- package/lib/screenplay/questions/lists/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.d.ts +0 -11
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.js +0 -3
- package/lib/screenplay/questions/mappings/AnswerMappingFunction.js.map +0 -1
- package/lib/screenplay/questions/mappings/index.d.ts +0 -2
- package/lib/screenplay/questions/mappings/index.js +0 -15
- package/lib/screenplay/questions/mappings/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/append.d.ts +0 -14
- package/lib/screenplay/questions/mappings/string/append.js +0 -25
- package/lib/screenplay/questions/mappings/string/append.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/index.d.ts +0 -11
- package/lib/screenplay/questions/mappings/string/index.js +0 -24
- package/lib/screenplay/questions/mappings/string/index.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/normalize.d.ts +0 -20
- package/lib/screenplay/questions/mappings/string/normalize.js +0 -30
- package/lib/screenplay/questions/mappings/string/normalize.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/replace.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/replace.js +0 -30
- package/lib/screenplay/questions/mappings/string/replace.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/slice.d.ts +0 -28
- package/lib/screenplay/questions/mappings/string/slice.js +0 -47
- package/lib/screenplay/questions/mappings/string/slice.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/split.d.ts +0 -19
- package/lib/screenplay/questions/mappings/string/split.js +0 -36
- package/lib/screenplay/questions/mappings/string/split.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js +0 -28
- package/lib/screenplay/questions/mappings/string/toLocaleLowerCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.d.ts +0 -17
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js +0 -29
- package/lib/screenplay/questions/mappings/string/toLocaleUpperCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toLowerCase.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toLowerCase.js +0 -19
- package/lib/screenplay/questions/mappings/string/toLowerCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toNumber.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toNumber.js +0 -18
- package/lib/screenplay/questions/mappings/string/toNumber.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/toUpperCase.d.ts +0 -10
- package/lib/screenplay/questions/mappings/string/toUpperCase.js +0 -19
- package/lib/screenplay/questions/mappings/string/toUpperCase.js.map +0 -1
- package/lib/screenplay/questions/mappings/string/trim.d.ts +0 -12
- package/lib/screenplay/questions/mappings/string/trim.js +0 -21
- package/lib/screenplay/questions/mappings/string/trim.js.map +0 -1
- package/lib/screenplay/questions/proxies/PropertyPathKey.d.ts +0 -4
- package/lib/screenplay/questions/proxies/PropertyPathKey.js +0 -3
- package/lib/screenplay/questions/proxies/PropertyPathKey.js.map +0 -1
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.d.ts +0 -14
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js +0 -35
- package/lib/screenplay/questions/proxies/createMetaQuestionProxy.js.map +0 -1
- package/lib/screenplay/questions/proxies/createQuestionProxy.d.ts +0 -13
- package/lib/screenplay/questions/proxies/createQuestionProxy.js +0 -34
- package/lib/screenplay/questions/proxies/createQuestionProxy.js.map +0 -1
- package/lib/screenplay/questions/proxies/describePath.d.ts +0 -5
- package/lib/screenplay/questions/proxies/describePath.js +0 -19
- package/lib/screenplay/questions/proxies/describePath.js.map +0 -1
- package/lib/screenplay/questions/proxies/index.d.ts +0 -2
- package/lib/screenplay/questions/proxies/index.js +0 -15
- package/lib/screenplay/questions/proxies/index.js.map +0 -1
- package/lib/screenplay/questions/proxies/key.d.ts +0 -8
- package/lib/screenplay/questions/proxies/key.js +0 -16
- package/lib/screenplay/questions/proxies/key.js.map +0 -1
- package/lib/screenplay/tasks/Loop.d.ts +0 -198
- package/lib/screenplay/tasks/Loop.js +0 -222
- package/lib/screenplay/tasks/Loop.js.map +0 -1
- package/lib/screenplay/tasks/index.d.ts +0 -1
- package/lib/screenplay/tasks/index.js.map +0 -1
- package/src/io/collections/index.ts +0 -2
- package/src/io/collections/mappable.ts +0 -60
- package/src/io/collections/reducible.ts +0 -16
- package/src/screenplay/questions/Property.ts +0 -98
- package/src/screenplay/questions/Transform.ts +0 -51
- package/src/screenplay/questions/lists/ArrayListAdapter.ts +0 -186
- package/src/screenplay/questions/lists/ListAdapter.ts +0 -33
- package/src/screenplay/questions/lists/index.ts +0 -2
- package/src/screenplay/questions/mappings/AnswerMappingFunction.ts +0 -13
- package/src/screenplay/questions/mappings/index.ts +0 -2
- package/src/screenplay/questions/mappings/string/append.ts +0 -28
- package/src/screenplay/questions/mappings/string/index.ts +0 -11
- package/src/screenplay/questions/mappings/string/normalize.ts +0 -33
- package/src/screenplay/questions/mappings/string/replace.ts +0 -34
- package/src/screenplay/questions/mappings/string/slice.ts +0 -53
- package/src/screenplay/questions/mappings/string/split.ts +0 -38
- package/src/screenplay/questions/mappings/string/toLocaleLowerCase.ts +0 -31
- package/src/screenplay/questions/mappings/string/toLocaleUpperCase.ts +0 -30
- package/src/screenplay/questions/mappings/string/toLowerCase.ts +0 -20
- package/src/screenplay/questions/mappings/string/toNumber.ts +0 -19
- package/src/screenplay/questions/mappings/string/toUpperCase.ts +0 -20
- package/src/screenplay/questions/mappings/string/trim.ts +0 -22
- package/src/screenplay/questions/proxies/PropertyPathKey.ts +0 -4
- package/src/screenplay/questions/proxies/createMetaQuestionProxy.ts +0 -51
- package/src/screenplay/questions/proxies/createQuestionProxy.ts +0 -49
- package/src/screenplay/questions/proxies/describePath.ts +0 -23
- package/src/screenplay/questions/proxies/index.ts +0 -2
- package/src/screenplay/questions/proxies/key.ts +0 -14
- package/src/screenplay/tasks/Loop.ts +0 -240
- package/src/screenplay/tasks/index.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,82 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0-rc.3](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.2...v3.0.0-rc.3) (2021-12-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** refactored Mappable so that it's easier to implement filters ([176e0cd](https://github.com/serenity-js/serenity-js/commit/176e0cd0303d63271477b2b7a8e7b0572dda99a0)), closes [#1074](https://github.com/serenity-js/serenity-js/issues/1074)
|
|
12
|
+
* **core:** removed interface Reducible since it's not used any more ([1e9f23b](https://github.com/serenity-js/serenity-js/commit/1e9f23b227e3c4509dd52d6885cde5d3ecd1d102))
|
|
13
|
+
* **deps:** updated tiny-types to 1.17.0 ([3187051](https://github.com/serenity-js/serenity-js/commit/3187051594158b4b450c82e851e417fd2ed21652))
|
|
14
|
+
* **web:** corrected synchronisation in Web questions and interactions ([c3a0ad1](https://github.com/serenity-js/serenity-js/commit/c3a0ad16de311e71d7e82e4f463baa0ca6b18863))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **core:** forEach for List and PageElements ([4592fb7](https://github.com/serenity-js/serenity-js/commit/4592fb7e700bad17fd44d91bd9db169839802d01)), closes [#823](https://github.com/serenity-js/serenity-js/issues/823)
|
|
20
|
+
* **core:** List supports custom collectors ([cd3f2bc](https://github.com/serenity-js/serenity-js/commit/cd3f2bc1b536c8e56714aecd669bfed7ab078e0a))
|
|
21
|
+
* **core:** new implementation of List.where filters ([45b3c80](https://github.com/serenity-js/serenity-js/commit/45b3c8080ca467ac6362e5217e7899ca36a04cdc)), closes [#1074](https://github.com/serenity-js/serenity-js/issues/1074)
|
|
22
|
+
* **core:** support for Screenplay-style collection filters and mapping (List.where & .eachMappedTo) ([3d3c02e](https://github.com/serenity-js/serenity-js/commit/3d3c02ebe0ec5c6865f91f1991fd59ef0190a16c)), closes [#1074](https://github.com/serenity-js/serenity-js/issues/1074)
|
|
23
|
+
* **web:** re-introduced PageElements.where DSL and universal By selectors ([39fe0a1](https://github.com/serenity-js/serenity-js/commit/39fe0a10edf7f652e93911159e4a4689c36d6876)), closes [#1081](https://github.com/serenity-js/serenity-js/issues/1081)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# [3.0.0-rc.1](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.0...v3.0.0-rc.1) (2021-12-09)
|
|
30
|
+
|
|
31
|
+
**Note:** Version bump only for package @serenity-js/core
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# [3.0.0-rc.0](https://github.com/serenity-js/serenity-js/compare/v2.32.5...v3.0.0-rc.0) (2021-12-08)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* **core:** `formatted` can be configured to produce single- or multi-line descriptions ([21145a3](https://github.com/serenity-js/serenity-js/commit/21145a3dda17e87ea7bd950da4526b90f37a1edc))
|
|
43
|
+
* **core:** `inspected` produces a better description of functions used as parameters ([15535c6](https://github.com/serenity-js/serenity-js/commit/15535c675469651b835c0b358649a590f2c15b5d))
|
|
44
|
+
* **core:** 3.0 RC ([469d54e](https://github.com/serenity-js/serenity-js/commit/469d54e4f81ef430566b93852e3174826f8ef672)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
|
|
45
|
+
* **core:** answerProxy renamed to ProxyAnswer to better reflect its purpose ([a98fe41](https://github.com/serenity-js/serenity-js/commit/a98fe41378bc8475f027946e0f01a30f4789d57a))
|
|
46
|
+
* **core:** corrected type defs of Question.as ([681ce22](https://github.com/serenity-js/serenity-js/commit/681ce22259bf75161df7ce2454f4b6d73ea87259))
|
|
47
|
+
* **core:** exported createProxyAnswer to make it easier to use ([5471989](https://github.com/serenity-js/serenity-js/commit/547198985025d0ede2ab47ea89d8944960fb980d))
|
|
48
|
+
* **core:** removed Loop as it will be replaced ([0b63d27](https://github.com/serenity-js/serenity-js/commit/0b63d27745c905001adf3c219dd0e3cf44756320))
|
|
49
|
+
* **core:** removed Property as it will be replaced by new Question ([fd7fa10](https://github.com/serenity-js/serenity-js/commit/fd7fa10dfbaa0c0cba059c5f18920609c4bac014))
|
|
50
|
+
* **core:** removed Transform and mapping functions as they'll be replaced with new Question ([506eaea](https://github.com/serenity-js/serenity-js/commit/506eaeaf2df22cfde5d7ca6a8f413fc053556c2b))
|
|
51
|
+
* **core:** renamed "Model" type to "Adapter" to better reflect its purpose ([b4ea7a1](https://github.com/serenity-js/serenity-js/commit/b4ea7a100fac2c896990bf15cbc906de641196b8)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
|
|
52
|
+
* **cucumber:** support for recognising non-Serenity AssertionErrors in older version of Cucumber ([31e9e99](https://github.com/serenity-js/serenity-js/commit/31e9e9919c2fd1e87b3f4405d9b2a6ae0164e893))
|
|
53
|
+
* **web:** wordsmithing of interface names ([5a1e76a](https://github.com/serenity-js/serenity-js/commit/5a1e76a9c162370e17238fcccc9f08e109d543c3))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
* **core:** question.about creates a proxy around the answer to simplify the API ([25e0841](https://github.com/serenity-js/serenity-js/commit/25e084116ad28a02b55fbd8814b6ffa0375ec433))
|
|
59
|
+
* **core:** question.about produces "props" that proxy the methods of the underlying model ([f771872](https://github.com/serenity-js/serenity-js/commit/f771872c56b487e404002c3800fc8f3baaed804f))
|
|
60
|
+
* **web:** Page.url() and Page.title() replace Website.url() and Website.title() ([49fe009](https://github.com/serenity-js/serenity-js/commit/49fe0094422ab53ec67d4ba303f80c33e382eebd)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
|
|
61
|
+
* **web:** removed Target in favour of PageElement ([69496c4](https://github.com/serenity-js/serenity-js/commit/69496c47c4a1ec7b92e7ab6c83da1559e926f28e)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
|
|
62
|
+
* **web:** support for working with cookies ([39cde6d](https://github.com/serenity-js/serenity-js/commit/39cde6de7a36d27a8b1c596493efbec94900af6b)), closes [#805](https://github.com/serenity-js/serenity-js/issues/805)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### BREAKING CHANGES
|
|
66
|
+
|
|
67
|
+
* **core:** Introduced @serenity-js/web - a shared library for Serenity/JS Web integration
|
|
68
|
+
modules such as @serenity-js/protractor and @serenity-js/webdriverio. Dropped support for Node 12.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## [2.32.5](https://github.com/serenity-js/serenity-js/compare/v2.32.4...v2.32.5) (2021-12-08)
|
|
75
|
+
|
|
76
|
+
**Note:** Version bump only for package @serenity-js/core
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
6
82
|
## [2.32.4](https://github.com/serenity-js/serenity-js/compare/v2.32.3...v2.32.4) (2021-11-25)
|
|
7
83
|
|
|
8
84
|
**Note:** Version bump only for package @serenity-js/core
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './errors';
|
|
2
2
|
export * from './instance';
|
|
3
|
-
export {
|
|
3
|
+
export { format } from './io';
|
|
4
|
+
export { Duration, Timestamp } from './model';
|
|
4
5
|
export * from './screenplay';
|
|
5
6
|
export * from './Serenity';
|
|
6
7
|
export { SerenityConfig } from './SerenityConfig';
|
package/lib/index.js
CHANGED
|
@@ -10,11 +10,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.SerenityConfig = exports.Duration = void 0;
|
|
13
|
+
exports.SerenityConfig = exports.Timestamp = exports.Duration = exports.format = void 0;
|
|
14
14
|
__exportStar(require("./errors"), exports);
|
|
15
15
|
__exportStar(require("./instance"), exports);
|
|
16
|
+
var io_1 = require("./io");
|
|
17
|
+
Object.defineProperty(exports, "format", { enumerable: true, get: function () { return io_1.format; } });
|
|
16
18
|
var model_1 = require("./model");
|
|
17
19
|
Object.defineProperty(exports, "Duration", { enumerable: true, get: function () { return model_1.Duration; } });
|
|
20
|
+
Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return model_1.Timestamp; } });
|
|
18
21
|
__exportStar(require("./screenplay"), exports);
|
|
19
22
|
__exportStar(require("./Serenity"), exports);
|
|
20
23
|
var SerenityConfig_1 = require("./SerenityConfig");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAyB;AACzB,6CAA2B;AAC3B,2BAA8B;AAArB,4FAAA,MAAM,OAAA;AACf,iCAA8C;AAArC,iGAAA,QAAQ,OAAA;AAAE,kGAAA,SAAS,OAAA;AAC5B,+CAA6B;AAC7B,6CAA2B;AAC3B,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,0CAAwB"}
|
|
@@ -5,10 +5,13 @@ const serenitySpecificErrors = require("../errors");
|
|
|
5
5
|
const json_1 = require("./json");
|
|
6
6
|
class ErrorSerialiser {
|
|
7
7
|
static serialise(error) {
|
|
8
|
+
const name = error && error.constructor && error.constructor.name
|
|
9
|
+
? error.constructor.name
|
|
10
|
+
: error.name;
|
|
8
11
|
const serialisedError = Object.getOwnPropertyNames(error).reduce((serialised, key) => {
|
|
9
12
|
serialised[key] = error[key];
|
|
10
13
|
return serialised;
|
|
11
|
-
}, { name
|
|
14
|
+
}, { name });
|
|
12
15
|
return (0, json_1.stringify)(serialisedError);
|
|
13
16
|
}
|
|
14
17
|
static deserialise(stringifiedError) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorSerialiser.js","sourceRoot":"","sources":["../../src/io/ErrorSerialiser.ts"],"names":[],"mappings":";;;AAEA,oDAAoD;AACpD,iCAA0C;AAyB1C,MAAa,eAAe;IAYxB,MAAM,CAAC,SAAS,CAAC,KAAY;QACzB,MAAM,eAAe,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE;YACjF,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;YAC5B,OAAO,UAAU,CAAC;QACtB,CAAC,EAAE,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"ErrorSerialiser.js","sourceRoot":"","sources":["../../src/io/ErrorSerialiser.ts"],"names":[],"mappings":";;;AAEA,oDAAoD;AACpD,iCAA0C;AAyB1C,MAAa,eAAe;IAYxB,MAAM,CAAC,SAAS,CAAC,KAAY;QACzB,MAAM,IAAI,GAAG,KAAK,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK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C;SACnC;QAED,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAE,GAAG,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAEtE,OAAO,eAAe,CAAC,WAAW,CAAC,IAAA,gBAAS,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC5F,CAAC;;AAhDL,0CAiDC;AAhDkB,gCAAgB,GAAG;IAC9B,GAAG,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC9E,KAAK;IACL,SAAS;IACT,UAAU;IACV,cAAc;IACd,WAAW;IACX,SAAS;IACT,QAAQ;CACX,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @desc
|
|
3
|
+
* Maps an Array<Item_Type> to an Array<Result_Type>, one element at a time.
|
|
4
|
+
*
|
|
5
|
+
* @param {Array<Item_Type>} items
|
|
6
|
+
* @param {function(item: Item_Type): Promise<Result_Type>} mappingFunction
|
|
7
|
+
*/
|
|
8
|
+
export declare function asyncMap<Item_Type, Result_Type>(items: Item_Type[], mappingFunction: (item: Item_Type) => Promise<Result_Type> | Result_Type): Promise<Result_Type[]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @desc
|
|
6
|
+
* Maps an Array<Item_Type> to an Array<Result_Type>, one element at a time.
|
|
7
|
+
*
|
|
8
|
+
* @param {Array<Item_Type>} items
|
|
9
|
+
* @param {function(item: Item_Type): Promise<Result_Type>} mappingFunction
|
|
10
|
+
*/
|
|
11
|
+
function asyncMap(items, mappingFunction) {
|
|
12
|
+
return items.reduce((previous, item) => previous.then(async (acc) => {
|
|
13
|
+
const result = await mappingFunction(item);
|
|
14
|
+
return acc.concat(result);
|
|
15
|
+
}), Promise.resolve([]));
|
|
16
|
+
}
|
|
17
|
+
exports.asyncMap = asyncMap;
|
|
18
|
+
//# sourceMappingURL=asyncMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asyncMap.js","sourceRoot":"","sources":["../../src/io/asyncMap.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAyB,KAAkB,EAAE,eAAwE;IACzI,OAAO,KAAK,CAAC,MAAM,CACf,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CACf,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;QAE3C,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC,EACJ,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CACxB,CAAC;AACN,CAAC;AAVD,4BAUC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Answerable } from '../screenplay';
|
|
2
|
+
/**
|
|
3
|
+
* @desc
|
|
4
|
+
* A factory function returning a tag function that produces a human-readable description of a template containing one or more {@link Answerable}s.
|
|
5
|
+
*
|
|
6
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { format, Question } from '@serenity-js/core';
|
|
10
|
+
*
|
|
11
|
+
* const someQuestion = () =>
|
|
12
|
+
* Question.about('some question', actor => 'some value');
|
|
13
|
+
*
|
|
14
|
+
* format({ markQuestions: true }) `actor answers ${ question() }`;
|
|
15
|
+
* // returns: actor answers <<some question>>
|
|
16
|
+
*
|
|
17
|
+
* format({ markQuestions: false }) `actor answers ${ question() }`;
|
|
18
|
+
* // returns: actor answers <<some question>>
|
|
19
|
+
*
|
|
20
|
+
* @example <caption>Aliasing</caption>
|
|
21
|
+
* import { format, Question } from '@serenity-js/core';
|
|
22
|
+
*
|
|
23
|
+
* const f = format({ markQuestions: true });
|
|
24
|
+
*
|
|
25
|
+
* const someQuestion = () =>
|
|
26
|
+
* Question.about('some question', actor => 'some value');
|
|
27
|
+
*
|
|
28
|
+
* f `actor answers ${ question() }`;
|
|
29
|
+
* // produces: actor answers <<some question>>
|
|
30
|
+
*
|
|
31
|
+
* @param {object} config
|
|
32
|
+
* - `markQuestions`: boolean - if set to true, descriptions of questions passed in as arguments will be surrounded with double angled brackets, i.e. `<<description>>`
|
|
33
|
+
* @returns {function(templates: TemplateStringsArray, placeholders: ...Array<Answerable<any>>): string}
|
|
34
|
+
*/
|
|
35
|
+
export declare function format(config: {
|
|
36
|
+
markQuestions: boolean;
|
|
37
|
+
}): (templates: TemplateStringsArray, ...placeholders: Array<Answerable<any>>) => string;
|
package/lib/io/format.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.format = void 0;
|
|
4
|
+
const inspected_1 = require("./inspected");
|
|
5
|
+
/**
|
|
6
|
+
* @desc
|
|
7
|
+
* A factory function returning a tag function that produces a human-readable description of a template containing one or more {@link Answerable}s.
|
|
8
|
+
*
|
|
9
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { format, Question } from '@serenity-js/core';
|
|
13
|
+
*
|
|
14
|
+
* const someQuestion = () =>
|
|
15
|
+
* Question.about('some question', actor => 'some value');
|
|
16
|
+
*
|
|
17
|
+
* format({ markQuestions: true }) `actor answers ${ question() }`;
|
|
18
|
+
* // returns: actor answers <<some question>>
|
|
19
|
+
*
|
|
20
|
+
* format({ markQuestions: false }) `actor answers ${ question() }`;
|
|
21
|
+
* // returns: actor answers <<some question>>
|
|
22
|
+
*
|
|
23
|
+
* @example <caption>Aliasing</caption>
|
|
24
|
+
* import { format, Question } from '@serenity-js/core';
|
|
25
|
+
*
|
|
26
|
+
* const f = format({ markQuestions: true });
|
|
27
|
+
*
|
|
28
|
+
* const someQuestion = () =>
|
|
29
|
+
* Question.about('some question', actor => 'some value');
|
|
30
|
+
*
|
|
31
|
+
* f `actor answers ${ question() }`;
|
|
32
|
+
* // produces: actor answers <<some question>>
|
|
33
|
+
*
|
|
34
|
+
* @param {object} config
|
|
35
|
+
* - `markQuestions`: boolean - if set to true, descriptions of questions passed in as arguments will be surrounded with double angled brackets, i.e. `<<description>>`
|
|
36
|
+
* @returns {function(templates: TemplateStringsArray, placeholders: ...Array<Answerable<any>>): string}
|
|
37
|
+
*/
|
|
38
|
+
function format(config) {
|
|
39
|
+
return (templates, ...placeholders) => {
|
|
40
|
+
return templates
|
|
41
|
+
.map((template, i) => i < placeholders.length
|
|
42
|
+
? [template, (0, inspected_1.inspected)(placeholders[i], { inline: true, markQuestions: config.markQuestions })]
|
|
43
|
+
: [template])
|
|
44
|
+
.reduce((acc, tuple) => acc.concat(tuple))
|
|
45
|
+
.join('');
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.format = format;
|
|
49
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/io/format.ts"],"names":[],"mappings":";;;AACA,2CAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,MAAM,CAAC,MAAkC;IACrD,OAAO,CAAC,SAA+B,EAAE,GAAG,YAAoC,EAAU,EAAE;QACxF,OAAO,SAAS;aACX,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM;YACzC,CAAC,CAAC,CAAE,QAAQ,EAAE,IAAA,qBAAS,EAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,CAAE;YACjG,CAAC,CAAC,CAAE,QAAQ,CAAE,CAAC;aAClB,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aACzC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC,CAAA;AACL,CAAC;AATD,wBASC"}
|
package/lib/io/formatted.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Answerable } from '../screenplay
|
|
1
|
+
import { Answerable } from '../screenplay';
|
|
2
2
|
/**
|
|
3
3
|
* @desc
|
|
4
4
|
* A tag function returning a human-readable description of a template containing one or more {@link Answerable}s.
|
|
5
|
+
* This function is deprecated, please use {@link format} instead.
|
|
5
6
|
*
|
|
6
7
|
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
7
8
|
*
|
|
9
|
+
*
|
|
10
|
+
* @deprecated
|
|
11
|
+
*
|
|
8
12
|
* @param {TemplateStringsArray} templates
|
|
9
13
|
* @param {Array<Answerable<any>>} placeholders
|
|
10
14
|
* @returns {string}
|
package/lib/io/formatted.js
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatted = void 0;
|
|
4
|
-
const
|
|
4
|
+
const format_1 = require("./format");
|
|
5
5
|
/**
|
|
6
6
|
* @desc
|
|
7
7
|
* A tag function returning a human-readable description of a template containing one or more {@link Answerable}s.
|
|
8
|
+
* This function is deprecated, please use {@link format} instead.
|
|
8
9
|
*
|
|
9
10
|
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
|
|
10
11
|
*
|
|
12
|
+
*
|
|
13
|
+
* @deprecated
|
|
14
|
+
*
|
|
11
15
|
* @param {TemplateStringsArray} templates
|
|
12
16
|
* @param {Array<Answerable<any>>} placeholders
|
|
13
17
|
* @returns {string}
|
|
14
18
|
*/
|
|
15
19
|
function formatted(templates, ...placeholders) {
|
|
16
|
-
return templates
|
|
17
|
-
.map((template, i) => i < placeholders.length
|
|
18
|
-
? [template, compacted((0, inspected_1.inspected)(placeholders[i]))]
|
|
19
|
-
: [template])
|
|
20
|
-
.reduce((acc, tuple) => acc.concat(tuple))
|
|
21
|
-
.join('');
|
|
20
|
+
return (0, format_1.format)({ markQuestions: false })(templates, ...placeholders);
|
|
22
21
|
}
|
|
23
22
|
exports.formatted = formatted;
|
|
24
|
-
/** @private */
|
|
25
|
-
function compacted(multiline) {
|
|
26
|
-
return multiline
|
|
27
|
-
.replace(/\r?\n/g, ' ')
|
|
28
|
-
.replace(/\s+/g, ' ');
|
|
29
|
-
}
|
|
30
23
|
//# sourceMappingURL=formatted.js.map
|
package/lib/io/formatted.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatted.js","sourceRoot":"","sources":["../../src/io/formatted.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"formatted.js","sourceRoot":"","sources":["../../src/io/formatted.ts"],"names":[],"mappings":";;;AACA,qCAAkC;AAElC;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CAAC,SAA+B,EAAE,GAAG,YAAoC;IAC9F,OAAO,IAAA,eAAM,EAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,YAAY,CAAC,CAAC;AACxE,CAAC;AAFD,8BAEC"}
|
package/lib/io/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './AssertionReportDiffer';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './asyncMap';
|
|
3
3
|
export * from './commaSeparated';
|
|
4
4
|
export * from './Config';
|
|
5
5
|
export * from './ErrorSerialiser';
|
|
@@ -7,6 +7,7 @@ export * from './ErrorStackParser';
|
|
|
7
7
|
export * from './FileFinder';
|
|
8
8
|
export * from './FileSystem';
|
|
9
9
|
export * from './FileSystemLocation';
|
|
10
|
+
export * from './format';
|
|
10
11
|
export * from './formatted';
|
|
11
12
|
export * from './json';
|
|
12
13
|
export * from './ModuleLoader';
|
package/lib/io/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./AssertionReportDiffer"), exports);
|
|
14
|
-
__exportStar(require("./
|
|
14
|
+
__exportStar(require("./asyncMap"), exports);
|
|
15
15
|
__exportStar(require("./commaSeparated"), exports);
|
|
16
16
|
__exportStar(require("./Config"), exports);
|
|
17
17
|
__exportStar(require("./ErrorSerialiser"), exports);
|
|
@@ -19,6 +19,7 @@ __exportStar(require("./ErrorStackParser"), exports);
|
|
|
19
19
|
__exportStar(require("./FileFinder"), exports);
|
|
20
20
|
__exportStar(require("./FileSystem"), exports);
|
|
21
21
|
__exportStar(require("./FileSystemLocation"), exports);
|
|
22
|
+
__exportStar(require("./format"), exports);
|
|
22
23
|
__exportStar(require("./formatted"), exports);
|
|
23
24
|
__exportStar(require("./json"), exports);
|
|
24
25
|
__exportStar(require("./ModuleLoader"), exports);
|
package/lib/io/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAwC;AACxC,6CAA2B;AAC3B,mDAAiC;AACjC,2CAAyB;AACzB,oDAAkC;AAClC,qDAAmC;AACnC,+CAA6B;AAC7B,+CAA6B;AAC7B,uDAAqC;AACrC,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB;AACvB,iDAA+B;AAC/B,iDAA+B;AAC/B,yCAAuB;AACvB,+CAA6B;AAC7B,sDAAoC;AACpC,4CAA0B;AAC1B,4CAA0B"}
|
package/lib/io/inspected.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Answerable } from '../screenplay/Answerable';
|
|
2
|
+
interface InspectedConfig {
|
|
3
|
+
inline: boolean;
|
|
4
|
+
markQuestions?: boolean;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* @desc
|
|
4
8
|
* Provides a human-readable description of the {@link Answerable<T>}.
|
|
@@ -6,6 +10,10 @@ import { Answerable } from '../screenplay/Answerable';
|
|
|
6
10
|
*
|
|
7
11
|
* @public
|
|
8
12
|
* @param {Answerable<any>} value
|
|
13
|
+
* @param config
|
|
14
|
+
* - inline - Return a single-line string instead of the default potentially multi-line description
|
|
15
|
+
* - markQuestions - Surround the description of async values, such as Promises and Questions with <<value>>
|
|
9
16
|
* @return {string}
|
|
10
17
|
*/
|
|
11
|
-
export declare function inspected(value: Answerable<any
|
|
18
|
+
export declare function inspected(value: Answerable<any>, config?: InspectedConfig): string;
|
|
19
|
+
export {};
|
package/lib/io/inspected.js
CHANGED
|
@@ -10,24 +10,24 @@ const Question_1 = require("../screenplay/Question");
|
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
12
|
* @param {Answerable<any>} value
|
|
13
|
+
* @param config
|
|
14
|
+
* - inline - Return a single-line string instead of the default potentially multi-line description
|
|
15
|
+
* - markQuestions - Surround the description of async values, such as Promises and Questions with <<value>>
|
|
13
16
|
* @return {string}
|
|
14
17
|
*/
|
|
15
|
-
function inspected(value) {
|
|
18
|
+
function inspected(value, config) {
|
|
19
|
+
const { inline, markQuestions } = { inline: false, markQuestions: false, ...config };
|
|
16
20
|
if (!isDefined(value)) {
|
|
17
21
|
return (0, util_1.inspect)(value);
|
|
18
22
|
}
|
|
19
23
|
if (Array.isArray(value)) {
|
|
20
|
-
return
|
|
21
|
-
'[',
|
|
22
|
-
value.map(item => ` ${inspected(item)}`).join(',\n'),
|
|
23
|
-
']',
|
|
24
|
-
].join('\n');
|
|
24
|
+
return stringifiedArray(value, inline);
|
|
25
25
|
}
|
|
26
26
|
if (isAPromise(value)) {
|
|
27
|
-
return
|
|
27
|
+
return markAs('Promise', true);
|
|
28
28
|
}
|
|
29
29
|
if (Question_1.Question.isAQuestion(value)) {
|
|
30
|
-
return value.toString();
|
|
30
|
+
return markAs(value.toString(), markQuestions);
|
|
31
31
|
}
|
|
32
32
|
if (isADate(value)) {
|
|
33
33
|
return value.toISOString();
|
|
@@ -38,15 +38,41 @@ function inspected(value) {
|
|
|
38
38
|
if (isInspectable(value)) {
|
|
39
39
|
return value.inspect();
|
|
40
40
|
}
|
|
41
|
-
if (
|
|
42
|
-
return
|
|
41
|
+
if (isAFunction(value)) {
|
|
42
|
+
return hasName(value)
|
|
43
|
+
? value.name
|
|
44
|
+
: markAs(`Function`, true);
|
|
43
45
|
}
|
|
44
46
|
if (!hasCustomInspectionFunction(value) && isPlainObject(value) && isSerialisableAsJSON(value)) {
|
|
45
|
-
return
|
|
47
|
+
return stringifiedToJson(value, inline);
|
|
46
48
|
}
|
|
47
|
-
return (0, util_1.inspect)(value, { breakLength: Number.POSITIVE_INFINITY, compact:
|
|
49
|
+
return (0, util_1.inspect)(value, { breakLength: Number.POSITIVE_INFINITY, compact: inline ? 3 : false, sorted: false });
|
|
48
50
|
}
|
|
49
51
|
exports.inspected = inspected;
|
|
52
|
+
function stringifiedToJson(value, inline) {
|
|
53
|
+
const indentation = inline ? 0 : 4;
|
|
54
|
+
return JSON.stringify(value, undefined, indentation);
|
|
55
|
+
}
|
|
56
|
+
function stringifiedArray(value, inline) {
|
|
57
|
+
const indentation = inline ? '' : ' ';
|
|
58
|
+
const separator = inline ? ' ' : '\n';
|
|
59
|
+
const inspectedItem = (item, index) => [
|
|
60
|
+
indentation,
|
|
61
|
+
inspected(item, { inline, markQuestions: true }),
|
|
62
|
+
index < value.length - 1 ? ',' : ''
|
|
63
|
+
].join('');
|
|
64
|
+
return [
|
|
65
|
+
'[',
|
|
66
|
+
...value.map(inspectedItem),
|
|
67
|
+
']',
|
|
68
|
+
].join(separator);
|
|
69
|
+
}
|
|
70
|
+
function markAs(value, markValue) {
|
|
71
|
+
const [left, right] = markValue && !value.startsWith('<<')
|
|
72
|
+
? ['<<', '>>']
|
|
73
|
+
: ['', ''];
|
|
74
|
+
return [left, value, right].join('');
|
|
75
|
+
}
|
|
50
76
|
/**
|
|
51
77
|
* @desc
|
|
52
78
|
* Checks if the value is defined
|
|
@@ -107,8 +133,18 @@ function isAPromise(v) {
|
|
|
107
133
|
* @private
|
|
108
134
|
* @param {Answerable<any>} v
|
|
109
135
|
*/
|
|
110
|
-
function
|
|
111
|
-
return Object.prototype.toString.call(v) === '[object Function]'
|
|
136
|
+
function isAFunction(v) {
|
|
137
|
+
return Object.prototype.toString.call(v) === '[object Function]';
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @desc
|
|
141
|
+
* Checks if the value is has a property called 'name' with a non-empty value.
|
|
142
|
+
*
|
|
143
|
+
* @private
|
|
144
|
+
* @param {Answerable<any>} v
|
|
145
|
+
*/
|
|
146
|
+
function hasName(v) {
|
|
147
|
+
return typeof v.name === 'string' && v.name !== '';
|
|
112
148
|
}
|
|
113
149
|
/**
|
|
114
150
|
* @desc
|
package/lib/io/inspected.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspected.js","sourceRoot":"","sources":["../../src/io/inspected.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAG/B,qDAAkD;
|
|
1
|
+
{"version":3,"file":"inspected.js","sourceRoot":"","sources":["../../src/io/inspected.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAG/B,q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AAC;YAChB,uCAAuC;aAClC,OAAO,CAAC,sBAAsB,EAAG,MAAM,CAAC;YACzC,0EAA0E;YAC1E,uFAAuF;YACvF,wBAAwB;aACvB,OAAO,CAAC,iDAAiD,EAAE,OAAO,CAAC;QACxE,GAAG,CACN,CAAC;IAEF,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC;IACtB,OAAO,IAAI,KAAK,UAAU;QACtB,sEAAsE;QACtE,6BAA6B;QAC7B,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,2EAA2E;QAC3E,uEAAuE;QACvE,yBAAyB;QACzB,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;AACtF,CAAC"}
|
package/lib/model/Timestamp.d.ts
CHANGED
|
@@ -3,12 +3,14 @@ import { Duration } from './Duration';
|
|
|
3
3
|
export declare class Timestamp extends TinyType {
|
|
4
4
|
readonly value: Date;
|
|
5
5
|
static fromJSON(v: string): Timestamp;
|
|
6
|
-
static
|
|
6
|
+
static fromTimestampInSeconds(v: number): Timestamp;
|
|
7
|
+
static fromTimestampInMilliseconds(v: number): Timestamp;
|
|
7
8
|
constructor(value?: Date);
|
|
8
9
|
diff(another: Timestamp): Duration;
|
|
9
10
|
plus(duration: Duration): Timestamp;
|
|
10
11
|
less(duration: Duration): Timestamp;
|
|
11
|
-
|
|
12
|
+
toMilliseconds(): number;
|
|
13
|
+
toSeconds(): number;
|
|
12
14
|
toJSON(): string;
|
|
13
15
|
toString(): string;
|
|
14
16
|
}
|
package/lib/model/Timestamp.js
CHANGED
|
@@ -13,7 +13,10 @@ class Timestamp extends tiny_types_1.TinyType {
|
|
|
13
13
|
static fromJSON(v) {
|
|
14
14
|
return new Timestamp(new Date((0, tiny_types_1.ensure)(Timestamp.name, v, isSerialisedISO8601Date())));
|
|
15
15
|
}
|
|
16
|
-
static
|
|
16
|
+
static fromTimestampInSeconds(v) {
|
|
17
|
+
return Timestamp.fromTimestampInMilliseconds(v * 1000);
|
|
18
|
+
}
|
|
19
|
+
static fromTimestampInMilliseconds(v) {
|
|
17
20
|
return new Timestamp(moment(v).toDate());
|
|
18
21
|
}
|
|
19
22
|
diff(another) {
|
|
@@ -25,9 +28,12 @@ class Timestamp extends tiny_types_1.TinyType {
|
|
|
25
28
|
less(duration) {
|
|
26
29
|
return new Timestamp(moment(this.value).subtract(duration.inMilliseconds(), 'ms').toDate());
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
toMilliseconds() {
|
|
29
32
|
return moment(this.value).valueOf();
|
|
30
33
|
}
|
|
34
|
+
toSeconds() {
|
|
35
|
+
return moment(this.value).unix();
|
|
36
|
+
}
|
|
31
37
|
toJSON() {
|
|
32
38
|
return this.value.toJSON();
|
|
33
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timestamp.js","sourceRoot":"","sources":["../../src/model/Timestamp.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2CAAkF;AAElF,yCAAsC;AAEtC,MAAa,SAAU,SAAQ,qBAAQ;
|
|
1
|
+
{"version":3,"file":"Timestamp.js","sourceRoot":"","sources":["../../src/model/Timestamp.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2CAAkF;AAElF,yCAAsC;AAEtC,MAAa,SAAU,SAAQ,qBAAQ;IAanC,YAA4B,QAAc,IAAI,IAAI,EAAE;QAChD,KAAK,EAAE,CAAC;QADgB,UAAK,GAAL,KAAK,CAAmB;QAEhD,IAAA,mBAAM,EAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,IAAA,sBAAS,GAAE,EAAE,IAAA,yBAAY,EAAC,IAAI,CAAC,CAAC,CAAC;IACnE,CAAC;IAfD,MAAM,CAAC,QAAQ,CAAC,CAAS;QACrB,OAAO,I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