@dosgato/templating 0.0.49 → 0.0.52

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.
@@ -20,10 +20,10 @@ export interface ValidationFeedback {
20
20
  export interface PageExtras {
21
21
  /** A function for executing a graphql query to acquire more information than is already at hand. */
22
22
  query: GraphQLQueryFn;
23
- /** The site id in which the page lives or is being created. */
24
- siteId: string;
25
- /** The pagetree id in which the page lives or is being created. */
26
- pagetreeId: string;
23
+ /** The site id in which the page lives or is being created. Null if we are validating creation of a site. */
24
+ siteId?: string;
25
+ /** The pagetree id in which the page lives or is being created. Null if we are validating creation of a site or pagetree. */
26
+ pagetreeId?: string;
27
27
  /** The page id of the page's parent or parent-to-be. Null if it is the root page of a pagetree. */
28
28
  parentId?: string;
29
29
  /** The page's id, presumably to be used in graphql queries. NOTE: will be null during page creation. */
@@ -73,13 +73,13 @@ export interface APITemplate {
73
73
  * can be indexed. Only fields that are links need to be returned. Links inside rich editor
74
74
  * text will be extracted automatically from any text returned by getFulltext (see below)
75
75
  */
76
- getLinks: LinkGatheringFn;
76
+ getLinks?: LinkGatheringFn;
77
77
  /**
78
78
  * Each template must provide the text from any text or rich editor data it possesses, so that
79
79
  * the text can be decomposed into words and indexed for fulltext searches. Any text returned
80
80
  * by this function will also be scanned for links.
81
81
  */
82
- getFulltext: FulltextGatheringFn;
82
+ getFulltext?: FulltextGatheringFn;
83
83
  }
84
84
  export interface APIComponentTemplate extends APITemplate {
85
85
  type: 'component';
@@ -107,25 +107,25 @@ export interface APIComponentTemplate extends APITemplate {
107
107
  *
108
108
  * See the ComponentExtras type to see all the contextual information you'll have available.
109
109
  */
110
- validate?: (data: ComponentData, extras: ComponentExtras) => Promise<ValidationFeedback[]>;
110
+ validate?: <T extends ComponentData>(data: T, extras: ComponentExtras) => Promise<ValidationFeedback[]>;
111
111
  /**
112
112
  * Each template must provide a list of migrations for upgrading the data schema over time.
113
113
  * Typically this will start as an empty array and migrations will be added as the template
114
114
  * gets refactored.
115
115
  */
116
- migrations: ComponentMigration[];
116
+ migrations?: ComponentMigration[];
117
117
  }
118
118
  export interface APIPageTemplate extends APITemplate {
119
119
  type: 'page';
120
120
  /**
121
121
  * Page areas are the same as components but are required.
122
122
  */
123
- areas: Record<string, string[]>;
123
+ areas?: Record<string, string[]>;
124
124
  /**
125
125
  * Page template implementations do not receive a path like component templates do.
126
126
  */
127
- validate?: (data: PageData, extras: PageExtras) => Promise<ValidationFeedback[]>;
128
- migrations: PageMigration[];
127
+ validate?: <T extends PageData>(data: T, extras: PageExtras) => Promise<ValidationFeedback[]>;
128
+ migrations?: PageMigration[];
129
129
  /**
130
130
  * Hard-coded properties that may be set on page templates to influence the rendering of
131
131
  * components on the page. For instance, a set of color choices that are customized for
@@ -144,8 +144,8 @@ export interface APIDataTemplate extends APITemplate {
144
144
  * as well as the folder id (if applicable) and their own id. Keep in mind dataId will be
145
145
  * null when it is a creation operation.
146
146
  */
147
- validate?: (data: ComponentData, extras: DataExtras) => Promise<ValidationFeedback[]>;
148
- migrations: DataMigration[];
147
+ validate?: <T extends DataData>(data: T, extras: DataExtras) => Promise<ValidationFeedback[]>;
148
+ migrations?: DataMigration[];
149
149
  }
150
150
  export declare type APIAnyTemplate = APIComponentTemplate | APIPageTemplate | APIDataTemplate;
151
151
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.49",
3
+ "version": "0.0.52",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {