ts-rules-composer 0.0.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.
Files changed (83) hide show
  1. package/.editorconfig +15 -0
  2. package/.eslintrc.json +66 -0
  3. package/.github/CONTRIBUTING.md +3 -0
  4. package/.github/ISSUE_TEMPLATE.md +9 -0
  5. package/.github/PULL_REQUEST_TEMPLATE.md +7 -0
  6. package/.github/workflows/docs.yml +29 -0
  7. package/.github/workflows/publish.yml +25 -0
  8. package/.github/workflows/test.yml +37 -0
  9. package/.prettierignore +2 -0
  10. package/.releaserc +11 -0
  11. package/LICENSE +21 -0
  12. package/README.md +625 -0
  13. package/dist/index.cjs +2 -0
  14. package/dist/index.cjs.map +1 -0
  15. package/dist/index.d.cts +634 -0
  16. package/dist/index.d.ts +634 -0
  17. package/dist/index.js +2 -0
  18. package/dist/index.js.map +1 -0
  19. package/package.json +64 -0
  20. package/src/lib/combinators/index.ts +2 -0
  21. package/src/lib/combinators/logic/every.spec.ts +264 -0
  22. package/src/lib/combinators/logic/every.ts +47 -0
  23. package/src/lib/combinators/logic/if-else.spec.ts +72 -0
  24. package/src/lib/combinators/logic/if-else.ts +39 -0
  25. package/src/lib/combinators/logic/index.ts +8 -0
  26. package/src/lib/combinators/logic/match.spec.ts +186 -0
  27. package/src/lib/combinators/logic/match.ts +92 -0
  28. package/src/lib/combinators/logic/not.spec.ts +62 -0
  29. package/src/lib/combinators/logic/not.ts +25 -0
  30. package/src/lib/combinators/logic/one-of.spec.ts +68 -0
  31. package/src/lib/combinators/logic/one-of.ts +41 -0
  32. package/src/lib/combinators/logic/unless.spec.ts +61 -0
  33. package/src/lib/combinators/logic/unless.ts +27 -0
  34. package/src/lib/combinators/logic/when.spec.ts +123 -0
  35. package/src/lib/combinators/logic/when.ts +29 -0
  36. package/src/lib/combinators/logic/with-fallback.spec.ts +72 -0
  37. package/src/lib/combinators/logic/with-fallback.ts +37 -0
  38. package/src/lib/combinators/utility/index.ts +8 -0
  39. package/src/lib/combinators/utility/inject.spec.ts +55 -0
  40. package/src/lib/combinators/utility/inject.ts +25 -0
  41. package/src/lib/combinators/utility/map-error.spec.ts +63 -0
  42. package/src/lib/combinators/utility/map-error.ts +35 -0
  43. package/src/lib/combinators/utility/tap.spec.ts +102 -0
  44. package/src/lib/combinators/utility/tap.ts +38 -0
  45. package/src/lib/combinators/utility/validate-field.spec.ts +150 -0
  46. package/src/lib/combinators/utility/validate-field.ts +59 -0
  47. package/src/lib/combinators/utility/with-debug.spec.ts +71 -0
  48. package/src/lib/combinators/utility/with-debug.ts +55 -0
  49. package/src/lib/combinators/utility/with-memoize.spec.ts +82 -0
  50. package/src/lib/combinators/utility/with-memoize.ts +81 -0
  51. package/src/lib/combinators/utility/with-retry.spec.ts +220 -0
  52. package/src/lib/combinators/utility/with-retry.ts +68 -0
  53. package/src/lib/combinators/utility/with-timeout.spec.ts +115 -0
  54. package/src/lib/combinators/utility/with-timeout.ts +34 -0
  55. package/src/lib/composition/compose-rules.spec.ts +211 -0
  56. package/src/lib/composition/compose-rules.ts +47 -0
  57. package/src/lib/composition/index.ts +3 -0
  58. package/src/lib/composition/pipe-rules.spec.ts +220 -0
  59. package/src/lib/composition/pipe-rules.ts +44 -0
  60. package/src/lib/composition/pipe.spec.ts +47 -0
  61. package/src/lib/composition/pipe.ts +106 -0
  62. package/src/lib/helpers/context/has-context.ts +13 -0
  63. package/src/lib/helpers/context/index.ts +3 -0
  64. package/src/lib/helpers/context/require-context.spec.ts +55 -0
  65. package/src/lib/helpers/context/require-context.ts +61 -0
  66. package/src/lib/helpers/context/with-lazy-context.spec.ts +74 -0
  67. package/src/lib/helpers/context/with-lazy-context.ts +35 -0
  68. package/src/lib/helpers/index.ts +6 -0
  69. package/src/lib/helpers/result/fail.ts +15 -0
  70. package/src/lib/helpers/result/index.ts +2 -0
  71. package/src/lib/helpers/result/pass.ts +14 -0
  72. package/src/lib/helpers/retry/calculate-delay.ts +31 -0
  73. package/src/lib/index.ts +4 -0
  74. package/src/lib/types/composition-options.ts +7 -0
  75. package/src/lib/types/debug-options.ts +36 -0
  76. package/src/lib/types/index.ts +4 -0
  77. package/src/lib/types/rule-result.ts +16 -0
  78. package/src/lib/types/rule.ts +21 -0
  79. package/src/test/helpers/get-rule-error.ts +23 -0
  80. package/src/test/integration.spec.ts +285 -0
  81. package/tsconfig.json +55 -0
  82. package/tsup.config.ts +36 -0
  83. package/vitest.config.ts +16 -0
