myst-frontmatter
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -25,4 +25,4 @@ import type { CreditRole } from 'credit-roles'; | ||
lite?: boolean; | ||
binder?: boolean | ThebeBinderOptions; | ||
server?: boolean | ThebeServerOptions; | ||
binder?: boolean | BinderHubOptions; | ||
server?: boolean | JupyterServerOptions; | ||
kernelName?: string; | ||
@@ -33,3 +33,3 @@ sessionName?: string; | ||
mathjaxConfig?: string; | ||
local?: boolean | ThebeLocalOptions; | ||
local?: boolean | JupyterLocalOptions; | ||
}; | ||
@@ -41,3 +41,3 @@ export declare enum BinderProviders { | ||
} | ||
export type ThebeBinderOptions = { | ||
export type BinderHubOptions = { | ||
url?: string; | ||
@@ -48,7 +48,7 @@ ref?: string; | ||
}; | ||
export type ThebeServerOptions = { | ||
export type JupyterServerOptions = { | ||
url?: string; | ||
token?: string; | ||
}; | ||
export type ThebeLocalOptions = ThebeServerOptions & { | ||
export type JupyterLocalOptions = JupyterServerOptions & { | ||
kernelName?: string; | ||
@@ -144,3 +144,3 @@ sessionName?: string; | ||
exports?: Export[]; | ||
thebe?: boolean | Thebe; | ||
thebe?: Thebe; | ||
requirements?: string[]; | ||
@@ -147,0 +147,0 @@ resources?: string[]; |
import type { ValidationOptions } from 'simple-validators'; | ||
import type { Author, Biblio, Export, Jupytext, KernelSpec, Numbering, PageFrontmatter, ProjectFrontmatter, SiteFrontmatter, Venue, Thebe, ThebeBinderOptions, ThebeServerOptions, ThebeLocalOptions } from './types.js'; | ||
import type { Author, Biblio, Export, Jupytext, KernelSpec, Numbering, PageFrontmatter, ProjectFrontmatter, SiteFrontmatter, Venue, Thebe, BinderHubOptions, JupyterServerOptions, JupyterLocalOptions } from './types.js'; | ||
export declare const SITE_FRONTMATTER_KEYS: string[]; | ||
@@ -25,3 +25,3 @@ export declare const PROJECT_FRONTMATTER_KEYS: string[]; | ||
/** | ||
* Validate Thebe Object | ||
* Validate Thebe options | ||
* | ||
@@ -31,5 +31,5 @@ * https://thebe-core.curve.space/docs-core/a-configuration | ||
export declare function validateThebe(input: any, opts: ValidationOptions): Thebe | undefined; | ||
export declare function validateThebeBinderOptions(input: any, opts: ValidationOptions): ThebeBinderOptions | undefined; | ||
export declare function validateThebeServerOptions(input: any, opts: ValidationOptions): ThebeServerOptions | undefined; | ||
export declare function validateThebeLocalOptions(input: any, opts: ValidationOptions): ThebeLocalOptions | undefined; | ||
export declare function validateBinderHubOptions(input: any, opts: ValidationOptions): BinderHubOptions | undefined; | ||
export declare function validateJupyterServerOptions(input: any, opts: ValidationOptions): JupyterServerOptions | undefined; | ||
export declare function validateJupyterLocalOptions(input: any, opts: ValidationOptions): JupyterLocalOptions | undefined; | ||
/** | ||
@@ -53,2 +53,3 @@ * Validate Numbering object | ||
export declare function validateSiteFrontmatterKeys(value: Record<string, any>, opts: ValidationOptions): SiteFrontmatter; | ||
export declare function validateSharedProjectFrontmatterKeys(value: Record<string, any>, opts: ValidationOptions): Omit<ProjectFrontmatter, "references" | "thebe" | "requirements" | "resources">; | ||
export declare function validateProjectFrontmatterKeys(value: Record<string, any>, opts: ValidationOptions): ProjectFrontmatter; | ||
@@ -55,0 +56,0 @@ export declare function validatePageFrontmatterKeys(value: Record<string, any>, opts: ValidationOptions): PageFrontmatter; |
@@ -36,5 +36,3 @@ import { doi } from 'doi-utils'; | ||
'exports', | ||
'thebe', | ||
'requirements', | ||
'resources', | ||
// Do not add any project specific keys here! | ||
].concat(SITE_FRONTMATTER_KEYS); | ||
@@ -51,3 +49,3 @@ export const PAGE_FRONTMATTER_KEYS = [ | ||
// These keys only exist on the project. | ||
PROJECT_FRONTMATTER_KEYS.push('references', 'requirements', 'resources'); | ||
PROJECT_FRONTMATTER_KEYS.push('references', 'requirements', 'resources', 'thebe'); | ||
export const USE_PROJECT_FALLBACK = [ | ||
@@ -98,5 +96,5 @@ 'authors', | ||
]; | ||
const THEBE_BINDER_OPTIONS_KEYS = ['url', 'ref', 'repo', 'provider']; | ||
const THEBE_SERVER_OPTIONS_KEYS = ['url', 'token']; | ||
const THEBE_LOCAL_OPTIONS_KEYS = ['url', 'token', 'kernelName', 'sessionName']; | ||
const BINDER_HUB_OPTIONS_KEYS = ['url', 'ref', 'repo', 'provider']; | ||
const JUPYTER_SERVER_OPTIONS_KEYS = ['url', 'token']; | ||
const JUPYTER_LOCAL_OPTIONS_KEYS = ['url', 'token', 'kernelName', 'sessionName']; | ||
const NUMBERING_KEYS = [ | ||
@@ -128,3 +126,3 @@ 'enumerator', | ||
]; | ||
const KNOWN_ALIASES = { | ||
const KNOWN_PAGE_ALIASES = { | ||
author: 'authors', | ||
@@ -134,2 +132,7 @@ affiliation: 'affiliations', | ||
}; | ||
const KNOWN_PROJECT_ALIASES = { | ||
...KNOWN_PAGE_ALIASES, | ||
// This must also be updated in myst-config | ||
jupyter: 'thebe', | ||
}; | ||
const GITHUB_USERNAME_REPO_REGEX = '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$'; | ||
@@ -314,3 +317,3 @@ function validateBooleanOrObject(input, opts, objectValidator) { | ||
/** | ||
* Validate Thebe Object | ||
* Validate Thebe options | ||
* | ||
@@ -320,2 +323,10 @@ * https://thebe-core.curve.space/docs-core/a-configuration | ||
export function validateThebe(input, opts) { | ||
if (input === false) | ||
return undefined; | ||
if (input === true || input === 'server') | ||
return { server: true }; | ||
if (input === 'lite') | ||
return { lite: true }; | ||
if (input === 'binder') | ||
return { binder: true }; | ||
const value = validateObjectKeys(input, { optional: THEBE_KEYS }, opts); | ||
@@ -329,6 +340,6 @@ if (value === undefined) | ||
if (defined(value.binder)) { | ||
output.binder = validateBooleanOrObject(value.binder, incrementOptions('binder', opts), validateThebeBinderOptions); | ||
output.binder = validateBooleanOrObject(value.binder, incrementOptions('binder', opts), validateBinderHubOptions); | ||
} | ||
if (defined(value.server)) { | ||
output.server = validateBooleanOrObject(value.server, incrementOptions('server', opts), validateThebeServerOptions); | ||
output.server = validateBooleanOrObject(value.server, incrementOptions('server', opts), validateJupyterServerOptions); | ||
} | ||
@@ -351,8 +362,8 @@ if (defined(value.kernelName)) { | ||
if (defined(value.local)) { | ||
output.local = validateBooleanOrObject(value.local, incrementOptions('local', opts), validateThebeLocalOptions); | ||
output.local = validateBooleanOrObject(value.local, incrementOptions('local', opts), validateJupyterLocalOptions); | ||
} | ||
return output; | ||
} | ||
export function validateThebeBinderOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: THEBE_BINDER_OPTIONS_KEYS }, opts); | ||
export function validateBinderHubOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: BINDER_HUB_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
@@ -381,4 +392,4 @@ return undefined; | ||
} | ||
export function validateThebeServerOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: THEBE_SERVER_OPTIONS_KEYS }, opts); | ||
export function validateJupyterServerOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: JUPYTER_SERVER_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
@@ -395,4 +406,4 @@ return undefined; | ||
} | ||
export function validateThebeLocalOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: THEBE_LOCAL_OPTIONS_KEYS }, opts); | ||
export function validateJupyterLocalOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: JUPYTER_LOCAL_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
@@ -649,3 +660,3 @@ return undefined; | ||
} | ||
export function validateProjectFrontmatterKeys(value, opts) { | ||
export function validateSharedProjectFrontmatterKeys(value, opts) { | ||
const output = validateSiteFrontmatterKeys(value, opts); | ||
@@ -734,2 +745,6 @@ if (defined(value.date)) { | ||
} | ||
return output; | ||
} | ||
export function validateProjectFrontmatterKeys(value, opts) { | ||
const output = validateSharedProjectFrontmatterKeys(value, opts); | ||
// This is only for the project, and is not defined on pages | ||
@@ -751,3 +766,5 @@ if (defined(value.references)) { | ||
if (defined(value.thebe)) { | ||
output.thebe = validateBooleanOrObject(value.thebe, incrementOptions('thebe', opts), validateThebe); | ||
const result = validateThebe(value.thebe, incrementOptions('thebe', opts)); | ||
if (result) | ||
output.thebe = result; | ||
} | ||
@@ -767,3 +784,3 @@ if (defined(value.requirements)) { | ||
export function validatePageFrontmatterKeys(value, opts) { | ||
const output = validateProjectFrontmatterKeys(value, opts); | ||
const output = validateSharedProjectFrontmatterKeys(value, opts); | ||
if (defined(value.kernelspec)) { | ||
@@ -810,4 +827,3 @@ output.kernelspec = validateKernelSpec(value.kernelspec, incrementOptions('kernelspec', opts)); | ||
export function validateProjectFrontmatter(input, opts) { | ||
const value = validateObjectKeys(input, { optional: PROJECT_FRONTMATTER_KEYS, alias: KNOWN_ALIASES }, opts) || | ||
{}; | ||
const value = validateObjectKeys(input, { optional: PROJECT_FRONTMATTER_KEYS, alias: KNOWN_PROJECT_ALIASES }, opts) || {}; | ||
return validateProjectFrontmatterKeys(value, opts); | ||
@@ -819,4 +835,3 @@ } | ||
export function validatePageFrontmatter(input, opts) { | ||
const value = validateObjectKeys(input, { optional: PAGE_FRONTMATTER_KEYS, alias: KNOWN_ALIASES }, opts) || | ||
{}; | ||
const value = validateObjectKeys(input, { optional: PAGE_FRONTMATTER_KEYS, alias: KNOWN_PAGE_ALIASES }, opts) || {}; | ||
return validatePageFrontmatterKeys(value, opts); | ||
@@ -823,0 +838,0 @@ } |
{ | ||
"name": "myst-frontmatter", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
103849
3168