From 2d515aaa5791ee354b434d8c33005b257a0ae7cb Mon Sep 17 00:00:00 2001 From: Egor Mikhnevich Date: Mon, 8 Aug 2022 13:20:01 +0300 Subject: [PATCH] Add per-document libraries info --- .changeset/popular-laws-fry.md | 6 ++++++ .../schema/abstract-document.schema.yaml | 3 +++ .../enums/document-library-type.schema.yaml | 13 +++++++++++++ .../objects/document-library-info.schema.yaml | 18 ++++++++++++++++++ packages/file/src/__tests__/file.test.ts | 1 + 5 files changed, 41 insertions(+) create mode 100644 .changeset/popular-laws-fry.md create mode 100644 packages/file-format/schema/enums/document-library-type.schema.yaml create mode 100644 packages/file-format/schema/objects/document-library-info.schema.yaml diff --git a/.changeset/popular-laws-fry.md b/.changeset/popular-laws-fry.md new file mode 100644 index 0000000..819cbdd --- /dev/null +++ b/.changeset/popular-laws-fry.md @@ -0,0 +1,6 @@ +--- +'@sketch-hq/sketch-file-format': minor +'@sketch-hq/sketch-file-format-ts': minor +--- + +Add per-document libraries info diff --git a/packages/file-format/schema/abstract-document.schema.yaml b/packages/file-format/schema/abstract-document.schema.yaml index 7d1fffd..0d9de70 100644 --- a/packages/file-format/schema/abstract-document.schema.yaml +++ b/packages/file-format/schema/abstract-document.schema.yaml @@ -35,3 +35,6 @@ properties: items: { $ref: ./objects/font-ref.schema.yaml } documentState: { $ref: ./objects/document-state.schema.yaml } patchInfo: { $ref: ./objects/patch-info.schema.yaml } + perDocumentLibraries: + type: array + items: { $ref: ./objects/document-library-info.schema.yaml } diff --git a/packages/file-format/schema/enums/document-library-type.schema.yaml b/packages/file-format/schema/enums/document-library-type.schema.yaml new file mode 100644 index 0000000..83879a4 --- /dev/null +++ b/packages/file-format/schema/enums/document-library-type.schema.yaml @@ -0,0 +1,13 @@ +title: Document Library Type +description: + Enumeration of the asset library type. Roughly represents all library types + from Preferences... > Libraries tab +type: integer +enum: + - 0 + - 1 + - 2 +enumDescriptions: + - Local + - Workspace + - Third-Party diff --git a/packages/file-format/schema/objects/document-library-info.schema.yaml b/packages/file-format/schema/objects/document-library-info.schema.yaml new file mode 100644 index 0000000..e9ff23a --- /dev/null +++ b/packages/file-format/schema/objects/document-library-info.schema.yaml @@ -0,0 +1,18 @@ +title: Document Library Info +description: + Represents a "reference" to the asset library, that is used in the document +type: object +optional: + - name + - appcastURL + - documentID + - shareID + - workspaceName +properties: + _class: { const: MSImmutableDocumentLibraryInfo } + libraryType: { $ref: ../enums/document-library-type.schema.yaml } + name: { type: string } + appcastURL: { type: string } + documentID: { $ref: ./utils/uuid.schema.yaml } + shareID: { $ref: ./utils/uuid.schema.yaml } + workspaceName: { type: string } diff --git a/packages/file/src/__tests__/file.test.ts b/packages/file/src/__tests__/file.test.ts index 470e6d3..fab6449 100644 --- a/packages/file/src/__tests__/file.test.ts +++ b/packages/file/src/__tests__/file.test.ts @@ -86,6 +86,7 @@ describe('toFile', () => { do_objectID: 'b08e8447-b31d-4901-abb7-8284e1f71113', }, pages: [blankPage], + perDocumentLibraries: [] }, meta: { app: FileFormat.BundleId.Testing,