@dosgato/templating
Advanced tools
Comparing version 0.0.135 to 0.0.136
@@ -182,4 +182,14 @@ import type { ComponentData, DataData, PageData } from './component.js'; | ||
* null when it is a creation operation. | ||
* | ||
* nameIsTaken will be true when the automatically generated name for the data entry already | ||
* exists elsewhere in the folder. This fact can be ignored and the generated name will be automatically | ||
* numerated to be unique. If you would rather present the editor with a validation error and let them resolve | ||
* the conflict, this parameter gives you an opportunity to do that. | ||
* | ||
* Note that numeration can lead to the name changing during unrelated edits, possibly breaking | ||
* links. For example, on creation the name is set with a "-1" suffix because of a conflict, then | ||
* the conflicting entry is deleted. Editing this data entry again will remove the "-1" because | ||
* of the lack of conflict. | ||
*/ | ||
validate?: (data: DataType, extras: DataExtras) => Promise<ValidationFeedback[]>; | ||
validate?: (data: DataType, extras: DataExtras, nameIsTaken: boolean) => Promise<ValidationFeedback[]>; | ||
migrations?: DataMigration<DataType>[]; | ||
@@ -192,2 +202,23 @@ /** | ||
global?: boolean; | ||
/** | ||
* Mark this data type as inappropriate for global. For example, if you have a data type for site | ||
* configurations, a global entry might make no sense. Setting this will avoid showing editors | ||
* the global space in the dataroot list. | ||
*/ | ||
noglobal?: boolean; | ||
/** | ||
* Data objects must have names so that they can be linked to at a specific path. However, | ||
* for an editor, setting an addressable name for a data entry that already has, say, a | ||
* title, is both tedious and confusing. | ||
* | ||
* Instead, it is the data template developer's responsibility to create the name from | ||
* the data gathered from the editor. If there is a title, that's a great option. Otherwise, | ||
* the dialog may need to have an explicit `name` field. Either way it's up to the developer | ||
* of each data template to decide and provide. | ||
* | ||
* Whatever is returned from this function will be further processed to fit well in a path - | ||
* i.e. lower-cased and non-word characters replaced by a dash. If there is a duplicate data | ||
* entry in the same folder, it will be automatically numerated. | ||
*/ | ||
computeName: (data: DataType) => string; | ||
} | ||
@@ -194,0 +225,0 @@ export type APIAnyTemplate = APIComponentTemplate | APIPageTemplate | APIDataTemplate; |
@@ -363,2 +363,21 @@ /// <reference types="node" /> | ||
} | ||
export interface DataRecord<DataType extends DataData = DataData> { | ||
id: string; | ||
name: string; | ||
linkId: string; | ||
createdAt: Date; | ||
createdBy: { | ||
id: string; | ||
name: string; | ||
}; | ||
modifiedAt: Date; | ||
modifiedBy: { | ||
id: string; | ||
name: string; | ||
}; | ||
publishedAt?: Date; | ||
path: string; | ||
data: DataType; | ||
site?: SiteInfo; | ||
} | ||
export interface ComponentData { | ||
@@ -365,0 +384,0 @@ templateKey: string; |
@@ -1,2 +0,2 @@ | ||
import type { ContextBase, DataData, PageData, PageRecord, PageRecordOptionalData } from './component.js'; | ||
import type { ContextBase, DataRecord, PageData, PageRecord, PageRecordOptionalData } from './component.js'; | ||
import type { AssetFolderLink, AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js'; | ||
@@ -55,10 +55,2 @@ /** | ||
} | ||
export interface DataRecord { | ||
id: string; | ||
path: string; | ||
name: string; | ||
modifiedAt: Date; | ||
publishedAt?: Date; | ||
data: DataData; | ||
} | ||
export interface PageForNavigation { | ||
@@ -65,0 +57,0 @@ id: string; |
@@ -1,2 +0,2 @@ | ||
import type { ComponentData, PageData } from './component.js'; | ||
import type { ComponentData, DataData, PageData, DataRecord } from './component.js'; | ||
interface IconifyIcon { | ||
@@ -15,3 +15,3 @@ body: string; | ||
} | ||
export interface UITemplate { | ||
export interface UITemplateBase { | ||
templateKey: string; | ||
@@ -57,2 +57,17 @@ /** | ||
/** | ||
* if present this SVG will be used when presenting users with | ||
* an array of choices of templates to create. Ideally it should look | ||
* a lot like the template will look on a webpage. It will be presented | ||
* about 1-2 inches wide | ||
*/ | ||
preview?: IconOrSVG; | ||
/** | ||
* if present this icon will be used to represent the template in various | ||
* UI contexts. It will be presented about 3mm wide. Falls back to the | ||
* preview image. | ||
*/ | ||
icon?: IconOrSVG; | ||
} | ||
export interface UITemplate extends UITemplateBase { | ||
/** | ||
* Sometimes when you create a component that has areas, you want to automatically fill | ||
@@ -73,15 +88,2 @@ * one or more areas with some default introductory content. | ||
/** | ||
* if present this SVG will be used when presenting users with | ||
* an array of choices of templates to create. Ideally it should look | ||
* a lot like the template will look on a webpage. It will be presented | ||
* about 1-2 inches wide | ||
*/ | ||
preview?: IconOrSVG; | ||
/** | ||
* if present this icon will be used to represent the template in various | ||
* UI contexts. It will be presented about 3mm wide. Falls back to the | ||
* preview image. | ||
*/ | ||
icon?: IconOrSVG; | ||
/** | ||
* Add buttons to the page bar in the page editing UI when editing pages with this | ||
@@ -113,2 +115,26 @@ * template. Only applies to page templates. | ||
} | ||
export interface UITemplateData extends UITemplateBase { | ||
/** | ||
* Without configuration, only data entry names and modified dates are shown | ||
* in the list view. Use this to configure your own set of columns. | ||
*/ | ||
columns?: { | ||
/** | ||
* A title for the column in header row. | ||
*/ | ||
title: string; | ||
/** | ||
* If given a string, will be treated as a dot-separated path within DataData and | ||
* the content at that path will be html-encoded and placed inside the field. | ||
* | ||
* If given a function, the result of the function will be placed inside the field | ||
* without html-encoding, so that you can write your own HTML. Do the encoding yourself. | ||
*/ | ||
get: string | ((data: DataRecord) => string); | ||
/** | ||
* An icon for the cell in all regular rows (not the header). | ||
*/ | ||
icon?: (data: DataData) => IconOrSVG; | ||
}[]; | ||
} | ||
/** | ||
@@ -115,0 +141,0 @@ * This is a type for the data that will be passed to dialog Svelte components as |
{ | ||
"name": "@dosgato/templating", | ||
"version": "0.0.135", | ||
"version": "0.0.136", | ||
"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
112598
2450