apollo-conn-gen 0.3.3 → 0.4.0

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 (78) hide show
  1. package/dist/cli/json.js +0 -16
  2. package/dist/cli/json.js.map +1 -1
  3. package/dist/cli/oas-helpers/index.js +0 -13
  4. package/dist/cli/oas-helpers/index.js.map +1 -1
  5. package/dist/index.js +0 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/json/walker/jsonGen.js +0 -31
  8. package/dist/json/walker/jsonGen.js.map +1 -1
  9. package/dist/json/walker/naming.d.ts +2 -4
  10. package/dist/json/walker/naming.js +14 -9
  11. package/dist/json/walker/naming.js.map +1 -1
  12. package/dist/json/walker/types/jsonArray.js +2 -7
  13. package/dist/json/walker/types/jsonArray.js.map +1 -1
  14. package/dist/json/walker/types/jsonObj.js +6 -11
  15. package/dist/json/walker/types/jsonObj.js.map +1 -1
  16. package/dist/json/walker/types/jsonScalar.js +16 -6
  17. package/dist/json/walker/types/jsonScalar.js.map +1 -1
  18. package/dist/json/walker/types/jsonType.d.ts +2 -1
  19. package/dist/json/walker/types/jsonType.js +5 -1
  20. package/dist/json/walker/types/jsonType.js.map +1 -1
  21. package/dist/oas/io/operationWriter.d.ts +14 -0
  22. package/dist/oas/io/operationWriter.js +106 -0
  23. package/dist/oas/io/operationWriter.js.map +1 -0
  24. package/dist/oas/io/pathCollector.d.ts +11 -0
  25. package/dist/oas/io/pathCollector.js +95 -0
  26. package/dist/oas/io/pathCollector.js.map +1 -0
  27. package/dist/oas/io/schemaWriter.d.ts +9 -0
  28. package/dist/oas/io/schemaWriter.js +36 -0
  29. package/dist/oas/io/schemaWriter.js.map +1 -0
  30. package/dist/oas/io/writer.d.ts +5 -17
  31. package/dist/oas/io/writer.js +24 -243
  32. package/dist/oas/io/writer.js.map +1 -1
  33. package/dist/oas/nodes/arr.js +2 -2
  34. package/dist/oas/nodes/arr.js.map +1 -1
  35. package/dist/oas/nodes/body.js +2 -2
  36. package/dist/oas/nodes/body.js.map +1 -1
  37. package/dist/oas/nodes/circularRef.js +2 -2
  38. package/dist/oas/nodes/circularRef.js.map +1 -1
  39. package/dist/oas/nodes/comp.js +4 -16
  40. package/dist/oas/nodes/comp.js.map +1 -1
  41. package/dist/oas/nodes/get.js +11 -11
  42. package/dist/oas/nodes/get.js.map +1 -1
  43. package/dist/oas/nodes/obj.js +6 -6
  44. package/dist/oas/nodes/obj.js.map +1 -1
  45. package/dist/oas/nodes/post.js +10 -14
  46. package/dist/oas/nodes/post.js.map +1 -1
  47. package/dist/oas/nodes/prop.js +6 -6
  48. package/dist/oas/nodes/prop.js.map +1 -1
  49. package/dist/oas/nodes/propArray.js +6 -6
  50. package/dist/oas/nodes/propArray.js.map +1 -1
  51. package/dist/oas/nodes/propCircRef.js +3 -3
  52. package/dist/oas/nodes/propCircRef.js.map +1 -1
  53. package/dist/oas/nodes/propComp.js +5 -5
  54. package/dist/oas/nodes/propComp.js.map +1 -1
  55. package/dist/oas/nodes/propEn.js +3 -3
  56. package/dist/oas/nodes/propEn.js.map +1 -1
  57. package/dist/oas/nodes/propObj.js +5 -5
  58. package/dist/oas/nodes/propObj.js.map +1 -1
  59. package/dist/oas/nodes/propRef.js +8 -8
  60. package/dist/oas/nodes/propRef.js.map +1 -1
  61. package/dist/oas/nodes/propScalar.js +3 -3
  62. package/dist/oas/nodes/propScalar.js.map +1 -1
  63. package/dist/oas/nodes/ref.js +1 -1
  64. package/dist/oas/nodes/ref.js.map +1 -1
  65. package/dist/oas/nodes/res.js +1 -1
  66. package/dist/oas/nodes/res.js.map +1 -1
  67. package/dist/oas/nodes/scalar.js +4 -4
  68. package/dist/oas/nodes/scalar.js.map +1 -1
  69. package/dist/oas/nodes/union.js +16 -16
  70. package/dist/oas/nodes/union.js.map +1 -1
  71. package/dist/oas/oasGen.d.ts +0 -1
  72. package/dist/oas/oasGen.js +0 -8
  73. package/dist/oas/oasGen.js.map +1 -1
  74. package/dist/oas/utils/naming.js.map +1 -1
  75. package/dist/tests/runners.js +2 -2
  76. package/dist/tests/runners.js.map +1 -1
  77. package/dist/tsconfig.tsbuildinfo +1 -1
  78. package/package.json +1 -1
