Skip to content

Commit 7cef1d9

Browse files
authored
deprecation(yaml): cleanup schema exports (#4566)
1 parent 44660ea commit 7cef1d9

File tree

6 files changed

+95
-26
lines changed

6 files changed

+95
-26
lines changed

yaml/schema/core.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@
55
// This module is browser compatible.
66

77
import { Schema } from "../schema.ts";
8-
import { json } from "./json.ts";
8+
import { JSON_SCHEMA } from "./json.ts";
99

10-
// Standard YAML's Core schema.
11-
// http://www.yaml.org/spec/1.2/spec.html#id2804923
12-
export const core: Schema = new Schema({
13-
include: [json],
10+
/**
11+
* Standard YAML's core schema.
12+
*
13+
* @see {@link http://www.yaml.org/spec/1.2/spec.html#id2804923}
14+
*/
15+
export const CORE_SCHEMA: Schema = new Schema({
16+
include: [JSON_SCHEMA],
1417
});
18+
19+
/**
20+
* Standard YAML's core schema.
21+
*
22+
* @see {@link http://www.yaml.org/spec/1.2/spec.html#id2804923}
23+
*
24+
* @deprecated (will be removed in 1.0.0) Use {@link CORE_SCHEMA} instead.
25+
*/
26+
export const core = CORE_SCHEMA;

yaml/schema/default.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66

77
import { Schema } from "../schema.ts";
88
import { binary, merge, omap, pairs, set, timestamp } from "../_type/mod.ts";
9-
import { core } from "./core.ts";
9+
import { CORE_SCHEMA } from "./core.ts";
1010

11-
// JS-YAML's default schema for `safeLoad` function.
12-
// It is not described in the YAML specification.
13-
export const def: Schema = new Schema({
11+
/**
12+
* Default YAML schema. It is not described in the YAML specification.
13+
*/
14+
export const DEFAULT_SCHEMA: Schema = new Schema({
1415
explicit: [binary, omap, pairs, set],
1516
implicit: [timestamp, merge],
16-
include: [core],
17+
include: [CORE_SCHEMA],
1718
});
19+
20+
/**
21+
* Default YAML schema. It is not described in the YAML specification.
22+
*
23+
* @deprecated (will be removed in 1.0.0) Use {@link DEFAULT_SCHEMA} instead.
24+
*/
25+
export const def = DEFAULT_SCHEMA;

yaml/schema/extended.ts

+35-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { Schema } from "../schema.ts";
55
import { regexp, undefinedType } from "../_type/mod.ts";
6-
import { def } from "./default.ts";
6+
import { DEFAULT_SCHEMA } from "./default.ts";
77

88
/***
99
* Extends JS-YAML default schema with additional JavaScript types
@@ -33,7 +33,39 @@ import { def } from "./default.ts";
3333
* );
3434
* ```
3535
*/
36-
export const extended: Schema = new Schema({
36+
export const EXTENDED_SCHEMA: Schema = new Schema({
3737
explicit: [regexp, undefinedType],
38-
include: [def],
38+
include: [DEFAULT_SCHEMA],
3939
});
40+
41+
/***
42+
* Extends JS-YAML default schema with additional JavaScript types
43+
* It is not described in the YAML specification.
44+
* Functions are no longer supported for security reasons.
45+
*
46+
* @example
47+
* ```ts
48+
* import {
49+
* EXTENDED_SCHEMA,
50+
* parse,
51+
* } from "https://deno.land/std@$STD_VERSION/yaml/mod.ts";
52+
*
53+
* const data = parse(
54+
* `
55+
* regexp:
56+
* simple: !!js/regexp foobar
57+
* modifiers: !!js/regexp /foobar/mi
58+
* undefined: !!js/undefined ~
59+
* # Disabled, see: https://github.com/denoland/deno_std/pull/1275
60+
* # function: !!js/function >
61+
* # function foobar() {
62+
* # return 'hello world!';
63+
* # }
64+
* `,
65+
* { schema: EXTENDED_SCHEMA },
66+
* );
67+
* ```
68+
*
69+
* @deprecated (will be removed in 1.0.0) Use {@link EXTENDED_SCHEMA} instead.
70+
*/
71+
export const extended = EXTENDED_SCHEMA;

yaml/schema/failsafe.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,20 @@
77
import { Schema } from "../schema.ts";
88
import { map, seq, str } from "../_type/mod.ts";
99

10-
// Standard YAML's Failsafe schema.
11-
// http://www.yaml.org/spec/1.2/spec.html#id2802346
12-
export const failsafe: Schema = new Schema({
10+
/**
11+
* Standard YAML's failsafe schema.
12+
*
13+
* @see {@link http://www.yaml.org/spec/1.2/spec.html#id2802346}
14+
*/
15+
export const FAILSAFE_SCHEMA: Schema = new Schema({
1316
explicit: [str, seq, map],
1417
});
18+
19+
/**
20+
* Standard YAML's failsafe schema.
21+
*
22+
* @see {@link http://www.yaml.org/spec/1.2/spec.html#id2802346}
23+
*
24+
* @deprecated (will be removed in 1.0.0) Use {@link FAILSAFE_SCHEMA} instead.
25+
*/
26+
export const failsafe = FAILSAFE_SCHEMA;

yaml/schema/json.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66

77
import { Schema } from "../schema.ts";
88
import { bool, float, int, nil } from "../_type/mod.ts";
9-
import { failsafe } from "./failsafe.ts";
9+
import { FAILSAFE_SCHEMA } from "./failsafe.ts";
1010

11-
// Standard YAML's JSON schema.
12-
// http://www.yaml.org/spec/1.2/spec.html#id2803231
13-
export const json: Schema = new Schema({
11+
/**
12+
* Standard YAML's JSON schema.
13+
*
14+
* @see {@link http://www.yaml.org/spec/1.2/spec.html#id2803231}
15+
*
16+
* @deprecated (will be removed in 1.0.0) Use {@link JSON_SCHEMA} instead.
17+
*/
18+
export const JSON_SCHEMA: Schema = new Schema({
1419
implicit: [nil, bool, int, float],
15-
include: [failsafe],
20+
include: [FAILSAFE_SCHEMA],
1621
});

yaml/schema/mod.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
55
// This module is browser compatible.
66

7-
export { core as CORE_SCHEMA } from "./core.ts";
8-
export { def as DEFAULT_SCHEMA } from "./default.ts";
9-
export { extended as EXTENDED_SCHEMA } from "./extended.ts";
10-
export { failsafe as FAILSAFE_SCHEMA } from "./failsafe.ts";
11-
export { json as JSON_SCHEMA } from "./json.ts";
7+
export { CORE_SCHEMA } from "./core.ts";
8+
export { DEFAULT_SCHEMA } from "./default.ts";
9+
export { EXTENDED_SCHEMA } from "./extended.ts";
10+
export { FAILSAFE_SCHEMA } from "./failsafe.ts";
11+
export { JSON_SCHEMA } from "./json.ts";

0 commit comments

Comments
 (0)