@dosgato/templating 0.0.24 → 0.0.27
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 +23 -8
- package/dist/apitemplate.js +6 -0
- package/package.json +1 -1
package/dist/apitemplate.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { PageRecord, ComponentData } from './component.js';
|
|
1
|
+
import { PageRecord, ComponentData, PageData } from './component.js';
|
|
2
2
|
import { LinkDefinition } from './links.js';
|
|
3
3
|
export declare type APITemplateType = 'page' | 'component' | 'data';
|
|
4
|
+
export declare enum ValidationMessageType {
|
|
5
|
+
ERROR = "error",
|
|
6
|
+
WARNING = "warning",
|
|
7
|
+
SUCCESS = "success"
|
|
8
|
+
}
|
|
9
|
+
export interface ValidationFeedback {
|
|
10
|
+
type: `${ValidationMessageType}`;
|
|
11
|
+
path?: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* This interface lays out the structure the API needs for each template in the system.
|
|
6
16
|
*/
|
|
@@ -41,17 +51,22 @@ export interface APITemplate {
|
|
|
41
51
|
getFulltext: FulltextGatheringFn;
|
|
42
52
|
/**
|
|
43
53
|
* Each template must provide a validation function so that the API can enforce its data is
|
|
44
|
-
* shaped properly.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
54
|
+
* shaped properly.
|
|
55
|
+
*
|
|
56
|
+
* Each entry in the return array can have a type of error, warning, or success. Errors
|
|
57
|
+
* represent a validation failure and mean that saving will not succeed. Warnings are shown
|
|
58
|
+
* to the editor but do not prevent saving. Success messages postively affirm valid input - for
|
|
59
|
+
* instance, a name they chose is available.
|
|
47
60
|
*
|
|
48
|
-
*
|
|
49
|
-
* { name:
|
|
61
|
+
* As an example, if name is required and the user didn't provide one, you would return:
|
|
62
|
+
* [{ type: 'error', path: 'name', message: 'A name is required.' }]
|
|
50
63
|
*
|
|
51
64
|
* This method is async so that you can do things like look in the database for conflicting
|
|
52
|
-
* names.
|
|
65
|
+
* names. The full page data, the path to this component, and a GraphQL query executor are
|
|
66
|
+
* available as parameters in case you need them. Keep in mind that the current editor MUST
|
|
67
|
+
* have access to any data you attempt to query in GraphQL.
|
|
53
68
|
*/
|
|
54
|
-
validate
|
|
69
|
+
validate?: (data: ComponentData, query: <T>(query: string, variables?: any) => Promise<T>, page: PageData, path: string) => Promise<ValidationFeedback[]>;
|
|
55
70
|
/**
|
|
56
71
|
* Hard-coded properties that may be set on page templates to influence the rendering of
|
|
57
72
|
* components on the page. For instance, a set of color choices that are customized for
|
package/dist/apitemplate.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { stopwords } from './stopwords.js';
|
|
2
|
+
export var ValidationMessageType;
|
|
3
|
+
(function (ValidationMessageType) {
|
|
4
|
+
ValidationMessageType["ERROR"] = "error";
|
|
5
|
+
ValidationMessageType["WARNING"] = "warning";
|
|
6
|
+
ValidationMessageType["SUCCESS"] = "success";
|
|
7
|
+
})(ValidationMessageType || (ValidationMessageType = {}));
|
|
2
8
|
/**
|
|
3
9
|
* This function is used by API template definitions to help them identify links inside large blocks
|
|
4
10
|
* of text and return them for indexing.
|