package/.editorconfig ADDED
@@ -0,0 +1,15 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ end_of_line = lf
7
+ indent_size = 2
8
+ indent_style = space
9
+ insert_final_newline = true
10
+ max_line_length = 80
11
+ trim_trailing_whitespace = true
12
+
13
+ [*.md]
14
+ max_line_length = 0
15
+ trim_trailing_whitespace = false
package/.eslintrc.json ADDED
@@ -0,0 +1,66 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ # Example Contributing Guidelines
2
+
3
+ This is an example of GitHub's contributing guidelines file. Check out GitHub's [CONTRIBUTING.md help center article](https://help.github.com/articles/setting-guidelines-for-repository-contributors/) for more information.
@@ -0,0 +1,9 @@
1
+ - **I'm submitting a ...**
2
+ [ ] bug report
3
+ [ ] feature request
4
+ [ ] question about the decisions made in the repository
5
+ [ ] question about how to use this project
6
+
7
+ - **Summary**
8
+
9
+ - **Other information** (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
@@ -0,0 +1,7 @@
1
+ - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
2
+
3
+ - **What is the current behavior?** (You can also link to an open issue here)
4
+
5
+ - **What is the new behavior (if this is a feature change)?**
6
+
7
+ - **Other information**:
@@ -0,0 +1,29 @@
1
+ name: docs
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ node-version: [22.x]
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Build on Node.js ${{ matrix.node-version }}
17
+ uses: actions/setup-node@v3
18
+ with:
19
+ node-version: ${{ matrix.node-version }}
20
+ - run: npm ci --ignore-scripts
21
+
22
+ - name: Run typedoc to generate html documentation
23
+ run: npm run generate-docs
24
+
25
+ - name: Deploy 🚀
26
+ uses: JamesIves/github-pages-deploy-action@4.1.4
27
+ with:
28
+ branch: gh-pages
29
+ folder: genDocs
@@ -0,0 +1,25 @@
1
+ name: publish
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows: ["test"]
6
+ branches: [main]
7
+ types:
8
+ - completed
9
+
10
+ jobs:
11
+ publish:
12
+ if: ${{ github.event.workflow_run.conclusion == 'success' }} && github.ref == 'refs/heads/main'
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: 22
19
+ registry-url: 'https://registry.npmjs.org'
20
+ - run: npm ci --ignore-scripts
21
+ - run: npm run build --if-present
22
+ - name: Publish
23
+ run: npm run release
24
+ env:
25
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,37 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - dev
8
+
9
+ pull_request:
10
+ types:
11
+ - opened
12
+ - synchronize
13
+
14
+ jobs:
15
+ test:
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ matrix:
19
+ node-version: [22.x]
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Build on Node.js ${{ matrix.node-version }}
23
+ uses: actions/setup-node@v1
24
+ with:
25
+ node-version: ${{ matrix.node-version }}
26
+ - run: npm ci --ignore-scripts
27
+ - run: npm run build --if-present
28
+ name: Build
29
+ - run: npm test
30
+ env:
31
+ CI: true
32
+ - run: npm run lint
33
+ env:
34
+ CI: true
35
+ - run: npm run format
36
+ env:
37
+ CI: true
@@ -0,0 +1,2 @@
1
+ # package.json is formatted by package managers, so we ignore it here
2
+ package.json
package/.releaserc ADDED
@@ -0,0 +1,11 @@
1
+ branches:
2
+ - main
3
+ - name: alpha
4
+ prerelease: true
5
+ debug: true
6
+ ci: true
7
+ dryRun: false
8
+ plugins:
9
+ - ["@semantic-release/commit-analyzer", { "preset": "conventionalcommits" }]
10
+ - "@semantic-release/release-notes-generator"
11
+ - "@semantic-release/npm"
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Breno Magalhães
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.