@@ -0,0 +1,106 @@
1
+ import _ from 'lodash';
2
+ import { Naming } from '../utils/naming.js';
3
+ export class OperationWriter {
4
+ gen;
5
+ constructor(gen) {
6
+ this.gen = gen;
7
+ }
8
+ writeQuery(context, writer, collected, selection) {
9
+ const selectionSet = new Set(selection.map((s) => s.split('>')[0]));
10
+ const paths = Array.from(collected.values()).filter((path) => selectionSet.has(path.id));
11
+ if (_.isEmpty(paths))
12
+ return;
13
+ writer.write('type Query {\n');
14
+ for (const path of paths) {
15
+ path.generate(context, writer, []);
16
+ this.writeConnector(context, writer, path, selection);
17
+ context.generatedSet.add(path.id);
18
+ }
19
+ writer.write('}\n\n');
20
+ }
21
+ writeMutations(context, writer, collected, selection) {
22
+ const selectionSet = new Set(selection.map((s) => s.split('>')[0]));
23
+ const paths = Array.from(collected.values()).filter((path) => selectionSet.has(path.id));
24
+ if (_.isEmpty(paths))
25
+ return;
26
+ writer.write('type Mutation {\n');
27
+ for (const path of paths) {
28
+ path.generate(context, writer, []);
29
+ this.writeConnector(context, writer, path, selection);
30
+ context.generatedSet.add(path.id);
31
+ }
32
+ writer.write('}\n\n');
33
+ }
34
+ writeConnector(context, writer, type, selection) {
35
+ const indent = 0;
36
+ const op = type; // assume type is GetOp
37
+ let spacing = ' '.repeat(indent + 4);
38
+ writer.write(spacing).write('@connect(\n');
39
+ spacing = ' '.repeat(indent + 6);
40
+ writer.write(spacing).write('source: "api"\n').write(spacing).write('http: ');
41
+ this.requestMethod(context, writer, op, selection);
42
+ writer.write('\n').write(spacing).write('selection: """\n');
43
+ if (_.has(op, 'resultType')) {
44
+ // scalar types don't need to be generated?
45
+ this.writeSelection(context, writer, _.get(op, 'resultType'), selection);
46
+ }
47
+ writer.write(spacing).write('"""\n');
48
+ spacing = ' '.repeat(indent + 4);
49
+ writer.write(spacing).write(')\n');
50
+ }
51
+ requestMethod(context, writer, op, selection) {
52
+ // replace every {elem} in the path for {$args.elem}
53
+ const verb = op.verb;
54
+ writer.write(`{ ${verb}: `).write('"' + op.operation.path.replace(/\{([a-zA-Z0-9]+)\}/g, '{$args.$1}'));
55
+ if (op.params.length > 0) {
56
+ const params = op.params.filter((p) => {
57
+ return p.required && p.parameter.in && p.parameter.in.toLowerCase() === 'query';
58
+ });
59
+ if (params.length > 0) {
60
+ writer.write('?' + params.map((p) => `${p.name}={$args.${Naming.genParamName(p.name)}}`).join('&'));
61
+ }
62
+ const headers = op.operation.getParameters().filter((p) => p.in && p.in.toLowerCase() === 'header');
63
+ writer.write('"\n');
64
+ if (headers.length > 0) {
65
+ let spacing = ' '.repeat(6);
66
+ writer.write(spacing + 'headers: [\n');
67
+ spacing = ' '.repeat(8);
68
+ for (const p of headers) {
69
+ let value = null;
70
+ if (p.example != null) {
71
+ value = p.example.toString();
72
+ }
73
+ if (p.examples && Object.keys(p.examples).length > 0) {
74
+ value = Object.keys(p.examples).join(',');
75
+ }
76
+ if (value == null) {
77
+ value = '<placeholder>';
78
+ }
79
+ writer.write(spacing + `{ name: "${p.name}", value: "${value}" }\n`);
80
+ }
81
+ spacing = ' '.repeat(6);
82
+ writer.write(spacing + ']');
83
+ }
84
+ }
85
+ else {
86
+ writer.write('"');
87
+ }
88
+ if (_.has(op, 'body')) {
89
+ const body = op.body;
90
+ this.writeBodySelection(context, writer, body, selection);
91
+ }
92
+ writer.write('}');
93
+ }
94
+ writeSelection(context, writer, type, selection) {
95
+ context.indent = 6;
96
+ type.select(context, writer, selection);
97
+ }
98
+ writeBodySelection(context, writer, body, selection) {
99
+ writer.write(',\n');
100
+ context.indent = 6;
101
+ if (body) {
102
+ body.select(context, writer, selection);
103
+ }
104
+ }
105
+ }
106
+ //# sourceMappingURL=operationWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operationWriter.js","sourceRoot":"","sources":["../../../src/oas/io/operationWriter.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C1C,CAAC;IACH,CAAC;CACF","sourcesContent":["import _ from 'lodash';\nimport { OasContext } from '../oasContext.js';\nimport { OasGen } from '../oasGen.js';\nimport { Body, IType, Op, Param, Type } from '../nodes/internal.js';\nimport { Naming } from '../utils/naming.js';\nimport { Writer } from './writer.js';\n\nexport class OperationWriter {\n constructor(private gen: OasGen) {}\n\n public writeQuery(context: OasContext, writer: Writer, collected: Map<string, IType>, selection: string[]): void {\n const selectionSet = new Set<string>(selection.map((s) => s.split('>')[0]));\n\n const paths = Array.from(collected.values()).filter((path) => selectionSet.has(path.id));\n if (_.isEmpty(paths)) return;\n\n writer.write('type Query {\\n');\n\n for (const path of paths) {\n path.generate(context, writer, []);\n this.writeConnector(context, writer, path, selection);\n context.generatedSet.add(path.id);\n }\n\n writer.write('}\\n\\n');\n }\n\n public writeMutations(context: OasContext, writer: Writer, collected: Map<string, IType>, selection: string[]): void {\n const selectionSet = new Set<string>(selection.map((s) => s.split('>')[0]));\n\n const paths = Array.from(collected.values()).filter((path) => selectionSet.has(path.id));\n if (_.isEmpty(paths)) return;\n\n writer.write('type Mutation {\\n');\n\n for (const path of paths) {\n path.generate(context, writer, []);\n this.writeConnector(context, writer, path, selection);\n context.generatedSet.add(path.id);\n }\n\n writer.write('}\\n\\n');\n }\n\n public writeConnector(context: OasContext, writer: Writer, type: IType, selection: string[]): void {\n const indent = 0;\n const op = type as unknown as Op; // assume type is GetOp\n let spacing = ' '.repeat(indent + 4);\n writer.write(spacing).write('@connect(\\n');\n\n spacing = ' '.repeat(indent + 6);\n writer.write(spacing).write('source: \"api\"\\n').write(spacing).write('http: ');\n\n this.requestMethod(context, writer, op, selection);\n\n writer.write('\\n').write(spacing).write('selection: \"\"\"\\n');\n\n if (_.has(op, 'resultType')) {\n // scalar types don't need to be generated?\n this.writeSelection(context, writer, _.get(op, 'resultType') as Type, selection);\n }\n\n writer.write(spacing).write('\"\"\"\\n');\n spacing = ' '.repeat(indent + 4);\n writer.write(spacing).write(')\\n');\n }\n\n private requestMethod(context: OasContext, writer: Writer, op: Op, selection: string[]): void {\n // replace every {elem} in the path for {$args.elem}\n const verb = op.verb;\n writer.write(`{ ${verb}: `).write('\"' + op.operation.path.replace(/\\{([a-zA-Z0-9]+)\\}/g, '{$args.$1}'));\n\n if (op.params.length > 0) {\n const params = op.params.filter((p: Param) => {\n return p.required && p.parameter.in && p.parameter.in.toLowerCase() === 'query';\n });\n\n if (params.length > 0) {\n writer.write('?' + params.map((p: Param) => `${p.name}={$args.${Naming.genParamName(p.name)}}`).join('&'));\n }\n const headers = op.operation.getParameters().filter((p) => p.in && p.in.toLowerCase() === 'header');\n\n writer.write('\"\\n');\n\n if (headers.length > 0) {\n let spacing = ' '.repeat(6);\n writer.write(spacing + 'headers: [\\n');\n spacing = ' '.repeat(8);\n\n for (const p of headers) {\n let value: string | null = null;\n\n if (p.example != null) {\n value = p.example.toString();\n }\n\n if (p.examples && Object.keys(p.examples).length > 0) {\n value = Object.keys(p.examples).join(',');\n }\n\n if (value == null) {\n value = '<placeholder>';\n }\n\n writer.write(spacing + `{ name: \"${p.name}\", value: \"${value}\" }\\n`);\n }\n\n spacing = ' '.repeat(6);\n writer.write(spacing + ']');\n }\n } else {\n writer.write('\"');\n }\n\n if (_.has(op, 'body')) {\n const body = op.body as Body;\n this.writeBodySelection(context, writer, body, selection);\n }\n\n writer.write('}');\n }\n\n private writeSelection(context: OasContext, writer: Writer, type: IType, selection: string[]): void {\n context.indent = 6;\n type.select(context, writer, selection);\n }\n\n private writeBodySelection(context: OasContext, writer: Writer, body: Body, selection: string[]): void {\n writer.write(',\\n');\n context.indent = 6;\n if (body) {\n body.select(context, writer, selection);\n }\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { OasGen } from '../oasGen.js';
2
+ import { IType } from '../nodes/internal.js';
3
+ export declare class PathCollector {
4
+ private gen;
5
+ constructor(gen: OasGen);
6
+ static findNonPropParent(type: IType): IType;
7
+ static progressiveSplits(input: string): string[];
8
+ collectPaths(path: string, collection: IType[]): IType[];
9
+ collectExpandedPaths(selection: string[]): string[];
10
+ traverseTree(current: IType, selection: string[], pending: Map<string, IType>): void;
11
+ }
@@ -0,0 +1,95 @@
1
+ import _ from 'lodash';
2
+ import { Composed, Prop, PropArray, Scalar, T } from '../nodes/internal.js';
3
+ export class PathCollector {
4
+ gen;
5
+ constructor(gen) {
6
+ this.gen = gen;
7
+ }
8
+ static findNonPropParent(type) {
9
+ let parent = type;
10
+ while (parent instanceof Prop) {
11
+ parent = parent.parent;
12
+ }
13
+ return parent;
14
+ }
15
+ static progressiveSplits(input) {
16
+ const parts = input.split('>');
17
+ const results = [];
18
+ for (let i = 1; i <= parts.length; i++) {
19
+ results.push(parts.slice(0, i).join('>'));
20
+ }
21
+ return results;
22
+ }
23
+ collectPaths(path, collection) {
24
+ const stack = [];
25
+ let current;
26
+ let last;
27
+ let i = 0;
28
+ const parts = path.split('>');
29
+ do {
30
+ const part = parts[i].replace(/#\/c\/s/g, '#/components/schemas');
31
+ current = collection.find((t) => t.id === part);
32
+ if (!current) {
33
+ throw new Error('Could not find type: ' + part + ' from ' + path + ', last: ' + last?.pathToRoot());
34
+ }
35
+ // make sure we expand it before we move on to the next part
36
+ this.gen.expand(current);
37
+ last = current;
38
+ collection = Array.from(current.children.values()) || Array.from(current.props.values()) || [];
39
+ stack.push(current);
40
+ i++;
41
+ } while (i < parts.length);
42
+ return stack;
43
+ }
44
+ collectExpandedPaths(selection) {
45
+ const newSelection = new Set();
46
+ const expands = selection.filter((p) => p.endsWith('>**'));
47
+ const filtered = expands.map((p) => p.replace('>**', ''));
48
+ const paths = Array.from(this.gen.paths.values());
49
+ const nodes = filtered.map((p) => this.collectPaths(p, paths));
50
+ nodes.forEach((stack) => {
51
+ const root = _.last(stack);
52
+ T.traverse(root, (child) => {
53
+ if (T.isPropScalar(child) || (child instanceof PropArray && child.items instanceof Scalar)) {
54
+ newSelection.add(child.path());
55
+ }
56
+ else {
57
+ this.gen.expand(child);
58
+ }
59
+ });
60
+ });
61
+ // finally remove the expanded paths from the selection
62
+ return [...newSelection, ...selection.filter((p) => !expands.includes(p))];
63
+ }
64
+ traverseTree(current, selection, pending) {
65
+ // we might be in a node far from the root, so we need to traverse upwards
66
+ // as well and add the props that we can find on the way
67
+ const source = current;
68
+ source
69
+ .ancestors()
70
+ .filter((t) => t instanceof Prop)
71
+ .map((p) => PathCollector.findNonPropParent(p))
72
+ .forEach((parent) => pending.set(parent.id, parent));
73
+ T.traverse(source, (child) => {
74
+ if (T.isLeaf(child)) {
75
+ // this is a weird take but if the child is an array of scalars
76
+ // then we want to avoid adding it twice
77
+ if (T.isLeaf(child.parent)) {
78
+ return;
79
+ }
80
+ selection.push(child.path());
81
+ const parentType = PathCollector.findNonPropParent(child);
82
+ if (!pending.has(parentType.id)) {
83
+ pending.set(parentType.id, parentType);
84
+ }
85
+ }
86
+ else {
87
+ this.gen.expand(child);
88
+ if (child instanceof Composed) {
89
+ child.consolidate(selection);
90
+ }
91
+ }
92
+ });
93
+ }
94
+ }
95
+ //# sourceMappingURL=pathCollector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathCollector.js","sourceRoot":"","sources":["../../../src/oas/io/pathCollector.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,EAAE,QAAQ,EAAS,IAAI,EAAE,SAAS,EAAE,MAAM,EAAQ,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAGzF,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAE5B,MAAM,CAAC,iBAAiB,CAAC,IAAW;QACzC,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,OAAO,MAAM,YAAY,IAAI,EAAE,CAAC;YAC9B,MAAM,GAAG,MAAM,CAAC,MAAO,CAAC;QAC1B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,iBAAiB,CAAC,KA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AChC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAEvB,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;oBAC9B,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import _ from 'lodash';\nimport { OasGen } from '../oasGen.js';\nimport { Composed, IType, Prop, PropArray, Scalar, Type, T } from '../nodes/internal.js';\nimport { Writer } from './writer.js';\n\nexport class PathCollector {\n constructor(private gen: OasGen) {}\n\n public static findNonPropParent(type: IType) {\n let parent = type;\n while (parent instanceof Prop) {\n parent = parent.parent!;\n }\n return parent;\n }\n\n public static progressiveSplits(input: string): string[] {\n const parts = input.split('>');\n const results: string[] = [];\n for (let i = 1; i <= parts.length; i++) {\n results.push(parts.slice(0, i).join('>'));\n }\n return results;\n }\n\n public collectPaths(path: string, collection: IType[]): IType[] {\n const stack: IType[] = [];\n let current: IType | undefined;\n let last: IType | undefined;\n\n let i = 0;\n const parts = path.split('>');\n do {\n const part = parts[i].replace(/#\\/c\\/s/g, '#/components/schemas');\n\n current = collection.find((t) => t.id === part);\n if (!current) {\n throw new Error('Could not find type: ' + part + ' from ' + path + ', last: ' + last?.pathToRoot());\n }\n\n // make sure we expand it before we move on to the next part\n this.gen.expand(current);\n last = current;\n\n collection = Array.from(current!.children.values()) || Array.from(current!.props.values()) || [];\n\n stack.push(current);\n i++;\n } while (i < parts.length);\n\n return stack;\n }\n\n public collectExpandedPaths(selection: string[]) {\n const newSelection = new Set<string>();\n const expands = selection.filter((p) => p.endsWith('>**'));\n const filtered = expands.map((p) => p.replace('>**', ''));\n\n const paths = Array.from(this.gen.paths.values());\n const nodes = filtered.map((p) => this.collectPaths(p, paths));\n\n nodes.forEach((stack) => {\n const root = _.last(stack)!;\n T.traverse(root, (child) => {\n if (T.isPropScalar(child) || (child instanceof PropArray && child.items instanceof Scalar)) {\n newSelection.add(child.path());\n } else {\n this.gen.expand(child);\n }\n });\n });\n\n // finally remove the expanded paths from the selection\n return [...newSelection, ...selection.filter((p) => !expands.includes(p))];\n }\n\n public traverseTree(current: IType, selection: string[], pending: Map<string, IType>) {\n // we might be in a node far from the root, so we need to traverse upwards\n // as well and add the props that we can find on the way\n const source = current as Type;\n\n source\n .ancestors()\n .filter((t) => t instanceof Prop)\n .map((p) => PathCollector.findNonPropParent(p))\n .forEach((parent) => pending.set(parent.id, parent));\n\n T.traverse(source, (child) => {\n if (T.isLeaf(child)) {\n // this is a weird take but if the child is an array of scalars\n // then we want to avoid adding it twice\n if (T.isLeaf(child.parent!)) {\n return;\n }\n selection.push(child.path());\n\n const parentType = PathCollector.findNonPropParent(child);\n if (!pending.has(parentType.id)) {\n pending.set(parentType.id, parentType);\n }\n } else {\n this.gen.expand(child);\n\n if (child instanceof Composed) {\n child.consolidate(selection);\n }\n }\n });\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { OasGen } from '../oasGen.js';
2
+ import { Writer } from './writer.js';
3
+ export declare class SchemaWriter {
4
+ private gen;
5
+ constructor(gen: OasGen);
6
+ writeJSONScalar(writer: Writer): void;
7
+ writeDirectives(writer: Writer): void;
8
+ private getServerUrl;
9
+ }
@@ -0,0 +1,36 @@
1
+ export class SchemaWriter {
2
+ gen;
3
+ constructor(gen) {
4
+ this.gen = gen;
5
+ }
6
+ writeJSONScalar(writer) {
7
+ writer.write('\nscalar JSON\n\n');
8
+ }
9
+ writeDirectives(writer) {
10
+ const api = this.gen.parser;
11
+ const host = this.getServerUrl(api.getDefinition().servers?.[0]);
12
+ writer
13
+ .write('extend schema\n')
14
+ .write(' @link(url: "https://specs.apollo.dev/federation/v2.10", import: ["@key"])\n')
15
+ .write(' @link(\n')
16
+ .write(' url: "https://specs.apollo.dev/connect/v0.1"\n')
17
+ .write(' import: ["@connect", "@source"]\n')
18
+ .write(' )\n')
19
+ .write(' @source(name: "api", http: { baseURL: "')
20
+ .write(host)
21
+ .write('" })\n\n');
22
+ }
23
+ getServerUrl(server) {
24
+ if (!server) {
25
+ return 'http://localhost:4010';
26
+ }
27
+ let url = server.url;
28
+ if (server.variables) {
29
+ for (const key in server.variables) {
30
+ url = url.replace('{' + key + '}', server.variables[key].default);
31
+ }
32
+ }
33
+ return url;
34
+ }
35
+ }
36
+ //# sourceMappingURL=schemaWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaWriter.js","sourceRoot":"","sources":["../../../src/oas/io/schemaWriter.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,YAAY;IACH;IAApB,YAAoB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAE5B,eAAe,CAAC,MAAc;QACnC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACpC,CAAC;IAEM,eAAe,CAAC,MAAc;QACnC,MAAM,GAAG,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,MAAM;aACH,KAAK,CAAC,iBAAiB,CAAC;aACxB,KAAK,CAAC,+EAA+E,CAAC;aACtF,KAAK,CAAC,YAAY,CAAC;aACnB,KAAK,CAAC,oDAAoD,CAAC;aAC3D,KAAK,CAAC,uCAAuC,CAAC;aAC9C,KAAK,CAAC,OAAO,CAAC;aACd,KAAK,CAAC,2CAA2C,CAAC;aAClD,KAAK,CAAC,IAAI,CAAC;aACX,KAAK,CAAC,UAAU,CAAC,CAAC;IACvB,CAAC;IAEO,YAAY,CAAC,MAAgC;QACnD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,uBAAuB,CAAC;QACjC,CAAC;QACD,IAAI,GAAG,GAAW,MAAM,CAAC,GAAG,CAAC;QAC7B,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACnC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["import Oas from 'oas';\nimport { ServerObject } from 'oas/types';\nimport { OasGen } from '../oasGen.js';\nimport { Writer } from './writer.js';\n\nexport class SchemaWriter {\n constructor(private gen: OasGen) {}\n\n public writeJSONScalar(writer: Writer): void {\n writer.write('\\nscalar JSON\\n\\n');\n }\n\n public writeDirectives(writer: Writer): void {\n const api: Oas = this.gen.parser;\n const host = this.getServerUrl(api.getDefinition().servers?.[0]);\n writer\n .write('extend schema\\n')\n .write(' @link(url: \"https://specs.apollo.dev/federation/v2.10\", import: [\"@key\"])\\n')\n .write(' @link(\\n')\n .write(' url: \"https://specs.apollo.dev/connect/v0.1\"\\n')\n .write(' import: [\"@connect\", \"@source\"]\\n')\n .write(' )\\n')\n .write(' @source(name: \"api\", http: { baseURL: \"')\n .write(host)\n .write('\" })\\n\\n');\n }\n\n private getServerUrl(server: ServerObject | undefined): string {\n if (!server) {\n return 'http://localhost:4010';\n }\n let url: string = server.url;\n if (server.variables) {\n for (const key in server.variables) {\n url = url.replace('{' + key + '}', server.variables[key].default);\n }\n }\n return url;\n }\n}\n"]}
@@ -1,26 +1,14 @@
1
1
  import { OasGen } from '../oasGen.js';
2
2
  import { IType } from '../nodes/internal.js';
3
3
  export declare class Writer {
4
- generator: OasGen;
5
- static findNonPropParent(type: IType): IType;
6
- static progressiveSplits(input: string): string[];
4
+ gen: OasGen;
5
+ private pathCollector;
6
+ private schemaWriter;
7
+ private operationWriter;
7
8
  buffer: string[];
8
- constructor(generator: OasGen);
9
+ constructor(gen: OasGen);
9
10
  write(input: string): Writer;
10
- append(input: string): Writer;
11
11
  flush(): string;
12
12
  writeSchema(writer: Writer, types: Map<string, IType>, selection: string[]): void;
13
13
  generate(selection: string[]): string[];
14
- collectPaths(path: string, collection: IType[]): IType[];
15
- private writeJSONScalar;
16
- private writeQuery;
17
- private writeConnector;
18
- private requestMethod;
19
- private writeSelection;
20
- private writeDirectives;
21
- private getServerUrl;
22
- private traverseTree;
23
- private collectExpandedPaths;
24
- private writeMutations;
25
- private writeBodySelection;
26
14
  }