polen 0.11.0-next.23 → 0.11.0-next.25
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/build/api/config/input.d.ts +76 -77
- package/build/api/config/input.d.ts.map +1 -1
- package/build/api/config/normalized.d.ts +136 -143
- package/build/api/config/normalized.d.ts.map +1 -1
- package/build/api/config-template/template.d.ts +110 -121
- package/build/api/config-template/template.d.ts.map +1 -1
- package/build/api/examples/diagnostic/diagnostic.d.ts +0 -23
- package/build/api/examples/diagnostic/diagnostic.d.ts.map +1 -1
- package/build/api/examples/diagnostic/diagnostic.js +1 -3
- package/build/api/examples/diagnostic/diagnostic.js.map +1 -1
- package/build/api/examples/scanner.d.ts +27 -1
- package/build/api/examples/scanner.d.ts.map +1 -1
- package/build/api/examples/scanner.js +19 -17
- package/build/api/examples/scanner.js.map +1 -1
- package/build/api/examples/schemas/catalog.d.ts +20 -12
- package/build/api/examples/schemas/catalog.d.ts.map +1 -1
- package/build/api/examples/schemas/example/example.d.ts +17 -11
- package/build/api/examples/schemas/example/example.d.ts.map +1 -1
- package/build/api/schema/augmentations/$$.d.ts +7 -0
- package/build/api/schema/augmentations/$$.d.ts.map +1 -0
- package/build/api/schema/augmentations/$$.js +7 -0
- package/build/api/schema/augmentations/$$.js.map +1 -0
- package/build/api/schema/augmentations/$.d.ts +1 -1
- package/build/api/schema/augmentations/$.d.ts.map +1 -1
- package/build/api/schema/augmentations/$.js +1 -1
- package/build/api/schema/augmentations/$.js.map +1 -1
- package/build/api/schema/augmentations/apply.d.ts +29 -0
- package/build/api/schema/augmentations/apply.d.ts.map +1 -0
- package/build/api/schema/augmentations/apply.js +181 -0
- package/build/api/schema/augmentations/apply.js.map +1 -0
- package/build/api/schema/augmentations/augmentation.d.ts +31 -0
- package/build/api/schema/augmentations/augmentation.d.ts.map +1 -0
- package/build/api/schema/augmentations/augmentation.js +22 -0
- package/build/api/schema/augmentations/augmentation.js.map +1 -0
- package/build/api/schema/augmentations/config.d.ts +24 -0
- package/build/api/schema/augmentations/config.d.ts.map +1 -0
- package/build/api/schema/augmentations/config.js +9 -0
- package/build/api/schema/augmentations/config.js.map +1 -0
- package/build/api/schema/augmentations/diagnostics/diagnostic.d.ts +67 -0
- package/build/api/schema/augmentations/diagnostics/diagnostic.d.ts.map +1 -0
- package/build/api/schema/augmentations/diagnostics/diagnostic.js +13 -0
- package/build/api/schema/augmentations/diagnostics/diagnostic.js.map +1 -0
- package/build/api/schema/augmentations/diagnostics/duplicate-version.d.ts +45 -0
- package/build/api/schema/augmentations/diagnostics/duplicate-version.d.ts.map +1 -0
- package/build/api/schema/augmentations/diagnostics/duplicate-version.js +17 -0
- package/build/api/schema/augmentations/diagnostics/duplicate-version.js.map +1 -0
- package/build/api/schema/augmentations/diagnostics/invalid-path.d.ts +46 -0
- package/build/api/schema/augmentations/diagnostics/invalid-path.d.ts.map +1 -0
- package/build/api/schema/augmentations/diagnostics/invalid-path.js +18 -0
- package/build/api/schema/augmentations/diagnostics/invalid-path.js.map +1 -0
- package/build/api/schema/augmentations/diagnostics/version-mismatch.d.ts +46 -0
- package/build/api/schema/augmentations/diagnostics/version-mismatch.d.ts.map +1 -0
- package/build/api/schema/augmentations/diagnostics/version-mismatch.js +18 -0
- package/build/api/schema/augmentations/diagnostics/version-mismatch.js.map +1 -0
- package/build/api/schema/augmentations/input.d.ts +145 -0
- package/build/api/schema/augmentations/input.d.ts.map +1 -0
- package/build/api/schema/augmentations/input.js +191 -0
- package/build/api/schema/augmentations/input.js.map +1 -0
- package/build/api/schema/augmentations/placement.d.ts +8 -0
- package/build/api/schema/augmentations/placement.d.ts.map +1 -0
- package/build/api/schema/augmentations/placement.js +7 -0
- package/build/api/schema/augmentations/placement.js.map +1 -0
- package/build/api/schema/config-schema.d.ts +66 -66
- package/build/api/schema/config-schema.d.ts.map +1 -1
- package/build/api/schema/config-schema.js +2 -2
- package/build/api/schema/config-schema.js.map +1 -1
- package/build/api/schema/input-source/load.d.ts +2 -0
- package/build/api/schema/input-source/load.d.ts.map +1 -1
- package/build/api/schema/input-source/load.js.map +1 -1
- package/build/api/schema/input-sources/directory.d.ts +39 -39
- package/build/api/schema/input-sources/file.d.ts +39 -39
- package/build/api/schema/input-sources/introspection-file.d.ts +39 -39
- package/build/api/schema/input-sources/introspection.d.ts +39 -39
- package/build/api/schema/input-sources/memory.d.ts +39 -39
- package/build/api/schema/input-sources/versioned-directory.d.ts +79 -79
- package/build/api/schema/load.d.ts.map +1 -1
- package/build/api/schema/load.js +9 -2
- package/build/api/schema/load.js.map +1 -1
- package/build/lib/catalog/catalog.d.ts +1181 -1181
- package/build/lib/catalog/unversioned.d.ts +312 -312
- package/build/lib/catalog/versioned.d.ts +634 -634
- package/build/lib/change/change.d.ts +238 -238
- package/build/lib/document/document.d.ts +14 -8
- package/build/lib/document/document.d.ts.map +1 -1
- package/build/lib/document/versioned.d.ts +17 -10
- package/build/lib/document/versioned.d.ts.map +1 -1
- package/build/lib/grafaid/schema/KindMap/_.d.ts +1 -1
- package/build/lib/graphql-path/$$.d.ts +7 -13
- package/build/lib/graphql-path/$$.d.ts.map +1 -1
- package/build/lib/graphql-path/$$.js +7 -13
- package/build/lib/graphql-path/$$.js.map +1 -1
- package/build/lib/graphql-path/definition.d.ts +104 -94
- package/build/lib/graphql-path/definition.d.ts.map +1 -1
- package/build/lib/graphql-path/definition.js +126 -125
- package/build/lib/graphql-path/definition.js.map +1 -1
- package/build/lib/graphql-path/query.d.ts +25 -57
- package/build/lib/graphql-path/query.d.ts.map +1 -1
- package/build/lib/graphql-path/query.js +15 -93
- package/build/lib/graphql-path/query.js.map +1 -1
- package/build/lib/graphql-path/schema.d.ts +49 -0
- package/build/lib/graphql-path/schema.d.ts.map +1 -0
- package/build/lib/graphql-path/schema.js +89 -0
- package/build/lib/graphql-path/schema.js.map +1 -0
- package/build/lib/graphql-path/types.d.ts +76 -28
- package/build/lib/graphql-path/types.d.ts.map +1 -1
- package/build/lib/graphql-path/types.js +101 -2
- package/build/lib/graphql-path/types.js.map +1 -1
- package/build/lib/revision/revision.d.ts +1170 -1170
- package/build/lib/schema/schema.d.ts +708 -708
- package/build/lib/schema/unversioned.d.ts +1092 -1092
- package/build/lib/schema/versioned.d.ts +634 -634
- package/build/lib/semver/official-release.d.ts +10 -10
- package/build/lib/semver/pre-release.d.ts +10 -10
- package/build/lib/semver/semver.d.ts +50 -50
- package/build/lib/version-coverage/version-coverage.d.ts +43 -11
- package/build/lib/version-coverage/version-coverage.d.ts.map +1 -1
- package/build/lib/version-coverage/version-coverage.js +40 -6
- package/build/lib/version-coverage/version-coverage.js.map +1 -1
- package/build/template/hooks/use-examples.d.ts +1 -1
- package/build/template/routes/changelog/ChangelogSidebar.d.ts +2 -2
- package/build/template/routes/changelog/ChangelogSidebar.d.ts.map +1 -1
- package/build/template/routes/changelog/ChangelogSidebar.js +4 -4
- package/build/template/routes/changelog/ChangelogSidebar.js.map +1 -1
- package/build/template/routes/examples/_.d.ts +3 -3
- package/build/template/routes/examples/_index.d.ts +2 -2
- package/build/template/routes/examples/name.d.ts +3 -3
- package/build/template/routes/pages.d.ts.map +1 -1
- package/build/template/routes/pages.js +5 -1
- package/build/template/routes/pages.js.map +1 -1
- package/build/template/stores/changelog.d.ts +39 -39
- package/build/vite/plugins/examples.d.ts.map +1 -1
- package/build/vite/plugins/examples.js +0 -2
- package/build/vite/plugins/examples.js.map +1 -1
- package/build/vite/plugins/schemas.d.ts.map +1 -1
- package/build/vite/plugins/schemas.js +38 -2
- package/build/vite/plugins/schemas.js.map +1 -1
- package/package.json +1 -1
- package/src/api/examples/diagnostic/diagnostic.ts +0 -3
- package/src/api/examples/scanner.test.ts +83 -0
- package/src/api/examples/scanner.ts +17 -21
- package/src/api/schema/augmentations/$$.ts +6 -0
- package/src/api/schema/augmentations/$.ts +1 -1
- package/src/api/schema/augmentations/apply.test.ts +89 -0
- package/src/api/schema/augmentations/apply.ts +277 -0
- package/src/api/schema/augmentations/augmentation.ts +24 -0
- package/src/api/schema/augmentations/config.ts +11 -0
- package/src/api/schema/augmentations/diagnostics/diagnostic.ts +20 -0
- package/src/api/schema/augmentations/diagnostics/duplicate-version.ts +20 -0
- package/src/api/schema/augmentations/diagnostics/invalid-path.ts +21 -0
- package/src/api/schema/augmentations/diagnostics/version-mismatch.ts +21 -0
- package/src/api/schema/augmentations/input.test.ts +144 -0
- package/src/api/schema/augmentations/input.ts +215 -0
- package/src/api/schema/augmentations/placement.ts +11 -0
- package/src/api/schema/config-schema.ts +2 -2
- package/src/api/schema/input-source/load.ts +2 -0
- package/src/api/schema/load.ts +19 -2
- package/src/lib/graphql-path/$$.ts +7 -13
- package/src/lib/graphql-path/$.test.ts +175 -0
- package/src/lib/graphql-path/definition.ts +162 -162
- package/src/lib/graphql-path/query.ts +15 -98
- package/src/lib/graphql-path/schema.ts +136 -0
- package/src/lib/graphql-path/types.ts +108 -28
- package/src/lib/version-coverage/version-coverage.ts +48 -6
- package/src/template/routes/changelog/ChangelogSidebar.tsx +4 -4
- package/src/template/routes/pages.tsx +6 -1
- package/src/vite/plugins/examples.ts +0 -2
- package/src/vite/plugins/schemas.ts +51 -2
- package/build/api/examples/diagnostic/unused-default.d.ts +0 -49
- package/build/api/examples/diagnostic/unused-default.d.ts.map +0 -1
- package/build/api/examples/diagnostic/unused-default.js +0 -19
- package/build/api/examples/diagnostic/unused-default.js.map +0 -1
- package/build/api/schema/augmentations/augmentations/description.d.ts +0 -26
- package/build/api/schema/augmentations/augmentations/description.d.ts.map +0 -1
- package/build/api/schema/augmentations/augmentations/description.js +0 -55
- package/build/api/schema/augmentations/augmentations/description.js.map +0 -1
- package/build/api/schema/augmentations/schema-augmentation.d.ts +0 -20
- package/build/api/schema/augmentations/schema-augmentation.d.ts.map +0 -1
- package/build/api/schema/augmentations/schema-augmentation.js +0 -22
- package/build/api/schema/augmentations/schema-augmentation.js.map +0 -1
- package/build/api/schema/augmentations/target.d.ts +0 -25
- package/build/api/schema/augmentations/target.d.ts.map +0 -1
- package/build/api/schema/augmentations/target.js +0 -39
- package/build/api/schema/augmentations/target.js.map +0 -1
- package/build/lib/graphql-path/constructors.d.ts +0 -57
- package/build/lib/graphql-path/constructors.d.ts.map +0 -1
- package/build/lib/graphql-path/constructors.js +0 -73
- package/build/lib/graphql-path/constructors.js.map +0 -1
- package/src/api/examples/diagnostic/unused-default.ts +0 -22
- package/src/api/schema/augmentations/augmentations/description.ts +0 -69
- package/src/api/schema/augmentations/schema-augmentation.ts +0 -32
- package/src/api/schema/augmentations/target.ts +0 -61
- package/src/lib/graphql-path/constructors.ts +0 -81
@@ -1,192 +1,193 @@
|
|
1
1
|
/**
|
2
|
-
* Definition path operations
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
2
|
+
* Definition path operations using Effect Schema transforms
|
3
|
+
*/
|
4
|
+
import { S } from '#lib/kit-temp/effect';
|
5
|
+
import { ParseResult } from 'effect';
|
6
|
+
import { ArgumentSegment, FieldSegment, TypeSegment } from './types.js';
|
7
|
+
// ============================================================================
|
8
|
+
// Internal Path Schemas (Decoded Forms)
|
9
|
+
// ============================================================================
|
10
|
+
const TypeDefinitionPathDecoded = S.Tuple(TypeSegment);
|
11
|
+
const FieldDefinitionPathDecoded = S.Tuple(TypeSegment, FieldSegment);
|
12
|
+
const ArgumentDefinitionPathDecoded = S.Tuple(TypeSegment, FieldSegment, ArgumentSegment);
|
13
|
+
// ============================================================================
|
14
|
+
// Transform Codecs (String <-> Struct)
|
15
|
+
// ============================================================================
|
16
|
+
/**
|
17
|
+
* Type definition path codec
|
18
|
+
* Encoded: "User"
|
19
|
+
* Decoded: [{ _tag: 'TypeSegment', type: 'User' }]
|
20
|
+
*/
|
21
|
+
export const TypeDefinitionPath = S.transformOrFail(S.String, TypeDefinitionPathDecoded, {
|
22
|
+
decode: (str, _options, ast) => {
|
23
|
+
if (!str || str.includes('.') || str.includes('(')) {
|
24
|
+
return ParseResult.fail(new ParseResult.Type(ast, str));
|
25
|
+
}
|
26
|
+
return ParseResult.succeed([TypeSegment.make({ type: str })]);
|
27
|
+
},
|
28
|
+
encode: (path) => ParseResult.succeed(path[0].type),
|
29
|
+
}).annotations({
|
30
|
+
identifier: 'TypeDefinitionPath',
|
31
|
+
description: 'Path to a type definition',
|
32
|
+
});
|
33
|
+
/**
|
34
|
+
* Field definition path codec
|
35
|
+
* Encoded: "User.name"
|
36
|
+
* Decoded: [{ _tag: 'TypeSegment', type: 'User' }, { _tag: 'FieldSegment', field: 'name' }]
|
37
|
+
*/
|
38
|
+
export const FieldDefinitionPath = S.transformOrFail(S.String, FieldDefinitionPathDecoded, {
|
39
|
+
decode: (str, _options, ast) => {
|
40
|
+
const parts = str.split('.');
|
41
|
+
if (parts.length !== 2 || !parts[0] || !parts[1] || str.includes('(')) {
|
42
|
+
return ParseResult.fail(new ParseResult.Type(ast, str));
|
43
|
+
}
|
44
|
+
return ParseResult.succeed([
|
45
|
+
TypeSegment.make({ type: parts[0] }),
|
46
|
+
FieldSegment.make({ field: parts[1] }),
|
47
|
+
]);
|
48
|
+
},
|
49
|
+
encode: (path) => ParseResult.succeed(`${path[0].type}.${path[1].field}`),
|
50
|
+
}).annotations({
|
51
|
+
identifier: 'FieldDefinitionPath',
|
52
|
+
description: 'Path to a field definition',
|
53
|
+
});
|
54
|
+
/**
|
55
|
+
* Argument definition path codec
|
56
|
+
* Encoded: "User.posts(limit)"
|
57
|
+
* Decoded: [{ _tag: 'TypeSegment', type: 'User' }, { _tag: 'FieldSegment', field: 'posts' }, { _tag: 'ArgumentSegment', argument: 'limit' }]
|
58
|
+
*/
|
59
|
+
export const ArgumentDefinitionPath = S.transformOrFail(S.String, ArgumentDefinitionPathDecoded, {
|
60
|
+
decode: (str, _options, ast) => {
|
61
|
+
const match = str.match(/^([^.]+)\.([^.(]+)\(([^)]+)\)$/);
|
62
|
+
if (!match || !match[1] || !match[2] || !match[3]) {
|
63
|
+
return ParseResult.fail(new ParseResult.Type(ast, str));
|
64
|
+
}
|
65
|
+
return ParseResult.succeed([
|
66
|
+
TypeSegment.make({ type: match[1] }),
|
67
|
+
FieldSegment.make({ field: match[2] }),
|
68
|
+
ArgumentSegment.make({ argument: match[3] }),
|
69
|
+
]);
|
70
|
+
},
|
71
|
+
encode: (path) => ParseResult.succeed(`${path[0].type}.${path[1].field}(${path[2].argument})`),
|
72
|
+
}).annotations({
|
73
|
+
identifier: 'ArgumentDefinitionPath',
|
74
|
+
description: 'Path to an argument definition',
|
75
|
+
});
|
76
|
+
/**
|
77
|
+
* Union of all definition paths
|
78
|
+
* Automatically determines the correct path type from the string format
|
79
|
+
*/
|
80
|
+
export const DefinitionPath = S.Union(ArgumentDefinitionPath, // Check argument first (most specific)
|
81
|
+
FieldDefinitionPath, // Then field
|
82
|
+
TypeDefinitionPath).annotations({
|
83
|
+
identifier: 'DefinitionPath',
|
84
|
+
description: 'Union of all definition path types',
|
85
|
+
});
|
86
|
+
// ============================================================================
|
87
|
+
// Codec Functions
|
88
|
+
// ============================================================================
|
26
89
|
/**
|
27
90
|
* Decode a string expression into a definition path
|
28
|
-
*
|
29
91
|
* @param expression - The string expression to decode
|
30
|
-
* @returns The decoded definition path
|
92
|
+
* @returns The decoded definition path
|
31
93
|
* @example
|
32
94
|
* decode('User') // type definition path
|
33
95
|
* decode('User.name') // field definition path
|
34
96
|
* decode('User.posts(limit)') // argument definition path
|
35
97
|
*/
|
36
|
-
export const
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
if (!typeName || !fieldName)
|
50
|
-
return null;
|
51
|
-
return createFieldDefinitionPath(typeName, fieldName);
|
52
|
-
}
|
53
|
-
// Handle type path: Type
|
54
|
-
const typeMatch = expression.match(/^[^.]+$/);
|
55
|
-
if (typeMatch) {
|
56
|
-
return createTypeDefinitionPath(expression);
|
57
|
-
}
|
58
|
-
return null;
|
59
|
-
};
|
98
|
+
export const decodeSync = S.decodeUnknownSync(DefinitionPath);
|
99
|
+
/**
|
100
|
+
* Encode a definition path to a string expression
|
101
|
+
* @param path - The definition path to encode
|
102
|
+
* @returns A string expression representation
|
103
|
+
* @example
|
104
|
+
* encode([{ _tag: 'TypeSegment', type: 'User' }]) // 'User'
|
105
|
+
* encode([{ _tag: 'TypeSegment', type: 'User' }, { _tag: 'FieldSegment', field: 'name' }]) // 'User.name'
|
106
|
+
*/
|
107
|
+
export const encodeSync = S.encodeSync(DefinitionPath);
|
108
|
+
// ============================================================================
|
109
|
+
// Helper Functions
|
110
|
+
// ============================================================================
|
60
111
|
/**
|
61
112
|
* Extract the type name from any definition path
|
62
|
-
*
|
63
113
|
* @param path - The definition path
|
64
114
|
* @returns The type name
|
65
|
-
* @example getType([{ kind: 'type', type: 'User' }]) // 'User'
|
66
115
|
*/
|
67
116
|
export const getType = (path) => {
|
68
117
|
return path[0].type;
|
69
118
|
};
|
70
119
|
/**
|
71
120
|
* Extract the field name from a field or argument definition path
|
72
|
-
*
|
73
121
|
* @param path - The field or argument definition path
|
74
122
|
* @returns The field name
|
75
|
-
* @example getField([{ kind: 'type', type: 'User' }, { kind: 'field', field: 'name' }]) // 'name'
|
76
123
|
*/
|
77
124
|
export const getField = (path) => {
|
78
125
|
return path[1].field;
|
79
126
|
};
|
80
127
|
/**
|
81
128
|
* Extract the argument name from an argument definition path
|
82
|
-
*
|
83
129
|
* @param path - The argument definition path
|
84
130
|
* @returns The argument name
|
85
|
-
* @example getArgument([{ kind: 'type', type: 'User' }, { kind: 'field', field: 'posts' }, { kind: 'argument', argument: 'limit' }]) // 'limit'
|
86
131
|
*/
|
87
132
|
export const getArgument = (path) => {
|
88
133
|
return path[2].argument;
|
89
134
|
};
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
export const parseFieldPath = (path) => {
|
94
|
-
if (!path)
|
95
|
-
return { typeName: null, fieldName: null };
|
96
|
-
const parts = path.split('.');
|
97
|
-
if (parts.length >= 2) {
|
98
|
-
return {
|
99
|
-
typeName: parts[0] || null,
|
100
|
-
fieldName: parts[1] || null,
|
101
|
-
};
|
102
|
-
}
|
103
|
-
return { typeName: null, fieldName: null };
|
104
|
-
};
|
135
|
+
// ============================================================================
|
136
|
+
// Type Guards
|
137
|
+
// ============================================================================
|
105
138
|
/**
|
106
139
|
* Type guard to check if a path is a type definition path
|
107
|
-
*
|
108
|
-
* @param path - The path to check
|
109
|
-
* @returns True if the path is a type definition path
|
110
140
|
*/
|
111
141
|
export const isTypeDefinitionPath = (path) => {
|
112
|
-
return path.length === 1 && path[0].
|
142
|
+
return path.length === 1 && path[0]._tag === 'TypeSegment';
|
113
143
|
};
|
114
144
|
/**
|
115
145
|
* Type guard to check if a path is a field definition path
|
116
|
-
*
|
117
|
-
* @param path - The path to check
|
118
|
-
* @returns True if the path is a field definition path
|
119
146
|
*/
|
120
147
|
export const isFieldDefinitionPath = (path) => {
|
121
|
-
return path.length === 2 && path[0].
|
148
|
+
return path.length === 2 && path[0]._tag === 'TypeSegment' && path[1]._tag === 'FieldSegment';
|
122
149
|
};
|
123
150
|
/**
|
124
151
|
* Type guard to check if a path is an argument definition path
|
125
|
-
*
|
126
|
-
* @param path - The path to check
|
127
|
-
* @returns True if the path is an argument definition path
|
128
152
|
*/
|
129
153
|
export const isArgumentDefinitionPath = (path) => {
|
130
|
-
return path.length === 3
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
*
|
135
|
-
* @param type - The type name
|
136
|
-
* @returns A type definition path
|
137
|
-
* @example createTypeDefinitionPath('User') // [{ kind: 'type', type: 'User' }]
|
138
|
-
*/
|
139
|
-
export const createTypeDefinitionPath = (type) => {
|
140
|
-
return [createTypeSegment(type)];
|
141
|
-
};
|
142
|
-
/**
|
143
|
-
* Create a path to a field definition
|
144
|
-
*
|
145
|
-
* @param type - The type name
|
146
|
-
* @param field - The field name
|
147
|
-
* @returns A field definition path
|
148
|
-
* @example createFieldDefinitionPath('User', 'name') // [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'name' }]
|
149
|
-
*/
|
150
|
-
export const createFieldDefinitionPath = (type, field) => {
|
151
|
-
return [createTypeSegment(type), createFieldSegment(field)];
|
152
|
-
};
|
153
|
-
/**
|
154
|
-
* Create a path to an argument definition
|
155
|
-
*
|
156
|
-
* @param type - The type name
|
157
|
-
* @param field - The field name
|
158
|
-
* @param argument - The argument name
|
159
|
-
* @returns An argument definition path
|
160
|
-
* @example createArgumentDefinitionPath('User', 'posts', 'limit') // [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'posts' }, { kind: 'argument', argument: 'limit' }]
|
161
|
-
*/
|
162
|
-
export const createArgumentDefinitionPath = (type, field, argument) => {
|
163
|
-
return [createTypeSegment(type), createFieldSegment(field), createArgumentSegment(argument)];
|
154
|
+
return (path.length === 3
|
155
|
+
&& path[0]._tag === 'TypeSegment'
|
156
|
+
&& path[1]._tag === 'FieldSegment'
|
157
|
+
&& path[2]._tag === 'ArgumentSegment');
|
164
158
|
};
|
159
|
+
// ============================================================================
|
160
|
+
// Constructor Functions
|
161
|
+
// ============================================================================
|
165
162
|
/**
|
166
163
|
* Create a type definition path
|
167
|
-
*
|
168
164
|
* @param type - The type name
|
169
165
|
* @returns A type definition path
|
170
|
-
* @example type('User') // [{ kind: 'type', type: 'User' }]
|
171
166
|
*/
|
172
|
-
export const type =
|
167
|
+
export const type = (typeName) => {
|
168
|
+
return [TypeSegment.make({ type: typeName })];
|
169
|
+
};
|
173
170
|
/**
|
174
171
|
* Create a field definition path
|
175
|
-
*
|
176
172
|
* @param type - The type name
|
177
173
|
* @param field - The field name
|
178
174
|
* @returns A field definition path
|
179
|
-
* @example field('User', 'name') // [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'name' }]
|
180
175
|
*/
|
181
|
-
export const field =
|
176
|
+
export const field = (typeName, fieldName) => {
|
177
|
+
return [TypeSegment.make({ type: typeName }), FieldSegment.make({ field: fieldName })];
|
178
|
+
};
|
182
179
|
/**
|
183
180
|
* Create an argument definition path
|
184
|
-
*
|
185
181
|
* @param type - The type name
|
186
182
|
* @param field - The field name
|
187
183
|
* @param argument - The argument name
|
188
184
|
* @returns An argument definition path
|
189
|
-
* @example argument('User', 'posts', 'limit') // [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'posts' }, { kind: 'argument', argument: 'limit' }]
|
190
185
|
*/
|
191
|
-
export const argument =
|
186
|
+
export const argument = (typeName, fieldName, argumentName) => {
|
187
|
+
return [
|
188
|
+
TypeSegment.make({ type: typeName }),
|
189
|
+
FieldSegment.make({ field: fieldName }),
|
190
|
+
ArgumentSegment.make({ argument: argumentName }),
|
191
|
+
];
|
192
|
+
};
|
192
193
|
//# sourceMappingURL=definition.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/lib/graphql-path/definition.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/lib/graphql-path/definition.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEvE,+EAA+E;AAC/E,wCAAwC;AACxC,+EAA+E;AAE/E,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AACtD,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AACrE,MAAM,6BAA6B,GAAG,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G,CAAC,QAAgB,EAAsB,EAAE;IAC3D,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAE,SAAiB,EAAuB,EAAE;IAChF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;AACxF,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAE,SAAiB,EAAE,YAAoB,EAA0B,EAAE;IAC5G,OAAO;QACL,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACpC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QACvC,eAAe,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;KACjD,CAAA;AACH,CAAC,CAAA"}
|
@@ -1,75 +1,43 @@
|
|
1
1
|
/**
|
2
2
|
* Query path operations
|
3
3
|
*/
|
4
|
-
import type { QueryPath } from './types.js';
|
5
|
-
/**
|
6
|
-
* Builder class for creating query paths with a fluent interface
|
7
|
-
*
|
8
|
-
* @example
|
9
|
-
* ```ts
|
10
|
-
* const path = builder()
|
11
|
-
* .type('User')
|
12
|
-
* .field('posts')
|
13
|
-
* .type('Post')
|
14
|
-
* .field('author')
|
15
|
-
* .build()
|
16
|
-
* ```
|
17
|
-
*/
|
18
|
-
export declare class QueryPathBuilder {
|
19
|
-
private segments;
|
20
|
-
/**
|
21
|
-
* Add a type segment to the path
|
22
|
-
*
|
23
|
-
* @param typeName - The type name
|
24
|
-
* @returns The builder for chaining
|
25
|
-
*/
|
26
|
-
type(typeName: string): this;
|
27
|
-
/**
|
28
|
-
* Add a field segment to the path
|
29
|
-
*
|
30
|
-
* @param fieldName - The field name
|
31
|
-
* @returns The builder for chaining
|
32
|
-
*/
|
33
|
-
field(fieldName: string): this;
|
34
|
-
/**
|
35
|
-
* Build the final query path
|
36
|
-
*
|
37
|
-
* @returns The constructed query path
|
38
|
-
*/
|
39
|
-
build(): QueryPath;
|
40
|
-
}
|
41
|
-
/**
|
42
|
-
* Create a new query path builder
|
43
|
-
*
|
44
|
-
* @returns A new query path builder instance
|
45
|
-
* @example
|
46
|
-
* ```ts
|
47
|
-
* const path = builder()
|
48
|
-
* .type('User')
|
49
|
-
* .field('posts')
|
50
|
-
* .type('Post')
|
51
|
-
* .field('author')
|
52
|
-
* .build()
|
53
|
-
* ```
|
54
|
-
*/
|
55
|
-
export declare const builder: () => QueryPathBuilder;
|
56
4
|
/**
|
57
5
|
* Encode a query path to a human-readable expression string
|
6
|
+
* Uses the Effect Schema codec for QueryPath
|
58
7
|
*
|
59
|
-
* @param path - The query path to encode
|
8
|
+
* @param path - The query path segments to encode
|
60
9
|
* @returns A string expression representation
|
61
10
|
* @example
|
62
|
-
* encode(
|
11
|
+
* encode([
|
12
|
+
* { _tag: 'TypeSegment', type: 'User' },
|
13
|
+
* { _tag: 'FieldSegment', field: 'posts' },
|
14
|
+
* { _tag: 'TypeSegment', type: 'Post' },
|
15
|
+
* { _tag: 'FieldSegment', field: 'title' }
|
16
|
+
* ]) // 'User.posts.Post.title'
|
63
17
|
*/
|
64
|
-
export declare const encode: (
|
18
|
+
export declare const encode: (a: readonly ({
|
19
|
+
readonly _tag: "TypeSegment";
|
20
|
+
readonly type: string;
|
21
|
+
} | {
|
22
|
+
readonly _tag: "FieldSegment";
|
23
|
+
readonly field: string;
|
24
|
+
})[], overrideOptions?: import("effect/SchemaAST").ParseOptions) => string;
|
65
25
|
/**
|
66
26
|
* Decode a string expression into a query path
|
27
|
+
* Uses the Effect Schema codec for QueryPath
|
67
28
|
* Note: This assumes alternating type.field.type.field pattern
|
68
29
|
*
|
69
30
|
* @param expression - The string expression to decode
|
70
|
-
* @returns The decoded query path
|
31
|
+
* @returns The decoded query path segments
|
32
|
+
* @throws ParseError if the expression is invalid
|
71
33
|
* @example
|
72
34
|
* decode('User.posts.Post.title') // Query path traversing User->posts->Post->title
|
73
35
|
*/
|
74
|
-
export declare const decode: (
|
36
|
+
export declare const decode: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions) => readonly ({
|
37
|
+
readonly _tag: "TypeSegment";
|
38
|
+
readonly type: string;
|
39
|
+
} | {
|
40
|
+
readonly _tag: "FieldSegment";
|
41
|
+
readonly field: string;
|
42
|
+
})[];
|
75
43
|
//# sourceMappingURL=query.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/lib/graphql-path/query.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/lib/graphql-path/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM;;;;;;0EAA0B,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM;;;;;;IAAiC,CAAA"}
|
@@ -1,111 +1,33 @@
|
|
1
1
|
/**
|
2
2
|
* Query path operations
|
3
3
|
*/
|
4
|
-
import {
|
5
|
-
|
6
|
-
* Builder class for creating query paths with a fluent interface
|
7
|
-
*
|
8
|
-
* @example
|
9
|
-
* ```ts
|
10
|
-
* const path = builder()
|
11
|
-
* .type('User')
|
12
|
-
* .field('posts')
|
13
|
-
* .type('Post')
|
14
|
-
* .field('author')
|
15
|
-
* .build()
|
16
|
-
* ```
|
17
|
-
*/
|
18
|
-
export class QueryPathBuilder {
|
19
|
-
segments = [];
|
20
|
-
/**
|
21
|
-
* Add a type segment to the path
|
22
|
-
*
|
23
|
-
* @param typeName - The type name
|
24
|
-
* @returns The builder for chaining
|
25
|
-
*/
|
26
|
-
type(typeName) {
|
27
|
-
this.segments.push(createTypeSegment(typeName));
|
28
|
-
return this;
|
29
|
-
}
|
30
|
-
/**
|
31
|
-
* Add a field segment to the path
|
32
|
-
*
|
33
|
-
* @param fieldName - The field name
|
34
|
-
* @returns The builder for chaining
|
35
|
-
*/
|
36
|
-
field(fieldName) {
|
37
|
-
this.segments.push(createFieldSegment(fieldName));
|
38
|
-
return this;
|
39
|
-
}
|
40
|
-
/**
|
41
|
-
* Build the final query path
|
42
|
-
*
|
43
|
-
* @returns The constructed query path
|
44
|
-
*/
|
45
|
-
build() {
|
46
|
-
return this.segments;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
/**
|
50
|
-
* Create a new query path builder
|
51
|
-
*
|
52
|
-
* @returns A new query path builder instance
|
53
|
-
* @example
|
54
|
-
* ```ts
|
55
|
-
* const path = builder()
|
56
|
-
* .type('User')
|
57
|
-
* .field('posts')
|
58
|
-
* .type('Post')
|
59
|
-
* .field('author')
|
60
|
-
* .build()
|
61
|
-
* ```
|
62
|
-
*/
|
63
|
-
export const builder = () => new QueryPathBuilder();
|
4
|
+
import { S } from '#lib/kit-temp/effect';
|
5
|
+
import { QueryPath } from './types.js';
|
64
6
|
/**
|
65
7
|
* Encode a query path to a human-readable expression string
|
8
|
+
* Uses the Effect Schema codec for QueryPath
|
66
9
|
*
|
67
|
-
* @param path - The query path to encode
|
10
|
+
* @param path - The query path segments to encode
|
68
11
|
* @returns A string expression representation
|
69
12
|
* @example
|
70
|
-
* encode(
|
13
|
+
* encode([
|
14
|
+
* { _tag: 'TypeSegment', type: 'User' },
|
15
|
+
* { _tag: 'FieldSegment', field: 'posts' },
|
16
|
+
* { _tag: 'TypeSegment', type: 'Post' },
|
17
|
+
* { _tag: 'FieldSegment', field: 'title' }
|
18
|
+
* ]) // 'User.posts.Post.title'
|
71
19
|
*/
|
72
|
-
export const encode = (
|
73
|
-
return path.map(segment => {
|
74
|
-
if (segment.kind === 'type')
|
75
|
-
return segment.type;
|
76
|
-
if (segment.kind === 'field')
|
77
|
-
return segment.field;
|
78
|
-
return '';
|
79
|
-
}).filter(Boolean).join('.');
|
80
|
-
};
|
20
|
+
export const encode = S.encodeSync(QueryPath);
|
81
21
|
/**
|
82
22
|
* Decode a string expression into a query path
|
23
|
+
* Uses the Effect Schema codec for QueryPath
|
83
24
|
* Note: This assumes alternating type.field.type.field pattern
|
84
25
|
*
|
85
26
|
* @param expression - The string expression to decode
|
86
|
-
* @returns The decoded query path
|
27
|
+
* @returns The decoded query path segments
|
28
|
+
* @throws ParseError if the expression is invalid
|
87
29
|
* @example
|
88
30
|
* decode('User.posts.Post.title') // Query path traversing User->posts->Post->title
|
89
31
|
*/
|
90
|
-
export const decode = (
|
91
|
-
if (!expression)
|
92
|
-
return null;
|
93
|
-
const parts = expression.split('.');
|
94
|
-
const segments = [];
|
95
|
-
// Assume alternating pattern: type.field.type.field...
|
96
|
-
for (let i = 0; i < parts.length; i++) {
|
97
|
-
const part = parts[i];
|
98
|
-
if (!part)
|
99
|
-
continue;
|
100
|
-
if (i % 2 === 0) {
|
101
|
-
// Even indices are types
|
102
|
-
segments.push(createTypeSegment(part));
|
103
|
-
}
|
104
|
-
else {
|
105
|
-
// Odd indices are fields
|
106
|
-
segments.push(createFieldSegment(part));
|
107
|
-
}
|
108
|
-
}
|
109
|
-
return segments;
|
110
|
-
};
|
32
|
+
export const decode = S.decodeUnknownSync(QueryPath);
|
111
33
|
//# sourceMappingURL=query.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/lib/graphql-path/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/lib/graphql-path/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA"}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* GraphQL schema location utilities for definition paths
|
3
|
+
*/
|
4
|
+
import { Grafaid } from '#lib/grafaid';
|
5
|
+
import { Either } from 'effect';
|
6
|
+
import * as Definition from './definition.js';
|
7
|
+
declare const TypeNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
8
|
+
readonly _tag: "TypeNotFoundError";
|
9
|
+
} & Readonly<A>;
|
10
|
+
export declare class TypeNotFoundError extends TypeNotFoundError_base<{
|
11
|
+
typeName: string;
|
12
|
+
path: string;
|
13
|
+
}> {
|
14
|
+
}
|
15
|
+
declare const FieldNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
16
|
+
readonly _tag: "FieldNotFoundError";
|
17
|
+
} & Readonly<A>;
|
18
|
+
export declare class FieldNotFoundError extends FieldNotFoundError_base<{
|
19
|
+
typeName: string;
|
20
|
+
fieldName: string;
|
21
|
+
path: string;
|
22
|
+
}> {
|
23
|
+
}
|
24
|
+
/**
|
25
|
+
* Locate a type in the GraphQL schema from a type definition path.
|
26
|
+
*
|
27
|
+
* @param schema - The GraphQL schema
|
28
|
+
* @param path - The type definition path
|
29
|
+
* @returns Either the located type or a TypeNotFoundError
|
30
|
+
*/
|
31
|
+
export declare const locateType: (schema: Grafaid.Schema.Schema, path: Definition.TypeDefinitionPath) => Either.Either<Grafaid.Schema.TypesLike.Named, TypeNotFoundError>;
|
32
|
+
/**
|
33
|
+
* Locate a field in the GraphQL schema from a field definition path.
|
34
|
+
*
|
35
|
+
* @param schema - The GraphQL schema
|
36
|
+
* @param path - The field definition path
|
37
|
+
* @returns Either the located field or a FieldNotFoundError
|
38
|
+
*/
|
39
|
+
export declare const locateField: (schema: Grafaid.Schema.Schema, path: Definition.FieldDefinitionPath) => Either.Either<Grafaid.Schema.NodesLike.Field, FieldNotFoundError>;
|
40
|
+
/**
|
41
|
+
* Locate a type or field in the GraphQL schema from a definition path.
|
42
|
+
*
|
43
|
+
* @param schema - The GraphQL schema
|
44
|
+
* @param path - The definition path (type or field)
|
45
|
+
* @returns Either the located type/field or an error
|
46
|
+
*/
|
47
|
+
export declare const locate: (schema: Grafaid.Schema.Schema, path: Definition.DefinitionPath) => Either.Either<Grafaid.Schema.TypesLike.Named | Grafaid.Schema.NodesLike.Field, TypeNotFoundError | FieldNotFoundError>;
|
48
|
+
export {};
|
49
|
+
//# sourceMappingURL=schema.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/lib/graphql-path/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAQ,MAAM,EAAS,MAAM,QAAQ,CAAA;AAC5C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;;;;AAM7C,qBAAa,iBAAkB,SAAQ,uBAAsC;IAC3E,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb,CAAC;CAAG;;;;AAEL,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC7E,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb,CAAC;CA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