Skip to content

Commit

Permalink
Merge pull request #11 from CloudCannon/more-updates-for-decoupled
Browse files Browse the repository at this point in the history
Update types to reflect latest state
  • Loading branch information
rphillips-cc authored Aug 22, 2024
2 parents f07306d + 56ad08a commit b434f00
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 57 deletions.
51 changes: 47 additions & 4 deletions src/build-coupled.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
import { CollectionConfig, Configuration, Parseable } from './configuration';
import { CollectionConfig, Configuration, DataConfigEntry, Paths } from './configuration';

export interface BuildCoupledPaths extends Paths {
/**
* Parent folder of all collections.
*/
collections?: string;
/**
* Parent folder of all site data files.
*/
data?: string;
/**
* Parent folder of all site layout files. _Only applies to Jekyll, Hugo, and Eleventy sites_.
*/
layouts?: string;
/**
* Parent folder of all includes, partials, or shortcode files. _Only applies to Jekyll, Hugo, and
* Eleventy sites_.
*/
includes?: string;
}

export type FilterBase = 'none' | 'all' | 'strict';

Expand All @@ -20,6 +40,13 @@ export interface Filter {
exclude?: string[];
}

interface Parseable {
/**
* Overrides the format files are read. Detected automatically from file extension if unset.
*/
parser?: 'csv' | 'front-matter' | 'json' | 'properties' | 'toml' | 'yaml';
}

interface Filterable {
/**
* Controls which files are displayed in the collection list. Does not change which files are
Expand All @@ -39,12 +66,20 @@ interface WithCollectionsConfigOverride {
/**
* The `collections_config` entry format for build-coupled non-Jekyll/Hugo/Eleventy sites.
*/
export interface ReaderCollectionConfig extends CollectionConfig, Parseable, Filterable {}
export interface ReaderCollectionConfig extends CollectionConfig, Parseable, Filterable {
/**
* Overrides the default singular input key of the collection. This is used for naming conventions
* for select and multiselect inputs.
*/
singular_key?: string;
}

/**
* The configuration format for build-coupled non-Jekyll/Hugo/Eleventy sites.
*/
export interface ReaderConfiguration extends Configuration {
paths?: BuildCoupledPaths;
data_config?: Record<string, DataConfigEntry & Parseable>;
collections_config?: Record<string, ReaderCollectionConfig>;
/**
* Generates the integration file in another folder. Not applicable to Jekyll, Hugo, and Eleventy.
Expand All @@ -53,11 +88,19 @@ export interface ReaderConfiguration extends Configuration {
output?: string;
}

export interface BuildCoupledCollectionConfig extends Omit<CollectionConfig, 'url'>, Filterable {}
export interface BuildCoupledCollectionConfig extends Omit<CollectionConfig, 'url'>, Filterable {
/**
* Overrides the default singular input key of the collection. This is used for naming conventions
* for select and multiselect inputs.
*/
singular_key?: string;
}

interface BuildCoupledConfiguration
extends Omit<Configuration, 'data_config'>,
WithCollectionsConfigOverride {}
WithCollectionsConfigOverride {
paths?: BuildCoupledPaths;
}

/**
* The `collections_config` entry format for build-coupled Hugo sites.
Expand Down
77 changes: 24 additions & 53 deletions src/configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import type { Syntax } from './syntax';
export type InstanceValue = 'UUID' | 'NOW';
export type EditorKey = 'visual' | 'content' | 'data';
export type SortOrder = 'ascending' | 'descending' | 'asc' | 'desc';
export type AttributeListPosition = 'none' | 'right' | 'space right' | 'below' | 'newline below' | 'right-of-prefix';
export type AttributeListPosition =
| 'none'
| 'right'
| 'space right'
| 'below'
| 'newline below'
| 'right-of-prefix';

export type MarkdownAttributeElementOptions = {
inline?: AttributeListPosition;
Expand Down Expand Up @@ -40,7 +46,9 @@ export interface MarkdownSettings {
*/
typographer?: boolean;
/**
* Double + single quotes replacement pairs, when typographer enabled and smartquotes on. For example, you can use '«»„“' for Russian, '„“‚‘' for German, and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
* Double + single quotes replacement pairs, when typographer enabled and smartquotes on. For
* example, you can use '«»„“' for Russian, '„“‚‘' for German, and ['«\xA0', '\xA0»', '‹\xA0',
* '\xA0›'] for French (including nbsp).
*/
quotes?: string;
/**
Expand Down Expand Up @@ -91,11 +99,11 @@ export interface MarkdownSettings {
* Save element attributes in Markdown format instead of converting to HTML.
*/
attributes?: boolean;
/**
/**
* Define positioning behaviour of Markdown attributes for different elements.
*/
*/
attribute_elements?: MarkdownAttributeElementOptions;
}
};
}

