@manifest-editor/creator-api 2.1.1-next.0.96fdf30 → 2.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/dist/index.cjs CHANGED
@@ -1 +1,2 @@
1
- let e=require(`@iiif/helpers/vault`),t=require(`@iiif/helpers/vault/actions`),n=require(`react-iiif-vault`),r=require(`@iiif/parser`),i=require(`@manifest-editor/editor-api`);function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class{constructor(e,t){c(this,`vault`,void 0),c(this,`original`,void 0),c(this,`reference`,void 0),c(this,`resource`,void 0),this.vault=t,this.original=e,this.reference=(0,r.isSpecificResource)(e)?e.source:e,this.resource=(0,r.isSpecificResource)(e)?e:{type:`SpecificResource`,source:this.reference}}ref(){return this.reference}specificResource(){return this.resource}optionalSpecificResource(){return(0,r.isSpecificResource)(this.original)?{...this.original,source:{id:this.original.source?.id,type:this.original.source?.type}}:this.original}get(){return this.vault.get(this.resource)}};function u(e){switch(e){case`Image`:case`Video`:case`Sound`:case`Dataset`:case`Text`:case`TextualBody`:case`Composite`:case`List`:case`Choice`:case`Independents`:case`Audience`:return`ContentResource`;case`ImageService1`:case`ImageService2`:case`ImageService3`:return`Service`}return e}const d={Annotation:r.emptyAnnotation,AnnotationPage:r.emptyAnnotationPage,Canvas:r.emptyCanvas,Collection:r.emptyCollection,Manifest:r.emptyManifest,Range:r.emptyRange,ResourceProvider:r.emptyAgent,Service:r.emptyService};function f(e){return d[u(e)]||{}}function p(){return`${Math.random().toString(36).substring(2)}-${Date.now().toString(36)}`}function m(e,t,n){let i=[];if(t.length===0)return[];let a=(0,r.toRef)(e.parent),o=e.property,s=e.filter;for(let r of t)if(!(s&&(!r.tags||!r.tags.includes(s)))&&a&&o){if(r.supports.parentTypes&&!r.supports.parentTypes.includes(a.type)||r.supports.parentFields&&!r.supports.parentFields.includes(o))continue;if(r.supports.parentFieldMap){let e=r.supports.parentFieldMap[a.type];if(!e||!e.includes(o))continue}if(r.supports.disallowPainting&&e.isPainting||r.supports.onlyPainting&&!e.isPainting||r.supports.custom&&!r.supports.custom({property:o,resource:a,atIndex:e.index},n.vault))continue;let t=Object.keys(e.initialData||{}).filter(e=>e!==`skipEditingOnCreate`);if(!r.supports.initialData&&t.length!==0||r.resourceType!==e.type&&!(r.additionalTypes||[]).includes(e.type))continue;i.push(r)}return i}function h(e,t,n,r){return(i,a={})=>(typeof t!=`string`&&(a.parent={property:n,resource:t,atIndex:a?.parent?.atIndex}),e.create(r,i,a))}var g=class e{constructor(t,n){c(this,`resource`,void 0),c(this,`warnings`,[]),c(this,`errors`,[]),c(this,`partOf`,void 0),c(this,`references`,[]),c(this,`embedded`,[]),c(this,`vault`,void 0),c(this,`specificResource`,void 0),this.vault=n;let r={...t};if(r.type===`SpecificResource`){let e=r.source;this.specificResource={...r,source:{id:e.id,type:u(e.type)}},r=e}let a=Object.keys(r),o=f(r.type);for(let t of a)if(!(i.references.inlineProperties.includes(t)||!i.references.all.includes(t))){if(r.type===`Range`&&t===`items`){let e=[];for(let i of r[t]){if(i instanceof l){this.references.push(i),e.push(i);continue}let a=new l(i,n);e.push(a),r[t]=a}r[t]=e;continue}if(r.type===`Manifest`&&t===`start`){let e=r[t];if(e instanceof l){this.references.push(e);continue}r[t]=new l(e,n);continue}if(r.type===`Annotation`&&t===`target`){let e=r[t];if(e instanceof l){this.references.push(e);continue}typeof e==`string`&&(e={id:e,type:`Canvas`}),r[t]=new l(e,n);continue}if(!i.references.single.includes(t)&&(i.references.externalProperties.includes(t)||i.references.internalProperties.includes(t))){let i=r[t]||[],a=Array.isArray(i)?i:[i],o=[];for(let t of a){if(t instanceof l){this.references.push(t),o.push(t);continue}if(t instanceof e){this.embedded.push(t),o.push(t);continue}if(this.vault.get(t,{skipSelfReturn:!0})){let e=u(t.type),r=new l({id:t.id,type:e},n);this.references.push(r),o.push(r)}else{let r=new e(t,n);this.embedded.push(r),o.push(r)}}r[t]=o}}this.resource={...o,...r}}get(){return this.resource}getSpecificResource(){let e=this.ref();return(0,r.isSpecificResource)(e)?e:{type:`SpecificResource`,source:e}}ref(){return this.specificResource?this.specificResource:{id:this.resource.id,type:u(this.resource.type)}}getAllReferencedResources(){return this.references}getAllEmbeddedResources(){let e=[];for(let t of this.embedded)e.push(...t.getAllEmbeddedResources());return e.push(...this.embedded),e}getVaultResource(){let t=this.resource,n=Object.keys(t),a={};for(let r of n){if(i.references.inlineProperties.includes(r)||!i.references.all.includes(r)){a[r]=t[r];continue}if(i.references.single.includes(r)){let e=t[r];e instanceof l?t.type===`Manifest`&&r===`start`||t.type===`Annotation`&&r===`target`?a[r]=e.specificResource():a[r]=e.optionalSpecificResource():a[r]=t[r];continue}if(t[r]){a[r]=[];for(let n of t[r]||[]){if(t.type===`Range`&&r===`items`){n instanceof l&&(n.ref().type===`Canvas`?a[r].push(n.specificResource()):a[r].push(n.ref())),n instanceof e&&(n.ref().type===`Canvas`?a[r].push(n.getSpecificResource()):a[r].push(n.ref()));continue}n instanceof l&&a[r].push(n.optionalSpecificResource()),n instanceof e&&a[r].push(n.ref())}}}return this.partOf&&(a[r.HAS_PART]=a[r.HAS_PART]||[],a[r.HAS_PART].push(this.partOf)),a}setPartOf(e){let t=this.ref();this.partOf={id:t.id,type:u(t.type),[r.PART_OF]:e}}},_=class{constructor(e,t,r,i){c(this,`vault`,void 0),c(this,`previewVault`,void 0),c(this,`configs`,void 0),c(this,`options`,void 0),c(this,`target`,void 0),c(this,`selector`,void 0),c(this,`serialisedSelector`,null),this.vault=e,this.previewVault=i,this.options=t,this.configs=r,this.target=this.options.target||this.options.parent?.resource;let a=this.options.initialData?.selector;this.selector=a?(0,n.annotationResponseToSelector)(a):null,this.options.initialData?.getSerialisedSelector&&(this.serialisedSelector=this.options.initialData.getSerialisedSelector())}getPreviewVault(){return this.previewVault}setSelector(e){this.selector=e}getSerialisedSelector(){if(this.serialisedSelector)return this.serialisedSelector;let e=this.selector;if(e){let t=(0,n.seraliseSupportedSelector)(e,this.options.initialData?.on);if(t)return t}return null}getTarget(){let e=this.target,t=this.getSerialisedSelector();return t?{type:`SpecificResource`,source:e,selector:t}:e}getParent(){return this.options.parent?.resource}getParentResource(){let e=this.getParent();if(e)return{type:`SpecificResource`,source:e}}generateId(e,t){return t&&t instanceof l&&(t=t.ref()),this.options.rootId&&(t={id:this.options.rootId,type:`none`}),`${(t||this.options.parent?.resource)?.id}/${e}/${p()}`}ref(e){let t=``,n=``;return typeof e==`string`?t=e:(t=e.id,n=e.type),n=this.vault.getState().iiif.mapping[t]||n||`unknown`,new l({id:t,type:n},this.vault)}embed(e){return new g(e,this.vault)}async create(e,t,n){let r=this.configs.find(t=>t.id===e);if(!r)throw Error(`Creator config ${e} not found`);return await new v(this.vault,r,t,this.configs,this.previewVault,n).run()}},v=class{constructor(e,t,n,r,i,a){c(this,`resource`,null),c(this,`payload`,void 0),c(this,`vault`,void 0),c(this,`previewVault`,void 0),c(this,`definition`,void 0),c(this,`options`,void 0),c(this,`configs`,void 0),this.vault=e,this.previewVault=i,this.definition=t,this.payload=n,this.configs=this.filterCreateConfigs(r),this.options={targetType:a?.targetType||t.resourceType,...a||{}}}filterCreateConfigs(e){let t={};for(let n of e)t[n.id]=n;return Object.values(t)}async run(){let e=new _(this.vault,this.options,this.configs,this.previewVault),t=await this.definition.create(this.payload,e);if(Array.isArray(t)){let e=[];for(let n of t)n instanceof g?e.push(n):e.push(new g(n,this.vault));return this.resource=e,this.resource}return t instanceof g?this.resource=t:this.resource=new g(t,this.vault),this.resource}getActions(){if(!this.resource)return[];let e=Array.isArray(this.resource)?this.resource:[this.resource],n=[],r={},i={};for(let a of e){this.options.parent&&a.setPartOf(this.options.parent.resource.id);let e=[...a.getAllEmbeddedResources(),a];for(let t of e){let e=t.getVaultResource();if(!e.type||!e.id)continue;let n=u(e.type);r[n]=r[n]?r[n]:{},r[n][e.id]=e,i[e.id]=n}n.push((0,t.importEntities)({entities:r})),n.push((0,t.addMappings)({mapping:i}))}return n}commit(e=[]){if(!this.resource)throw Error(`Creator has not been run`);let n=this.getActions();return this.vault.dispatch((0,t.batchActions)({actions:[...n,...e]})),Array.isArray(this.resource)?this.resource.map(e=>e.ref()):this.resource.ref()}},y=class{constructor(t,n,r){c(this,`configs`,void 0),c(this,`vault`,void 0),c(this,`previewVault`,void 0),this.configs=n||[],this.vault=t,this.previewVault=r||new e.Vault}matchBasedOnResource(e){return m(e,this.configs||[],{vault:this.vault})}async create(e,n,r){let i=this.configs.find(t=>t.id===e);if(!i)throw Error(`Creator config ${e} not found`);if(r?.parent){if(i.supports.parentTypes&&!i.supports.parentTypes.includes(r.parent.resource.type))throw Error(`Definition ${e} does not support parent type ${r.parent.resource.type}`);if(i.supports.parentFields&&!i.supports.parentFields.includes(r.parent.property))throw Error(`Definition ${e} does not support parent field ${r.parent.property}`);if(i.supports.parentFieldMap){let t=i.supports.parentFieldMap[r.parent.resource.type];if(!t||!t.includes(r.parent.property))throw Error(`Definition ${e} does not support parent ${r.parent.property} / ${r.parent.property}`)}if(i.supports.custom&&!i.supports.custom(r.parent,this.vault))throw Error(`Definition does not support resource`)}let a=new v(this.vault,i,n,this.configs,this.previewVault,r),o=await a.run(),s=Array.isArray(o)?o:[o],c=[];for(let e of s)r?.parent&&(r.parent.property===`start`||r.parent.property===`target`?c.push(t.entityActions.modifyEntityField({id:r.parent.resource.id,type:r.parent.resource.type,value:e.ref(),key:r.parent.property})):c.push(t.entityActions.addReference({id:r.parent.resource.id,type:r.parent.resource.type,reference:e.ref(),key:r.parent.property,index:r.parent.atIndex})));let l=a.commit(c);if(r?.parent&&i.sideEffects){for(let e of i.sideEffects)if(e.run){let t=Array.isArray(l)?l:[l];for(let n of t)await e.run(n,{vault:this.vault,options:r})}}return l}};function b(e){return e}function x(e,t,n={}){let r=e.render?r=>{let i={...r,options:{...r.options||{},initialData:{...t||{},...r.options?.initialData||{},...n||{}}}};return e.render?.(i)}:void 0;return{...e,render:r}}function S(e,t){let n=n=>t(n,e.render);return{...e,render:n}}exports.Creator=y,exports.CreatorResource=g,exports.creatorHelper=h,exports.defineCreator=b,exports.getEmptyType=f,exports.matchBasedOnResource=m,exports.randomId=p,exports.resolveType=u,exports.withCustomRender=S,exports.withInitialData=x;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@iiif/helpers/vault"),t=require("@iiif/helpers/vault/actions"),n=require("react-iiif-vault"),r=require("@iiif/parser"),i=require("@manifest-editor/editor-api");function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class{constructor(e,t){c(this,`vault`,void 0),c(this,`original`,void 0),c(this,`reference`,void 0),c(this,`resource`,void 0),this.vault=t,this.original=e,this.reference=(0,r.isSpecificResource)(e)?e.source:e,this.resource=(0,r.isSpecificResource)(e)?e:{type:`SpecificResource`,source:this.reference}}ref(){return this.reference}specificResource(){return this.resource}optionalSpecificResource(){return(0,r.isSpecificResource)(this.original)?{...this.original,source:{id:this.original.source?.id,type:this.original.source?.type}}:this.original}get(){return this.vault.get(this.resource)}};function u(e){return e.configKey??e.id}function d(e){switch(e){case`Image`:case`Video`:case`Sound`:case`Dataset`:case`Text`:case`TextualBody`:case`Composite`:case`List`:case`Choice`:case`Independents`:case`Audience`:return`ContentResource`;case`ImageService1`:case`ImageService2`:case`ImageService3`:return`Service`}return e}const f={Annotation:r.emptyAnnotation,AnnotationPage:r.emptyAnnotationPage,Canvas:r.emptyCanvas,Collection:r.emptyCollection,Manifest:r.emptyManifest,Range:r.emptyRange,ResourceProvider:r.emptyAgent,Service:r.emptyService};function p(e){let t=d(e);return f[t]||{}}function m(){return`${Math.random().toString(36).substring(2)}-${Date.now().toString(36)}`}function h(e,t,n){let i=[];if(t.length===0)return[];let a=(0,r.toRef)(e.parent),o=e.property,s=e.filter;for(let r of t)if(!(s&&(!r.tags||!r.tags.includes(s)))&&a&&o){if(r.supports.parentTypes&&!r.supports.parentTypes.includes(a.type)||r.supports.parentFields&&!r.supports.parentFields.includes(o))continue;if(r.supports.parentFieldMap){let e=r.supports.parentFieldMap[a.type];if(!e||!e.includes(o))continue}if(r.supports.disallowPainting&&e.isPainting||r.supports.onlyPainting&&!e.isPainting||r.supports.custom&&!r.supports.custom({property:o,resource:a,atIndex:e.index},n.vault))continue;let t=Object.keys(e.initialData||{}).filter(e=>e!==`skipEditingOnCreate`);if(!r.supports.initialData&&t.length!==0||r.resourceType!==e.type&&!(r.additionalTypes||[]).includes(e.type))continue;i.push(r)}return i}function g(e,t,n,r){return(i,a={})=>(typeof t!=`string`&&(a.parent={property:n,resource:t,atIndex:a?.parent?.atIndex}),e.create(r,i,a))}var _=class e{constructor(t,n){c(this,`resource`,void 0),c(this,`warnings`,[]),c(this,`errors`,[]),c(this,`partOf`,void 0),c(this,`references`,[]),c(this,`embedded`,[]),c(this,`vault`,void 0),c(this,`specificResource`,void 0),this.vault=n;let a={...t};if(a.type===`SpecificResource`){let e=a.source;this.specificResource={...a,source:{id:e.id,type:d(e.type)}},a=e}let o=Object.keys(a),s=p(a.type);for(let t of o)if(!(i.references.inlineProperties.includes(t)||!i.references.all.includes(t))){if(a.type===`Range`&&t===`items`){let e=[];for(let r of a[t]){if(r instanceof l){this.references.push(r),e.push(r);continue}let i=new l(r,n);e.push(i),a[t]=i}a[t]=e;continue}if(a.type===`Manifest`&&t===`start`){let e=a[t];if(e instanceof l){this.references.push(e);continue}let r=new l(e,n);a[t]=r;continue}if(a.type===`Annotation`&&t===`target`){let e=a[t];if(e instanceof l){this.references.push(e);continue}typeof e==`string`&&(e={id:e,type:`Canvas`});let r=new l(e,n);a[t]=r;continue}if(!i.references.single.includes(t)&&(i.references.externalProperties.includes(t)||i.references.internalProperties.includes(t))){let i=a[t]||[],o=Array.isArray(i)?i:[i],s=[];for(let t of o){if(t instanceof l){this.references.push(t),s.push(t);continue}if(t instanceof e){this.embedded.push(t),s.push(t);continue}if((0,r.isSpecificResource)(t)){let r=new e(t,n);this.embedded.push(r),s.push(r);continue}if(this.vault.get(t,{skipSelfReturn:!0})){let e=d(t.type),r=new l({id:t.id,type:e},n);this.references.push(r),s.push(r)}else{let r=new e(t,n);this.embedded.push(r),s.push(r)}}a[t]=s}}this.resource={...s,...a}}get(){return this.resource}getSpecificResource(){let e=this.ref();return(0,r.isSpecificResource)(e)?e:{type:`SpecificResource`,source:e}}ref(){return this.specificResource?this.specificResource:{id:this.resource.id,type:d(this.resource.type)}}getAllReferencedResources(){return this.references}getAllEmbeddedResources(){let e=[];for(let t of this.embedded)e.push(...t.getAllEmbeddedResources());return e.push(...this.embedded),e}getVaultResource(){let t=this.resource,n=Object.keys(t),a={};for(let r of n){if(i.references.inlineProperties.includes(r)||!i.references.all.includes(r)){a[r]=t[r];continue}if(i.references.single.includes(r)){let e=t[r];a[r]=e instanceof l?t.type===`Manifest`&&r===`start`||t.type===`Annotation`&&r===`target`?e.specificResource():e.optionalSpecificResource():t[r];continue}if(t[r]){a[r]=[];for(let n of t[r]||[]){if(t.type===`Range`&&r===`items`){n instanceof l&&(n.ref().type===`Canvas`?a[r].push(n.specificResource()):a[r].push(n.ref())),n instanceof e&&(n.ref().type===`Canvas`?a[r].push(n.getSpecificResource()):a[r].push(n.ref()));continue}n instanceof l&&a[r].push(n.optionalSpecificResource()),n instanceof e&&a[r].push(n.ref())}}}return this.partOf&&(a[r.HAS_PART]=a[r.HAS_PART]||[],a[r.HAS_PART].push(this.partOf)),a}setPartOf(e){let t=this.ref();this.partOf={id:t.id,type:d(t.type),[r.PART_OF]:e}}},v=class{constructor(e,t,r,i,a,o={}){c(this,`vault`,void 0),c(this,`previewVault`,void 0),c(this,`configs`,void 0),c(this,`options`,void 0),c(this,`config`,void 0),c(this,`creatorConfig`,void 0),c(this,`target`,void 0),c(this,`selector`,void 0),c(this,`serialisedSelector`,null),this.vault=e,this.previewVault=i,this.options=t,this.configs=r,this.creatorConfig=o,this.config=o[a]||{},this.target=this.options.target||this.options.parent?.resource;let s=this.options.initialData?.selector;this.selector=s?(0,n.annotationResponseToSelector)(s):null,this.options.initialData?.getSerialisedSelector&&(this.serialisedSelector=this.options.initialData.getSerialisedSelector())}getPreviewVault(){return this.previewVault}setSelector(e){this.selector=e}getSerialisedSelector(){if(this.serialisedSelector)return this.serialisedSelector;let e=this.selector;if(e){let t=(0,n.seraliseSupportedSelector)(e,this.options.initialData?.on);if(t)return t}return null}getTarget(){let e=this.target,t=this.getSerialisedSelector();return t?{type:`SpecificResource`,source:e,selector:t}:e}getParent(){return this.options.parent?.resource}getParentResource(){let e=this.getParent();if(e)return{type:`SpecificResource`,source:e}}generateId(e,t){return t&&t instanceof l&&(t=t.ref()),this.options.rootId&&(t={id:this.options.rootId,type:`none`}),`${(t||this.options.parent?.resource)?.id}/${e}/${m()}`}ref(e){let t=``,n=``;return typeof e==`string`?t=e:(t=e.id,n=e.type),n=this.vault.getState().iiif.mapping[t]||n||`unknown`,new l({id:t,type:n},this.vault)}embed(e){return new _(e,this.vault)}async create(e,t,n){let r=this.configs.find(t=>t.id===e);if(!r)throw Error(`Creator config ${e} not found`);return await new y(this.vault,r,t,this.configs,this.previewVault,n,this.creatorConfig).run()}},y=class{constructor(e,t,n,r,i,a,o){c(this,`resource`,null),c(this,`payload`,void 0),c(this,`vault`,void 0),c(this,`previewVault`,void 0),c(this,`definition`,void 0),c(this,`options`,void 0),c(this,`configs`,void 0),c(this,`creatorConfig`,void 0),this.vault=e,this.previewVault=i,this.definition=t,this.payload=n,this.configs=this.filterCreateConfigs(r),this.creatorConfig=o||{},this.options={targetType:a?.targetType||t.resourceType,...a||{}}}filterCreateConfigs(e){let t={};for(let n of e)t[n.id]=n;return Object.values(t)}async run(){let e=new v(this.vault,this.options,this.configs,this.previewVault,u(this.definition),this.creatorConfig),t=await this.definition.create(this.payload,e);if(Array.isArray(t)){let e=[];for(let n of t)n instanceof _?e.push(n):e.push(new _(n,this.vault));return this.resource=e,this.resource}return this.resource=t instanceof _?t:new _(t,this.vault),this.resource}getActions(){if(!this.resource)return[];let e=Array.isArray(this.resource)?this.resource:[this.resource],n=[],r={},i={};for(let a of e){this.options.parent&&a.setPartOf(this.options.parent.resource.id);let e=[...a.getAllEmbeddedResources(),a];for(let t of e){let e=t.getVaultResource();if(!e.type||!e.id)continue;let n=d(e.type);r[n]=r[n]?r[n]:{},r[n][e.id]=e,i[e.id]=n}n.push((0,t.importEntities)({entities:r})),n.push((0,t.addMappings)({mapping:i}))}return n}commit(e=[]){if(!this.resource)throw Error(`Creator has not been run`);let n=this.getActions();return this.vault.dispatch((0,t.batchActions)({actions:[...n,...e]})),Array.isArray(this.resource)?this.resource.map(e=>e.ref()):this.resource.ref()}},b=class{constructor(t,n,r,i){c(this,`configs`,void 0),c(this,`vault`,void 0),c(this,`previewVault`,void 0),c(this,`creatorConfig`,void 0),this.configs=n||[],this.vault=t,this.previewVault=r||new e.Vault,this.creatorConfig=i||{}}matchBasedOnResource(e){return h(e,this.configs||[],{vault:this.vault})}async create(e,n,r){let i=this.configs.find(t=>t.id===e);if(!i)throw Error(`Creator config ${e} not found`);if(r?.parent){if(i.supports.parentTypes&&!i.supports.parentTypes.includes(r.parent.resource.type))throw Error(`Definition ${e} does not support parent type ${r.parent.resource.type}`);if(i.supports.parentFields&&!i.supports.parentFields.includes(r.parent.property))throw Error(`Definition ${e} does not support parent field ${r.parent.property}`);if(i.supports.parentFieldMap){let t=i.supports.parentFieldMap[r.parent.resource.type];if(!t||!t.includes(r.parent.property))throw Error(`Definition ${e} does not support parent ${r.parent.property} / ${r.parent.property}`)}if(i.supports.custom&&!i.supports.custom(r.parent,this.vault))throw Error(`Definition does not support resource`)}let a=new y(this.vault,i,n,this.configs,this.previewVault,r,this.creatorConfig),o=await a.run(),s=Array.isArray(o)?o:[o],c=[];for(let e of s)r?.parent&&(r.parent.property===`start`||r.parent.property===`target`?c.push(t.entityActions.modifyEntityField({id:r.parent.resource.id,type:r.parent.resource.type,value:e.ref(),key:r.parent.property})):c.push(t.entityActions.addReference({id:r.parent.resource.id,type:r.parent.resource.type,reference:e.ref(),key:r.parent.property,index:r.parent.atIndex})));let l=a.commit(c);if(r?.parent&&i.sideEffects){for(let e of i.sideEffects)if(e.run){let t=Array.isArray(l)?l:[l];for(let n of t)await e.run(n,{vault:this.vault,options:r})}}return l}};function x(e){return e}function S(e,t,n={}){let r=e.render?r=>{let i={...r,options:{...r.options||{},initialData:{...t||{},...r.options?.initialData||{},...n||{}}}};return e.render?.(i)}:void 0;return{...e,render:r}}function C(e,t){let n=n=>t(n,e.render);return{...e,render:n}}exports.Creator=b,exports.CreatorResource=_,exports.creatorHelper=g,exports.defineCreator=x,exports.getCreatorConfigKey=u,exports.getEmptyType=p,exports.matchBasedOnResource=h,exports.randomId=m,exports.resolveType=d,exports.withCustomRender=C,exports.withInitialData=S;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["isSpecificResource","emptyAnnotation","emptyAnnotationPage","emptyCanvas","emptyCollection","emptyManifest","emptyRange","emptyAgent","emptyService","toRef","references","isSpecificResource","HAS_PART","PART_OF","annotationResponseToSelector","seraliseSupportedSelector","importEntities","addMappings","batchActions","Vault","entityActions"],"sources":["../src/ReferencedResource.ts","../src/utils.ts","../src/CreatorResource.ts","../src/CreatorInstance.ts","../src/CreatorRuntime.ts","../src/Creator.ts","../src/creator-register.ts"],"sourcesContent":["import type { Vault } from \"@iiif/helpers/vault\";\nimport { isSpecificResource } from \"@iiif/parser\";\nimport type { Reference, SpecificResource } from \"@iiif/presentation-3\";\n\nexport class ReferencedResource {\n vault: Vault;\n original: Reference | SpecificResource;\n reference: Reference;\n resource: SpecificResource;\n constructor(reference: Reference | SpecificResource, vault: Vault) {\n this.vault = vault;\n this.original = reference;\n this.reference = isSpecificResource(reference)\n ? reference.source\n : reference;\n this.resource = isSpecificResource(reference)\n ? reference\n : { type: \"SpecificResource\", source: this.reference };\n }\n\n // @todo editable specific resource.\n\n ref() {\n return this.reference;\n }\n\n specificResource() {\n return this.resource;\n }\n\n optionalSpecificResource() {\n if (isSpecificResource(this.original)) {\n return {\n ...this.original,\n source: {\n id: this.original.source?.id,\n type: this.original.source?.type,\n },\n };\n }\n\n // @todo check if there are targets here that would make this a specific resource.\n return this.original;\n }\n\n get() {\n return this.vault.get(this.resource);\n }\n}\n","import type { Entities, Vault } from \"@iiif/helpers/vault\";\nimport {\n emptyAgent,\n emptyAnnotation,\n emptyAnnotationPage,\n emptyCanvas,\n emptyCollection,\n emptyManifest,\n emptyRange,\n emptyService,\n toRef,\n} from \"@iiif/parser\";\nimport type {\n CreatorDefinitionFilterByParent,\n IIIFManifestEditor,\n} from \"./creator-register\";\nimport type {\n AllAvailableParentTypes,\n CreatableResource,\n CreatorDefinition,\n CreatorFunctionContext,\n CreatorOptions,\n GetCreatorPayload,\n GetSupportedResourceFields,\n ResolvedCreatorReturn,\n} from \"./types\";\n\nexport function getCreatorConfigKey(definition: CreatorDefinition): string {\n return definition.configKey ?? definition.id;\n}\n\nexport function resolveType(type: string): keyof Entities {\n switch (type) {\n case \"Image\":\n case \"Video\":\n case \"Sound\":\n case \"Dataset\":\n case \"Text\":\n case \"TextualBody\":\n case \"Composite\":\n case \"List\":\n case \"Choice\":\n case \"Independents\":\n case \"Audience\":\n return \"ContentResource\";\n case \"ImageService1\":\n case \"ImageService2\":\n case \"ImageService3\":\n return \"Service\";\n }\n\n return type as any;\n}\n\nconst emptyTypes = {\n Annotation: emptyAnnotation,\n AnnotationPage: emptyAnnotationPage,\n Canvas: emptyCanvas,\n Collection: emptyCollection,\n Manifest: emptyManifest,\n Range: emptyRange,\n ResourceProvider: emptyAgent,\n Service: emptyService,\n};\n\nexport function getEmptyType(type: string): any {\n const key = resolveType(type);\n return emptyTypes[key as \"Manifest\"] || {};\n}\n\nexport function randomId() {\n return `${Math.random().toString(36).substring(2)}-${Date.now().toString(36)}`;\n}\n\nexport function matchBasedOnResource(\n resource: CreatableResource,\n list: CreatorDefinition[],\n options: { vault: Vault },\n): CreatorDefinition[] {\n const supported = [];\n if (list.length === 0) {\n return [];\n }\n const parent = toRef(resource.parent);\n const property = resource.property;\n const filter = resource.filter;\n\n for (const def of list) {\n if (filter) {\n if (!def.tags) continue;\n if (!def.tags.includes(filter)) {\n continue;\n }\n }\n\n if (parent && property) {\n if (def.supports.parentTypes) {\n if (!def.supports.parentTypes.includes(parent.type)) {\n continue;\n }\n }\n if (def.supports.parentFields) {\n if (!def.supports.parentFields.includes(property)) {\n continue;\n }\n }\n\n if (def.supports.parentFieldMap) {\n const type = def.supports.parentFieldMap[parent.type];\n if (!type || !type.includes(property)) {\n continue;\n }\n }\n\n if (def.supports.disallowPainting && resource.isPainting) {\n continue;\n }\n if (def.supports.onlyPainting && !resource.isPainting) {\n continue;\n }\n\n if (def.supports.custom) {\n const isValid = def.supports.custom(\n { property, resource: parent, atIndex: resource.index },\n options.vault,\n );\n if (!isValid) {\n continue;\n }\n }\n\n const initialDataKeys = Object.keys(resource.initialData || {}).filter(\n (key) => key !== \"skipEditingOnCreate\",\n );\n\n if (!def.supports.initialData && initialDataKeys.length !== 0) {\n continue;\n }\n\n if (def.resourceType !== resource.type) {\n if (!(def.additionalTypes || []).includes(resource.type)) {\n continue;\n }\n }\n supported.push(def);\n }\n }\n\n return supported;\n}\n\nexport function creatorHelper<\n const ResourceType extends AllAvailableParentTypes,\n const Parent extends { id: string; type: ResourceType },\n const ResourceField extends GetSupportedResourceFields<ResourceType>,\n const CID extends CreatorDefinitionFilterByParent<\n ResourceType,\n ResourceField\n >[\"id\"],\n Payload = GetCreatorPayload<IIIFManifestEditor.CreatorDefinitions[CID]>,\n Return = ResolvedCreatorReturn<IIIFManifestEditor.CreatorDefinitions[CID]>,\n>(\n ctx: CreatorFunctionContext,\n parent: Parent | ResourceType,\n property: ResourceField,\n definition: CID,\n): (payload: Payload, options?: Partial<CreatorOptions>) => Promise<Return> {\n return (payload: Payload, options = {}) => {\n if (typeof parent !== \"string\") {\n options.parent = {\n property,\n resource: parent,\n atIndex: options?.parent?.atIndex,\n };\n }\n return ctx.create(definition, payload, options) as any;\n };\n}\n","import type { Vault } from \"@iiif/helpers/vault\";\nimport { HAS_PART, isSpecificResource, PART_OF } from \"@iiif/parser\";\nimport type { SpecificResource } from \"@iiif/presentation-3\";\nimport { references } from \"@manifest-editor/editor-api\";\nimport { ReferencedResource } from \"./ReferencedResource\";\nimport { getEmptyType, resolveType } from \"./utils\";\n\nexport class CreatorResource {\n resource: any;\n warnings: string[] = [];\n errors: string[] = [];\n partOf: any;\n references: ReferencedResource[] = [];\n embedded: CreatorResource[] = [];\n vault: Vault;\n specificResource?: SpecificResource;\n\n constructor(inputData: any, vault: Vault) {\n this.vault = vault;\n let data = { ...inputData };\n\n if (data.type === \"SpecificResource\") {\n const source = data.source;\n this.specificResource = {\n ...data,\n source: { id: source.id, type: resolveType(source.type) },\n };\n data = source;\n }\n\n const properties = Object.keys(data);\n const defaultType = getEmptyType(data.type);\n\n for (const key of properties) {\n // These properties are NOT references and can be just included normally.\n if (\n references.inlineProperties.includes(key as any) ||\n !references.all.includes(key as any)\n ) {\n continue;\n }\n\n if (data.type === \"Range\" && key === \"items\") {\n const newRange: any = [];\n for (const range of data[key]) {\n if (range instanceof ReferencedResource) {\n this.references.push(range);\n newRange.push(range);\n continue;\n }\n\n const rangeRef = new ReferencedResource(range, vault);\n newRange.push(rangeRef);\n data[key] = rangeRef;\n }\n\n data[key] = newRange;\n continue;\n }\n\n if (data.type === \"Manifest\" && key === \"start\") {\n const start = data[key];\n\n if (start instanceof ReferencedResource) {\n this.references.push(start);\n continue;\n }\n\n const startRef = new ReferencedResource(start, vault);\n data[key] = startRef;\n continue;\n }\n\n if (data.type === \"Annotation\" && key === \"target\") {\n let target = data[key];\n\n if (target instanceof ReferencedResource) {\n this.references.push(target);\n continue;\n }\n\n if (typeof target === \"string\") {\n target = { id: target, type: \"Canvas\" };\n }\n\n const targetRef = new ReferencedResource(target, vault);\n data[key] = targetRef;\n continue;\n }\n\n // @todo Handle single item cases. (not caught by the above 2 cases)\n if (references.single.includes(key as any)) {\n continue;\n }\n\n // This property SHOULD already be in the Vault OR an instance of creator resource.\n if (\n references.externalProperties.includes(key as any) ||\n references.internalProperties.includes(key as any)\n ) {\n const _items = (data[key] || []) as any[];\n const items = Array.isArray(_items) ? _items : [_items];\n const newItems: any[] = [];\n for (const item of items) {\n if (item instanceof ReferencedResource) {\n this.references.push(item);\n newItems.push(item);\n continue;\n }\n if (item instanceof CreatorResource) {\n this.embedded.push(item);\n newItems.push(item);\n continue;\n }\n\n // A SpecificResource carries its selector and source inline. Vault.get()\n // resolves it to its source, so an existing source must not turn the\n // wrapper into a plain reference.\n if (isSpecificResource(item)) {\n const newItem = new CreatorResource(item, vault);\n this.embedded.push(newItem);\n newItems.push(newItem);\n continue;\n }\n\n const exists = this.vault.get(item, { skipSelfReturn: true });\n if (exists) {\n const type = resolveType(item.type);\n const newItem = new ReferencedResource(\n { id: item.id, type },\n vault,\n );\n this.references.push(newItem);\n newItems.push(newItem);\n } else {\n const newItem = new CreatorResource(item, vault);\n this.embedded.push(newItem);\n newItems.push(newItem);\n }\n }\n data[key] = newItems;\n }\n }\n this.resource = { ...defaultType, ...data };\n }\n\n // This is what is returned from the creator instance\n get() {\n return this.resource;\n }\n\n getSpecificResource() {\n const reference = this.ref();\n return isSpecificResource(reference)\n ? reference\n : { type: \"SpecificResource\", source: reference };\n }\n\n ref() {\n if (this.specificResource) {\n return this.specificResource;\n }\n\n return {\n id: this.resource.id,\n type: resolveType(this.resource.type as string) as any,\n };\n }\n\n getAllReferencedResources() {\n return this.references;\n }\n\n getAllEmbeddedResources(): CreatorResource[] {\n const allEmbedded = [];\n for (const resource of this.embedded) {\n allEmbedded.push(...resource.getAllEmbeddedResources());\n }\n allEmbedded.push(...this.embedded);\n return allEmbedded;\n }\n\n getVaultResource() {\n const resource = this.resource;\n const properties = Object.keys(resource);\n const newResource: any = {};\n\n for (const key of properties) {\n // Skip these, they are just normal inline values.\n if (\n references.inlineProperties.includes(key as any) ||\n !references.all.includes(key as any)\n ) {\n newResource[key] = resource[key];\n continue;\n }\n\n if (references.single.includes(key as any)) {\n const ref = resource[key];\n if (ref instanceof ReferencedResource) {\n // These MUST be specific resources.\n if (\n (resource.type === \"Manifest\" && key === \"start\") ||\n (resource.type === \"Annotation\" && key === \"target\")\n ) {\n newResource[key] = ref.specificResource();\n } else {\n newResource[key] = ref.optionalSpecificResource();\n }\n } else {\n newResource[key] = resource[key];\n }\n continue;\n }\n\n if (resource[key]) {\n newResource[key] = [];\n for (const item of resource[key] || []) {\n if (resource.type === \"Range\" && key === \"items\") {\n if (item instanceof ReferencedResource) {\n if (item.ref().type === \"Canvas\") {\n newResource[key].push(item.specificResource());\n } else {\n newResource[key].push(item.ref());\n }\n }\n if (item instanceof CreatorResource) {\n if (item.ref().type === \"Canvas\") {\n newResource[key].push(item.getSpecificResource());\n } else {\n newResource[key].push(item.ref());\n }\n }\n continue;\n }\n\n if (item instanceof ReferencedResource) {\n newResource[key].push(item.optionalSpecificResource());\n }\n if (item instanceof CreatorResource) {\n newResource[key].push(item.ref());\n }\n }\n }\n }\n\n if (this.partOf) {\n newResource[HAS_PART] = newResource[HAS_PART] || [];\n newResource[HAS_PART].push(this.partOf);\n }\n\n return newResource;\n }\n\n setPartOf(id: string) {\n const ref = this.ref();\n this.partOf = {\n id: ref.id,\n type: resolveType(ref.type),\n [PART_OF]: id,\n };\n }\n}\n","import type { SupportedSelector } from \"@iiif/helpers\";\nimport type { Vault } from \"@iiif/helpers/vault\";\nimport type {\n Reference,\n Selector,\n SpecificResource,\n} from \"@iiif/presentation-3\";\nimport {\n type AnnotationResponse,\n annotationResponseToSelector,\n seraliseSupportedSelector,\n} from \"react-iiif-vault\";\nimport { CreatorResource } from \"./CreatorResource\";\nimport { CreatorRuntime } from \"./CreatorRuntime\";\nimport { ReferencedResource } from \"./ReferencedResource\";\nimport type {\n CreatorConfig,\n CreatorDefinition,\n CreatorFunctionContext,\n CreatorOptions,\n} from \"./types\";\nimport { randomId } from \"./utils\";\n\nexport class CreatorInstance implements CreatorFunctionContext {\n vault: Vault;\n previewVault: Vault;\n configs: CreatorDefinition[];\n options: CreatorOptions;\n config: Record<string, unknown>;\n creatorConfig: CreatorConfig;\n\n target: CreatorOptions[\"target\"];\n selector: SupportedSelector | undefined | null;\n serialisedSelector: { type: string; value: string } | null = null;\n\n constructor(\n vault: Vault,\n options: CreatorOptions,\n createConfigs: CreatorDefinition[],\n previewVault: Vault,\n configKey: string,\n creatorConfig: CreatorConfig = {},\n ) {\n this.vault = vault;\n this.previewVault = previewVault;\n this.options = options;\n this.configs = createConfigs;\n this.creatorConfig = creatorConfig;\n this.config = creatorConfig[configKey] || {};\n this.target = this.options.target || this.options.parent?.resource;\n const response: AnnotationResponse = this.options.initialData?.selector;\n this.selector = response ? annotationResponseToSelector(response) : null;\n if (this.options.initialData?.getSerialisedSelector) {\n this.serialisedSelector =\n this.options.initialData.getSerialisedSelector();\n }\n }\n\n getPreviewVault() {\n return this.previewVault;\n }\n\n setSelector(selector: SupportedSelector) {\n this.selector = selector;\n }\n\n getSerialisedSelector() {\n if (this.serialisedSelector) {\n return this.serialisedSelector;\n }\n const selector = this.selector;\n if (selector) {\n const serialisedSelector = seraliseSupportedSelector(\n selector,\n this.options.initialData?.on,\n );\n if (serialisedSelector) {\n return serialisedSelector;\n }\n }\n return null;\n }\n\n getTarget(): SpecificResource | Reference | undefined {\n const target = this.target;\n const serialisedSelector = this.getSerialisedSelector();\n\n if (serialisedSelector) {\n return {\n type: \"SpecificResource\",\n source: target,\n selector: serialisedSelector as Selector,\n };\n }\n\n return target;\n }\n\n getParent(): Reference | undefined {\n return this.options.parent?.resource;\n }\n getParentResource(): SpecificResource | undefined {\n const parent = this.getParent();\n if (parent) {\n return {\n type: \"SpecificResource\",\n source: parent,\n };\n }\n }\n\n generateId(type: string, parent?: Reference | ReferencedResource) {\n if (parent && parent instanceof ReferencedResource) {\n parent = parent.ref();\n }\n if (this.options.rootId) {\n parent = { id: this.options.rootId, type: \"none\" };\n }\n\n return `${(parent || this.options.parent?.resource)?.id}/${type}/${randomId()}`;\n }\n\n ref(idOrRef: string | Reference) {\n let id = \"\";\n let type = \"\";\n\n if (typeof idOrRef === \"string\") {\n id = idOrRef;\n } else {\n id = idOrRef.id;\n type = idOrRef.type;\n }\n\n const state = this.vault.getState();\n const realType = state.iiif.mapping[id];\n\n if (!realType) {\n type = type || \"unknown\";\n } else {\n type = realType;\n }\n\n return new ReferencedResource({ id, type }, this.vault);\n }\n\n embed(data: any) {\n return new CreatorResource(data, this.vault);\n }\n\n async create(\n definition: string,\n payload: any,\n options?: Partial<CreatorOptions>,\n ) {\n const foundDefinition = this.configs.find((t) => t.id === definition);\n if (!foundDefinition) {\n throw new Error(`Creator config ${definition} not found`);\n }\n\n const runtime = new CreatorRuntime(\n this.vault,\n foundDefinition,\n payload,\n this.configs,\n this.previewVault,\n options,\n this.creatorConfig,\n );\n\n return (await runtime.run()) as any;\n }\n}\n","import type { Vault } from \"@iiif/helpers/vault\";\nimport {\n addMappings,\n batchActions,\n importEntities,\n} from \"@iiif/helpers/vault/actions\";\nimport type { Reference } from \"@iiif/presentation-3\";\nimport { CreatorInstance } from \"./CreatorInstance\";\nimport { CreatorResource } from \"./CreatorResource\";\nimport type { CreatorConfig, CreatorDefinition, CreatorOptions } from \"./types\";\nimport { getCreatorConfigKey, resolveType } from \"./utils\";\n\nexport class CreatorRuntime {\n // This will hold state for the creation process\n resource: CreatorResource | Array<CreatorResource> | null = null;\n payload: any;\n vault: Vault;\n previewVault: Vault;\n definition: CreatorDefinition;\n options: CreatorOptions;\n configs: CreatorDefinition[];\n creatorConfig: CreatorConfig;\n\n constructor(\n vault: Vault,\n definition: CreatorDefinition,\n payload: any,\n createConfigs: CreatorDefinition[],\n previewVault: Vault,\n options?: Partial<CreatorOptions>,\n creatorConfig?: CreatorConfig,\n ) {\n this.vault = vault;\n this.previewVault = previewVault;\n this.definition = definition;\n this.payload = payload;\n this.configs = this.filterCreateConfigs(createConfigs);\n this.creatorConfig = creatorConfig || {};\n this.options = {\n targetType: options?.targetType || definition.resourceType,\n ...(options || {}),\n };\n }\n\n filterCreateConfigs(configs: CreatorDefinition[]) {\n const indexedByIdLastWins: Record<string, CreatorDefinition> = {};\n for (const config of configs) {\n indexedByIdLastWins[config.id] = config;\n }\n return Object.values(indexedByIdLastWins);\n }\n\n async run(): Promise<CreatorResource | CreatorResource[]> {\n const instance = new CreatorInstance(\n this.vault,\n this.options,\n this.configs,\n this.previewVault,\n getCreatorConfigKey(this.definition),\n this.creatorConfig,\n );\n const result = await this.definition.create(this.payload, instance);\n\n // Could be an array.\n if (Array.isArray(result)) {\n const results: CreatorResource[] = [];\n for (const item of result) {\n if (item instanceof CreatorResource) {\n results.push(item);\n } else {\n results.push(new CreatorResource(item, this.vault));\n }\n }\n this.resource = results;\n\n return this.resource;\n }\n\n if (result instanceof CreatorResource) {\n this.resource = result;\n } else {\n this.resource = new CreatorResource(result, this.vault);\n }\n\n return this.resource;\n }\n\n getActions() {\n if (!this.resource) {\n return [];\n }\n\n const allResources = Array.isArray(this.resource)\n ? this.resource\n : [this.resource];\n\n const actions = [];\n\n const resources: any = {};\n const mapping: any = {};\n\n for (const resource of allResources) {\n if (this.options.parent) {\n resource.setPartOf(this.options.parent.resource.id);\n }\n\n const embedded = resource.getAllEmbeddedResources();\n\n const allItems = [...embedded, resource];\n\n for (const item of allItems) {\n const resource = item.getVaultResource();\n if (!resource.type || !resource.id) {\n continue;\n }\n const type = resolveType(resource.type);\n resources[type] = resources[type] ? resources[type] : {};\n resources[type][resource.id] = resource;\n mapping[resource.id] = type;\n }\n\n actions.push(importEntities({ entities: resources }));\n actions.push(addMappings({ mapping }));\n }\n\n return actions as any[];\n }\n\n commit(afterActions: any[] = []): Reference | Reference[] {\n if (!this.resource) {\n throw new Error(\"Creator has not been run\");\n }\n\n const actions = this.getActions();\n this.vault.dispatch(\n batchActions({ actions: [...actions, ...afterActions] }),\n );\n\n if (Array.isArray(this.resource)) {\n return this.resource.map((resource) => resource.ref() as Reference);\n }\n\n return this.resource.ref() as Reference;\n }\n}\n","import { Vault } from \"@iiif/helpers/vault\";\nimport { entityActions } from \"@iiif/helpers/vault/actions\";\nimport type { Reference } from \"@iiif/presentation-3\";\nimport { CreatorRuntime } from \"./CreatorRuntime\";\nimport type { CreatableResource, CreatorConfig, CreatorDefinition, CreatorOptions } from \"./types\";\nimport { matchBasedOnResource } from \"./utils\";\n\nexport class Creator {\n configs: CreatorDefinition[];\n vault: Vault;\n previewVault: Vault;\n creatorConfig: CreatorConfig;\n\n constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault, creatorConfig?: CreatorConfig) {\n this.configs = configs || [];\n this.vault = vault;\n this.previewVault = previewVault || new Vault();\n this.creatorConfig = creatorConfig || {};\n }\n\n matchBasedOnResource(resource: CreatableResource) {\n return matchBasedOnResource(resource, this.configs || [], { vault: this.vault });\n }\n\n async create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference | Reference[]> {\n const foundDefinition = this.configs.find((t) => t.id === definition);\n if (!foundDefinition) {\n throw new Error(`Creator config ${definition} not found`);\n }\n\n if (options?.parent) {\n if (foundDefinition.supports.parentTypes) {\n if (!foundDefinition.supports.parentTypes.includes(options.parent.resource.type)) {\n throw new Error(`Definition ${definition} does not support parent type ${options.parent.resource.type}`);\n }\n }\n if (foundDefinition.supports.parentFields) {\n if (!foundDefinition.supports.parentFields.includes(options.parent.property)) {\n throw new Error(`Definition ${definition} does not support parent field ${options.parent.property}`);\n }\n }\n\n if (foundDefinition.supports.parentFieldMap) {\n const type = foundDefinition.supports.parentFieldMap[options.parent.resource.type];\n if (!type || !type.includes(options.parent.property)) {\n throw new Error(\n `Definition ${definition} does not support parent ${options.parent.property} / ${options.parent.property}`,\n );\n }\n }\n if (foundDefinition.supports.custom) {\n const isValid = foundDefinition.supports.custom(options.parent, this.vault);\n if (!isValid) {\n throw new Error(`Definition does not support resource`);\n }\n }\n }\n\n const runtime = new CreatorRuntime(\n this.vault,\n foundDefinition,\n payload,\n this.configs,\n this.previewVault,\n options,\n this.creatorConfig,\n );\n\n const run = await runtime.run();\n const allResources = Array.isArray(run) ? run : [run];\n const afterActions: any[] = [];\n\n for (const resource of allResources) {\n if (options?.parent) {\n if (options.parent.property === \"start\" || options.parent.property === \"target\") {\n afterActions.push(\n entityActions.modifyEntityField({\n id: options.parent.resource.id,\n type: options.parent.resource.type as any,\n value: resource.ref(),\n key: options.parent.property,\n }),\n );\n } else {\n afterActions.push(\n entityActions.addReference({\n id: options.parent.resource.id,\n type: options.parent.resource.type as any,\n reference: resource.ref(),\n key: options.parent.property,\n index: options.parent.atIndex,\n }),\n );\n }\n }\n }\n\n const result = runtime.commit(afterActions);\n\n // Only run side effects if there is a parent\n if (options?.parent) {\n if (foundDefinition.sideEffects) {\n for (const sideEffect of foundDefinition.sideEffects) {\n if (sideEffect.run) {\n const allResults = Array.isArray(result) ? result : [result];\n for (const item of allResults) {\n // @todo we need more in the ctx (like parent/target where this is to be added.)\n await sideEffect.run(item, { vault: this.vault, options: options as any });\n }\n }\n }\n }\n }\n\n return result;\n }\n}\n","import type {\n AllAvailableParentTypes,\n AllParentTypes,\n AllProperties,\n CreatorContext,\n CreatorDefinition,\n SpecificCreatorDefinition,\n} from \"./types\";\n\n// Want to enable the following APIs.\n//\n// const createImage = useCreator(\n// resource,\n// \"thumbnail\",\n// \"@manifest-editor/image-url-creator\"\n// );\n//\n// createImage({ url: 'https://example.org/image.jpg' });\n//\n// These should be constructed from an array of creators.\n// UseCreator<Resource, ResourceField, CreatorId> -> CreatorPayload\n//\n// But then also:\n// await manifestEditor.descriptive.thumbnail.create(\"@manifest-editor/image-url-creator\", {\n// url: \"https://example.org/image.jpg\",\n// });\n//\n// So essentially, I think we want to create a type that is roughly structured like this:\n// {\n// Manifest: {\n// thumbnail: {\n// \"@manifest-editor/image-url-creator\": {\n// url: string;\n// }\n// }\n// }\n// }\n// Although it would include _all_ available creators.\n// Then the helpers would be fairly easy to implement.\n//\n// Here the creator definition (might need to change) for this:\n\nexport function defineCreator<\n const Payload = any,\n const ID = Readonly<string>,\n const ResourceType extends AllAvailableParentTypes = never,\n const AdditionalResourceTypes extends Array<AllAvailableParentTypes> = [],\n const AllResourceTypes = [ResourceType, ...AdditionalResourceTypes],\n const SupportsParentTypes extends Array<AllAvailableParentTypes> = AllParentTypes,\n const SupportsParentFields extends Array<AllProperties> = [],\n const CreateReturnType = any,\n>(\n options: SpecificCreatorDefinition<\n Payload,\n ID,\n ResourceType,\n AdditionalResourceTypes,\n AllResourceTypes,\n SupportsParentTypes,\n SupportsParentFields,\n CreateReturnType\n >\n) {\n return options;\n}\n\nexport function withInitialData<T extends CreatorDefinition>(\n creator: T,\n data: Record<string, any>,\n overrides: Record<string, any> = {}\n): T {\n const render = creator.render\n ? (ctx: CreatorContext<any>) => {\n const newContext: CreatorContext = {\n ...ctx,\n options: {\n ...(ctx.options || {}),\n initialData: {\n ...(data || {}),\n ...(ctx.options?.initialData || {}),\n ...(overrides || {}),\n },\n },\n };\n return creator.render?.(newContext);\n }\n : undefined;\n\n return { ...creator, render } as T;\n}\n\nexport function withCustomRender<T extends CreatorDefinition>(\n creator: T,\n render: (ctx: CreatorContext<any>, originalRender: (ctx: CreatorContext<any>) => React.ReactNode) => React.ReactNode\n): T {\n const newRender = (ctx: CreatorContext<any>) => {\n return render(ctx, creator.render as any);\n };\n\n return { ...creator, render: newRender } as T;\n}\n\nexport declare namespace IIIFManifestEditor {\n interface CreatorDefinitions {}\n}\n\nexport type ExtractCreatorGenerics<T extends CreatorDefinition> =\n T extends SpecificCreatorDefinition<\n infer Payload,\n infer ID,\n infer ResourceType,\n infer AdditionalResourceTypes,\n infer AllResourceTypes,\n infer SupportsParentTypes,\n infer SupportsParentFields,\n infer CreateReturnType\n >\n ? {\n Payload: Payload;\n ID: ID;\n ResourceType: ResourceType;\n AdditionalResourceTypes: AdditionalResourceTypes;\n AllResourceTypes: AllResourceTypes;\n SupportsParentTypes: SupportsParentTypes;\n SupportsParentFields: SupportsParentFields;\n CreateReturnType: CreateReturnType;\n }\n : never;\n\ntype CreatorSupportsParentTypes<T, Type extends AllAvailableParentTypes> = T extends CreatorDefinition\n ? ExtractCreatorGenerics<T>[\"SupportsParentTypes\"] extends never\n ? false\n : HelperInArray<Type, ExtractCreatorGenerics<T>[\"SupportsParentTypes\"]>\n : false;\n\ntype CreatorSupportsParentFields<T, Field extends AllProperties> = T extends CreatorDefinition\n ? ExtractCreatorGenerics<T>[\"SupportsParentFields\"] extends never\n ? false\n : HelperInArray<Field, ExtractCreatorGenerics<T>[\"SupportsParentFields\"]>\n : false;\n\ntype CreatorSupportsParent<\n T,\n Type extends AllAvailableParentTypes,\n Field extends AllProperties,\n> = T extends CreatorDefinition\n ? CreatorSupportsParentTypes<T, Type> extends true\n ? CreatorSupportsParentFields<T, Field> extends true\n ? true\n : false\n : false\n : false;\n\ntype HelperInArray<ToFind, Array extends readonly any[]> = Array extends readonly [infer Head, ...infer Tail]\n ? Head extends ToFind\n ? true\n : HelperInArray<ToFind, Tail>\n : false;\n\nexport type CreatorDefinitionFilterByParent<\n Type extends AllAvailableParentTypes,\n Field extends AllProperties = AllProperties,\n CD extends IIIFManifestEditor.CreatorDefinitions = IIIFManifestEditor.CreatorDefinitions,\n> = {\n [K in keyof CD]: CreatorSupportsParent<CD[K], Type, Field> extends true ? CD[K] : never;\n}[keyof CD];\n"],"mappings":"s6BAIA,IAAa,EAAb,KAAgC,CAK9B,YAAY,EAAyC,EAAc,CAJnE,EAAA,KAAA,QAAA,IAAA,EAAA,EACA,EAAA,KAAA,WAAA,IAAA,EAAA,EACA,EAAA,KAAA,YAAA,IAAA,EAAA,EACA,EAAA,KAAA,WAAA,IAAA,EAAA,EAEE,KAAK,MAAQ,EACb,KAAK,SAAW,EAChB,KAAK,WAAA,EAAYA,EAAAA,mBAAAA,CAAmB,CAAS,EACzC,EAAU,OACV,EACJ,KAAK,UAAA,EAAWA,EAAAA,mBAAAA,CAAmB,CAAS,EACxC,EACA,CAAE,KAAM,mBAAoB,OAAQ,KAAK,SAAU,CACzD,CAIA,KAAM,CACJ,OAAO,KAAK,SACd,CAEA,kBAAmB,CACjB,OAAO,KAAK,QACd,CAEA,0BAA2B,CAYzB,OAXA,EAAIA,EAAAA,mBAAAA,CAAmB,KAAK,QAAQ,EAC3B,CACL,GAAG,KAAK,SACR,OAAQ,CACN,GAAI,KAAK,SAAS,QAAQ,GAC1B,KAAM,KAAK,SAAS,QAAQ,IAC9B,CACF,EAIK,KAAK,QACd,CAEA,KAAM,CACJ,OAAO,KAAK,MAAM,IAAI,KAAK,QAAQ,CACrC,CACF,ECrBA,SAAgB,EAAoB,EAAuC,CACzE,OAAO,EAAW,WAAa,EAAW,EAC5C,CAEA,SAAgB,EAAY,EAA8B,CACxD,OAAQ,EAAR,CACE,IAAK,QACL,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B,CAEA,SAAgB,EACd,EACA,EACG,CACH,IAAM,EAAa,GACV,EAAO,EAAK,EAAQ,MAAa,EAG1C,MAAO,CAAE,GAAG,EAAS,OAAQ,CAAU,CACzC"}
package/dist/index.d.cts CHANGED
@@ -1,10 +1,8 @@
1
1
  import { Entities, Vault } from "@iiif/helpers/vault";
