@squiz/dx-common-lib 1.2.1-alpha.107 → 1.2.1-alpha.99

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.
Files changed (108) hide show
  1. package/CHANGELOG.md +0 -64
  2. package/jest.integration.config.ts +26 -0
  3. package/lib/assertions/assertAssignWithDefaultUndefinedValue.d.ts +0 -1
  4. package/lib/assertions/assertAssignWithDefaultUndefinedValue.js +1 -3
  5. package/lib/assertions/assertAssignWithDefaultUndefinedValue.js.map +1 -1
  6. package/lib/index.d.ts +7 -4
  7. package/lib/index.js +9 -4
  8. package/lib/index.js.map +1 -1
  9. package/package.json +6 -12
  10. package/src/assertions/assertAssignWithDefaultUndefinedValue.ts +0 -5
  11. package/src/index.ts +10 -4
  12. package/tsconfig.tsbuildinfo +1 -1
  13. package/lib/assertions/assertIsEnumValue.d.ts +0 -1
  14. package/lib/assertions/assertIsEnumValue.js +0 -18
  15. package/lib/assertions/assertIsEnumValue.js.map +0 -1
  16. package/lib/assertions/assertIsEnumValue.spec.d.ts +0 -1
  17. package/lib/assertions/assertIsEnumValue.spec.js +0 -39
  18. package/lib/assertions/assertIsEnumValue.spec.js.map +0 -1
  19. package/lib/assertions/index.d.ts +0 -8
  20. package/lib/assertions/index.js +0 -27
  21. package/lib/assertions/index.js.map +0 -1
  22. package/lib/error/BadRequestError.d.ts +0 -4
  23. package/lib/error/BadRequestError.js +0 -11
  24. package/lib/error/BadRequestError.js.map +0 -1
  25. package/lib/error/ErrorWithHttpStatusCode.d.ts +0 -5
  26. package/lib/error/ErrorWithHttpStatusCode.js +0 -12
  27. package/lib/error/ErrorWithHttpStatusCode.js.map +0 -1
  28. package/lib/error/InternalServerError.d.ts +0 -4
  29. package/lib/error/InternalServerError.js +0 -11
  30. package/lib/error/InternalServerError.js.map +0 -1
  31. package/lib/error/MethodNotImplementedError.d.ts +0 -4
  32. package/lib/error/MethodNotImplementedError.js +0 -11
  33. package/lib/error/MethodNotImplementedError.js.map +0 -1
  34. package/lib/error/ResourceNotFoundError.d.ts +0 -4
  35. package/lib/error/ResourceNotFoundError.js +0 -11
  36. package/lib/error/ResourceNotFoundError.js.map +0 -1
  37. package/lib/error/TimeoutError.d.ts +0 -5
  38. package/lib/error/TimeoutError.js +0 -12
  39. package/lib/error/TimeoutError.js.map +0 -1
  40. package/lib/error/index.d.ts +0 -6
  41. package/lib/error/index.js +0 -23
  42. package/lib/error/index.js.map +0 -1
  43. package/lib/util/getNodeEnv.d.ts +0 -1
  44. package/lib/util/getNodeEnv.js +0 -14
  45. package/lib/util/getNodeEnv.js.map +0 -1
  46. package/lib/util/getNodeEnv.spec.d.ts +0 -1
  47. package/lib/util/getNodeEnv.spec.js +0 -22
  48. package/lib/util/getNodeEnv.spec.js.map +0 -1
  49. package/lib/util/getPageInfo.d.ts +0 -9
  50. package/lib/util/getPageInfo.js +0 -18
  51. package/lib/util/getPageInfo.js.map +0 -1
  52. package/lib/util/index.d.ts +0 -7
  53. package/lib/util/index.js +0 -18
  54. package/lib/util/index.js.map +0 -1
  55. package/lib/util/isPathTryingToAccessOutsideOfRoot.d.ts +0 -1
  56. package/lib/util/isPathTryingToAccessOutsideOfRoot.js +0 -14
  57. package/lib/util/isPathTryingToAccessOutsideOfRoot.js.map +0 -1
  58. package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.d.ts +0 -1
  59. package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js +0 -25
  60. package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js.map +0 -1
  61. package/lib/util/isReadable.d.ts +0 -1
  62. package/lib/util/isReadable.js +0 -20
  63. package/lib/util/isReadable.js.map +0 -1
  64. package/lib/util/joinAbsoluteUrlPath.d.ts +0 -1
  65. package/lib/util/joinAbsoluteUrlPath.js +0 -26
  66. package/lib/util/joinAbsoluteUrlPath.js.map +0 -1
  67. package/lib/util/joinAbsoluteUrlPath.spec.d.ts +0 -1
  68. package/lib/util/joinAbsoluteUrlPath.spec.js +0 -43
  69. package/lib/util/joinAbsoluteUrlPath.spec.js.map +0 -1
  70. package/lib/util/never.d.ts +0 -1
  71. package/lib/util/never.js +0 -9
  72. package/lib/util/never.js.map +0 -1
  73. package/lib/util/parseEnvVarForVar.d.ts +0 -1
  74. package/lib/util/parseEnvVarForVar.js +0 -15
  75. package/lib/util/parseEnvVarForVar.js.map +0 -1
  76. package/lib/util/parseEnvVarForVar.spec.d.ts +0 -1
  77. package/lib/util/parseEnvVarForVar.spec.js +0 -20
  78. package/lib/util/parseEnvVarForVar.spec.js.map +0 -1
  79. package/lib/zip/zipDirectory.d.ts +0 -1
  80. package/lib/zip/zipDirectory.js +0 -32
  81. package/lib/zip/zipDirectory.js.map +0 -1
  82. package/lib/zip/zipDirectory.spec.d.ts +0 -1
  83. package/lib/zip/zipDirectory.spec.js +0 -25
  84. package/lib/zip/zipDirectory.spec.js.map +0 -1
  85. package/src/assertions/assertIsEnumValue.spec.ts +0 -39
  86. package/src/assertions/assertIsEnumValue.ts +0 -15
  87. package/src/assertions/index.ts +0 -11
  88. package/src/error/BadRequestError.ts +0 -7
  89. package/src/error/ErrorWithHttpStatusCode.ts +0 -5
  90. package/src/error/InternalServerError.ts +0 -7
  91. package/src/error/MethodNotImplementedError.ts +0 -7
  92. package/src/error/ResourceNotFoundError.ts +0 -7
  93. package/src/error/TimeoutError.ts +0 -8
  94. package/src/error/index.ts +0 -6
  95. package/src/util/getNodeEnv.spec.ts +0 -25
  96. package/src/util/getNodeEnv.ts +0 -11
  97. package/src/util/getPageInfo.ts +0 -23
  98. package/src/util/index.ts +0 -7
  99. package/src/util/isPathTryingToAccessOutsideOfRoot.spec.ts +0 -25
  100. package/src/util/isPathTryingToAccessOutsideOfRoot.ts +0 -8
  101. package/src/util/isReadable.ts +0 -12
  102. package/src/util/joinAbsoluteUrlPath.spec.ts +0 -62
  103. package/src/util/joinAbsoluteUrlPath.ts +0 -22
  104. package/src/util/never.ts +0 -4
  105. package/src/util/parseEnvVarForVar.spec.ts +0 -22
  106. package/src/util/parseEnvVarForVar.ts +0 -12
  107. package/src/zip/zipDirectory.spec.ts +0 -24
  108. package/src/zip/zipDirectory.ts +0 -31
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
1
- export * from './BadRequestError';
2
- export * from './ErrorWithHttpStatusCode';
3
- export * from './InternalServerError';
4
- export * from './ResourceNotFoundError';
5
- export * from './TimeoutError';
6
- export * from './MethodNotImplementedError';
@@ -1,23 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export declare function getNodeEnv(): 'production' | 'development';
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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;
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
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';
package/lib/util/index.js DELETED
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export declare function isPathTryingToAccessOutsideOfRoot(rootPath: string, filePath: string): boolean;
@@ -1,14 +0,0 @@
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.isPathTryingToAccessOutsideOfRoot = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- function isPathTryingToAccessOutsideOfRoot(rootPath, filePath) {
9
- const resolvedRoot = path_1.default.resolve(rootPath);
10
- const joinedPath = path_1.default.join(resolvedRoot, filePath);
11
- return !joinedPath.includes(resolvedRoot);
12
- }
13
- exports.isPathTryingToAccessOutsideOfRoot = isPathTryingToAccessOutsideOfRoot;
14
- //# sourceMappingURL=isPathTryingToAccessOutsideOfRoot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isPathTryingToAccessOutsideOfRoot.js","sourceRoot":"","sources":["../../src/util/isPathTryingToAccessOutsideOfRoot.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,SAAgB,iCAAiC,CAAC,QAAgB,EAAE,QAAgB;IAClF,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrD,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC;AALD,8EAKC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const isPathTryingToAccessOutsideOfRoot_1 = require("./isPathTryingToAccessOutsideOfRoot");
4
- describe('isPathTryingToAccessOutsideOfRoot', () => {
5
- it("should return false if filepath doesn't try to access outside of root", () => {
6
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('my-root/', 'hello')).toEqual(false);
7
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('my-root/', './hello')).toEqual(false);
8
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('my-root/', './hello/../')).toEqual(false);
9
- });
10
- it('should resolve a relative root path', () => {
11
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello')).toEqual(false);
12
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello/../world')).toEqual(false);
13
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello/world/..')).toEqual(false);
14
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', './')).toEqual(false);
15
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/something', './else')).toEqual(false);
16
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/something', './else/1/../../')).toEqual(false);
17
- });
18
- it('should return true if filepath does access outside of the root', () => {
19
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', '../')).toEqual(true);
20
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', '../../')).toEqual(true);
21
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello/../world/../../')).toEqual(true);
22
- expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello/../../')).toEqual(true);
23
- });
24
- });
25
- //# sourceMappingURL=isPathTryingToAccessOutsideOfRoot.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isPathTryingToAccessOutsideOfRoot.spec.js","sourceRoot":"","sources":["../../src/util/isPathTryingToAccessOutsideOfRoot.spec.ts"],"names":[],"mappings":";;AAAA,2FAAwF;AAExF,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,MAAM,CAAC,IAAA,qEAAiC,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9E,MAAM,CAAC,IAAA,qEAAiC,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChF,MAAM,CAAC,IAAA,qEAAiC,EAAC,UAAU,EAA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,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export declare function isReadable(basePath: string, file: string): Promise<boolean>;
@@ -1,20 +0,0 @@
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.isReadable = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const fs_1 = require("fs");
10
- async function isReadable(basePath, file) {
11
- try {
12
- await fs_extra_1.default.access(path_1.default.join(basePath, file), fs_1.constants.R_OK);
13
- return true;
14
- }
15
- catch {
16
- return false;
17
- }
18
- }
19
- exports.isReadable = isReadable;
20
- //# sourceMappingURL=isReadable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isReadable.js","sourceRoot":"","sources":["../../src/util/isReadable.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,wDAA2B;AAC3B,2BAA+B;AAExB,KAAK,UAAU,UAAU,CAAC,QAAgB,EAAE,IAAY;IAC7D,IAAI;QACF,MAAM,kBAAG,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,cAAS,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC;KACb;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAPD,gCAOC"}
@@ -1 +0,0 @@
1
- export declare function joinAbsoluteUrlPath(...args: string[]): string;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinAbsoluteUrlPath = void 0;
4
- function joinAbsoluteUrlPath(...args) {
5
- const [rootUrl] = args;
6
- /**
7
- * This method takes any form of input string and resolves them to make an absolute url
8
- * Since these paths are web paths and not file paths, we are creating a URL object (https://nodejs.org/api/url.html). http://example.com has just been used as a dummy entry to create a valid url.
9
- * Note: path.resolves gives you different output based on the OS node is running on. More reading here https://nodejs.org/api/path.html#windows-vs-posix.
10
- */
11
- const url = new URL(getSanitisedString(args), 'http://example.com');
12
- if (urlIsAbsolute(rootUrl)) {
13
- return url.toString();
14
- }
15
- else {
16
- return url.pathname.replace(/(^\/|\/$)/g, '');
17
- }
18
- }
19
- exports.joinAbsoluteUrlPath = joinAbsoluteUrlPath;
20
- function getSanitisedString(subdirs) {
21
- return subdirs.map((dir) => dir.replace(/(^\.\/+)|(^\/+|\/+$)/g, '')).join('/');
22
- }
23
- function urlIsAbsolute(url) {
24
- return url.match(/^http(s?):\/\//);
25
- }
26
- //# sourceMappingURL=joinAbsoluteUrlPath.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"joinAbsoluteUrlPath.js","sourceRoot":"","sources":["../../src/util/joinAbsoluteUrlPath.ts"],"names":[],"mappings":";;;AAAA,SAAgB,mBAAmB,CAAC,GAAG,IAAc;IACnD,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACvB;;;;OAIG;IACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC;IACpE,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE;QAC1B,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;KACvB;SAAM;QACL,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;KAC/C;AACH,CAAC;AAbD,kDAaC;AAED,SAAS,kBAAkB,CAAC,OAAiB;IAC3C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACrC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const joinAbsoluteUrlPath_1 = require("./joinAbsoluteUrlPath");
4
- describe('joinAbsoluteUrlPath', () => {
5
- it('should return a valid absolute url for protocol based inputs', () => {
6
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com', 'aaa', 'bbb')).toEqual('https://example.com/aaa/bbb');
7
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', '/aaa', 'bbb')).toEqual('https://example.com/aaa/bbb');
8
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', '/aaa/', '/bbb///')).toEqual('https://example.com/aaa/bbb');
9
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', './..///', '/bbb///')).toEqual('https://example.com/bbb');
10
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', './aaa/', '/bbb/')).toEqual('https://example.com/aaa/bbb');
11
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', '../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
12
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', 'ccc', '../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
13
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', 'ccc', '../../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
14
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', 'ccc', '/../../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
15
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', 'ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('https://example.com/ddd/aaa/bbb');
16
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', 'aaa', 'bbb')).toEqual('http://localhost:3000/aaa/bbb');
17
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', '/aaa', 'bbb')).toEqual('http://localhost:3000/aaa/bbb');
18
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', '/aaa/', '/bbb///')).toEqual('http://localhost:3000/aaa/bbb');
19
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', './aaa/', '/bbb/')).toEqual('http://localhost:3000/aaa/bbb');
20
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', '../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
21
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', 'ccc', '../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
22
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', 'ccc', '../../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
23
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', 'ccc', '/../../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
24
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000/', 'ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('http://localhost:3000/ddd/aaa/bbb');
25
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000/', 'localhost', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('http://localhost:3000/localhost/aaa/bbb');
26
- });
27
- it('should return a valid resolved path for inputs', () => {
28
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('aaa', 'bbb')).toEqual('aaa/bbb');
29
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('/aaa', 'bbb')).toEqual('aaa/bbb');
30
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('/aaa/', '/bbb///')).toEqual('aaa/bbb');
31
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('./aaa/', '/bbb/')).toEqual('aaa/bbb');
32
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('../aaa/', '/bbb')).toEqual('aaa/bbb');
33
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('ccc', '../aaa/', '/bbb')).toEqual('aaa/bbb');
34
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('ccc', '../../aaa/', '/bbb')).toEqual('aaa/bbb');
35
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('ccc', '/../../aaa/', '/bbb')).toEqual('aaa/bbb');
36
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('ddd/aaa/bbb');
37
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http', 'ccc', '/aaa/', '/bbb')).toEqual('http/ccc/aaa/bbb');
38
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https', 'ccc', '/aaa/', '/bbb')).toEqual('https/ccc/aaa/bbb');
39
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https', '../ccc', '/aaa/', '/bbb')).toEqual('ccc/aaa/bbb');
40
- expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https', './ccc', '/aaa/', '/bbb')).toEqual('https/ccc/aaa/bbb');
41
- });
42
- });
43
- //# sourceMappingURL=joinAbsoluteUrlPath.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"joinAbsoluteUrlPath.spec.js","sourceRoot":"","sources":["../../src/util/joinAbs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AC,CAAC;QAC7E,MAAM,CAAC,IAAA,yCAAmB,EAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC/F,MAAM,CAAC,IAAA,yCAAmB,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACxF,MAAM,CAAC,IAAA,yCAAmB,EAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAC1F,MAAM,CAAC,IAAA,yCAAmB,EAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACvF,MAAM,CAAC,IAAA,yCAAmB,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export declare function never(a: never): never;
package/lib/util/never.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.never = void 0;
4
- function never(a) {
5
- // this should never be executed. This is a compile time check
6
- throw new Error(`value ${a} is not valid`);
7
- }
8
- exports.never = never;
9
- //# sourceMappingURL=never.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"never.js","sourceRoot":"","sources":["../../src/util/never.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CAAC,CAAQ;IAC5B,8DAA8D;IAC9D,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAC7C,CAAC;AAHD,sBAGC"}
@@ -1 +0,0 @@
1
- export declare function parseEnvVarForVar(varName: string, defaultValue?: string | undefined): string;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseEnvVarForVar = void 0;
4
- function parseEnvVarForVar(varName, defaultValue = undefined) {
5
- if (process.env[varName] === undefined) {
6
- if (defaultValue !== undefined) {
7
- return defaultValue;
8
- }
9
- throw new Error(`env variable ${varName} must be set`);
10
- }
11
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12
- return process.env[varName];
13
- }
14
- exports.parseEnvVarForVar = parseEnvVarForVar;
15
- //# sourceMappingURL=parseEnvVarForVar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseEnvVarForVar.js","sourceRoot":"","sources":["../../src/util/parseEnvVarForVar.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAAC,OAAe,EAAE,eAAmC,SAAS;IAC7F,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;QACtC,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,OAAO,YAAY,CAAC;SACrB;QAED,MAAM,IAAI,KAAK,CAAC,gBAAgB,OAAO,cAAc,CAAC,CAAC;KACxD;IAED,oEAAoE;IACpE,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAE,CAAC;AAC/B,CAAC;AAXD,8CAWC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const parseEnvVarForVar_1 = require("./parseEnvVarForVar");
4
- describe('parseEnvVarForVar', () => {
5
- it('it should read an environment variable from process.env.*', () => {
6
- process.env.MY_VAR = 'hello';
7
- expect((0, parseEnvVarForVar_1.parseEnvVarForVar)('MY_VAR')).toEqual('hello');
8
- });
9
- it('it should throw an error if the variable is not available', () => {
10
- expect(() => (0, parseEnvVarForVar_1.parseEnvVarForVar)('DOESNT_EXIST')).toThrowError(new Error('env variable DOESNT_EXIST must be set'));
11
- });
12
- it('it should not throw an error if a default value is provided and env var doesnt exist', () => {
13
- expect((0, parseEnvVarForVar_1.parseEnvVarForVar)('DOESNT_EXIST', 'default')).toEqual('default');
14
- });
15
- it('it should return env var if its set and a defualt value is set', () => {
16
- process.env.MY_VAR = 'hello';
17
- expect((0, parseEnvVarForVar_1.parseEnvVarForVar)('MY_VAR', 'default')).toEqual('hello');
18
- });
19
- });
20
- //# sourceMappingURL=parseEnvVarForVar.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseEnvVarForVar.spec.js","sourceRoot":"","sources":["../../src/util/parseEnvVarForVar.spec.ts"],"names":[],"mappings":";;AAAA,2DAAwD;AAExD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC;QAE7B,MAAM,CAAC,IAAA,qCAAiB,EAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,qCAAiB,EAAC,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC,CAAC;IACnH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sFAAsF,EAAE,GAAG,EAAE;QAC9F,MAAM,CAAC,IAAA,qCAAiB,EAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC;QAC7B,MAAM,CAAC,IAAA,qCAAiB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export declare function zipDirectory(sourceDirectory: string, outputDirectory: string): Promise<string>;
@@ -1,32 +0,0 @@
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.zipDirectory = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const archiver_1 = __importDefault(require("archiver"));
10
- function zipDirectory(sourceDirectory, outputDirectory) {
11
- return new Promise((resolve, reject) => {
12
- const outputZipFile = path_1.default.join(outputDirectory, '/export.zip');
13
- const output = fs_1.default.createWriteStream(outputZipFile);
14
- const archive = (0, archiver_1.default)('zip', {
15
- zlib: { level: 9 }, // Sets the compression level.
16
- });
17
- output.on('close', function () {
18
- resolve(outputZipFile);
19
- });
20
- archive.on('warning', function (err) {
21
- reject(err);
22
- });
23
- archive.on('error', function (err) {
24
- reject(err);
25
- });
26
- archive.pipe(output);
27
- archive.directory(sourceDirectory, false);
28
- archive.finalize();
29
- });
30
- }
31
- exports.zipDirectory = zipDirectory;
32
- //# sourceMappingURL=zipDirectory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zipDirectory.js","sourceRoot":"","sources":["../../src/zip/zipDirectory.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,wDAAgC;AAEhC,SAAgB,YAAY,CAAC,eAAuB,EAAE,eAAuB;IAC3E,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,YAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAEnD,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,KAAK,EAAE;YAC9B,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,8BAA8B;SACnD,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,aAAa,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,GAAG;YACjC,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG;YAC/B,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,CAAC,SAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAzBD,oCAyBC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
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
- const path_1 = __importDefault(require("path"));
7
- const fs_1 = __importDefault(require("fs"));
8
- const zipDirectory_1 = require("./zipDirectory");
9
- describe('zipDirectory', () => {
10
- const inputDir = fs_1.default.mkdtempSync('zip-test');
11
- const outDir = fs_1.default.mkdtempSync('zip-test-out');
12
- beforeAll(() => {
13
- fs_1.default.writeFileSync(path_1.default.join(inputDir, 'f1.txt'), '1');
14
- fs_1.default.writeFileSync(path_1.default.join(inputDir, 'f2.txt'), '2');
15
- });
16
- afterAll(() => {
17
- fs_1.default.rmSync(inputDir, { force: true, recursive: true });
18
- fs_1.default.rmSync(outDir, { force: true, recursive: true });
19
- });
20
- it('should take an input path and an output path and create a export.zip', async () => {
21
- await (0, zipDirectory_1.zipDirectory)(inputDir, outDir);
22
- expect(fs_1.default.existsSync(path_1.default.join(outDir, 'export.zip'))).toEqual(true);
23
- });
24
- });
25
- //# sourceMappingURL=zipDirectory.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zipDirectory.spec.js","sourceRoot":"","sources":["../../src/zip/zipDirectory.spec.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,iDAA8C;AAE9C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,MAAM,QAAQ,GAAG,YAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,YAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAE9C,SAAS,CAAC,GAAG,EAAE;QACb,YAAE,CAAC,aAAa,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;QACrD,YAAE,CAAC,aAAa,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,EAAE;QACZ,YAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,YAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;QACpF,MAAM,IAAA,2BAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAErC,MAAM,CAAC,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,39 +0,0 @@
1
- import { AssertionError } from 'assert';
2
- import { assertIsEnumValue } from './assertIsEnumValue';
3
-
4
- describe('assertIsEnumValue', () => {
5
- enum StringEnum {
6
- A = 'a',
7
- B = 'b',
8
- C = 'c',
9
- }
10
-
11
- enum NumEnum {
12
- A,
13
- B,
14
- C,
15
- }
16
-
17
- it('should not show an error if input value is in enum object', () => {
18
- expect(assertIsEnumValue('a', StringEnum)).toBeUndefined();
19
- const val = StringEnum.B;
20
- expect(assertIsEnumValue(val, StringEnum)).toBeUndefined();
21
- });
22
-
23
- it('should not show an error if input value is in enum object (with no default values)', () => {
24
- expect(assertIsEnumValue(2, NumEnum)).toBeUndefined();
25
- const val = NumEnum.C;
26
- expect(assertIsEnumValue(val, NumEnum)).toBeUndefined();
27
- });
28
-
29
- it("should throw an AssertionError is value isn't in enum", () => {
30
- expect(() => assertIsEnumValue('zz', StringEnum)).toThrowError(AssertionError);
31
- expect(() => assertIsEnumValue('zz', StringEnum)).toThrowErrorMatchingInlineSnapshot(`
32
- "'zz' in [
33
- 'a',
34
- 'b',
35
- 'c'
36
- ]"
37
- `);
38
- });
39
- });
@@ -1,15 +0,0 @@
1
- import { AssertionError } from 'assert';
2
-
3
- export function assertIsEnumValue<T extends object>(val: unknown, obj: T): asserts val is T[keyof T] {
4
- if (isValueIsEnumValue(val, obj) === false) {
5
- throw new AssertionError({
6
- actual: val,
7
- expected: Object.values(obj),
8
- operator: 'in',
9
- });
10
- }
11
- }
12
-
13
- function isValueIsEnumValue<TEnum extends object>(val: unknown, enumType: TEnum): val is TEnum[keyof TEnum] {
14
- return Object.values(enumType).includes(val as TEnum[keyof TEnum]);
15
- }
@@ -1,11 +0,0 @@
1
- // Common Assertions
2
- export * from './assertIsString';
3
- export * from './assertIsDefined';
4
- export * from './assertIsMapOfStringString';
5
- export * from './assertIsObject';
6
- export * from './assertIsNotAnEmptyString';
7
- export * from './assertIsEnumValue';
8
-
9
- // Assert assign
10
- export * from './assertAssignWithDefaultUndefinedValue';
11
- export * from './assertAssign';
@@ -1,7 +0,0 @@
1
- import { ErrorWithHttpStatusCode } from './ErrorWithHttpStatusCode';
2
-
3
- export class BadRequestError extends ErrorWithHttpStatusCode {
4
- constructor(message: string) {
5
- super(400, message);
6
- }
7
- }
@@ -1,5 +0,0 @@
1
- export class ErrorWithHttpStatusCode extends Error {
2
- constructor(public statusCode: number, public message: string) {
3
- super(message);
4
- }
5
- }
@@ -1,7 +0,0 @@
1
- import { ErrorWithHttpStatusCode } from './ErrorWithHttpStatusCode';
2
-
3
- export class InternalServerError extends ErrorWithHttpStatusCode {
4
- constructor(message: string) {
5
- super(500, message);
6
- }
7
- }