@manifest-editor/creator-api 1.3.0 → 1.3.1
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 +10 -8
- package/dist/index.d.ts +10 -8
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -138,12 +138,14 @@ interface CreatorFunctionContext {
|
|
|
138
138
|
ref(idOrRef: string | Reference): ReferencedResource;
|
|
139
139
|
embed(data: any): CreatorResource;
|
|
140
140
|
create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource>;
|
|
141
|
+
create<Definition extends CreatorDefinition = any>(definition: Definition["id"], payload: GetCreatorPayload<Definition>, options?: Partial<CreatorOptions>): Promise<CreatorResource>;
|
|
141
142
|
generateId(type: string, parent?: Reference | ReferencedResource): string;
|
|
142
143
|
getParent(): Reference | undefined;
|
|
143
144
|
getTarget(): SpecificResource | Reference | undefined;
|
|
144
145
|
getParentResource(): SpecificResource | undefined;
|
|
145
146
|
getPreviewVault(): Vault;
|
|
146
147
|
}
|
|
148
|
+
type GetCreatorPayload<T extends CreatorDefinition> = T extends CreatorDefinition<infer Payload> ? Payload : never;
|
|
147
149
|
interface CreatorParent {
|
|
148
150
|
resource: Reference;
|
|
149
151
|
property: string;
|
|
@@ -155,18 +157,18 @@ interface CreatorOptions {
|
|
|
155
157
|
parent?: CreatorParent;
|
|
156
158
|
initialData?: any;
|
|
157
159
|
}
|
|
158
|
-
interface CreatorDefinition {
|
|
160
|
+
interface CreatorDefinition<Payload = any> {
|
|
159
161
|
id: string;
|
|
160
162
|
label: string;
|
|
161
163
|
summary?: string;
|
|
162
164
|
icon?: any;
|
|
163
165
|
dependencies?: string[];
|
|
164
166
|
tags?: string[];
|
|
165
|
-
create: (payload:
|
|
166
|
-
validate?: (payload:
|
|
167
|
-
render?: (ctx: CreatorContext) => ReactNode;
|
|
168
|
-
renderCanvas?: (ctx: CreatorContext) => ReactNode | null;
|
|
169
|
-
renderModal?: (ctx: CreatorContext) => ReactNode;
|
|
167
|
+
create: (payload: Payload, ctx: CreatorInstance) => any | Promise<any>;
|
|
168
|
+
validate?: (payload: Payload, vault: Vault) => void | Promise<void>;
|
|
169
|
+
render?: (ctx: CreatorContext<Payload>) => ReactNode;
|
|
170
|
+
renderCanvas?: (ctx: CreatorContext<Payload>) => ReactNode | null;
|
|
171
|
+
renderModal?: (ctx: CreatorContext<Payload>) => ReactNode;
|
|
170
172
|
resourceType: string;
|
|
171
173
|
additionalTypes?: string[];
|
|
172
174
|
resourceFields: string[];
|
|
@@ -212,7 +214,7 @@ declare class Creator {
|
|
|
212
214
|
vault: Vault;
|
|
213
215
|
previewVault: Vault;
|
|
214
216
|
constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault);
|
|
215
|
-
matchBasedOnResource(resource: CreatableResource): CreatorDefinition[];
|
|
217
|
+
matchBasedOnResource(resource: CreatableResource): CreatorDefinition<any>[];
|
|
216
218
|
create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference>;
|
|
217
219
|
}
|
|
218
220
|
|
|
@@ -223,4 +225,4 @@ declare function matchBasedOnResource(resource: CreatableResource, list: Creator
|
|
|
223
225
|
vault: Vault;
|
|
224
226
|
}): CreatorDefinition[];
|
|
225
227
|
|
|
226
|
-
export { type CreatableResource, Creator, type CreatorContext, type CreatorDefinition, type CreatorFunctionContext, type CreatorOptions, CreatorResource, type CreatorSideEffect, getEmptyType, matchBasedOnResource, randomId, resolveType };
|
|
228
|
+
export { type CreatableResource, Creator, type CreatorContext, type CreatorDefinition, type CreatorFunctionContext, type CreatorOptions, CreatorResource, type CreatorSideEffect, type GetCreatorPayload, getEmptyType, matchBasedOnResource, randomId, resolveType };
|
package/dist/index.d.ts
CHANGED
|
@@ -138,12 +138,14 @@ interface CreatorFunctionContext {
|
|
|
138
138
|
ref(idOrRef: string | Reference): ReferencedResource;
|
|
139
139
|
embed(data: any): CreatorResource;
|
|
140
140
|
create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource>;
|
|
141
|
+
create<Definition extends CreatorDefinition = any>(definition: Definition["id"], payload: GetCreatorPayload<Definition>, options?: Partial<CreatorOptions>): Promise<CreatorResource>;
|
|
141
142
|
generateId(type: string, parent?: Reference | ReferencedResource): string;
|
|
142
143
|
getParent(): Reference | undefined;
|
|
143
144
|
getTarget(): SpecificResource | Reference | undefined;
|
|
144
145
|
getParentResource(): SpecificResource | undefined;
|
|
145
146
|
getPreviewVault(): Vault;
|
|
146
147
|
}
|
|
148
|
+
type GetCreatorPayload<T extends CreatorDefinition> = T extends CreatorDefinition<infer Payload> ? Payload : never;
|
|
147
149
|
interface CreatorParent {
|
|
148
150
|
resource: Reference;
|
|
149
151
|
property: string;
|
|
@@ -155,18 +157,18 @@ interface CreatorOptions {
|
|
|
155
157
|
parent?: CreatorParent;
|
|
156
158
|
initialData?: any;
|
|
157
159
|
}
|
|
158
|
-
interface CreatorDefinition {
|
|
160
|
+
interface CreatorDefinition<Payload = any> {
|
|
159
161
|
id: string;
|
|
160
162
|
label: string;
|
|
161
163
|
summary?: string;
|
|
162
164
|
icon?: any;
|
|
163
165
|
dependencies?: string[];
|
|
164
166
|
tags?: string[];
|
|
165
|
-
create: (payload:
|
|
166
|
-
validate?: (payload:
|
|
167
|
-
render?: (ctx: CreatorContext) => ReactNode;
|
|
168
|
-
renderCanvas?: (ctx: CreatorContext) => ReactNode | null;
|
|
169
|
-
renderModal?: (ctx: CreatorContext) => ReactNode;
|
|
167
|
+
create: (payload: Payload, ctx: CreatorInstance) => any | Promise<any>;
|
|
168
|
+
validate?: (payload: Payload, vault: Vault) => void | Promise<void>;
|
|
169
|
+
render?: (ctx: CreatorContext<Payload>) => ReactNode;
|
|
170
|
+
renderCanvas?: (ctx: CreatorContext<Payload>) => ReactNode | null;
|
|
171
|
+
renderModal?: (ctx: CreatorContext<Payload>) => ReactNode;
|
|
170
172
|
resourceType: string;
|
|
171
173
|
additionalTypes?: string[];
|
|
172
174
|
resourceFields: string[];
|
|
@@ -212,7 +214,7 @@ declare class Creator {
|
|
|
212
214
|
vault: Vault;
|
|
213
215
|
previewVault: Vault;
|
|
214
216
|
constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault);
|
|
215
|
-
matchBasedOnResource(resource: CreatableResource): CreatorDefinition[];
|
|
217
|
+
matchBasedOnResource(resource: CreatableResource): CreatorDefinition<any>[];
|
|
216
218
|
create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference>;
|
|
217
219
|
}
|
|
218
220
|
|
|
@@ -223,4 +225,4 @@ declare function matchBasedOnResource(resource: CreatableResource, list: Creator
|
|
|
223
225
|
vault: Vault;
|
|
224
226
|
}): CreatorDefinition[];
|
|
225
227
|
|
|
226
|
-
export { type CreatableResource, Creator, type CreatorContext, type CreatorDefinition, type CreatorFunctionContext, type CreatorOptions, CreatorResource, type CreatorSideEffect, getEmptyType, matchBasedOnResource, randomId, resolveType };
|
|
228
|
+
export { type CreatableResource, Creator, type CreatorContext, type CreatorDefinition, type CreatorFunctionContext, type CreatorOptions, CreatorResource, type CreatorSideEffect, type GetCreatorPayload, getEmptyType, matchBasedOnResource, randomId, resolveType };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manifest-editor/creator-api",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bugs": "https://github.com/digirati-co-uk/iiif-manifest-editor/issues",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@iiif/parser": "^2.1.7",
|
|
47
47
|
"@iiif/presentation-3": "^2.2.3",
|
|
48
48
|
"@iiif/presentation-3-normalized": "^0.9.7",
|
|
49
|
-
"@manifest-editor/editor-api": "1.3.
|
|
49
|
+
"@manifest-editor/editor-api": "1.3.1",
|
|
50
50
|
"polygon-editor": "^0.0.6",
|
|
51
51
|
"react-iiif-vault": "^1.2.1"
|
|
52
52
|
},
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "920fe405869996394c204c6eae70f446aab78986"
|
|
63
63
|
}
|