@dosgato/templating
Advanced tools
Comparing version 0.0.30 to 0.0.31
@@ -1,2 +0,2 @@ | ||
import { PageRecord, ComponentData } from './component.js'; | ||
import { PageRecord, ComponentData, DataData, PageData } from './component.js'; | ||
import { LinkDefinition } from './links.js'; | ||
@@ -29,14 +29,2 @@ export declare type APITemplateType = 'page' | 'component' | 'data'; | ||
/** | ||
* Each template must declare its areas and the template keys of components that will be | ||
* permitted inside each area. The list of allowed component templates can be updated beyond | ||
* the list provided here. See templateRegistry.addAvailableComponent's comment for info on why. | ||
*/ | ||
areas: Record<string, string[]>; | ||
/** | ||
* Each template must provide a list of migrations for upgrading the data schema over time. | ||
* Typically this will start as an empty array and migrations will be added as the template | ||
* gets refactored. | ||
*/ | ||
migrations: Migration[]; | ||
/** | ||
* Each template must provide a function that returns links from its data so that they | ||
@@ -53,3 +41,12 @@ * can be indexed. Only fields that are links need to be returned. Links inside rich editor | ||
getFulltext: FulltextGatheringFn; | ||
} | ||
export interface APIComponentTemplate extends APITemplate { | ||
type: 'component'; | ||
/** | ||
* Each template must declare its areas and the template keys of components that will be | ||
* permitted inside each area. The list of allowed component templates can be updated beyond | ||
* the list provided here. See templateRegistry.addAvailableComponent's comment for info on why. | ||
*/ | ||
areas?: Record<string, string[]>; | ||
/** | ||
* Each template must provide a validation function so that the API can enforce its data is | ||
@@ -73,2 +70,20 @@ * shaped properly. | ||
/** | ||
* Each template must provide a list of migrations for upgrading the data schema over time. | ||
* Typically this will start as an empty array and migrations will be added as the template | ||
* gets refactored. | ||
*/ | ||
migrations: ComponentMigration[]; | ||
} | ||
export interface APIPageTemplate extends APITemplate { | ||
type: 'page'; | ||
/** | ||
* Page areas are the same as components but are required. | ||
*/ | ||
areas: Record<string, string[]>; | ||
/** | ||
* Page template implementations do not receive a path like component templates do. | ||
*/ | ||
validate?: (data: ComponentData, query: GraphQLQueryFn, page: PageRecord) => Promise<ValidationFeedback[]>; | ||
migrations: PageMigration[]; | ||
/** | ||
* Hard-coded properties that may be set on page templates to influence the rendering of | ||
@@ -84,2 +99,11 @@ * components on the page. For instance, a set of color choices that are customized for | ||
} | ||
export interface APIDataTemplate extends APITemplate { | ||
type: 'data'; | ||
/** | ||
* Data template implementations receive the dataId so they can self-reference in queries. | ||
*/ | ||
validate?: (data: ComponentData, query: GraphQLQueryFn, dataId: string) => Promise<ValidationFeedback[]>; | ||
migrations: DataMigration[]; | ||
} | ||
export declare type APIAnyTemplate = APIComponentTemplate | APIPageTemplate | APIDataTemplate; | ||
/** | ||
@@ -115,5 +139,16 @@ * In dosgato CMS, the data in the database is not altered except during user activity. This | ||
createdAt: Date; | ||
} | ||
export interface ComponentMigration extends Migration { | ||
up: (data: ComponentData, query: GraphQLQueryFn, page: PageRecord, path: string) => ComponentData | Promise<ComponentData>; | ||
down: (data: ComponentData, query: GraphQLQueryFn, page: PageRecord, path: string) => ComponentData | Promise<ComponentData>; | ||
} | ||
export interface PageMigration extends Migration { | ||
up: (data: PageData, query: GraphQLQueryFn, page: PageRecord) => PageData | Promise<PageData>; | ||
down: (data: PageData, query: GraphQLQueryFn, page: PageRecord) => PageData | Promise<PageData>; | ||
} | ||
export interface DataMigration extends Migration { | ||
up: (data: DataData, query: GraphQLQueryFn, dataId: string) => DataData | Promise<DataData>; | ||
down: (data: DataData, query: GraphQLQueryFn, dataId: string) => DataData | Promise<DataData>; | ||
} | ||
export declare type AnyMigration = ComponentMigration | PageMigration | DataMigration; | ||
export declare type LinkGatheringFn = (data: any) => LinkDefinition[]; | ||
@@ -120,0 +155,0 @@ export declare type FulltextGatheringFn = (data: any) => string[]; |
{ | ||
"name": "@dosgato/templating", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"description": "A library to support building templates for dosgato CMS.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48715
1114