@manifest-editor/creator-api 1.4.2 → 2.0.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.d.cts CHANGED
@@ -1,273 +1,315 @@
1
- import { Vault, Entities } from '@iiif/helpers/vault';
2
- import * as _iiif_presentation_3 from '@iiif/presentation-3';
3
- import { Reference, SpecificResource, LinkingProperties, StructuralProperties, TechnicalProperties, DescriptiveProperties, Annotation, NavPlaceExtension } from '@iiif/presentation-3';
4
- import { resources } from '@manifest-editor/editor-api';
5
- import { ReactNode } from 'react';
1
+ import { Entities, Vault } from "@iiif/helpers/vault";
2
+ import * as _iiif_presentation_329 from "@iiif/presentation-3";
3
+ import { Annotation, DescriptiveProperties, LinkingProperties, NavPlaceExtension, Reference, SpecificResource, StructuralProperties, TechnicalProperties } from "@iiif/presentation-3";
4
+ import { resources } from "@manifest-editor/editor-api";
5
+ import { ReactNode } from "react";
6
+ import { SupportedSelector } from "@iiif/helpers";
6
7
 
8
+ //#region src/ReferencedResource.d.ts
7
9
  declare class ReferencedResource {
8
- vault: Vault;
9
- original: Reference | SpecificResource;
10
- reference: Reference;
11
- resource: SpecificResource;
12
- constructor(reference: Reference | SpecificResource, vault: Vault);
13
- ref(): {
14
- type: string;
15
- id: string;
16
- };
17
- specificResource(): {
18
- created?: string | undefined;
19
- generated?: string | undefined;
20
- modified?: string | undefined;
21
- creator?: _iiif_presentation_3.Creator | undefined;
22
- generator?: _iiif_presentation_3.Creator | undefined;
23
- audience?: (_iiif_presentation_3.Audience | _iiif_presentation_3.Audience[]) | undefined;
24
- accessibility?: string | string[] | undefined;
25
- motivation?: (_iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[]) | undefined;
26
- rights?: string | string[] | undefined;
27
- canonical?: string | undefined;
28
- via?: string | string[] | undefined;
29
- role?: string | undefined;
30
- id?: string | undefined;
31
- type: "SpecificResource";
32
- state?: (_iiif_presentation_3.State | _iiif_presentation_3.State[]) | undefined;
33
- purpose?: (_iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[]) | undefined;
34
- source?: any;
35
- selector?: (_iiif_presentation_3.Selector | _iiif_presentation_3.Selector[]) | undefined;
36
- styleClass?: string | undefined;
37
- renderedVia?: (_iiif_presentation_3.Agent | _iiif_presentation_3.Agent[]) | undefined;
38
- scope?: _iiif_presentation_3.LinkedResource;
39
- };
40
- optionalSpecificResource(): {
41
- type: string;
42
- id: string;
43
- } | {
44
- source: {
45
- id: any;
46
- type: any;
47
- };
48
- created?: string | undefined;
49
- generated?: string | undefined;
50
- modified?: string | undefined;
51
- creator?: _iiif_presentation_3.Creator | undefined;
52
- generator?: _iiif_presentation_3.Creator | undefined;
53
- audience?: (_iiif_presentation_3.Audience | _iiif_presentation_3.Audience[]) | undefined;
54
- accessibility?: string | string[] | undefined;
55
- motivation?: (_iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[]) | undefined;
56
- rights?: string | string[] | undefined;
57
- canonical?: string | undefined;
58
- via?: string | string[] | undefined;
59
- role?: string | undefined;
60
- id?: string | undefined;
61
- type: "SpecificResource";
62
- state?: (_iiif_presentation_3.State | _iiif_presentation_3.State[]) | undefined;
63
- purpose?: (_iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[]) | undefined;
64
- selector?: (_iiif_presentation_3.Selector | _iiif_presentation_3.Selector[]) | undefined;
65
- styleClass?: string | undefined;
66
- renderedVia?: (_iiif_presentation_3.Agent | _iiif_presentation_3.Agent[]) | undefined;
67
- scope?: _iiif_presentation_3.LinkedResource;
10
+ vault: Vault;
11
+ original: Reference | SpecificResource;
12
+ reference: Reference;
13
+ resource: SpecificResource;
14
+ constructor(reference: Reference | SpecificResource, vault: Vault);
15
+ ref(): {
16
+ type: string;
17
+ id: string;
18
+ };
19
+ 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;
33
+ type: "SpecificResource";
34
+ state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
35
+ purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
36
+ 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;
41
+ };
42
+ optionalSpecificResource(): {
43
+ type: string;
44
+ id: string;
45
+ } | {
46
+ source: {
47
+ id: any;
48
+ type: any;
68
49
  };
69
- get(): any;
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
+ };
71
+ get(): any;
70
72
  }
