From 684df40bf12826dcb008dbc8b408c8a17d65ebb0 Mon Sep 17 00:00:00 2001 From: EMaslowskiQ <118929649+EMaslowskiQ@users.noreply.github.com> Date: Thu, 25 Jan 2024 00:39:21 -0500 Subject: [PATCH] (fix) updating Voyager parsing/validation of scenes to support modern (#569) Updated Voyager parser and validation to support modern features and properties. --- server/types/voyager/DocumentValidator.ts | 32 ++++++++++----------- server/types/voyager/common.ts | 9 +++--- server/types/voyager/document.ts | 3 +- server/types/voyager/json/model.schema.json | 13 +++++++++ server/types/voyager/meta.ts | 7 +++-- server/types/voyager/model.ts | 6 ++-- server/types/voyager/setup.ts | 10 ++++--- 7 files changed, 49 insertions(+), 31 deletions(-) diff --git a/server/types/voyager/DocumentValidator.ts b/server/types/voyager/DocumentValidator.ts index 798f54acf..8577ac1a7 100644 --- a/server/types/voyager/DocumentValidator.ts +++ b/server/types/voyager/DocumentValidator.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/brace-style */ /** * 3D Foundation Project * Copyright 2019 Smithsonian Institution @@ -16,13 +15,13 @@ * limitations under the License. */ -import ajv from 'ajv'; +import AjvCore from 'ajv'; -import * as documentSchema from './json/document.schema.json'; -import * as commonSchema from './json/common.schema.json'; -import * as metaSchema from './json/meta.schema.json'; -import * as modelSchema from './json/model.schema.json'; -import * as setupSchema from './json/setup.schema.json'; +import documentSchema from './json/document.schema.json'; +import commonSchema from './json/common.schema.json'; +import metaSchema from './json/meta.schema.json'; +import modelSchema from './json/model.schema.json'; +import setupSchema from './json/setup.schema.json'; import { IDocument } from './document'; @@ -31,14 +30,12 @@ import * as H from '../../utils/helpers'; //////////////////////////////////////////////////////////////////////////////// -export class DocumentValidator -{ - private _schemaValidator: ajv.Ajv; - private _validateDocument: ajv.ValidateFunction; +export class DocumentValidator { + private _schemaValidator; + private _validateDocument; - constructor() - { - this._schemaValidator = new ajv({ + constructor() { + this._schemaValidator = new AjvCore({ schemas: [ documentSchema, commonSchema, @@ -54,14 +51,17 @@ export class DocumentValidator ); } - validate(document: IDocument): H.IOResults - { + validate(document: IDocument): H.IOResults { if (!this._validateDocument(document)) { const error: string = this._schemaValidator.errorsText(this._validateDocument.errors, { separator: ', ', dataVar: 'document' }); LOG.error(error, LOG.LS.eSYS); return { success: false, error }; } + // if (ENV_DEVELOPMENT) { + // console.log('JSONValidator.validateDocument - OK'); + // } + return { success: true }; } } \ No newline at end of file diff --git a/server/types/voyager/common.ts b/server/types/voyager/common.ts index 99e0961c4..6ece81afe 100644 --- a/server/types/voyager/common.ts +++ b/server/types/voyager/common.ts @@ -1,11 +1,10 @@ /* eslint-disable quotes, @typescript-eslint/brace-style */ /** * NOTE: this file is part of the definition of a Voyager scene, found in a .svx.json file. - * This was imported from Voyager's source/client/schema on 1/27/2023. It was then modified, + * This was imported from Voyager's source/client/schema on 1/24/2024. It was then modified, * minimally, to allow for use by Packrat. Ideally, in the future, we will extract out the * definition of this shared file format for use by both projects. */ - /** * 3D Foundation Project * Copyright 2019 Smithsonian Institution @@ -33,13 +32,15 @@ export type Quaternion = Vector4; export type ColorRGB = Vector3; export type ColorRGBA = Vector4; -export type TLanguageType = "EN" | "ES" | "DE" | "NL" | "JA"; -export enum ELanguageType { EN, ES, DE, NL, JA } +export type TLanguageType = "EN" | "ES" | "DE" | "NL" | "JA" | "FR" | "HAW"; +export enum ELanguageType { EN, ES, DE, NL, JA, FR, HAW } export enum ELanguageStringType { EN = 'English', ES = 'Spanish (Español)', DE = 'German (Deutsche)', NL = 'Dutch (Nederlands)', JA = 'Japanese (日本語)', + FR = 'French (Français)', + HAW = 'Hawaiian (ʻŌlelo Hawaiʻi)', } export const DEFAULT_LANGUAGE = "EN"; diff --git a/server/types/voyager/document.ts b/server/types/voyager/document.ts index 96331fe0a..5ce89adc4 100644 --- a/server/types/voyager/document.ts +++ b/server/types/voyager/document.ts @@ -1,11 +1,10 @@ /* eslint-disable quotes, @typescript-eslint/brace-style */ /** * NOTE: this file is part of the definition of a Voyager scene, found in a .svx.json file. - * This was imported from Voyager's source/client/schema on 1/27/2023. It was then modified, + * This was imported from Voyager's source/client/schema on 1/24/2024. It was then modified, * minimally, to allow for use by Packrat. Ideally, in the future, we will extract out the * definition of this shared file format for use by both projects. */ - /** * 3D Foundation Project * Copyright 2019 Smithsonian Institution diff --git a/server/types/voyager/json/model.schema.json b/server/types/voyager/json/model.schema.json index 1117d10a3..0af3f951e 100644 --- a/server/types/voyager/json/model.schema.json +++ b/server/types/voyager/json/model.schema.json @@ -52,6 +52,19 @@ "type": "string", "minLength": 1 }, + "imageCredit": { + "description": "Credit line image in this annotation with language key.", + "type": "object" + }, + "imageAltText": { + "description": "Alt text for image in this annotation with language key", + "type": "object" + }, + "audioId": { + "description": "Id of an audio resource for this annotation.", + "type": "string", + "minLength": 1 + }, "style": { "type": "string" }, diff --git a/server/types/voyager/meta.ts b/server/types/voyager/meta.ts index f980eba27..b41d2c9ad 100644 --- a/server/types/voyager/meta.ts +++ b/server/types/voyager/meta.ts @@ -1,11 +1,10 @@ -/* eslint-disable quotes, @typescript-eslint/brace-style, @typescript-eslint/no-explicit-any */ +/* eslint-disable quotes, @typescript-eslint/brace-style */ /** * NOTE: this file is part of the definition of a Voyager scene, found in a .svx.json file. - * This was imported from Voyager's source/client/schema on 1/27/2023. It was then modified, + * This was imported from Voyager's source/client/schema on 1/24/2024. It was then modified, * minimally, to allow for use by Packrat. Ideally, in the future, we will extract out the * definition of this shared file format for use by both projects. */ - /** * 3D Foundation Project * Copyright 2019 Smithsonian Institution @@ -92,4 +91,6 @@ export interface IAudioClip id: string; name: string; uris: Dictionary; + captionUris: Dictionary; + durations: Dictionary; } \ No newline at end of file diff --git a/server/types/voyager/model.ts b/server/types/voyager/model.ts index a5abfd46c..7941041c7 100644 --- a/server/types/voyager/model.ts +++ b/server/types/voyager/model.ts @@ -1,11 +1,10 @@ /* eslint-disable quotes, @typescript-eslint/brace-style */ /** * NOTE: this file is part of the definition of a Voyager scene, found in a .svx.json file. - * This was imported from Voyager's source/client/schema on 1/27/2023. It was then modified, + * This was imported from Voyager's source/client/schema on 1/24/2024. It was then modified, * minimally, to allow for use by Packrat. Ideally, in the future, we will extract out the * definition of this shared file format for use by both projects. */ - /** * 3D Foundation Project * Copyright 2019 Smithsonian Institution @@ -84,6 +83,9 @@ export interface IAnnotation taglist?: Dictionary; articleId?: string; imageUri?: string; + imageCredit?: Dictionary; + imageAltText?: Dictionary; + audioId?: string; style?: string; visible?: boolean; diff --git a/server/types/voyager/setup.ts b/server/types/voyager/setup.ts index 5d43ca642..73a460032 100644 --- a/server/types/voyager/setup.ts +++ b/server/types/voyager/setup.ts @@ -1,12 +1,11 @@ -/* eslint-disable quotes, @typescript-eslint/brace-style, @typescript-eslint/no-explicit-any */ +/* eslint-disable quotes, @typescript-eslint/brace-style */ /** * NOTE: this file is part of the definition of a Voyager scene, found in a .svx.json file. - * This was imported from Voyager's source/client/schema on 1/27/2023. It was then modified, + * This was imported from Voyager's source/client/schema on 1/24/2024. It was then modified, * minimally, to allow for use by Packrat. Ideally, in the future, we will extract out the * definition of this shared file format for use by both projects. */ - -// import { Dictionary } from "@ff/core/types"; +//import { Dictionary } from "@ff/core/types"; type Dictionary = Record; import { ELanguageType, TLanguageType } from "./common"; @@ -74,6 +73,8 @@ export interface IViewer exposure: number; toneMapping: boolean; gamma: number; + isWallMountAR: boolean; + arScale: number; annotationsVisible?: boolean; activeTags?: string; sortedTags?: string; @@ -169,6 +170,7 @@ export interface ISlicer axis: TSliceAxis; inverted: boolean; position: number; + color: number[]; } export type ITours = ITour[];