myst-frontmatter
Advanced tools
Comparing version 1.1.16 to 1.1.17
@@ -7,3 +7,3 @@ import type { Biblio } from '../biblio/types.js'; | ||
import type { SiteFrontmatter } from '../site/types.js'; | ||
import type { Thebe } from '../thebe/types.js'; | ||
import type { ExpandedThebeFrontmatter } from '../thebe/types.js'; | ||
export type ProjectAndPageFrontmatter = SiteFrontmatter & { | ||
@@ -38,4 +38,4 @@ date?: string; | ||
resources?: string[]; | ||
thebe?: Thebe; | ||
thebe?: ExpandedThebeFrontmatter; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -165,3 +165,3 @@ import { defined, filterKeys, incrementOptions, validateBoolean, validateDate, validateList, validateObject, validateObjectKeys, validateString, validateUrl, } from 'simple-validators'; | ||
if (defined(value.thebe)) { | ||
const result = validateThebe(value.thebe, incrementOptions('thebe', opts)); | ||
const result = validateThebe(value.thebe, output.github, incrementOptions('thebe', opts)); | ||
if (result && Object.values(result).filter((val) => val !== undefined).length > 0) { | ||
@@ -168,0 +168,0 @@ output.thebe = result; |
@@ -1,2 +0,3 @@ | ||
export type Thebe = { | ||
export type ThebeFrontmatter = boolean | string | ThebeFrontmatterObject; | ||
export type ThebeFrontmatterObject = { | ||
lite?: boolean; | ||
@@ -11,2 +12,5 @@ binder?: boolean | BinderHubOptions; | ||
}; | ||
export type ExpandedThebeFrontmatter = Omit<ThebeFrontmatterObject, 'binder'> & { | ||
binder?: BinderHubOptions; | ||
}; | ||
export type WellKnownRepoProviders = 'github' | 'gitlab' | 'git' | 'gist'; | ||
@@ -13,0 +17,0 @@ export type BinderProviders = WellKnownRepoProviders | string; |
import type { ValidationOptions } from 'simple-validators'; | ||
import type { BinderHubOptions, JupyterServerOptions, Thebe } from './types.js'; | ||
import type { BinderHubOptions, JupyterServerOptions, ExpandedThebeFrontmatter, ThebeFrontmatter } from './types.js'; | ||
/** | ||
@@ -8,5 +8,5 @@ * Validate Thebe options | ||
*/ | ||
export declare function validateThebe(input: any, opts: ValidationOptions): Thebe | undefined; | ||
export declare function validateBinderHubOptions(input: BinderHubOptions, opts: ValidationOptions): BinderHubOptions | undefined; | ||
export declare function validateThebe(input: ThebeFrontmatter, github: string | undefined, opts: ValidationOptions): ExpandedThebeFrontmatter | undefined; | ||
export declare function validateBinderHubOptions(input: BinderHubOptions, github: string | undefined, opts: ValidationOptions): BinderHubOptions | undefined; | ||
export declare function validateJupyterServerOptions(input: any, opts: ValidationOptions): JupyterServerOptions | undefined; | ||
//# sourceMappingURL=validators.d.ts.map |
@@ -21,3 +21,3 @@ import { defined, incrementOptions, validateBoolean, validateObjectKeys, validateString, validateUrl, validationError, } from 'simple-validators'; | ||
*/ | ||
export function validateThebe(input, opts) { | ||
export function validateThebe(input, github, opts) { | ||
if (input === false) | ||
@@ -30,3 +30,3 @@ return undefined; | ||
} | ||
let inputObject = input; | ||
let inputObject; | ||
if (input === true || input === 'binder') { | ||
@@ -36,2 +36,5 @@ // expand boolean methods to object | ||
} | ||
else { | ||
inputObject = input; | ||
} | ||
const value = validateObjectKeys(inputObject, { optional: THEBE_KEYS }, opts); | ||
@@ -45,3 +48,3 @@ if (value === undefined) | ||
if (value.binder) { | ||
output.binder = validateBinderHubOptions(value.binder === true ? {} : value.binder, { | ||
output.binder = validateBinderHubOptions(value.binder === true ? {} : value.binder, github, { | ||
...incrementOptions('binder', opts), | ||
@@ -72,3 +75,3 @@ errorLogFn: (msg) => validationError(msg.split('object').join('an object or boolean'), opts), | ||
} | ||
export function validateBinderHubOptions(input, opts) { | ||
export function validateBinderHubOptions(input, github, opts) { | ||
var _a, _b; | ||
@@ -93,2 +96,3 @@ // input expected to be resolved to an object at this stage. | ||
if ((_b = output.provider) === null || _b === void 0 ? void 0 : _b.match(/^(git|github|gitlab|gist)$/i)) { | ||
const fallbackRepo = github ? github : 'executablebooks/thebe-binder-base'; | ||
// first try to validate repo as a github username/repo string | ||
@@ -102,3 +106,3 @@ output.repo = value.repo | ||
}) | ||
: 'executablebooks/thebe-binder-base'; | ||
: fallbackRepo; | ||
// then if not, validate as a url and report errors based on url validation | ||
@@ -105,0 +109,0 @@ // this will encourage use of fully qualified urls |
{ | ||
"name": "myst-frontmatter", | ||
"version": "1.1.16", | ||
"version": "1.1.17", | ||
"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
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
176198
4555