71
-
73
+ //#endregion
74
+ //#region src/CreatorResource.d.ts
72
75
  declare class CreatorResource {
73
- resource: any;
74
- warnings: string[];
75
- errors: string[];
76
- partOf: any;
77
- references: ReferencedResource[];
78
- embedded: CreatorResource[];
79
- vault: Vault;
80
- specificResource?: SpecificResource;
81
- constructor(inputData: any, vault: Vault);
82
- get(): any;
83
- ref(): {
84
- created?: string | undefined;
85
- generated?: string | undefined;
86
- modified?: string | undefined;
87
- creator?: _iiif_presentation_3.Creator | undefined;
88
- generator?: _iiif_presentation_3.Creator | undefined;
89
- audience?: (_iiif_presentation_3.Audience | _iiif_presentation_3.Audience[]) | undefined;
90
- accessibility?: string | string[] | undefined;
91
- motivation?: (_iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[]) | undefined;
92
- rights?: string | string[] | undefined;
93
- canonical?: string | undefined;
94
- via?: string | string[] | undefined;
95
- role?: string | undefined;
96
- id?: string | undefined;
97
- type: "SpecificResource";
98
- state?: (_iiif_presentation_3.State | _iiif_presentation_3.State[]) | undefined;
99
- purpose?: (_iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[]) | undefined;
100
- source?: any;
101
- selector?: (_iiif_presentation_3.Selector | _iiif_presentation_3.Selector[]) | undefined;
102
- styleClass?: string | undefined;
103
- renderedVia?: (_iiif_presentation_3.Agent | _iiif_presentation_3.Agent[]) | undefined;
104
- scope?: _iiif_presentation_3.LinkedResource;
105
- } | {
106
- id: any;
107
- type: any;
76
+ resource: any;
77
+ warnings: string[];
78
+ errors: string[];
79
+ partOf: any;
80
+ references: ReferencedResource[];
81
+ embedded: CreatorResource[];
82
+ vault: Vault;
83
+ specificResource?: SpecificResource;
84
+ constructor(inputData: any, vault: Vault);
85
+ get(): any;
86
+ 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;
100
+ type: "SpecificResource";
101
+ state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
102
+ purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
103
+ 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;
108
+ } | {
109
+ type: string;
110
+ source: {
111
+ id: any;
112
+ type: any;
108
113
  };
109
- getAllReferencedResources(): ReferencedResource[];
110
- getAllEmbeddedResources(): CreatorResource[];
111
- getVaultResource(): any;
112
- setPartOf(id: string): void;
114
+ };
115
+ 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;
129
+ type: "SpecificResource";
130
+ state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
131
+ purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
132
+ 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;
137
+ } | {
138
+ id: any;
139
+ type: any;
140
+ };
141
+ getAllReferencedResources(): ReferencedResource[];
142
+ getAllEmbeddedResources(): CreatorResource[];
143
+ getVaultResource(): any;
144
+ setPartOf(id: string): void;
113
145
  }
