@dosgato/templating 0.0.27 → 0.0.30
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/apitemplate.d.ts +14 -5
- package/package.json +1 -1
package/dist/apitemplate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PageRecord, ComponentData
|
|
1
|
+
import { PageRecord, ComponentData } from './component.js';
|
|
2
2
|
import { LinkDefinition } from './links.js';
|
|
3
3
|
export declare type APITemplateType = 'page' | 'component' | 'data';
|
|
4
4
|
export declare enum ValidationMessageType {
|
|
@@ -7,7 +7,7 @@ export declare enum ValidationMessageType {
|
|
|
7
7
|
SUCCESS = "success"
|
|
8
8
|
}
|
|
9
9
|
export interface ValidationFeedback {
|
|
10
|
-
type
|
|
10
|
+
type?: `${ValidationMessageType}`;
|
|
11
11
|
path?: string;
|
|
12
12
|
message: string;
|
|
13
13
|
}
|
|
@@ -66,7 +66,7 @@ export interface APITemplate {
|
|
|
66
66
|
* available as parameters in case you need them. Keep in mind that the current editor MUST
|
|
67
67
|
* have access to any data you attempt to query in GraphQL.
|
|
68
68
|
*/
|
|
69
|
-
validate?: (data: ComponentData, query:
|
|
69
|
+
validate?: (data: ComponentData, query: GraphQLQueryFn, page: PageRecord, path: string) => Promise<ValidationFeedback[]>;
|
|
70
70
|
/**
|
|
71
71
|
* Hard-coded properties that may be set on page templates to influence the rendering of
|
|
72
72
|
* components on the page. For instance, a set of color choices that are customized for
|
|
@@ -97,14 +97,23 @@ export interface APITemplate {
|
|
|
97
97
|
*
|
|
98
98
|
* Your `up` and `down` methods will be applied to components in bottom-up fashion, so you
|
|
99
99
|
* can assume that any components inside one of your areas has already been processed.
|
|
100
|
+
*
|
|
101
|
+
* All migration functions receive a `query` function for making a graphql query, in case the
|
|
102
|
+
* migration depends on the state of a parent page or something. Be careful not
|
|
103
|
+
* to create an infinite loop - querying a page will trigger that page to be migrated, which
|
|
104
|
+
* could end up calling your code again on that page.
|
|
105
|
+
*
|
|
106
|
+
* If you're migrating a component template, you'll also get the page record and the
|
|
107
|
+
* path inside that page's data to the component being migrated.
|
|
100
108
|
*/
|
|
101
109
|
export interface Migration {
|
|
102
110
|
createdAt: Date;
|
|
103
|
-
up: (data: ComponentData, page: PageRecord) => ComponentData | Promise<ComponentData>;
|
|
104
|
-
down: (data: ComponentData, page: PageRecord) => ComponentData | Promise<ComponentData>;
|
|
111
|
+
up: (data: ComponentData, query: GraphQLQueryFn, page: PageRecord, path: string) => ComponentData | Promise<ComponentData>;
|
|
112
|
+
down: (data: ComponentData, query: GraphQLQueryFn, page: PageRecord, path: string) => ComponentData | Promise<ComponentData>;
|
|
105
113
|
}
|
|
106
114
|
export declare type LinkGatheringFn = (data: any) => LinkDefinition[];
|
|
107
115
|
export declare type FulltextGatheringFn = (data: any) => string[];
|
|
116
|
+
export declare type GraphQLQueryFn = <T>(query: string, variables?: any) => Promise<T>;
|
|
108
117
|
/**
|
|
109
118
|
* This function is used by API template definitions to help them identify links inside large blocks
|
|
110
119
|
* of text and return them for indexing.
|