@squiz/dx-common-lib 1.2.1-alpha.99 → 1.2.2
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 +80 -0
- package/lib/assertions/assertAssignWithDefaultUndefinedValue.d.ts +1 -0
- package/lib/assertions/assertAssignWithDefaultUndefinedValue.js +3 -1
- package/lib/assertions/assertAssignWithDefaultUndefinedValue.js.map +1 -1
- package/lib/assertions/assertIsBoolean.d.ts +1 -0
- package/lib/assertions/assertIsBoolean.js +12 -0
- package/lib/assertions/assertIsBoolean.js.map +1 -0
- package/lib/assertions/assertIsBoolean.spec.d.ts +1 -0
- package/lib/assertions/assertIsBoolean.spec.js +16 -0
- package/lib/assertions/assertIsBoolean.spec.js.map +1 -0
- package/lib/assertions/assertIsEnumValue.d.ts +1 -0
- package/lib/assertions/assertIsEnumValue.js +18 -0
- package/lib/assertions/assertIsEnumValue.js.map +1 -0
- package/lib/assertions/assertIsEnumValue.spec.d.ts +1 -0
- package/lib/assertions/assertIsEnumValue.spec.js +39 -0
- package/lib/assertions/assertIsEnumValue.spec.js.map +1 -0
- package/lib/assertions/index.d.ts +9 -0
- package/lib/assertions/index.js +28 -0
- package/lib/assertions/index.js.map +1 -0
- package/lib/error/BadRequestError.d.ts +4 -0
- package/lib/error/BadRequestError.js +11 -0
- package/lib/error/BadRequestError.js.map +1 -0
- package/lib/error/ErrorWithHttpStatusCode.d.ts +5 -0
- package/lib/error/ErrorWithHttpStatusCode.js +12 -0
- package/lib/error/ErrorWithHttpStatusCode.js.map +1 -0
- package/lib/error/InternalServerError.d.ts +4 -0
- package/lib/error/InternalServerError.js +11 -0
- package/lib/error/InternalServerError.js.map +1 -0
- package/lib/error/MethodNotImplementedError.d.ts +4 -0
- package/lib/error/MethodNotImplementedError.js +11 -0
- package/lib/error/MethodNotImplementedError.js.map +1 -0
- package/lib/error/ResourceNotFoundError.d.ts +4 -0
- package/lib/error/ResourceNotFoundError.js +11 -0
- package/lib/error/ResourceNotFoundError.js.map +1 -0
- package/lib/error/TimeoutError.d.ts +5 -0
- package/lib/error/TimeoutError.js +12 -0
- package/lib/error/TimeoutError.js.map +1 -0
- package/lib/error/index.d.ts +6 -0
- package/lib/error/index.js +23 -0
- package/lib/error/index.js.map +1 -0
- package/lib/index.d.ts +4 -7
- package/lib/index.js +4 -9
- package/lib/index.js.map +1 -1
- package/lib/util/getNodeEnv.d.ts +1 -0
- package/lib/util/getNodeEnv.js +14 -0
- package/lib/util/getNodeEnv.js.map +1 -0
- package/lib/util/getNodeEnv.spec.d.ts +1 -0
- package/lib/util/getNodeEnv.spec.js +22 -0
- package/lib/util/getNodeEnv.spec.js.map +1 -0
- package/lib/util/getPageInfo.d.ts +9 -0
- package/lib/util/getPageInfo.js +18 -0
- package/lib/util/getPageInfo.js.map +1 -0
- package/lib/util/index.d.ts +7 -0
- package/lib/util/index.js +18 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.d.ts +1 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.js +14 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.js.map +1 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.d.ts +1 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js +25 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js.map +1 -0
- package/lib/util/isReadable.d.ts +1 -0
- package/lib/util/isReadable.js +20 -0
- package/lib/util/isReadable.js.map +1 -0
- package/lib/util/joinAbsoluteUrlPath.d.ts +1 -0
- package/lib/util/joinAbsoluteUrlPath.js +26 -0
- package/lib/util/joinAbsoluteUrlPath.js.map +1 -0
- package/lib/util/joinAbsoluteUrlPath.spec.d.ts +1 -0
- package/lib/util/joinAbsoluteUrlPath.spec.js +43 -0
- package/lib/util/joinAbsoluteUrlPath.spec.js.map +1 -0
- package/lib/util/never.d.ts +1 -0
- package/lib/util/never.js +9 -0
- package/lib/util/never.js.map +1 -0
- package/lib/util/parseEnvVarForVar.d.ts +1 -0
- package/lib/util/parseEnvVarForVar.js +15 -0
- package/lib/util/parseEnvVarForVar.js.map +1 -0
- package/lib/util/parseEnvVarForVar.spec.d.ts +1 -0
- package/lib/util/parseEnvVarForVar.spec.js +20 -0
- package/lib/util/parseEnvVarForVar.spec.js.map +1 -0
- package/lib/zip/zipDirectory.d.ts +1 -0
- package/lib/zip/zipDirectory.js +32 -0
- package/lib/zip/zipDirectory.js.map +1 -0
- package/lib/zip/zipDirectory.spec.d.ts +1 -0
- package/lib/zip/zipDirectory.spec.js +25 -0
- package/lib/zip/zipDirectory.spec.js.map +1 -0
- package/package.json +13 -7
- package/src/assertions/assertAssignWithDefaultUndefinedValue.ts +5 -0
- package/src/assertions/assertIsBoolean.spec.ts +16 -0
- package/src/assertions/assertIsBoolean.ts +5 -0
- package/src/assertions/assertIsEnumValue.spec.ts +39 -0
- package/src/assertions/assertIsEnumValue.ts +15 -0
- package/src/assertions/index.ts +12 -0
- package/src/error/BadRequestError.ts +7 -0
- package/src/error/ErrorWithHttpStatusCode.ts +5 -0
- package/src/error/InternalServerError.ts +7 -0
- package/src/error/MethodNotImplementedError.ts +7 -0
- package/src/error/ResourceNotFoundError.ts +7 -0
- package/src/error/TimeoutError.ts +8 -0
- package/src/error/index.ts +6 -0
- package/src/index.ts +4 -10
- package/src/util/getNodeEnv.spec.ts +25 -0
- package/src/util/getNodeEnv.ts +11 -0
- package/src/util/getPageInfo.ts +23 -0
- package/src/util/index.ts +7 -0
- package/src/util/isPathTryingToAccessOutsideOfRoot.spec.ts +25 -0
- package/src/util/isPathTryingToAccessOutsideOfRoot.ts +8 -0
- package/src/util/isReadable.ts +12 -0
- package/src/util/joinAbsoluteUrlPath.spec.ts +62 -0
- package/src/util/joinAbsoluteUrlPath.ts +22 -0
- package/src/util/never.ts +4 -0
- package/src/util/parseEnvVarForVar.spec.ts +22 -0
- package/src/util/parseEnvVarForVar.ts +12 -0
- package/src/zip/zipDirectory.spec.ts +24 -0
- package/src/zip/zipDirectory.ts +31 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/jest.integration.config.ts +0 -26
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,86 @@
|
|
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
|
+
## [1.2.2](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.2) (2022-09-23)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [1.2.1](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1) (2022-09-23)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
## [1.2.1-alpha.107](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.107) (2022-09-21)
|
23
|
+
|
24
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
## [1.2.1-alpha.106](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.106) (2022-09-02)
|
31
|
+
|
32
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
## [1.2.1-alpha.105](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.105) (2022-08-26)
|
39
|
+
|
40
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
## [1.2.1-alpha.104](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.104) (2022-08-23)
|
47
|
+
|
48
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
## [1.2.1-alpha.103](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.103) (2022-08-23)
|
55
|
+
|
56
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
## [1.2.1-alpha.102](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.102) (2022-08-23)
|
63
|
+
|
64
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
## [1.2.1-alpha.101](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.101) (2022-08-19)
|
71
|
+
|
72
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
## [1.2.1-alpha.100](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.100) (2022-08-18)
|
79
|
+
|
80
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
6
86
|
## [1.2.1-alpha.99](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.99) (2022-08-18)
|
7
87
|
|
8
88
|
**Note:** Version bump only for package @squiz/dx-common-lib
|
@@ -2,3 +2,4 @@
|
|
2
2
|
* If value is undefined, return default value otherwise assert it meets assertion rule
|
3
3
|
*/
|
4
4
|
export declare function assertAssignWithDefaultUndefinedValue<T>(value: unknown, assertionFunc: (val: unknown) => asserts val is T, defaultValue: T, errorMessage?: string): T;
|
5
|
+
export declare const isSomeEnum: <TEnum>(enumType: TEnum) => (token: unknown) => token is TEnum[keyof TEnum];
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.assertAssignWithDefaultUndefinedValue = void 0;
|
3
|
+
exports.isSomeEnum = exports.assertAssignWithDefaultUndefinedValue = void 0;
|
4
4
|
const assertAssign_1 = require("./assertAssign");
|
5
5
|
/**
|
6
6
|
* If value is undefined, return default value otherwise assert it meets assertion rule
|
@@ -12,4 +12,6 @@ function assertAssignWithDefaultUndefinedValue(value, assertionFunc, defaultValu
|
|
12
12
|
return (0, assertAssign_1.assertAssign)(value, assertionFunc, errorMessage);
|
13
13
|
}
|
14
14
|
exports.assertAssignWithDefaultUndefinedValue = assertAssignWithDefaultUndefinedValue;
|
15
|
+
const isSomeEnum = (enumType) => (token) => Object.values(enumType).includes(token);
|
16
|
+
exports.isSomeEnum = isSomeEnum;
|
15
17
|
//# sourceMappingURL=assertAssignWithDefaultUndefinedValue.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"assertAssignWithDefaultUndefinedValue.js","sourceRoot":"","sources":["../../src/assertions/assertAssignWithDefaultUndefinedValue.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAE9C;;GAEG;AACH,SAAgB,qCAAqC,CACnD,KAAc,EACd,aAAiD,EACjD,YAAe,EACf,YAAqB;IAErB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;QACzC,OAAO,YAAY,CAAC;KACrB;IAED,OAAO,IAAA,2BAAY,EAAC,KAAK,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAC1D,CAAC;AAXD,sFAWC"}
|
1
|
+
{"version":3,"file":"assertAssignWithDefaultUndefinedValue.js","sourceRoot":"","sources":["../../src/assertions/assertAssignWithDefaultUndefinedValue.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAE9C;;GAEG;AACH,SAAgB,qCAAqC,CACnD,KAAc,EACd,aAAiD,EACjD,YAAe,EACf,YAAqB;IAErB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;QACzC,OAAO,YAAY,CAAC;KACrB;IAED,OAAO,IAAA,2BAAY,EAAC,KAAK,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAC1D,CAAC;AAXD,sFAWC;AAEM,MAAM,UAAU,GACrB,CAAQ,QAAe,EAAE,EAAE,CAC3B,CAAC,KAAc,EAA+B,EAAE,CAC9C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAA2B,CAAC,CAAC;AAHrD,QAAA,UAAU,cAG2C"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function assertIsBoolean(value: unknown): asserts value is boolean;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.assertIsBoolean = void 0;
|
7
|
+
const strict_1 = __importDefault(require("assert/strict"));
|
8
|
+
function assertIsBoolean(value) {
|
9
|
+
strict_1.default.ok(typeof value === 'boolean', `Expected ${value} to be a boolean`);
|
10
|
+
}
|
11
|
+
exports.assertIsBoolean = assertIsBoolean;
|
12
|
+
//# sourceMappingURL=assertIsBoolean.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"assertIsBoolean.js","sourceRoot":"","sources":["../../src/assertions/assertIsBoolean.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAmC;AAEnC,SAAgB,eAAe,CAAC,KAAc;IAC5C,gBAAM,CAAC,EAAE,CAAC,OAAO,KAAK,KAAK,SAAS,EAAE,YAAY,KAAK,kBAAkB,CAAC,CAAC;AAC7E,CAAC;AAFD,0CAEC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const assertIsBoolean_1 = require("./assertIsBoolean");
|
4
|
+
describe('assertIsBoolean', () => {
|
5
|
+
it('should throw an assertion error if input is undefined', () => {
|
6
|
+
expect(() => (0, assertIsBoolean_1.assertIsBoolean)(undefined)).toThrowErrorMatchingInlineSnapshot(`"Expected undefined to be a boolean"`);
|
7
|
+
});
|
8
|
+
it('should throw an assertion error if input is null', () => {
|
9
|
+
expect(() => (0, assertIsBoolean_1.assertIsBoolean)(null)).toThrowErrorMatchingInlineSnapshot(`"Expected null to be a boolean"`);
|
10
|
+
});
|
11
|
+
it('should return "void" or undefined if valid', () => {
|
12
|
+
expect((0, assertIsBoolean_1.assertIsBoolean)(true)).toBeUndefined();
|
13
|
+
expect(() => (0, assertIsBoolean_1.assertIsBoolean)(false)).not.toThrowError();
|
14
|
+
});
|
15
|
+
});
|
16
|
+
//# sourceMappingURL=assertIsBoolean.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"assertIsBoolean.spec.js","sourceRoot":"","sources":["../../src/assertions/assertIsBoolean.spec.ts"],"names":[],"mappings":";;AAAA,uDAAoD;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,iCAAe,EAAC,SAAS,CAAC,CAAC,CAAC,kCAAkC,CAAC,sCAAsC,CAAC,CAAC;IACtH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,iCAAe,EAAC,IAAI,CAAC,CAAC,CAAC,kCAAkC,CAAC,iCAAiC,CAAC,CAAC;IAC5G,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,IAAA,iCAAe,EAAC,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QAC9C,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,iCAAe,EAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function assertIsEnumValue<T extends object>(val: unknown, obj: T): asserts val is T[keyof T];
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.assertIsEnumValue = void 0;
|
4
|
+
const assert_1 = require("assert");
|
5
|
+
function assertIsEnumValue(val, obj) {
|
6
|
+
if (isValueIsEnumValue(val, obj) === false) {
|
7
|
+
throw new assert_1.AssertionError({
|
8
|
+
actual: val,
|
9
|
+
expected: Object.values(obj),
|
10
|
+
operator: 'in',
|
11
|
+
});
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.assertIsEnumValue = assertIsEnumValue;
|
15
|
+
function isValueIsEnumValue(val, enumType) {
|
16
|
+
return Object.values(enumType).includes(val);
|
17
|
+
}
|
18
|
+
//# sourceMappingURL=assertIsEnumValue.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"assertIsEnumValue.js","sourceRoot":"","sources":["../../src/assertions/assertIsEnumValue.ts"],"names":[],"mappings":";;;AAAA,mCAAwC;AAExC,SAAgB,iBAAiB,CAAmB,GAAY,EAAE,GAAM;IACtE,IAAI,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,KAAK,EAAE;QAC1C,MAAM,IAAI,uBAAc,CAAC;YACvB,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;YAC5B,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;KACJ;AACH,CAAC;AARD,8CAQC;AAED,SAAS,kBAAkB,CAAuB,GAAY,EAAE,QAAe;IAC7E,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAyB,CAAC,CAAC;AACrE,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const assert_1 = require("assert");
|
4
|
+
const assertIsEnumValue_1 = require("./assertIsEnumValue");
|
5
|
+
describe('assertIsEnumValue', () => {
|
6
|
+
let StringEnum;
|
7
|
+
(function (StringEnum) {
|
8
|
+
StringEnum["A"] = "a";
|
9
|
+
StringEnum["B"] = "b";
|
10
|
+
StringEnum["C"] = "c";
|
11
|
+
})(StringEnum || (StringEnum = {}));
|
12
|
+
let NumEnum;
|
13
|
+
(function (NumEnum) {
|
14
|
+
NumEnum[NumEnum["A"] = 0] = "A";
|
15
|
+
NumEnum[NumEnum["B"] = 1] = "B";
|
16
|
+
NumEnum[NumEnum["C"] = 2] = "C";
|
17
|
+
})(NumEnum || (NumEnum = {}));
|
18
|
+
it('should not show an error if input value is in enum object', () => {
|
19
|
+
expect((0, assertIsEnumValue_1.assertIsEnumValue)('a', StringEnum)).toBeUndefined();
|
20
|
+
const val = StringEnum.B;
|
21
|
+
expect((0, assertIsEnumValue_1.assertIsEnumValue)(val, StringEnum)).toBeUndefined();
|
22
|
+
});
|
23
|
+
it('should not show an error if input value is in enum object (with no default values)', () => {
|
24
|
+
expect((0, assertIsEnumValue_1.assertIsEnumValue)(2, NumEnum)).toBeUndefined();
|
25
|
+
const val = NumEnum.C;
|
26
|
+
expect((0, assertIsEnumValue_1.assertIsEnumValue)(val, NumEnum)).toBeUndefined();
|
27
|
+
});
|
28
|
+
it("should throw an AssertionError is value isn't in enum", () => {
|
29
|
+
expect(() => (0, assertIsEnumValue_1.assertIsEnumValue)('zz', StringEnum)).toThrowError(assert_1.AssertionError);
|
30
|
+
expect(() => (0, assertIsEnumValue_1.assertIsEnumValue)('zz', StringEnum)).toThrowErrorMatchingInlineSnapshot(`
|
31
|
+
"'zz' in [
|
32
|
+
'a',
|
33
|
+
'b',
|
34
|
+
'c'
|
35
|
+
]"
|
36
|
+
`);
|
37
|
+
});
|
38
|
+
});
|
39
|
+
//# sourceMappingURL=assertIsEnumValue.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"assertIsEnumValue.spec.js","sourceRoot":"","sources":["../../src/assertions/assertIsEnumValue.spec.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AACxC,2DAAwD;AAExD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAK,UAIJ;IAJD,WAAK,UAAU;QACb,qBAAO,CAAA;QACP,qBAAO,CAAA;QACP,qBAAO,CAAA;IACT,CAAC,EAJI,UAAU,KAAV,UAAU,QAId;IAED,IAAK,OAIJ;IAJD,WAAK,OAAO;QACV,+BAAC,CAAA;QACD,+BAAC,CAAA;QACD,+BAAC,CAAA;IACH,CAAC,EAJI,OAAO,KAAP,OAAO,QAIX;IAED,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,CAAC,IAAA,qCAAiB,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QAC3D,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,IAAA,qCAAiB,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oFAAoF,EAAE,GAAG,EAAE;QAC5F,MAAM,CAAC,IAAA,qCAAiB,EAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QACtD,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;QACtB,MAAM,CAAC,IAAA,qCAAiB,EAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,qCAAiB,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,uBAAc,CAAC,CAAC;QAC/E,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,qCAAiB,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,kCAAkC,CAAC;;;;;;KAMpF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export * from './assertIsString';
|
2
|
+
export * from './assertIsDefined';
|
3
|
+
export * from './assertIsMapOfStringString';
|
4
|
+
export * from './assertIsObject';
|
5
|
+
export * from './assertIsNotAnEmptyString';
|
6
|
+
export * from './assertIsEnumValue';
|
7
|
+
export * from './assertIsBoolean';
|
8
|
+
export * from './assertAssignWithDefaultUndefinedValue';
|
9
|
+
export * from './assertAssign';
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
// Common Assertions
|
18
|
+
__exportStar(require("./assertIsString"), exports);
|
19
|
+
__exportStar(require("./assertIsDefined"), exports);
|
20
|
+
__exportStar(require("./assertIsMapOfStringString"), exports);
|
21
|
+
__exportStar(require("./assertIsObject"), exports);
|
22
|
+
__exportStar(require("./assertIsNotAnEmptyString"), exports);
|
23
|
+
__exportStar(require("./assertIsEnumValue"), exports);
|
24
|
+
__exportStar(require("./assertIsBoolean"), exports);
|
25
|
+
// Assert assign
|
26
|
+
__exportStar(require("./assertAssignWithDefaultUndefinedValue"), exports);
|
27
|
+
__exportStar(require("./assertAssign"), exports);
|
28
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assertions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oBAAoB;AACpB,mDAAiC;AACjC,oDAAkC;AAClC,8DAA4C;AAC5C,mDAAiC;AACjC,6DAA2C;AAC3C,sDAAoC;AACpC,oDAAkC;AAElC,gBAAgB;AAChB,0EAAwD;AACxD,iDAA+B"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BadRequestError = void 0;
|
4
|
+
const ErrorWithHttpStatusCode_1 = require("./ErrorWithHttpStatusCode");
|
5
|
+
class BadRequestError extends ErrorWithHttpStatusCode_1.ErrorWithHttpStatusCode {
|
6
|
+
constructor(message) {
|
7
|
+
super(400, message);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.BadRequestError = BadRequestError;
|
11
|
+
//# sourceMappingURL=BadRequestError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"BadRequestError.js","sourceRoot":"","sources":["../../src/error/BadRequestError.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAEpE,MAAa,eAAgB,SAAQ,iDAAuB;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAJD,0CAIC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ErrorWithHttpStatusCode = void 0;
|
4
|
+
class ErrorWithHttpStatusCode extends Error {
|
5
|
+
constructor(statusCode, message) {
|
6
|
+
super(message);
|
7
|
+
this.statusCode = statusCode;
|
8
|
+
this.message = message;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
exports.ErrorWithHttpStatusCode = ErrorWithHttpStatusCode;
|
12
|
+
//# sourceMappingURL=ErrorWithHttpStatusCode.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ErrorWithHttpStatusCode.js","sourceRoot":"","sources":["../../src/error/ErrorWithHttpStatusCode.ts"],"names":[],"mappings":";;;AAAA,MAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAmB,UAAkB,EAAS,OAAe;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,eAAU,GAAV,UAAU,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAQ;IAE7D,CAAC;CACF;AAJD,0DAIC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.InternalServerError = void 0;
|
4
|
+
const ErrorWithHttpStatusCode_1 = require("./ErrorWithHttpStatusCode");
|
5
|
+
class InternalServerError extends ErrorWithHttpStatusCode_1.ErrorWithHttpStatusCode {
|
6
|
+
constructor(message) {
|
7
|
+
super(500, message);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.InternalServerError = InternalServerError;
|
11
|
+
//# sourceMappingURL=InternalServerError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"InternalServerError.js","sourceRoot":"","sources":["../../src/error/InternalServerError.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAEpE,MAAa,mBAAoB,SAAQ,iDAAuB;IAC9D,YAAY,OAAe;QACzB,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAJD,kDAIC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MethodNotImplementedError = void 0;
|
4
|
+
const InternalServerError_1 = require("./InternalServerError");
|
5
|
+
class MethodNotImplementedError extends InternalServerError_1.InternalServerError {
|
6
|
+
constructor(message) {
|
7
|
+
super(message !== null && message !== void 0 ? message : 'method is not implemented');
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.MethodNotImplementedError = MethodNotImplementedError;
|
11
|
+
//# sourceMappingURL=MethodNotImplementedError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MethodNotImplementedError.js","sourceRoot":"","sources":["../../src/error/MethodNotImplementedError.ts"],"names":[],"mappings":";;;AAAA,+DAA4D;AAE5D,MAAa,yBAA0B,SAAQ,yCAAmB;IAChE,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,2BAA2B,CAAC,CAAC;IAChD,CAAC;CACF;AAJD,8DAIC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ResourceNotFoundError = void 0;
|
4
|
+
const ErrorWithHttpStatusCode_1 = require("./ErrorWithHttpStatusCode");
|
5
|
+
class ResourceNotFoundError extends ErrorWithHttpStatusCode_1.ErrorWithHttpStatusCode {
|
6
|
+
constructor(message) {
|
7
|
+
super(404, message);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.ResourceNotFoundError = ResourceNotFoundError;
|
11
|
+
//# sourceMappingURL=ResourceNotFoundError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ResourceNotFoundError.js","sourceRoot":"","sources":["../../src/error/ResourceNotFoundError.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAEpE,MAAa,qBAAsB,SAAQ,iDAAuB;IAChE,YAAY,OAAe;QACzB,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAJD,sDAIC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TimeoutError = void 0;
|
4
|
+
const ErrorWithHttpStatusCode_1 = require("./ErrorWithHttpStatusCode");
|
5
|
+
class TimeoutError extends ErrorWithHttpStatusCode_1.ErrorWithHttpStatusCode {
|
6
|
+
constructor(message = 'request failed to evaluate within the timeout period') {
|
7
|
+
super(500, message);
|
8
|
+
this.name = 'TimeoutError';
|
9
|
+
}
|
10
|
+
}
|
11
|
+
exports.TimeoutError = TimeoutError;
|
12
|
+
//# sourceMappingURL=TimeoutError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TimeoutError.js","sourceRoot":"","sources":["../../src/error/TimeoutError.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAEpE,MAAa,YAAa,SAAQ,iDAAuB;IAEvD,YAAY,UAAkB,sDAAsD;QAClF,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAFtB,SAAI,GAAG,cAAc,CAAC;IAGtB,CAAC;CACF;AALD,oCAKC"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./BadRequestError"), exports);
|
18
|
+
__exportStar(require("./ErrorWithHttpStatusCode"), exports);
|
19
|
+
__exportStar(require("./InternalServerError"), exports);
|
20
|
+
__exportStar(require("./ResourceNotFoundError"), exports);
|
21
|
+
__exportStar(require("./TimeoutError"), exports);
|
22
|
+
__exportStar(require("./MethodNotImplementedError"), exports);
|
23
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,4DAA0C;AAC1C,wDAAsC;AACtC,0DAAwC;AACxC,iDAA+B;AAC/B,8DAA4C"}
|
package/lib/index.d.ts
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
export * from './assertions/
|
2
|
-
export * from './
|
3
|
-
export * from './
|
4
|
-
export * from './
|
5
|
-
export * from './assertions/assertIsNotAnEmptyString';
|
6
|
-
export * from './assertions/assertAssignWithDefaultUndefinedValue';
|
7
|
-
export * from './assertions/assertAssign';
|
1
|
+
export * from './assertions/';
|
2
|
+
export * from './error';
|
3
|
+
export * from './util';
|
4
|
+
export * from './zip/zipDirectory';
|
package/lib/index.js
CHANGED
@@ -14,13 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
|
18
|
-
__exportStar(require("./
|
19
|
-
__exportStar(require("./
|
20
|
-
__exportStar(require("./
|
21
|
-
__exportStar(require("./assertions/assertIsObject"), exports);
|
22
|
-
__exportStar(require("./assertions/assertIsNotAnEmptyString"), exports);
|
23
|
-
// Assert assign
|
24
|
-
__exportStar(require("./assertions/assertAssignWithDefaultUndefinedValue"), exports);
|
25
|
-
__exportStar(require("./assertions/assertAssign"), exports);
|
17
|
+
__exportStar(require("./assertions/"), exports);
|
18
|
+
__exportStar(require("./error"), exports);
|
19
|
+
__exportStar(require("./util"), exports);
|
20
|
+
__exportStar(require("./zip/zipDirectory"), exports);
|
26
21
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,0CAAwB;AACxB,yCAAuB;AACvB,qDAAmC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function getNodeEnv(): 'production' | 'development';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getNodeEnv = void 0;
|
4
|
+
function getNodeEnv() {
|
5
|
+
if (process.env.NODE_ENV == 'production') {
|
6
|
+
return 'production';
|
7
|
+
}
|
8
|
+
if (process.env.NODE_ENV == 'development' || process.env.NODE_ENV === undefined) {
|
9
|
+
return 'development';
|
10
|
+
}
|
11
|
+
throw new Error('NODE_ENV env var can only be values "production" or "development"');
|
12
|
+
}
|
13
|
+
exports.getNodeEnv = getNodeEnv;
|
14
|
+
//# sourceMappingURL=getNodeEnv.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getNodeEnv.js","sourceRoot":"","sources":["../../src/util/getNodeEnv.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU;IACxB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,YAAY,EAAE;QACxC,OAAO,YAAY,CAAC;KACrB;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,EAAE;QAC/E,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;AACvF,CAAC;AAVD,gCAUC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const getNodeEnv_1 = require("./getNodeEnv");
|
4
|
+
describe('getNodeEnv', () => {
|
5
|
+
it('should return production if NODE_ENV equals production', () => {
|
6
|
+
process.env.NODE_ENV = 'production';
|
7
|
+
expect((0, getNodeEnv_1.getNodeEnv)()).toEqual('production');
|
8
|
+
});
|
9
|
+
it('should return development if NODE_ENV equals development', () => {
|
10
|
+
process.env.NODE_ENV = 'development';
|
11
|
+
expect((0, getNodeEnv_1.getNodeEnv)()).toEqual('development');
|
12
|
+
});
|
13
|
+
it('should return development if NODE_ENV is not set', () => {
|
14
|
+
delete process.env.NODE_ENV;
|
15
|
+
expect((0, getNodeEnv_1.getNodeEnv)()).toEqual('development');
|
16
|
+
});
|
17
|
+
it('should throw if NODE_ENV set to non valid environment', () => {
|
18
|
+
process.env.NODE_ENV = 'invalid';
|
19
|
+
expect(() => (0, getNodeEnv_1.getNodeEnv)()).toThrowError(new Error('NODE_ENV env var can only be values "production" or "development"'));
|
20
|
+
});
|
21
|
+
});
|
22
|
+
//# sourceMappingURL=getNodeEnv.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getNodeEnv.spec.js","sourceRoot":"","sources":["../../src/util/getNodeEnv.spec.ts"],"names":[],"mappings":";;AAAA,6CAA0C;AAE1C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;QACpC,MAAM,CAAC,IAAA,uBAAU,GAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAC;QACrC,MAAM,CAAC,IAAA,uBAAU,GAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC5B,MAAM,CAAC,IAAA,uBAAU,GAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC;QACjC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,uBAAU,GAAE,CAAC,CAAC,YAAY,CACrC,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAC/E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export declare type PageInfoResult = {
|
2
|
+
current: number;
|
3
|
+
next: number | null;
|
4
|
+
previous: number | null;
|
5
|
+
totalPages: number;
|
6
|
+
totalItems: number;
|
7
|
+
pageSize: number;
|
8
|
+
};
|
9
|
+
export declare function getPageInfo(current: number, pageSize: number, totalItems: number): PageInfoResult;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getPageInfo = void 0;
|
4
|
+
function getPageInfo(current, pageSize, totalItems) {
|
5
|
+
const totalPages = Math.ceil(totalItems / pageSize);
|
6
|
+
const next = current + 1 > totalPages ? null : current + 1;
|
7
|
+
const previous = current <= 1 ? null : current - 1;
|
8
|
+
return {
|
9
|
+
current,
|
10
|
+
next,
|
11
|
+
previous,
|
12
|
+
totalPages,
|
13
|
+
totalItems,
|
14
|
+
pageSize,
|
15
|
+
};
|
16
|
+
}
|
17
|
+
exports.getPageInfo = getPageInfo;
|
18
|
+
//# sourceMappingURL=getPageInfo.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getPageInfo.js","sourceRoot":"","sources":["../../src/util/getPageInfo.ts"],"names":[],"mappings":";;;AASA,SAAgB,WAAW,CAAC,OAAe,EAAE,QAAgB,EAAE,UAAkB;IAC/E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;IAEnD,OAAO;QACL,OAAO;QACP,IAAI;QACJ,QAAQ;QACR,UAAU;QACV,UAAU;QACV,QAAQ;KACT,CAAC;AACJ,CAAC;AAbD,kCAaC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export { getNodeEnv } from './getNodeEnv';
|
2
|
+
export { isPathTryingToAccessOutsideOfRoot } from './isPathTryingToAccessOutsideOfRoot';
|
3
|
+
export { joinAbsoluteUrlPath } from './joinAbsoluteUrlPath';
|
4
|
+
export { parseEnvVarForVar } from './parseEnvVarForVar';
|
5
|
+
export { isReadable } from './isReadable';
|
6
|
+
export { never } from './never';
|
7
|
+
export { getPageInfo, PageInfoResult } from './getPageInfo';
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getPageInfo = exports.never = exports.isReadable = exports.parseEnvVarForVar = exports.joinAbsoluteUrlPath = exports.isPathTryingToAccessOutsideOfRoot = exports.getNodeEnv = void 0;
|
4
|
+
var getNodeEnv_1 = require("./getNodeEnv");
|
5
|
+
Object.defineProperty(exports, "getNodeEnv", { enumerable: true, get: function () { return getNodeEnv_1.getNodeEnv; } });
|
6
|
+
var isPathTryingToAccessOutsideOfRoot_1 = require("./isPathTryingToAccessOutsideOfRoot");
|
7
|
+
Object.defineProperty(exports, "isPathTryingToAccessOutsideOfRoot", { enumerable: true, get: function () { return isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot; } });
|
8
|
+
var joinAbsoluteUrlPath_1 = require("./joinAbsoluteUrlPath");
|
9
|
+
Object.defineProperty(exports, "joinAbsoluteUrlPath", { enumerable: true, get: function () { return joinAbsoluteUrlPath_1.joinAbsoluteUrlPath; } });
|
10
|
+
var parseEnvVarForVar_1 = require("./parseEnvVarForVar");
|
11
|
+
Object.defineProperty(exports, "parseEnvVarForVar", { enumerable: true, get: function () { return parseEnvVarForVar_1.parseEnvVarForVar; } });
|
12
|
+
var isReadable_1 = require("./isReadable");
|
13
|
+
Object.defineProperty(exports, "isReadable", { enumerable: true, get: function () { return isReadable_1.isReadable; } });
|
14
|
+
var never_1 = require("./never");
|
15
|
+
Object.defineProperty(exports, "never", { enumerable: true, get: function () { return never_1.never; } });
|
16
|
+
var getPageInfo_1 = require("./getPageInfo");
|
17
|
+
Object.defineProperty(exports, "getPageInfo", { enumerable: true, get: function () { return getPageInfo_1.getPageInfo; } });
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,yFAAwF;AAA/E,sJAAA,iCAAiC,OAAA;AAC1C,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,6CAA4D;AAAnD,0GAAA,WAAW,OAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function isPathTryingToAccessOutsideOfRoot(rootPath: string, filePath: string): boolean;
|