doc-model.js 1.10.1 → 2.0.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 +28 -4
- package/dist/content-json-schema-defs.cjs +413 -0
- package/dist/content-json-schema-defs.d.cts +9 -0
- package/dist/content-json-schema-defs.d.ts +9 -0
- package/dist/content-json-schema-defs.js +409 -0
- package/dist/content.cjs +75 -14
- package/dist/content.d.cts +653 -15
- package/dist/content.d.ts +653 -15
- package/dist/content.js +71 -15
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/mathml-B1oTCtzc.d.cts +56 -0
- package/dist/mathml-B1oTCtzc.d.ts +56 -0
- package/dist/mathml.cjs +60 -0
- package/dist/mathml.d.cts +2 -0
- package/dist/mathml.d.ts +2 -0
- package/dist/mathml.js +51 -0
- package/dist/package.d.cts +139 -7
- package/dist/package.d.ts +139 -7
- package/dist/schema-io.cjs +1 -1
- package/dist/schema-io.js +1 -1
- package/package.json +1 -1
- package/schemas/content-document.schema.json +622 -14
- package/schemas/document-package.schema.json +3 -3
- package/schemas/layout-document.schema.json +1 -1
package/README.md
CHANGED
|
@@ -39,9 +39,9 @@ graph TD
|
|
|
39
39
|
style schema fill:#f9a825,stroke:#333,stroke-width:3px
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
`ContentDocument` (the semantic pivot) is a discriminated union of
|
|
42
|
+
`ContentDocument` (the semantic pivot) is a discriminated union of five kinds: `wordprocessing` (docx/odt-style sections of paragraphs/runs/tables/images), `presentation` (pptx/odp-style slides of shapes), `spreadsheet` (xlsx/ods-style sheets of cells, columns, rows, and print settings), `drawing` (odg-style pages of shapes plus vector primitives -- rect/ellipse/line/path), and `formula` (an equation, carrying its own MathML presentation-layer node tree plus the StarMath source when the producing format had one). `ContentEmbeddedObjectSchema` lets any of the five embed another whole `ContentDocument` -- including a `formula` one, which is what an embedded equation inside a document or slide now carries. `LayoutDocument` (the PDF-rendering pivot) is pages of positioned `LayoutItem`s -- `text`/`image`/`rect`/`line`/`ellipse`/`path`/`link` -- in PDF user-space coordinates, with `LayoutPathSchema` modelling a general vector path rather than only axis-aligned rectangles. `DocumentPackageSchema` is a small envelope pairing the two: `content` required, `layout` optional (it's a derived artifact, absent until something lays the content out), correlated via each item's own `sourcePath` when both are present -- a pairing this schema does not itself keep in sync or detect as stale.
|
|
43
43
|
|
|
44
|
-
It contains only [Zod](https://zod.dev) schemas, their inferred types, and a handful of trivial schema-attached helpers (hex-colour conversion,
|
|
44
|
+
It contains only [Zod](https://zod.dev) schemas, their inferred types, and a handful of trivial schema-attached helpers (hex-colour conversion, recursive structural type guards for the mutually-recursive table/block/embedded-object types and for the MathML node tree). There is no XML, ZIP, PDF, or other binary handling here, and no `zod` dependency other than `zod` itself.
|
|
45
45
|
|
|
46
46
|
The GitHub repository is [`ExaDev/document-schema.js`](https://github.com/ExaDev/document-schema.js), matching the published npm package name.
|
|
47
47
|
|
|
@@ -80,7 +80,31 @@ node_modules/document-schema.js/schemas/content-document.schema.json
|
|
|
80
80
|
node_modules/document-schema.js/schemas/layout-document.schema.json
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
Each file's `$id` is a `https://cdn.jsdelivr.net/npm/document-schema.js@<version>/schemas/<file>` URL, pinned to the exact npm version that generated it -- immutable (jsdelivr serves each version's own published tarball contents forever, with an immutable cache header) and genuinely live the moment that version is published, unlike a commit-SHA-pinned raw GitHub URL would be: a gitignored, generated file can never actually be committed at the commit whose SHA it would need to embed, since committing it changes the tree and thus the hash. The three files are cross-referenced via real `$ref`s (e.g. `document-package.schema.json`'s `content`/`layout` properties `$ref` the other two files directly, at that same version), so a JSON Schema validator that resolves `$ref`s over HTTP (or against local copies of all three files) can validate a whole `DocumentPackage` value. `content-document.schema.json` additionally carries a `$defs` block for the recursive paragraph/table/embedded-object block model, which Zod's own converter can
|
|
83
|
+
Each file's `$id` is a `https://cdn.jsdelivr.net/npm/document-schema.js@<version>/schemas/<file>` URL, pinned to the exact npm version that generated it -- immutable (jsdelivr serves each version's own published tarball contents forever, with an immutable cache header) and genuinely live the moment that version is published, unlike a commit-SHA-pinned raw GitHub URL would be: a gitignored, generated file can never actually be committed at the commit whose SHA it would need to embed, since committing it changes the tree and thus the hash. The three files are cross-referenced via real `$ref`s (e.g. `document-package.schema.json`'s `content`/`layout` properties `$ref` the other two files directly, at that same version), so a JSON Schema validator that resolves `$ref`s over HTTP (or against local copies of all three files) can validate a whole `DocumentPackage` value. `content-document.schema.json` additionally carries a `$defs` block for the recursive paragraph/table/embedded-object block model and for the recursive MathML node tree the `formula` kind carries, neither of which Zod's own converter can express directly (see that script's own top-of-file comment for why). `content-json-schema-defs.ts` (a normal, fully typechecked/linted `src/` module, not part of the `scripts/` build step) is where those hand-authored `$defs` fragments actually live; a regression test (`content-json-schema-defs.test.ts`) holds every fragment with a real, non-recursive, non-`z.custom()` exported Zod schema counterpart (`Color`, `Box`, `Alignment`, `ContentStrokeStyle`, `ContentBorder`, `ContentCellBorders`, `ContentListMembership`, `ContentRun`, `ContentParagraph`, `ContentImageBlock`, `ContentPageBreak`) to a live `z.toJSONSchema()` comparison against that real schema, so a field added to (or removed from) one of those schemas without updating its hand-authored `$defs` fragment now fails a test rather than silently drifting. The remaining fragments (`ContentBlock`, `ContentTable`/`ContentTableRow`/`ContentTableCell`, `ContentEmbeddedObjectBlock`, `MathMlNode`/`MathMlElement`/`MathMlAttribute`) sit downstream of one of the three genuinely un-representable `z.custom()` nodes and still need re-verifying by hand against `src/content.ts`/`src/mathml.ts` whenever those files change -- see the `z.lazy()` investigation immediately below for why those three nodes are `z.custom()` in the first place, and whether that still has to be true.
|
|
84
|
+
|
|
85
|
+
### `z.custom()` vs `z.lazy()` for recursive schemas
|
|
86
|
+
|
|
87
|
+
`ContentBlockSchema`, `ContentEmbeddedObjectSchema` (`src/content.ts`), and `MathMlNodeSchema` (`src/mathml.ts`) are all `z.custom()` type-guard predicates rather than real Zod schemas, because -- per each file's own long-standing code comment -- `z.lazy()` was believed to "collapse to `unknown`" for recursive children in the pinned Zod version. That belief was re-tested directly against the version actually installed today (`zod@4.4.3`, confirmed via `node_modules/zod/package.json`) by converting `MathMlNodeSchema`/`MathMlElementSchema` (the simplest of the three -- a self-recursive discriminated union, not `ContentBlock`'s mutual table/cell recursion or the cross-cutting `ContentDocument` cycle `ContentEmbeddedObject` carries) to a genuine `z.lazy()`-based pair, as a throwaway spike later reverted in full (`git diff -- src/mathml.ts` shows no changes on the commit this note was added in).
|
|
88
|
+
|
|
89
|
+
**Finding: `zod@4.4.3`'s `z.lazy()` genuinely supports this now, with one real constructional gotcha.** The naive rewrite --
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
export const MathMlElementSchema: z.ZodType<MathMlElement> = z.object({
|
|
93
|
+
type: z.literal('element'),
|
|
94
|
+
tag: z.string(),
|
|
95
|
+
attributes: z.array(MathMlAttributeSchema),
|
|
96
|
+
children: z.lazy(() => z.array(MathMlNodeSchema)),
|
|
97
|
+
});
|
|
98
|
+
export const MathMlNodeSchema: z.ZodType<MathMlNode> = z.discriminatedUnion('type', [
|
|
99
|
+
MathMlTextSchema, MathMlCdataSchema, MathMlCommentSchema, MathMlDeclarationSchema, MathMlPiSchema, MathMlElementSchema,
|
|
100
|
+
]);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
fails to typecheck: annotating `MathMlElementSchema` itself as `z.ZodType<MathMlElement>` widens it enough that `z.discriminatedUnion` (which needs each member's own internal `propValues` metadata to dispatch on the discriminant) rejects it with a real, correct type error (`Types of property '_zod.propValues' are incompatible ... Type 'undefined' is not assignable to type 'PropValues'`) -- not a Zod bug, but a genuine consequence of erasing a `ZodObject`'s specific shape down to the generic `ZodType` interface. Dropping the annotation entirely instead produces TypeScript's own classic circular-inference error (`'MathMlElementSchema' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer`) -- this is the failure the original "collapses to `unknown`" comment was almost certainly describing. The fix that actually works: annotate **only the outer union's own binding** (`MathMlNodeSchema: z.ZodType<MathMlNode> = z.discriminatedUnion(...)`), leaving every member schema, `MathMlElementSchema` included, unannotated and fully inferred. That one annotation breaks the circularity for the type-checker without erasing any member's own internal shape, since the erasure only ever applies to the final union result, not to what's passed into `z.discriminatedUnion`'s own argument list.
|
|
104
|
+
|
|
105
|
+
With that one change, every existing test in `mathml.test.ts` passed unmodified -- including the four-level-deep nested-element test and the exact-failure-at-the-deepest-level negative test -- proving recursion genuinely terminates and validates correctly at runtime, not just at the type level. `z.toJSONSchema(MathMlNodeSchema, { unrepresentable: 'any' })`, called on its own (no registry, no `override()`), produced a fully real, standard `oneOf`-based JSON Schema with a genuine `{ "$ref": "#" }` at the exact recursion point (`element.children.items`) -- no empty `{}` degenerate node anywhere, and `unrepresentable: 'any'` never actually had to activate for it.
|
|
106
|
+
|
|
107
|
+
**What this means, and what it doesn't (yet):** this is a confirmed, empirically-verified capability upgrade in the currently-pinned Zod version for the *simplest* of the three `z.custom()` cases in this package. It was **not** implemented as a real change in this task -- it's flagged here as a scoped, tracked follow-up, not carried out speculatively alongside unrelated work. Converting `MathMlNodeSchema` for real would let `scripts/generate-json-schemas.mjs` drop its `MathMlNode`/`MathMlElement`/`MathMlAttribute` hand-authored `$defs` entries (and the `override()` branch for `MathMlNodeSchema`) entirely, replacing them with Zod's own native recursive output. `ContentBlockSchema`/`ContentEmbeddedObjectSchema` are meaningfully harder (mutual recursion across `ContentBlock ↔ ContentTableCell ↔ ContentTableRow ↔ ContentTable`, plus `ContentEmbeddedObject`'s cycle back through a whole five-variant `ContentDocument` union) and were not spiked at all -- the same "annotate only the outermost binding" technique is the natural starting point, but the actual mutual-recursion shape needs its own from-scratch verification before assuming it generalises.
|
|
84
108
|
|
|
85
109
|
### Self-describing JSON
|
|
86
110
|
|
|
@@ -109,7 +133,7 @@ try {
|
|
|
109
133
|
}
|
|
110
134
|
```
|
|
111
135
|
|
|
112
|
-
`documentSchemaKindOf(value)` is the lower-level building block `documentFromJson` uses internally -- exported on its own for a caller that only wants to know which kind a value claims to be (version-agnostically: a `$schema` from an older or newer installed version still resolves), without also parsing it. `schemaUriFor(kind)` is the URL builder itself, also exported directly. Deliberately not added: a JSON-Schema-validator dependency (e.g. `ajv`) for ingest -- the generated `.schema.json` files are already a strictly *weaker* approximation of the real Zod schemas (see the
|
|
136
|
+
`documentSchemaKindOf(value)` is the lower-level building block `documentFromJson` uses internally -- exported on its own for a caller that only wants to know which kind a value claims to be (version-agnostically: a `$schema` from an older or newer installed version still resolves), without also parsing it. `schemaUriFor(kind)` is the URL builder itself, also exported directly. Deliberately not added: a JSON-Schema-validator dependency (e.g. `ajv`) for ingest -- the generated `.schema.json` files are already a strictly *weaker* approximation of the real Zod schemas (see the hand-authored `$defs` fragments above), so re-validating against them on ingest would be a fidelity regression, not an improvement.
|
|
113
137
|
|
|
114
138
|
## Used by
|
|
115
139
|
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_schema_io = require("./schema-io.cjs");
|
|
3
|
+
//#region src/content-json-schema-defs.ts
|
|
4
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
|
|
5
|
+
const EMBEDDED_OBJECT_KINDS = [
|
|
6
|
+
"formula",
|
|
7
|
+
"wordprocessing",
|
|
8
|
+
"presentation",
|
|
9
|
+
"spreadsheet",
|
|
10
|
+
"drawing"
|
|
11
|
+
];
|
|
12
|
+
const CONTENT_DOCUMENT_URI = require_schema_io.schemaUriFor("ContentDocument");
|
|
13
|
+
const CONTENT_DEFS = {
|
|
14
|
+
Color: {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
r: {
|
|
18
|
+
type: "number",
|
|
19
|
+
minimum: 0,
|
|
20
|
+
maximum: 1
|
|
21
|
+
},
|
|
22
|
+
g: {
|
|
23
|
+
type: "number",
|
|
24
|
+
minimum: 0,
|
|
25
|
+
maximum: 1
|
|
26
|
+
},
|
|
27
|
+
b: {
|
|
28
|
+
type: "number",
|
|
29
|
+
minimum: 0,
|
|
30
|
+
maximum: 1
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
required: [
|
|
34
|
+
"r",
|
|
35
|
+
"g",
|
|
36
|
+
"b"
|
|
37
|
+
],
|
|
38
|
+
additionalProperties: false
|
|
39
|
+
},
|
|
40
|
+
Box: {
|
|
41
|
+
type: "object",
|
|
42
|
+
properties: {
|
|
43
|
+
xPt: { type: "number" },
|
|
44
|
+
yPt: { type: "number" },
|
|
45
|
+
widthPt: {
|
|
46
|
+
type: "number",
|
|
47
|
+
minimum: 0
|
|
48
|
+
},
|
|
49
|
+
heightPt: {
|
|
50
|
+
type: "number",
|
|
51
|
+
minimum: 0
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
required: [
|
|
55
|
+
"xPt",
|
|
56
|
+
"yPt",
|
|
57
|
+
"widthPt",
|
|
58
|
+
"heightPt"
|
|
59
|
+
],
|
|
60
|
+
additionalProperties: false
|
|
61
|
+
},
|
|
62
|
+
Alignment: {
|
|
63
|
+
type: "string",
|
|
64
|
+
enum: [
|
|
65
|
+
"left",
|
|
66
|
+
"center",
|
|
67
|
+
"right",
|
|
68
|
+
"justify"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
ContentStrokeStyle: {
|
|
72
|
+
type: "string",
|
|
73
|
+
enum: [
|
|
74
|
+
"solid",
|
|
75
|
+
"dashed",
|
|
76
|
+
"dotted",
|
|
77
|
+
"double"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
ContentBorder: {
|
|
81
|
+
type: "object",
|
|
82
|
+
properties: {
|
|
83
|
+
color: { $ref: "#/$defs/Color" },
|
|
84
|
+
widthPt: {
|
|
85
|
+
type: "number",
|
|
86
|
+
exclusiveMinimum: 0
|
|
87
|
+
},
|
|
88
|
+
style: { $ref: "#/$defs/ContentStrokeStyle" }
|
|
89
|
+
},
|
|
90
|
+
required: ["color", "widthPt"],
|
|
91
|
+
additionalProperties: false
|
|
92
|
+
},
|
|
93
|
+
ContentCellBorders: {
|
|
94
|
+
type: "object",
|
|
95
|
+
properties: {
|
|
96
|
+
left: { $ref: "#/$defs/ContentBorder" },
|
|
97
|
+
right: { $ref: "#/$defs/ContentBorder" },
|
|
98
|
+
top: { $ref: "#/$defs/ContentBorder" },
|
|
99
|
+
bottom: { $ref: "#/$defs/ContentBorder" }
|
|
100
|
+
},
|
|
101
|
+
additionalProperties: false
|
|
102
|
+
},
|
|
103
|
+
ContentListMembership: {
|
|
104
|
+
type: "object",
|
|
105
|
+
properties: {
|
|
106
|
+
numId: { type: "string" },
|
|
107
|
+
level: {
|
|
108
|
+
type: "integer",
|
|
109
|
+
minimum: 0,
|
|
110
|
+
maximum: MAX_SAFE_INTEGER
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
required: ["numId", "level"],
|
|
114
|
+
additionalProperties: false
|
|
115
|
+
},
|
|
116
|
+
ContentRun: {
|
|
117
|
+
type: "object",
|
|
118
|
+
properties: {
|
|
119
|
+
text: { type: "string" },
|
|
120
|
+
bold: { type: "boolean" },
|
|
121
|
+
italic: { type: "boolean" },
|
|
122
|
+
underline: { type: "boolean" },
|
|
123
|
+
strike: { type: "boolean" },
|
|
124
|
+
fontFamily: { type: "string" },
|
|
125
|
+
sizePt: {
|
|
126
|
+
type: "number",
|
|
127
|
+
exclusiveMinimum: 0
|
|
128
|
+
},
|
|
129
|
+
color: { $ref: "#/$defs/Color" },
|
|
130
|
+
hyperlink: { type: "string" },
|
|
131
|
+
sourcePath: { type: "string" }
|
|
132
|
+
},
|
|
133
|
+
required: ["text"],
|
|
134
|
+
additionalProperties: false
|
|
135
|
+
},
|
|
136
|
+
ContentParagraph: {
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: {
|
|
139
|
+
kind: {
|
|
140
|
+
type: "string",
|
|
141
|
+
const: "paragraph"
|
|
142
|
+
},
|
|
143
|
+
runs: {
|
|
144
|
+
type: "array",
|
|
145
|
+
items: { $ref: "#/$defs/ContentRun" }
|
|
146
|
+
},
|
|
147
|
+
styleId: { type: "string" },
|
|
148
|
+
alignment: { $ref: "#/$defs/Alignment" },
|
|
149
|
+
list: { $ref: "#/$defs/ContentListMembership" },
|
|
150
|
+
spacingBeforePt: { type: "number" },
|
|
151
|
+
spacingAfterPt: { type: "number" },
|
|
152
|
+
lineSpacing: {
|
|
153
|
+
type: "number",
|
|
154
|
+
exclusiveMinimum: 0
|
|
155
|
+
},
|
|
156
|
+
indentLeftPt: { type: "number" },
|
|
157
|
+
indentFirstLinePt: { type: "number" },
|
|
158
|
+
sourcePath: { type: "string" }
|
|
159
|
+
},
|
|
160
|
+
required: ["kind", "runs"],
|
|
161
|
+
additionalProperties: false
|
|
162
|
+
},
|
|
163
|
+
ContentImageBlock: {
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: {
|
|
166
|
+
kind: {
|
|
167
|
+
type: "string",
|
|
168
|
+
const: "image"
|
|
169
|
+
},
|
|
170
|
+
format: {
|
|
171
|
+
type: "string",
|
|
172
|
+
enum: ["png", "jpeg"]
|
|
173
|
+
},
|
|
174
|
+
base64: { type: "string" },
|
|
175
|
+
widthPt: {
|
|
176
|
+
type: "number",
|
|
177
|
+
exclusiveMinimum: 0
|
|
178
|
+
},
|
|
179
|
+
heightPt: {
|
|
180
|
+
type: "number",
|
|
181
|
+
exclusiveMinimum: 0
|
|
182
|
+
},
|
|
183
|
+
altText: { type: "string" },
|
|
184
|
+
sourcePath: { type: "string" }
|
|
185
|
+
},
|
|
186
|
+
required: [
|
|
187
|
+
"kind",
|
|
188
|
+
"format",
|
|
189
|
+
"base64",
|
|
190
|
+
"widthPt",
|
|
191
|
+
"heightPt"
|
|
192
|
+
],
|
|
193
|
+
additionalProperties: false
|
|
194
|
+
},
|
|
195
|
+
ContentPageBreak: {
|
|
196
|
+
type: "object",
|
|
197
|
+
properties: {
|
|
198
|
+
kind: {
|
|
199
|
+
type: "string",
|
|
200
|
+
const: "pageBreak"
|
|
201
|
+
},
|
|
202
|
+
sourcePath: { type: "string" }
|
|
203
|
+
},
|
|
204
|
+
required: ["kind"],
|
|
205
|
+
additionalProperties: false
|
|
206
|
+
},
|
|
207
|
+
ContentTableCell: {
|
|
208
|
+
type: "object",
|
|
209
|
+
properties: {
|
|
210
|
+
blocks: {
|
|
211
|
+
type: "array",
|
|
212
|
+
items: { $ref: "#/$defs/ContentBlock" }
|
|
213
|
+
},
|
|
214
|
+
colSpan: {
|
|
215
|
+
type: "integer",
|
|
216
|
+
exclusiveMinimum: 0,
|
|
217
|
+
maximum: MAX_SAFE_INTEGER
|
|
218
|
+
},
|
|
219
|
+
rowSpan: {
|
|
220
|
+
type: "integer",
|
|
221
|
+
exclusiveMinimum: 0,
|
|
222
|
+
maximum: MAX_SAFE_INTEGER
|
|
223
|
+
},
|
|
224
|
+
background: { $ref: "#/$defs/Color" },
|
|
225
|
+
borders: { $ref: "#/$defs/ContentCellBorders" },
|
|
226
|
+
sourcePath: { type: "string" }
|
|
227
|
+
},
|
|
228
|
+
required: ["blocks"],
|
|
229
|
+
additionalProperties: false
|
|
230
|
+
},
|
|
231
|
+
ContentTableRow: {
|
|
232
|
+
type: "object",
|
|
233
|
+
properties: {
|
|
234
|
+
cells: {
|
|
235
|
+
type: "array",
|
|
236
|
+
items: { $ref: "#/$defs/ContentTableCell" }
|
|
237
|
+
},
|
|
238
|
+
heightPt: {
|
|
239
|
+
type: "number",
|
|
240
|
+
exclusiveMinimum: 0
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
required: ["cells"],
|
|
244
|
+
additionalProperties: false
|
|
245
|
+
},
|
|
246
|
+
ContentTable: {
|
|
247
|
+
type: "object",
|
|
248
|
+
properties: {
|
|
249
|
+
kind: {
|
|
250
|
+
type: "string",
|
|
251
|
+
const: "table"
|
|
252
|
+
},
|
|
253
|
+
rows: {
|
|
254
|
+
type: "array",
|
|
255
|
+
items: { $ref: "#/$defs/ContentTableRow" }
|
|
256
|
+
},
|
|
257
|
+
columnWidthsPt: {
|
|
258
|
+
type: "array",
|
|
259
|
+
items: {
|
|
260
|
+
type: "number",
|
|
261
|
+
exclusiveMinimum: 0
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
sourcePath: { type: "string" }
|
|
265
|
+
},
|
|
266
|
+
required: [
|
|
267
|
+
"kind",
|
|
268
|
+
"rows",
|
|
269
|
+
"columnWidthsPt"
|
|
270
|
+
],
|
|
271
|
+
additionalProperties: false
|
|
272
|
+
},
|
|
273
|
+
ContentEmbeddedObjectBlock: {
|
|
274
|
+
type: "object",
|
|
275
|
+
properties: {
|
|
276
|
+
kind: {
|
|
277
|
+
type: "string",
|
|
278
|
+
const: "embeddedObject"
|
|
279
|
+
},
|
|
280
|
+
objectKind: {
|
|
281
|
+
type: "string",
|
|
282
|
+
enum: EMBEDDED_OBJECT_KINDS
|
|
283
|
+
},
|
|
284
|
+
document: { $ref: CONTENT_DOCUMENT_URI },
|
|
285
|
+
frame: { $ref: "#/$defs/Box" },
|
|
286
|
+
sourcePath: { type: "string" }
|
|
287
|
+
},
|
|
288
|
+
required: [
|
|
289
|
+
"kind",
|
|
290
|
+
"objectKind",
|
|
291
|
+
"document",
|
|
292
|
+
"frame"
|
|
293
|
+
],
|
|
294
|
+
additionalProperties: false
|
|
295
|
+
},
|
|
296
|
+
ContentBlock: { oneOf: [
|
|
297
|
+
{ $ref: "#/$defs/ContentParagraph" },
|
|
298
|
+
{ $ref: "#/$defs/ContentTable" },
|
|
299
|
+
{ $ref: "#/$defs/ContentImageBlock" },
|
|
300
|
+
{ $ref: "#/$defs/ContentPageBreak" },
|
|
301
|
+
{ $ref: "#/$defs/ContentEmbeddedObjectBlock" }
|
|
302
|
+
] },
|
|
303
|
+
MathMlAttribute: {
|
|
304
|
+
type: "object",
|
|
305
|
+
properties: {
|
|
306
|
+
name: { type: "string" },
|
|
307
|
+
value: { type: "string" }
|
|
308
|
+
},
|
|
309
|
+
required: ["name", "value"],
|
|
310
|
+
additionalProperties: false
|
|
311
|
+
},
|
|
312
|
+
MathMlElement: {
|
|
313
|
+
type: "object",
|
|
314
|
+
properties: {
|
|
315
|
+
type: {
|
|
316
|
+
type: "string",
|
|
317
|
+
const: "element"
|
|
318
|
+
},
|
|
319
|
+
tag: { type: "string" },
|
|
320
|
+
attributes: {
|
|
321
|
+
type: "array",
|
|
322
|
+
items: { $ref: "#/$defs/MathMlAttribute" }
|
|
323
|
+
},
|
|
324
|
+
children: {
|
|
325
|
+
type: "array",
|
|
326
|
+
items: { $ref: "#/$defs/MathMlNode" }
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
required: [
|
|
330
|
+
"type",
|
|
331
|
+
"tag",
|
|
332
|
+
"attributes",
|
|
333
|
+
"children"
|
|
334
|
+
],
|
|
335
|
+
additionalProperties: false
|
|
336
|
+
},
|
|
337
|
+
MathMlNode: { oneOf: [
|
|
338
|
+
{
|
|
339
|
+
type: "object",
|
|
340
|
+
properties: {
|
|
341
|
+
type: {
|
|
342
|
+
type: "string",
|
|
343
|
+
const: "text"
|
|
344
|
+
},
|
|
345
|
+
value: { type: "string" }
|
|
346
|
+
},
|
|
347
|
+
required: ["type", "value"],
|
|
348
|
+
additionalProperties: false
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
type: "object",
|
|
352
|
+
properties: {
|
|
353
|
+
type: {
|
|
354
|
+
type: "string",
|
|
355
|
+
const: "cdata"
|
|
356
|
+
},
|
|
357
|
+
value: { type: "string" }
|
|
358
|
+
},
|
|
359
|
+
required: ["type", "value"],
|
|
360
|
+
additionalProperties: false
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
type: "object",
|
|
364
|
+
properties: {
|
|
365
|
+
type: {
|
|
366
|
+
type: "string",
|
|
367
|
+
const: "comment"
|
|
368
|
+
},
|
|
369
|
+
value: { type: "string" }
|
|
370
|
+
},
|
|
371
|
+
required: ["type", "value"],
|
|
372
|
+
additionalProperties: false
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
type: "object",
|
|
376
|
+
properties: {
|
|
377
|
+
type: {
|
|
378
|
+
type: "string",
|
|
379
|
+
const: "declaration"
|
|
380
|
+
},
|
|
381
|
+
attributes: {
|
|
382
|
+
type: "array",
|
|
383
|
+
items: { $ref: "#/$defs/MathMlAttribute" }
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
required: ["type", "attributes"],
|
|
387
|
+
additionalProperties: false
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
type: "object",
|
|
391
|
+
properties: {
|
|
392
|
+
type: {
|
|
393
|
+
type: "string",
|
|
394
|
+
const: "pi"
|
|
395
|
+
},
|
|
396
|
+
target: { type: "string" },
|
|
397
|
+
content: { type: "string" }
|
|
398
|
+
},
|
|
399
|
+
required: [
|
|
400
|
+
"type",
|
|
401
|
+
"target",
|
|
402
|
+
"content"
|
|
403
|
+
],
|
|
404
|
+
additionalProperties: false
|
|
405
|
+
},
|
|
406
|
+
{ $ref: "#/$defs/MathMlElement" }
|
|
407
|
+
] }
|
|
408
|
+
};
|
|
409
|
+
//#endregion
|
|
410
|
+
exports.CONTENT_DEFS = CONTENT_DEFS;
|
|
411
|
+
exports.CONTENT_DOCUMENT_URI = CONTENT_DOCUMENT_URI;
|
|
412
|
+
exports.EMBEDDED_OBJECT_KINDS = EMBEDDED_OBJECT_KINDS;
|
|
413
|
+
exports.MAX_SAFE_INTEGER = MAX_SAFE_INTEGER;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/content-json-schema-defs.d.ts
|
|
3
|
+
type JsonSchema = z.core.JSONSchema.JSONSchema;
|
|
4
|
+
declare const MAX_SAFE_INTEGER: number;
|
|
5
|
+
declare const EMBEDDED_OBJECT_KINDS: string[];
|
|
6
|
+
declare const CONTENT_DOCUMENT_URI: string;
|
|
7
|
+
declare const CONTENT_DEFS: Record<string, JsonSchema>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { CONTENT_DEFS, CONTENT_DOCUMENT_URI, EMBEDDED_OBJECT_KINDS, MAX_SAFE_INTEGER };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/content-json-schema-defs.d.ts
|
|
3
|
+
type JsonSchema = z.core.JSONSchema.JSONSchema;
|
|
4
|
+
declare const MAX_SAFE_INTEGER: number;
|
|
5
|
+
declare const EMBEDDED_OBJECT_KINDS: string[];
|
|
6
|
+
declare const CONTENT_DOCUMENT_URI: string;
|
|
7
|
+
declare const CONTENT_DEFS: Record<string, JsonSchema>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { CONTENT_DEFS, CONTENT_DOCUMENT_URI, EMBEDDED_OBJECT_KINDS, MAX_SAFE_INTEGER };
|