114
-
146
+ //#endregion
147
+ //#region src/CreatorInstance.d.ts
115
148
  declare class CreatorInstance implements CreatorFunctionContext {
116
- vault: Vault;
117
- previewVault: Vault;
118
- configs: CreatorDefinition[];
119
- options: CreatorOptions;
120
- constructor(vault: Vault, options: CreatorOptions, createConfigs: CreatorDefinition[], previewVault: Vault);
121
- getPreviewVault(): Vault;
122
- getTarget(): SpecificResource | Reference | undefined;
123
- getParent(): Reference | undefined;
124
- getParentResource(): SpecificResource | undefined;
125
- generateId(type: string, parent?: Reference | ReferencedResource): string;
126
- ref(idOrRef: string | Reference): ReferencedResource;
127
- embed(data: any): CreatorResource;
128
- create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<any>;
149
+ vault: Vault;
150
+ previewVault: Vault;
151
+ configs: CreatorDefinition[];
152
+ options: CreatorOptions;
153
+ target: CreatorOptions["target"];
154
+ selector: SupportedSelector | undefined | null;
155
+ serialisedSelector: {
156
+ type: string;
157
+ value: string;
158
+ } | null;
159
+ constructor(vault: Vault, options: CreatorOptions, createConfigs: CreatorDefinition[], previewVault: Vault);
160
+ getPreviewVault(): Vault;
161
+ setSelector(selector: SupportedSelector): void;
162
+ getSerialisedSelector(): {
163
+ type: "SvgSelector";
164
+ id: string;
165
+ } | {
166
+ type: string;
167
+ value: string;
168
+ } | null;
169
+ getTarget(): SpecificResource | Reference | undefined;
170
+ getParent(): Reference | undefined;
171
+ getParentResource(): SpecificResource | undefined;
172
+ generateId(type: string, parent?: Reference | ReferencedResource): string;
173
+ ref(idOrRef: string | Reference): ReferencedResource;
174
+ embed(data: any): CreatorResource;
175
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<any>;
129
176
  }
130
-
131
- 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>;
177
+ //#endregion
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>;
132
180
  declare namespace IIIFManifestEditor {
133
- interface CreatorDefinitions {
134
- }
181
+ interface CreatorDefinitions {}
135
182
  }
136
183
  type ExtractCreatorGenerics<T extends CreatorDefinition> = T extends SpecificCreatorDefinition<infer Payload, infer ID, infer ResourceType, infer AdditionalResourceTypes, infer AllResourceTypes, infer SupportsParentTypes, infer SupportsParentFields, infer CreateReturnType> ? {
137
- Payload: Payload;
138
- ID: ID;
139
- ResourceType: ResourceType;
140
- AdditionalResourceTypes: AdditionalResourceTypes;
141
- AllResourceTypes: AllResourceTypes;
142
- SupportsParentTypes: SupportsParentTypes;
143
- SupportsParentFields: SupportsParentFields;
144
- CreateReturnType: CreateReturnType;
184
+ Payload: Payload;
185
+ ID: ID;
186
+ ResourceType: ResourceType;
187
+ AdditionalResourceTypes: AdditionalResourceTypes;
188
+ AllResourceTypes: AllResourceTypes;
189
+ SupportsParentTypes: SupportsParentTypes;
190
+ SupportsParentFields: SupportsParentFields;
191
+ CreateReturnType: CreateReturnType;
145
192
  } : never;
146
193
  type CreatorSupportsParentTypes<T, Type extends AllAvailableParentTypes> = T extends CreatorDefinition ? ExtractCreatorGenerics<T>["SupportsParentTypes"] extends never ? false : HelperInArray<Type, ExtractCreatorGenerics<T>["SupportsParentTypes"]> : false;