2
- import * as _iiif_presentation_329 from "@iiif/presentation-3";
3
2
  import { Annotation, DescriptiveProperties, LinkingProperties, NavPlaceExtension, Reference, SpecificResource, StructuralProperties, TechnicalProperties } from "@iiif/presentation-3";
4
3
  import { resources } from "@manifest-editor/editor-api";
5
4
  import { ReactNode } from "react";
6
5
  import { SupportedSelector } from "@iiif/helpers";
7
-
8
6
  //#region src/ReferencedResource.d.ts
9
7
  declare class ReferencedResource {
10
8
  vault: Vault;
@@ -17,56 +15,56 @@ declare class ReferencedResource {
17
15
  id: string;
18
16
  };
19
17
  specificResource(): {
20
- created?: string | undefined;
21
- generated?: string | undefined;
22
- modified?: string | undefined;
23
- creator?: _iiif_presentation_329.Creator | undefined;
24
- generator?: _iiif_presentation_329.Creator | undefined;
25
- audience?: (_iiif_presentation_329.Audience | _iiif_presentation_329.Audience[]) | undefined;
26
- accessibility?: string | string[] | undefined;
27
- motivation?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
28
- rights?: string | string[] | undefined;
29
- canonical?: string | undefined;
30
- via?: string | string[] | undefined;
31
- role?: string | undefined;
32
- id?: string | undefined;
18
+ created?: string;
19
+ generated?: string;
20
+ modified?: string;
21
+ creator?: import("@iiif/presentation-3").Creator;
22
+ generator?: import("@iiif/presentation-3").Creator;
23
+ audience?: import("@iiif/presentation-3").Audience | import("@iiif/presentation-3").Audience[];
24
+ accessibility?: string | string[];
25
+ motivation?: import("@iiif/presentation-3").AnyMotivation | import("@iiif/presentation-3").AnyMotivation[];
26
+ rights?: string | string[];
27
+ canonical?: string;
28
+ via?: string | string[];
29
+ role?: string;
30
+ id?: string;
33
31
  type: "SpecificResource";
34
- state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
35
- purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
32
+ state?: import("@iiif/presentation-3").State | import("@iiif/presentation-3").State[];
33
+ purpose?: import("@iiif/presentation-3").AnyMotivation | import("@iiif/presentation-3").AnyMotivation[];
36
34
  source?: any;
37
- selector?: (_iiif_presentation_329.Selector | _iiif_presentation_329.Selector[]) | undefined;
38
- styleClass?: string | undefined;
39
- renderedVia?: (_iiif_presentation_329.Agent | _iiif_presentation_329.Agent[]) | undefined;
40
- scope?: _iiif_presentation_329.LinkedResource;
35
+ selector?: import("@iiif/presentation-3").Selector | import("@iiif/presentation-3").Selector[];
36
+ styleClass?: string;
37
+ renderedVia?: import("@iiif/presentation-3").Agent | import("@iiif/presentation-3").Agent[];
38
+ scope?: import("@iiif/presentation-3").LinkedResource;
41
39
  };
42
40
  optionalSpecificResource(): {
43
41
  type: string;
44
42
  id: string;
45
43
  } | {
44
+ created?: string;
45
+ generated?: string;
46
+ modified?: string;
47
+ creator?: import("@iiif/presentation-3").Creator;
48
+ generator?: import("@iiif/presentation-3").Creator;
49
+ audience?: import("@iiif/presentation-3").Audience | import("@iiif/presentation-3").Audience[];
50
+ accessibility?: string | string[];
51
+ motivation?: import("@iiif/presentation-3").AnyMotivation | import("@iiif/presentation-3").AnyMotivation[];
52
+ rights?: string | string[];
53
+ canonical?: string;
54
+ via?: string | string[];
55
+ role?: string;
56
+ id?: string;
57
+ type: "SpecificResource";
58
+ state?: import("@iiif/presentation-3").State | import("@iiif/presentation-3").State[];
59
+ purpose?: import("@iiif/presentation-3").AnyMotivation | import("@iiif/presentation-3").AnyMotivation[];
60
+ selector?: import("@iiif/presentation-3").Selector | import("@iiif/presentation-3").Selector[];
61
+ styleClass?: string;
62
+ renderedVia?: import("@iiif/presentation-3").Agent | import("@iiif/presentation-3").Agent[];
63
+ scope?: import("@iiif/presentation-3").LinkedResource;
46
64
  source: {
47
65
  id: any;
48
66
  type: any;
49
67
  };
50
- created?: string | undefined;
51
- generated?: string | undefined;
52
- modified?: string | undefined;
53
- creator?: _iiif_presentation_329.Creator | undefined;
54
- generator?: _iiif_presentation_329.Creator | undefined;
55
- audience?: (_iiif_presentation_329.Audience | _iiif_presentation_329.Audience[]) | undefined;
56
- accessibility?: string | string[] | undefined;
57
- motivation?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
58
- rights?: string | string[] | undefined;
59
- canonical?: string | undefined;
60
- via?: string | string[] | undefined;
61
- role?: string | undefined;
62
- id?: string | undefined;
63
- type: "SpecificResource";
64
- state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
65
- purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
66
- selector?: (_iiif_presentation_329.Selector | _iiif_presentation_329.Selector[]) | undefined;
67
- styleClass?: string | undefined;
68
- renderedVia?: (_iiif_presentation_329.Agent | _iiif_presentation_329.Agent[]) | undefined;
69
- scope?: _iiif_presentation_329.LinkedResource;
70
68
  };
71
69
  get(): any;
72
70
  }
