@devp0nt/error0 1.0.0-next.5 → 1.0.0-next.51

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 (75) hide show
  1. package/dist/cjs/index.cjs +614 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/index.d.cts +345 -414
  4. package/dist/cjs/plugins/cause.cjs +63 -0
  5. package/dist/cjs/plugins/cause.cjs.map +1 -0
  6. package/dist/cjs/plugins/cause.d.cts +15 -0
  7. package/dist/cjs/plugins/code.cjs +46 -0
  8. package/dist/cjs/plugins/code.cjs.map +1 -0
  9. package/dist/cjs/plugins/code.d.cts +8 -0
  10. package/dist/cjs/plugins/expected.cjs +67 -0
  11. package/dist/cjs/plugins/expected.cjs.map +1 -0
  12. package/dist/cjs/plugins/expected.d.cts +37 -0
  13. package/dist/cjs/plugins/message-merge.cjs +39 -0
  14. package/dist/cjs/plugins/message-merge.cjs.map +1 -0
  15. package/dist/cjs/plugins/message-merge.d.cts +8 -0
  16. package/dist/cjs/plugins/meta.cjs +78 -0
  17. package/dist/cjs/plugins/meta.cjs.map +1 -0
  18. package/dist/cjs/plugins/meta.d.cts +7 -0
  19. package/dist/cjs/plugins/stack-merge.cjs +42 -0
  20. package/dist/cjs/plugins/stack-merge.cjs.map +1 -0
  21. package/dist/cjs/plugins/stack-merge.d.cts +8 -0
  22. package/dist/cjs/plugins/status.cjs +60 -0
  23. package/dist/cjs/plugins/status.cjs.map +1 -0
  24. package/dist/cjs/plugins/status.d.cts +9 -0
  25. package/dist/cjs/plugins/tags.cjs +73 -0
  26. package/dist/cjs/plugins/tags.cjs.map +1 -0
  27. package/dist/cjs/plugins/tags.d.cts +12 -0
  28. package/dist/esm/index.d.ts +345 -414
  29. package/dist/esm/index.js +530 -341
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/esm/plugins/cause.d.ts +15 -0
  32. package/dist/esm/plugins/cause.js +39 -0
  33. package/dist/esm/plugins/cause.js.map +1 -0
  34. package/dist/esm/plugins/code.d.ts +8 -0
  35. package/dist/esm/plugins/code.js +22 -0
  36. package/dist/esm/plugins/code.js.map +1 -0
  37. package/dist/esm/plugins/expected.d.ts +37 -0
  38. package/dist/esm/plugins/expected.js +43 -0
  39. package/dist/esm/plugins/expected.js.map +1 -0
  40. package/dist/esm/plugins/message-merge.d.ts +8 -0
  41. package/dist/esm/plugins/message-merge.js +15 -0
  42. package/dist/esm/plugins/message-merge.js.map +1 -0
  43. package/dist/esm/plugins/meta.d.ts +7 -0
  44. package/dist/esm/plugins/meta.js +54 -0
  45. package/dist/esm/plugins/meta.js.map +1 -0
  46. package/dist/esm/plugins/stack-merge.d.ts +8 -0
  47. package/dist/esm/plugins/stack-merge.js +18 -0
  48. package/dist/esm/plugins/stack-merge.js.map +1 -0
  49. package/dist/esm/plugins/status.d.ts +9 -0
  50. package/dist/esm/plugins/status.js +36 -0
  51. package/dist/esm/plugins/status.js.map +1 -0
  52. package/dist/esm/plugins/tags.d.ts +12 -0
  53. package/dist/esm/plugins/tags.js +49 -0
  54. package/dist/esm/plugins/tags.js.map +1 -0
  55. package/package.json +53 -23
  56. package/src/index.test.ts +696 -452
  57. package/src/index.ts +1178 -502
  58. package/src/plugins/cause.test.ts +106 -0
  59. package/src/plugins/cause.ts +45 -0
  60. package/src/plugins/code.test.ts +27 -0
  61. package/src/plugins/code.ts +20 -0
  62. package/src/plugins/expected.test.ts +66 -0
  63. package/src/plugins/expected.ts +48 -0
  64. package/src/plugins/message-merge.test.ts +32 -0
  65. package/src/plugins/message-merge.ts +19 -0
  66. package/src/plugins/meta.test.ts +32 -0
  67. package/src/plugins/meta.ts +59 -0
  68. package/src/plugins/stack-merge.test.ts +57 -0
  69. package/src/plugins/stack-merge.ts +20 -0
  70. package/src/plugins/status.test.ts +54 -0
  71. package/src/plugins/status.ts +35 -0
  72. package/src/plugins/tags.test.ts +74 -0
  73. package/src/plugins/tags.ts +51 -0
  74. package/dist/cjs/index.js +0 -435
  75. package/dist/cjs/index.js.map +0 -1
