@dosgato/templating 1.1.1 → 1.1.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.
- package/dist/apitemplate.d.ts +13 -15
- package/package.json +1 -1
package/dist/apitemplate.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface ValidationFeedback {
|
|
|
17
17
|
* do advanced logic when validating or migrating data, e.g. looking up a name in the
|
|
18
18
|
* API to make sure it hasn't been used already.
|
|
19
19
|
*/
|
|
20
|
-
export interface PageExtras {
|
|
20
|
+
export interface PageExtras<DataType = PageData> {
|
|
21
21
|
/** A function for executing a graphql query to acquire more information than is already at hand. */
|
|
22
22
|
query: GraphQLQueryFn;
|
|
23
23
|
/** The site id in which the page lives or is being created. Null if we are validating creation of a site. */
|
|
@@ -35,14 +35,14 @@ export interface PageExtras {
|
|
|
35
35
|
/** The name the page has or will have. NOTE: looking the page up by name will not work during page creation. */
|
|
36
36
|
name: string;
|
|
37
37
|
/**
|
|
38
|
-
* The full page data before the validation
|
|
38
|
+
* The full page data before the validation in case validating depends on the previous
|
|
39
39
|
* state of the page.
|
|
40
40
|
*
|
|
41
|
-
* Will be undefined
|
|
41
|
+
* Will be undefined for page creation or during migration.
|
|
42
42
|
*/
|
|
43
|
-
page?:
|
|
43
|
+
page?: DataType;
|
|
44
44
|
}
|
|
45
|
-
export interface ComponentExtras extends PageExtras {
|
|
45
|
+
export interface ComponentExtras<DataType = ComponentData> extends PageExtras {
|
|
46
46
|
/** The path within the page data to the component currently being evaluated. */
|
|
47
47
|
path: string;
|
|
48
48
|
/**
|
|
@@ -51,12 +51,11 @@ export interface ComponentExtras extends PageExtras {
|
|
|
51
51
|
*/
|
|
52
52
|
page: PageData;
|
|
53
53
|
/**
|
|
54
|
-
* The component data before validation.
|
|
55
|
-
* data already being passed to the migration. Undefined for a new component.
|
|
54
|
+
* The component data before validation. Undefined for a new component or during migration.
|
|
56
55
|
*/
|
|
57
|
-
currentData?:
|
|
56
|
+
currentData?: DataType;
|
|
58
57
|
}
|
|
59
|
-
export interface DataExtras {
|
|
58
|
+
export interface DataExtras<DataType = DataData> {
|
|
60
59
|
/** A function for executing a graphql query to acquire more information than is already at hand. */
|
|
61
60
|
query: GraphQLQueryFn;
|
|
62
61
|
/** The id of the dataroot the entry lives in or will be placed in. */
|
|
@@ -66,10 +65,9 @@ export interface DataExtras {
|
|
|
66
65
|
/** The id of the data entry itself. NOTE: will be null during page creation. */
|
|
67
66
|
dataId?: string;
|
|
68
67
|
/**
|
|
69
|
-
* The data before validation.
|
|
70
|
-
* data already being passed to the migration. Undefined for a new data entry.
|
|
68
|
+
* The data before validation. Undefined for a new data entry or during migration.
|
|
71
69
|
*/
|
|
72
|
-
currentData?:
|
|
70
|
+
currentData?: DataType;
|
|
73
71
|
}
|
|
74
72
|
/**
|
|
75
73
|
* This interface lays out the structure the API needs for each template in the system.
|
|
@@ -177,7 +175,7 @@ export interface APIComponentTemplate<DataType extends ComponentData = any> exte
|
|
|
177
175
|
*
|
|
178
176
|
* See the ComponentExtras type to see all the contextual information you'll have available.
|
|
179
177
|
*/
|
|
180
|
-
validate?: (data: DataType, extras: ComponentExtras) => Promise<ValidationFeedback[]>;
|
|
178
|
+
validate?: (data: DataType, extras: ComponentExtras<DataType>) => Promise<ValidationFeedback[]>;
|
|
181
179
|
/**
|
|
182
180
|
* Each template must provide a list of migrations for upgrading the data schema over time.
|
|
183
181
|
* Typically this will start as an empty array and migrations will be added as the template
|
|
@@ -194,7 +192,7 @@ export interface APIPageTemplate<DataType extends PageData = any> extends APITem
|
|
|
194
192
|
/**
|
|
195
193
|
* Page template implementations do not receive a path like component templates do.
|
|
196
194
|
*/
|
|
197
|
-
validate?: (data: DataType, extras: PageExtras) => Promise<ValidationFeedback[]>;
|
|
195
|
+
validate?: (data: DataType, extras: PageExtras<DataType>) => Promise<ValidationFeedback[]>;
|
|
198
196
|
migrations?: PageMigration<DataType>[];
|
|
199
197
|
/**
|
|
200
198
|
* Hard-coded properties that may be set on page templates to influence the rendering of
|
|
@@ -238,7 +236,7 @@ export interface APIDataTemplate<DataType extends DataData = any> extends APITem
|
|
|
238
236
|
* the conflicting entry is deleted. Editing this data entry again will remove the "-1" because
|
|
239
237
|
* of the lack of conflict.
|
|
240
238
|
*/
|
|
241
|
-
validate?: (data: DataType, extras: DataExtras
|
|
239
|
+
validate?: (data: DataType, extras: DataExtras<DataType>, nameIsTaken: boolean) => Promise<ValidationFeedback[]>;
|
|
242
240
|
migrations?: DataMigration<DataType>[];
|
|
243
241
|
/**
|
|
244
242
|
* Mark this data type as inappropriate for sites. For example, if you have system-wide configuration
|