@script-it/json-views-core 0.1.0-beta.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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/THIRD_PARTY_NOTICES.txt +4917 -0
  4. package/dist/annotation-capabilities.d.ts +17 -0
  5. package/dist/annotation-capabilities.js +21 -0
  6. package/dist/atomic-value.d.ts +3 -0
  7. package/dist/atomic-value.js +6 -0
  8. package/dist/date-type.d.ts +48 -0
  9. package/dist/date-type.js +244 -0
  10. package/dist/diagnostics.d.ts +8 -0
  11. package/dist/diagnostics.js +252 -0
  12. package/dist/document-session.d.ts +52 -0
  13. package/dist/document-session.js +164 -0
  14. package/dist/formats/conversion.d.ts +17 -0
  15. package/dist/formats/conversion.js +75 -0
  16. package/dist/formats/csv-format.d.ts +31 -0
  17. package/dist/formats/csv-format.js +269 -0
  18. package/dist/formats/document-format.d.ts +35 -0
  19. package/dist/formats/document-format.js +1 -0
  20. package/dist/formats/json-format.d.ts +12 -0
  21. package/dist/formats/json-format.js +109 -0
  22. package/dist/html-view-bindings.d.ts +4 -0
  23. package/dist/html-view-bindings.js +32 -0
  24. package/dist/html-view-limits.d.ts +1 -0
  25. package/dist/html-view-limits.js +1 -0
  26. package/dist/index.d.ts +19 -0
  27. package/dist/index.js +19 -0
  28. package/dist/inference-fields.d.ts +5 -0
  29. package/dist/inference-fields.js +23 -0
  30. package/dist/inference.d.ts +26 -0
  31. package/dist/inference.js +304 -0
  32. package/dist/json-limits.d.ts +8 -0
  33. package/dist/json-limits.js +25 -0
  34. package/dist/json-path.d.ts +14 -0
  35. package/dist/json-path.js +84 -0
  36. package/dist/json-source-patcher.d.ts +97 -0
  37. package/dist/json-source-patcher.js +778 -0
  38. package/dist/metadata.d.ts +137 -0
  39. package/dist/metadata.js +952 -0
  40. package/dist/safe-pattern.d.ts +5 -0
  41. package/dist/safe-pattern.js +20 -0
  42. package/dist/schema-validation.d.ts +3 -0
  43. package/dist/schema-validation.js +4 -0
  44. package/dist/source-default.d.ts +2 -0
  45. package/dist/source-default.js +39 -0
  46. package/dist/table-suitability.d.ts +5 -0
  47. package/dist/table-suitability.js +55 -0
  48. package/dist/type-registry.d.ts +57 -0
  49. package/dist/type-registry.js +238 -0
  50. package/dist/value-comparison.d.ts +18 -0
  51. package/dist/value-comparison.js +133 -0
  52. package/dist/view-model.d.ts +18 -0
  53. package/dist/view-model.js +134 -0
  54. package/package.json +52 -0
  55. package/schema/jsonviews.schema.json +102 -0