@@ -0,0 +1,49 @@
1
+ import { Error0 } from "../index.js";
2
+ const tagsPlugin = ({
3
+ isPublic = false,
4
+ tags,
5
+ strict = true
6
+ } = {}) => {
7
+ function hasTag(error, tag, policy) {
8
+ const tags2 = error.tags;
9
+ if (!tags2) {
10
+ return false;
11
+ }
12
+ if (Array.isArray(tag)) {
13
+ if (policy === "every") {
14
+ return tag.every((item) => tags2.includes(item));
15
+ }
16
+ return tag.some((item) => tags2.includes(item));
17
+ }
18
+ return tags2.includes(tag);
19
+ }
20
+ const isTag = (value) => typeof value === "string" && (!tags || !strict || tags.includes(value));
21
+ return Error0.plugin().prop("tags", {
22
+ init: (input) => input,
23
+ resolve: ({ flow }) => {
24
+ const merged = [];
25
+ for (const value of flow) {
26
+ if (Array.isArray(value)) {
27
+ merged.push(...value);
28
+ }
29
+ }
30
+ return merged.length > 0 ? Array.from(new Set(merged)) : void 0;
31
+ },
32
+ serialize: ({ resolved, isPublic: _isPublic }) => {
33
+ if (!isPublic && _isPublic) {
34
+ return void 0;
35
+ }
36
+ return resolved;
37
+ },
38
+ deserialize: ({ value }) => {
39
+ if (!Array.isArray(value)) {
40
+ return void 0;
41
+ }
42
+ return value.filter((item) => isTag(item));
43
+ }
44
+ }).method("hasTag", hasTag);
45
+ };
46
+ export {
47
+ tagsPlugin
48
+ };
49
+ //# sourceMappingURL=tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/plugins/tags.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const tagsPlugin = <TTag extends string>({\n isPublic = false,\n tags,\n strict = true,\n}: { isPublic?: boolean; tags?: TTag[] | readonly TTag[]; strict?: boolean } = {}) => {\n function hasTag(error: Error0, tag: TTag): boolean\n function hasTag(error: Error0, tag: TTag[], policy: 'every' | 'some'): boolean\n function hasTag(error: Error0, tag: TTag | TTag[], policy?: 'every' | 'some'): boolean {\n const tags = (error as any).tags as string[] | undefined\n if (!tags) {\n return false\n }\n if (Array.isArray(tag)) {\n if (policy === 'every') {\n return tag.every((item) => tags.includes(item))\n }\n return tag.some((item) => tags.includes(item))\n }\n return tags.includes(tag)\n }\n const isTag = (value: unknown): value is TTag =>\n typeof value === 'string' && (!tags || !strict || tags.includes(value as TTag))\n return Error0.plugin()\n .prop('tags', {\n init: (input: string[]) => input,\n resolve: ({ flow }) => {\n const merged: string[] = []\n for (const value of flow) {\n if (Array.isArray(value)) {\n merged.push(...value)\n }\n }\n return merged.length > 0 ? Array.from(new Set(merged)) : undefined\n },\n serialize: ({ resolved, isPublic: _isPublic }) => {\n if (!isPublic && _isPublic) {\n return undefined\n }\n return resolved\n },\n deserialize: ({ value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n return value.filter((item) => isTag(item))\n },\n })\n .method('hasTag', hasTag)\n}\n"],"mappings":"AAAA,SAAS,cAAc;AAEhB,MAAM,aAAa,CAAsB;AAAA,EAC9C,WAAW;AAAA,EACX;AAAA,EACA,SAAS;AACX,IAA+E,CAAC,MAAM;AAGpF,WAAS,OAAO,OAAe,KAAoB,QAAoC;AACrF,UAAMA,QAAQ,MAAc;AAC5B,QAAI,CAACA,OAAM;AACT,aAAO;AAAA,IACT;AACA,QAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,UAAI,WAAW,SAAS;AACtB,eAAO,IAAI,MAAM,CAAC,SAASA,MAAK,SAAS,IAAI,CAAC;AAAA,MAChD;AACA,aAAO,IAAI,KAAK,CAAC,SAASA,MAAK,SAAS,IAAI,CAAC;AAAA,IAC/C;AACA,WAAOA,MAAK,SAAS,GAAG;AAAA,EAC1B;AACA,QAAM,QAAQ,CAAC,UACb,OAAO,UAAU,aAAa,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS,KAAa;AAC/E,SAAO,OAAO,OAAO,EAClB,KAAK,QAAQ;AAAA,IACZ,MAAM,CAAC,UAAoB;AAAA,IAC3B,SAAS,CAAC,EAAE,KAAK,MAAM;AACrB,YAAM,SAAmB,CAAC;AAC1B,iBAAW,SAAS,MAAM;AACxB,YAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,iBAAO,KAAK,GAAG,KAAK;AAAA,QACtB;AAAA,MACF;AACA,aAAO,OAAO,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,IAC3D;AAAA,IACA,WAAW,CAAC,EAAE,UAAU,UAAU,UAAU,MAAM;AAChD,UAAI,CAAC,YAAY,WAAW;AAC1B,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT;AAAA,IACA,aAAa,CAAC,EAAE,MAAM,MAAM;AAC1B,UAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,eAAO;AAAA,MACT;AACA,aAAO,MAAM,OAAO,CAAC,SAAS,MAAM,IAAI,CAAC;AAAA,IAC3C;AAAA,EACF,CAAC,EACA,OAAO,UAAU,MAAM;AAC5B;","names":["tags"]}
package/package.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "name": "@devp0nt/error0",
3
+ "version": "1.0.0-next.51",
3
4
  "license": "MIT",