147
194
  type CreatorSupportsParentFields<T, Field extends AllProperties> = T extends CreatorDefinition ? ExtractCreatorGenerics<T>["SupportsParentFields"] extends never ? false : HelperInArray<Field, ExtractCreatorGenerics<T>["SupportsParentFields"]> : false;
148
195
  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;
149
- type HelperInArray<ToFind, Array extends readonly any[]> = Array extends readonly [infer Head, ...infer Tail] ? Head extends ToFind ? true : HelperInArray<ToFind, Tail> : false;
150
- type CreatorDefinitionFilterByParent<Type extends AllAvailableParentTypes, Field extends AllProperties = AllProperties, CD extends IIIFManifestEditor.CreatorDefinitions = IIIFManifestEditor.CreatorDefinitions> = {
151
- [K in keyof CD]: CreatorSupportsParent<CD[K], Type, Field> extends true ? CD[K] : never;
152
- }[keyof CD];
153
-
196
+ type HelperInArray<ToFind, Array$1 extends readonly any[]> = Array$1 extends readonly [infer Head, ...infer Tail] ? Head extends ToFind ? true : HelperInArray<ToFind, Tail> : false;
197
+ 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
+ //#endregion
199
+ //#region src/types.d.ts
154
200
  interface CreatorContext<T = any> {
155
- vault: Vault;
156
- options: CreatorOptions;
157
- validate: (payload: T) => Promise<boolean> | boolean;
158
- runCreate: (payload: T) => void;
201
+ vault: Vault;
202
+ options: CreatorOptions;
203
+ validate: (payload: T) => Promise<boolean> | boolean;
204
+ runCreate: (payload: T) => void;
159
205
  }
160
206
  type ResolvedCreatorReturn<T extends CreatorDefinition> = Awaited<ExtractCreatorGenerics<T>["CreateReturnType"]> extends any[] ? CreatorResource[] : CreatorResource;
161
207
  interface CreatorFunctionContext {
162
- vault: Vault;
163
- options: CreatorOptions;
164
- ref(idOrRef: string | Reference): ReferencedResource;
165
- embed(data: any): CreatorResource;
166
- create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource | CreatorResource[]>;
167
- create<Definition extends CreatorDefinition = any>(definition: Definition["id"], payload: GetCreatorPayload<Definition>, options?: Partial<CreatorOptions>): Promise<ResolvedCreatorReturn<Definition>>;
168
- generateId(type: string, parent?: Reference | ReferencedResource): string;
169
- getParent(): Reference | undefined;
170
- getTarget(): SpecificResource | Reference | undefined;
171
- getParentResource(): SpecificResource | undefined;
172
- getPreviewVault(): Vault;
208
+ vault: Vault;
209
+ options: CreatorOptions;
210
+ ref(idOrRef: string | Reference): ReferencedResource;
211
+ embed(data: any): CreatorResource;
212
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource | CreatorResource[]>;
213
+ create<Definition extends CreatorDefinition = any>(definition: Definition["id"], payload: GetCreatorPayload<Definition>, options?: Partial<CreatorOptions>): Promise<ResolvedCreatorReturn<Definition>>;
214
+ generateId(type: string, parent?: Reference | ReferencedResource): string;
215
+ getParent(): Reference | undefined;
216
+ getTarget(): SpecificResource | Reference | undefined;
217
+ getParentResource(): SpecificResource | undefined;
218
+ getPreviewVault(): Vault;
173
219
  }
174
220
  type GetCreatorPayload<T extends CreatorDefinition> = T extends CreatorDefinition<infer Payload> ? Payload : never;
175
221
  interface CreatorParent {
176
- resource: Reference;
177
- property: string;
178
- atIndex?: number;
222
+ resource: Reference;
223
+ property: string;
224
+ atIndex?: number;
179
225
  }
