From 62432d73bc876a9bee4456a1a8f93c7e102c8c4d Mon Sep 17 00:00:00 2001 From: Dion Amago Date: Fri, 29 Nov 2024 16:16:20 -0800 Subject: [PATCH] Do not throw if there is no version key, assume it is an old version where that was not required --- app/libs/package.json | 2 +- app/libs/src/metapage/conversions-metaframe.ts | 6 +++++- app/libs/src/metapage/conversions-metapage.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/libs/package.json b/app/libs/package.json index f61ec2e..4244af0 100644 --- a/app/libs/package.json +++ b/app/libs/package.json @@ -1,7 +1,7 @@ { "name": "@metapages/metapage", "public": true, - "version": "1.4.2", + "version": "1.4.3", "description": "Connect web pages together", "repository": "https://github.com/metapages/metapage", "homepage": "https://metapage.io/", diff --git a/app/libs/src/metapage/conversions-metaframe.ts b/app/libs/src/metapage/conversions-metaframe.ts index 58ccb95..b24313d 100644 --- a/app/libs/src/metapage/conversions-metaframe.ts +++ b/app/libs/src/metapage/conversions-metaframe.ts @@ -76,7 +76,11 @@ const convertMetaframeDefinitionToTargetVersionInternal = ( } if (!def.version) { - throw 'Missing "version" key in metaframe definition'; + // we assume this is an older version of the definition + // that does not have the version key + def = create(def, (draft :MetaframeDefinitionV03) => { + draft.version = "0.3"; + }) as MetaframeDefinitionV6; } let currentVersion = getMatchingMetaframeVersion(def.version); diff --git a/app/libs/src/metapage/conversions-metapage.ts b/app/libs/src/metapage/conversions-metapage.ts index 5d7998b..82c4510 100644 --- a/app/libs/src/metapage/conversions-metapage.ts +++ b/app/libs/src/metapage/conversions-metapage.ts @@ -23,7 +23,9 @@ export const convertMetapageDefinitionToVersion = async ( } if (!def.version) { - throw 'Missing "version" key in metapage definition'; + def = create(def, (draft :MetapageDefinitionV03) => { + draft.version = "0.3"; + }) as MetapageDefinitionV03; } if (!targetVersion) { throw 'Missing "version" argument';