mad-data-parser 0.0.1 → 0.0.2-beta.12
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/.vscode/launch.json +40 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mad-data-parser-0.0.2-beta.12.tgz +0 -0
- package/dist/package.json +28 -0
- package/dist/parser/parseJsonPaths.d.ts +11 -3
- package/dist/parser/parseJsonPaths.d.ts.map +1 -1
- package/dist/parser/parseJsonPaths.js +127 -68
- package/dist/parser/parseJsonPaths.js.map +1 -1
- package/dist/utils/graphql/index.d.ts +2 -2
- package/dist/utils/graphql/index.d.ts.map +1 -1
- package/dist/utils/graphql/index.js +2 -1
- package/dist/utils/graphql/index.js.map +1 -1
- package/dist/utils/graphql-tag/collocated/gql.d.ts +47 -0
- package/dist/utils/graphql-tag/collocated/gql.d.ts.map +1 -0
- package/dist/utils/graphql-tag/collocated/gql.js +133 -0
- package/dist/utils/graphql-tag/collocated/gql.js.map +1 -0
- package/dist/utils/graphql-tag/collocated/guards.d.ts +4 -0
- package/dist/utils/graphql-tag/collocated/guards.d.ts.map +1 -0
- package/dist/utils/graphql-tag/collocated/guards.js +13 -0
- package/dist/utils/graphql-tag/collocated/guards.js.map +1 -0
- package/dist/utils/graphql-tag/collocated/stringifyDocument.d.ts +2 -0
- package/dist/utils/graphql-tag/collocated/stringifyDocument.d.ts.map +1 -0
- package/dist/utils/graphql-tag/collocated/stringifyDocument.js +38 -0
- package/dist/utils/graphql-tag/collocated/stringifyDocument.js.map +1 -0
- package/dist/utils/graphql-tag/collocated/types.d.ts +19 -0
- package/dist/utils/graphql-tag/collocated/types.d.ts.map +1 -0
- package/dist/utils/graphql-tag/collocated/types.js +2 -0
- package/dist/utils/graphql-tag/collocated/types.js.map +1 -0
- package/dist/utils/graphql-tag/index.d.ts +5 -0
- package/dist/utils/graphql-tag/index.d.ts.map +1 -0
- package/dist/utils/graphql-tag/index.js +5 -0
- package/dist/utils/graphql-tag/index.js.map +1 -0
- package/dist/utils/jsonPath/guards.d.ts +1 -1
- package/dist/utils/jsonPath/index.d.ts +3 -3
- package/dist/utils/jsonPath/index.js +3 -3
- package/dist/utils/jsonPath/visitor.d.ts +2 -2
- package/dist/utils/jsonPath/visitor.js +3 -3
- package/dist/version.txt +1 -0
- package/nodemon.json +1 -1
- package/package.json +24 -11
- package/var/cache/schema.graphql +35655 -0
- package/.swcrc +0 -27
- package/example/data/__tests__/output.ts +0 -57
- package/example/data/data.ts +0 -226
- package/example/data/output.ts +0 -74
- package/example/data/types.ts +0 -92
- package/example/example.ts +0 -26
- package/example/jsonPaths.data.ts +0 -13
- package/example/loadSchema.ts +0 -32
- package/src/index.ts +0 -2
- package/src/parser/parseJsonPaths.ts +0 -136
- package/src/utils/graphql/index.ts +0 -51
- package/src/utils/jsonPath/guards.ts +0 -37
- package/src/utils/jsonPath/index.ts +0 -3
- package/src/utils/jsonPath/types.ts +0 -56
- package/src/utils/jsonPath/visitor.ts +0 -108
- package/src/utils/ts/helpers.ts +0 -13
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function isGraphqlDataObject(value) {
|
|
2
|
+
return typeof value === 'object' && !!value && ('__typename' in value) && typeof value.__typename === 'string';
|
|
3
|
+
}
|
|
4
|
+
export function isCollocatedFragment(value) {
|
|
5
|
+
if (typeof value === 'object' && !!value) {
|
|
6
|
+
const colFrag = value;
|
|
7
|
+
const hasName = 'name' in colFrag && typeof colFrag.name === 'string';
|
|
8
|
+
const hasFragment = 'fragment' in colFrag && colFrag.fragment && 'definitions' in colFrag.fragment;
|
|
9
|
+
return hasName && hasFragment;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../src/utils/graphql-tag/collocated/guards.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAA;AAChH,CAAC;AAGD,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,KAA2B,CAAA;QAC3C,MAAM,OAAO,GAAG,MAAM,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAA;QACrE,MAAM,WAAW,GAAG,UAAU,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,aAAa,IAAI,OAAO,CAAC,QAAQ,CAAA;QAClG,OAAO,OAAO,IAAI,WAAW,CAAA;IAC/B,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyDocument.d.ts","sourceRoot":"","sources":["../../../../src/utils/graphql-tag/collocated/stringifyDocument.ts"],"names":[],"mappings":"AAaA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAyBnD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { print } from "graphql";
|
|
2
|
+
var SOURCE_NAME = 'gql';
|
|
3
|
+
var GRAPHQL_STRING_RE = /("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g;
|
|
4
|
+
var REPLACE_CHAR_RE = /(?:#[^\n\r]+)?(?:[\r\n]+|$)/g;
|
|
5
|
+
var replaceOutsideStrings = (str, idx) => idx % 2 === 0 ? str.replace(REPLACE_CHAR_RE, '\n') : str;
|
|
6
|
+
var prints = new WeakMap();
|
|
7
|
+
var docs = new WeakMap();
|
|
8
|
+
/** Sanitizes a GraphQL document string by replacing comments and redundant newlines in it. */
|
|
9
|
+
const sanitizeDocument = (node) => node.split(GRAPHQL_STRING_RE).map(replaceOutsideStrings).join('').trim();
|
|
10
|
+
export function stringifyDocument(node) {
|
|
11
|
+
var printed;
|
|
12
|
+
if (typeof node === 'string') {
|
|
13
|
+
printed = sanitizeDocument(node);
|
|
14
|
+
}
|
|
15
|
+
else if (node.loc && docs.get(node.__key) === node) {
|
|
16
|
+
printed = node.loc.source.body;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
printed = prints.get(node) || sanitizeDocument(print(node));
|
|
20
|
+
prints.set(node, printed);
|
|
21
|
+
}
|
|
22
|
+
if (typeof node !== 'string' && !node.loc) {
|
|
23
|
+
node.loc = {
|
|
24
|
+
start: 0,
|
|
25
|
+
end: printed.length,
|
|
26
|
+
source: {
|
|
27
|
+
body: printed,
|
|
28
|
+
name: SOURCE_NAME,
|
|
29
|
+
locationOffset: {
|
|
30
|
+
line: 1,
|
|
31
|
+
column: 1
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return printed;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=stringifyDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyDocument.js","sourceRoot":"","sources":["../../../../src/utils/graphql-tag/collocated/stringifyDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,iBAAiB,GAAG,oCAAoC,CAAC;AAC7D,IAAI,eAAe,GAAG,8BAA8B,CAAC;AACrD,IAAI,qBAAqB,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACnH,IAAI,MAA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@@
|
|
|
1
|
+
import type { TypedDocumentNode } from "@graphql-typed-document-node/core";
|
|
2
|
+
export type AnyVariables = Record<string, any>;
|
|
3
|
+
export interface CollocatedFragment<T extends Record<string, any> = Record<string, any>, Variables extends Record<string, any> = Record<string, any>> {
|
|
4
|
+
fragment: TypedDocumentNode<T, Variables>;
|
|
5
|
+
name: string;
|
|
6
|
+
requiredVars?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export type Stage = 'DRAFT' | 'PUBLISHED';
|
|
9
|
+
export interface GraphqlDataObject {
|
|
10
|
+
__typename?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
stage?: Stage;
|
|
13
|
+
}
|
|
14
|
+
export interface SplitableDataObject {
|
|
15
|
+
typename: string;
|
|
16
|
+
id: string;
|
|
17
|
+
stage: Stage;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/utils/graphql-tag/collocated/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAI9C,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAClJ,QAAQ,EAAE,iBAAiB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC;AAGD,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,WAAW,CAAA;AAEzC,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AACD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,KAAK,CAAA;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/utils/graphql-tag/collocated/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/graphql-tag/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/graphql-tag/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseNode, IdentifierNode, ASTNode, NumericLiteralNode, FilterExpressionNode, ScriptExpressionNode, StringLiteralNode, WildcardNode, SliceNode, RootNode } from "./types";
|
|
1
|
+
import type { BaseNode, IdentifierNode, ASTNode, NumericLiteralNode, FilterExpressionNode, ScriptExpressionNode, StringLiteralNode, WildcardNode, SliceNode, RootNode } from "./types.js";
|
|
2
2
|
export declare function isAstNode(node: unknown): node is ASTNode;
|
|
3
3
|
export declare function isBaseNode(node: ASTNode): node is BaseNode;
|
|
4
4
|
export declare function isIdentifierNode(node: ASTNode): node is IdentifierNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './guards';
|
|
3
|
-
export * from './visitor';
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './guards.js';
|
|
3
|
+
export * from './visitor.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './guards';
|
|
3
|
-
export * from './visitor';
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './guards.js';
|
|
3
|
+
export * from './visitor.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ASTNode, ExpressionType, RootNode, IdentifierNode, NumericLiteralNode, FilterExpressionNode, ScriptExpressionNode, StringLiteralNode, WildcardNode, SliceNode } from "./types";
|
|
2
|
-
import { type SnakeToPascalCase } from "../../utils/ts/helpers";
|
|
1
|
+
import type { ASTNode, ExpressionType, RootNode, IdentifierNode, NumericLiteralNode, FilterExpressionNode, ScriptExpressionNode, StringLiteralNode, WildcardNode, SliceNode } from "./types.js";
|
|
2
|
+
import { type SnakeToPascalCase } from "../../utils/ts/helpers.js";
|
|
3
3
|
export declare const BREAK: unique symbol;
|
|
4
4
|
type Kind = {
|
|
5
5
|
root: RootNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isJSONPath } from "./guards";
|
|
2
|
-
import { isAstNode } from "./guards";
|
|
3
|
-
import { snakeToPascalCase } from "../../utils/ts/helpers";
|
|
1
|
+
import { isJSONPath } from "./guards.js";
|
|
2
|
+
import { isAstNode } from "./guards.js";
|
|
3
|
+
import { snakeToPascalCase } from "../../utils/ts/helpers.js";
|
|
4
4
|
export const BREAK = Symbol('BREAK');
|
|
5
5
|
function doVisit(nodes, visitor) {
|
|
6
6
|
if (isJSONPath(nodes)) {
|
package/dist/version.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.2-beta.12
|
package/nodemon.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"ext": "js ts gql",
|
|
14
14
|
"signal": "SIGQUIT",
|
|
15
15
|
"execMap": {
|
|
16
|
-
"ts": "NODE_ENV=${NODE_ENV:-development} NODE_OPTIONS='--max-http-header-size=65535' UWS_HTTP_MAX_HEADERS_SIZE=65535 tsx
|
|
16
|
+
"ts": "NODE_ENV=${NODE_ENV:-development} NODE_OPTIONS='--max-http-header-size=65535' UWS_HTTP_MAX_HEADERS_SIZE=65535 tsx --inspect --trace-warnings --trace-uncaught"
|
|
17
17
|
|
|
18
18
|
},
|
|
19
19
|
"spawn": false,
|
package/package.json
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mad-data-parser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-beta.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
6
7
|
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./utils/jsonPath": "./dist/utils/jsonPath/index.js",
|
|
11
|
+
"./utils/graphql": "./dist/utils/graphql/index.js",
|
|
12
|
+
"./utils/graphql-tag": "./dist/utils/graphql-tag/index.js"
|
|
13
|
+
},
|
|
7
14
|
"keywords": [],
|
|
8
15
|
"author": "",
|
|
9
16
|
"license": "ISC",
|
|
10
17
|
"dependencies": {
|
|
11
|
-
"@
|
|
12
|
-
"bumpp": "~10.3.1",
|
|
18
|
+
"@graphql-tools/utils": "~10.9.1",
|
|
13
19
|
"fast-glob": "~3.3.2",
|
|
14
20
|
"gql-query-builder": "~3.8.0",
|
|
15
|
-
"graphql": "
|
|
21
|
+
"graphql": "^16.8.1",
|
|
16
22
|
"graphql-tag": "~2.12.6",
|
|
17
23
|
"jsonpath": "~1.1.1",
|
|
18
|
-
"number-format.js": "~2.0.9"
|
|
19
|
-
"tsc-alias": "~1.8.16"
|
|
24
|
+
"number-format.js": "~2.0.9"
|
|
20
25
|
},
|
|
21
26
|
"devDependencies": {
|
|
27
|
+
"@graphql-typed-document-node/core": "^3.1.0",
|
|
28
|
+
"tsc-alias": "~1.8.16",
|
|
29
|
+
"@types/jsonpath": "~0.2.4",
|
|
30
|
+
"bumpp": "~10.3.1",
|
|
22
31
|
"@graphql-tools/graphql-file-loader": "~8.1.2",
|
|
23
32
|
"@graphql-tools/load": "~8.1.2",
|
|
24
33
|
"@graphql-tools/url-loader": "~9.0.0",
|
|
@@ -44,9 +53,13 @@
|
|
|
44
53
|
"test": "NODE_ENV=test jest --maxWorkers=50% --",
|
|
45
54
|
"autotest": "NODE_ENV=test jest --watch --maxWorkers=10%",
|
|
46
55
|
"test:inspect": "NODE_ENV=test NODE_OPTIONS='--inspect-brk' jest --maxWorkers=1 -- ",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
"clean": "rm -rf dist",
|
|
57
|
+
"prebuild": "pnpm run clean",
|
|
58
|
+
"build": "p=tsconfig.build.json;tsc --project $p; tsc-alias --project $p",
|
|
59
|
+
"prebuildpackage": "pnpm build && node dist/setupPackages.js && rm dist/setupPackages*",
|
|
60
|
+
"buildpackage": "cd dist && pnpm pack",
|
|
61
|
+
"prepublish": "pnpm buildpackage",
|
|
62
|
+
"pub": "pnpm buildpackage && pnpm publish dist",
|
|
63
|
+
"release": "bumpp && pnpm pub"
|
|
64
|
+
}
|
|
52
65
|
}
|