@gqlbase/plugins 0.0.2 → 0.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.
Files changed (89) hide show
  1. package/dist/base/ModelPlugin/ModelPlugin.d.ts +97 -0
  2. package/dist/base/ModelPlugin/ModelPlugin.d.ts.map +1 -0
  3. package/dist/base/ModelPlugin/ModelPlugin.js +405 -0
  4. package/dist/base/ModelPlugin/ModelPlugin.js.map +1 -0
  5. package/dist/base/ModelPlugin/ModelPlugin.utils.d.ts +31 -0
  6. package/dist/base/ModelPlugin/ModelPlugin.utils.d.ts.map +1 -0
  7. package/dist/base/ModelPlugin/ModelPlugin.utils.js +57 -0
  8. package/dist/base/ModelPlugin/ModelPlugin.utils.js.map +1 -0
  9. package/dist/base/ModelPlugin/index.d.ts +3 -0
  10. package/dist/base/ModelPlugin/index.d.ts.map +1 -0
  11. package/dist/base/ModelPlugin/index.js +3 -0
  12. package/dist/base/ModelPlugin/index.js.map +1 -0
  13. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.d.ts +23 -0
  14. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.d.ts.map +1 -0
  15. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.js +161 -0
  16. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.js.map +1 -0
  17. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.d.ts +12 -0
  18. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.d.ts.map +1 -0
  19. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.js +30 -0
  20. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.js.map +1 -0
  21. package/dist/base/ModelTypesGeneratorPlugin/index.d.ts +2 -0
  22. package/dist/base/ModelTypesGeneratorPlugin/index.d.ts.map +1 -0
  23. package/dist/base/ModelTypesGeneratorPlugin/index.js +2 -0
  24. package/dist/base/ModelTypesGeneratorPlugin/index.js.map +1 -0
  25. package/dist/base/RelationsPlugin/RelationsPlugin.d.ts +60 -0
  26. package/dist/base/RelationsPlugin/RelationsPlugin.d.ts.map +1 -0
  27. package/dist/base/RelationsPlugin/RelationsPlugin.js +188 -0
  28. package/dist/base/RelationsPlugin/RelationsPlugin.js.map +1 -0
  29. package/dist/base/RelationsPlugin/RelationsPlugin.utils.d.ts +19 -0
  30. package/dist/base/RelationsPlugin/RelationsPlugin.utils.d.ts.map +1 -0
  31. package/dist/base/RelationsPlugin/RelationsPlugin.utils.js +30 -0
  32. package/dist/base/RelationsPlugin/RelationsPlugin.utils.js.map +1 -0
  33. package/dist/base/RelationsPlugin/index.d.ts +3 -0
  34. package/dist/base/RelationsPlugin/index.d.ts.map +1 -0
  35. package/dist/base/RelationsPlugin/index.js +3 -0
  36. package/dist/base/RelationsPlugin/index.js.map +1 -0
  37. package/dist/base/ScalarsPlugin/ScalarsPlugin.d.ts +56 -0
  38. package/dist/base/ScalarsPlugin/ScalarsPlugin.d.ts.map +1 -0
  39. package/dist/base/ScalarsPlugin/ScalarsPlugin.js +140 -0
  40. package/dist/base/ScalarsPlugin/ScalarsPlugin.js.map +1 -0
  41. package/dist/base/ScalarsPlugin/index.d.ts +2 -0
  42. package/dist/base/ScalarsPlugin/index.d.ts.map +1 -0
  43. package/dist/base/ScalarsPlugin/index.js +2 -0
  44. package/dist/base/ScalarsPlugin/index.js.map +1 -0
  45. package/dist/base/SchemaGeneratorPlugin.d.ts +7 -0
  46. package/dist/base/SchemaGeneratorPlugin.d.ts.map +1 -0
  47. package/dist/base/SchemaGeneratorPlugin.js +14 -0
  48. package/dist/base/SchemaGeneratorPlugin.js.map +1 -0
  49. package/dist/base/UtilitiesPlugin/UtilitiesPlugin.d.ts +17 -0
  50. package/dist/base/UtilitiesPlugin/UtilitiesPlugin.d.ts.map +1 -0
  51. package/dist/base/UtilitiesPlugin/UtilitiesPlugin.js +66 -0
  52. package/dist/base/UtilitiesPlugin/UtilitiesPlugin.js.map +1 -0
  53. package/dist/base/UtilitiesPlugin/UtilitiesPlugin.utils.d.ts +25 -0
  54. package/dist/base/UtilitiesPlugin/UtilitiesPlugin.utils.d.ts.map +1 -0
  55. package/dist/base/UtilitiesPlugin/UtilitiesPlugin.utils.js +38 -0
  56. package/dist/base/UtilitiesPlugin/UtilitiesPlugin.utils.js.map +1 -0
  57. package/dist/base/UtilitiesPlugin/index.d.ts +3 -0
  58. package/dist/base/UtilitiesPlugin/index.d.ts.map +1 -0
  59. package/dist/base/UtilitiesPlugin/index.js +3 -0
  60. package/dist/base/UtilitiesPlugin/index.js.map +1 -0
  61. package/dist/base/basePreset.d.ts +15 -0
  62. package/dist/base/basePreset.d.ts.map +1 -0
  63. package/dist/base/basePreset.js +30 -0
  64. package/dist/base/basePreset.js.map +1 -0
  65. package/dist/base/index.d.ts +6 -2
  66. package/dist/base/index.d.ts.map +1 -1
  67. package/dist/base/index.js +7 -2
  68. package/dist/base/index.js.map +1 -0
  69. package/dist/relay/ConnectionPlugin.d.ts +46 -0
  70. package/dist/relay/ConnectionPlugin.d.ts.map +1 -0
  71. package/dist/relay/ConnectionPlugin.js +200 -0
  72. package/dist/relay/ConnectionPlugin.js.map +1 -0
  73. package/dist/{base → relay}/NodeInterfacePlugin.d.ts +1 -0
  74. package/dist/relay/NodeInterfacePlugin.d.ts.map +1 -0
  75. package/dist/{base → relay}/NodeInterfacePlugin.js +20 -6
  76. package/dist/relay/NodeInterfacePlugin.js.map +1 -0
  77. package/dist/relay/index.d.ts +3 -0
  78. package/dist/relay/index.d.ts.map +1 -0
  79. package/dist/relay/index.js +3 -0
  80. package/dist/relay/index.js.map +1 -0
  81. package/dist/relay/relayPreset.d.ts +11 -0
  82. package/dist/relay/relayPreset.d.ts.map +1 -0
  83. package/dist/relay/relayPreset.js +15 -0
  84. package/dist/relay/relayPreset.js.map +1 -0
  85. package/package.json +3 -3
  86. package/dist/base/ModelPlugin.d.ts +0 -59
  87. package/dist/base/ModelPlugin.d.ts.map +0 -1
  88. package/dist/base/ModelPlugin.js +0 -222
  89. package/dist/base/NodeInterfacePlugin.d.ts.map +0 -1