@@ -84,27 +82,27 @@ declare class CreatorResource {
84
82
  constructor(inputData: any, vault: Vault);
85
83
  get(): any;
86
84
  getSpecificResource(): {
87
- created?: string | undefined;
88
- generated?: string | undefined;
89
- modified?: string | undefined;
90
- creator?: _iiif_presentation_329.Creator | undefined;
91
- generator?: _iiif_presentation_329.Creator | undefined;
92
- audience?: (_iiif_presentation_329.Audience | _iiif_presentation_329.Audience[]) | undefined;
93
- accessibility?: string | string[] | undefined;
94
- motivation?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
95
- rights?: string | string[] | undefined;
96
- canonical?: string | undefined;
97
- via?: string | string[] | undefined;
98
- role?: string | undefined;
99
- id?: string | undefined;
85
+ created?: string;
86
+ generated?: string;
87
+ modified?: string;
88
+ creator?: import("@iiif/presentation-3").Creator;
89
+ generator?: import("@iiif/presentation-3").Creator;
90
+ audience?: import("@iiif/presentation-3").Audience | import("@iiif/presentation-3").Audience[];
91
+ accessibility?: string | string[];
92
+ motivation?: import("@iiif/presentation-3").AnyMotivation | import("@iiif/presentation-3").AnyMotivation[];
93
+ rights?: string | string[];
94
+ canonical?: string;
95
+ via?: string | string[];
96
+ role?: string;
97
+ id?: string;
100
98
  type: "SpecificResource";
101
- state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
102
- purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
99
+ state?: import("@iiif/presentation-3").State | import("@iiif/presentation-3").State[];
100
+ purpose?: import("@iiif/presentation-3").AnyMotivation | import("@iiif/presentation-3").AnyMotivation[];
103
101
  source?: any;
104
- selector?: (_iiif_presentation_329.Selector | _iiif_presentation_329.Selector[]) | undefined;
105
- styleClass?: string | undefined;
106
- renderedVia?: (_iiif_presentation_329.Agent | _iiif_presentation_329.Agent[]) | undefined;
107
- scope?: _iiif_presentation_329.LinkedResource;
102
+ selector?: import("@iiif/presentation-3").Selector | import("@iiif/presentation-3").Selector[];
103
+ styleClass?: string;
104
+ renderedVia?: import("@iiif/presentation-3").Agent | import("@iiif/presentation-3").Agent[];
105
+ scope?: import("@iiif/presentation-3").LinkedResource;
108
106
  } | {
109
107
  type: string;
110
108
  source: {
@@ -113,27 +111,27 @@ declare class CreatorResource {
113
111
  };
114
112
  };
115
113
  ref(): {
116
- created?: string | undefined;
117
- generated?: string | undefined;
118
- modified?: string | undefined;
119
- creator?: _iiif_presentation_329.Creator | undefined;
120
- generator?: _iiif_presentation_329.Creator | undefined;
121
- audience?: (_iiif_presentation_329.Audience | _iiif_presentation_329.Audience[]) | undefined;
122
- accessibility?: string | string[] | undefined;
123
- motivation?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
124
- rights?: string | string[] | undefined;
125
- canonical?: string | undefined;
126
- via?: string | string[] | undefined;
127
- role?: string | undefined;
128
- id?: string | undefined;
114
+ created?: string;
115
+ generated?: string;
116
+ modified?: string;
117
+ creator?: import("@iiif/presentation-3").Creator;
118
+ generator?: import("@iiif/presentation-3").Creator;
119
+ audience?: import("@iiif/presentation-3").Audience | import("@iiif/presentation-3").Audience[];
120
+ accessibility?: string | string[];
121
+ motivation?: import("@iiif/presentation-3").AnyMotivation | import("@iiif/presentation-3").AnyMotivation[];
122
+ rights?: string | string[];
123
+ canonical?: string;
124
+ via?: string | string[];
125
+ role?: string;
126
+ id?: string;
129
127
  type: "SpecificResource";
130
- state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
131
- purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
128
+ state?: import("@iiif/presentation-3").State | import("@iiif/presentation-3").State[];
129
+ purpose?: import("@iiif/presentation-3").AnyMotivation | import("@iiif/presentation-3").AnyMotivation[];
132
130
  source?: any;
133
- selector?: (_iiif_presentation_329.Selector | _iiif_presentation_329.Selector[]) | undefined;
134
- styleClass?: string | undefined;
135
- renderedVia?: (_iiif_presentation_329.Agent | _iiif_presentation_329.Agent[]) | undefined;
136
- scope?: _iiif_presentation_329.LinkedResource;
131
+ selector?: import("@iiif/presentation-3").Selector | import("@iiif/presentation-3").Selector[];
132
+ styleClass?: string;
133
+ renderedVia?: import("@iiif/presentation-3").Agent | import("@iiif/presentation-3").Agent[];
134
+ scope?: import("@iiif/presentation-3").LinkedResource;
137
135
  } | {
138
136
  id: any;
139
137
  type: any;
@@ -150,13 +148,15 @@ declare class CreatorInstance implements CreatorFunctionContext {
150
148
  previewVault: Vault;
151
149
  configs: CreatorDefinition[];
152
150
  options: CreatorOptions;
151
+ config: Record<string, unknown>;
152
+ creatorConfig: CreatorConfig;
153
153
  target: CreatorOptions["target"];
154
154
  selector: SupportedSelector | undefined | null;
155
155
  serialisedSelector: {
156
156
  type: string;
157
157
  value: string;
158
158
  } | null;
159
- constructor(vault: Vault, options: CreatorOptions, createConfigs: CreatorDefinition[], previewVault: Vault);
159
+ constructor(vault: Vault, options: CreatorOptions, createConfigs: CreatorDefinition[], previewVault: Vault, configKey: string, creatorConfig?: CreatorConfig);
160
160
  getPreviewVault(): Vault;
161
161
  setSelector(selector: SupportedSelector): void;
162
162
  getSerialisedSelector(): {
@@ -176,7 +176,7 @@ declare class CreatorInstance implements CreatorFunctionContext {
176
176
  }
177
177
  //#endregion
178
178
  //#region src/creator-register.d.ts
179
- declare function defineCreator<const Payload$1 = any, const ID$1 = Readonly<string>, const ResourceType$1 extends AllAvailableParentTypes = never, const AdditionalResourceTypes$1 extends Array<AllAvailableParentTypes> = [], const AllResourceTypes$1 = [ResourceType$1, ...AdditionalResourceTypes$1], const SupportsParentTypes$1 extends Array<AllAvailableParentTypes> = AllParentTypes, const SupportsParentFields$1 extends Array<AllProperties> = [], const CreateReturnType$1 = any>(options: SpecificCreatorDefinition<Payload$1, ID$1, ResourceType$1, AdditionalResourceTypes$1, AllResourceTypes$1, SupportsParentTypes$1, SupportsParentFields$1, CreateReturnType$1>): SpecificCreatorDefinition<Payload$1, ID$1, ResourceType$1, AdditionalResourceTypes$1, AllResourceTypes$1, SupportsParentTypes$1, SupportsParentFields$1, CreateReturnType$1>;
179
+ declare function defineCreator<const Payload = any, const ID = Readonly<string>, const ResourceType extends AllAvailableParentTypes = never, const AdditionalResourceTypes extends Array<AllAvailableParentTypes> = [], const AllResourceTypes = [ResourceType, ...AdditionalResourceTypes], const SupportsParentTypes extends Array<AllAvailableParentTypes> = AllParentTypes, const SupportsParentFields extends Array<AllProperties> = [], const CreateReturnType = any>(options: SpecificCreatorDefinition<Payload, ID, ResourceType, AdditionalResourceTypes, AllResourceTypes, SupportsParentTypes, SupportsParentFields, CreateReturnType>): SpecificCreatorDefinition<Payload, ID, ResourceType, AdditionalResourceTypes, AllResourceTypes, SupportsParentTypes, SupportsParentFields, CreateReturnType>;
180
180
  declare function withInitialData<T extends CreatorDefinition>(creator: T, data: Record<string, any>, overrides?: Record<string, any>): T;
181
181
  declare function withCustomRender<T extends CreatorDefinition>(creator: T, render: (ctx: CreatorContext<any>, originalRender: (ctx: CreatorContext<any>) => React.ReactNode) => React.ReactNode): T;
182
182
  declare namespace IIIFManifestEditor {
@@ -195,13 +195,14 @@ type ExtractCreatorGenerics<T extends CreatorDefinition> = T extends SpecificCre
195
195
  type CreatorSupportsParentTypes<T, Type extends AllAvailableParentTypes> = T extends CreatorDefinition ? ExtractCreatorGenerics<T>["SupportsParentTypes"] extends never ? false : HelperInArray<Type, ExtractCreatorGenerics<T>["SupportsParentTypes"]> : false;
196
196
  type CreatorSupportsParentFields<T, Field extends AllProperties> = T extends CreatorDefinition ? ExtractCreatorGenerics<T>["SupportsParentFields"] extends never ? false : HelperInArray<Field, ExtractCreatorGenerics<T>["SupportsParentFields"]> : false;
197
197
  type CreatorSupportsParent<T, Type extends AllAvailableParentTypes, Field extends AllProperties> = T extends CreatorDefinition ? CreatorSupportsParentTypes<T, Type> extends true ? CreatorSupportsParentFields<T, Field> extends true ? true : false : false : false;
198
- type HelperInArray<ToFind, Array$1 extends readonly any[]> = Array$1 extends readonly [infer Head, ...infer Tail] ? Head extends ToFind ? true : HelperInArray<ToFind, Tail> : false;
199
- type CreatorDefinitionFilterByParent<Type extends AllAvailableParentTypes, Field extends AllProperties = AllProperties, CD extends IIIFManifestEditor.CreatorDefinitions = IIIFManifestEditor.CreatorDefinitions> = { [K in keyof CD]: CreatorSupportsParent<CD[K], Type, Field> extends true ? CD[K] : never }[keyof CD];
198
+ type HelperInArray<ToFind, Array extends readonly any[]> = Array extends readonly [infer Head, ...infer Tail] ? Head extends ToFind ? true : HelperInArray<ToFind, Tail> : false;
199
+ type CreatorDefinitionFilterByParent<Type extends AllAvailableParentTypes, Field extends AllProperties = AllProperties, CD extends IIIFManifestEditor.CreatorDefinitions = IIIFManifestEditor.CreatorDefinitions> = { [K in keyof CD]: CreatorSupportsParent<CD[K], Type, Field> extends true ? CD[K] : never; }[keyof CD];
200
200
  //#endregion
201
201
  //#region src/types.d.ts
202
202
  interface CreatorContext<T = any> {
203
203
  vault: Vault;
204
204
  options: CreatorOptions;
205
+ config?: Record<string, unknown>;
205
206
  validate: (payload: T) => Promise<boolean> | boolean;
206
207
  runCreate: (payload: T) => void;
207
208
  }
@@ -209,6 +210,7 @@ type ResolvedCreatorReturn<T extends CreatorDefinition> = Awaited<ExtractCreator
209
210
  interface CreatorFunctionContext {
210
211
  vault: Vault;
211
212
  options: CreatorOptions;
213
+ config: Record<string, unknown>;
212
214
  ref(idOrRef: string | Reference): ReferencedResource;
213
215
  embed(data: any): CreatorResource;
214
216
  create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource | CreatorResource[]>;
@@ -232,24 +234,51 @@ interface CreatorOptions {
232
234
  initialData?: any;
233
235
  rootId?: string;
234
236
  }
237
+ type CreatorConfig = Record<string, Record<string, unknown>>;
238
+ type CreatorConfigField = {
239
+ id: string;
240
+ type: "checkbox";
241
+ label: string;
242
+ summary?: string;
243
+ defaultValue?: boolean;
244
+ };
245
+ interface CreatorConfiguration {
246
+ fields: CreatorConfigField[];
247
+ }
248
+ interface CreatorResourceProbeHelpers {
249
+ json(url: string): Promise<any>;
250
+ text(url: string): Promise<string>;
251
+ head(url: string): Promise<Response>;
252
+ contentType(url: string): Promise<string>;
253
+ }
254
+ type CreatorResourceProbeResult = boolean | {
255
+ initialData?: Record<string, any>;
256
+ label?: string;
257
+ };
235
258
  type AllAvailableParentTypes = keyof typeof resources.supported;
236
259
  type GetSupportedResourceFields<Resource extends AllAvailableParentTypes> = {} & (typeof resources.supported)[Resource]["allowed"][number];
237
260
  type AllProperties = ({} & keyof LinkingProperties) | ({} & keyof StructuralProperties<any>) | ({} & keyof TechnicalProperties) | ({} & keyof DescriptiveProperties) | ({} & keyof Annotation) | ({} & keyof NavPlaceExtension);
238
261
  type AllParentTypes = ["Collection", "Manifest", "Canvas", "Annotation", "AnnotationPage", "Range", "AnnotationCollection", "ContentResource", "Agent"];
239
- interface SpecificCreatorDefinition<Payload$1 = any, ID$1 = Readonly<string>, ResourceType$1 extends AllAvailableParentTypes = never, AdditionalResourceTypes$1 extends Array<AllAvailableParentTypes> = [], AllResourceTypes$1 = [ResourceType$1, ...AdditionalResourceTypes$1], SupportsParentTypes$1 extends Array<AllAvailableParentTypes> = AllParentTypes, SupportsParentFields$1 extends Array<AllProperties> = [], CreateReturnType$1 = any | Promise<any> | any[] | Promise<any[]>> {
240
- readonly id: ID$1;
262
+ interface SpecificCreatorDefinition<Payload = any, ID = Readonly<string>, ResourceType extends AllAvailableParentTypes = never, AdditionalResourceTypes extends Array<AllAvailableParentTypes> = [], AllResourceTypes = [ResourceType, ...AdditionalResourceTypes], SupportsParentTypes extends Array<AllAvailableParentTypes> = AllParentTypes, SupportsParentFields extends Array<AllProperties> = [], CreateReturnType = any | Promise<any> | any[] | Promise<any[]>> {
263
+ readonly id: ID;
241
264
  label: string;
242
265
  summary?: string;
243
266
  icon?: any;
244
267
  dependencies?: string[];
245
268
  tags?: string[];
246
- create: (payload: Payload$1, ctx: CreatorInstance) => CreateReturnType$1;
247
- validate?: (payload: Payload$1, vault: Vault) => void | Promise<void>;
248
- render?: (ctx: CreatorContext<Payload$1>) => ReactNode;
249
- renderCanvas?: (ctx: CreatorContext<Payload$1>) => ReactNode | null;
250
- renderModal?: (ctx: CreatorContext<Payload$1>) => ReactNode;
251
- resourceType: ResourceType$1;
252
- additionalTypes?: AdditionalResourceTypes$1;
269
+ configuration?: CreatorConfiguration;
270
+ readonly configKey?: string;
271
+ create: (payload: Payload, ctx: CreatorInstance) => CreateReturnType;
272
+ validate?: (payload: Payload, vault: Vault) => void | Promise<void>;
273
+ supportsResource?: (value: string, helpers: CreatorResourceProbeHelpers, ctx: {
274
+ vault: Vault;
275
+ resource: CreatableResource;
276
+ }) => CreatorResourceProbeResult | Promise<CreatorResourceProbeResult>;
277
+ render?: (ctx: CreatorContext<Payload>) => ReactNode;
278
+ renderCanvas?: (ctx: CreatorContext<Payload>) => ReactNode | null;
279
+ renderModal?: (ctx: CreatorContext<Payload>) => ReactNode;
280
+ resourceType: ResourceType;
281
+ additionalTypes?: AdditionalResourceTypes;
253
282
  actionButton?: string;
254
283
  resourceFields: string[];
255
284
  embeddedResources?: string[];
@@ -258,8 +287,8 @@ interface SpecificCreatorDefinition<Payload$1 = any, ID$1 = Readonly<string>, Re
258
287
  hiddenModal?: boolean;
259
288
  supports: {
260
289
  initialData?: boolean;
261
- parentTypes?: SupportsParentTypes$1;
262
- parentFields?: SupportsParentFields$1;
290
+ parentTypes?: SupportsParentTypes;
291
+ parentFields?: SupportsParentFields;
263
292
  parentFieldMap?: Record<string, string[]>;
264
293
  custom?: (parent: CreatorParent, vault: Vault) => boolean;
265
294
  disallowPainting?: boolean;
@@ -267,7 +296,7 @@ interface SpecificCreatorDefinition<Payload$1 = any, ID$1 = Readonly<string>, Re
267
296
  };
268
297
  sideEffects?: Array<CreatorSideEffect>;
269
298
  }
270
- type CreatorDefinition<Payload$1 = any> = SpecificCreatorDefinition<Payload$1, any, any, any, any, any, any>;
299
+ type CreatorDefinition<Payload = any> = SpecificCreatorDefinition<Payload, any, any, any, any, any, any>;
271
300
  interface CreatorSideEffect {
272
301
  run?: (result: any, ctx: {
273
302
  options: CreatorOptions;
@@ -296,22 +325,24 @@ declare class Creator {
296
325
  configs: CreatorDefinition[];
297
326
  vault: Vault;
298
327
  previewVault: Vault;
299
- constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault);
328
+ creatorConfig: CreatorConfig;
329
+ constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault, creatorConfig?: CreatorConfig);
300
330
  matchBasedOnResource(resource: CreatableResource): CreatorDefinition[];
301
331
  create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference | Reference[]>;
302
332
  }
303
333
  //#endregion
304
334
  //#region src/utils.d.ts
335
+ declare function getCreatorConfigKey(definition: CreatorDefinition): string;
305
336
  declare function resolveType(type: string): keyof Entities;
306
337
  declare function getEmptyType(type: string): any;
307
338
  declare function randomId(): string;
308
339
  declare function matchBasedOnResource(resource: CreatableResource, list: CreatorDefinition[], options: {
309
340
  vault: Vault;
310
341
  }): CreatorDefinition[];
311
- declare function creatorHelper<const ResourceType$1 extends AllAvailableParentTypes, const Parent extends {
342
+ declare function creatorHelper<const ResourceType extends AllAvailableParentTypes, const Parent extends {
312
343
  id: string;
313
- type: ResourceType$1;
314
- }, const ResourceField extends GetSupportedResourceFields<ResourceType$1>, const CID extends CreatorDefinitionFilterByParent<ResourceType$1, ResourceField>["id"], Payload$1 = GetCreatorPayload<IIIFManifestEditor.CreatorDefinitions[CID]>, Return = ResolvedCreatorReturn<IIIFManifestEditor.CreatorDefinitions[CID]>>(ctx: CreatorFunctionContext, parent: Parent | ResourceType$1, property: ResourceField, definition: CID): (payload: Payload$1, options?: Partial<CreatorOptions>) => Promise<Return>;
344
+ type: ResourceType;
345
+ }, const ResourceField extends GetSupportedResourceFields<ResourceType>, const CID extends CreatorDefinitionFilterByParent<ResourceType, ResourceField>["id"], Payload = GetCreatorPayload<IIIFManifestEditor.CreatorDefinitions[CID]>, Return = ResolvedCreatorReturn<IIIFManifestEditor.CreatorDefinitions[CID]>>(ctx: CreatorFunctionContext, parent: Parent | ResourceType, property: ResourceField, definition: CID): (payload: Payload, options?: Partial<CreatorOptions>) => Promise<Return>;
315
346
  //#endregion
316
- export { AllAvailableParentTypes, AllParentTypes, AllProperties, CreatableResource, Creator, CreatorContext, CreatorDefinition, CreatorDefinitionFilterByParent, CreatorFunctionContext, CreatorOptions, CreatorResource, CreatorSideEffect, ExtractCreatorGenerics, GetCreatorPayload, GetSupportedResourceFields, IIIFManifestEditor, ResolvedCreatorReturn, SpecificCreatorDefinition, creatorHelper, defineCreator, getEmptyType, matchBasedOnResource, randomId, resolveType, withCustomRender, withInitialData };
347
+ export { AllAvailableParentTypes, AllParentTypes, AllProperties, CreatableResource, Creator, CreatorConfig, CreatorConfigField, CreatorConfiguration, CreatorContext, CreatorDefinition, CreatorDefinitionFilterByParent, CreatorFunctionContext, CreatorOptions, CreatorResource, CreatorResourceProbeHelpers, CreatorResourceProbeResult, CreatorSideEffect, ExtractCreatorGenerics, GetCreatorPayload, GetSupportedResourceFields, IIIFManifestEditor, ResolvedCreatorReturn, SpecificCreatorDefinition, creatorHelper, defineCreator, getCreatorConfigKey, getEmptyType, matchBasedOnResource, randomId, resolveType, withCustomRender, withInitialData };
317
348
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/ReferencedResource.ts","../src/CreatorResource.ts","../src/CreatorInstance.ts","../src/creator-register.ts","../src/types.ts","../src/Creator.ts","../src/utils.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAIa,kBAAA;SACJ;YACG,YAAY;aACX;YACD;yBACa,YAAY,yBAAyB;EALjD,GAAA,CAAA,CAAA,EAAA;IACJ,IAAA,EAAA,MAAA;IACG,EAAA,EAAA,MAAA;EAAY,CAAA;EACX,gBAAA,CAAA,CAAA,EAAA;IACD,OAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IACa,SAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IAAY,QAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IAAyB,OAAA,CAAA,EAAK,sBAAA,CAAA,OAAA,GAAL,SAAA;IAAK,SAAA,CAAA,mCAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ICFtD,MAAA,CAAA,EAAA,MAAe,GAAA,MAAA,EAAA,GAAA,SAAA;IAKd,SAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IACF,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;IACH,IAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IACY,EAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IAEgB,IAAA,EAAA,kBAAA;IAAK,KAAA,CAAA,EAAA,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B,OAAA;WACF;SACF;gBACO;qBAEK,gBAAgB,oCAAoC;ELR5D,oBAAA,CAAkB,QAAA,EKcE,iBLdF,CAAA,EKcmB,iBLdnB,EAAA;EACtB,MAAA,CAAA,UAAA,EAAA,MAAA,EAAA,OAAA,EAAA,GAAA,EAAA,OAAA,CAAA,EKiBkD,OLjBlD,CKiB0D,cLjB1D,CAAA,CAAA,EKiB4E,OLjB5E,CKiBoF,SLjBpF,GKiBgG,SLjBhG,EAAA,CAAA;;;;iBMsBO,WAAA,sBAAiC;iBAkCjC,YAAA;iBAKA,QAAA,CAAA;iBAIA,oBAAA,WACJ,yBACJ;SACY;ANrEpB,CAAA,CAAA,EMsEG,iBNtEU,EAAA;AACJ,iBM8IO,aN9IP,CAAA,6BM+IoB,uBN/IpB,EAAA,qBAAA;EACG,EAAA,EAAA,MAAA;EAAY,IAAA,EM+ImB,cN/InB;CACX,EAAA,4BM+IiB,0BN/IjB,CM+I4C,cN/I5C,CAAA,EAAA,kBMgJO,+BNhJP,CMiJT,cNjJS,EMkJT,aNlJS,CAAA,CAAA,IAAA,CAAA,EAAA,YMoJD,iBNpJC,CMoJiB,kBAAA,CAAmB,kBNpJpC,CMoJuD,GNpJvD,CAAA,CAAA,EAAA,SMqJF,qBNrJE,CMqJoB,kBAAA,CAAmB,kBNrJvC,CMqJ0D,GNrJ1D,CAAA,CAAA,CAAA,CAAA,GAAA,EMuJN,sBNvJM,EAAA,MAAA,EMwJH,MNxJG,GMwJM,cNxJN,EAAA,QAAA,EMyJD,aNzJC,EAAA,UAAA,EM0JC,GN1JD,CAAA,EAAA,CAAA,OAAA,EM2JA,SN3JA,EAAA,OAAA,CAAA,EM2JmB,ON3JnB,CM2J2B,cN3J3B,CAAA,EAAA,GM2J+C,ON3J/C,CM2JuD,MN3JvD,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/ReferencedResource.ts","../src/CreatorResource.ts","../src/CreatorInstance.ts","../src/creator-register.ts","../src/types.ts","../src/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