myst-frontmatter
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unnestKernelSpec = exports.fillPageFrontmatter = exports.validatePageFrontmatter = exports.validateProjectFrontmatter = exports.validatePageFrontmatterKeys = exports.validateProjectFrontmatterKeys = exports.validateSiteFrontmatterKeys = exports.validateGithubUrl = exports.validateExport = exports.validateExportsList = exports.validateJupytext = exports.validateKernelSpec = exports.validateNumbering = exports.validateBiblio = exports.validateAuthor = exports.validateVenue = exports.RESERVED_EXPORT_KEYS = exports.USE_PROJECT_FALLBACK = exports.PAGE_FRONTMATTER_KEYS = exports.PROJECT_FRONTMATTER_KEYS = exports.SITE_FRONTMATTER_KEYS = void 0; | ||
exports.unnestKernelSpec = exports.fillPageFrontmatter = exports.validatePageFrontmatter = exports.validateProjectFrontmatter = exports.validatePageFrontmatterKeys = exports.validateProjectFrontmatterKeys = exports.validateSiteFrontmatterKeys = exports.validateGithubUrl = exports.validateExport = exports.validateExportsList = exports.validateJupytext = exports.validateKernelSpec = exports.validateNumbering = exports.validateThebeBinderOptions = exports.validateThebeSavedSessionOptions = exports.validateThebeKernelOptions = exports.validateThebeServerSettings = exports.validateThebe = exports.validateBiblio = exports.validateAuthor = exports.validateVenue = exports.RESERVED_EXPORT_KEYS = exports.USE_PROJECT_FALLBACK = exports.PAGE_FRONTMATTER_KEYS = exports.PROJECT_FRONTMATTER_KEYS = exports.SITE_FRONTMATTER_KEYS = void 0; | ||
const doi_utils_1 = __importDefault(require("doi-utils")); | ||
@@ -40,2 +40,3 @@ const credit_roles_1 = __importDefault(require("credit-roles")); | ||
'exports', | ||
'thebe', | ||
].concat(exports.SITE_FRONTMATTER_KEYS); | ||
@@ -84,2 +85,17 @@ exports.PAGE_FRONTMATTER_KEYS = [ | ||
const BIBLIO_KEYS = ['volume', 'issue', 'first_page', 'last_page']; | ||
const THEBE_KEYS = [ | ||
'useBinder', | ||
'useJupyterLite', | ||
'requestKernel', | ||
'binderOptions', | ||
'serverSettings', | ||
'kernelOptions', | ||
'savedSessionOptions', | ||
'mathjaxConfig', | ||
'mathjaxUrl', | ||
]; | ||
const THEBE_BINDER_OPTIONS_KEYS = ['binderUrl', 'ref', 'repo', 'repoProvider']; | ||
const THEBE_SERVER_SETTINGS_KEYS = ['baseUrl', 'token', 'wsUrl', 'appendToken']; | ||
const THEBE_KERNEL_OPTIONS_KEYS = ['kernelName', 'name', 'path']; | ||
const THEBE_SAVED_SESSION_OPTIONS_KEYS = ['enabled', 'maxAge', 'storagePrefix']; | ||
const NUMBERING_KEYS = [ | ||
@@ -266,2 +282,116 @@ 'enumerator', | ||
/** | ||
* Validate Thebe Object | ||
* | ||
* https://thebe-core.curve.space/docs-core/a-configuration | ||
*/ | ||
function validateThebe(input, opts) { | ||
const value = (0, simple_validators_1.validateObjectKeys)(input, { optional: THEBE_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if ((0, simple_validators_1.defined)(value.useBinder)) { | ||
output.useBinder = (0, simple_validators_1.validateBoolean)(value.useBinder, (0, simple_validators_1.incrementOptions)('useBinder', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.useJupyterLite)) { | ||
output.useJupyterLite = (0, simple_validators_1.validateBoolean)(value.useJupyterLite, (0, simple_validators_1.incrementOptions)('useJupyterLite', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.requestKernel)) { | ||
output.requestKernel = (0, simple_validators_1.validateBoolean)(value.requestKernel, (0, simple_validators_1.incrementOptions)('requestKernel', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.binderOptions)) { | ||
output.binderOptions = validateThebeBinderOptions(value.binderOptions, (0, simple_validators_1.incrementOptions)('binderOptions', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.serverSettings)) { | ||
output.serverSettings = validateThebeServerSettings(value.serverSettings, (0, simple_validators_1.incrementOptions)('serverSettings', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.kernelOptions)) { | ||
output.kernelOptions = validateThebeKernelOptions(value.kernelOptions, (0, simple_validators_1.incrementOptions)('kernelOptions', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.savedSessionOptions)) { | ||
output.savedSessionOptions = validateThebeSavedSessionOptions(value.savedSessionOptions, (0, simple_validators_1.incrementOptions)('savedSessionOptions', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.mathjaxUrl)) { | ||
output.mathjaxUrl = (0, simple_validators_1.validateUrl)(value.mathjaxUrl, (0, simple_validators_1.incrementOptions)('mathjaxUrl', opts)); | ||
} | ||
if ((0, simple_validators_1.defined)(value.mathjaxConfig)) { | ||
output.mathjaxConfig = (0, simple_validators_1.validateString)(value.mathjaxConfig, (0, simple_validators_1.incrementOptions)('mathjaxConfig', opts)); | ||
} | ||
return output; | ||
} | ||
exports.validateThebe = validateThebe; | ||
function validateThebeServerSettings(input, opts) { | ||
const value = (0, simple_validators_1.validateObjectKeys)(input, { optional: THEBE_SERVER_SETTINGS_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if ((0, simple_validators_1.defined)(value.baseUrl)) { | ||
output.baseUrl = (0, simple_validators_1.validateUrl)(value.baseUrl, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.token)) { | ||
output.token = (0, simple_validators_1.validateString)(value.token, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.wsUrl)) { | ||
output.wsUrl = (0, simple_validators_1.validateUrl)(value.wsUrl, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.appendToken)) { | ||
output.appendToken = (0, simple_validators_1.validateBoolean)(value.appendToken, opts); | ||
} | ||
return output; | ||
} | ||
exports.validateThebeServerSettings = validateThebeServerSettings; | ||
function validateThebeKernelOptions(input, opts) { | ||
const value = (0, simple_validators_1.validateObjectKeys)(input, { optional: THEBE_KERNEL_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if ((0, simple_validators_1.defined)(value.kernelName)) { | ||
output.kernelName = (0, simple_validators_1.validateString)(value.kernelName, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.name)) { | ||
output.name = (0, simple_validators_1.validateString)(value.name, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.path)) { | ||
output.path = (0, simple_validators_1.validateString)(value.path, opts); | ||
} | ||
return output; | ||
} | ||
exports.validateThebeKernelOptions = validateThebeKernelOptions; | ||
function validateThebeSavedSessionOptions(input, opts) { | ||
const value = (0, simple_validators_1.validateObjectKeys)(input, { optional: THEBE_SAVED_SESSION_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if ((0, simple_validators_1.defined)(value.enabled)) { | ||
output.enabled = (0, simple_validators_1.validateBoolean)(value.enabled, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.maxAge)) { | ||
output.maxAge = validateStringOrNumber(value.maxAge, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.storagePrefix)) { | ||
output.storagePrefix = (0, simple_validators_1.validateString)(value.storagePrefix, opts); | ||
} | ||
return output; | ||
} | ||
exports.validateThebeSavedSessionOptions = validateThebeSavedSessionOptions; | ||
function validateThebeBinderOptions(input, opts) { | ||
const value = (0, simple_validators_1.validateObjectKeys)(input, { optional: THEBE_BINDER_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if ((0, simple_validators_1.defined)(value.binderUrl)) { | ||
output.binderUrl = (0, simple_validators_1.validateUrl)(value.binderUrl, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.ref)) { | ||
output.ref = (0, simple_validators_1.validateString)(value.ref, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.repo)) { | ||
output.repo = (0, simple_validators_1.validateString)(value.repo, opts); | ||
} | ||
if ((0, simple_validators_1.defined)(value.repoProvider)) { | ||
output.repoProvider = (0, simple_validators_1.validateString)(value.repoProvider, opts); | ||
} | ||
return output; | ||
} | ||
exports.validateThebeBinderOptions = validateThebeBinderOptions; | ||
/** | ||
* Validate Numbering object | ||
@@ -566,2 +696,5 @@ */ | ||
} | ||
if ((0, simple_validators_1.defined)(value.thebe)) { | ||
output.thebe = validateThebe(value.thebe, (0, simple_validators_1.incrementOptions)('thebe', opts)); | ||
} | ||
return output; | ||
@@ -568,0 +701,0 @@ } |
@@ -33,2 +33,3 @@ import doi from 'doi-utils'; | ||
'exports', | ||
'thebe', | ||
].concat(SITE_FRONTMATTER_KEYS); | ||
@@ -77,2 +78,17 @@ export const PAGE_FRONTMATTER_KEYS = [ | ||
const BIBLIO_KEYS = ['volume', 'issue', 'first_page', 'last_page']; | ||
const THEBE_KEYS = [ | ||
'useBinder', | ||
'useJupyterLite', | ||
'requestKernel', | ||
'binderOptions', | ||
'serverSettings', | ||
'kernelOptions', | ||
'savedSessionOptions', | ||
'mathjaxConfig', | ||
'mathjaxUrl', | ||
]; | ||
const THEBE_BINDER_OPTIONS_KEYS = ['binderUrl', 'ref', 'repo', 'repoProvider']; | ||
const THEBE_SERVER_SETTINGS_KEYS = ['baseUrl', 'token', 'wsUrl', 'appendToken']; | ||
const THEBE_KERNEL_OPTIONS_KEYS = ['kernelName', 'name', 'path']; | ||
const THEBE_SAVED_SESSION_OPTIONS_KEYS = ['enabled', 'maxAge', 'storagePrefix']; | ||
const NUMBERING_KEYS = [ | ||
@@ -256,2 +272,111 @@ 'enumerator', | ||
/** | ||
* Validate Thebe Object | ||
* | ||
* https://thebe-core.curve.space/docs-core/a-configuration | ||
*/ | ||
export function validateThebe(input, opts) { | ||
const value = validateObjectKeys(input, { optional: THEBE_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if (defined(value.useBinder)) { | ||
output.useBinder = validateBoolean(value.useBinder, incrementOptions('useBinder', opts)); | ||
} | ||
if (defined(value.useJupyterLite)) { | ||
output.useJupyterLite = validateBoolean(value.useJupyterLite, incrementOptions('useJupyterLite', opts)); | ||
} | ||
if (defined(value.requestKernel)) { | ||
output.requestKernel = validateBoolean(value.requestKernel, incrementOptions('requestKernel', opts)); | ||
} | ||
if (defined(value.binderOptions)) { | ||
output.binderOptions = validateThebeBinderOptions(value.binderOptions, incrementOptions('binderOptions', opts)); | ||
} | ||
if (defined(value.serverSettings)) { | ||
output.serverSettings = validateThebeServerSettings(value.serverSettings, incrementOptions('serverSettings', opts)); | ||
} | ||
if (defined(value.kernelOptions)) { | ||
output.kernelOptions = validateThebeKernelOptions(value.kernelOptions, incrementOptions('kernelOptions', opts)); | ||
} | ||
if (defined(value.savedSessionOptions)) { | ||
output.savedSessionOptions = validateThebeSavedSessionOptions(value.savedSessionOptions, incrementOptions('savedSessionOptions', opts)); | ||
} | ||
if (defined(value.mathjaxUrl)) { | ||
output.mathjaxUrl = validateUrl(value.mathjaxUrl, incrementOptions('mathjaxUrl', opts)); | ||
} | ||
if (defined(value.mathjaxConfig)) { | ||
output.mathjaxConfig = validateString(value.mathjaxConfig, incrementOptions('mathjaxConfig', opts)); | ||
} | ||
return output; | ||
} | ||
export function validateThebeServerSettings(input, opts) { | ||
const value = validateObjectKeys(input, { optional: THEBE_SERVER_SETTINGS_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if (defined(value.baseUrl)) { | ||
output.baseUrl = validateUrl(value.baseUrl, opts); | ||
} | ||
if (defined(value.token)) { | ||
output.token = validateString(value.token, opts); | ||
} | ||
if (defined(value.wsUrl)) { | ||
output.wsUrl = validateUrl(value.wsUrl, opts); | ||
} | ||
if (defined(value.appendToken)) { | ||
output.appendToken = validateBoolean(value.appendToken, opts); | ||
} | ||
return output; | ||
} | ||
export function validateThebeKernelOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: THEBE_KERNEL_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if (defined(value.kernelName)) { | ||
output.kernelName = validateString(value.kernelName, opts); | ||
} | ||
if (defined(value.name)) { | ||
output.name = validateString(value.name, opts); | ||
} | ||
if (defined(value.path)) { | ||
output.path = validateString(value.path, opts); | ||
} | ||
return output; | ||
} | ||
export function validateThebeSavedSessionOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: THEBE_SAVED_SESSION_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if (defined(value.enabled)) { | ||
output.enabled = validateBoolean(value.enabled, opts); | ||
} | ||
if (defined(value.maxAge)) { | ||
output.maxAge = validateStringOrNumber(value.maxAge, opts); | ||
} | ||
if (defined(value.storagePrefix)) { | ||
output.storagePrefix = validateString(value.storagePrefix, opts); | ||
} | ||
return output; | ||
} | ||
export function validateThebeBinderOptions(input, opts) { | ||
const value = validateObjectKeys(input, { optional: THEBE_BINDER_OPTIONS_KEYS }, opts); | ||
if (value === undefined) | ||
return undefined; | ||
const output = {}; | ||
if (defined(value.binderUrl)) { | ||
output.binderUrl = validateUrl(value.binderUrl, opts); | ||
} | ||
if (defined(value.ref)) { | ||
output.ref = validateString(value.ref, opts); | ||
} | ||
if (defined(value.repo)) { | ||
output.repo = validateString(value.repo, opts); | ||
} | ||
if (defined(value.repoProvider)) { | ||
output.repoProvider = validateString(value.repoProvider, opts); | ||
} | ||
return output; | ||
} | ||
/** | ||
* Validate Numbering object | ||
@@ -549,2 +674,5 @@ */ | ||
} | ||
if (defined(value.thebe)) { | ||
output.thebe = validateThebe(value.thebe, incrementOptions('thebe', opts)); | ||
} | ||
return output; | ||
@@ -551,0 +679,0 @@ } |
@@ -22,2 +22,35 @@ import type { CreditRole } from 'credit-roles'; | ||
}; | ||
export declare type Thebe = { | ||
useBinder?: boolean; | ||
useJupyterLite?: boolean; | ||
requestKernel?: boolean; | ||
binderOptions?: ThebeBinderOptions; | ||
serverSettings?: ThebeServerSettings; | ||
kernelOptions?: ThebeKernelOptions; | ||
savedSessionOptions?: ThebeSavedSessionOptions; | ||
mathjaxConfig?: string; | ||
mathjaxUrl?: string; | ||
}; | ||
export declare type ThebeBinderOptions = { | ||
binderUrl?: string; | ||
ref?: string; | ||
repo?: string; | ||
repoProvider?: string; | ||
}; | ||
export declare type ThebeServerSettings = { | ||
baseUrl?: string; | ||
token?: string; | ||
wsUrl?: string; | ||
appendToken?: boolean; | ||
}; | ||
export declare type ThebeKernelOptions = { | ||
kernelName?: string; | ||
name?: string; | ||
path?: string; | ||
}; | ||
export declare type ThebeSavedSessionOptions = { | ||
enabled?: boolean; | ||
maxAge?: string | number; | ||
storagePrefix?: string; | ||
}; | ||
export declare type Numbering = { | ||
@@ -101,2 +134,3 @@ enumerator?: string; | ||
exports?: Export[]; | ||
thebe?: Thebe; | ||
}; | ||
@@ -103,0 +137,0 @@ export declare type PageFrontmatter = Omit<ProjectFrontmatter, 'references'> & { |
import type { ValidationOptions } from 'simple-validators'; | ||
import type { Author, Biblio, Export, Jupytext, KernelSpec, Numbering, PageFrontmatter, ProjectFrontmatter, SiteFrontmatter, Venue } from './types'; | ||
import type { Author, Biblio, Export, Jupytext, KernelSpec, Numbering, PageFrontmatter, ProjectFrontmatter, SiteFrontmatter, Venue, Thebe, ThebeBinderOptions, ThebeKernelOptions, ThebeSavedSessionOptions, ThebeServerSettings } from './types'; | ||
export declare const SITE_FRONTMATTER_KEYS: string[]; | ||
@@ -25,2 +25,12 @@ export declare const PROJECT_FRONTMATTER_KEYS: string[]; | ||
/** | ||
* Validate Thebe Object | ||
* | ||
* https://thebe-core.curve.space/docs-core/a-configuration | ||
*/ | ||
export declare function validateThebe(input: any, opts: ValidationOptions): Thebe | undefined; | ||
export declare function validateThebeServerSettings(input: any, opts: ValidationOptions): ThebeServerSettings | undefined; | ||
export declare function validateThebeKernelOptions(input: any, opts: ValidationOptions): ThebeKernelOptions | undefined; | ||
export declare function validateThebeSavedSessionOptions(input: any, opts: ValidationOptions): ThebeSavedSessionOptions | undefined; | ||
export declare function validateThebeBinderOptions(input: any, opts: ValidationOptions): ThebeBinderOptions | undefined; | ||
/** | ||
* Validate Numbering object | ||
@@ -27,0 +37,0 @@ */ |
{ | ||
"name": "myst-frontmatter", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"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
173082
3407