ajv#JSONSchemaType TypeScript Examples
The following examples show how to use
ajv#JSONSchemaType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From dendron with GNU Affero General Public License v3.0 | 7 votes |
static validate<T>(config: Partial<T>, schema: JSONSchemaType<T>) {
const validateConfig = ajv.compile(schema);
const valid = validateConfig(config);
if (!valid) {
const errors = ajv.errorsText(validateConfig.errors);
throw new DendronError({
message: `validation errors: ${errors}`,
payload: `error: ${JSON.stringify(validateConfig.errors)}`,
});
}
}
Example #2
Source File: GoogleDocsConnection.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
static getSchema(): JSONSchemaType<GoogleDocsConnection> {
return {
type: "object",
required: ["connectionId", "serviceType", "accessToken", "refreshToken"],
properties: {
connectionId: {
description: "configuration ID",
type: "string",
},
serviceType: {
type: "string",
description: "Connection Type",
default: ExternalService.GoogleDocs,
},
accessToken: {
type: "string",
description: "google docs personal access token",
},
refreshToken: {
type: "string",
description: "google docs personal refresh token",
},
expirationTime: {
type: "number",
description: "expiration time of access token",
},
},
};
}
Example #3
Source File: NotionExportPodV2.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
static config(): JSONSchemaType<NotionV2PodConfig> {
return ConfigFileUtils.createExportConfig({
required: ["connectionId", "parentPageId"],
properties: {
connectionId: {
description: "ID of the Notion Connected Service",
type: "string",
},
parentPageId: {
description: "ID of parent page in notion",
type: "string",
},
},
}) as JSONSchemaType<NotionV2PodConfig>;
}
Example #4
Source File: MarkdownExportPodV2.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
static config(): JSONSchemaType<MarkdownV2PodConfig> {
return ConfigFileUtils.createExportConfig({
required: ["destination"],
properties: {
wikiLinkToURL: {
description: "How to convert the wikilinks",
type: "boolean",
default: false,
nullable: true,
},
destination: {
description:
"export destination. Specify either a file path or 'clipboard' to export to your clipboard",
type: "string",
},
convertTagNotesToLinks: {
type: "boolean",
default: false,
nullable: true,
},
convertUserNotesToLinks: {
type: "boolean",
default: false,
nullable: true,
},
addFrontmatterTitle: {
type: "boolean",
nullable: true,
},
},
}) as JSONSchemaType<MarkdownV2PodConfig>;
}
Example #5
Source File: JSONExportPodV2.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
static config(): JSONSchemaType<JSONV2PodConfig> {
return ConfigFileUtils.createExportConfig({
required: ["destination"],
properties: {
destination: {
description:
"export destination. Specify either a file path or 'clipboard' to export to your clipboard",
type: "string",
},
},
}) as JSONSchemaType<JSONV2PodConfig>;
}
Example #6
Source File: GoogleDocsExportPodV2.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
static config(): JSONSchemaType<GoogleDocsV2PodConfig> {
return ConfigFileUtils.createExportConfig({
required: ["connectionId"],
properties: {
connectionId: {
description: "ID of the Airtable Connected Service",
type: "string",
},
},
}) as JSONSchemaType<GoogleDocsV2PodConfig>;
}
Example #7
Source File: AirtableExportPodV2.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
static config(): JSONSchemaType<PersistedAirtablePodConfig> {
return ConfigFileUtils.createExportConfig({
required: ["connectionId", "baseId", "tableName", "sourceFieldMapping"],
properties: {
connectionId: {
description: "ID of the Airtable Connected Service",
type: "string",
},
baseId: {
description: "airtable base id",
type: "string",
},
tableName: { type: "string", description: "Name of the airtable" },
sourceFieldMapping: {
type: "object",
required: [],
description:
"mapping of airtable fields with the note eg: {Created On: created, Notes: body}",
},
filters: {
type: "object",
required: [],
nullable: true,
properties: {
fname: {
type: "array",
items: {
type: "string",
},
},
},
},
},
}) as JSONSchemaType<PersistedAirtablePodConfig>;
}
Example #8
Source File: NotionPodConfig.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
export function createRunnableNotionV2PodConfigSchema(): JSONSchemaType<RunnableNotionV2PodConfig> {
return {
type: "object",
required: ["apiKey", "exportScope", "parentPageId"],
properties: {
apiKey: {
type: "string",
},
exportScope: {
type: "string",
},
parentPageId: {
type: "string",
},
},
};
}
Example #9
Source File: JSONPodConfig.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
/**
*
* @returns
* creates an AJV schema for runnable config
*/
export function createRunnableJSONV2PodConfigSchema(): JSONSchemaType<RunnableJSONV2PodConfig> {
return {
type: "object",
required: ["destination", "exportScope"],
properties: {
destination: {
type: "string",
},
exportScope: {
type: "string",
},
},
};
}
Example #10
Source File: GoogleDocsConfig.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
export function createRunnableGoogleDocsV2PodConfigSchema(): JSONSchemaType<RunnableGoogleDocsV2PodConfig> {
return {
type: "object",
required: [
"accessToken",
"refreshToken",
"expirationTime",
"exportScope",
"connectionId",
],
properties: {
accessToken: {
type: "string",
},
refreshToken: {
type: "string",
},
expirationTime: {
type: "number",
},
connectionId: {
type: "string",
},
exportScope: {
type: "string",
},
description: {
type: "string",
nullable: true,
},
},
};
}
Example #11
Source File: NotionConnection.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
static getSchema(): JSONSchemaType<NotionConnection> {
return {
type: "object",
required: ["connectionId", "serviceType", "apiKey"],
properties: {
connectionId: {
description: "configuration ID",
type: "string",
},
serviceType: {
type: "string",
description: "Connection Type",
default: ExternalService.Notion,
},
apiKey: { type: "string", description: "API Key to access Notion" },
},
};
}
Example #12
Source File: AirtableConnection.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
static getSchema(): JSONSchemaType<AirtableConnection> {
return {
type: "object",
required: ["connectionId", "serviceType", "apiKey"],
properties: {
connectionId: {
description: "configuration ID",
type: "string",
},
serviceType: {
type: "string",
description: "Connection Type",
default: ExternalService.Airtable,
},
apiKey: { type: "string", description: "API Key to access Airtable" },
},
};
}
Example #13
Source File: ReplayCursorSettings.ts From rewind with MIT License | 6 votes |
ReplayCursorSettingsSchema: JSONSchemaType<ReplayCursorSettings> = {
type: "object",
properties: {
showTrail: { type: "boolean", default: DEFAULT_REPLAY_CURSOR_SETTINGS.showTrail },
scale: { type: "number", default: DEFAULT_REPLAY_CURSOR_SETTINGS.scale },
enabled: { type: "boolean", default: DEFAULT_REPLAY_CURSOR_SETTINGS.enabled },
scaleWithCS: { type: "boolean", default: DEFAULT_REPLAY_CURSOR_SETTINGS.scaleWithCS },
smoothCursorTrail: { type: "boolean", default: DEFAULT_REPLAY_CURSOR_SETTINGS.smoothCursorTrail },
},
required: [],
}
Example #14
Source File: BeatmapBackgroundSettings.ts From rewind with MIT License | 6 votes |
BeatmapBackgroundSettingsSchema: JSONSchemaType<BeatmapBackgroundSettings> = {
type: "object",
properties: {
dim: { type: "number", default: DEFAULT_BEATMAP_BACKGROUND_SETTINGS.dim },
blur: { type: "number", default: DEFAULT_BEATMAP_BACKGROUND_SETTINGS.blur },
enabled: { type: "boolean", default: DEFAULT_BEATMAP_BACKGROUND_SETTINGS.enabled },
},
required: [],
}
Example #15
Source File: AudioSettings.ts From rewind with MIT License | 6 votes |
AudioSettingsSchema: JSONSchemaType<AudioSettings> = {
type: "object",
properties: {
muted: { type: "boolean", default: DEFAULT_AUDIO_SETTINGS.muted },
volume: {
type: "object",
properties: {
master: { type: "number", default: DEFAULT_AUDIO_SETTINGS.volume.master },
music: { type: "number", default: DEFAULT_AUDIO_SETTINGS.volume.music },
effects: { type: "number", default: DEFAULT_AUDIO_SETTINGS.volume.effects },
},
required: [],
},
},
required: [],
}
Example #16
Source File: AnalysisCursorSettings.ts From rewind with MIT License | 6 votes |
AnalysisCursorSettingsSchema: JSONSchemaType<AnalysisCursorSettings> = {
type: "object",
properties: {
scale: { type: "number", default: DEFAULT_ANALYSIS_CURSOR_SETTINGS.scale },
enabled: { type: "boolean", default: DEFAULT_ANALYSIS_CURSOR_SETTINGS.enabled },
scaleWithCS: { type: "boolean", default: DEFAULT_ANALYSIS_CURSOR_SETTINGS.scaleWithCS },
colorNoKeys: { type: "number", default: DEFAULT_ANALYSIS_CURSOR_SETTINGS.colorNoKeys },
colorKey1: { type: "number", default: DEFAULT_ANALYSIS_CURSOR_SETTINGS.colorKey1 },
colorKey2: { type: "number", default: DEFAULT_ANALYSIS_CURSOR_SETTINGS.colorKey2 },
colorBothKeys: { type: "number", default: DEFAULT_ANALYSIS_CURSOR_SETTINGS.colorBothKeys },
},
required: [],
}
Example #17
Source File: config.ts From rewind with MIT License | 5 votes |
RewindElectronSettingsSchema: JSONSchemaType<RewindElectronSettings> = {
type: "object",
properties: {
osuPath: { type: "string", default: DEFAULT_REWIND_ELECTRON_SETTINGS.osuPath },
},
required: [],
}
Example #18
Source File: SkinSettings.ts From rewind with MIT License | 5 votes |
SkinSettingsSchema: JSONSchemaType<SkinSettings> = {
type: "object",
properties: {
preferredSkinId: { type: "string", default: DEFAULT_SKIN_SETTINGS.preferredSkinId },
},
required: ["preferredSkinId"],
}
Example #19
Source File: AirtablePodConfig.ts From dendron with GNU Affero General Public License v3.0 | 5 votes |
export function createRunnableAirtableV2PodConfigSchema(): JSONSchemaType<RunnableAirtableV2PodConfig> {
return {
type: "object",
required: [
"apiKey",
"baseId",
"tableName",
"sourceFieldMapping",
"exportScope",
"podId",
],
properties: {
apiKey: {
type: "string",
},
baseId: {
type: "string",
},
tableName: {
type: "string",
},
sourceFieldMapping: {
type: "object",
required: [],
},
exportScope: {
type: "string",
},
filters: {
type: "object",
required: [],
nullable: true,
properties: {
fname: {
type: "array",
items: {
type: "string",
},
},
},
},
podId: {
type: "string",
},
},
};
}
Example #20
Source File: PlaybarSettings.ts From rewind with MIT License | 5 votes |
PlaybarSettingsSchema: JSONSchemaType<PlaybarSettings> = {
type: "object",
properties: {
difficultyGraphEnabled: { type: "boolean", default: DEFAULT_PLAY_BAR_SETTINGS.difficultyGraphEnabled },
},
required: [],
}
Example #21
Source File: MarkdownPodConfig.ts From dendron with GNU Affero General Public License v3.0 | 5 votes |
/**
*
* @returns
* creates an AJV schema for runnable config
*/
export function createRunnableMarkdownV2PodConfigSchema(): JSONSchemaType<RunnableMarkdownV2PodConfig> {
return {
type: "object",
required: ["destination", "exportScope"],
properties: {
destination: {
type: "string",
},
exportScope: {
type: "string",
},
description: {
type: "string",
nullable: true,
},
wikiLinkToURL: {
type: "boolean",
default: false,
nullable: true,
},
convertTagNotesToLinks: {
type: "boolean",
default: false,
nullable: true,
},
convertUserNotesToLinks: {
type: "boolean",
default: false,
nullable: true,
},
addFrontmatterTitle: {
type: "boolean",
nullable: true,
},
},
};
}
Example #22
Source File: HitErrorBarSettings.ts From rewind with MIT License | 5 votes |
HitErrorBarSettingsSchema: JSONSchemaType<HitErrorBarSettings> = {
type: "object",
properties: {
enabled: { type: "boolean", default: DEFAULT_HIT_ERROR_BAR_SETTINGS.enabled },
scale: { type: "number", default: DEFAULT_HIT_ERROR_BAR_SETTINGS.scale },
},
required: [],
}
Example #23
Source File: BeatmapRenderSettings.ts From rewind with MIT License | 5 votes |
BeatmapRenderSettingsSchema: JSONSchemaType<BeatmapRenderSettings> = {
type: "object",
properties: {
sliderDevMode: { type: "boolean", default: DEFAULT_BEATMAP_RENDER_SETTINGS.sliderDevMode },
drawSliderEnds: { type: "boolean", default: DEFAULT_BEATMAP_RENDER_SETTINGS.drawSliderEnds },
},
required: [],
}
Example #24
Source File: LocalStorageService.ts From rewind with MIT License | 5 votes |
constructor(private readonly localStorageKey: string, schema: JSONSchemaType<T>, private readonly defaultValue: T) {
this.validate = ajv.compile<T>(schema);
}