@@ -0,0 +1,23 @@
1
+ import { ITransformerContext, TransformerPluginBase } from "@gqlbase/core";
2
+ import { DefinitionNode } from "@gqlbase/core/definition";
3
+ /**
4
+ * This plugin generates TypeScript types for all objects defined in the schema.
5
+ */
6
+ export declare class ModelTypesGeneratorPlugin extends TransformerPluginBase {
7
+ private nodes;
8
+ constructor(context: ITransformerContext);
9
+ private _getContent;
10
+ private _createTypeNameIdentifier;
11
+ private _createValueTypeReference;
12
+ private _createFieldMembers;
13
+ private _createObjectType;
14
+ private _createInterfaceType;
15
+ private _createEnumType;
16
+ private _createUnionType;
17
+ before(): void;
18
+ match(definition: DefinitionNode): boolean;
19
+ generate(definition: DefinitionNode): void;
20
+ output(): {};
21
+ }
22
+ export declare const modelTypesGeneratorPlugin: (options?: unknown) => import("@gqlbase/core").IPluginFactory;
23
+ //# sourceMappingURL=ModelTypesGeneratorPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelTypesGeneratorPlugin.d.ts","sourceRoot":"","sources":["../../../src/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGhG,OAAO,EACL,cAAc,EAQf,MAAM,0BAA0B,CAAC;AAWlC;;GAEG;AAEH,qBAAa,yBAA0B,SAAQ,qBAAqB;IAClE,OAAO,CAAC,KAAK,CAAiB;gBAElB,OAAO,EAAE,mBAAmB;IAIxC,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,yBAAyB;IAkCjC,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,mBAAmB;IAoC3B,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,eAAe;IAsBvB,OAAO,CAAC,gBAAgB;IAsBjB,MAAM;IAkBN,KAAK,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO;IAQ1C,QAAQ,CAAC,UAAU,EAAE,cAAc;IAkBnC,MAAM;CAMd;AAED,eAAO,MAAM,yBAAyB,+DAAiD,CAAC"}
@@ -0,0 +1,161 @@
1
+ import ts from "typescript";
2
+ import { createPluginFactory, TransformerPluginBase } from "@gqlbase/core";
3
+ import { writeOutputFile } from "@gqlbase/shared/files";
4
+ import { createFileHeaders } from "@gqlbase/shared/codegen";
5
+ import { EnumNode, InterfaceNode, ListTypeNode, NonNullTypeNode, ObjectNode, UnionNode, } from "@gqlbase/core/definition";
6
+ import { getBuildinScalarTypeKeyword, isNonNullableField, isOperationNode, } from "./ModelTypesGeneratorPlugin.utils.js";
7
+ import { isEnum, isObjectLike, isScalar } from "../ModelPlugin/ModelPlugin.utils.js";
8
+ import { isRelationField } from "../RelationsPlugin/RelationsPlugin.utils.js";
9
+ import { isBuildInScalar } from "@gqlbase/shared/definition";
10
+ import { getTypeHint, isInternal } from "@gqlbase/core/plugins";
11
+ /**
12
+ * This plugin generates TypeScript types for all objects defined in the schema.
13
+ */
14
+ export class ModelTypesGeneratorPlugin extends TransformerPluginBase {
15
+ nodes = [];
16
+ constructor(context) {
17
+ super("ModelTypesGeneratorPlugin", context);
18
+ }
19
+ _getContent() {
20
+ const file = ts.createSourceFile("models.typegen.ts",
21
+ /*sourceText*/ "", ts.ScriptTarget.Latest,
22
+ /*setParentNodes*/ false, ts.ScriptKind.TS);
23
+ const printer = ts.createPrinter({
24
+ newLine: ts.NewLineKind.CarriageReturnLineFeed,
25
+ removeComments: false,
26
+ });
27
+ return printer.printList(ts.ListFormat.MultiLine, ts.factory.createNodeArray(this.nodes), file);
28
+ }
29
+ _createTypeNameIdentifier(typeName) {
30
+ if (isBuildInScalar(typeName)) {
31
+ return ts.factory.createIdentifier(getBuildinScalarTypeKeyword(typeName));
32
+ }
33
+ const typeDef = this.context.document.getNodeOrThrow(typeName);
34
+ if (isScalar(typeDef)) {
35
+ const hint = getTypeHint(typeDef);
36
+ switch (hint) {
37
+ case "id":
38
+ return ts.factory.createIdentifier("string");
39
+ case "string":
40
+ return ts.factory.createIdentifier("string");
41
+ case "number":
42
+ return ts.factory.createIdentifier("number");
43
+ case "boolean":
44
+ return ts.factory.createIdentifier("boolean");
45
+ case "object":
46
+ return ts.factory.createIdentifier("Record<string, unknown>");
47
+ case "unknown":
48
+ default: {
49
+ this.context.logger.warn(`Unknown type hint for scalar ${typeDef.name}. Defaulting to unknown.`);
50
+ return ts.factory.createIdentifier("unknown");
51
+ }
52
+ }
53
+ }
54
+ return ts.factory.createIdentifier(typeName);
55
+ }
56
+ _createValueTypeReference(fieldType) {
57
+ if (fieldType instanceof NonNullTypeNode) {
58
+ return this._createValueTypeReference(fieldType.type);
59
+ }
60
+ if (fieldType instanceof ListTypeNode) {
61
+ const elementType = this._createValueTypeReference(fieldType.type);
62
+ return ts.factory.createArrayTypeNode(elementType);
63
+ }
64
+ return ts.factory.createTypeReferenceNode(this._createTypeNameIdentifier(fieldType.name));
65
+ }
66
+ _createFieldMembers(definition) {
67
+ const members = [];
68
+ for (const field of definition.fields ?? []) {
69
+ if (isRelationField(field)) {
70
+ continue;
71
+ }
72
+ const questionToken = isNonNullableField(field)
73
+ ? undefined
74
+ : ts.factory.createToken(ts.SyntaxKind.QuestionToken);
75
+ const typeNode = isNonNullableField(field)
76
+ ? this._createValueTypeReference(field.type)
77
+ : ts.factory.createTypeReferenceNode("Maybe", [this._createValueTypeReference(field.type)]);
78
+ const propertySignature = ts.factory.createPropertySignature([ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)], ts.factory.createIdentifier(field.name), questionToken, typeNode);
79
+ // ts.addSyntheticLeadingComment(
80
+ // propertySignature,
81
+ // ts.SyntaxKind.MultiLineCommentTrivia,
82
+ // `* ${field.name ?? ""} `,
83
+ // /*hasTrailingNewLine*/ true
84
+ // );
85
+ members.push(propertySignature);
86
+ }
87
+ return members;
88
+ }
89
+ _createObjectType(definition) {
90
+ const members = this._createFieldMembers(definition);
91
+ const objectType = ts.factory.createTypeAliasDeclaration(
92
+ /*modifiers*/ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createIdentifier(definition.name),
93
+ /*typeParameters*/ undefined, ts.factory.createTypeLiteralNode(members));
94
+ this.nodes.push(objectType);
95
+ }
96
+ _createInterfaceType(definition) {
97
+ const members = this._createFieldMembers(definition);
98
+ const interfaceType = ts.factory.createInterfaceDeclaration(
99
+ /*modifiers*/ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createIdentifier(definition.name),
100
+ /*typeParameters*/ undefined,
101
+ /*heritageClauses*/ undefined, members);
102
+ this.nodes.push(interfaceType);
103
+ }
104
+ _createEnumType(definition) {
105
+ if (!definition.values?.length) {
106
+ this.context.logger.warn(`Enum type ${definition.name} does not have any values. Skipping type generation.`);
107
+ return;
108
+ }
109
+ const members = definition.values.map((value) => ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(value.name)));
110
+ const enumType = ts.factory.createTypeAliasDeclaration(
111
+ /*modifiers*/ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createIdentifier(definition.name),
112
+ /*typeParameters*/ undefined, ts.factory.createUnionTypeNode(members));
113
+ this.nodes.push(enumType);
114
+ }
115
+ _createUnionType(definition) {
116
+ if (!definition.types?.length) {
117
+ this.context.logger.warn(`Union type ${definition.name} does not have any member types. Skipping type generation.`);
118
+ return;
119
+ }
120
+ const refs = definition.types.map((type) => ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(type.name)));
121
+ const unionType = ts.factory.createTypeAliasDeclaration(
122
+ /*modifiers*/ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createIdentifier(definition.name),
123
+ /*typeParameters*/ undefined, ts.factory.createUnionTypeNode(refs));
124
+ this.nodes.push(unionType);
125
+ }
126
+ before() {
127
+ const headers = createFileHeaders();
128
+ this.nodes = [...headers];
129
+ this.nodes.push(ts.factory.createTypeAliasDeclaration(
130
+ /*modifiers*/ [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createIdentifier("Maybe"), [ts.factory.createTypeParameterDeclaration(undefined, "T")], ts.factory.createUnionTypeNode([
131
+ ts.factory.createTypeReferenceNode("T"),
132
+ ts.factory.createLiteralTypeNode(ts.factory.createNull()),
133
+ ])));
134
+ }
135
+ match(definition) {
136
+ return ((isObjectLike(definition) || isEnum(definition)) &&
137
+ !isOperationNode(definition) &&
138
+ !isInternal(definition));
139
+ }
140
+ generate(definition) {
141
+ if (definition instanceof InterfaceNode) {
142
+ return this._createInterfaceType(definition);
143
+ }
144
+ if (definition instanceof ObjectNode) {
145
+ return this._createObjectType(definition);
146
+ }
147
+ if (definition instanceof UnionNode) {
148
+ return this._createUnionType(definition);
149
+ }
150
+ if (definition instanceof EnumNode) {
151
+ return this._createEnumType(definition);
152
+ }
153
+ }
154
+ output() {
155
+ const content = this._getContent();
156
+ writeOutputFile(this.context.outputDirectory, "models.typegen.ts", content);
157
+ return {};
158
+ }
159
+ }
160
+ export const modelTypesGeneratorPlugin = createPluginFactory(ModelTypesGeneratorPlugin);
161
+ //# sourceMappingURL=ModelTypesGeneratorPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelTypesGeneratorPlugin.js","sourceRoot":"","sources":["../../../src/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAuB,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAEL,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,eA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O,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,UAAU,YAAY,UAAU,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,UAAU,YAAY,SAAS,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,UAAU,YAAY,QAAQ,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAEM,MAAM;QACX,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAE5E,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAAC,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { DefinitionNode, FieldNode, InputValueNode } from "@gqlbase/core/definition";
2
+ export declare const isOperationNode: (node: DefinitionNode) => boolean;
3
+ /**
4
+ *
5
+ * @param field Field node to check for non-nullability
6
+ * @returns True if the field is non-nullable, false otherwise
7
+ *
8
+ * TODO: check for semantic nullability based on directives.
9
+ */
10
+ export declare const isNonNullableField: (field: FieldNode | InputValueNode) => boolean;
11
+ export declare const getBuildinScalarTypeKeyword: (typeName: string) => string;
12
+ //# sourceMappingURL=ModelTypesGeneratorPlugin.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelTypesGeneratorPlugin.utils.d.ts","sourceRoot":"","sources":["../../../src/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,cAAc,EAEf,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,eAAe,GAAI,MAAM,cAAc,YAEnD,CAAC;AAEF;;;;;;GAMG;AAEH,eAAO,MAAM,kBAAkB,GAAI,OAAO,SAAS,GAAG,cAAc,YAEnE,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,UAAU,MAAM,KAAG,MAa9D,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { NonNullTypeNode, } from "@gqlbase/core/definition";
2
+ const OPERATION_NODE_NAME = ["Query", "Mutation", "Subscription"];
3
+ export const isOperationNode = (node) => {
4
+ return OPERATION_NODE_NAME.includes(node.name);
5
+ };
6
+ /**
7
+ *
8
+ * @param field Field node to check for non-nullability
9
+ * @returns True if the field is non-nullable, false otherwise
10
+ *
11
+ * TODO: check for semantic nullability based on directives.
12
+ */
13
+ export const isNonNullableField = (field) => {
14
+ return field.type instanceof NonNullTypeNode;
15
+ };
16
+ export const getBuildinScalarTypeKeyword = (typeName) => {
17
+ switch (typeName) {
18
+ case "ID":
19
+ case "String":
20
+ return "string";
21
+ case "Int":
22
+ case "Float":
23
+ return "number";
24
+ case "Boolean":
25
+ return "boolean";
26
+ default:
27
+ throw new Error(`Unsupported build-in scalar type: ${typeName}`);
28
+ }
29
+ };
30
+ //# sourceMappingURL=ModelTypesGeneratorPlugin.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelTypesGeneratorPlugin.utils.js","sourceRoot":"","sources":["../../../src/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,cAAc,CAAU,CAAC;AAE3E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAoB,EAAE,EAAE;IACtD,OAAO,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAA4C,CAAC,CAAC;AACzF,CAAC,CAAC;AAEF;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAiC,EAAE,EAAE;IACtE,OAAO,KAAK,CAAC,IAAI,YAAY,eAAe,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,QAAgB,EAAU,EAAE;IACtE,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,IAAI,CAAC;QACV,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,KAAK,CAAC;QACX,KAAK,OAAO;YACV,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB;YACE,MAAM,IAAI,KAAK,CAAC,qCAAqC,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { ModelTypesGeneratorPlugin, modelTypesGeneratorPlugin, } from "./ModelTypesGeneratorPlugin.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/base/ModelTypesGeneratorPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { ModelTypesGeneratorPlugin, modelTypesGeneratorPlugin, } from "./ModelTypesGeneratorPlugin.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/ModelTypesGeneratorPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { ITransformerContext, ITransformerPlugin } from "@gqlbase/core";
2
+ import { DefinitionNode, InterfaceNode, ObjectNode } from "@gqlbase/core/definition";
3
+ import { RelationPluginOptions } from "./RelationsPlugin.utils.js";
4
+ /**
5
+ * This plugin is responsible for adding the `@hasOne` and `@hasMany` directives to the schema, which can be used to define relationships between types. It also adds the necessary fields and arguments to the schema to support these directives.
6
+ *
7
+ * @example
8
+ *
9
+ * ```graphql
10
+ *
11
+ * # Before
12
+ * type User {
13
+ * id: ID!
14
+ * name: String!
15
+ * posts: Post `@hasMany(key: "authorId")`
16
+ * }
17
+ *
18
+ * type Post {
19
+ * id: ID!
20
+ * title: String!
21
+ * author: User `@hasOne`
22
+ * }
23
+ *
24
+ * # After
25
+ * type User {
26
+ * id: ID!
27
+ * name: String!
28
+ * posts: [Post]
29
+ * }
30
+ *
31
+ * type Post {
32
+ * id: ID!
33
+ * title: String!
34
+ * authorId: ID
35
+ * author: User
36
+ * }
37
+ * ```
38
+ *
39
+ * In the above example, the `User` type has a `posts` field that is decorated with the `@hasMany` directive, indicating that a user can have many posts. The plugin will automatically add the necessary fields and arguments to support this relationship in the schema.
40
+ *
41
+ */
42
+ export declare class RelationsPlugin implements ITransformerPlugin {
43
+ readonly name = "RelationsPlugin";
44
+ readonly context: ITransformerContext;
45
+ private readonly _useConnections;
46
+ constructor(context: ITransformerContext, options?: RelationPluginOptions);
47
+ private _getRelationshipTarget;
48
+ private _getFieldRelation;
49
+ private _setRelationKey;
50
+ private _setConnectionArguments;
51
+ private _createFieldConnection;
52
+ init(): void;
53
+ match(definition: DefinitionNode): boolean;
54
+ normalize(definition: ObjectNode | InterfaceNode): void;
55
+ execute(definition: ObjectNode | InterfaceNode): void;
56
+ cleanup(definition: ObjectNode | InterfaceNode): void;
57
+ after(): void;
58
+ }
59
+ export declare const relationPlugin: (options?: RelationPluginOptions | undefined) => import("@gqlbase/core").IPluginFactory;
60
+ //# sourceMappingURL=RelationsPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelationsPlugin.d.ts","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/RelationsPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EACL,cAAc,EAId,aAAa,EAGb,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAQL,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AAGpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,qBAAa,eAAgB,YAAW,kBAAkB;IACxD,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;gBAGxC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,GAAE,qBAAiD;IAM5D,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,iBAAiB;IAmDzB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,sBAAsB;IAiBvB,IAAI;IAkBJ,KAAK,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO;IAW1C,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa,GAAG,IAAI;IAiC9D,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa,GAAG,IAAI;IAoB9C,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa,GAAG,IAAI;IAY5D,KAAK,IAAI,IAAI;CAKd;AAED,eAAO,MAAM,cAAc,yFAAuC,CAAC"}
@@ -0,0 +1,188 @@
1
+ import { createPluginFactory } from "@gqlbase/core";
2
+ import { DirectiveDefinitionNode, FieldNode, InputValueNode, InterfaceNode, ListTypeNode, NamedTypeNode, ObjectNode, UnionNode, } from "@gqlbase/core/definition";
3
+ import { TransformerPluginExecutionError } from "@gqlbase/shared/errors";
4
+ import { camelCase, pascalCase } from "@gqlbase/shared/format";
5
+ import { isConnectionNode, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, RelationDirective, } from "./RelationsPlugin.utils.js";
6
+ import { isListTypeNode } from "../ModelPlugin/ModelPlugin.utils.js";
7
+ /**
8
+ * This plugin is responsible for adding the `@hasOne` and `@hasMany` directives to the schema, which can be used to define relationships between types. It also adds the necessary fields and arguments to the schema to support these directives.
9
+ *
10
+ * @example
11
+ *
12
+ * ```graphql
13
+ *
14
+ * # Before
15
+ * type User {
16
+ * id: ID!
17
+ * name: String!
18
+ * posts: Post `@hasMany(key: "authorId")`
19
+ * }
20
+ *
21
+ * type Post {
22
+ * id: ID!
23
+ * title: String!
24
+ * author: User `@hasOne`
25
+ * }
26
+ *
27
+ * # After
28
+ * type User {
29
+ * id: ID!
30
+ * name: String!
31
+ * posts: [Post]
32
+ * }
33
+ *
34
+ * type Post {
35
+ * id: ID!
36
+ * title: String!
37
+ * authorId: ID
38
+ * author: User
39
+ * }
40
+ * ```
41
+ *
42
+ * In the above example, the `User` type has a `posts` field that is decorated with the `@hasMany` directive, indicating that a user can have many posts. The plugin will automatically add the necessary fields and arguments to support this relationship in the schema.
43
+ *
44
+ */
45
+ export class RelationsPlugin {
46
+ name = "RelationsPlugin";
47
+ context;
48
+ _useConnections;
49
+ constructor(context, options = { useConnections: false }) {
50
+ this.context = context;
51
+ this._useConnections = options.useConnections ?? false;
52
+ }
53
+ _getRelationshipTarget(field) {
54
+ const fieldType = this.context.document.getNode(field.type.getTypeName());
55
+ if (isRelationField(field)) {
56
+ return fieldType;
57
+ }
58
+ return undefined;
59
+ }
60
+ _getFieldRelation(object, field) {
61
+ const target = this._getRelationshipTarget(field);
62
+ if (!target)
63
+ return null;
64
+ if (!isValidRelationTarget(target)) {
65
+ throw new TransformerPluginExecutionError(this.name, `Type ${target.name} is not a valid relationship target for ${object.name}.${field.name}`);
66
+ }
67
+ let directive = field.getDirective(RelationDirective.HAS_ONE);
68
+ if (directive) {
69
+ if (field.hasDirective(RelationDirective.HAS_MANY)) {
70
+ throw new TransformerPluginExecutionError(this.name, `Multiple relationship directives detected for ${object.name}.${field.name}`);
71
+ }
72
+ const args = directive.getArgumentsJSON();
73
+ return {
74
+ type: "oneToOne",
75
+ target: target,
76
+ key: args.key ?? camelCase(field.name, "id"),
77
+ };
78
+ }
79
+ directive = field.getDirective(RelationDirective.HAS_MANY);
80
+ if (directive) {
81
+ const args = directive.getArgumentsJSON();
82
+ return {
83
+ type: "oneToMany",
84
+ target: target,
85
+ key: args.key ?? camelCase(object.name, "id"),
86
+ };
87
+ }
88
+ throw new TransformerPluginExecutionError(this.name, `Could not find connection directive: ${field.name}`);
89
+ }
90
+ _setRelationKey(node, key) {
91
+ if (!node.hasField(key)) {
92
+ node.addField(FieldNode.create(key, NamedTypeNode.create("ID")));
93
+ }
94
+ }
95
+ _setConnectionArguments(field) {
96
+ if (!field.hasArgument("limit")) {
97
+ field.addArgument(InputValueNode.create("limit", NamedTypeNode.create("Int")));
98
+ }
99
+ if (!field.hasArgument("nextToken")) {
100
+ field.addArgument(InputValueNode.create("nextToken", NamedTypeNode.create("String")));
101
+ }
102
+ }
103
+ _createFieldConnection(field, target) {
104
+ this._setConnectionArguments(field);
105
+ if (isConnectionNode(target)) {
106
+ return target;
107
+ }
108
+ const connectionTypeName = pascalCase(target.name, "Connection");
109
+ return this.context.document.getOrCreateNode(connectionTypeName, ObjectNode.create(connectionTypeName)
110
+ .addField(FieldNode.create("items", ListTypeNode.create(NamedTypeNode.create(target.name))))
111
+ .addField(FieldNode.create("nextToken", NamedTypeNode.create("String"))));
112
+ }
113
+ init() {
114
+ this.context.base
115
+ .addNode(DirectiveDefinitionNode.create(RelationDirective.HAS_ONE, ["FIELD_DEFINITION"], [InputValueNode.create("key", "String")]))
116
+ .addNode(DirectiveDefinitionNode.create(RelationDirective.HAS_MANY, ["FIELD_DEFINITION"], [InputValueNode.create("key", "String")]));
117
+ }
118
+ match(definition) {
119
+ if (definition instanceof InterfaceNode || definition instanceof ObjectNode) {
120
+ if (definition.name === "Mutation")
121
+ return false;
122
+ if (isConnectionNode(definition))
123
+ return false;
124
+ if (!definition.fields?.length)
125
+ return false;
126
+ return true;
127
+ }
128
+ return false;
129
+ }
130
+ normalize(definition) {
131
+ for (const field of definition.fields ?? []) {
132
+ const relation = this._getFieldRelation(definition, field);
133
+ if (!relation) {
134
+ continue;
135
+ }
136
+ if (relation.type === "oneToOne") {
137
+ this._setRelationKey(definition, relation.key);
138
+ continue;
139
+ }
140
+ if (relation.target instanceof UnionNode) {
141
+ for (const type of relation.target.types ?? []) {
142
+ const unionType = this.context.document.getNode(type.getTypeName());
143
+ if (unionType instanceof ObjectNode || unionType instanceof InterfaceNode) {
144
+ this._setRelationKey(unionType, relation.key);
145
+ continue;
146
+ }
147
+ throw new TransformerPluginExecutionError(this.name, `Invalid relation union target: ${relation.target.name}`);
148
+ }
149
+ }
150
+ else {
151
+ this._setRelationKey(relation.target, relation.key);
152
+ }
153
+ }
154
+ }
155
+ execute(definition) {
156
+ for (const field of definition.fields ?? []) {
157
+ const relation = this._getFieldRelation(definition, field);
158
+ if (!relation || relation.type === "oneToOne") {
159
+ continue;
160
+ }
161
+ if (this._useConnections) {
162
+ const connection = this._createFieldConnection(field, relation.target);
163
+ field.setType(NamedTypeNode.create(connection.name));
164
+ continue;
165
+ }
166
+ if (!isListTypeNode(field.type)) {
167
+ field.setType(ListTypeNode.create(field.type));
168
+ }
169
+ }
170
+ }
171
+ cleanup(definition) {
172
+ for (const field of definition.fields ?? []) {
173
+ if (isOneRelationship(field)) {
174
+ field.removeDirective(RelationDirective.HAS_ONE);
175
+ }
176
+ if (isManyRelationship(field)) {
177
+ field.removeDirective(RelationDirective.HAS_MANY);
178
+ }
179
+ }
180
+ }
181
+ after() {
182
+ this.context.document
183
+ .removeNode(RelationDirective.HAS_ONE)
184
+ .removeNode(RelationDirective.HAS_MANY);
185
+ }
186
+ }
187
+ export const relationPlugin = createPluginFactory(RelationsPlugin);
188
+ //# sourceMappingURL=RelationsPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelationsPlugin.js","sourceRoot":"","sources":["../../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AC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;gBACrD,SAAS;YACX,CAAC;YAED,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAEM,OAAO,CAAC,UAAsC;QACnD,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC5C,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,KAAK,CAAC,eAAe,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;YACnD,CAAC;YAED,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,KAAK,CAAC,eAAe,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,QAAQ;aAClB,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC;aACrC,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { DefinitionNode, FieldNode, InterfaceNode, ObjectNode, UnionNode } from "@gqlbase/core/definition";
2
+ export interface RelationPluginOptions {
3
+ useConnections?: boolean;
4
+ }
5
+ export declare const RelationDirective: {
6
+ readonly HAS_ONE: "hasOne";
7
+ readonly HAS_MANY: "hasMany";
8
+ };
9
+ export interface FieldRelationship {
10
+ type: "oneToOne" | "oneToMany";
11
+ target: ObjectNode | InterfaceNode | UnionNode;
12
+ key?: string;
13
+ }
14
+ export declare const isOneRelationship: (field: FieldNode) => boolean;
15
+ export declare const isManyRelationship: (field: FieldNode) => boolean;
16
+ export declare const isRelationField: (field: FieldNode) => boolean;
17
+ export declare const isConnectionNode: (node: DefinitionNode) => boolean;
18
+ export declare const isValidRelationTarget: (node: DefinitionNode) => node is ObjectNode | InterfaceNode | UnionNode;
19
+ //# sourceMappingURL=RelationsPlugin.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelationsPlugin.utils.d.ts","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/RelationsPlugin.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACV,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,qBAAqB;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;IAC/B,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,KAAG,OAEpD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,SAAS,KAAG,OAErD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,KAAG,OAElD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,cAAc,KAAG,OASvD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,MAAM,cAAc,KACnB,IAAI,IAAI,UAAU,GAAG,aAAa,GAAG,SAEvC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { InterfaceNode, ObjectNode, UnionNode, } from "@gqlbase/core/definition";
2
+ export const RelationDirective = {
3
+ HAS_ONE: "hasOne",
4
+ HAS_MANY: "hasMany",
5
+ };
6
+ export const isOneRelationship = (field) => {
7
+ return field.hasDirective(RelationDirective.HAS_ONE);
8
+ };
9
+ export const isManyRelationship = (field) => {
10
+ return field.hasDirective(RelationDirective.HAS_MANY);
11
+ };
12
+ export const isRelationField = (field) => {
13
+ return isOneRelationship(field) || isManyRelationship(field);
14
+ };
15
+ export const isConnectionNode = (node) => {
16
+ if (node instanceof ObjectNode) {
17
+ if (!node.name.endsWith("Connection"))
18
+ return false;
19
+ if (!node.fields || node.fields.length < 2)
20
+ return false;
21
+ if (!node.hasField("items") || !node.hasField("nextToken"))
22
+ return false;
23
+ return true;
24
+ }
25
+ return false;
26
+ };
27
+ export const isValidRelationTarget = (node) => {
28
+ return node instanceof ObjectNode || node instanceof InterfaceNode || node instanceof UnionNode;
29
+ };
30
+ //# sourceMappingURL=RelationsPlugin.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelationsPlugin.utils.js","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/RelationsPlugin.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,0BAA0B,CAAC;AAMlC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,SAAS;CACX,CAAC;AAQX,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAgB,EAAW,EAAE;IAC7D,OAAO,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAgB,EAAW,EAAE;IAC9D,OAAO,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAgB,EAAW,EAAE;IAC3D,OAAO,iBAAiB,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAoB,EAAW,EAAE;IAChE,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;YAAE,OAAO,KAAK,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QACzD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,IAAoB,EAC4B,EAAE;IAClD,OAAO,IAAI,YAAY,UAAU,IAAI,IAAI,YAAY,aAAa,IAAI,IAAI,YAAY,SAAS,CAAC;AAClG,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { RelationsPlugin, relationPlugin } from "./RelationsPlugin.js";
2
+ export { type RelationPluginOptions, type FieldRelationship, RelationDirective, isConnectionNode, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, } from "./RelationsPlugin.utils.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,GACtB,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { RelationsPlugin, relationPlugin } from "./RelationsPlugin.js";
2
+ export { RelationDirective, isConnectionNode, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, } from "./RelationsPlugin.utils.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,GACtB,MAAM,4BAA4B,CAAC"}