@sera4/essentia 1.1.66-rc.1 → 3.0.8
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 +352 -8
- package/dist/ts/index.d.ts +1 -1
- package/dist/ts/index.js +1 -1
- package/dist/ts/index.js.map +1 -1
- package/dist/ts/logger/s4-logger.js +0 -2
- package/dist/ts/logger/s4-logger.js.map +1 -1
- package/dist/ts/queue/index.d.ts +2 -38
- package/dist/ts/queue/index.js +67 -136
- package/dist/ts/queue/index.js.map +1 -1
- package/package.json +51 -12
- package/package.tar.gz +0 -0
- package/cache/index.js +0 -188
- package/constants/index.js +0 -9
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/configurations/index.html +0 -116
- package/coverage/configurations/server-config.ts.html +0 -94
- package/coverage/dns/DnsCache.ts.html +0 -598
- package/coverage/dns/index.html +0 -131
- package/coverage/dns/index.ts.html +0 -94
- package/coverage/favicon.png +0 -0
- package/coverage/health/index.html +0 -116
- package/coverage/health/index.ts.html +0 -778
- package/coverage/index.html +0 -161
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/configurations/index.html +0 -116
- package/coverage/lcov-report/configurations/server-config.ts.html +0 -94
- package/coverage/lcov-report/dns/DnsCache.ts.html +0 -598
- package/coverage/lcov-report/dns/index.html +0 -131
- package/coverage/lcov-report/dns/index.ts.html +0 -94
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/health/index.html +0 -116
- package/coverage/lcov-report/health/index.ts.html +0 -778
- package/coverage/lcov-report/index.html +0 -161
- package/coverage/lcov-report/logger/index.html +0 -131
- package/coverage/lcov-report/logger/index.ts.html +0 -94
- package/coverage/lcov-report/logger/s4-logger.ts.html +0 -514
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -747
- package/coverage/logger/index.html +0 -131
- package/coverage/logger/index.ts.html +0 -94
- package/coverage/logger/s4-logger.ts.html +0 -514
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/tmp/coverage-24302-1746472691313-0.json +0 -1
- package/coverage/tmp/coverage-24302-1746472691366-1.json +0 -1
- package/dist/cache/index.d.ts +0 -22
- package/dist/cache/index.js +0 -166
- package/dist/cache/index.js.map +0 -1
- package/dist/constants/index.d.ts +0 -6
- package/dist/constants/index.js +0 -9
- package/dist/constants/index.js.map +0 -1
- package/dist/coverage/block-navigation.d.ts +0 -1
- package/dist/coverage/block-navigation.js +0 -70
- package/dist/coverage/block-navigation.js.map +0 -1
- package/dist/coverage/lcov-report/block-navigation.d.ts +0 -1
- package/dist/coverage/lcov-report/block-navigation.js +0 -70
- package/dist/coverage/lcov-report/block-navigation.js.map +0 -1
- package/dist/coverage/lcov-report/prettify.d.ts +0 -0
- package/dist/coverage/lcov-report/prettify.js +0 -477
- package/dist/coverage/lcov-report/prettify.js.map +0 -1
- package/dist/coverage/lcov-report/sorter.d.ts +0 -1
- package/dist/coverage/lcov-report/sorter.js +0 -163
- package/dist/coverage/lcov-report/sorter.js.map +0 -1
- package/dist/coverage/prettify.d.ts +0 -0
- package/dist/coverage/prettify.js +0 -477
- package/dist/coverage/prettify.js.map +0 -1
- package/dist/coverage/sorter.d.ts +0 -1
- package/dist/coverage/sorter.js +0 -163
- package/dist/coverage/sorter.js.map +0 -1
- package/dist/formatter/index.d.ts +0 -37
- package/dist/formatter/index.js +0 -75
- package/dist/formatter/index.js.map +0 -1
- package/dist/hal/index.d.ts +0 -5
- package/dist/hal/index.js +0 -69
- package/dist/hal/index.js.map +0 -1
- package/dist/health/health-logger.d.ts +0 -9
- package/dist/health/health-logger.js +0 -34
- package/dist/health/health-logger.js.map +0 -1
- package/dist/health/index.d.ts +0 -19
- package/dist/health/index.js +0 -175
- package/dist/health/index.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.js +0 -2
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/test-server-wrapper.d.ts +0 -120
- package/dist/helpers/test-server-wrapper.js +0 -165
- package/dist/helpers/test-server-wrapper.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- package/dist/last-commit.d.ts +0 -1
- package/dist/last-commit.js +0 -12
- package/dist/last-commit.js.map +0 -1
- package/dist/last_commit/index.d.ts +0 -7
- package/dist/last_commit/index.js +0 -83
- package/dist/last_commit/index.js.map +0 -1
- package/dist/paginator/s4-pagination.d.ts +0 -9
- package/dist/paginator/s4-pagination.js +0 -49
- package/dist/paginator/s4-pagination.js.map +0 -1
- package/dist/paginator/sql-pagination.d.ts +0 -27
- package/dist/paginator/sql-pagination.js +0 -166
- package/dist/paginator/sql-pagination.js.map +0 -1
- package/dist/paper-trail/helpers.d.ts +0 -11
- package/dist/paper-trail/helpers.js +0 -74
- package/dist/paper-trail/helpers.js.map +0 -1
- package/dist/paper-trail/index.d.ts +0 -13
- package/dist/paper-trail/index.js +0 -662
- package/dist/paper-trail/index.js.map +0 -1
- package/dist/prompts/index.d.ts +0 -14
- package/dist/prompts/index.js +0 -63
- package/dist/prompts/index.js.map +0 -1
- package/dist/queue/index.d.ts +0 -166
- package/dist/queue/index.js +0 -371
- package/dist/queue/index.js.map +0 -1
- package/dist/queue/publisher.d.ts +0 -31
- package/dist/queue/publisher.js +0 -84
- package/dist/queue/publisher.js.map +0 -1
- package/dist/queue/queue-logger.d.ts +0 -9
- package/dist/queue/queue-logger.js +0 -35
- package/dist/queue/queue-logger.js.map +0 -1
- package/dist/queue/subscriber.d.ts +0 -39
- package/dist/queue/subscriber.js +0 -97
- package/dist/queue/subscriber.js.map +0 -1
- package/dist/safe_proxy/index.d.ts +0 -13
- package/dist/safe_proxy/index.js +0 -54
- package/dist/safe_proxy/index.js.map +0 -1
- package/dist/serializer/index.d.ts +0 -5
- package/dist/serializer/index.js +0 -83
- package/dist/serializer/index.js.map +0 -1
- package/dist/test/debug-array.d.ts +0 -0
- package/dist/test/debug-array.js +0 -1
- package/dist/test/debug-array.js.map +0 -1
- package/dist/test/debug-setJSONB.d.ts +0 -0
- package/dist/test/debug-setJSONB.js +0 -1
- package/dist/test/debug-setJSONB.js.map +0 -1
- package/dist/test/prompt.test.d.ts +0 -1
- package/dist/test/prompt.test.js +0 -74
- package/dist/test/prompt.test.js.map +0 -1
- package/dist/test/s4-formatter.spec.d.ts +0 -1
- package/dist/test/s4-formatter.spec.js +0 -67
- package/dist/test/s4-formatter.spec.js.map +0 -1
- package/dist/test/s4-pagination.spec.d.ts +0 -1
- package/dist/test/s4-pagination.spec.js +0 -170
- package/dist/test/s4-pagination.spec.js.map +0 -1
- package/dist/test/safe-proxy.spec.d.ts +0 -1
- package/dist/test/safe-proxy.spec.js +0 -252
- package/dist/test/safe-proxy.spec.js.map +0 -1
- package/dist/test/serializer.spec.d.ts +0 -1
- package/dist/test/serializer.spec.js +0 -27
- package/dist/test/serializer.spec.js.map +0 -1
- package/dist/test/utils.spec.d.ts +0 -1
- package/dist/test/utils.spec.js +0 -446
- package/dist/test/utils.spec.js.map +0 -1
- package/dist/ts/task-scheduler/index.d.ts +0 -130
- package/dist/ts/task-scheduler/index.js +0 -259
- package/dist/ts/task-scheduler/index.js.map +0 -1
- package/formatter/index.js +0 -81
- package/hal/README.md +0 -54
- package/hal/index.js +0 -75
- package/health/health-logger.js +0 -40
- package/health/index.js +0 -188
- package/helpers/index.js +0 -1
- package/helpers/test-server-wrapper.js +0 -196
- package/last-commit.js +0 -12
- package/last_commit/index.js +0 -82
- package/logger/s4-logger.js +0 -128
- package/paginator/README.md +0 -183
- package/paginator/s4-pagination.js +0 -51
- package/paginator/sql-pagination.js +0 -178
- package/paper-trail/README.md +0 -68
- package/paper-trail/helpers.js +0 -99
- package/paper-trail/index.js +0 -843
- package/prompts/index.js +0 -78
- package/queue/index.js +0 -402
- package/queue/publisher.js +0 -96
- package/queue/queue-logger.js +0 -40
- package/queue/subscriber.js +0 -107
- package/safe_proxy/index.js +0 -61
- package/scripts/publish.sh +0 -46
- package/serializer/index.js +0 -90
- package/test/health.spec.js +0 -213
- package/test/prompt.test.js +0 -91
- package/test/s4-formatter.spec.js +0 -80
- package/test/s4-pagination.spec.js +0 -196
- package/test/serializer.spec.js +0 -34
- package/test/utils.spec.js +0 -145
- package/utils/index.js +0 -74
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import should from "should";
|
|
2
|
-
import S4Pagination from "../paginator/s4-pagination.js";
|
|
3
|
-
import http_mocks from "node-mocks-http";
|
|
4
|
-
import events from "events";
|
|
5
|
-
|
|
6
|
-
describe("Pagination", function () {
|
|
7
|
-
var paginator = null;
|
|
8
|
-
var request = null;
|
|
9
|
-
var response = null;
|
|
10
|
-
var next = null;
|
|
11
|
-
|
|
12
|
-
before("Setup", function () {
|
|
13
|
-
next = function () { };
|
|
14
|
-
response = http_mocks.createResponse({ eventEmitter: events.EventEmitter });
|
|
15
|
-
request = http_mocks.createRequest({
|
|
16
|
-
method: "GET",
|
|
17
|
-
url: "/"
|
|
18
|
-
})
|
|
19
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe("Parsing query parameters", function () {
|
|
23
|
-
describe("Default values", function () {
|
|
24
|
-
it("should have default page set to 1", function () {
|
|
25
|
-
paginator.should.have.property("page", 1);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("should have default page size set to 5", function () {
|
|
29
|
-
paginator.should.have.property("page_size", 5);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe("Page value set to 0", function () {
|
|
34
|
-
before("Setup", function () {
|
|
35
|
-
request = http_mocks.createRequest({
|
|
36
|
-
method: "GET",
|
|
37
|
-
url: "/?page=0"
|
|
38
|
-
})
|
|
39
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should set page to 1", function () {
|
|
43
|
-
paginator.should.have.property("page", 1);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe("Page value set to negative", function () {
|
|
48
|
-
before("Setup", function () {
|
|
49
|
-
request = http_mocks.createRequest({
|
|
50
|
-
method: "GET",
|
|
51
|
-
url: "/?page=-1"
|
|
52
|
-
})
|
|
53
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("should set page to 1", function () {
|
|
57
|
-
paginator.should.have.property("page", 1);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("Page value set to 2", function () {
|
|
62
|
-
before("Setup", function () {
|
|
63
|
-
request = http_mocks.createRequest({
|
|
64
|
-
method: "GET",
|
|
65
|
-
url: "/?page=2"
|
|
66
|
-
})
|
|
67
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("should set page to 2", function () {
|
|
71
|
-
paginator.should.have.property("page", 2);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe("Page value set to 10", function () {
|
|
76
|
-
before("Setup", function () {
|
|
77
|
-
request = http_mocks.createRequest({
|
|
78
|
-
method: "GET",
|
|
79
|
-
url: "/?page=10"
|
|
80
|
-
})
|
|
81
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("should set page to 10", function () {
|
|
85
|
-
paginator.should.have.property("page", 10);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe("Page value set to 100", function () {
|
|
90
|
-
before("Setup", function () {
|
|
91
|
-
request = http_mocks.createRequest({
|
|
92
|
-
method: "GET",
|
|
93
|
-
url: "/?page=100"
|
|
94
|
-
})
|
|
95
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("should set page to 100", function () {
|
|
99
|
-
paginator.should.have.property("page", 100);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe("Page Size value set to 0", function () {
|
|
104
|
-
before("Setup", function () {
|
|
105
|
-
request = http_mocks.createRequest({
|
|
106
|
-
method: "GET",
|
|
107
|
-
url: "/?page_size=0"
|
|
108
|
-
})
|
|
109
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("should set page size to 5", function () {
|
|
113
|
-
paginator.should.have.property("page_size", 5);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe("Page Size value set to negative", function () {
|
|
118
|
-
before("Setup", function () {
|
|
119
|
-
request = http_mocks.createRequest({
|
|
120
|
-
method: "GET",
|
|
121
|
-
url: "/?page_size=-1"
|
|
122
|
-
})
|
|
123
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("should set page size to 5", function () {
|
|
127
|
-
paginator.should.have.property("page_size", 5);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
describe("Page Size value set to 2", function () {
|
|
132
|
-
before("Setup", function () {
|
|
133
|
-
request = http_mocks.createRequest({
|
|
134
|
-
method: "GET",
|
|
135
|
-
url: "/?page_size=2"
|
|
136
|
-
})
|
|
137
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("should set page size to 5", function () {
|
|
141
|
-
paginator.should.have.property("page_size", 5);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe("Page Size value set to 10", function () {
|
|
146
|
-
before("Setup", function () {
|
|
147
|
-
request = http_mocks.createRequest({
|
|
148
|
-
method: "GET",
|
|
149
|
-
url: "/?page_size=10"
|
|
150
|
-
})
|
|
151
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("should set page size to 10", function () {
|
|
155
|
-
paginator.should.have.property("page_size", 10);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe("Page Size value set to 100", function () {
|
|
160
|
-
before("Setup", function () {
|
|
161
|
-
request = http_mocks.createRequest({
|
|
162
|
-
method: "GET",
|
|
163
|
-
url: "/?page_size=100"
|
|
164
|
-
})
|
|
165
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should set page size to 100", function () {
|
|
169
|
-
paginator.should.have.property("page_size", 100);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe("Replying", function() {
|
|
175
|
-
beforeEach("Clear request", function() {
|
|
176
|
-
response = http_mocks.createResponse({ eventEmitter: events.EventEmitter });
|
|
177
|
-
paginator = S4Pagination.createPaginator(request, response, next);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it ("should return 500 if data is null", function(){
|
|
181
|
-
paginator.reply(null);
|
|
182
|
-
response.statusCode.should.equal(500);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it ("should return pagination data", function(){
|
|
186
|
-
const items = [1,2,3,4,5,6,7,8,9,10];
|
|
187
|
-
const data = {
|
|
188
|
-
docs : items,
|
|
189
|
-
total : items.length,
|
|
190
|
-
};
|
|
191
|
-
paginator.reply(data);
|
|
192
|
-
response.statusCode.should.equal(200);
|
|
193
|
-
response._getHeaders().should.have.property("s4-pagination");
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
});
|
package/test/serializer.spec.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import serializer from "../serializer/index.js";
|
|
3
|
-
|
|
4
|
-
describe("Serializer", () => {
|
|
5
|
-
|
|
6
|
-
describe("Serialize", () => {
|
|
7
|
-
|
|
8
|
-
it ("should not show Hidden/Removed fields", () => {
|
|
9
|
-
const model = { prototype: {} }
|
|
10
|
-
model.prototype.get = function() {
|
|
11
|
-
return {
|
|
12
|
-
name: "John",
|
|
13
|
-
hidden_prefs: "should be hidden",
|
|
14
|
-
password: "password",
|
|
15
|
-
password_salt: "password_salt",
|
|
16
|
-
mfa_totp_secret: "mfa_totp_secret",
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const options = { hide: ["hidden_prefs"], remove: ["password", "password_salt", "mfa_totp_secret"] }
|
|
20
|
-
|
|
21
|
-
serializer.serialize(model, options);
|
|
22
|
-
|
|
23
|
-
const serialized = model.prototype.toJSON();
|
|
24
|
-
|
|
25
|
-
expect(serialized.name).to.eq("John");
|
|
26
|
-
|
|
27
|
-
expect(serialized.hidden_prefs).to.be.undefined;
|
|
28
|
-
expect(serialized.password).to.be.undefined;
|
|
29
|
-
expect(serialized.password_salt).to.be.undefined;
|
|
30
|
-
expect(serialized.mfa_totp_secret).to.be.undefined;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
});
|
package/test/utils.spec.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
|
|
3
|
-
import { utils } from "../utils/index.js";
|
|
4
|
-
import { TWS_ROUTE_TYPES } from "../constants/index.js";
|
|
5
|
-
|
|
6
|
-
describe("Utils", () => {
|
|
7
|
-
|
|
8
|
-
describe("UUID V4", () => {
|
|
9
|
-
|
|
10
|
-
it ("should not validate ABCD", () => {
|
|
11
|
-
expect(utils.isValidUuidV4("ABC")).to.be.false
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it ("should not validate null", () => {
|
|
15
|
-
expect(utils.isValidUuidV4(null)).to.be.false
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it ("should not validate undefined", () => {
|
|
19
|
-
expect(utils.isValidUuidV4()).to.be.false
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it ("should not validate empty string", () => {
|
|
23
|
-
expect(utils.isValidUuidV4("")).to.be.false
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it ("should not validate 26d61a823587-4875-98a8e950e1bf2350", () => {
|
|
27
|
-
expect(utils.isValidUuidV4("26d61a823587-4875-98a8-950e1bf2350")).to.be.false
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it ("should not validate 26d61a82-3587-4875-98a8-e950e1bf235", () => {
|
|
31
|
-
expect(utils.isValidUuidV4("26d61a82-3587-4875-98a8-e950e1bf235")).to.be.false
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it ("should not validate 26d61a8-3587-4875-98a8-e950e1bf2350", () => {
|
|
35
|
-
expect(utils.isValidUuidV4("26d61a8-3587-4875-98a8-e950e1bf2350")).to.be.false
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it ("should not validate 26d61a82-3587-487-98a8-e950e1bf2350", () => {
|
|
39
|
-
expect(utils.isValidUuidV4("26d61a82-3587-487-98a8-e950e1bf2350")).to.be.false
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it ("should validate 26d61a82-3587-4875-98a8-e950e1bf2350", () => {
|
|
43
|
-
expect(utils.isValidUuidV4("26d61a82-3587-4875-98a8-e950e1bf2350")).to.be.true
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it ("should validate 26D61A82-3587-4875-98A8-E950E1BF2350", () => {
|
|
47
|
-
expect(utils.isValidUuidV4("26D61A82-3587-4875-98A8-E950E1BF2350")).to.be.true
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("String -> Integer Array", () => {
|
|
53
|
-
it ("Should return [] with a null/undefined input", () => {
|
|
54
|
-
expect(utils.convertToIntegerArray()).to.be.an('array').that.is.empty;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it ("Should return a valid integer array for '1,2,3'", () => {
|
|
58
|
-
expect(utils.convertToIntegerArray('1,2,3')).to.be.an('array').to.deep.equal([1, 2, 3])
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it ("Should return a valid integer array for '[1,2,3]'", () => {
|
|
62
|
-
expect(utils.convertToIntegerArray('[1,2,3]')).to.be.an('array').to.deep.equal([1, 2, 3])
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it ("Should return a valid integer array for '[1,2],3'", () => {
|
|
66
|
-
expect(utils.convertToIntegerArray('[1,2],3')).to.be.an('array').to.deep.equal([1, 2])
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it ("Should return a valid integer array for '[1,2]],3'", () => {
|
|
70
|
-
expect(utils.convertToIntegerArray('[1,2]],3')).to.be.an('array').to.deep.equal([1, 2])
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it ("Should return a valid integer array for '[1,2,3'", () => {
|
|
74
|
-
expect(utils.convertToIntegerArray('[1,2,3')).to.be.an('array').to.deep.equal([1, 2, 3])
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it ("Should return a valid integer array for '1[1,2],3'", () => {
|
|
78
|
-
expect(utils.convertToIntegerArray('1[1,2],3')).to.be.an('array').to.deep.equal([1, 2])
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it ("Should return a valid integer array for 1", () => {
|
|
82
|
-
expect(utils.convertToIntegerArray(1)).to.be.an('array').to.deep.equal([1])
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it ("Should return a valid integer array for '1'", () => {
|
|
86
|
-
expect(utils.convertToIntegerArray('1')).to.be.an('array').to.deep.equal([1])
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it ("Should return a valid integer array for '1w'", () => {
|
|
90
|
-
expect(utils.convertToIntegerArray('1w')).to.be.an('array').to.deep.equal([1])
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it ("Should return a valid integer array for '[1,2e'", () => {
|
|
94
|
-
expect(utils.convertToIntegerArray('[1,2e')).to.be.an('array').to.deep.equal([1,2])
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe("Route testing", () => {
|
|
99
|
-
it ("Return -1 for a blank domain", () => {
|
|
100
|
-
expect(utils.getRouteType('')).to.eq(-1);
|
|
101
|
-
});
|
|
102
|
-
it ("Return a web route type for tws-web", () => {
|
|
103
|
-
const route = utils.getRouteType('tws-web.sera4.com/v3/xxx');
|
|
104
|
-
expect(route).to.eq(TWS_ROUTE_TYPES['web']);
|
|
105
|
-
expect(utils.isWebRoute(route)).to.be.true
|
|
106
|
-
});
|
|
107
|
-
it ("Return a web route type for tws-web-staging", () => {
|
|
108
|
-
const route = utils.getRouteType('tws-web-environmentX.sera4.com/v3/xxx');
|
|
109
|
-
expect(route).to.eq(TWS_ROUTE_TYPES['web']);
|
|
110
|
-
expect(utils.isWebRoute(route)).to.be.true
|
|
111
|
-
});
|
|
112
|
-
it ("Return a mobile route type for tws-mob", () => {
|
|
113
|
-
const route = utils.getRouteType('tws-mob.sera4.com/v3/xxx');
|
|
114
|
-
expect(route).to.eq(TWS_ROUTE_TYPES['mobile']);
|
|
115
|
-
expect(utils.isMobileRoute(route)).to.be.true
|
|
116
|
-
});
|
|
117
|
-
it ("Return a mobile route type for tws-mob-staging", () => {
|
|
118
|
-
const route = utils.getRouteType('tws-mob-environmentX.sera4.com/v3/xxx');
|
|
119
|
-
expect(route).to.eq(TWS_ROUTE_TYPES['mobile']);
|
|
120
|
-
expect(utils.isMobileRoute(route)).to.be.true
|
|
121
|
-
});
|
|
122
|
-
it ("Return an API route type for tws-api-xxxx", () => {
|
|
123
|
-
const route = utils.getRouteType('tws-api-1234.sera4.com/v3/xxx');
|
|
124
|
-
expect(route).to.eq(TWS_ROUTE_TYPES['api']);
|
|
125
|
-
expect(utils.isApiRoute(route)).to.be.true
|
|
126
|
-
});
|
|
127
|
-
it ("Return isWebRoute TRUE for 1 or '1'", () => {
|
|
128
|
-
expect(utils.isWebRoute(1)).to.eq(true);
|
|
129
|
-
expect(utils.isWebRoute('1')).to.eq(true);
|
|
130
|
-
});
|
|
131
|
-
it ("Return isMobileRoute TRUE for 2 or '2'", () => {
|
|
132
|
-
expect(utils.isMobileRoute(2)).to.eq(true);
|
|
133
|
-
expect(utils.isMobileRoute('2')).to.eq(true);
|
|
134
|
-
});
|
|
135
|
-
it ("Return isApiRoute TRUE for 3 or '3'", () => {
|
|
136
|
-
expect(utils.isApiRoute(3)).to.eq(true);
|
|
137
|
-
expect(utils.isApiRoute('3')).to.eq(true);
|
|
138
|
-
});
|
|
139
|
-
it ("Return isApiRoute TRUE for many other values", () => {
|
|
140
|
-
expect(utils.isOtherRoute(4)).to.eq(true);
|
|
141
|
-
expect(utils.isOtherRoute('4')).to.eq(true);
|
|
142
|
-
expect(utils.isOtherRoute('a')).to.eq(true);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
package/utils/index.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { TWS_ROUTE_TYPES } from "../constants/index.js";
|
|
4
|
-
|
|
5
|
-
export const utils = {
|
|
6
|
-
isValidUuidV4 : (input) => {
|
|
7
|
-
if (!input) {
|
|
8
|
-
return false
|
|
9
|
-
} else {
|
|
10
|
-
return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(input);
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
// convert a regular string or Array to array (ie, "[1,2,3, 0xA]", "1,2,3,10")
|
|
14
|
-
// useful for controller inputs
|
|
15
|
-
// - also accepts hex
|
|
16
|
-
convertToIntegerArray(input) {
|
|
17
|
-
return this.convertToArray(input)
|
|
18
|
-
.filter((el) => /^[0-9]+/.test(el))
|
|
19
|
-
.map((el) => parseInt(el))
|
|
20
|
-
.filter((el) => Number.isInteger(el));
|
|
21
|
-
},
|
|
22
|
-
convertToArray: (input) => {
|
|
23
|
-
if (Array.isArray(input)){
|
|
24
|
-
return input
|
|
25
|
-
} else {
|
|
26
|
-
if (!!input) {
|
|
27
|
-
if (typeof input === "number") {
|
|
28
|
-
return [ input ]
|
|
29
|
-
}
|
|
30
|
-
let matches;
|
|
31
|
-
if (matches = input.match(/\[(.*?)\]/)) {
|
|
32
|
-
input = matches[1]
|
|
33
|
-
}
|
|
34
|
-
input = input.replace(/[\[\]]/, '')
|
|
35
|
-
|
|
36
|
-
return input.replace(/\s+/, '').split(',').filter((el) => /^[0-9A-Za-z-.]+/.test(el));
|
|
37
|
-
} else {
|
|
38
|
-
return []
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
isBlank: (str) => {
|
|
43
|
-
return ((str === null) || (str === undefined) || /^\s*$/.test(str));
|
|
44
|
-
},
|
|
45
|
-
getRouteType: (domain) => {
|
|
46
|
-
if (!domain)
|
|
47
|
-
return -1;
|
|
48
|
-
|
|
49
|
-
let routeType;
|
|
50
|
-
|
|
51
|
-
switch (true) {
|
|
52
|
-
case /^(tws-web|local-gateway)/i.test(domain):
|
|
53
|
-
routeType = TWS_ROUTE_TYPES['web'];
|
|
54
|
-
break;
|
|
55
|
-
case /^tws-mob/i.test(domain):
|
|
56
|
-
routeType = TWS_ROUTE_TYPES['mobile'];
|
|
57
|
-
break;
|
|
58
|
-
case /^(tws-api-)/i.test(domain):
|
|
59
|
-
routeType = TWS_ROUTE_TYPES['api'];
|
|
60
|
-
break;
|
|
61
|
-
default:
|
|
62
|
-
routeType = TWS_ROUTE_TYPES['other'];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return routeType;
|
|
66
|
-
},
|
|
67
|
-
isWebRoute: (sessionType) => (parseInt(sessionType) === TWS_ROUTE_TYPES['web']),
|
|
68
|
-
isApiRoute: (sessionType) => (parseInt(sessionType) === TWS_ROUTE_TYPES['api']),
|
|
69
|
-
isMobileRoute: (sessionType) => (parseInt(sessionType) === TWS_ROUTE_TYPES['mobile']),
|
|
70
|
-
isOtherRoute: (sessionType) => {
|
|
71
|
-
const value = parseInt(sessionType);
|
|
72
|
-
return ((value === TWS_ROUTE_TYPES['other']) || isNaN(value)) ? true : false;
|
|
73
|
-
}
|
|
74
|
-
}
|