// TODO: use SnippetConfig from @cloudcannon/scrap-booker when ParserConfig issue resolved.
Expand Down Expand Up @@ -388,20 +396,20 @@ export interface BlockEditable extends ImageResizeable, TextEditable {
table?: boolean;
}

interface WithReducedPaths {
interface WithPaths {
/**
* Paths to where new asset files are uploaded to. They also set the default path when choosing
* existing images, and linking to existing files. Each path is relative to global `source`.
* Defaults to the global `paths`.
*/
paths?: ReducedPaths;
paths?: Paths;
}

export interface ImageEditable extends ImageResizeable, WithReducedPaths {}
export interface ImageEditable extends ImageResizeable, WithPaths {}

export interface LinkEditable extends WithReducedPaths {}
export interface LinkEditable extends WithPaths {}

export interface TextEditable extends WithReducedPaths {
export interface TextEditable extends WithPaths {
/**
* Enables a control to set selected text to bold.
*/
Expand Down Expand Up @@ -720,7 +728,7 @@ export interface RangeInput extends BaseInput<RangeInputOptions> {
type: 'range';
}

export interface UrlInputOptions extends BaseInputOptions, WithReducedPaths {}
export interface UrlInputOptions extends BaseInputOptions, WithPaths {}

export interface UrlInput extends BaseInput<UrlInputOptions> {
type: 'range';
Expand Down Expand Up @@ -753,7 +761,7 @@ export interface DateInput extends BaseInput<DateInputOptions> {
type: 'date' | 'datetime';
}

export interface FileInputOptions extends BaseInputOptions, WithReducedPaths {
export interface FileInputOptions extends BaseInputOptions, WithPaths {
/**
* Restricts which file types are available to select or upload to this input.
*/
Expand Down Expand Up @@ -940,7 +948,7 @@ export type Input =
| ObjectInput
| ArrayInput;

export interface ReducedPaths {
export interface Paths {
/**
* Location of assets that are statically copied to the output site. This prefix will be removed
* from the _Uploads_ path when CloudCannon outputs the URL of an asset.
Expand Down Expand Up @@ -980,26 +988,6 @@ export interface ReducedPaths {
uploads_use_relative_path?: boolean;
}

export interface Paths extends ReducedPaths {
/**
* Parent folder of all collections.
*/
collections?: string;
/**
* Parent folder of all site data files.
*/
data?: string;
/**
* Parent folder of all site layout files. _Only applies to Jekyll, Hugo, and Eleventy sites_.
*/
layouts?: string;
/**
* Parent folder of all includes, partials, or shortcode files. _Only applies to Jekyll, Hugo, and
* Eleventy sites_.
*/
includes?: string;
}

export interface Documentation {
/**
* The "href" value of the link.
Expand Down Expand Up @@ -1277,11 +1265,6 @@ export interface CollectionConfig extends Cascade, Previewable {
* collection add menu and file context menu.
*/
singular_name?: string;
/**
* Overrides the default singular input key of the collection. This is used for naming conventions
* for select and multiselect inputs.
*/
singular_key?: string;
/**
* Changes the options presented in the add menu in the collection file list. Defaults to an
* automatically generated list from _Schemas_, or uses the first file in the collection if no
Expand Down Expand Up @@ -1431,14 +1414,7 @@ export type SelectValues =
| Record<string, string>
| Record<string, Record<string, any>>;

export interface Parseable {
/**
* Overrides the format files are read. Detected automatically from file extension if unset.
*/
parser?: 'csv' | 'front-matter' | 'json' | 'properties' | 'toml' | 'yaml';
}

export interface DataConfigEntry extends Parseable {
export interface DataConfigEntry {
/**
* The path to a file or folder of files containing data.
*/
Expand Down Expand Up @@ -1523,19 +1499,14 @@ export type SsgKey =
| 'nuxtjs'
| 'sphinx'
| 'static'
| 'other'
| 'legacy'
| 'unknown';
| 'other';

export interface Configuration extends Cascade, WithSnippets {
export interface Configuration extends Cascade, WithSnippets, WithPaths {
/**
* Base path to your site source files, relative to the root folder.
*/
source?: string;
/**
* Global paths to common folders.
*/
paths?: Paths;
/**
* Definitions for your collections, which are the sets of content files for your site grouped by
* folder. Entries are keyed by a chosen collection key, and contain configuration specific to
Expand Down

0 comments on commit b434f00

Please sign in to comment.