ts-rules-composer 0.0.1 → 1.0.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/.github/workflows/publish.yml +1 -1
- package/README.md +310 -42
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +335 -55
- package/dist/index.d.ts +335 -55
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/eslint.config.mjs +84 -0
- package/examples/financial-transaction.example.ts +188 -0
- package/examples/model-deployment.example.ts +136 -0
- package/examples/user-registration.example.ts +101 -0
- package/package.json +21 -6
- package/src/lib/combinators/logic/every.spec.ts +1 -1
- package/src/lib/combinators/logic/every.ts +17 -7
- package/src/lib/combinators/logic/if-else.spec.ts +11 -1
- package/src/lib/combinators/logic/if-else.ts +33 -8
- package/src/lib/combinators/logic/match.ts +20 -6
- package/src/lib/combinators/logic/not.spec.ts +3 -1
- package/src/lib/combinators/logic/not.ts +12 -3
- package/src/lib/combinators/logic/one-of.spec.ts +7 -7
- package/src/lib/combinators/logic/one-of.ts +11 -4
- package/src/lib/combinators/logic/unless.spec.ts +1 -1
- package/src/lib/combinators/logic/unless.ts +28 -5
- package/src/lib/combinators/logic/when.spec.ts +11 -15
- package/src/lib/combinators/logic/when.ts +29 -8
- package/src/lib/combinators/logic/with-fallback.ts +13 -4
- package/src/lib/combinators/utility/index.ts +5 -2
- package/src/lib/combinators/utility/inject.ts +1 -1
- package/src/lib/combinators/utility/map-error.ts +1 -1
- package/src/lib/combinators/utility/tap.spec.ts +63 -63
- package/src/lib/combinators/utility/tap.ts +18 -28
- package/src/lib/combinators/utility/validate-field.spec.ts +1 -1
- package/src/lib/combinators/utility/validate-field.ts +10 -3
- package/src/lib/combinators/utility/with-debug.spec.ts +1 -1
- package/src/lib/combinators/utility/with-debug.ts +1 -1
- package/src/lib/combinators/utility/with-memoize.spec.ts +1 -1
- package/src/lib/combinators/utility/with-memoize.ts +12 -4
- package/src/lib/combinators/utility/with-retry.spec.ts +1 -1
- package/src/lib/combinators/utility/with-retry.ts +4 -2
- package/src/lib/combinators/utility/with-safe-error.spec.ts +137 -0
- package/src/lib/combinators/utility/with-safe-error.ts +56 -0
- package/src/lib/combinators/utility/with-safe-predicate.spec.ts +176 -0
- package/src/lib/combinators/utility/with-safe-predicate.ts +64 -0
- package/src/lib/combinators/utility/with-tap.spec.ts +104 -0
- package/src/lib/combinators/utility/with-tap.ts +46 -0
- package/src/lib/combinators/utility/with-timeout.spec.ts +1 -1
- package/src/lib/combinators/utility/with-timeout.ts +10 -3
- package/src/lib/composition/compose-rules.spec.ts +1 -1
- package/src/lib/composition/compose-rules.ts +16 -8
- package/src/lib/composition/pipe-rules.spec.ts +1 -1
- package/src/lib/composition/pipe-rules.ts +15 -7
- package/src/lib/composition/pipe.ts +1 -0
- package/src/lib/helpers/clone/clone.ts +12 -0
- package/src/lib/helpers/clone/getCloneFn.ts +17 -0
- package/src/lib/helpers/clone/shallowClone.ts +12 -0
- package/src/lib/helpers/context/require-context.ts +1 -1
- package/src/lib/helpers/context/with-lazy-context.spec.ts +1 -1
- package/src/lib/helpers/context/with-lazy-context.ts +1 -1
- package/src/lib/helpers/index.ts +2 -0
- package/src/lib/helpers/result/fail.ts +1 -1
- package/src/lib/helpers/result/pass.ts +1 -1
- package/src/lib/helpers/retry/calculate-delay.ts +1 -1
- package/src/lib/helpers/safety/get-normalized-rule.spec.ts +209 -0
- package/src/lib/helpers/safety/get-normalized-rule.ts +14 -0
- package/src/lib/helpers/safety/get-normalized-rules.spec.ts +138 -0
- package/src/lib/helpers/safety/get-normalized-rules.ts +14 -0
- package/src/lib/index.ts +1 -1
- package/src/lib/types/composition-options.ts +28 -3
- package/src/lib/types/debug-options.ts +1 -1
- package/src/lib/types/index.ts +8 -4
- package/src/lib/types/predicate-result.ts +20 -0
- package/src/lib/types/predicate-safe.ts +10 -0
- package/src/lib/types/predicate-safety-options.ts +27 -0
- package/src/lib/types/predicate.ts +8 -0
- package/src/lib/types/prettify.ts +3 -0
- package/src/lib/types/rule-safety-options.ts +34 -0
- package/src/lib/types/rule.ts +1 -1
- package/src/lib/types/safety-options.ts +7 -0
- package/src/test/financial-transaction.spec.ts +251 -0
- package/src/test/helpers/get-rule-error.ts +1 -1
- package/src/test/integration.spec.ts +3 -3
- package/src/test/model-deployment.spec.ts +209 -0
- package/src/test/user-registration.spec.ts +164 -0
- package/tsconfig.json +5 -4
- package/tsup.config.ts +15 -15
- package/typedoc/tsconfig.typedoc.json +15 -0
- package/typedoc/typedoc.json +14 -0
- package/.eslintrc.json +0 -66
package/tsconfig.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"incremental": false,
|
|
4
4
|
"target": "ES2018",
|
|
5
5
|
"outDir": "dist",
|
|
6
|
-
"rootDir": "src",
|
|
7
6
|
"sourceRoot": "src",
|
|
8
7
|
"moduleResolution": "node",
|
|
9
8
|
"module": "ES6",
|
|
@@ -44,12 +43,14 @@
|
|
|
44
43
|
]
|
|
45
44
|
},
|
|
46
45
|
"include": [
|
|
47
|
-
"src/**/*.ts"
|
|
46
|
+
"src/**/*.ts",
|
|
47
|
+
"examples/**/*.ts"
|
|
48
48
|
],
|
|
49
49
|
"exclude": [
|
|
50
50
|
"dist/**",
|
|
51
51
|
"build/**",
|
|
52
|
-
"node_modules/**"
|
|
52
|
+
"node_modules/**",
|
|
53
|
+
"vitest.config.ts",
|
|
53
54
|
],
|
|
54
|
-
"compileOnSave": false
|
|
55
|
+
"compileOnSave": false,
|
|
55
56
|
}
|
package/tsup.config.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
// tsup.config.ts
|
|
2
|
-
import { defineConfig } from
|
|
2
|
+
import { defineConfig } from "tsup";
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
// Entry file(s)
|
|
6
|
-
entry: [
|
|
7
|
-
|
|
6
|
+
entry: ["src/lib/index.ts"],
|
|
7
|
+
|
|
8
8
|
// Output formats
|
|
9
|
-
format: [
|
|
10
|
-
|
|
9
|
+
format: ["cjs", "esm"],
|
|
10
|
+
|
|
11
11
|
// Generate declaration files
|
|
12
12
|
dts: true,
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
// Clean dist folder before build
|
|
15
15
|
clean: true,
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
// Target ES2018 for good balance
|
|
18
|
-
target:
|
|
19
|
-
|
|
18
|
+
target: "es2018",
|
|
19
|
+
|
|
20
20
|
// Bundle dependencies (adjust based on your needs)
|
|
21
21
|
noExternal: [], // Bundle all dependencies
|
|
22
22
|
// or
|
|
23
23
|
// external: ['some-package'], // Mark specific packages as external
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
// Enable sourcemaps
|
|
26
26
|
sourcemap: true,
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
// Optional: Splitting for ESM
|
|
29
29
|
splitting: true,
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
// Optional: Minification
|
|
32
32
|
minify: true,
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
// Optional: Tree-shaking
|
|
35
|
-
treeshake: true,
|
|
36
|
-
})
|
|
35
|
+
treeshake: true,
|
|
36
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"moduleResolution": "bundler"
|
|
5
|
+
},
|
|
6
|
+
"module": "ES6",
|
|
7
|
+
"exclude": [
|
|
8
|
+
"dist/**",
|
|
9
|
+
"build/**",
|
|
10
|
+
"node_modules/**",
|
|
11
|
+
"vitest.config.ts",
|
|
12
|
+
// workaround for https://github.com/rollup/rollup/issues/5199
|
|
13
|
+
"**/**spec.ts",
|
|
14
|
+
],
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"githubPages": true,
|
|
3
|
+
"includeVersion": true,
|
|
4
|
+
"out": "../genDocs",
|
|
5
|
+
"entryPoints": [
|
|
6
|
+
"../src/lib/index.ts"
|
|
7
|
+
],
|
|
8
|
+
"tsconfig": "./tsconfig.typedoc.json",
|
|
9
|
+
"exclude": ["/**/**.spec.ts", "vitest.config.ts"],
|
|
10
|
+
"plugin": [
|
|
11
|
+
"typedoc-plugin-mermaid",
|
|
12
|
+
"typedoc-github-theme",
|
|
13
|
+
]
|
|
14
|
+
}
|
package/.eslintrc.json
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"parserOptions": {
|
|
5
|
-
"project": "./tsconfig.json"
|
|
6
|
-
},
|
|
7
|
-
"env": {
|
|
8
|
-
"es6": true
|
|
9
|
-
},
|
|
10
|
-
"ignorePatterns": [
|
|
11
|
-
"node_modules",
|
|
12
|
-
"build",
|
|
13
|
-
"coverage",
|
|
14
|
-
"vitest.config.js"
|
|
15
|
-
],
|
|
16
|
-
"plugins": [
|
|
17
|
-
"import",
|
|
18
|
-
"eslint-comments"
|
|
19
|
-
],
|
|
20
|
-
"extends": [
|
|
21
|
-
"eslint:recommended",
|
|
22
|
-
"plugin:eslint-comments/recommended",
|
|
23
|
-
"plugin:@typescript-eslint/recommended",
|
|
24
|
-
"plugin:import/typescript",
|
|
25
|
-
"prettier",
|
|
26
|
-
"prettier/@typescript-eslint"
|
|
27
|
-
],
|
|
28
|
-
"globals": {
|
|
29
|
-
"BigInt": true,
|
|
30
|
-
"console": true,
|
|
31
|
-
"WebAssembly": true
|
|
32
|
-
},
|
|
33
|
-
"rules": {
|
|
34
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
35
|
-
"@typescript-eslint/no-unused-vars": [
|
|
36
|
-
1,
|
|
37
|
-
{
|
|
38
|
-
"argsIgnorePattern": "^_",
|
|
39
|
-
"varsIgnorePattern": "^_"
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
"eslint-comments/disable-enable-pair": [
|
|
43
|
-
"error",
|
|
44
|
-
{
|
|
45
|
-
"allowWholeFile": true
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
"eslint-comments/no-unused-disable": "error",
|
|
49
|
-
"import/order": [
|
|
50
|
-
"error",
|
|
51
|
-
{
|
|
52
|
-
"newlines-between": "always",
|
|
53
|
-
"alphabetize": {
|
|
54
|
-
"order": "asc"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"quotes": [
|
|
59
|
-
"error",
|
|
60
|
-
"single",
|
|
61
|
-
{
|
|
62
|
-
"allowTemplateLiterals": true
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
}
|