wrapper-fns 1.1.0 → 1.1.1
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/contract/index.d.ts +5 -5
- package/dist/contract/index.js +5 -5
- package/dist/contract/index.js.map +1 -1
- package/dist/{domain/objects → domain.objects}/Wrapper.d.ts +1 -1
- package/dist/{domain/objects → domain.objects}/Wrapper.js.map +1 -1
- package/dist/domain.operations/withBottleneck.js.map +1 -0
- package/dist/domain.operations/withRetry.d.ts +5 -0
- package/dist/domain.operations/withRetry.js +33 -0
- package/dist/domain.operations/withRetry.js.map +1 -0
- package/dist/{logic → domain.operations}/withTimeout.d.ts +2 -2
- package/dist/domain.operations/withTimeout.js.map +1 -0
- package/dist/{logic → domain.operations}/withWrappers.d.ts +2 -2
- package/dist/domain.operations/withWrappers.js.map +1 -0
- package/license.md +21 -0
- package/package.json +51 -41
- package/dist/logic/withBottleneck.js.map +0 -1
- package/dist/logic/withRetry.d.ts +0 -4
- package/dist/logic/withRetry.js +0 -26
- package/dist/logic/withRetry.js.map +0 -1
- package/dist/logic/withTimeout.js.map +0 -1
- package/dist/logic/withWrappers.js.map +0 -1
- package/dist/logic/withWrappers.test.d.ts +0 -1
- package/dist/logic/withWrappers.test.js +0 -63
- package/dist/logic/withWrappers.test.js.map +0 -1
- /package/dist/{domain/objects → domain.objects}/Wrapper.js +0 -0
- /package/dist/{logic → domain.operations}/withBottleneck.d.ts +0 -0
- /package/dist/{logic → domain.operations}/withBottleneck.js +0 -0
- /package/dist/{logic → domain.operations}/withTimeout.js +0 -0
- /package/dist/{logic → domain.operations}/withWrappers.js +0 -0
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export * from '../
|
|
1
|
+
export * from '../domain.objects/Wrapper';
|
|
2
|
+
export { withBottleneck } from '../domain.operations/withBottleneck';
|
|
3
|
+
export { withRetry } from '../domain.operations/withRetry';
|
|
4
|
+
export { withTimeout } from '../domain.operations/withTimeout';
|
|
5
|
+
export * from '../domain.operations/withWrappers';
|
package/dist/contract/index.js
CHANGED
|
@@ -15,12 +15,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.withTimeout = exports.withRetry = exports.withBottleneck = void 0;
|
|
18
|
-
|
|
18
|
+
__exportStar(require("../domain.objects/Wrapper"), exports);
|
|
19
|
+
var withBottleneck_1 = require("../domain.operations/withBottleneck");
|
|
19
20
|
Object.defineProperty(exports, "withBottleneck", { enumerable: true, get: function () { return withBottleneck_1.withBottleneck; } });
|
|
20
|
-
var withRetry_1 = require("../
|
|
21
|
+
var withRetry_1 = require("../domain.operations/withRetry");
|
|
21
22
|
Object.defineProperty(exports, "withRetry", { enumerable: true, get: function () { return withRetry_1.withRetry; } });
|
|
22
|
-
var withTimeout_1 = require("../
|
|
23
|
+
var withTimeout_1 = require("../domain.operations/withTimeout");
|
|
23
24
|
Object.defineProperty(exports, "withTimeout", { enumerable: true, get: function () { return withTimeout_1.withTimeout; } });
|
|
24
|
-
__exportStar(require("../domain/
|
|
25
|
-
__exportStar(require("../logic/withWrappers"), exports);
|
|
25
|
+
__exportStar(require("../domain.operations/withWrappers"), exports);
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,wEAAuE;AAA9D,gHAAA,cAAc,OAAA;AACvB,8DAA6D;AAApD,sGAAA,SAAS,OAAA;AAClB,kEAAiE;AAAxD,0GAAA,WAAW,OAAA;AACpB,sEAAoD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Procedure } from 'domain-glossary-procedure';
|
|
1
|
+
import type { Procedure } from 'domain-glossary-procedure';
|
|
2
2
|
export type Wrapper<TProcedure extends Procedure, TOptions> = (logic: TProcedure, options: TOptions) => TProcedure;
|
|
3
3
|
export type WrapperChoice<TProcedure extends Procedure, TOptions> = {
|
|
4
4
|
wrapper: Wrapper<TProcedure, TOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wrapper.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"Wrapper.js","sourceRoot":"","sources":["../../src/domain.objects/Wrapper.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withBottleneck.js","sourceRoot":"","sources":["../../src/domain.operations/withBottleneck.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AAEpC,MAAM,4BAA4B,GAAG,IAAI,oBAAU,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC;AAEnE,MAAM,cAAc,GAAG,CAK5B,KAAQ,EACR,UAEI,EAAE,UAAU,EAAE,4BAA4B,EAAE,EAC7C,EAAE;IACL,MAAM,OAAO,GAAG,CAAC,GAAG,IAAO,EAAE,EAAE,CAC7B,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAI,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACvD,OAAO,OAAY,CAAC;AACtB,CAAC,CAAC;AAbW,QAAA,cAAc,kBAazB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Procedure } from 'as-procedure';
|
|
2
|
+
import type { ContextLogTrail } from 'simple-log-methods';
|
|
3
|
+
export declare function withRetry<TOutput>(logic: () => TOutput): typeof logic;
|
|
4
|
+
export declare function withRetry<TInput, TOutput>(logic: (input: TInput) => TOutput): typeof logic;
|
|
5
|
+
export declare function withRetry<TInput, TContext extends ContextLogTrail, TOutput>(logic: Procedure<TInput, TContext, TOutput>): typeof logic;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withRetry = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = wraps a procedure to retry once on error
|
|
6
|
+
* .why = provides resilience against transient failures
|
|
7
|
+
* .note = logs retry attempts if context.log is available, otherwise retries silently
|
|
8
|
+
*/
|
|
9
|
+
function withRetry(logic) {
|
|
10
|
+
return (async (input, context) => {
|
|
11
|
+
try {
|
|
12
|
+
return await logic(input, context);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (!(error instanceof Error))
|
|
16
|
+
throw error;
|
|
17
|
+
// log retry attempt if context.log is available
|
|
18
|
+
const log = context
|
|
19
|
+
?.log;
|
|
20
|
+
if (log?.warn) {
|
|
21
|
+
log.warn('withRetry.progress: caught an error, will retry', {
|
|
22
|
+
error: {
|
|
23
|
+
message: error.message,
|
|
24
|
+
stack: error.stack,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return await logic(input, context);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.withRetry = withRetry;
|
|
33
|
+
//# sourceMappingURL=withRetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withRetry.js","sourceRoot":"","sources":["../../src/domain.operations/withRetry.ts"],"names":[],"mappings":";;;AAgBA;;;;GAIG;AACH,SAAgB,SAAS,CACvB,KAA2C;IAE3C,OAAO,CAAC,KAAK,EACX,KAAmC,EACnC,OAAuC,EACC,EAAE;QAC1C,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YAE3C,gDAAgD;YAChD,MAAM,GAAG,GAAI,OAA6D;gBACxE,EAAE,GAAG,CAAC;YACR,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC;gBACd,GAAG,CAAC,IAAI,CAAC,iDAAiD,EAAE;oBAC1D,KAAK,EAAE;wBACL,OAAO,EAAE,KAAK,CAAC,OAAO;wBACtB,KAAK,EAAE,KAAK,CAAC,KAAK;qBACnB;iBACF,CAAC,CAAC;YACL,CAAC;YAED,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAiB,CAAC;AACrB,CAAC;AA3BD,8BA2BC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UniDuration } from '@ehmpathy/uni-time';
|
|
2
|
-
import { Procedure } from '
|
|
1
|
+
import { type UniDuration } from '@ehmpathy/uni-time';
|
|
2
|
+
import type { Procedure } from 'as-procedure';
|
|
3
3
|
export declare function withTimeout<TInput, TContext, TOutput>(logic: () => TOutput, // empty inputs override
|
|
4
4
|
options: {
|
|
5
5
|
threshold: UniDuration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTimeout.js","sourceRoot":"","sources":["../../src/domain.operations/withTimeout.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AAiBtE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,WAAW,CACzB,KAA2C,EAC3C,OAAmC;IAEnC,MAAM,WAAW,GAAG,IAAA,yBAAc,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtD,OAAO,CACL,KAAmC,EACnC,OAAuC,EACR,EAAE;QACjC,6HAA6H;QAC7H,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;gBACzB,YAAY,CAAC,EAAE,CAAC,CAAC;gBACjB,MAAM,CACJ,IAAI,KAAK,CACP,4BAA4B,WAAW,qBAAqB,CAC7D,CACF,CAAC;YACJ,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,4BAA4B;QAC/C,CAAC,CAAC,CAAC;QAEH,uFAAuF;QACvF,OAAO,OAAO,CAAC,IAAI,CAAC;YAClB,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,+CAA+C;YACtE,OAAO,EAAE,cAAc;SACxB,CAAkC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC;AA3BD,kCA2BC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Procedure } from '
|
|
2
|
-
import { WrapperChoice } from '../domain
|
|
1
|
+
import type { Procedure } from 'as-procedure';
|
|
2
|
+
import type { WrapperChoice } from '../domain.objects/Wrapper';
|
|
3
3
|
/**
|
|
4
4
|
* .what = a helper procedure to ensure that the choice.options matches the wrapper.options
|
|
5
5
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withWrappers.js","sourceRoot":"","sources":["../../src/domain.operations/withWrappers.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACI,MAAM,UAAU,GAAG,CACxB,KAAqC,EACa,EAAE;IACpD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,+FAA+F;AACxJ,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEF;;;;GAIG;AACH,SAAgB,YAAY,CAK1B,KAAiB,EAAE,QAAkB;IACrC,OAAO,QAAQ,CAAC,MAAM,CACpB,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAC5D,KAAK,CACN,CAAC;AACJ,CAAC;AAVD,oCAUC"}
|
package/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 ehmpathy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "wrapper-fns",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "Use wrappers for simpler, safer, and more readable code",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.1",
|
|
6
6
|
"repository": "ehmpathy/wrapper-fns",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/wrapper-fns",
|
|
8
8
|
"keywords": [
|
|
@@ -23,66 +23,76 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build:ts": "tsc -p ./tsconfig.build.json",
|
|
25
25
|
"commit:with-cli": "npx cz",
|
|
26
|
-
"fix:format:
|
|
27
|
-
"fix:format": "npm run fix:format:
|
|
28
|
-
"fix:lint": "
|
|
29
|
-
"
|
|
30
|
-
"build:
|
|
31
|
-
"build": "
|
|
26
|
+
"fix:format:biome": "biome check --write",
|
|
27
|
+
"fix:format": "npm run fix:format:biome",
|
|
28
|
+
"fix:lint": "biome check --write",
|
|
29
|
+
"fix": "npm run fix:format && npm run fix:lint",
|
|
30
|
+
"build:clean": "chmod -R u+w dist 2>/dev/null; rm -rf dist/",
|
|
31
|
+
"build:compile": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
32
|
+
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
32
33
|
"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",
|
|
33
|
-
"test:types": "tsc -p ./tsconfig.
|
|
34
|
-
"test:format:
|
|
35
|
-
"test:format": "npm run test:format:
|
|
36
|
-
"test:lint:deps": "npx depcheck -c
|
|
37
|
-
"test:lint:
|
|
38
|
-
"test:lint": "
|
|
39
|
-
"test:
|
|
40
|
-
"test:
|
|
41
|
-
"test:
|
|
34
|
+
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
35
|
+
"test:format:biome": "biome format",
|
|
36
|
+
"test:format": "npm run test:format:biome",
|
|
37
|
+
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
38
|
+
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
39
|
+
"test:lint:biome:all": "biome check",
|
|
40
|
+
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
41
|
+
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
42
|
+
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
43
|
+
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
42
44
|
"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",
|
|
43
|
-
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
|
|
45
|
+
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
44
46
|
"prepush": "npm run test && npm run build",
|
|
45
47
|
"prepublish": "npm run build",
|
|
46
48
|
"preversion": "npm run prepush",
|
|
47
49
|
"postversion": "git push origin HEAD --tags --no-verify",
|
|
48
|
-
"
|
|
49
|
-
"prepare:
|
|
50
|
+
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
51
|
+
"prepare:rhachet": "rhachet init && rhachet roles link --repo ehmpathy --role mechanic && rhachet roles link --repo bhuild --role behaver && rhachet roles link --repo bhrain --role reviewer && rhachet roles init --role mechanic && rhachet roles init --role behaver",
|
|
52
|
+
"prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi"
|
|
50
53
|
},
|
|
51
54
|
"dependencies": {
|
|
52
55
|
"@ehmpathy/uni-time": "1.7.4",
|
|
56
|
+
"as-procedure": "1.1.10",
|
|
53
57
|
"bottleneck": "2.19.5",
|
|
54
58
|
"domain-glossary-procedure": "1.0.0",
|
|
55
|
-
"
|
|
59
|
+
"domain-objects": "0.31.7",
|
|
60
|
+
"helpful-errors": "1.5.3",
|
|
61
|
+
"simple-log-methods": "0.6.5"
|
|
56
62
|
},
|
|
57
63
|
"devDependencies": {
|
|
58
|
-
"@
|
|
59
|
-
"@commitlint/
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"
|
|
64
|
+
"@biomejs/biome": "2.3.8",
|
|
65
|
+
"@commitlint/cli": "19.5.0",
|
|
66
|
+
"@commitlint/config-conventional": "19.5.0",
|
|
67
|
+
"@swc/core": "1.15.3",
|
|
68
|
+
"@swc/jest": "0.2.39",
|
|
69
|
+
"@tsconfig/node20": "20.1.5",
|
|
70
|
+
"@tsconfig/strictest": "2.0.5",
|
|
71
|
+
"@types/jest": "30.0.0",
|
|
72
|
+
"@types/node": "22.15.21",
|
|
66
73
|
"cz-conventional-changelog": "3.3.0",
|
|
67
|
-
"declapract": "0.
|
|
68
|
-
"declapract-typescript-ehmpathy": "0.
|
|
74
|
+
"declapract": "0.13.11",
|
|
75
|
+
"declapract-typescript-ehmpathy": "0.47.8",
|
|
76
|
+
"declastruct": "1.7.3",
|
|
77
|
+
"declastruct-github": "1.3.0",
|
|
69
78
|
"depcheck": "1.4.3",
|
|
70
|
-
"
|
|
71
|
-
"eslint-config-airbnb-typescript": "18.0.0",
|
|
72
|
-
"eslint-config-prettier": "8.5.0",
|
|
73
|
-
"eslint-plugin-import": "2.26.0",
|
|
74
|
-
"eslint-plugin-prettier": "4.2.1",
|
|
79
|
+
"esbuild-register": "3.6.0",
|
|
75
80
|
"husky": "8.0.3",
|
|
76
|
-
"jest": "
|
|
77
|
-
"
|
|
81
|
+
"jest": "30.2.0",
|
|
82
|
+
"rhachet": "1.19.1",
|
|
83
|
+
"rhachet-roles-bhrain": "0.5.7",
|
|
84
|
+
"rhachet-roles-bhuild": "0.5.0",
|
|
85
|
+
"rhachet-roles-ehmpathy": "1.15.25",
|
|
78
86
|
"test-fns": "1.5.0",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"typescript": "5.4.5"
|
|
87
|
+
"tsc-alias": "1.8.10",
|
|
88
|
+
"tsx": "4.20.6",
|
|
89
|
+
"typescript": "5.4.5",
|
|
90
|
+
"yalc": "1.0.0-pre.53"
|
|
82
91
|
},
|
|
83
92
|
"config": {
|
|
84
93
|
"commitizen": {
|
|
85
94
|
"path": "./node_modules/cz-conventional-changelog"
|
|
86
95
|
}
|
|
87
|
-
}
|
|
96
|
+
},
|
|
97
|
+
"packageManager": "pnpm@10.24.0"
|
|
88
98
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withBottleneck.js","sourceRoot":"","sources":["../../src/logic/withBottleneck.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AAEpC,MAAM,4BAA4B,GAAG,IAAI,oBAAU,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC;AAEnE,MAAM,cAAc,GAAG,CAK5B,KAAQ,EACR,UAEI,EAAE,UAAU,EAAE,4BAA4B,EAAE,EAC7C,EAAE;IACL,MAAM,OAAO,GAAG,CAAC,GAAG,IAAO,EAAE,EAAE,CAC7B,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAI,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACvD,OAAO,OAAY,CAAC;AACtB,CAAC,CAAC;AAbW,QAAA,cAAc,kBAazB"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Procedure, VisualogicContext } from 'visualogic';
|
|
2
|
-
export declare function withRetry<TInput, TContext extends VisualogicContext, TOutput>(logic: () => TOutput): typeof logic;
|
|
3
|
-
export declare function withRetry<TInput, TContext extends VisualogicContext, TOutput>(logic: (input: TInput) => TOutput): typeof logic;
|
|
4
|
-
export declare function withRetry<TInput, TContext extends VisualogicContext, TOutput>(logic: Procedure<TInput, TContext, TOutput>): typeof logic;
|
package/dist/logic/withRetry.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withRetry = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* function which calls the wrapped function and runs it again one time if an error is caught
|
|
6
|
-
*/
|
|
7
|
-
function withRetry(logic) {
|
|
8
|
-
return (async (input, context) => {
|
|
9
|
-
try {
|
|
10
|
-
return await logic(input, context);
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
if (!(error instanceof Error))
|
|
14
|
-
throw error;
|
|
15
|
-
context.log.warn('withRetry.progress: caught an error, will retry', {
|
|
16
|
-
error: {
|
|
17
|
-
message: error.message,
|
|
18
|
-
stack: error.stack,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
return await logic(input, context);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.withRetry = withRetry;
|
|
26
|
-
//# sourceMappingURL=withRetry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withRetry.js","sourceRoot":"","sources":["../../src/logic/withRetry.ts"],"names":[],"mappings":";;;AAkBA;;GAEG;AACH,SAAgB,SAAS,CACvB,KAA2C;IAE3C,OAAO,CAAC,KAAK,EACX,KAAmC,EACnC,OAAuC,EACC,EAAE;QAC1C,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,iDAAiD,EAAE;gBAClE,KAAK,EAAE;oBACL,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,KAAK,EAAE,KAAK,CAAC,KAAK;iBACnB;aACF,CAAC,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAiB,CAAC;AACrB,CAAC;AApBD,8BAoBC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withTimeout.js","sourceRoot":"","sources":["../../src/logic/withTimeout.ts"],"names":[],"mappings":";;;AAAA,iDAAiE;AAiBjE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,WAAW,CACzB,KAA2C,EAC3C,OAAmC;IAEnC,MAAM,WAAW,GAAG,IAAA,yBAAc,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtD,OAAO,CACL,KAAmC,EACnC,OAAuC,EACR,EAAE;QACjC,6HAA6H;QAC7H,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;gBACzB,YAAY,CAAC,EAAE,CAAC,CAAC;gBACjB,MAAM,CACJ,IAAI,KAAK,CACP,4BAA4B,WAAW,qBAAqB,CAC7D,CACF,CAAC;YACJ,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,4BAA4B;QAC/C,CAAC,CAAC,CAAC;QAEH,uFAAuF;QACvF,OAAO,OAAO,CAAC,IAAI,CAAC;YAClB,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,+CAA+C;YACtE,OAAO,EAAE,cAAc;SACxB,CAAkC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC;AA3BD,kCA2BC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withWrappers.js","sourceRoot":"","sources":["../../src/logic/withWrappers.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACI,MAAM,UAAU,GAAG,CACxB,KAAqC,EACa,EAAE;IACpD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,+FAA+F;AACxJ,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEF;;;;GAIG;AACH,SAAgB,YAAY,CAK1B,KAAiB,EAAE,QAAkB;IACrC,OAAO,QAAQ,CAAC,MAAM,CACpB,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAC5D,KAAK,CACN,CAAC;AACJ,CAAC;AAVD,oCAUC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const test_fns_1 = require("test-fns");
|
|
4
|
-
const withWrappers_1 = require("./withWrappers");
|
|
5
|
-
describe('withWrappers', () => {
|
|
6
|
-
(0, test_fns_1.given)('a simple procedure to wrap', () => {
|
|
7
|
-
const withTimeoutCallInputs = [];
|
|
8
|
-
const withTimeout = (logic, { threshold }) => {
|
|
9
|
-
return async (input, context) => {
|
|
10
|
-
withTimeoutCallInputs.push(input);
|
|
11
|
-
const start = Date.now();
|
|
12
|
-
const result = await logic(input, context);
|
|
13
|
-
const duration = Date.now() - start;
|
|
14
|
-
if (duration > threshold)
|
|
15
|
-
console.warn(`Took too long: ${duration}ms`);
|
|
16
|
-
return result;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
const withLogTrailCallInputs = [];
|
|
20
|
-
const withLogTrail = (logic, { name }) => {
|
|
21
|
-
return async (input, context) => {
|
|
22
|
-
withLogTrailCallInputs.push(input);
|
|
23
|
-
console.log(`[${name}] Input:`, input);
|
|
24
|
-
const result = await logic(input, context);
|
|
25
|
-
console.log(`[${name}] Output:`, result);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
const logic = async (input, context) => {
|
|
30
|
-
return `Processed ${input.payload} for ${context.userUuid}`;
|
|
31
|
-
};
|
|
32
|
-
(0, test_fns_1.then)('it should successfully execute the wrappers', async () => {
|
|
33
|
-
const wrapped = (0, withWrappers_1.withWrappers)(logic, [
|
|
34
|
-
(0, withWrappers_1.setWrapper)({
|
|
35
|
-
wrapper: withLogTrail,
|
|
36
|
-
options: { name: 'wrapped-procedure' },
|
|
37
|
-
}),
|
|
38
|
-
(0, withWrappers_1.setWrapper)({
|
|
39
|
-
wrapper: withTimeout,
|
|
40
|
-
options: { threshold: 100 },
|
|
41
|
-
}),
|
|
42
|
-
]);
|
|
43
|
-
await wrapped({ payload: 'yellow' }, { userUuid: 'beefbeef...' });
|
|
44
|
-
expect(withLogTrailCallInputs.length).toEqual(1);
|
|
45
|
-
expect(withTimeoutCallInputs.length).toEqual(1);
|
|
46
|
-
await wrapped({ payload: 'blue' }, { userUuid: 'beefbeef...' });
|
|
47
|
-
expect(withLogTrailCallInputs.length).toEqual(2);
|
|
48
|
-
expect(withTimeoutCallInputs.length).toEqual(2);
|
|
49
|
-
});
|
|
50
|
-
(0, test_fns_1.then)('it should typethrow if setWrapper was not used', {
|
|
51
|
-
because: 'this guarantees the options are typechecked',
|
|
52
|
-
}, () => {
|
|
53
|
-
(0, withWrappers_1.withWrappers)(logic, [
|
|
54
|
-
// @ts-expect-error: Property '_safe' is missing in type '{ wrapper: Wrapper<Procedure, { name: string; }>; options: { name: string; }; }' but required in type '{ _safe: true; }'.
|
|
55
|
-
{
|
|
56
|
-
wrapper: withLogTrail,
|
|
57
|
-
options: { name: 'wrapped-procedure' },
|
|
58
|
-
},
|
|
59
|
-
]);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
//# sourceMappingURL=withWrappers.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withWrappers.test.js","sourceRoot":"","sources":["../../src/logic/withWrappers.test.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAIvC,iDAA0D;AAE1D,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAA,gBAAK,EAAC,4BAA4B,EAAE,GAAG,EAAE;QACvC,MAAM,qBAAqB,GAAU,EAAE,CAAC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without changes
|
|
File without changes
|