@manifest-editor/creator-api 1.0.2

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.
@@ -0,0 +1,204 @@
1
+ import * as _iiif_presentation_3 from '@iiif/presentation-3';
2
+ import { Reference, SpecificResource } from '@iiif/presentation-3';
3
+ import { Vault } from '@iiif/helpers/vault';
4
+ import { ReactNode } from 'react';
5
+
6
+ declare class ReferencedResource {
7
+ vault: Vault;
8
+ original: Reference | SpecificResource;
9
+ reference: Reference;
10
+ resource: SpecificResource;
11
+ constructor(reference: Reference | SpecificResource, vault: Vault);
12
+ ref(): {
13
+ type: string;
14
+ id: string;
15
+ };
16
+ specificResource(): {
17
+ created?: string | undefined;
18
+ generated?: string | undefined;
19
+ modified?: string | undefined;
20
+ creator?: _iiif_presentation_3.Creator | undefined;
21
+ generator?: _iiif_presentation_3.Creator | undefined;
22
+ audience?: _iiif_presentation_3.Audience | _iiif_presentation_3.Audience[] | undefined;
23
+ accessibility?: string | string[] | undefined;
24
+ motivation?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
25
+ rights?: string | string[] | undefined;
26
+ canonical?: string | undefined;
27
+ via?: string | string[] | undefined;
28
+ role?: string | undefined;
29
+ id?: string | undefined;
30
+ type: "SpecificResource";
31
+ state?: _iiif_presentation_3.State | _iiif_presentation_3.State[] | undefined;
32
+ purpose?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
33
+ source?: any;
34
+ selector?: _iiif_presentation_3.Selector | _iiif_presentation_3.Selector[] | undefined;
35
+ styleClass?: string | undefined;
36
+ renderedVia?: _iiif_presentation_3.Agent | _iiif_presentation_3.Agent[] | undefined;
37
+ scope?: any;
38
+ };
39
+ optionalSpecificResource(): {
40
+ type: string;
41
+ id: string;
42
+ } | {
43
+ source: {
44
+ id: any;
45
+ type: any;
46
+ };
47
+ created?: string | undefined;
48
+ generated?: string | undefined;
49
+ modified?: string | undefined;
50
+ creator?: _iiif_presentation_3.Creator | undefined;
51
+ generator?: _iiif_presentation_3.Creator | undefined;
52
+ audience?: _iiif_presentation_3.Audience | _iiif_presentation_3.Audience[] | undefined;
53
+ accessibility?: string | string[] | undefined;
54
+ motivation?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
55
+ rights?: string | string[] | undefined;
56
+ canonical?: string | undefined;
57
+ via?: string | string[] | undefined;
58
+ role?: string | undefined;
59
+ id?: string | undefined;
60
+ type: "SpecificResource";
61
+ state?: _iiif_presentation_3.State | _iiif_presentation_3.State[] | undefined;
62
+ purpose?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
63
+ selector?: _iiif_presentation_3.Selector | _iiif_presentation_3.Selector[] | undefined;
64
+ styleClass?: string | undefined;
65
+ renderedVia?: _iiif_presentation_3.Agent | _iiif_presentation_3.Agent[] | undefined;
66
+ scope?: any;
67
+ };
68
+ get(): any;
69
+ }
70
+
71
+ declare class CreatorResource {
72
+ resource: any;
73
+ warnings: string[];
74
+ errors: string[];
75
+ partOf: any;
76
+ references: ReferencedResource[];
77
+ embedded: CreatorResource[];
78
+ vault: Vault;
79
+ specificResource?: SpecificResource;
80
+ constructor(data: any, vault: Vault);
81
+ get(): any;
82
+ ref(): {
83
+ created?: string | undefined;
84
+ generated?: string | undefined;
85
+ modified?: string | undefined;
86
+ creator?: _iiif_presentation_3.Creator | undefined;
87
+ generator?: _iiif_presentation_3.Creator | undefined;
88
+ audience?: _iiif_presentation_3.Audience | _iiif_presentation_3.Audience[] | undefined;
89
+ accessibility?: string | string[] | undefined;
90
+ motivation?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
91
+ rights?: string | string[] | undefined;
92
+ canonical?: string | undefined;
93
+ via?: string | string[] | undefined;
94
+ role?: string | undefined;
95
+ id?: string | undefined;
96
+ type: "SpecificResource";
97
+ state?: _iiif_presentation_3.State | _iiif_presentation_3.State[] | undefined;
98
+ purpose?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
99
+ source?: any;
100
+ selector?: _iiif_presentation_3.Selector | _iiif_presentation_3.Selector[] | undefined;
101
+ styleClass?: string | undefined;
102
+ renderedVia?: _iiif_presentation_3.Agent | _iiif_presentation_3.Agent[] | undefined;
103
+ scope?: any;
104
+ } | {
105
+ id: any;
106
+ type: any;
107
+ };
108
+ getAllReferencedResources(): ReferencedResource[];
109
+ getAllEmbeddedResources(): CreatorResource[];
110
+ getVaultResource(): any;
111
+ setPartOf(id: string): void;
112
+ }
113
+
114
+ declare class CreatorInstance implements CreatorFunctionContext {
115
+ vault: Vault;
116
+ previewVault: Vault;
117
+ configs: CreatorDefinition[];
118
+ options: CreatorOptions;
119
+ constructor(vault: Vault, options: CreatorOptions, createConfigs: CreatorDefinition[], previewVault: Vault);
120
+ getPreviewVault(): Vault;
121
+ getTarget(): SpecificResource | Reference | undefined;
122
+ getParent(): Reference | undefined;
123
+ getParentResource(): SpecificResource | undefined;
124
+ generateId(type: string, parent?: Reference | ReferencedResource): string;
125
+ ref(idOrRef: string | Reference): ReferencedResource;
126
+ embed(data: any): CreatorResource;
127
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource>;
128
+ }
129
+
130
+ interface CreatorContext<T = any> {
131
+ vault: Vault;
132
+ options: CreatorOptions;
133
+ validate: (payload: T) => Promise<boolean> | boolean;
134
+ runCreate: (payload: T) => void;
135
+ }
136
+ interface CreatorFunctionContext {
137
+ options: CreatorOptions;
138
+ ref(idOrRef: string | Reference): ReferencedResource;
139
+ embed(data: any): CreatorResource;
140
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource>;
141
+ generateId(type: string, parent?: Reference | ReferencedResource): string;
142
+ getParent(): Reference | undefined;
143
+ getTarget(): SpecificResource | Reference | undefined;
144
+ getParentResource(): SpecificResource | undefined;
145
+ getPreviewVault(): Vault;
146
+ }
147
+ interface CreatorParent {
148
+ resource: Reference;
149
+ property: string;
150
+ atIndex?: number;
151
+ }
152
+ interface CreatorOptions {
153
+ targetType: string;
154
+ target?: Reference;
155
+ parent?: CreatorParent;
156
+ initialData?: any;
157
+ }
158
+ interface CreatorDefinition {
159
+ id: string;
160
+ label: string;
161
+ summary?: string;
162
+ icon?: any;
163
+ dependencies?: string[];
164
+ create: (payload: any, ctx: CreatorInstance) => any | Promise<any>;
165
+ validate?: (payload: any, vault: Vault) => void | Promise<void>;
166
+ render?: (ctx: CreatorContext) => ReactNode;
167
+ renderCanvas?: (ctx: CreatorContext) => ReactNode | null;
168
+ renderModal?: (ctx: CreatorContext) => ReactNode;
169
+ resourceType: string;
170
+ additionalTypes?: string[];
171
+ resourceFields: string[];
172
+ embeddedResources?: string[];
173
+ staticFields?: Record<string, any>;
174
+ allowModal?: boolean;
175
+ supports: {
176
+ initialData?: boolean;
177
+ parentTypes?: string[];
178
+ parentFields?: string[];
179
+ parentFieldMap?: Record<string, string[]>;
180
+ custom?: (parent: CreatorParent, vault: Vault) => boolean;
181
+ disallowPainting?: boolean;
182
+ };
183
+ sideEffects?: Array<CreatorSideEffect>;
184
+ }
185
+ interface CreatorSideEffect {
186
+ run?: (result: any, ctx: {
187
+ options: CreatorOptions;
188
+ vault: Vault;
189
+ }) => void | Promise<void>;
190
+ temporal?: boolean;
191
+ spatial?: boolean;
192
+ replaceSiblings?: boolean;
193
+ canvasInteraction?: boolean;
194
+ }
195
+
196
+ declare class Creator {
197
+ configs: CreatorDefinition[];
198
+ vault: Vault;
199
+ previewVault: Vault;
200
+ constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault);
201
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference>;
202
+ }
203
+
204
+ export { Creator, type CreatorContext, type CreatorDefinition, type CreatorFunctionContext, type CreatorOptions, CreatorResource, type CreatorSideEffect };
@@ -0,0 +1,204 @@
1
+ import * as _iiif_presentation_3 from '@iiif/presentation-3';
2
+ import { Reference, SpecificResource } from '@iiif/presentation-3';
3
+ import { Vault } from '@iiif/helpers/vault';
4
+ import { ReactNode } from 'react';
5
+
6
+ declare class ReferencedResource {
7
+ vault: Vault;
8
+ original: Reference | SpecificResource;
9
+ reference: Reference;
10
+ resource: SpecificResource;
11
+ constructor(reference: Reference | SpecificResource, vault: Vault);
12
+ ref(): {
13
+ type: string;
14
+ id: string;
15
+ };
16
+ specificResource(): {
17
+ created?: string | undefined;
18
+ generated?: string | undefined;
19
+ modified?: string | undefined;
20
+ creator?: _iiif_presentation_3.Creator | undefined;
21
+ generator?: _iiif_presentation_3.Creator | undefined;
22
+ audience?: _iiif_presentation_3.Audience | _iiif_presentation_3.Audience[] | undefined;
23
+ accessibility?: string | string[] | undefined;
24
+ motivation?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
25
+ rights?: string | string[] | undefined;
26
+ canonical?: string | undefined;
27
+ via?: string | string[] | undefined;
28
+ role?: string | undefined;
29
+ id?: string | undefined;
30
+ type: "SpecificResource";
31
+ state?: _iiif_presentation_3.State | _iiif_presentation_3.State[] | undefined;
32
+ purpose?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
33
+ source?: any;
34
+ selector?: _iiif_presentation_3.Selector | _iiif_presentation_3.Selector[] | undefined;
35
+ styleClass?: string | undefined;
36
+ renderedVia?: _iiif_presentation_3.Agent | _iiif_presentation_3.Agent[] | undefined;
37
+ scope?: any;
38
+ };
39
+ optionalSpecificResource(): {
40
+ type: string;
41
+ id: string;
42
+ } | {
43
+ source: {
44
+ id: any;
45
+ type: any;
46
+ };
47
+ created?: string | undefined;
48
+ generated?: string | undefined;
49
+ modified?: string | undefined;
50
+ creator?: _iiif_presentation_3.Creator | undefined;
51
+ generator?: _iiif_presentation_3.Creator | undefined;
52
+ audience?: _iiif_presentation_3.Audience | _iiif_presentation_3.Audience[] | undefined;
53
+ accessibility?: string | string[] | undefined;
54
+ motivation?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
55
+ rights?: string | string[] | undefined;
56
+ canonical?: string | undefined;
57
+ via?: string | string[] | undefined;
58
+ role?: string | undefined;
59
+ id?: string | undefined;
60
+ type: "SpecificResource";
61
+ state?: _iiif_presentation_3.State | _iiif_presentation_3.State[] | undefined;
62
+ purpose?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
63
+ selector?: _iiif_presentation_3.Selector | _iiif_presentation_3.Selector[] | undefined;
64
+ styleClass?: string | undefined;
65
+ renderedVia?: _iiif_presentation_3.Agent | _iiif_presentation_3.Agent[] | undefined;
66
+ scope?: any;
67
+ };
68
+ get(): any;
69
+ }
70
+
71
+ declare class CreatorResource {
72
+ resource: any;
73
+ warnings: string[];
74
+ errors: string[];
75
+ partOf: any;
76
+ references: ReferencedResource[];
77
+ embedded: CreatorResource[];
78
+ vault: Vault;
79
+ specificResource?: SpecificResource;
80
+ constructor(data: any, vault: Vault);
81
+ get(): any;
82
+ ref(): {
83
+ created?: string | undefined;
84
+ generated?: string | undefined;
85
+ modified?: string | undefined;
86
+ creator?: _iiif_presentation_3.Creator | undefined;
87
+ generator?: _iiif_presentation_3.Creator | undefined;
88
+ audience?: _iiif_presentation_3.Audience | _iiif_presentation_3.Audience[] | undefined;
89
+ accessibility?: string | string[] | undefined;
90
+ motivation?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
91
+ rights?: string | string[] | undefined;
92
+ canonical?: string | undefined;
93
+ via?: string | string[] | undefined;
94
+ role?: string | undefined;
95
+ id?: string | undefined;
96
+ type: "SpecificResource";
97
+ state?: _iiif_presentation_3.State | _iiif_presentation_3.State[] | undefined;
98
+ purpose?: _iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[] | undefined;
99
+ source?: any;
100
+ selector?: _iiif_presentation_3.Selector | _iiif_presentation_3.Selector[] | undefined;
101
+ styleClass?: string | undefined;
102
+ renderedVia?: _iiif_presentation_3.Agent | _iiif_presentation_3.Agent[] | undefined;
103
+ scope?: any;
104
+ } | {
105
+ id: any;
106
+ type: any;
107
+ };
108
+ getAllReferencedResources(): ReferencedResource[];
109
+ getAllEmbeddedResources(): CreatorResource[];
110
+ getVaultResource(): any;
111
+ setPartOf(id: string): void;
112
+ }
113
+
114
+ declare class CreatorInstance implements CreatorFunctionContext {
115
+ vault: Vault;
116
+ previewVault: Vault;
117
+ configs: CreatorDefinition[];
118
+ options: CreatorOptions;
119
+ constructor(vault: Vault, options: CreatorOptions, createConfigs: CreatorDefinition[], previewVault: Vault);
120
+ getPreviewVault(): Vault;
121
+ getTarget(): SpecificResource | Reference | undefined;
122
+ getParent(): Reference | undefined;
123
+ getParentResource(): SpecificResource | undefined;
124
+ generateId(type: string, parent?: Reference | ReferencedResource): string;
125
+ ref(idOrRef: string | Reference): ReferencedResource;
126
+ embed(data: any): CreatorResource;
127
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource>;
128
+ }
129
+
130
+ interface CreatorContext<T = any> {
131
+ vault: Vault;
132
+ options: CreatorOptions;
133
+ validate: (payload: T) => Promise<boolean> | boolean;
134
+ runCreate: (payload: T) => void;
135
+ }
136
+ interface CreatorFunctionContext {
137
+ options: CreatorOptions;
138
+ ref(idOrRef: string | Reference): ReferencedResource;
139
+ embed(data: any): CreatorResource;
140
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource>;
141
+ generateId(type: string, parent?: Reference | ReferencedResource): string;
142
+ getParent(): Reference | undefined;
143
+ getTarget(): SpecificResource | Reference | undefined;
144
+ getParentResource(): SpecificResource | undefined;
145
+ getPreviewVault(): Vault;
146
+ }
147
+ interface CreatorParent {
148
+ resource: Reference;
149
+ property: string;
150
+ atIndex?: number;
151
+ }
152
+ interface CreatorOptions {
153
+ targetType: string;
154
+ target?: Reference;
155
+ parent?: CreatorParent;
156
+ initialData?: any;
157
+ }
158
+ interface CreatorDefinition {
159
+ id: string;
160
+ label: string;
161
+ summary?: string;
162
+ icon?: any;
163
+ dependencies?: string[];
164
+ create: (payload: any, ctx: CreatorInstance) => any | Promise<any>;
165
+ validate?: (payload: any, vault: Vault) => void | Promise<void>;
166
+ render?: (ctx: CreatorContext) => ReactNode;
167
+ renderCanvas?: (ctx: CreatorContext) => ReactNode | null;
168
+ renderModal?: (ctx: CreatorContext) => ReactNode;
169
+ resourceType: string;
170
+ additionalTypes?: string[];
171
+ resourceFields: string[];
172
+ embeddedResources?: string[];
173
+ staticFields?: Record<string, any>;
174
+ allowModal?: boolean;
175
+ supports: {
176
+ initialData?: boolean;
177
+ parentTypes?: string[];
178
+ parentFields?: string[];
179
+ parentFieldMap?: Record<string, string[]>;
180
+ custom?: (parent: CreatorParent, vault: Vault) => boolean;
181
+ disallowPainting?: boolean;
182
+ };
183
+ sideEffects?: Array<CreatorSideEffect>;
184
+ }
185
+ interface CreatorSideEffect {
186
+ run?: (result: any, ctx: {
187
+ options: CreatorOptions;
188
+ vault: Vault;
189
+ }) => void | Promise<void>;
190
+ temporal?: boolean;
191
+ spatial?: boolean;
192
+ replaceSiblings?: boolean;
193
+ canvasInteraction?: boolean;
194
+ }
195
+
196
+ declare class Creator {
197
+ configs: CreatorDefinition[];
198
+ vault: Vault;
199
+ previewVault: Vault;
200
+ constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault);
201
+ create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference>;
202
+ }
203
+
204
+ export { Creator, type CreatorContext, type CreatorDefinition, type CreatorFunctionContext, type CreatorOptions, CreatorResource, type CreatorSideEffect };