@graphql-markdown/helpers 1.0.6 → 1.0.7
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.
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.directiveDescriptor =
|
|
10
|
+
exports.directiveDescriptor = directiveDescriptor;
|
|
11
11
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
12
12
|
const interpolate_1 = require("../utils/interpolate");
|
|
13
13
|
/**
|
|
@@ -87,4 +87,3 @@ function directiveDescriptor(directive, type, descriptionTemplate) {
|
|
|
87
87
|
}
|
|
88
88
|
return (0, interpolate_1.interpolate)(descriptionTemplate, params);
|
|
89
89
|
}
|
|
90
|
-
exports.directiveDescriptor = directiveDescriptor;
|
package/dist/directives/tag.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.directiveTag =
|
|
10
|
+
exports.directiveTag = directiveTag;
|
|
11
11
|
/**
|
|
12
12
|
* Helper for rendering custom description from schema directive on type.
|
|
13
13
|
* This is an example on how to build a custom `tag` callback.
|
|
@@ -54,4 +54,3 @@ function directiveTag(directive, type, classname = "badge--secondary") {
|
|
|
54
54
|
classname: classname,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
exports.directiveTag = directiveTag;
|
|
@@ -25,7 +25,7 @@ import type { Maybe } from "@graphql-markdown/types";
|
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
|
-
export declare
|
|
28
|
+
export declare const getObjPath: (path: Maybe<string>, obj: unknown, fallback?: unknown) => unknown;
|
|
29
29
|
/**
|
|
30
30
|
* Interpolate a template literal-like string.
|
|
31
31
|
*
|
|
@@ -44,6 +44,6 @@ export declare function getObjPath(path: Maybe<string>, obj: unknown, fallback?:
|
|
|
44
44
|
* ```
|
|
45
45
|
*
|
|
46
46
|
*/
|
|
47
|
-
export declare
|
|
47
|
+
export declare const interpolate: (template: string, variables: Maybe<Record<string, unknown> & {
|
|
48
48
|
description?: string;
|
|
49
|
-
}>, fallback?: string)
|
|
49
|
+
}>, fallback?: string) => string;
|
|
@@ -28,14 +28,14 @@ const utils_1 = require("@graphql-markdown/utils");
|
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
const getObjPath = (path, obj, fallback = "") => {
|
|
32
32
|
if ((0, utils_1.isEmpty)(obj) || typeof path !== "string") {
|
|
33
|
-
return fallback;
|
|
33
|
+
return String(fallback);
|
|
34
34
|
}
|
|
35
35
|
return path.split(".").reduce((res, key) => {
|
|
36
|
-
return res[key] ?? fallback;
|
|
37
|
-
}, obj);
|
|
38
|
-
}
|
|
36
|
+
return res[key] ?? String(fallback);
|
|
37
|
+
}, obj);
|
|
38
|
+
};
|
|
39
39
|
exports.getObjPath = getObjPath;
|
|
40
40
|
/**
|
|
41
41
|
* Interpolate a template literal-like string.
|
|
@@ -55,11 +55,11 @@ exports.getObjPath = getObjPath;
|
|
|
55
55
|
* ```
|
|
56
56
|
*
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
const interpolate = (template, variables, fallback) => {
|
|
59
59
|
const regex = /\${[^{]+}/g;
|
|
60
60
|
return template.replace(regex, (match) => {
|
|
61
61
|
const objPath = match.slice(2, -1).trim();
|
|
62
|
-
return getObjPath(objPath, variables, fallback);
|
|
62
|
+
return (0, exports.getObjPath)(objPath, variables, fallback);
|
|
63
63
|
});
|
|
64
|
-
}
|
|
64
|
+
};
|
|
65
65
|
exports.interpolate = interpolate;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.0.
|
|
8
|
+
"version": "1.0.7",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"docs": "typedoc"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@graphql-markdown/graphql": "^1.1.
|
|
60
|
-
"@graphql-markdown/utils": "^1.
|
|
59
|
+
"@graphql-markdown/graphql": "^1.1.4",
|
|
60
|
+
"@graphql-markdown/utils": "^1.7.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"graphql": "^16.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@graphql-markdown/types": "^1.
|
|
66
|
+
"@graphql-markdown/types": "^1.4.0"
|
|
67
67
|
},
|
|
68
68
|
"directories": {
|
|
69
69
|
"test": "tests"
|