4
5
  "author": {
5
6
  "name": "Sergei Dmitriev",
@@ -14,14 +15,29 @@
14
15
  "url": "https://github.com/devp0nt/error0/issues"
15
16
  },
16
17
  "type": "module",
17
- "main": "./dist/cjs/index.js",
18
- "module": "./dist/esm/index.js",
19
18
  "types": "./dist/esm/index.d.ts",
19
+ "main": "./dist/cjs/index.cjs",
20
+ "module": "./dist/esm/index.js",
20
21
  "exports": {
21
22
  ".": {
22
23
  "types": "./dist/esm/index.d.ts",
23
- "import": "./dist/esm/index.js",
24
- "require": "./dist/cjs/index.js"
24
+ "require": "./dist/cjs/index.cjs",
25
+ "import": "./dist/esm/index.js"
26
+ },
27
+ "./plugins/*": {
28
+ "types": "./dist/esm/plugins/*.d.ts",
29
+ "require": "./dist/cjs/plugins/*.cjs",
30
+ "import": "./dist/esm/plugins/*.js"
31
+ }
32
+ },
33
+ "typesVersions": {
34
+ "*": {
35
+ "": [
36
+ "./dist/esm/index.d.ts"
37
+ ],
38
+ "plugins/*": [
39
+ "./dist/esm/plugins/*"
40
+ ]
25
41
  }
26
42
  },
27
43
  "files": [
@@ -31,7 +47,8 @@
31
47
  "LICENSE"
32
48
  ],
