zarr-metadata 0.6.0 → 0.8.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/README.md CHANGED
@@ -78,11 +78,14 @@ format the conformance corpus asserts on.
78
78
 
79
79
  The structural validators check key presence, value shapes, and fixed
80
80
  literals without interpreting extension points, matching the Python
81
- package's layering. `validateArraySemanticsV3` is a separate,
82
- TS-only semantic layer on top: it interprets the well-known core extension
83
- points to enforce the specs' cross-field prose rules (regular chunk grid
84
- arity, transpose permutations, sharding divisibility, fill_value vs data
85
- type), skipping unrecognized names — the extension name space is open.
81
+ package's layering. The semantic layer (`validateSemanticsV3` /
82
+ `validateArraySemanticsV3`) is TS-only and sits on top, organized by
83
+ content: `chunk-grids.ts`, `codecs.ts`, and `data-types.ts` each hold the
84
+ syntax (configuration types) and semantics (required members, cross-field
85
+ prose rules — grid arity and sums, transpose permutations, sharding
86
+ divisibility, fill_value vs data type) for the names the package
87
+ interprets, with `semantics.ts` as the document-walking orchestrator.
88
+ Unrecognized names are skipped — the extension name space is open.
86
89
 
87
90
  Consumers include the
88
91
  [Zarr Metadata VS Code extension](https://github.com/d-v-b/vscode-zarr).
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The chunk grids this package interprets: syntax (configuration types) and
3
+ * semantics (the spec's prose rules) for `regular` and `rectilinear`, in
4
+ * one place per grid. The structural document layer never reads this
5
+ * module — extension points are uninterpreted there by spec design.
6
+ */
7
+ import type { PathedIssue } from "./errors.js";
8
+ /** Configuration of the core `regular` chunk grid. */
9
+ export interface RegularChunkGridConfiguration {
10
+ chunk_shape: number[];
11
+ }
12
+ /**
13
+ * One dimension's spec in a rectilinear grid: a bare integer (uniform
14
+ * shorthand, no sum constraint) or a list of chunk sizes and
15
+ * `[size, count]` run-length pairs that must sum to the dimension length.
16
+ */
17
+ export type RectilinearDimSpec = number | Array<number | [number, number]>;
18
+ /** Configuration of the zarr-extensions `rectilinear` chunk grid. */
19
+ export interface RectilinearChunkGridConfiguration {
20
+ kind: "inline";
21
+ chunk_shapes: RectilinearDimSpec[];
22
+ }
23
+ /** What interpreting a chunk grid yields for the rest of the semantic layer. */
24
+ export interface ChunkGridVerdict {
25
+ /** Issues, pathed relative to the `chunk_grid` field. */
26
+ issues: PathedIssue[];
27
+ /**
28
+ * Distinct chunk lengths per dimension — the division context a
29
+ * sharding codec's inner chunks must satisfy — when derivable.
30
+ */
31
+ chunkSizes: number[][] | undefined;
32
+ }
33
+ /**
34
+ * Interpret a document's `chunk_grid` field: required members, cross-field
35
+ * rules against `shape`, and the division context for codec pipelines.
36
+ * Unrecognized grid names yield no issues and no context — the extension
37
+ * name space is open.
38
+ */
39
+ export declare function chunkGridVerdict(rawGrid: unknown, shape: number[] | undefined): ChunkGridVerdict;
40
+ //# sourceMappingURL=chunk-grids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-grids.d.ts","sourceRoot":"","sources":["../src/chunk-grids.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC5C,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3E,qEAAqE;AACrE,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,kBAAkB,EAAE,CAAC;CACpC;AAED,gFAAgF;AAChF,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IACzD,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC;CACpC;AA0GD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,gBAAgB,CAQhG"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * The chunk grids this package interprets: syntax (configuration types) and
3
+ * semantics (the spec's prose rules) for `regular` and `rectilinear`, in
4
+ * one place per grid. The structural document layer never reads this
5
+ * module — extension points are uninterpreted there by spec design.
6
+ */
7
+ import { configurationMissing, fieldParts, isIntArray, isPlainObject } from "./guards.js";
8
+ function regularIssues(rawGrid, shape) {
9
+ const issues = [];
10
+ let chunkSizes;
11
+ const configuration = fieldParts(rawGrid)?.configuration;
12
+ if (configurationMissing(rawGrid)) {
13
+ issues.push({
14
+ path: [],
15
+ message: '"regular" requires a configuration with "chunk_shape"',
16
+ kind: "missing_key",
17
+ });
18
+ }
19
+ else if (configuration !== undefined && !Object.hasOwn(configuration, "chunk_shape")) {
20
+ issues.push({
21
+ path: ["configuration", "chunk_shape"],
22
+ message: "missing required key",
23
+ kind: "missing_key",
24
+ });
25
+ }
26
+ const configured = configuration?.["chunk_shape"];
27
+ if (isIntArray(configured)) {
28
+ if (shape !== undefined && configured.length !== shape.length) {
29
+ issues.push({
30
+ path: ["configuration", "chunk_shape"],
31
+ message: `expected one length per dimension of shape (${shape.length})`,
32
+ kind: "invalid_value",
33
+ });
34
+ // wrong arity: unusable as division context
35
+ }
36
+ else {
37
+ chunkSizes = configured.map((length) => [length]);
38
+ }
39
+ }
40
+ return { issues, chunkSizes };
41
+ }
42
+ function rectilinearIssues(rawGrid, shape) {
43
+ const issues = [];
44
+ let chunkSizes;
45
+ const configuration = fieldParts(rawGrid)?.configuration;
46
+ if (configurationMissing(rawGrid)) {
47
+ issues.push({
48
+ path: [],
49
+ message: '"rectilinear" requires a configuration with "kind" and "chunk_shapes"',
50
+ kind: "missing_key",
51
+ });
52
+ }
53
+ else if (configuration !== undefined) {
54
+ for (const key of ["kind", "chunk_shapes"]) {
55
+ if (!Object.hasOwn(configuration, key)) {
56
+ issues.push({
57
+ path: ["configuration", key],
58
+ message: "missing required key",
59
+ kind: "missing_key",
60
+ });
61
+ }
62
+ }
63
+ }
64
+ const specs = configuration?.["chunk_shapes"];
65
+ if (Array.isArray(specs)) {
66
+ if (shape !== undefined && specs.length !== shape.length) {
67
+ issues.push({
68
+ path: ["configuration", "chunk_shapes"],
69
+ message: `expected one entry per dimension of shape (${shape.length})`,
70
+ kind: "invalid_value",
71
+ });
72
+ }
73
+ else {
74
+ const perDim = specs.map((spec, dim) => {
75
+ // Bare integer: uniform shorthand, no sum constraint (edge chunks
76
+ // are permitted, as with the regular grid).
77
+ if (Number.isInteger(spec))
78
+ return spec > 0 ? [spec] : undefined;
79
+ if (!Array.isArray(spec))
80
+ return undefined; // registry schema's problem
81
+ const sizes = new Set();
82
+ let total = 0;
83
+ for (const entry of spec) {
84
+ if (Number.isInteger(entry)) {
85
+ sizes.add(entry);
86
+ total += entry;
87
+ }
88
+ else if (Array.isArray(entry) &&
89
+ entry.length === 2 &&
90
+ Number.isInteger(entry[0]) &&
91
+ Number.isInteger(entry[1])) {
92
+ sizes.add(entry[0]);
93
+ total += entry[0] * entry[1];
94
+ }
95
+ else {
96
+ return undefined; // malformed entry: registry schema's problem
97
+ }
98
+ }
99
+ const extent = shape?.[dim];
100
+ if (extent !== undefined && total !== extent) {
101
+ issues.push({
102
+ path: ["configuration", "chunk_shapes", dim],
103
+ message: `expected chunk sizes summing to ${extent} along dimension ${dim}, got ${total}`,
104
+ kind: "invalid_value",
105
+ });
106
+ }
107
+ return [...sizes];
108
+ });
109
+ if (perDim.every((sizes) => sizes !== undefined)) {
110
+ chunkSizes = perDim;
111
+ }
112
+ }
113
+ }
114
+ return { issues, chunkSizes };
115
+ }
116
+ /**
117
+ * Interpret a document's `chunk_grid` field: required members, cross-field
118
+ * rules against `shape`, and the division context for codec pipelines.
119
+ * Unrecognized grid names yield no issues and no context — the extension
120
+ * name space is open.
121
+ */
122
+ export function chunkGridVerdict(rawGrid, shape) {
123
+ if (!isPlainObject(rawGrid) && typeof rawGrid !== "string") {
124
+ return { issues: [], chunkSizes: undefined }; // structural layer's problem
125
+ }
126
+ const name = fieldParts(rawGrid)?.name;
127
+ if (name === "regular")
128
+ return regularIssues(rawGrid, shape);
129
+ if (name === "rectilinear")
130
+ return rectilinearIssues(rawGrid, shape);
131
+ return { issues: [], chunkSizes: undefined };
132
+ }
133
+ //# sourceMappingURL=chunk-grids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-grids.js","sourceRoot":"","sources":["../src/chunk-grids.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA+B1F,SAAS,aAAa,CAAC,OAAgB,EAAE,KAA2B;IAClE,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,UAAkC,CAAC;IACvC,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACzD,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,uDAAuD;YAChE,IAAI,EAAE,aAAa;SACpB,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC;QACvF,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,CAAC,eAAe,EAAE,aAAa,CAAC;YACtC,OAAO,EAAE,sBAAsB;YAC/B,IAAI,EAAE,aAAa;SACpB,CAAC,CAAC;IACL,CAAC;IACD,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,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AAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7D,IAAI,IAAI,KAAK,aAAa;QAAE,OAAO,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The codecs this package interprets — `transpose` and `sharding_indexed` —
3
+ * syntax (configuration types) and semantics together, plus the pipeline
4
+ * walker that threads dimensional context between codecs (mirroring
5
+ * zarr-python's chunk-spec threading): a valid transpose permutes the
6
+ * per-dimension chunk sizes for the codecs after it, and any codec this
7
+ * module cannot reason about — `reshape` may change a chunk's rank, and
8
+ * unknown codecs may do anything — invalidates the dimensional context for
9
+ * the rest of the pipeline instead of letting stale array-level facts
10
+ * produce false verdicts.
11
+ *
12
+ * Other codecs' required fields (blosc, gzip, zstd, ...) are deliberately
13
+ * NOT known here: they are registry-schema facts enforced by schema-driven
14
+ * tooling, and a second hardcoded source of truth would drift.
15
+ */
16
+ import type { PathedIssue } from "./errors.js";
17
+ import { type Path } from "./guards.js";
18
+ /** Configuration of the core `transpose` codec. */
19
+ export interface TransposeCodecConfiguration {
20
+ order: number[];
21
+ }
22
+ /** Configuration of the core `sharding_indexed` codec. */
23
+ export interface ShardingIndexedCodecConfiguration {
24
+ chunk_shape: number[];
25
+ codecs: unknown[];
26
+ index_codecs: unknown[];
27
+ index_location?: "start" | "end";
28
+ }
29
+ /**
30
+ * Walk one codec pipeline. `initialDims` is the array dimensionality at
31
+ * this point (undefined when unknowable); `initialChunkSizes` holds the
32
+ * distinct chunk lengths per dimension this pipeline may encode — what a
33
+ * sharding codec's inner chunks must divide. A regular grid contributes
34
+ * one size per dimension; a rectilinear grid may contribute several.
35
+ */
36
+ export declare function pipelineIssues(pipeline: unknown[], path: Path, initialDims: number | undefined, initialChunkSizes: number[][] | undefined): PathedIssue[];
37
+ //# sourceMappingURL=codecs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgD,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEtF,mDAAmD;AACnD,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,0DAA0D;AAC1D,MAAM,WAAW,iCAAiC;IAChD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;CAClC;AAOD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,iBAAiB,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,GACxC,WAAW,EAAE,CAoKf"}
package/dist/codecs.js ADDED
@@ -0,0 +1,182 @@
1
+ /**
2
+ * The codecs this package interprets — `transpose` and `sharding_indexed` —
3
+ * syntax (configuration types) and semantics together, plus the pipeline
4
+ * walker that threads dimensional context between codecs (mirroring
5
+ * zarr-python's chunk-spec threading): a valid transpose permutes the
6
+ * per-dimension chunk sizes for the codecs after it, and any codec this
7
+ * module cannot reason about — `reshape` may change a chunk's rank, and
8
+ * unknown codecs may do anything — invalidates the dimensional context for
9
+ * the rest of the pipeline instead of letting stale array-level facts
10
+ * produce false verdicts.
11
+ *
12
+ * Other codecs' required fields (blosc, gzip, zstd, ...) are deliberately
13
+ * NOT known here: they are registry-schema facts enforced by schema-driven
14
+ * tooling, and a second hardcoded source of truth would drift.
15
+ */
16
+ import { configurationMissing, fieldParts, isIntArray } from "./guards.js";
17
+ function isPermutation(order) {
18
+ const seen = new Set(order);
19
+ return seen.size === order.length && order.every((entry) => entry >= 0 && entry < order.length);
20
+ }
21
+ /**
22
+ * Walk one codec pipeline. `initialDims` is the array dimensionality at
23
+ * this point (undefined when unknowable); `initialChunkSizes` holds the
24
+ * distinct chunk lengths per dimension this pipeline may encode — what a
25
+ * sharding codec's inner chunks must divide. A regular grid contributes
26
+ * one size per dimension; a rectilinear grid may contribute several.
27
+ */
28
+ export function pipelineIssues(pipeline, path, initialDims, initialChunkSizes) {
29
+ const issues = [];
30
+ // The dimensional context THREADS through the pipeline: transpose permutes
31
+ // it, and anything this module cannot reason about invalidates it for the
32
+ // remaining codecs.
33
+ let dims = initialDims;
34
+ let chunkSizes = initialChunkSizes;
35
+ const dropContext = () => {
36
+ dims = undefined;
37
+ chunkSizes = undefined;
38
+ };
39
+ pipeline.forEach((entry, index) => {
40
+ const parts = fieldParts(entry);
41
+ if (parts === undefined) {
42
+ dropContext(); // structurally invalid entry: no further reasoning
43
+ return;
44
+ }
45
+ const { name, configuration } = parts;
46
+ const configMissing = configurationMissing(entry);
47
+ if (name === "transpose") {
48
+ if (configMissing) {
49
+ issues.push({
50
+ path: [...path, index],
51
+ message: '"transpose" requires a configuration with "order"',
52
+ kind: "missing_key",
53
+ });
54
+ dropContext();
55
+ return;
56
+ }
57
+ if (configuration !== undefined && !Object.hasOwn(configuration, "order")) {
58
+ issues.push({
59
+ path: [...path, index, "configuration", "order"],
60
+ message: "missing required key",
61
+ kind: "missing_key",
62
+ });
63
+ dropContext();
64
+ return;
65
+ }
66
+ const order = configuration?.["order"];
67
+ if (!isIntArray(order)) {
68
+ dropContext(); // shape errors are the schema layer's
69
+ return;
70
+ }
71
+ const orderPath = [...path, index, "configuration", "order"];
72
+ let sound = true;
73
+ if (!isPermutation(order)) {
74
+ sound = false;
75
+ issues.push({
76
+ path: orderPath,
77
+ message: `expected a permutation of the integers 0..${order.length - 1}`,
78
+ kind: "invalid_value",
79
+ });
80
+ }
81
+ if (dims !== undefined && order.length !== dims) {
82
+ sound = false;
83
+ issues.push({
84
+ path: orderPath,
85
+ message: `expected one entry per array dimension (${dims})`,
86
+ kind: "invalid_value",
87
+ });
88
+ }
89
+ if (!sound) {
90
+ dropContext();
91
+ }
92
+ else if (chunkSizes !== undefined) {
93
+ const sizes = chunkSizes;
94
+ chunkSizes =
95
+ order.length === sizes.length
96
+ ? order.map((axis) => sizes[axis])
97
+ : undefined;
98
+ }
99
+ }
100
+ else if (name === "sharding_indexed") {
101
+ if (configMissing) {
102
+ issues.push({
103
+ path: [...path, index],
104
+ message: '"sharding_indexed" requires a configuration with "chunk_shape", "codecs", and "index_codecs"',
105
+ kind: "missing_key",
106
+ });
107
+ dropContext();
108
+ return;
109
+ }
110
+ if (configuration !== undefined) {
111
+ for (const key of ["chunk_shape", "codecs", "index_codecs"]) {
112
+ if (!Object.hasOwn(configuration, key)) {
113
+ issues.push({
114
+ path: [...path, index, "configuration", key],
115
+ message: "missing required key",
116
+ kind: "missing_key",
117
+ });
118
+ }
119
+ }
120
+ }
121
+ const chunkShape = configuration?.["chunk_shape"];
122
+ if (!isIntArray(chunkShape)) {
123
+ // Still walk a present inner pipeline (entries deserve their own
124
+ // verdicts) before the context becomes unknowable.
125
+ const inner = configuration?.["codecs"];
126
+ if (Array.isArray(inner)) {
127
+ issues.push(...pipelineIssues(inner, [...path, index, "configuration", "codecs"], undefined, undefined));
128
+ }
129
+ dropContext();
130
+ return;
131
+ }
132
+ const chunkShapePath = [...path, index, "configuration", "chunk_shape"];
133
+ if (dims !== undefined && chunkShape.length !== dims) {
134
+ issues.push({
135
+ path: chunkShapePath,
136
+ message: `expected one length per array dimension (${dims})`,
137
+ kind: "invalid_value",
138
+ });
139
+ }
140
+ else if (chunkSizes !== undefined &&
141
+ chunkShape.length === chunkSizes.length &&
142
+ chunkShape.every((length) => length > 0)) {
143
+ let violation;
144
+ chunkSizes.forEach((sizes, axis) => {
145
+ if (violation !== undefined)
146
+ return;
147
+ const bad = sizes.find((size) => size % chunkShape[axis] !== 0);
148
+ if (bad !== undefined)
149
+ violation = { axis, size: bad };
150
+ });
151
+ if (violation !== undefined) {
152
+ const { axis, size } = violation;
153
+ const sizesNow = chunkSizes;
154
+ const uniform = sizesNow.every((sizes) => sizes.length === 1);
155
+ issues.push({
156
+ path: chunkShapePath,
157
+ message: uniform
158
+ ? `expected ${JSON.stringify(chunkShape)} to evenly divide the outer chunk shape ${JSON.stringify(sizesNow.map((sizes) => sizes[0]))}`
159
+ : `expected ${JSON.stringify(chunkShape)} to evenly divide every chunk size of the grid (dimension ${axis} has chunk size ${size})`,
160
+ kind: "invalid_value",
161
+ });
162
+ }
163
+ }
164
+ const inner = configuration?.["codecs"];
165
+ if (Array.isArray(inner)) {
166
+ issues.push(...pipelineIssues(inner, [...path, index, "configuration", "codecs"], chunkShape.length, chunkShape.map((length) => [length])));
167
+ }
168
+ // index_codecs encode the shard index, whose shape differs from the
169
+ // array's — no dimensional context applies there. After the
170
+ // array -> bytes boundary the dimensional context is spent.
171
+ dropContext();
172
+ }
173
+ else {
174
+ // A codec this module cannot reason about (reshape may change a
175
+ // chunk's rank; unknown codecs may do anything): stale array-level
176
+ // facts must not judge the codecs after it.
177
+ dropContext();
178
+ }
179
+ });
180
+ return issues;
181
+ }
182
+ //# sourceMappingURL=codecs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AAetF,SAAS,aAAa,CAAC,KAAe;IACpC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC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C;oBAC9D,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,cAAc;wBACpB,OAAO,EAAE,OAAO;4BACd,CAAC,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,2CAA2C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;4BACtI,CAAC,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,6DAA6D,IAAI,mBAAmB,IAAI,GAAG;wBACrI,IAAI,EAAE,eAAe;qBACtB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,MAAM,CAAC,IAAI,CACT,GAAG,cAAc,CACf,KAAK,EACL,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,EAC3C,UAAU,CAAC,MAAM,EACjB,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CACrC,CACF,CAAC;YACJ,CAAC;YACD,oEAAoE;YACpE,4DAA4D;YAC5D,4DAA4D;YAC5D,WAAW,EAAE,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,gEAAgE;YAChE,mEAAmE;YACnE,4CAA4C;YAC5C,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The core data types this package interprets: fill-value syntax per type,
3
+ * in one place per family. Extension data types are skipped — their shapes
4
+ * are registry-schema facts, and the name space is open.
5
+ */
6
+ /** A float fill value: a JSON number, a non-finite sentinel, or a hex string. */
7
+ export type FloatFillValue = number | "NaN" | "Infinity" | "-Infinity" | string;
8
+ /** A complex fill value: `[real, imaginary]`, each a float fill form. */
9
+ export type ComplexFillValue = [FloatFillValue, FloatFillValue];
10
+ /** The fill_value issue for a KNOWN core data type, if any; undefined otherwise. */
11
+ export declare function fillValueIssue(dataTypeName: string, fill: unknown): string | undefined;
12
+ //# sourceMappingURL=data-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-types.d.ts","sourceRoot":"","sources":["../src/data-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iFAAiF;AACjF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;AAEhF,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;AAuChE,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CA8BtF"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The core data types this package interprets: fill-value syntax per type,
3
+ * in one place per family. Extension data types are skipped — their shapes
4
+ * are registry-schema facts, and the name space is open.
5
+ */
6
+ const INT_RANGES = {
7
+ int8: [-128, 127],
8
+ int16: [-32768, 32767],
9
+ int32: [-2147483648, 2147483647],
10
+ int64: [-9223372036854775808, 9223372036854775807],
11
+ uint8: [0, 255],
12
+ uint16: [0, 65535],
13
+ uint32: [0, 4294967295],
14
+ uint64: [0, 18446744073709551615],
15
+ };
16
+ const FLOAT_HEX_DIGITS = {
17
+ float16: 4,
18
+ float32: 8,
19
+ float64: 16,
20
+ };
21
+ /** Hex digit width of each complex type's component floats. */
22
+ const COMPLEX_COMPONENT_HEX_DIGITS = {
23
+ complex64: 8,
24
+ complex128: 16,
25
+ };
26
+ function isFloatFill(value, hexDigits) {
27
+ if (typeof value === "number")
28
+ return true;
29
+ if (typeof value !== "string")
30
+ return false;
31
+ if (value === "NaN" || value === "Infinity" || value === "-Infinity")
32
+ return true;
33
+ return new RegExp(`^0x[0-9a-fA-F]{${hexDigits}}$`).test(value);
34
+ }
35
+ function floatFillMessage(name, hexDigits) {
36
+ return (`expected a number, "NaN", "Infinity", "-Infinity", or a ` +
37
+ `${hexDigits}-hex-digit "0x..." string for data type ${JSON.stringify(name)}`);
38
+ }
39
+ /** The fill_value issue for a KNOWN core data type, if any; undefined otherwise. */
40
+ export function fillValueIssue(dataTypeName, fill) {
41
+ if (dataTypeName === "bool") {
42
+ return typeof fill === "boolean"
43
+ ? undefined
44
+ : 'expected a boolean fill value for data type "bool"';
45
+ }
46
+ const intRange = INT_RANGES[dataTypeName];
47
+ if (intRange !== undefined) {
48
+ const [low, high] = intRange;
49
+ return Number.isInteger(fill) && fill >= low && fill <= high
50
+ ? undefined
51
+ : `expected an integer in [${low}, ${high}] for data type ${JSON.stringify(dataTypeName)}`;
52
+ }
53
+ const floatDigits = FLOAT_HEX_DIGITS[dataTypeName];
54
+ if (floatDigits !== undefined) {
55
+ return isFloatFill(fill, floatDigits)
56
+ ? undefined
57
+ : floatFillMessage(dataTypeName, floatDigits);
58
+ }
59
+ const complexDigits = COMPLEX_COMPONENT_HEX_DIGITS[dataTypeName];
60
+ if (complexDigits !== undefined) {
61
+ const ok = Array.isArray(fill) &&
62
+ fill.length === 2 &&
63
+ fill.every((part) => isFloatFill(part, complexDigits));
64
+ return ok
65
+ ? undefined
66
+ : `expected a two-element [real, imaginary] array for data type ${JSON.stringify(dataTypeName)}`;
67
+ }
68
+ return undefined; // unrecognized data type: no verdict
69
+ }
70
+ //# sourceMappingURL=data-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-types.js","sourceRoot":"","sources":["../src/data-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,UAAU,GAA8C;IAC5D,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC;IACjB,KAAK,EAAE,CAAC,C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 * Shared value guards for the content modules (chunk grids, codecs, data
3
+ * types) and the semantics orchestrator. The structural document layer
4
+ * (validation.ts) keeps its own copies deliberately: it is the
5
+ * corpus-governed layer and stays self-contained.
6
+ */
7
+ export type Path = ReadonlyArray<string | number>;
8
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
9
+ export declare function isIntArray(value: unknown): value is number[];
10
+ /** The `{name, configuration}` of a metadata field, when extractable. */
11
+ export declare function fieldParts(field: unknown): {
12
+ name: string;
13
+ configuration: Record<string, unknown> | undefined;
14
+ } | undefined;
15
+ /**
16
+ * Whether a metadata field genuinely lacks a `configuration` member (a
17
+ * malformed one — `configuration: 5` — is the structural layer's
18
+ * complaint, not the semantic layer's).
19
+ */
20
+ export declare function configurationMissing(field: unknown): boolean;
21
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAElD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI9E;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,EAAE,CAM5D;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,GACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAUlF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAI5D"}
package/dist/guards.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Shared value guards for the content modules (chunk grids, codecs, data
3
+ * types) and the semantics orchestrator. The structural document layer
4
+ * (validation.ts) keeps its own copies deliberately: it is the
5
+ * corpus-governed layer and stays self-contained.
6
+ */
7
+ export function isPlainObject(value) {
8
+ if (typeof value !== "object" || value === null || Array.isArray(value))
9
+ return false;
10
+ const proto = Object.getPrototypeOf(value);
11
+ return proto === null || proto === Object.prototype;
12
+ }
13
+ export function isIntArray(value) {
14
+ return (Array.isArray(value) &&
15
+ Object.keys(value).length === value.length &&
16
+ value.every((item) => Number.isInteger(item)));
17
+ }
18
+ /** The `{name, configuration}` of a metadata field, when extractable. */
19
+ export function fieldParts(field) {
20
+ if (typeof field === "string")
21
+ return { name: field, configuration: undefined };
22
+ if (isPlainObject(field) && typeof field["name"] === "string") {
23
+ const configuration = field["configuration"];
24
+ return {
25
+ name: field["name"],
26
+ configuration: isPlainObject(configuration) ? configuration : undefined,
27
+ };
28
+ }
29
+ return undefined;
30
+ }
31
+ /**
32
+ * Whether a metadata field genuinely lacks a `configuration` member (a
33
+ * malformed one — `configuration: 5` — is the structural layer's
34
+ * complaint, not the semantic layer's).
35
+ */
36
+ export function configurationMissing(field) {
37
+ return (typeof field === "string" || (isPlainObject(field) && !Object.hasOwn(field, "configuration")));
38
+ }
39
+ //# sourceMappingURL=guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtF,MAAM,KAAK,GAAY,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAC1C,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,UAAU,CACxB,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;IAChF,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC9D,MAAM,aAAa,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC;QAC7C,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YACnB,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;SACxE,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAC9F,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,9 @@
7
7
  */
8
8
  export type { JSONValue, ZarrV3MetadataFieldJSON, ZarrV3NamedConfigJSON } from "./common.js";
9
9
  export { flattenTree, formatTree, isEmptyTree, MetadataValidationError, treeOf, type ErrorTree, type Issue, type IssueKind, type IssuePath, type ParseResult, type PathedIssue, } from "./errors.js";
10
+ export type { ChunkGridVerdict, RectilinearChunkGridConfiguration, RectilinearDimSpec, RegularChunkGridConfiguration, } from "./chunk-grids.js";
11
+ export type { ShardingIndexedCodecConfiguration, TransposeCodecConfiguration, } from "./codecs.js";
12
+ export type { ComplexFillValue, FloatFillValue } from "./data-types.js";
10
13
  export * from "./schemas.js";
11
14
  export * from "./semantics.js";
12
15
  export type { StandardSchemaV1 } from "./standard-schema.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,SAAS,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,uBAAuB,EACvB,MAAM,EACN,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,SAAS,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,uBAAuB,EACvB,MAAM,EACN,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,gBAAgB,EAChB,iCAAiC,EACjC,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,iCAAiC,EACjC,2BAA2B,GAC5B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,uBAAuB,EACvB,MAAM,GAOP,MAAM,aAAa,CAAC;AACrB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,uBAAuB,EACvB,MAAM,GAOP,MAAM,aAAa,CAAC;AAYrB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}