@dosgato/templating 0.0.29 → 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.
@@ -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: <T>(query: string, variables?: any) => Promise<T>, page: PageRecord, path: string) => Promise<ValidationFeedback[]>;
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {