@tinacms/graphql 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/util.d.ts +8 -2
- package/dist/index.js +67 -29
- package/dist/resolver/index.d.ts +4 -0
- package/package.json +7 -6
package/dist/database/util.d.ts
CHANGED
|
@@ -11,7 +11,13 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import * as yup from 'yup';
|
|
14
|
-
export declare const stringifyFile: (content: object, format: FormatType | string, keepTemplateKey: boolean
|
|
15
|
-
|
|
14
|
+
export declare const stringifyFile: (content: object, format: FormatType | string, keepTemplateKey: boolean, markdownParseConfig?: {
|
|
15
|
+
frontmatterFormat?: 'toml' | 'yaml' | 'json';
|
|
16
|
+
frontmatterDelimiters?: [string, string] | string;
|
|
17
|
+
}) => string;
|
|
18
|
+
export declare const parseFile: <T extends object>(content: string, format: FormatType | string, yupSchema: (args: typeof yup) => yup.ObjectSchema<any>, markdownParseConfig?: {
|
|
19
|
+
frontmatterFormat?: 'toml' | 'yaml' | 'json';
|
|
20
|
+
frontmatterDelimiters?: [string, string] | string;
|
|
21
|
+
}) => T;
|
|
16
22
|
export declare type FormatType = 'json' | 'md' | 'mdx' | 'markdown';
|
|
17
23
|
export declare const normalizePath: (filepath: string) => string;
|
package/dist/index.js
CHANGED
|
@@ -2454,7 +2454,7 @@ var validateField = async (field) => {
|
|
|
2454
2454
|
|
|
2455
2455
|
// package.json
|
|
2456
2456
|
var name = "@tinacms/graphql";
|
|
2457
|
-
var version = "1.0.
|
|
2457
|
+
var version = "1.0.5";
|
|
2458
2458
|
var main = "dist/index.js";
|
|
2459
2459
|
var typings = "dist/index.d.ts";
|
|
2460
2460
|
var files = [
|
|
@@ -2481,9 +2481,10 @@ var scripts = {
|
|
|
2481
2481
|
};
|
|
2482
2482
|
var dependencies = {
|
|
2483
2483
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
2484
|
+
"@iarna/toml": "^2.2.5",
|
|
2484
2485
|
"@tinacms/datalayer": "workspace:*",
|
|
2485
|
-
"@tinacms/schema-tools": "workspace:*",
|
|
2486
2486
|
"@tinacms/mdx": "workspace:*",
|
|
2487
|
+
"@tinacms/schema-tools": "workspace:*",
|
|
2487
2488
|
"body-parser": "^1.19.0",
|
|
2488
2489
|
cors: "^2.8.5",
|
|
2489
2490
|
dataloader: "^2.0.0",
|
|
@@ -2498,7 +2499,7 @@ var dependencies = {
|
|
|
2498
2499
|
graphql: "15.8.0",
|
|
2499
2500
|
"graphql-type-json": "^0.3.2",
|
|
2500
2501
|
"gray-matter": "^4.0.2",
|
|
2501
|
-
"js-yaml": "^3.14.
|
|
2502
|
+
"js-yaml": "^3.14.1",
|
|
2502
2503
|
leveldown: "^6.1.0",
|
|
2503
2504
|
lodash: "^4.17.20",
|
|
2504
2505
|
mdast: "^3.0.0",
|
|
@@ -3650,46 +3651,67 @@ var import_path3 = __toModule(require("path"));
|
|
|
3650
3651
|
var import_graphql5 = __toModule(require("graphql"));
|
|
3651
3652
|
|
|
3652
3653
|
// src/database/util.ts
|
|
3654
|
+
var import_toml = __toModule(require("@iarna/toml"));
|
|
3655
|
+
var import_js_yaml = __toModule(require("js-yaml"));
|
|
3653
3656
|
var import_gray_matter = __toModule(require("gray-matter"));
|
|
3654
|
-
var
|
|
3657
|
+
var matterEngines = {
|
|
3658
|
+
toml: {
|
|
3659
|
+
parse: (val) => import_toml.default.parse(val),
|
|
3660
|
+
stringify: (val) => import_toml.default.stringify(val)
|
|
3661
|
+
}
|
|
3662
|
+
};
|
|
3663
|
+
var stringifyFile = (content, format, keepTemplateKey, markdownParseConfig) => {
|
|
3664
|
+
const _a = content, {
|
|
3665
|
+
_relativePath,
|
|
3666
|
+
_keepTemplateKey,
|
|
3667
|
+
_id,
|
|
3668
|
+
_template,
|
|
3669
|
+
_collection,
|
|
3670
|
+
$_body
|
|
3671
|
+
} = _a, rest = __objRest(_a, [
|
|
3672
|
+
"_relativePath",
|
|
3673
|
+
"_keepTemplateKey",
|
|
3674
|
+
"_id",
|
|
3675
|
+
"_template",
|
|
3676
|
+
"_collection",
|
|
3677
|
+
"$_body"
|
|
3678
|
+
]);
|
|
3679
|
+
const extra = {};
|
|
3680
|
+
if (keepTemplateKey) {
|
|
3681
|
+
extra["_template"] = _template;
|
|
3682
|
+
}
|
|
3683
|
+
const strippedContent = __spreadValues(__spreadValues({}, rest), extra);
|
|
3655
3684
|
switch (format) {
|
|
3656
3685
|
case ".markdown":
|
|
3657
3686
|
case ".mdx":
|
|
3658
3687
|
case ".md":
|
|
3659
|
-
const _a = content, {
|
|
3660
|
-
_relativePath,
|
|
3661
|
-
_keepTemplateKey,
|
|
3662
|
-
_id,
|
|
3663
|
-
_template,
|
|
3664
|
-
_collection,
|
|
3665
|
-
$_body
|
|
3666
|
-
} = _a, rest = __objRest(_a, [
|
|
3667
|
-
"_relativePath",
|
|
3668
|
-
"_keepTemplateKey",
|
|
3669
|
-
"_id",
|
|
3670
|
-
"_template",
|
|
3671
|
-
"_collection",
|
|
3672
|
-
"$_body"
|
|
3673
|
-
]);
|
|
3674
|
-
const extra = {};
|
|
3675
|
-
if (keepTemplateKey) {
|
|
3676
|
-
extra["_template"] = _template;
|
|
3677
|
-
}
|
|
3678
3688
|
const ok = import_gray_matter.default.stringify(typeof $_body === "undefined" ? "" : `
|
|
3679
|
-
${$_body}`,
|
|
3689
|
+
${$_body}`, strippedContent, {
|
|
3690
|
+
language: (markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterFormat) || "yaml",
|
|
3691
|
+
engines: matterEngines,
|
|
3692
|
+
delimiters: (markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterDelimiters) || "---"
|
|
3693
|
+
});
|
|
3680
3694
|
return ok;
|
|
3681
3695
|
case ".json":
|
|
3682
|
-
return JSON.stringify(
|
|
3696
|
+
return JSON.stringify(strippedContent, null, 2);
|
|
3697
|
+
case ".yaml":
|
|
3698
|
+
return import_js_yaml.default.safeDump(strippedContent);
|
|
3699
|
+
case ".toml":
|
|
3700
|
+
return import_toml.default.stringify(strippedContent);
|
|
3683
3701
|
default:
|
|
3684
3702
|
throw new Error(`Must specify a valid format, got ${format}`);
|
|
3685
3703
|
}
|
|
3686
3704
|
};
|
|
3687
|
-
var parseFile = (content, format, yupSchema) => {
|
|
3705
|
+
var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
3688
3706
|
switch (format) {
|
|
3689
3707
|
case ".markdown":
|
|
3690
3708
|
case ".mdx":
|
|
3691
3709
|
case ".md":
|
|
3692
|
-
const contentJSON = (0, import_gray_matter.default)(content || ""
|
|
3710
|
+
const contentJSON = (0, import_gray_matter.default)(content || "", {
|
|
3711
|
+
language: (markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterFormat) || "yaml",
|
|
3712
|
+
delimiters: (markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterDelimiters) || "---",
|
|
3713
|
+
engines: matterEngines
|
|
3714
|
+
});
|
|
3693
3715
|
const markdownData = __spreadProps(__spreadValues({}, contentJSON.data), {
|
|
3694
3716
|
$_body: contentJSON.content
|
|
3695
3717
|
});
|
|
@@ -3700,6 +3722,16 @@ var parseFile = (content, format, yupSchema) => {
|
|
|
3700
3722
|
return {};
|
|
3701
3723
|
}
|
|
3702
3724
|
return JSON.parse(content);
|
|
3725
|
+
case ".toml":
|
|
3726
|
+
if (!content) {
|
|
3727
|
+
return {};
|
|
3728
|
+
}
|
|
3729
|
+
return import_toml.default.parse(content);
|
|
3730
|
+
case ".yaml":
|
|
3731
|
+
if (!content) {
|
|
3732
|
+
return {};
|
|
3733
|
+
}
|
|
3734
|
+
return import_js_yaml.default.safeLoad(content);
|
|
3703
3735
|
default:
|
|
3704
3736
|
throw new Error(`Must specify a valid format, got ${format}`);
|
|
3705
3737
|
}
|
|
@@ -3850,7 +3882,10 @@ var Database = class {
|
|
|
3850
3882
|
payload = data;
|
|
3851
3883
|
}
|
|
3852
3884
|
const extension = import_path3.default.extname(filepath);
|
|
3853
|
-
const stringifiedFile = stringifyFile(payload, extension, templateInfo.type === "union"
|
|
3885
|
+
const stringifiedFile = stringifyFile(payload, extension, templateInfo.type === "union", {
|
|
3886
|
+
frontmatterFormat: collection == null ? void 0 : collection.frontmatterFormat,
|
|
3887
|
+
frontmatterDelimiters: collection == null ? void 0 : collection.frontmatterDelimiters
|
|
3888
|
+
});
|
|
3854
3889
|
return {
|
|
3855
3890
|
stringifiedFile,
|
|
3856
3891
|
payload,
|
|
@@ -4149,7 +4184,10 @@ var _indexContent = async (database, documentPaths, collection) => {
|
|
|
4149
4184
|
await sequential(documentPaths, async (filepath) => {
|
|
4150
4185
|
try {
|
|
4151
4186
|
const dataString = await database.bridge.get(normalizePath(filepath));
|
|
4152
|
-
const data = parseFile(dataString, import_path3.default.extname(filepath), (yup3) => yup3.object({})
|
|
4187
|
+
const data = parseFile(dataString, import_path3.default.extname(filepath), (yup3) => yup3.object({}), {
|
|
4188
|
+
frontmatterDelimiters: collection == null ? void 0 : collection.frontmatterDelimiters,
|
|
4189
|
+
frontmatterFormat: collection == null ? void 0 : collection.frontmatterFormat
|
|
4190
|
+
});
|
|
4153
4191
|
if (database.store.supportsSeeding()) {
|
|
4154
4192
|
await database.store.seed(normalizePath(filepath), data, seedOptions);
|
|
4155
4193
|
}
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export declare class Resolver {
|
|
|
42
42
|
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
43
43
|
indexes?: import("@tinacms/schema-tools").TinaIndex[];
|
|
44
44
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
45
|
+
frontmatterFormat?: "json" | "yaml" | "toml";
|
|
46
|
+
frontmatterDelimiters?: string | [string, string];
|
|
45
47
|
ui?: import("@tinacms/schema-tools").UICollection;
|
|
46
48
|
match?: string;
|
|
47
49
|
documents: {
|
|
@@ -65,6 +67,8 @@ export declare class Resolver {
|
|
|
65
67
|
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
66
68
|
indexes?: import("@tinacms/schema-tools").TinaIndex[];
|
|
67
69
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
70
|
+
frontmatterFormat?: "json" | "yaml" | "toml";
|
|
71
|
+
frontmatterDelimiters?: string | [string, string];
|
|
68
72
|
ui?: import("@tinacms/schema-tools").UICollection;
|
|
69
73
|
match?: string;
|
|
70
74
|
documents: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
22
|
+
"@iarna/toml": "^2.2.5",
|
|
22
23
|
"@tinacms/datalayer": "1.0.0",
|
|
23
|
-
"@tinacms/
|
|
24
|
-
"@tinacms/
|
|
24
|
+
"@tinacms/mdx": "1.1.0",
|
|
25
|
+
"@tinacms/schema-tools": "1.2.0",
|
|
25
26
|
"body-parser": "^1.19.0",
|
|
26
27
|
"cors": "^2.8.5",
|
|
27
28
|
"dataloader": "^2.0.0",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"graphql": "15.8.0",
|
|
37
38
|
"graphql-type-json": "^0.3.2",
|
|
38
39
|
"gray-matter": "^4.0.2",
|
|
39
|
-
"js-yaml": "^3.14.
|
|
40
|
+
"js-yaml": "^3.14.1",
|
|
40
41
|
"leveldown": "^6.1.0",
|
|
41
42
|
"lodash": "^4.17.20",
|
|
42
43
|
"mdast": "^3.0.0",
|
|
@@ -72,8 +73,8 @@
|
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
74
75
|
"@tinacms/datalayer": "1.0.0",
|
|
75
|
-
"@tinacms/schema-tools": "1.0
|
|
76
|
-
"@tinacms/scripts": "1.0.
|
|
76
|
+
"@tinacms/schema-tools": "1.2.0",
|
|
77
|
+
"@tinacms/scripts": "1.0.1",
|
|
77
78
|
"@types/cors": "^2.8.7",
|
|
78
79
|
"@types/estree": "^0.0.50",
|
|
79
80
|
"@types/express": "^4.17.8",
|