@json-to-office/shared 0.1.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/LICENSE +18 -0
- package/README.md +9 -0
- package/dist/cache/index.d.ts +464 -0
- package/dist/cache/index.js +738 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/chunk-244MHDOZ.js +39 -0
- package/dist/chunk-244MHDOZ.js.map +1 -0
- package/dist/chunk-5J43F4XD.js +181 -0
- package/dist/chunk-5J43F4XD.js.map +1 -0
- package/dist/chunk-ZKD5BAMU.js +382 -0
- package/dist/chunk-ZKD5BAMU.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/schema-utils-CbCi6dEk.d.ts +43 -0
- package/dist/schemas/schema-utils.d.ts +2 -0
- package/dist/schemas/schema-utils.js +15 -0
- package/dist/schemas/schema-utils.js.map +1 -0
- package/dist/types/warnings.d.ts +9 -0
- package/dist/types/warnings.js +1 -0
- package/dist/types/warnings.js.map +1 -0
- package/dist/utils/semver.d.ts +11 -0
- package/dist/utils/semver.js +13 -0
- package/dist/utils/semver.js.map +1 -0
- package/dist/validation/unified/index.d.ts +66 -0
- package/dist/validation/unified/index.js +41 -0
- package/dist/validation/unified/index.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ValueError } from '@sinclair/typebox/value';
|
|
2
|
+
import { TSchema, TLiteral, TObject, TUnion } from '@sinclair/typebox';
|
|
3
|
+
|
|
4
|
+
interface ValidationError {
|
|
5
|
+
path: string;
|
|
6
|
+
message: string;
|
|
7
|
+
code?: string;
|
|
8
|
+
value?: unknown;
|
|
9
|
+
suggestion?: string;
|
|
10
|
+
line?: number;
|
|
11
|
+
column?: number;
|
|
12
|
+
}
|
|
13
|
+
interface ValidationResult {
|
|
14
|
+
valid: boolean;
|
|
15
|
+
errors?: ValidationError[];
|
|
16
|
+
}
|
|
17
|
+
/** Backward-compat alias used by pptx shared */
|
|
18
|
+
type TransformedError = ValidationError;
|
|
19
|
+
|
|
20
|
+
interface ErrorFormatterConfig {
|
|
21
|
+
includeEmojis?: boolean;
|
|
22
|
+
verbosity?: 'minimal' | 'normal' | 'detailed';
|
|
23
|
+
includeSuggestions?: boolean;
|
|
24
|
+
includePath?: boolean;
|
|
25
|
+
maxMessageLength?: number;
|
|
26
|
+
includeDocLinks?: boolean;
|
|
27
|
+
colorSupport?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const DEFAULT_ERROR_CONFIG: Required<ErrorFormatterConfig>;
|
|
30
|
+
declare function createErrorConfig(config?: ErrorFormatterConfig): Required<ErrorFormatterConfig>;
|
|
31
|
+
declare const ERROR_EMOJIS: {
|
|
32
|
+
ERROR: string;
|
|
33
|
+
WARNING: string;
|
|
34
|
+
FIX: string;
|
|
35
|
+
INFO: string;
|
|
36
|
+
SUCCESS: string;
|
|
37
|
+
};
|
|
38
|
+
declare function formatErrorMessage(message: string, config: Required<ErrorFormatterConfig>): string;
|
|
39
|
+
|
|
40
|
+
declare function transformValueError(error: ValueError, jsonString?: string, config?: ErrorFormatterConfig): ValidationError;
|
|
41
|
+
declare function transformValueErrors(errors: ValueError[], options?: {
|
|
42
|
+
jsonString?: string;
|
|
43
|
+
maxErrors?: number;
|
|
44
|
+
}): ValidationError[];
|
|
45
|
+
declare function calculatePosition(jsonString: string, path: string): {
|
|
46
|
+
line: number;
|
|
47
|
+
column: number;
|
|
48
|
+
} | null;
|
|
49
|
+
declare function formatErrorSummary(errors: ValidationError[]): string;
|
|
50
|
+
declare function groupErrorsByPath(errors: ValidationError[]): Map<string, ValidationError[]>;
|
|
51
|
+
declare function createJsonParseError(error: Error, jsonString: string): ValidationError;
|
|
52
|
+
|
|
53
|
+
declare function isUnionSchema(schema: TSchema): schema is TUnion;
|
|
54
|
+
declare function isObjectSchema(schema: TSchema): schema is TObject;
|
|
55
|
+
declare function isLiteralSchema(schema: TSchema): schema is TLiteral;
|
|
56
|
+
declare function getObjectSchemaPropertyNames(schema: TSchema): string[];
|
|
57
|
+
declare function getLiteralValue(schema: TSchema): unknown;
|
|
58
|
+
declare function extractStandardComponentNames(schema: TSchema): string[];
|
|
59
|
+
declare function clearComponentNamesCache(): void;
|
|
60
|
+
declare function getSchemaMetadata(schema: TSchema): {
|
|
61
|
+
type?: string;
|
|
62
|
+
properties?: string[];
|
|
63
|
+
literal?: unknown;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { DEFAULT_ERROR_CONFIG, ERROR_EMOJIS, type ErrorFormatterConfig, type TransformedError, type ValidationError, type ValidationResult, calculatePosition, clearComponentNamesCache, createErrorConfig, createJsonParseError, extractStandardComponentNames, formatErrorMessage, formatErrorSummary, getLiteralValue, getObjectSchemaPropertyNames, getSchemaMetadata, groupErrorsByPath, isLiteralSchema, isObjectSchema, isUnionSchema, transformValueError, transformValueErrors };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_ERROR_CONFIG,
|
|
3
|
+
ERROR_EMOJIS,
|
|
4
|
+
calculatePosition,
|
|
5
|
+
clearComponentNamesCache,
|
|
6
|
+
createErrorConfig,
|
|
7
|
+
createJsonParseError,
|
|
8
|
+
extractStandardComponentNames,
|
|
9
|
+
formatErrorMessage,
|
|
10
|
+
formatErrorSummary,
|
|
11
|
+
getLiteralValue,
|
|
12
|
+
getObjectSchemaPropertyNames,
|
|
13
|
+
getSchemaMetadata,
|
|
14
|
+
groupErrorsByPath,
|
|
15
|
+
isLiteralSchema,
|
|
16
|
+
isObjectSchema,
|
|
17
|
+
isUnionSchema,
|
|
18
|
+
transformValueError,
|
|
19
|
+
transformValueErrors
|
|
20
|
+
} from "../../chunk-ZKD5BAMU.js";
|
|
21
|
+
export {
|
|
22
|
+
DEFAULT_ERROR_CONFIG,
|
|
23
|
+
ERROR_EMOJIS,
|
|
24
|
+
calculatePosition,
|
|
25
|
+
clearComponentNamesCache,
|
|
26
|
+
createErrorConfig,
|
|
27
|
+
createJsonParseError,
|
|
28
|
+
extractStandardComponentNames,
|
|
29
|
+
formatErrorMessage,
|
|
30
|
+
formatErrorSummary,
|
|
31
|
+
getLiteralValue,
|
|
32
|
+
getObjectSchemaPropertyNames,
|
|
33
|
+
getSchemaMetadata,
|
|
34
|
+
groupErrorsByPath,
|
|
35
|
+
isLiteralSchema,
|
|
36
|
+
isObjectSchema,
|
|
37
|
+
isUnionSchema,
|
|
38
|
+
transformValueError,
|
|
39
|
+
transformValueErrors
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@json-to-office/shared",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Format-agnostic shared types, schemas and validation utilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./schemas/*": {
|
|
15
|
+
"types": "./dist/schemas/*.d.ts",
|
|
16
|
+
"import": "./dist/schemas/*.js",
|
|
17
|
+
"default": "./dist/schemas/*.js"
|
|
18
|
+
},
|
|
19
|
+
"./validation/unified": {
|
|
20
|
+
"types": "./dist/validation/unified/index.d.ts",
|
|
21
|
+
"import": "./dist/validation/unified/index.js",
|
|
22
|
+
"default": "./dist/validation/unified/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./validation/parsers/*": {
|
|
25
|
+
"types": "./dist/validation/parsers/*.d.ts",
|
|
26
|
+
"import": "./dist/validation/parsers/*.js",
|
|
27
|
+
"default": "./dist/validation/parsers/*.js"
|
|
28
|
+
},
|
|
29
|
+
"./cache": {
|
|
30
|
+
"types": "./dist/cache/index.d.ts",
|
|
31
|
+
"import": "./dist/cache/index.js",
|
|
32
|
+
"default": "./dist/cache/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./*": {
|
|
35
|
+
"types": "./dist/*.d.ts",
|
|
36
|
+
"import": "./dist/*.js",
|
|
37
|
+
"default": "./dist/*.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@sinclair/typebox": "0.34.38",
|
|
42
|
+
"ajv": "8.17.1",
|
|
43
|
+
"ajv-formats": "3.0.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "20.11.0",
|
|
47
|
+
"tsup": "8.5.0",
|
|
48
|
+
"typescript": "5.3.3"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"author": "Paolo Barbato",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/Wiseair-srl/json-to-office.git",
|
|
55
|
+
"directory": "packages/shared"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/Wiseair-srl/json-to-office/tree/main/packages/shared",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/Wiseair-srl/json-to-office/issues"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist",
|
|
66
|
+
"LICENSE"
|
|
67
|
+
],
|
|
68
|
+
"keywords": [
|
|
69
|
+
"json-to-office",
|
|
70
|
+
"typescript",
|
|
71
|
+
"schemas",
|
|
72
|
+
"validation"
|
|
73
|
+
],
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=20.0.0"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build": "tsup",
|
|
79
|
+
"dev": "tsup --watch",
|
|
80
|
+
"clean": "rm -rf dist",
|
|
81
|
+
"lint": "eslint src/**/*.ts",
|
|
82
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
83
|
+
"format": "prettier --write src/**/*.ts",
|
|
84
|
+
"typecheck": "tsc --noEmit",
|
|
85
|
+
"test": "vitest run --passWithNoTests",
|
|
86
|
+
"test:watch": "vitest",
|
|
87
|
+
"test:coverage": "vitest run --coverage --passWithNoTests"
|
|
88
|
+
}
|
|
89
|
+
}
|