type-fns 1.16.0 → 1.17.0
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/dist/utils/environment.d.ts +2 -1
- package/dist/utils/environment.js +18 -1
- package/dist/utils/environment.js.map +1 -1
- package/package.json +18 -14
- package/dist/utils/errors/UnexpectedCodePathError.d.ts +0 -9
- package/dist/utils/errors/UnexpectedCodePathError.js +0 -17
- package/dist/utils/errors/UnexpectedCodePathError.js.map +0 -1
|
@@ -3,5 +3,6 @@ export declare enum Stage {
|
|
|
3
3
|
DEVELOPMENT = "dev",
|
|
4
4
|
TEST = "test"
|
|
5
5
|
}
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const isOfStage: import("type-fns").AssessWithAssure<string | number | symbol, Stage>;
|
|
7
|
+
export declare const stage: Stage;
|
|
7
8
|
export declare const serviceClientStage: Stage;
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serviceClientStage = exports.stage = exports.Stage = void 0;
|
|
3
|
+
exports.serviceClientStage = exports.stage = exports.isOfStage = exports.Stage = void 0;
|
|
4
|
+
const error_fns_1 = require("@ehmpathy/error-fns");
|
|
5
|
+
const type_fns_1 = require("type-fns");
|
|
4
6
|
var Stage;
|
|
5
7
|
(function (Stage) {
|
|
6
8
|
Stage["PRODUCTION"] = "prod";
|
|
7
9
|
Stage["DEVELOPMENT"] = "dev";
|
|
8
10
|
Stage["TEST"] = "test";
|
|
9
11
|
})(Stage || (exports.Stage = Stage = {}));
|
|
12
|
+
exports.isOfStage = (0, type_fns_1.createIsOfEnum)(Stage);
|
|
13
|
+
/**
|
|
14
|
+
* verify that the server is on UTC timezone
|
|
15
|
+
*
|
|
16
|
+
* why?
|
|
17
|
+
* - non UTC timezone usage causes problems and takes a while to track down
|
|
18
|
+
* - by failing fast if the server our code runs in is not in UTC, we avoid these issues
|
|
19
|
+
* =>
|
|
20
|
+
* - create a pit of success
|
|
21
|
+
*/
|
|
22
|
+
const TIMEZONE = process.env.TZ;
|
|
23
|
+
if (TIMEZONE !== 'UTC')
|
|
24
|
+
throw new error_fns_1.UnexpectedCodePathError('env.TZ is not set to UTC. this can cause issues. please set the env var', { found: TIMEZONE, desire: 'UTC' });
|
|
10
25
|
/**
|
|
11
26
|
* this allows us to infer what the stage should be in environments that do not have STAGE specified
|
|
12
27
|
* - e.g., when running locally
|
|
@@ -32,6 +47,8 @@ const getEnvironment = () => {
|
|
|
32
47
|
const stage = (_a = process.env.STAGE) !== null && _a !== void 0 ? _a : inferStageFromNodeEnv(); // figure it out from NODE_ENV if not explicitly defined
|
|
33
48
|
if (!stage)
|
|
34
49
|
throw new Error('process.env.STAGE must be defined');
|
|
50
|
+
if (!(0, exports.isOfStage)(stage))
|
|
51
|
+
throw new Error(`invalid stage defined '${stage}'`);
|
|
35
52
|
return { stage };
|
|
36
53
|
};
|
|
37
54
|
// export stage immediately, since it does not change
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":";;;AAAA,IAAY,KAIX;AAJD,WAAY,KAAK;IACf,4BAAmB,CAAA;IACnB,4BAAmB,CAAA;IACnB,sBAAa,CAAA;AACf,CAAC,EAJW,KAAK,qBAAL,KAAK,QAIhB;
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":";;;AAAA,mDAA8D;AAC9D,uCAA0C;AAE1C,IAAY,KAIX;AAJD,WAAY,KAAK;IACf,4BAAmB,CAAA;IACnB,4BAAmB,CAAA;IACnB,sBAAa,CAAA;AACf,CAAC,EAJW,KAAK,qBAAL,KAAK,QAIhB;AACY,QAAA,SAAS,GAAG,IAAA,yBAAc,EAAC,KAAK,CAAC,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,OAAO,CAAC,GA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CAAC,WAAW,CAAC,CAAC,8CAA8C"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "type-fns",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "A set of types, type checks, and type guards for simpler, safer, and easier to read code.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.17.0",
|
|
6
6
|
"repository": "ehmpathy/type-fns",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/type-fns",
|
|
8
8
|
"keywords": [
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"typescript"
|
|
17
17
|
],
|
|
18
18
|
"bugs": "https://github.com/ehmpathy/type-fns/issues",
|
|
19
|
+
"license": "MIT",
|
|
19
20
|
"main": "dist/index.js",
|
|
20
21
|
"engines": {
|
|
21
22
|
"node": ">=8.0.0"
|
|
@@ -34,25 +35,31 @@
|
|
|
34
35
|
"build": "npm run build:clean && npm run build:compile",
|
|
35
36
|
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
36
37
|
"test:types": "tsc -p ./tsconfig.build.json --noEmit",
|
|
37
|
-
"prepublish": "npm run build",
|
|
38
38
|
"test:format:prettier": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
|
|
39
39
|
"test:format": "npm run test:format:prettier",
|
|
40
40
|
"test:lint:deps": "npx depcheck -c ./depcheckrc.yml",
|
|
41
41
|
"test:lint:eslint": "eslint -c ./.eslintrc.js src/**/*.ts",
|
|
42
42
|
"test:lint": "npm run test:lint:eslint && npm run test:lint:deps",
|
|
43
|
-
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests",
|
|
44
|
-
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests",
|
|
43
|
+
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
|
|
44
|
+
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
|
|
45
45
|
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
|
|
46
46
|
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
47
47
|
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
|
|
48
48
|
"prepush": "npm run test && npm run build",
|
|
49
|
+
"prepublish": "npm run build",
|
|
49
50
|
"preversion": "npm run prepush",
|
|
50
|
-
"postversion": "git push origin HEAD --tags --no-verify"
|
|
51
|
+
"postversion": "git push origin HEAD --tags --no-verify",
|
|
52
|
+
"postinstall": "[ -d .git ] && npx husky install || exit 0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@ehmpathy/error-fns": "1.0.2",
|
|
56
|
+
"type-fns": "1.16.0",
|
|
57
|
+
"uuid": "9.0.0"
|
|
51
58
|
},
|
|
52
59
|
"devDependencies": {
|
|
53
|
-
"@commitlint/cli": "
|
|
60
|
+
"@commitlint/cli": "19.3.0",
|
|
54
61
|
"@commitlint/config-conventional": "13.1.0",
|
|
55
|
-
"@trivago/prettier-plugin-sort-imports": "
|
|
62
|
+
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
56
63
|
"@tsconfig/node-lts-strictest": "18.12.1",
|
|
57
64
|
"@types/jest": "29.2.4",
|
|
58
65
|
"@types/uuid": "9.0.0",
|
|
@@ -60,19 +67,19 @@
|
|
|
60
67
|
"@typescript-eslint/parser": "7.8.0",
|
|
61
68
|
"core-js": "3.26.1",
|
|
62
69
|
"cz-conventional-changelog": "3.3.0",
|
|
63
|
-
"declapract": "0.11.
|
|
64
|
-
"declapract-typescript-ehmpathy": "0.
|
|
70
|
+
"declapract": "0.11.5",
|
|
71
|
+
"declapract-typescript-ehmpathy": "0.33.6",
|
|
65
72
|
"depcheck": "1.4.3",
|
|
66
73
|
"eslint": "8.56.0",
|
|
67
74
|
"eslint-config-airbnb-typescript": "18.0.0",
|
|
68
75
|
"eslint-config-prettier": "8.5.0",
|
|
69
76
|
"eslint-plugin-import": "2.26.0",
|
|
70
77
|
"eslint-plugin-prettier": "4.2.1",
|
|
71
|
-
"husky": "
|
|
78
|
+
"husky": "8.0.3",
|
|
72
79
|
"jest": "29.3.1",
|
|
73
80
|
"prettier": "2.8.1",
|
|
74
81
|
"test-fns": "1.3.0",
|
|
75
|
-
"ts-jest": "29.
|
|
82
|
+
"ts-jest": "29.1.3",
|
|
76
83
|
"ts-node": "10.9.2",
|
|
77
84
|
"typescript": "5.4.5",
|
|
78
85
|
"uuid": "^3.3.3"
|
|
@@ -81,8 +88,5 @@
|
|
|
81
88
|
"commitizen": {
|
|
82
89
|
"path": "./node_modules/cz-conventional-changelog"
|
|
83
90
|
}
|
|
84
|
-
},
|
|
85
|
-
"dependencies": {
|
|
86
|
-
"@ehmpathy/error-fns": "1.0.2"
|
|
87
91
|
}
|
|
88
92
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UnexpectedCodePath errors are used to indicate that we've reached a code path that should never have been reached
|
|
3
|
-
*
|
|
4
|
-
* Purpose of having a dedicated class for this type of error is to allow us to easily add metadata about what was going on when we reached this code path
|
|
5
|
-
* - e.g., the variables in memory at the time
|
|
6
|
-
*/
|
|
7
|
-
export declare class UnexpectedCodePathError extends Error {
|
|
8
|
-
constructor(message: string, metadata?: Record<string, any>);
|
|
9
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnexpectedCodePathError = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* UnexpectedCodePath errors are used to indicate that we've reached a code path that should never have been reached
|
|
6
|
-
*
|
|
7
|
-
* Purpose of having a dedicated class for this type of error is to allow us to easily add metadata about what was going on when we reached this code path
|
|
8
|
-
* - e.g., the variables in memory at the time
|
|
9
|
-
*/
|
|
10
|
-
class UnexpectedCodePathError extends Error {
|
|
11
|
-
constructor(message, metadata) {
|
|
12
|
-
const fullMessage = `UnexpectedCodePath: ${message}${metadata ? `\n\n${JSON.stringify(metadata)}` : ''}}`;
|
|
13
|
-
super(fullMessage);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.UnexpectedCodePathError = UnexpectedCodePathError;
|
|
17
|
-
//# sourceMappingURL=UnexpectedCodePathError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UnexpectedCodePathError.js","sourceRoot":"","sources":["../../../src/utils/errors/UnexpectedCodePathError.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe,EAAE,QAA8B;QACzD,MAAM,WAAW,GAAG,uBAAuB,OAAO,GAChD,QAAQ,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EACjD,GAAG,CAAC;QACJ,KAAK,CAAC,WAAW,CAAC,CAAC;IACrB,CAAC;CACF;AAPD,0DAOC"}
|