180
226
  interface CreatorOptions {
181
- targetType: string;
182
- target?: Reference;
183
- parent?: CreatorParent;
184
- initialData?: any;
227
+ targetType: string;
228
+ target?: Reference;
229
+ parent?: CreatorParent;
230
+ initialData?: any;
231
+ rootId?: string;
185
232
  }
186
233
  type AllAvailableParentTypes = keyof typeof resources.supported;
187
234
  type GetSupportedResourceFields<Resource extends AllAvailableParentTypes> = {} & (typeof resources.supported)[Resource]["allowed"][number];
188
235
  type AllProperties = ({} & keyof LinkingProperties) | ({} & keyof StructuralProperties<any>) | ({} & keyof TechnicalProperties) | ({} & keyof DescriptiveProperties) | ({} & keyof Annotation) | ({} & keyof NavPlaceExtension);
189
- type AllParentTypes = [
190
- "Collection",
191
- "Manifest",
192
- "Canvas",
193
- "Annotation",
194
- "AnnotationPage",
195
- "Range",
196
- "AnnotationCollection",
197
- "ContentResource",
198
- "Agent"
199
- ];
200
- 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[]>> {
201
- readonly id: ID;
202
- label: string;
203
- summary?: string;
204
- icon?: any;
205
- dependencies?: string[];
206
- tags?: string[];
207
- create: (payload: Payload, ctx: CreatorInstance) => CreateReturnType;
208
- validate?: (payload: Payload, vault: Vault) => void | Promise<void>;
209
- render?: (ctx: CreatorContext<Payload>) => ReactNode;
210
- renderCanvas?: (ctx: CreatorContext<Payload>) => ReactNode | null;
211
- renderModal?: (ctx: CreatorContext<Payload>) => ReactNode;
212
- resourceType: ResourceType;
213
- additionalTypes?: AdditionalResourceTypes;
214
- resourceFields: string[];
215
- embeddedResources?: string[];
216
- staticFields?: Record<string, any>;
217
- allowModal?: boolean;
218
- hiddenModal?: boolean;
219
- supports: {
220
- initialData?: boolean;
221
- parentTypes?: SupportsParentTypes;
222
- parentFields?: SupportsParentFields;
223
- parentFieldMap?: Record<string, string[]>;
224
- custom?: (parent: CreatorParent, vault: Vault) => boolean;
225
- disallowPainting?: boolean;
226
- };
227
- sideEffects?: Array<CreatorSideEffect>;
236
+ type AllParentTypes = ["Collection", "Manifest", "Canvas", "Annotation", "AnnotationPage", "Range", "AnnotationCollection", "ContentResource", "Agent"];
237
+ 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[]>> {
238
+ readonly id: ID$1;
239
+ label: string;
240
+ summary?: string;
241
+ icon?: any;
242
+ dependencies?: string[];
243
+ tags?: string[];
244
+ create: (payload: Payload$1, ctx: CreatorInstance) => CreateReturnType$1;
245
+ validate?: (payload: Payload$1, vault: Vault) => void | Promise<void>;
246
+ render?: (ctx: CreatorContext<Payload$1>) => ReactNode;
247
+ renderCanvas?: (ctx: CreatorContext<Payload$1>) => ReactNode | null;
248
+ renderModal?: (ctx: CreatorContext<Payload$1>) => ReactNode;
249
+ resourceType: ResourceType$1;
250
+ additionalTypes?: AdditionalResourceTypes$1;
251
+ actionButton?: string;
252
+ resourceFields: string[];
253
+ embeddedResources?: string[];
254
+ staticFields?: Record<string, any>;
255
+ allowModal?: boolean;
256
+ hiddenModal?: boolean;
257
+ supports: {
258
+ initialData?: boolean;
259
+ parentTypes?: SupportsParentTypes$1;
260
+ parentFields?: SupportsParentFields$1;
261
+ parentFieldMap?: Record<string, string[]>;
262
+ custom?: (parent: CreatorParent, vault: Vault) => boolean;
263
+ disallowPainting?: boolean;
264
+ onlyPainting?: boolean;
265
+ };
266
+ sideEffects?: Array<CreatorSideEffect>;
228
267
  }
229
- type CreatorDefinition<Payload = any> = SpecificCreatorDefinition<Payload, any, any, any, any, any, any>;
268
+ type CreatorDefinition<Payload$1 = any> = SpecificCreatorDefinition<Payload$1, any, any, any, any, any, any>;
230
269
  interface CreatorSideEffect {
231
- run?: (result: any, ctx: {
232
- options: CreatorOptions;
233
- vault: Vault;
234
- }) => void | Promise<void>;
235
- temporal?: boolean;
236
- spatial?: boolean;
237
- replaceSiblings?: boolean;
238
- canvasInteraction?: boolean;
270
+ run?: (result: any, ctx: {
271
+ options: CreatorOptions;
272
+ vault: Vault;
273
+ }) => void | Promise<void>;
274
+ temporal?: boolean;
275
+ spatial?: boolean;
276
+ replaceSiblings?: boolean;
277
+ canvasInteraction?: boolean;
239
278
  }
240
279
  interface CreatableResource {
241
- type: string;
242
- parent?: Reference;
243
- property?: string;
244
- index?: number;
245
- onlyReference?: boolean;
246
- target?: Reference;
247
- initialData?: any;
248
- isPainting?: boolean;
249
- filter?: string;
250
- initialCreator?: string;
280
+ type: string;
281
+ parent?: Reference;
282
+ property?: string;
283
+ index?: number;
284
+ onlyReference?: boolean;
285
+ target?: Reference;
286
+ initialData?: any;
287
+ isPainting?: boolean;
288
+ filter?: string;
289
+ initialCreator?: string;
251
290
  }
252
-
291
+ //#endregion
292
+ //#region src/Creator.d.ts
253
293
  declare class Creator {
254
- configs: CreatorDefinition[];
255
- vault: Vault;
256
- previewVault: Vault;
257
- constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault);
258
- matchBasedOnResource(resource: CreatableResource): CreatorDefinition[];
259
- create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference | Reference[]>;
294
+ configs: CreatorDefinition[];
295
+ vault: Vault;
296
+ previewVault: Vault;
297
+ constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault);
298
+ matchBasedOnResource(resource: CreatableResource): CreatorDefinition[];
299
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference | Reference[]>;
260
300
  }
