@moondraft/import 0.0.0-stage → 0.2.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/CHANGELOG.md +36 -0
- package/LICENSE +34 -0
- package/README.md +36 -2
- package/SOURCE.md +394 -0
- package/dist/adapter/convert.d.ts +144 -0
- package/dist/adapter/convert.js +2811 -0
- package/dist/adapter/figma-descriptions.d.ts +7 -0
- package/dist/adapter/figma-descriptions.js +34 -0
- package/dist/adapter/figma-grids.d.ts +12 -0
- package/dist/adapter/figma-grids.js +175 -0
- package/dist/adapter/figma-handoff.d.ts +12 -0
- package/dist/adapter/figma-handoff.js +167 -0
- package/dist/adapter/figma-hyperlinks.d.ts +13 -0
- package/dist/adapter/figma-hyperlinks.js +77 -0
- package/dist/adapter/figma.d.ts +12 -0
- package/dist/adapter/figma.js +40 -0
- package/dist/adapter/file-components.d.ts +20 -0
- package/dist/adapter/file-components.js +352 -0
- package/dist/adapter/file-resources.d.ts +29 -0
- package/dist/adapter/file-resources.js +851 -0
- package/dist/adapter/image-crop.d.ts +18 -0
- package/dist/adapter/image-crop.js +30 -0
- package/dist/adapter/index.d.ts +6 -0
- package/dist/adapter/index.js +9 -0
- package/dist/adapter/link.d.ts +49 -0
- package/dist/adapter/link.js +892 -0
- package/dist/adapter/payload.d.ts +31 -0
- package/dist/adapter/payload.js +78 -0
- package/dist/adapter/shapes.d.ts +31 -0
- package/dist/adapter/shapes.js +75 -0
- package/dist/adapter/variables.d.ts +45 -0
- package/dist/adapter/variables.js +106 -0
- package/dist/figma-file.d.ts +38 -0
- package/dist/figma-file.js +97 -0
- package/dist/figma-worker.d.ts +11 -0
- package/dist/figma-worker.js +12 -0
- package/dist/figma.d.ts +26 -0
- package/dist/figma.js +230 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +50 -0
- package/dist/report.d.ts +42 -0
- package/dist/report.js +142 -0
- package/dist/serialize.d.ts +7 -0
- package/dist/serialize.js +79 -0
- package/dist/svg.d.ts +33 -0
- package/dist/svg.js +44 -0
- package/dist/syntax.d.ts +8 -0
- package/dist/syntax.js +19 -0
- package/dist/taco/figma-import/clipboard.d.ts +25 -0
- package/dist/taco/figma-import/clipboard.js +87 -0
- package/dist/taco/figma-import/clipboardSize.d.ts +31 -0
- package/dist/taco/figma-import/clipboardSize.js +107 -0
- package/dist/taco/figma-import/container/compression.d.ts +9 -0
- package/dist/taco/figma-import/container/compression.js +174 -0
- package/dist/taco/figma-import/container/error.d.ts +15 -0
- package/dist/taco/figma-import/container/error.js +19 -0
- package/dist/taco/figma-import/container/kiwiContainer.d.ts +41 -0
- package/dist/taco/figma-import/container/kiwiContainer.js +61 -0
- package/dist/taco/figma-import/container/limits.d.ts +22 -0
- package/dist/taco/figma-import/container/limits.js +22 -0
- package/dist/taco/figma-import/container/zip.d.ts +14 -0
- package/dist/taco/figma-import/container/zip.js +154 -0
- package/dist/taco/figma-import/figFile.d.ts +34 -0
- package/dist/taco/figma-import/figFile.js +91 -0
- package/dist/taco/figma-import/figFileDocument.d.ts +25 -0
- package/dist/taco/figma-import/figFileDocument.js +100 -0
- package/dist/taco/figma-import/import/blobs.d.ts +10 -0
- package/dist/taco/figma-import/import/blobs.js +23 -0
- package/dist/taco/figma-import/import/carry.d.ts +24 -0
- package/dist/taco/figma-import/import/carry.js +66 -0
- package/dist/taco/figma-import/import/componentProps.d.ts +90 -0
- package/dist/taco/figma-import/import/componentProps.js +329 -0
- package/dist/taco/figma-import/import/componentSets.d.ts +85 -0
- package/dist/taco/figma-import/import/componentSets.js +647 -0
- package/dist/taco/figma-import/import/converters/effects.d.ts +31 -0
- package/dist/taco/figma-import/import/converters/effects.js +127 -0
- package/dist/taco/figma-import/import/converters/ellipse.d.ts +7 -0
- package/dist/taco/figma-import/import/converters/ellipse.js +54 -0
- package/dist/taco/figma-import/import/converters/exportSettings.d.ts +4 -0
- package/dist/taco/figma-import/import/converters/exportSettings.js +49 -0
- package/dist/taco/figma-import/import/converters/frame.d.ts +21 -0
- package/dist/taco/figma-import/import/converters/frame.js +63 -0
- package/dist/taco/figma-import/import/converters/gradient.d.ts +74 -0
- package/dist/taco/figma-import/import/converters/gradient.js +108 -0
- package/dist/taco/figma-import/import/converters/group.d.ts +19 -0
- package/dist/taco/figma-import/import/converters/group.js +30 -0
- package/dist/taco/figma-import/import/converters/image.d.ts +13 -0
- package/dist/taco/figma-import/import/converters/image.js +94 -0
- package/dist/taco/figma-import/import/converters/layout.d.ts +33 -0
- package/dist/taco/figma-import/import/converters/layout.js +187 -0
- package/dist/taco/figma-import/import/converters/line.d.ts +11 -0
- package/dist/taco/figma-import/import/converters/line.js +40 -0
- package/dist/taco/figma-import/import/converters/rectangle.d.ts +3 -0
- package/dist/taco/figma-import/import/converters/rectangle.js +11 -0
- package/dist/taco/figma-import/import/converters/section.d.ts +8 -0
- package/dist/taco/figma-import/import/converters/section.js +29 -0
- package/dist/taco/figma-import/import/converters/shared.d.ts +71 -0
- package/dist/taco/figma-import/import/converters/shared.js +372 -0
- package/dist/taco/figma-import/import/converters/text.d.ts +54 -0
- package/dist/taco/figma-import/import/converters/text.js +707 -0
- package/dist/taco/figma-import/import/converters/vector.d.ts +105 -0
- package/dist/taco/figma-import/import/converters/vector.js +609 -0
- package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +114 -0
- package/dist/taco/figma-import/import/converters/vectorNetwork.js +503 -0
- package/dist/taco/figma-import/import/fields.d.ts +15 -0
- package/dist/taco/figma-import/import/fields.js +29 -0
- package/dist/taco/figma-import/import/instances.d.ts +184 -0
- package/dist/taco/figma-import/import/instances.js +1530 -0
- package/dist/taco/figma-import/import/nestingCycles.d.ts +86 -0
- package/dist/taco/figma-import/import/nestingCycles.js +488 -0
- package/dist/taco/figma-import/import/slots.d.ts +56 -0
- package/dist/taco/figma-import/import/slots.js +96 -0
- package/dist/taco/figma-import/import/styles.d.ts +48 -0
- package/dist/taco/figma-import/import/styles.js +48 -0
- package/dist/taco/figma-import/import/tree.d.ts +66 -0
- package/dist/taco/figma-import/import/tree.js +194 -0
- package/dist/taco/figma-import/import/types.d.ts +232 -0
- package/dist/taco/figma-import/import/types.js +33 -0
- package/dist/taco/figma-import/import/variables.d.ts +137 -0
- package/dist/taco/figma-import/import/variables.js +769 -0
- package/dist/taco/figma-import/import/variantTrees.d.ts +20 -0
- package/dist/taco/figma-import/import/variantTrees.js +520 -0
- package/dist/taco/figma-import/import/walk.d.ts +207 -0
- package/dist/taco/figma-import/import/walk.js +1464 -0
- package/dist/taco/figma-import/index.d.ts +22 -0
- package/dist/taco/figma-import/index.js +13 -0
- package/dist/taco/figma-import/kiwi/byteReader.d.ts +37 -0
- package/dist/taco/figma-import/kiwi/byteReader.js +151 -0
- package/dist/taco/figma-import/kiwi/error.d.ts +14 -0
- package/dist/taco/figma-import/kiwi/error.js +29 -0
- package/dist/taco/figma-import/kiwi/limits.d.ts +18 -0
- package/dist/taco/figma-import/kiwi/limits.js +18 -0
- package/dist/taco/figma-import/kiwi/message.d.ts +12 -0
- package/dist/taco/figma-import/kiwi/message.js +147 -0
- package/dist/taco/figma-import/kiwi/schema.d.ts +42 -0
- package/dist/taco/figma-import/kiwi/schema.js +206 -0
- package/dist/taco/figma-import/kiwi/types.d.ts +46 -0
- package/dist/taco/figma-import/kiwi/types.js +18 -0
- package/dist/taco/model/agent-hidden-fields.d.ts +20 -0
- package/dist/taco/model/agent-hidden-fields.js +29 -0
- package/dist/taco/model/asset-users.d.ts +23 -0
- package/dist/taco/model/asset-users.js +128 -0
- package/dist/taco/model/auto-layout-lines.d.ts +32 -0
- package/dist/taco/model/auto-layout-lines.js +70 -0
- package/dist/taco/model/codec.d.ts +444 -0
- package/dist/taco/model/codec.js +5665 -0
- package/dist/taco/model/color.d.ts +11 -0
- package/dist/taco/model/color.js +61 -0
- package/dist/taco/model/comment-operations.d.ts +102 -0
- package/dist/taco/model/comment-operations.js +227 -0
- package/dist/taco/model/component-evaluation.d.ts +96 -0
- package/dist/taco/model/component-evaluation.js +555 -0
- package/dist/taco/model/component-expressions.d.ts +242 -0
- package/dist/taco/model/component-expressions.js +1082 -0
- package/dist/taco/model/component-properties.d.ts +111 -0
- package/dist/taco/model/component-properties.js +339 -0
- package/dist/taco/model/component-samples.d.ts +83 -0
- package/dist/taco/model/component-samples.js +290 -0
- package/dist/taco/model/component-validity.d.ts +85 -0
- package/dist/taco/model/component-validity.js +397 -0
- package/dist/taco/model/components.d.ts +155 -0
- package/dist/taco/model/components.js +505 -0
- package/dist/taco/model/connector-ends.d.ts +20 -0
- package/dist/taco/model/connector-ends.js +188 -0
- package/dist/taco/model/connector-geometry.d.ts +74 -0
- package/dist/taco/model/connector-geometry.js +293 -0
- package/dist/taco/model/corner-radii.d.ts +26 -0
- package/dist/taco/model/corner-radii.js +47 -0
- package/dist/taco/model/derivations.d.ts +81 -0
- package/dist/taco/model/derivations.js +151 -0
- package/dist/taco/model/export-settings.d.ts +53 -0
- package/dist/taco/model/export-settings.js +156 -0
- package/dist/taco/model/expressions/ast.d.ts +153 -0
- package/dist/taco/model/expressions/ast.js +6 -0
- package/dist/taco/model/expressions/cache.d.ts +23 -0
- package/dist/taco/model/expressions/cache.js +43 -0
- package/dist/taco/model/expressions/check.d.ts +72 -0
- package/dist/taco/model/expressions/check.js +517 -0
- package/dist/taco/model/expressions/completion.d.ts +61 -0
- package/dist/taco/model/expressions/completion.js +421 -0
- package/dist/taco/model/expressions/evaluate.d.ts +32 -0
- package/dist/taco/model/expressions/evaluate.js +519 -0
- package/dist/taco/model/expressions/forms.d.ts +84 -0
- package/dist/taco/model/expressions/forms.js +200 -0
- package/dist/taco/model/expressions/index.d.ts +14 -0
- package/dist/taco/model/expressions/index.js +17 -0
- package/dist/taco/model/expressions/lexer.d.ts +42 -0
- package/dist/taco/model/expressions/lexer.js +213 -0
- package/dist/taco/model/expressions/library.d.ts +33 -0
- package/dist/taco/model/expressions/library.js +117 -0
- package/dist/taco/model/expressions/names.d.ts +43 -0
- package/dist/taco/model/expressions/names.js +99 -0
- package/dist/taco/model/expressions/parser.d.ts +15 -0
- package/dist/taco/model/expressions/parser.js +438 -0
- package/dist/taco/model/expressions/rename.d.ts +34 -0
- package/dist/taco/model/expressions/rename.js +46 -0
- package/dist/taco/model/expressions/source.d.ts +15 -0
- package/dist/taco/model/expressions/source.js +161 -0
- package/dist/taco/model/expressions/types.d.ts +119 -0
- package/dist/taco/model/expressions/types.js +102 -0
- package/dist/taco/model/expressions/values.d.ts +97 -0
- package/dist/taco/model/expressions/values.js +160 -0
- package/dist/taco/model/geometry-limits.d.ts +16 -0
- package/dist/taco/model/geometry-limits.js +67 -0
- package/dist/taco/model/geometry.d.ts +47 -0
- package/dist/taco/model/geometry.js +193 -0
- package/dist/taco/model/group-bounds.d.ts +38 -0
- package/dist/taco/model/group-bounds.js +144 -0
- package/dist/taco/model/id-table.d.ts +37 -0
- package/dist/taco/model/id-table.js +80 -0
- package/dist/taco/model/index.d.ts +25 -0
- package/dist/taco/model/index.js +27 -0
- package/dist/taco/model/instance-resolver.d.ts +376 -0
- package/dist/taco/model/instance-resolver.js +1778 -0
- package/dist/taco/model/layer-syntax.d.ts +340 -0
- package/dist/taco/model/layer-syntax.js +3506 -0
- package/dist/taco/model/layout/constraints.d.ts +84 -0
- package/dist/taco/model/layout/constraints.js +445 -0
- package/dist/taco/model/layout/frame-layout.d.ts +46 -0
- package/dist/taco/model/layout/frame-layout.js +618 -0
- package/dist/taco/model/layout/node-sizing.d.ts +163 -0
- package/dist/taco/model/layout/node-sizing.js +486 -0
- package/dist/taco/model/legacy-connector-caps.d.ts +15 -0
- package/dist/taco/model/legacy-connector-caps.js +70 -0
- package/dist/taco/model/linear-call.d.ts +48 -0
- package/dist/taco/model/linear-call.js +58 -0
- package/dist/taco/model/new-nodes.d.ts +145 -0
- package/dist/taco/model/new-nodes.js +277 -0
- package/dist/taco/model/node-builder.d.ts +449 -0
- package/dist/taco/model/node-builder.js +2294 -0
- package/dist/taco/model/node-table-watch.d.ts +36 -0
- package/dist/taco/model/node-table-watch.js +63 -0
- package/dist/taco/model/node-transform.d.ts +39 -0
- package/dist/taco/model/node-transform.js +79 -0
- package/dist/taco/model/node-users-index.d.ts +10 -0
- package/dist/taco/model/node-users-index.js +82 -0
- package/dist/taco/model/operation-references.d.ts +80 -0
- package/dist/taco/model/operation-references.js +399 -0
- package/dist/taco/model/operations.d.ts +610 -0
- package/dist/taco/model/operations.js +2882 -0
- package/dist/taco/model/overlay-table.d.ts +71 -0
- package/dist/taco/model/overlay-table.js +171 -0
- package/dist/taco/model/override-remap.d.ts +69 -0
- package/dist/taco/model/override-remap.js +230 -0
- package/dist/taco/model/parent-table.d.ts +53 -0
- package/dist/taco/model/parent-table.js +193 -0
- package/dist/taco/model/problem-collector.d.ts +27 -0
- package/dist/taco/model/problem-collector.js +101 -0
- package/dist/taco/model/sha256.d.ts +10 -0
- package/dist/taco/model/sha256.js +79 -0
- package/dist/taco/model/shape-geometry.d.ts +96 -0
- package/dist/taco/model/shape-geometry.js +368 -0
- package/dist/taco/model/shared-node-table.d.ts +97 -0
- package/dist/taco/model/shared-node-table.js +546 -0
- package/dist/taco/model/slots.d.ts +113 -0
- package/dist/taco/model/slots.js +281 -0
- package/dist/taco/model/stroke-settings.d.ts +37 -0
- package/dist/taco/model/stroke-settings.js +90 -0
- package/dist/taco/model/svg-path-import.d.ts +89 -0
- package/dist/taco/model/svg-path-import.js +219 -0
- package/dist/taco/model/text-measurement.d.ts +142 -0
- package/dist/taco/model/text-measurement.js +846 -0
- package/dist/taco/model/text-reads.d.ts +66 -0
- package/dist/taco/model/text-reads.js +128 -0
- package/dist/taco/model/text-sizer.d.ts +358 -0
- package/dist/taco/model/text-sizer.js +996 -0
- package/dist/taco/model/theme-users.d.ts +59 -0
- package/dist/taco/model/theme-users.js +312 -0
- package/dist/taco/model/thumbnail.d.ts +15 -0
- package/dist/taco/model/thumbnail.js +34 -0
- package/dist/taco/model/types.d.ts +2369 -0
- package/dist/taco/model/types.js +366 -0
- package/dist/taco/model/unknown-property.d.ts +5 -0
- package/dist/taco/model/unknown-property.js +7 -0
- package/dist/taco/model/validated-documents.d.ts +22 -0
- package/dist/taco/model/validated-documents.js +22 -0
- package/dist/taco/model/variable-modes.d.ts +61 -0
- package/dist/taco/model/variable-modes.js +438 -0
- package/dist/taco/model/variable-references.d.ts +54 -0
- package/dist/taco/model/variable-references.js +183 -0
- package/dist/taco/model/variables.d.ts +24 -0
- package/dist/taco/model/variables.js +151 -0
- package/dist/taco/model/vector-network.d.ts +34 -0
- package/dist/taco/model/vector-network.js +411 -0
- package/dist/taco/svg-import/import-svg.d.ts +36 -0
- package/dist/taco/svg-import/import-svg.js +729 -0
- package/dist/taco/svg-import/index.d.ts +3 -0
- package/dist/taco/svg-import/index.js +3 -0
- package/dist/taco/svg-import/limits/limits.d.ts +79 -0
- package/dist/taco/svg-import/limits/limits.js +160 -0
- package/dist/taco/svg-import/paint/gradients.d.ts +64 -0
- package/dist/taco/svg-import/paint/gradients.js +429 -0
- package/dist/taco/svg-import/paint/paint.d.ts +32 -0
- package/dist/taco/svg-import/paint/paint.js +162 -0
- package/dist/taco/svg-import/paths/paths.d.ts +58 -0
- package/dist/taco/svg-import/paths/paths.js +205 -0
- package/dist/taco/svg-import/public-types.d.ts +279 -0
- package/dist/taco/svg-import/public-types.js +56 -0
- package/dist/taco/svg-import/report/report.d.ts +44 -0
- package/dist/taco/svg-import/report/report.js +79 -0
- package/dist/taco/svg-import/reuse/reuse.d.ts +99 -0
- package/dist/taco/svg-import/reuse/reuse.js +840 -0
- package/dist/taco/svg-import/shapes/shapes.d.ts +35 -0
- package/dist/taco/svg-import/shapes/shapes.js +386 -0
- package/dist/taco/svg-import/structure/effects.d.ts +26 -0
- package/dist/taco/svg-import/structure/effects.js +618 -0
- package/dist/taco/svg-import/structure/image.d.ts +24 -0
- package/dist/taco/svg-import/structure/image.js +495 -0
- package/dist/taco/svg-import/structure/walk.d.ts +85 -0
- package/dist/taco/svg-import/structure/walk.js +544 -0
- package/dist/taco/svg-import/style/color.d.ts +40 -0
- package/dist/taco/svg-import/style/color.js +275 -0
- package/dist/taco/svg-import/style/computed.d.ts +214 -0
- package/dist/taco/svg-import/style/computed.js +1534 -0
- package/dist/taco/svg-import/style/css.d.ts +127 -0
- package/dist/taco/svg-import/style/css.js +541 -0
- package/dist/taco/svg-import/style/media.d.ts +25 -0
- package/dist/taco/svg-import/style/media.js +307 -0
- package/dist/taco/svg-import/style/properties.d.ts +43 -0
- package/dist/taco/svg-import/style/properties.js +135 -0
- package/dist/taco/svg-import/style/selector-reach.d.ts +30 -0
- package/dist/taco/svg-import/style/selector-reach.js +169 -0
- package/dist/taco/svg-import/style/selector-validity.d.ts +14 -0
- package/dist/taco/svg-import/style/selector-validity.js +307 -0
- package/dist/taco/svg-import/text/text.d.ts +29 -0
- package/dist/taco/svg-import/text/text.js +545 -0
- package/dist/taco/svg-import/transform/matrix.d.ts +111 -0
- package/dist/taco/svg-import/transform/matrix.js +229 -0
- package/dist/taco/svg-import/tree/element-data.d.ts +52 -0
- package/dist/taco/svg-import/tree/element-data.js +155 -0
- package/dist/taco/svg-import/tree/elements.d.ts +36 -0
- package/dist/taco/svg-import/tree/elements.js +121 -0
- package/dist/taco/svg-import/units/length.d.ts +43 -0
- package/dist/taco/svg-import/units/length.js +125 -0
- package/dist/taco/svg-import/units/viewbox.d.ts +35 -0
- package/dist/taco/svg-import/units/viewbox.js +77 -0
- package/package.json +55 -4
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import type { DocumentPartReference } from "./operation-references.ts";
|
|
2
|
+
import { type Asset, type CommentMessage, type CommentThread, type CommentThreadDigest, type CommentEditRecord, type DocumentTheme, type DesignDocument, type DocumentSchemaVersion, type SceneNode, type ShapeNode, type TextStyleOverrides } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* What kind of problem a `ModelError` reports:
|
|
5
|
+
*
|
|
6
|
+
* - `INVALID_JSON`: the input string is not JSON, or a value is not plain
|
|
7
|
+
* JSON (it holds `undefined`, a non-finite number, a cycle, or a class
|
|
8
|
+
* instance).
|
|
9
|
+
* - `INVALID_SCHEMA`: a value has the wrong shape, an unknown property, or an
|
|
10
|
+
* out-of-range number. Rejected operations and store calls also use it.
|
|
11
|
+
* - `INVALID_TREE`: the value is well formed but its references do not fit
|
|
12
|
+
* together: a missing or shared child, a cycle, an unreachable node, or a
|
|
13
|
+
* missing style, variable, asset or commit.
|
|
14
|
+
* - `UNSUPPORTED_VERSION`: the data is newer than this package supports.
|
|
15
|
+
* - `MISSING_MIGRATION`: no migration step starts at the data's version.
|
|
16
|
+
* - `MIGRATION_FAILED`: a migration step threw or produced the wrong version.
|
|
17
|
+
*/
|
|
18
|
+
export type ModelErrorCode = "INVALID_JSON" | "INVALID_SCHEMA" | "INVALID_TREE" | "UNSUPPORTED_VERSION" | "MISSING_MIGRATION" | "MIGRATION_FAILED"
|
|
19
|
+
/** A contract whose implementation has not landed yet. @since 0.23.0 */
|
|
20
|
+
| "NOT_IMPLEMENTED"
|
|
21
|
+
/** A change would remove a page whose `removable` is `false`. @since 0.29.0 */
|
|
22
|
+
| "PAGE_NOT_REMOVABLE"
|
|
23
|
+
/** A request is over one of its documented limits, such as `LIBRARY_UPDATE_LIMITS`. @since 0.42.0 */
|
|
24
|
+
| "LIMIT_EXCEEDED"
|
|
25
|
+
/** A library update names a component the document has and the library lacks. @since 0.42.0 */
|
|
26
|
+
| "MISSING_LIBRARY_COMPONENT";
|
|
27
|
+
/** One problem the model found: what kind, a sentence, and where, as `ModelError` reports one. */
|
|
28
|
+
export interface ModelProblem {
|
|
29
|
+
readonly code: ModelErrorCode;
|
|
30
|
+
readonly message: string;
|
|
31
|
+
readonly path: string;
|
|
32
|
+
/** The parts of the document this problem names by ID beyond its path; absent when it names none. */
|
|
33
|
+
readonly parts?: readonly DocumentPartReference[];
|
|
34
|
+
}
|
|
35
|
+
/** The most problems one refusal lists; past it, one more entry says how many were left out. */
|
|
36
|
+
export declare const MODEL_PROBLEM_LIMIT = 20;
|
|
37
|
+
/**
|
|
38
|
+
* The error this package throws for invalid data and rejected edits. The
|
|
39
|
+
* message ends with `at <path>`.
|
|
40
|
+
*/
|
|
41
|
+
export declare class ModelError extends Error {
|
|
42
|
+
/**
|
|
43
|
+
* Every problem found, in the order the checks ran; the first is this
|
|
44
|
+
* error's own `code`, message and `path`. The throwing checks stop at the
|
|
45
|
+
* first problem, so only the collecting ones (`checkSceneNode`,
|
|
46
|
+
* `checkOperation`) list more than one.
|
|
47
|
+
*/
|
|
48
|
+
readonly problems: readonly ModelProblem[];
|
|
49
|
+
/** What kind of problem this is. */
|
|
50
|
+
readonly code: ModelErrorCode;
|
|
51
|
+
/**
|
|
52
|
+
* Where the problem is, as a JSON path such as `$.nodes.n1.opacity`.
|
|
53
|
+
* Paths that start with `$operation`, `$store` or `$commit` point into an
|
|
54
|
+
* operation, stored history or a commit instead of a document, and
|
|
55
|
+
* `$svgPath` into the description given to `pathNodeFromSvgPath`.
|
|
56
|
+
*/
|
|
57
|
+
readonly path: string;
|
|
58
|
+
constructor(code: ModelErrorCode, message: string, path?: string, options?: ModelErrorOptions);
|
|
59
|
+
/**
|
|
60
|
+
* The parts of the document the error names by ID beyond its path, such as
|
|
61
|
+
* the missing component of an instance together with that instance, or the
|
|
62
|
+
* layer that still uses a component being removed: of all its `problems`
|
|
63
|
+
* together, each once. Empty when it names none. A problem that names none
|
|
64
|
+
* has no `parts` of its own, even when this lists the parts of the others.
|
|
65
|
+
*/
|
|
66
|
+
readonly parts: readonly DocumentPartReference[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The options of a `ModelError`: the standard ones, the parts its one problem
|
|
70
|
+
* names, and every problem found. When `problems` is given, the error's parts
|
|
71
|
+
* are theirs and `parts` is not used.
|
|
72
|
+
*/
|
|
73
|
+
export interface ModelErrorOptions extends ErrorOptions {
|
|
74
|
+
readonly parts?: readonly DocumentPartReference[];
|
|
75
|
+
readonly problems?: readonly ModelProblem[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Runs `check` with the same checks the throwing functions use, but records
|
|
79
|
+
* each problem and goes on, and returns every problem in the order the checks
|
|
80
|
+
* ran. The first is the error the throwing check would throw. Past
|
|
81
|
+
* `MODEL_PROBLEM_LIMIT` the list ends with one entry, "and N more".
|
|
82
|
+
*/
|
|
83
|
+
export declare function collectModelProblems(check: () => void, limit?: number): readonly ModelProblem[];
|
|
84
|
+
/**
|
|
85
|
+
* At most `limit` problems, then one entry, "and N more", at the path of the
|
|
86
|
+
* first one left out. That entry names the parts of every problem left out
|
|
87
|
+
* together, or none when one of them names none. A caller that joins the
|
|
88
|
+
* problems of several checks collects them with no limit (`Infinity`) and
|
|
89
|
+
* limits the whole list once.
|
|
90
|
+
*/
|
|
91
|
+
export declare function limitModelProblems<P extends {
|
|
92
|
+
readonly path: string;
|
|
93
|
+
readonly message: string;
|
|
94
|
+
readonly parts?: readonly DocumentPartReference[];
|
|
95
|
+
}>(problems: readonly P[], limit?: number): readonly P[];
|
|
96
|
+
/**
|
|
97
|
+
* One `ModelError` for a list of problems from a collecting check: the first
|
|
98
|
+
* is its code, message and path, and `problems` holds them all. Undefined
|
|
99
|
+
* when the list is empty.
|
|
100
|
+
*/
|
|
101
|
+
export declare function modelErrorOf(problems: readonly ModelProblem[]): ModelError | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Checks that `value` is a document schema version: a non-negative whole
|
|
104
|
+
* number (legacy) or a `major.minor.patch` string. Returns it unchanged.
|
|
105
|
+
* Throws a `ModelError` with code `INVALID_SCHEMA` at `path` otherwise.
|
|
106
|
+
*/
|
|
107
|
+
export declare function readDocumentSchemaVersion(value: unknown, path: string): DocumentSchemaVersion;
|
|
108
|
+
/**
|
|
109
|
+
* Orders two schema versions, returning -1, 0 or 1. Semantic versions compare
|
|
110
|
+
* part by part. Legacy numbers 0 and 1 sort before every semantic version,
|
|
111
|
+
* and higher numbers after them. Throws a `TypeError` for a malformed version
|
|
112
|
+
* string.
|
|
113
|
+
*/
|
|
114
|
+
export declare function compareDocumentSchemaVersions(left: DocumentSchemaVersion, right: DocumentSchemaVersion): number;
|
|
115
|
+
export declare const jsonCodecStats: {
|
|
116
|
+
jsonPathAllocations: number;
|
|
117
|
+
canonicalJsonCalls: number;
|
|
118
|
+
/** Document checks that walked the whole node tree. */
|
|
119
|
+
wholeTreeChecks: number;
|
|
120
|
+
/** Nodes whose every field was checked (`validateNode`). */
|
|
121
|
+
nodeShapeChecks: number;
|
|
122
|
+
/** Nodes found to differ from a stored node in their position alone (`differsInPositionOnly`), so only it was checked. */
|
|
123
|
+
positionOnlyChecks: number;
|
|
124
|
+
};
|
|
125
|
+
export declare function resetJsonCodecStats(): void;
|
|
126
|
+
/** The fields a paint takes, by its `kind`, as the codec checks them. */
|
|
127
|
+
export declare const paintFieldNames: {
|
|
128
|
+
readonly solid: readonly ["kind", "color", "opacity", "visible", "blendMode"];
|
|
129
|
+
readonly "linear-gradient": readonly ["kind", "from", "to", "stops", "opacity", "visible", "blendMode"];
|
|
130
|
+
readonly "radial-gradient": readonly ["kind", "center", "radius", "stops", "opacity", "visible", "blendMode"];
|
|
131
|
+
readonly "angular-gradient": readonly ["kind", "center", "angle", "stops", "opacity", "visible", "blendMode"];
|
|
132
|
+
readonly image: readonly ["kind", "assetId", "fit", "opacity", "visible", "blendMode"];
|
|
133
|
+
};
|
|
134
|
+
/** The fields a `LayerOverride` may hold. */
|
|
135
|
+
export declare const layerOverrideFieldNames: readonly string[];
|
|
136
|
+
/** The fields of `TextStyleOverrides`, as the codec checks them. */
|
|
137
|
+
export declare const textStyleOverrideFieldNames: readonly ["fontFamily", "fontStyle", "fontAssetId", "fontFallbackAssetIds", "language", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "color", "italic", "underline", "strikethrough", "openTypeFeatures", "fontVariations"];
|
|
138
|
+
/** Validates a standalone authored run or list-marker text-style override. */
|
|
139
|
+
export declare function assertTextStyleOverrides(value: unknown): asserts value is TextStyleOverrides;
|
|
140
|
+
/** The fields a `TextParagraph` takes, as the codec checks them. */
|
|
141
|
+
export declare const textParagraphFieldNames: readonly ["runs", "direction", "align", "spacingBefore", "spacingAfter", "indent", "list"];
|
|
142
|
+
/** The fields a `TextRun` takes, as the codec checks them; its size, colour and weight go in `overrides`. */
|
|
143
|
+
export declare const textRunFieldNames: readonly ["text", "styleId", "overrides", "hyperlink"];
|
|
144
|
+
/**
|
|
145
|
+
* A kind of node: its `type`, plus its `shape` for a shape node, because a
|
|
146
|
+
* path has no `frame`. Any `SceneNode` is one.
|
|
147
|
+
*/
|
|
148
|
+
export type SceneNodeKind = {
|
|
149
|
+
readonly type: Exclude<SceneNode["type"], "shape">;
|
|
150
|
+
} | {
|
|
151
|
+
readonly type: "shape";
|
|
152
|
+
readonly shape: ShapeNode["shape"];
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* The fields a node of `kind` may have, as `assertSceneNode` and the document
|
|
156
|
+
* codec accept them: the fields every node has (but `constraints`, which a
|
|
157
|
+
* group never takes), then the fields of its kind.
|
|
158
|
+
* Pass the node itself, or `{ type }` (`{ type: "shape", shape }` for a shape).
|
|
159
|
+
* Whether a field is required, and which values it takes, is checked by
|
|
160
|
+
* `assertSceneNode`; this is only the list of names.
|
|
161
|
+
*/
|
|
162
|
+
export declare function sceneNodeFieldNames(kind: SceneNodeKind): readonly string[];
|
|
163
|
+
/**
|
|
164
|
+
* Checks the shape of one node on its own. References to other nodes, styles
|
|
165
|
+
* and assets are not checked. Throws a `ModelError` on failure.
|
|
166
|
+
*/
|
|
167
|
+
export declare function assertSceneNode(value: unknown): asserts value is SceneNode;
|
|
168
|
+
/**
|
|
169
|
+
* Checks a node as `assertSceneNode` does, with the same checks, but returns
|
|
170
|
+
* every problem instead of throwing the first: each field is checked, and a
|
|
171
|
+
* value that failed counts once, without the problems inside it. Empty when
|
|
172
|
+
* `assertSceneNode` accepts the node; otherwise the first problem is the
|
|
173
|
+
* error it throws. At most `limit`, then "and N more".
|
|
174
|
+
*/
|
|
175
|
+
export declare function checkSceneNode(value: unknown, limit?: number): readonly ModelProblem[];
|
|
176
|
+
/** Checks the shape of a theme on its own. Throws a `ModelError` on failure. */
|
|
177
|
+
export declare function assertDocumentTheme(value: unknown): asserts value is DocumentTheme;
|
|
178
|
+
/** Checks the shape of one asset on its own. Throws a `ModelError` on failure. */
|
|
179
|
+
export declare function assertAsset(value: unknown): asserts value is Asset;
|
|
180
|
+
/**
|
|
181
|
+
* Names the parts a transaction touched. Everything the document carries over
|
|
182
|
+
* unchanged was validated when it first entered the document, so it is checked
|
|
183
|
+
* for shape again only when it appears here.
|
|
184
|
+
*
|
|
185
|
+
* A change set that omits something the transaction wrote would let an invalid
|
|
186
|
+
* value through, so only produce one alongside the edit that made it.
|
|
187
|
+
*/
|
|
188
|
+
export interface ChangedDocumentEntities {
|
|
189
|
+
readonly nodeIds: ReadonlySet<string>;
|
|
190
|
+
readonly pageIds: ReadonlySet<string>;
|
|
191
|
+
readonly assetIds: ReadonlySet<string>;
|
|
192
|
+
/** Components whose definition was written. @since 0.23.0 */
|
|
193
|
+
readonly componentIds: ReadonlySet<string>;
|
|
194
|
+
readonly themeChanged: boolean;
|
|
195
|
+
/** Comment threads were written, so the whole list is checked. @since 0.31.0 */
|
|
196
|
+
readonly commentThreadsChanged?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* The valid, frozen document the transaction was applied to. When only
|
|
199
|
+
* nodes were written and none removed, the rules that span entities (the
|
|
200
|
+
* node tree and the references a node makes) are then checked only around
|
|
201
|
+
* the written nodes instead of across the whole document.
|
|
202
|
+
*/
|
|
203
|
+
readonly previous?: DesignDocument;
|
|
204
|
+
/**
|
|
205
|
+
* The written nodes come from editor code that moved nodes of `previous`
|
|
206
|
+
* (`ApplyOperationsOptions.movedStoredNodes`): a written node that differs
|
|
207
|
+
* from its node in `previous` in its position alone (`frame.x` and `frame.y`, or a path's translation)
|
|
208
|
+
* (`differsInPositionOnly`) has only those two numbers checked, since
|
|
209
|
+
* every other field is a value of a valid node. Never set for an edit
|
|
210
|
+
* read from an agent, a file, a paste or history.
|
|
211
|
+
*/
|
|
212
|
+
readonly movedStoredNodes?: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* `nodeIds` also holds every node that uses a changed asset in `previous`
|
|
215
|
+
* or in the document (`nodeUsesAsset`). The references to assets are then
|
|
216
|
+
* checked only at those nodes: every other node names the same assets as
|
|
217
|
+
* in `previous`, whose entries did not change. Without it, a change of
|
|
218
|
+
* assets checks the references of every node.
|
|
219
|
+
*/
|
|
220
|
+
readonly assetUsersWritten?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* `nodeIds` also holds every node that uses a part of the theme that
|
|
223
|
+
* differs between `previous` and the document (`nodesUsingThemeChange`).
|
|
224
|
+
* After a theme change the theme is checked, and the references to it only
|
|
225
|
+
* at those nodes: every other node names parts of the theme that did not
|
|
226
|
+
* change. Without it, a theme change checks every node.
|
|
227
|
+
* @since 0.35.0
|
|
228
|
+
*/
|
|
229
|
+
readonly themeUsersWritten?: boolean;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The field that holds a node's position: `transform` for a path, whose
|
|
233
|
+
* last two entries are its translation, and `frame` for every other node.
|
|
234
|
+
*/
|
|
235
|
+
export declare function positionFieldOf(node: SceneNode): "frame" | "transform";
|
|
236
|
+
/**
|
|
237
|
+
* Whether `candidate` is the valid, frozen node `stored` with only its
|
|
238
|
+
* position changed: a plain object with the same keys and every field but
|
|
239
|
+
* the position field (`positionFieldOf`) the same value as the stored one.
|
|
240
|
+
* For a `frame`, a plain object with exactly `x`, `y`, `width` and `height`,
|
|
241
|
+
* the same width and height, and bounded finite numbers for `x` and `y`. For a
|
|
242
|
+
* path's `transform`, an array of exactly six entries, the first four the
|
|
243
|
+
* stored ones and the last two (the translation) bounded finite numbers. A node
|
|
244
|
+
* that passes holds valid values everywhere, since no rule of a node reads
|
|
245
|
+
* its position beyond asking for finite numbers. Costs as much as the
|
|
246
|
+
* node's top-level fields, not as much as the values inside them.
|
|
247
|
+
*/
|
|
248
|
+
export declare function differsInPositionOnly(stored: SceneNode, candidate: unknown): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Checks that `value` is a valid `DesignDocument` at
|
|
251
|
+
* `CURRENT_DOCUMENT_SCHEMA_VERSION`: every entity's shape, the node tree
|
|
252
|
+
* (each node reachable from exactly one page, no cycles or shared children),
|
|
253
|
+
* page order, and style, variable, connector, media-node and font
|
|
254
|
+
* references. It
|
|
255
|
+
* does not migrate; use `deserializeDocument` for older data.
|
|
256
|
+
*
|
|
257
|
+
* Throws a `ModelError` naming the first problem found.
|
|
258
|
+
*/
|
|
259
|
+
/** The values `CommentAuthor.kind` may take. @since 0.31.0 */
|
|
260
|
+
export declare const COMMENT_AUTHOR_KINDS: readonly ["person", "agent"];
|
|
261
|
+
/** The values `CommentAnchor.kind` may take. @since 0.31.0 */
|
|
262
|
+
export declare const COMMENT_ANCHOR_KINDS: readonly ["point", "region"];
|
|
263
|
+
/** The values `CommentThread.agentStatus` may take. @since 0.31.0 */
|
|
264
|
+
export declare const COMMENT_AGENT_STATUSES: readonly ["reading", "editing", "done"];
|
|
265
|
+
/** Called once by `operations.ts` with `assertOperation`. Not part of the public API. */
|
|
266
|
+
export declare function registerDesignOperationCheck(check: (value: unknown) => void): void;
|
|
267
|
+
/**
|
|
268
|
+
* Checks that `value` is a valid `CommentEditRecord`. Throws a `ModelError`
|
|
269
|
+
* with code `INVALID_SCHEMA` that names the first problem and its path
|
|
270
|
+
* otherwise.
|
|
271
|
+
* @since 0.32.0
|
|
272
|
+
*/
|
|
273
|
+
export declare function assertCommentEditRecord(value: unknown): asserts value is CommentEditRecord;
|
|
274
|
+
/**
|
|
275
|
+
* Checks that `value` is a valid `CommentThread`. Throws a `ModelError` with
|
|
276
|
+
* code `INVALID_SCHEMA` that names the first problem and its path otherwise.
|
|
277
|
+
* The page and the attached layer are not looked up.
|
|
278
|
+
* @since 0.31.0
|
|
279
|
+
*/
|
|
280
|
+
export declare function assertCommentThread(value: unknown): asserts value is CommentThread;
|
|
281
|
+
/**
|
|
282
|
+
* Checks that `value` is a valid `CommentMessage`. Throws a `ModelError`
|
|
283
|
+
* with code `INVALID_SCHEMA` otherwise.
|
|
284
|
+
* @since 0.31.0
|
|
285
|
+
*/
|
|
286
|
+
export declare function assertCommentMessage(value: unknown): asserts value is CommentMessage;
|
|
287
|
+
/**
|
|
288
|
+
* Checks that `value` is a valid `CommentThreadDigest`. Throws a
|
|
289
|
+
* `ModelError` with code `INVALID_SCHEMA` otherwise.
|
|
290
|
+
* @since 0.31.0
|
|
291
|
+
*/
|
|
292
|
+
export declare function assertCommentThreadDigest(value: unknown): asserts value is CommentThreadDigest;
|
|
293
|
+
/**
|
|
294
|
+
* Checks that `value` is a valid document. A document already known to be
|
|
295
|
+
* valid and frozen (`fullyValidatedDocuments`) is not checked again.
|
|
296
|
+
*/
|
|
297
|
+
export declare function assertDocument(value: unknown): asserts value is DesignDocument;
|
|
298
|
+
/**
|
|
299
|
+
* Validates a document produced by editing an already valid one. The shape of
|
|
300
|
+
* the changed entities is checked, and every rule that spans entities — the
|
|
301
|
+
* node tree, page order, sections, and references — is checked in full.
|
|
302
|
+
*/
|
|
303
|
+
export declare function assertChangedDocument(value: unknown, changed: ChangedDocumentEntities): asserts value is DesignDocument;
|
|
304
|
+
/**
|
|
305
|
+
* Serializes a JSON value with object keys sorted, so equal values give equal
|
|
306
|
+
* text. Throws a `ModelError` if `value` is not plain JSON (for example
|
|
307
|
+
* `undefined`, `NaN`, or a class instance).
|
|
308
|
+
*/
|
|
309
|
+
export declare function canonicalJson(value: unknown, indentation?: number): string;
|
|
310
|
+
/**
|
|
311
|
+
* Freezes a value and everything it contains.
|
|
312
|
+
*
|
|
313
|
+
* A frozen object is treated as already frozen all the way down, because this
|
|
314
|
+
* package only ever freezes values through this function. Without that rule,
|
|
315
|
+
* re-freezing a document would walk every node on every edit.
|
|
316
|
+
*/
|
|
317
|
+
export declare function deepFreeze<Value>(value: Value): Readonly<Value>;
|
|
318
|
+
/**
|
|
319
|
+
* Deep-copies a plain JSON value. Throws a `ModelError` if it is not plain
|
|
320
|
+
* JSON. A shared node table (`sharedTableDraft`) anywhere in it, such as the
|
|
321
|
+
* `nodes` of a document or of a document inside a record, which
|
|
322
|
+
* `structuredClone` cannot copy, is copied as a plain table.
|
|
323
|
+
*/
|
|
324
|
+
export declare function cloneJson<Value>(value: Value): Value;
|
|
325
|
+
/**
|
|
326
|
+
* One step that upgrades a document from one schema version to the next.
|
|
327
|
+
* Register steps in a `MigrationRegistry`.
|
|
328
|
+
*/
|
|
329
|
+
export interface DocumentMigration {
|
|
330
|
+
/** The version this step reads. Only one step may start at a version. */
|
|
331
|
+
readonly from: DocumentSchemaVersion;
|
|
332
|
+
/**
|
|
333
|
+
* The version this step writes: `from + 1` for a legacy number, `"0.0.0"`
|
|
334
|
+
* from legacy version 1, or a later semantic version.
|
|
335
|
+
*/
|
|
336
|
+
readonly to: DocumentSchemaVersion;
|
|
337
|
+
/**
|
|
338
|
+
* Set when every document of `from` is already a valid document of `to`,
|
|
339
|
+
* so the step only changes `schemaVersion`. The registry then writes the
|
|
340
|
+
* new version on a shallow copy of the top record itself, without copying
|
|
341
|
+
* the document, calling `migrate`, or checking the document again.
|
|
342
|
+
*/
|
|
343
|
+
readonly versionOnly?: boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Returns the upgraded document as plain JSON, with `schemaVersion` set to
|
|
346
|
+
* `to`. The input is a private copy, so changing it in place is fine.
|
|
347
|
+
*/
|
|
348
|
+
migrate(input: unknown): unknown;
|
|
349
|
+
/**
|
|
350
|
+
* Carries one stored operation across the same version step.
|
|
351
|
+
*
|
|
352
|
+
* Stored history keeps whole nodes, pages, themes, and assets inside its
|
|
353
|
+
* operations, so a change to any of those shapes leaves the recorded
|
|
354
|
+
* operations behind. Provide this whenever `migrate` rewrites something an
|
|
355
|
+
* operation can carry, and leave it out when the change is only about a
|
|
356
|
+
* document-level field that no operation contains.
|
|
357
|
+
*
|
|
358
|
+
* The operation is given as plain JSON. Returning it unchanged is fine, and
|
|
359
|
+
* returning something that no longer changes the document is fine too: the
|
|
360
|
+
* commit is dropped while its children keep their place in history.
|
|
361
|
+
*/
|
|
362
|
+
migrateOperation?(operation: unknown): unknown;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* An ordered chain of `DocumentMigration` steps. `deserializeDocument` and
|
|
366
|
+
* `deserializeStore` use `defaultMigrations` unless given another registry.
|
|
367
|
+
*/
|
|
368
|
+
export declare class MigrationRegistry {
|
|
369
|
+
#private;
|
|
370
|
+
constructor(migrations?: readonly DocumentMigration[]);
|
|
371
|
+
/**
|
|
372
|
+
* Adds a step and returns the registry. Throws a `ModelError` with code
|
|
373
|
+
* `INVALID_SCHEMA` if the step does not move forward as `DocumentMigration.to`
|
|
374
|
+
* describes, or if a step from the same version is already registered.
|
|
375
|
+
*/
|
|
376
|
+
register(migration: DocumentMigration): this;
|
|
377
|
+
/**
|
|
378
|
+
* Carries one stored operation from the version it was recorded under to the
|
|
379
|
+
* current one, using the same ordered steps as documents. Steps without
|
|
380
|
+
* `migrateOperation` pass the operation through. Returns `null` when a step
|
|
381
|
+
* returns `null`.
|
|
382
|
+
*/
|
|
383
|
+
migrateOperation(operation: unknown, from: DocumentSchemaVersion, target?: DocumentSchemaVersion): unknown;
|
|
384
|
+
/**
|
|
385
|
+
* Runs the steps from the input's `schemaVersion` up to `target` and
|
|
386
|
+
* returns the result as plain JSON. It does not validate the result.
|
|
387
|
+
* The input is not changed. A version-only step (`versionOnly`) copies
|
|
388
|
+
* only the top record, so a result reached through such steps alone
|
|
389
|
+
* shares everything else, such as the node table, with the input.
|
|
390
|
+
*
|
|
391
|
+
* Throws a `ModelError`: `UNSUPPORTED_VERSION` when the input is newer than
|
|
392
|
+
* `target`, `MISSING_MIGRATION` when no step starts at a version on the way,
|
|
393
|
+
* and `MIGRATION_FAILED` when a step throws or writes the wrong version.
|
|
394
|
+
*/
|
|
395
|
+
migrate(input: unknown, target?: DocumentSchemaVersion): unknown;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* The stored node IDs in `nodeIds` whose 0.23.0 rename needs a collision
|
|
399
|
+
* suffix, because their plain "_" form is already taken. Operation
|
|
400
|
+
* migration cannot see those suffixes, so a stored history whose root
|
|
401
|
+
* document has one is ambiguous.
|
|
402
|
+
*/
|
|
403
|
+
export declare function nodeIdsRenamedWithSuffix(nodeIds: readonly string[]): string[];
|
|
404
|
+
/**
|
|
405
|
+
* The migrations this package ships: one step per schema version, from
|
|
406
|
+
* legacy version 1 through `0.0.0` and every later version up to
|
|
407
|
+
* `CURRENT_DOCUMENT_SCHEMA_VERSION`. Data saved at a version with no step
|
|
408
|
+
* fails with `MISSING_MIGRATION`.
|
|
409
|
+
*/
|
|
410
|
+
export declare const defaultMigrations: MigrationRegistry;
|
|
411
|
+
/**
|
|
412
|
+
* Loads a document from a JSON string or an already parsed value.
|
|
413
|
+
*
|
|
414
|
+
* Runs `migrations` up to `CURRENT_DOCUMENT_SCHEMA_VERSION`, validates the
|
|
415
|
+
* result with `assertDocument`, refits every group to its children (which
|
|
416
|
+
* repairs files saved with a stale group size), and returns a deeply frozen
|
|
417
|
+
* copy. The input is not changed.
|
|
418
|
+
*
|
|
419
|
+
* Throws a `ModelError`: `INVALID_JSON` for a string that does not parse,
|
|
420
|
+
* a migration error code (see `MigrationRegistry.migrate`), or a validation
|
|
421
|
+
* error.
|
|
422
|
+
*/
|
|
423
|
+
export declare function deserializeDocument(input: string | unknown, migrations?: MigrationRegistry): DesignDocument;
|
|
424
|
+
/**
|
|
425
|
+
* Whether `copy`, a document `deserializeDocument` or `snapshotDocument`
|
|
426
|
+
* returned for `original`, holds what `original` held when it was copied: no
|
|
427
|
+
* migration, renamed connector end or refitted group changed it. It answers
|
|
428
|
+
* without reading either document, so it stands in for comparing their
|
|
429
|
+
* `canonicalJson`. False when the copy was rewritten, was made from text, or
|
|
430
|
+
* was not made from `original`; a false answer says nothing about whether the
|
|
431
|
+
* two are equal.
|
|
432
|
+
*/
|
|
433
|
+
export declare function isUnchangedCopyOf(copy: DesignDocument, original: unknown): boolean;
|
|
434
|
+
/**
|
|
435
|
+
* Validates `document` with `assertDocument` and writes it as JSON with
|
|
436
|
+
* sorted keys, so the same document always gives the same text.
|
|
437
|
+
* `indentation` is passed to `JSON.stringify`; 0 writes one line.
|
|
438
|
+
*/
|
|
439
|
+
export declare function serializeDocument(document: DesignDocument, indentation?: number): string;
|
|
440
|
+
/**
|
|
441
|
+
* Returns a validated, deeply frozen copy of a document. The same as
|
|
442
|
+
* `deserializeDocument` with the default migrations.
|
|
443
|
+
*/
|
|
444
|
+
export declare function snapshotDocument(input: DesignDocument | unknown): DesignDocument;
|