Skip to content

Commit

Permalink
Release 0.0.1-next.8
Browse files Browse the repository at this point in the history
  • Loading branch information
accuser committed Oct 30, 2024
1 parent a4b1fee commit 413aaf6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 36 deletions.
19 changes: 13 additions & 6 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ interface Archetype {
optional: Record<string, SchemaField>;
};
/**
* Name of parent archetype to inherit from.
* Name(s) of archetype(s) this archetype extends.
*/
extends?: string;
extends?: string[];
}

declare class ArchetypeLoadError extends Error {
Expand Down Expand Up @@ -132,6 +132,13 @@ interface ValidationResult {
errors: ValidationError[];
}

interface LoadOptions {
/**
* Override the cache setting for this load. If not provided, the default
* cache setting will be used.
*/
cache?: false;
}
interface ArchetypeValidator {
/**
* The base archetype schema that all other archetypes must conform to
Expand All @@ -140,15 +147,15 @@ interface ArchetypeValidator {
/**
* Load an archetype by name from the configured store
*/
readonly loadArchetype: (name: string) => Promise<Archetype>;
readonly loadArchetype: (name: string, options?: LoadOptions) => Promise<Archetype>;
/**
* Validate an archetype definition against the base archetype schema
*/
readonly validateArchetype: (archetype: unknown) => Promise<ValidationResult>;
/**
* Validate frontmatter against a named archetype
* Validate frontmatter
*/
readonly validateFrontmatter: (frontmatter: unknown, defaultArchetypeName?: string) => Promise<ValidationResult>;
readonly validateFrontmatter: (frontmatter: unknown) => Promise<ValidationResult>;
}

interface ValidatorOptions {
Expand All @@ -174,7 +181,7 @@ interface ValidatorOptions {
*
* @param options - Configuration options for the validator.
* @param options.store - The data store used to load archetype schemas.
* @param options.cache - Determines whether to cache loaded archetypes. Defaults to `true`.
* @param options.cache - Determines whether to cache loaded archetypes. Defaults to `true` in test and production environments.
* @param options.validation - Additional validation options to apply. Defaults to an empty object.
* @returns A promise that resolves to an initialized ArchetypeValidator.
*
Expand Down
87 changes: 59 additions & 28 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typematter/archetype",
"version": "0.0.1-next.7",
"version": "0.0.1-next.8",
"description": "Archetype system for validating frontmatter.",
"private": false,
"type": "module",
Expand Down

0 comments on commit 413aaf6

Please sign in to comment.