@@ -0,0 +1,137 @@
1
+ import { type ValuePath } from './json-path.js';
2
+ import { type JsonViewOptionColor, type JsonViewTypeRegistry } from './type-registry.js';
3
+ import { type InferredJsonViewMetadata } from './inference.js';
4
+ import { type JsonViewDiagnosticHelp } from './annotation-capabilities.js';
5
+ export type JsonViewPathRoot = '$';
6
+ export type JsonViewPathSegment = {
7
+ kind: 'property';
8
+ key: string;
9
+ } | {
10
+ kind: 'index';
11
+ index: number;
12
+ } | {
13
+ kind: 'wildcard';
14
+ };
15
+ export interface JsonViewPath {
16
+ source: string;
17
+ root: JsonViewPathRoot;
18
+ segments: JsonViewPathSegment[];
19
+ }
20
+ export interface JsonViewSchemaDescriptor {
21
+ type: string;
22
+ title?: string;
23
+ description?: string;
24
+ required?: boolean;
25
+ minimum?: number | string | null;
26
+ maximum?: number | string | null;
27
+ defaultIncludeTime?: boolean;
28
+ pattern?: string;
29
+ options?: string[];
30
+ optionColors?: Record<string, JsonViewOptionColor>;
31
+ placeholder?: string;
32
+ multiline?: boolean;
33
+ step?: number;
34
+ [key: string]: unknown;
35
+ }
36
+ export interface CompiledJsonViewSchema {
37
+ declaration: string;
38
+ path: JsonViewPath;
39
+ descriptor: JsonViewSchemaDescriptor;
40
+ declarationIndex: number;
41
+ specificity: readonly [concreteSegments: number, totalSegments: number];
42
+ metadataPath: ValuePath;
43
+ }
44
+ export interface CompiledJsonViewColumn {
45
+ label: string;
46
+ path: JsonViewPath;
47
+ metadataPath: ValuePath;
48
+ }
49
+ export type JsonViewFilterOperator = 'eq' | 'neq' | 'in' | 'notIn' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'notContains' | 'isEmpty' | 'isNotEmpty' | (string & {});
50
+ export interface CompiledJsonViewFilterRule {
51
+ /** Present only when this operand comes from the embedded source metadata. */
52
+ sourceValuePath?: ValuePath;
53
+ path: JsonViewPath;
54
+ operator: JsonViewFilterOperator;
55
+ value?: unknown;
56
+ metadataPath: ValuePath;
57
+ }
58
+ export interface CompiledJsonViewFilter {
59
+ match: 'all' | 'any';
60
+ rules: CompiledJsonViewFilterRule[];
61
+ }
62
+ export interface CompiledJsonViewSort {
63
+ path: JsonViewPath;
64
+ direction: 'asc' | 'desc';
65
+ metadataPath: ValuePath;
66
+ }
67
+ export type JsonViewGroupValue = string | number | boolean | null;
68
+ export interface CompiledJsonViewView {
69
+ id: string;
70
+ name: string;
71
+ path: JsonViewPath;
72
+ sourcePath: ValuePath;
73
+ value: unknown;
74
+ display: 'adaptive' | 'kanban' | 'html';
75
+ html?: string;
76
+ css?: string;
77
+ groupBy?: JsonViewPath;
78
+ groupOrder?: JsonViewGroupValue[];
79
+ orderPath?: JsonViewPath;
80
+ columns?: CompiledJsonViewColumn[];
81
+ filter?: CompiledJsonViewFilter;
82
+ sort: CompiledJsonViewSort[];
83
+ declarationIndex: number;
84
+ metadataPath: ValuePath;
85
+ }
86
+ export type JsonViewDiagnosticScope = 'metadata' | 'schema' | 'view' | 'value';
87
+ export interface JsonViewMetadataDiagnostic {
88
+ scope: JsonViewDiagnosticScope;
89
+ code: string;
90
+ message: string;
91
+ metadataPath: ValuePath;
92
+ sourcePath?: ValuePath;
93
+ severity?: 'warning' | 'error';
94
+ viewId?: string;
95
+ declaration?: string;
96
+ metadataSource?: 'embedded' | 'external' | 'inferred';
97
+ help?: JsonViewDiagnosticHelp;
98
+ }
99
+ export interface CompiledJsonViewMetadata {
100
+ status: 'none' | 'ready' | 'invalid' | 'unsupported-version';
101
+ metadata?: unknown;
102
+ metadataSource?: 'embedded' | 'external' | 'inferred';
103
+ root: unknown;
104
+ recognized: boolean;
105
+ active: boolean;
106
+ schema: CompiledJsonViewSchema[];
107
+ views: CompiledJsonViewView[];
108
+ diagnostics: JsonViewMetadataDiagnostic[];
109
+ inference?: InferredJsonViewMetadata;
110
+ }
111
+ export declare const JSON_VIEW_PATH_MISSING: unique symbol;
112
+ export interface ResolvedJsonViewPath {
113
+ value: unknown | typeof JSON_VIEW_PATH_MISSING;
114
+ sourcePath: ValuePath;
115
+ }
116
+ export interface JsonViewViewRow {
117
+ key: string | number;
118
+ value: Record<string, unknown>;
119
+ sourcePath: ValuePath;
120
+ }
121
+ export declare function parseJsonViewPath(source: string, options?: {
122
+ root?: JsonViewPathRoot;
123
+ allowWildcard?: boolean;
124
+ }): JsonViewPath;
125
+ export declare function resolveJsonViewPath(root: unknown, path: JsonViewPath): ResolvedJsonViewPath;
126
+ /** Without a root, reads the compiled snapshot; supplying a root resolves the plan against it. */
127
+ export declare function getJsonViewViewRows(view: CompiledJsonViewView, root?: unknown): JsonViewViewRow[];
128
+ export declare function resolveJsonViewRowPath(root: unknown, row: Pick<JsonViewViewRow, 'value' | 'sourcePath'>, path: JsonViewPath): ResolvedJsonViewPath;
129
+ export declare function matchesJsonViewPath(path: JsonViewPath, sourcePath: ValuePath): boolean;
130
+ export declare function schemaForJsonViewPath(schema: readonly CompiledJsonViewSchema[], sourcePath: ValuePath): CompiledJsonViewSchema | undefined;
131
+ export interface CompileJsonViewMetadataOptions {
132
+ /** Explicit annotations take precedence over embedded annotations and inference. */
133
+ metadata?: unknown;
134
+ /** Temporarily hides required-value diagnostics below paths for unfinished record drafts. */
135
+ suppressRequiredPaths?: readonly ValuePath[];
136
+ }
137
+ export declare function compileJsonViewMetadata(root: unknown, typeRegistry?: JsonViewTypeRegistry, options?: CompileJsonViewMetadataOptions): CompiledJsonViewMetadata;