33
49
  "scripts": {
34
- "dev": "tsc --watch --preserveWatchOutput --project tsconfig.build.json",
50
+ "dev": "tsc-watch --preserveWatchOutput --project tsconfig.build.json",
51
+ "dev:npm": "tsc-watch --preserveWatchOutput --project tsconfig.build.json --onSuccess 'bun run pack:dist'",
35
52
  "build": "tsup",
36
53
  "build:test:esm": "tsup --outDir dist-test/esm --tsconfig tsconfig.build.test.json --format esm src",
37
54
  "build:test:esm:watch": "bun run build:test:esm --watch",
@@ -40,14 +57,14 @@
40
57
  "build:test": "bun run build:test:esm && bun run build:test:cjs",
41
58
  "build:test:watch": "bun run build:test:esm:watch & bun run build:test:cjs:watch",
42
59
  "build:all": "bun run build && bun run build:test",
43
- "test": "bun test src",
44
- "test:us": "bun test src --update-snapshots",
60
+ "test": "bun test ./src",
61
+ "test:us": "bun test ./src --update-snapshots",
45
62
  "test:watch": "bun test --watch",
46
- "test:coverage": "bun test --coverage",
47
- "test:dist:esm": "bun test dist-test/esm",
63
+ "test:coverage": "bun test ./src --coverage",
64
+ "test:dist:esm": "bun test ./dist-test/esm",
48
65
  "test:dist:esm:watch": "bun run test:dist:esm --watch",
49
66
  "test:dist:esm:build:watch": "bun build:test:esm:watch --no-clean & bun test:dist:esm:watch",
50
- "test:dist:cjs": "bun test dist-test/cjs",
67
+ "test:dist:cjs": "bun test ./dist-test/cjs",
51
68
  "test:dist:cjs:watch": "bun run test:dist:cjs --watch",
52
69
  "test:dist:cjs:build:watch": "bun build:test:cjs:watch --no-clean & bun test:dist:cjs:watch",
53
70
  "test:dist": "bun run test:dist:esm && bun run test:dist:cjs",
@@ -57,34 +74,48 @@
57
74
  "test:all:watch": "bun run test:watch & bun run test:dist:watch",
58
75
  "test:all:build": "bun run build:all && bun run test:all",
59
76
  "test:all:build:watch": "bun run build:all:watch & bun run test:all:watch",
60
- "lint": "biome check --write",
77
+ "lint": "bun run lint:fix .",
78
+ "lint:base": "eslint --cache --cache-location node_modules/.cache/eslint/.eslintcache",
79
+ "lint:fix": "bun run lint:base --fix",
80
+ "format": "bun run format:fix .",
81
+ "format:base": "prettier --cache --cache-location node_modules/.cache/prettier/.prettiercache --ignore-path .gitignore --ignore-path .prettierignore",
82
+ "format:fix": "bun run format:base --write",
61
83
  "types:build": "tsc --noEmit --project tsconfig.build.json",
62
84
  "types:dev": "tsc --noEmit",
63
85
  "types": "bun run types:dev",
64
86
  "pack:dry": "npm pack --dry-run",
65
- "prepare": "husky"
87
+ "pack:dist": "mkdir -p dist-npm && npm pack --pack-destination dist-npm --silent && cd dist-npm && tar -xzf *.tgz && cp -r package/* . && rm -rf package && rm *.tgz",
88
+ "pack:dist:hard": "rimraf dist-npm && bun run pack:dist",
89
+ "prepare": "husky",
90
+ "clean": "rimraf dist && rimraf dist-test && rimraf dist-npm && rimraf node_modules/.cache"
66
91
  },
67
92
  "dependencies": {},
68
- "peerDependencies": {
69
- "@devp0nt/meta0": "^1.0.0-next.2",
70
- "axios": "^1.12.2",
71
- "zod": "^4.1.9"
72
- },
93
+ "peerDependencies": {},
73
94
  "devDependencies": {
74
- "@biomejs/biome": "^2.2.4",
95
+ "axios": "^1.12.2",
96
+ "zod": "^4.1.9",
75
97
  "@commitlint/cli": "^19.8.1",
76
98
  "@commitlint/config-conventional": "^19.8.1",
77
99
  "@semantic-release/changelog": "^6.0.3",
78
100
  "@semantic-release/git": "^10.0.1",
79
- "@semantic-release/github": "^11.0.6",
80
- "@semantic-release/npm": "^12.0.2",
101
+ "@semantic-release/github": "^12.0.2",
102
+ "@semantic-release/npm": "^13.1.3",
81
103
  "@types/bun": "^1.2.22",
82
104
  "@types/lodash": "^4.17.20",
83
105
  "@types/node": "^20.0.0",
84
106
  "cross-env": "^10.0.0",
107
+ "esbuild-fix-imports-plugin": "^1.0.22",
108
+ "eslint": "^9.36.0",
109
+ "eslint-config-love": "^130.0.0",
110
+ "eslint-config-prettier": "^10.1.8",
111
+ "eslint-plugin-no-only-tests": "^3.3.0",
85
112
  "husky": "^9.1.7",
113
+ "lint-staged": "^16.2.1",
86
114
  "lodash": "^4.17.21",
87
- "semantic-release": "^24.2.8",
115
+ "prettier": "^3.6.2",
116
+ "rimraf": "^6.0.1",
117
+ "semantic-release": "^25.0.2",
118
+ "tsc-watch": "^7.1.1",
88
119
  "tsup": "^8.0.0",
89
120
  "typescript": "^5.0.0"
90
121
  },
@@ -94,6 +125,5 @@
94
125
  },
95
126
  "publishConfig": {
96
127
  "access": "public"
97
- },
98
- "version": "1.0.0-next.5"
128
+ }
99
129
  }