@eldrforge/shared 0.1.1-dev.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/LICENSE +190 -0
- package/README.md +64 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1092 -0
- package/dist/index.js.map +1 -0
- package/dist/src/dates.d.ts +57 -0
- package/dist/src/dates.d.ts.map +1 -0
- package/dist/src/errors/ArgumentError.d.ts +6 -0
- package/dist/src/errors/ArgumentError.d.ts.map +1 -0
- package/dist/src/errors/CancellationError.d.ts +4 -0
- package/dist/src/errors/CancellationError.d.ts.map +1 -0
- package/dist/src/errors/CommandErrors.d.ts +74 -0
- package/dist/src/errors/CommandErrors.d.ts.map +1 -0
- package/dist/src/errors/ExitError.d.ts +4 -0
- package/dist/src/errors/ExitError.d.ts.map +1 -0
- package/dist/src/errors/index.d.ts +8 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/general.d.ts +21 -0
- package/dist/src/general.d.ts.map +1 -0
- package/dist/src/index.d.ts +16 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/logger.d.ts +10 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/safety.d.ts +28 -0
- package/dist/src/safety.d.ts.map +1 -0
- package/dist/src/stdin.d.ts +3 -0
- package/dist/src/stdin.d.ts.map +1 -0
- package/dist/src/storage.d.ts +34 -0
- package/dist/src/storage.d.ts.map +1 -0
- package/dist/src/types.d.ts +20 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/validation.d.ts +39 -0
- package/dist/src/validation.d.ts.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ValidationResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Generic validation function that validates data against a schema
|
|
4
|
+
* @param data Data to validate
|
|
5
|
+
* @param schema Validation schema (can be a Zod schema or custom validator)
|
|
6
|
+
* @returns ValidationResult with success status and either data or error
|
|
7
|
+
*/
|
|
8
|
+
export declare const validate: <T>(data: unknown, schema: {
|
|
9
|
+
parse: (data: unknown) => T;
|
|
10
|
+
}) => ValidationResult<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Validates that a value is a string
|
|
13
|
+
*/
|
|
14
|
+
export declare const validateString: (value: unknown, fieldName?: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Validates that a value is a number
|
|
17
|
+
*/
|
|
18
|
+
export declare const validateNumber: (value: unknown, fieldName?: string) => number;
|
|
19
|
+
/**
|
|
20
|
+
* Validates that a value is a boolean
|
|
21
|
+
*/
|
|
22
|
+
export declare const validateBoolean: (value: unknown, fieldName?: string) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Validates that a value is an array
|
|
25
|
+
*/
|
|
26
|
+
export declare const validateArray: <T>(value: unknown, fieldName?: string) => T[];
|
|
27
|
+
/**
|
|
28
|
+
* Validates that a value is an object (and not null or array)
|
|
29
|
+
*/
|
|
30
|
+
export declare const validateObject: (value: unknown, fieldName?: string) => Record<string, any>;
|
|
31
|
+
/**
|
|
32
|
+
* Validates that a string is not empty
|
|
33
|
+
*/
|
|
34
|
+
export declare const validateNonEmptyString: (value: unknown, fieldName?: string) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Validates that a value is one of the allowed values
|
|
37
|
+
*/
|
|
38
|
+
export declare const validateEnum: <T>(value: unknown, allowedValues: readonly T[], fieldName?: string) => T;
|
|
39
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EACtB,MAAM,OAAO,EACb,QAAQ;IAAE,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,CAAC,CAAA;CAAE,KACxC,gBAAgB,CAAC,CAAC,CAOpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,EAAE,YAAW,MAAgB,KAAG,MAK5E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,EAAE,YAAW,MAAgB,KAAG,MAK5E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,EAAE,YAAW,MAAgB,KAAG,OAK7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,OAAO,OAAO,EAAE,YAAW,MAAgB,KAAG,CAAC,EAK/E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,EAAE,YAAW,MAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAK9F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,EAAE,YAAW,MAAgB,KAAG,MAMpF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAC1B,OAAO,OAAO,EACd,eAAe,SAAS,CAAC,EAAE,EAC3B,YAAW,MAAgB,KAC5B,CAOF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eldrforge/shared",
|
|
3
|
+
"version": "0.1.1-dev.1",
|
|
4
|
+
"description": "Shared utilities for Eldrforge tools - storage, validation, errors, and more",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/calenvarek/shared-utils.git"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "npm run lint && tsc --noEmit && vite build",
|
|
22
|
+
"dev": "vite",
|
|
23
|
+
"watch": "vite build --watch",
|
|
24
|
+
"test": "vitest run --coverage",
|
|
25
|
+
"lint": "eslint . --ext .ts",
|
|
26
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"precommit": "npm run clean && npm run build && npm run lint && npm run test",
|
|
29
|
+
"prepublishOnly": "npm run clean && npm run lint && npm run build && npm run test"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"utilities",
|
|
33
|
+
"storage",
|
|
34
|
+
"validation",
|
|
35
|
+
"errors",
|
|
36
|
+
"helpers",
|
|
37
|
+
"typescript"
|
|
38
|
+
],
|
|
39
|
+
"author": "Calen Varek <calenvarek@gmail.com>",
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"dayjs": "^1.11.13",
|
|
43
|
+
"glob": "^13.0.0",
|
|
44
|
+
"js-yaml": "^4.1.0",
|
|
45
|
+
"moment-timezone": "^0.6.0",
|
|
46
|
+
"semver": "^7.7.2",
|
|
47
|
+
"zod": "^4.1.12"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@eldrforge/git-tools": "^0.1.0",
|
|
51
|
+
"winston": "^3.17.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@eldrforge/git-tools": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"winston": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@eldrforge/git-tools": "^0.1.10",
|
|
63
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
64
|
+
"@eslint/js": "^9.33.0",
|
|
65
|
+
"@swc/core": "^1.13.3",
|
|
66
|
+
"@types/js-yaml": "^4.0.9",
|
|
67
|
+
"@types/node": "^24.10.1",
|
|
68
|
+
"@types/semver": "^7.7.0",
|
|
69
|
+
"@types/winston": "^2.4.4",
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "^8.39.1",
|
|
71
|
+
"@typescript-eslint/parser": "^8.47.0",
|
|
72
|
+
"@vitest/coverage-v8": "^4.0.13",
|
|
73
|
+
"esbuild": "0.27.0",
|
|
74
|
+
"eslint": "^9.33.0",
|
|
75
|
+
"eslint-plugin-import": "^2.32.0",
|
|
76
|
+
"globals": "^16.3.0",
|
|
77
|
+
"mockdate": "^3.0.5",
|
|
78
|
+
"typescript": "^5.9.2",
|
|
79
|
+
"vite": "^7.2.4",
|
|
80
|
+
"vite-plugin-dts": "^4.3.0",
|
|
81
|
+
"vite-plugin-node": "^7.0.0",
|
|
82
|
+
"vitest": "^4.0.13",
|
|
83
|
+
"winston": "^3.17.0"
|
|
84
|
+
}
|
|
85
|
+
}
|