261
-
301
+ //#endregion
302
+ //#region src/utils.d.ts
262
303
  declare function resolveType(type: string): keyof Entities;
263
304
  declare function getEmptyType(type: string): any;
264
305
  declare function randomId(): string;
265
306
  declare function matchBasedOnResource(resource: CreatableResource, list: CreatorDefinition[], options: {
266
- vault: Vault;
307
+ vault: Vault;
267
308
  }): CreatorDefinition[];
268
- declare function creatorHelper<const ResourceType extends AllAvailableParentTypes, const Parent extends {
269
- id: string;
270
- type: ResourceType;
271
- }, 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>;
272
-
273
- export { type AllAvailableParentTypes, type AllParentTypes, type AllProperties, type CreatableResource, Creator, type CreatorContext, type CreatorDefinition, type CreatorDefinitionFilterByParent, type CreatorFunctionContext, type CreatorOptions, CreatorResource, type CreatorSideEffect, type ExtractCreatorGenerics, type GetCreatorPayload, type GetSupportedResourceFields, IIIFManifestEditor, type ResolvedCreatorReturn, type SpecificCreatorDefinition, creatorHelper, defineCreator, getEmptyType, matchBasedOnResource, randomId, resolveType };
309
+ declare function creatorHelper<const ResourceType$1 extends AllAvailableParentTypes, const Parent extends {
310
+ id: string;
311
+ type: ResourceType$1;
312
+ }, 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>;
313
+ //#endregion
314
+ 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 };
315
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +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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