apollo-conn-gen 0.3.3 → 0.4.1

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 (85) 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/io/writer.js +3 -3
  8. package/dist/json/io/writer.js.map +1 -1
  9. package/dist/json/walker/jsonContext.d.ts +4 -0
  10. package/dist/json/walker/jsonContext.js +10 -0
  11. package/dist/json/walker/jsonContext.js.map +1 -1
  12. package/dist/json/walker/jsonGen.js +1 -31
  13. package/dist/json/walker/jsonGen.js.map +1 -1
  14. package/dist/json/walker/naming.d.ts +2 -4
  15. package/dist/json/walker/naming.js +14 -9
  16. package/dist/json/walker/naming.js.map +1 -1
  17. package/dist/json/walker/types/jsonArray.js +4 -9
  18. package/dist/json/walker/types/jsonArray.js.map +1 -1
  19. package/dist/json/walker/types/jsonObj.d.ts +3 -4
  20. package/dist/json/walker/types/jsonObj.js +7 -12
  21. package/dist/json/walker/types/jsonObj.js.map +1 -1
  22. package/dist/json/walker/types/jsonScalar.d.ts +3 -4
  23. package/dist/json/walker/types/jsonScalar.js +19 -9
  24. package/dist/json/walker/types/jsonScalar.js.map +1 -1
  25. package/dist/json/walker/types/jsonType.d.ts +3 -5
  26. package/dist/json/walker/types/jsonType.js +4 -6
  27. package/dist/json/walker/types/jsonType.js.map +1 -1
  28. package/dist/oas/io/operationWriter.d.ts +14 -0
  29. package/dist/oas/io/operationWriter.js +106 -0
  30. package/dist/oas/io/operationWriter.js.map +1 -0
  31. package/dist/oas/io/pathCollector.d.ts +11 -0
  32. package/dist/oas/io/pathCollector.js +95 -0
  33. package/dist/oas/io/pathCollector.js.map +1 -0
  34. package/dist/oas/io/schemaWriter.d.ts +9 -0
  35. package/dist/oas/io/schemaWriter.js +36 -0
  36. package/dist/oas/io/schemaWriter.js.map +1 -0
  37. package/dist/oas/io/writer.d.ts +5 -17
  38. package/dist/oas/io/writer.js +24 -243
  39. package/dist/oas/io/writer.js.map +1 -1
  40. package/dist/oas/nodes/arr.js +2 -2
  41. package/dist/oas/nodes/arr.js.map +1 -1
  42. package/dist/oas/nodes/body.js +2 -2
  43. package/dist/oas/nodes/body.js.map +1 -1
  44. package/dist/oas/nodes/circularRef.js +2 -2
  45. package/dist/oas/nodes/circularRef.js.map +1 -1
  46. package/dist/oas/nodes/comp.js +4 -16
  47. package/dist/oas/nodes/comp.js.map +1 -1
  48. package/dist/oas/nodes/get.js +11 -11
  49. package/dist/oas/nodes/get.js.map +1 -1
  50. package/dist/oas/nodes/obj.js +6 -6
  51. package/dist/oas/nodes/obj.js.map +1 -1
  52. package/dist/oas/nodes/post.js +10 -14
  53. package/dist/oas/nodes/post.js.map +1 -1
  54. package/dist/oas/nodes/prop.js +6 -6
  55. package/dist/oas/nodes/prop.js.map +1 -1
  56. package/dist/oas/nodes/propArray.js +6 -6
  57. package/dist/oas/nodes/propArray.js.map +1 -1
  58. package/dist/oas/nodes/propCircRef.js +3 -3
  59. package/dist/oas/nodes/propCircRef.js.map +1 -1
  60. package/dist/oas/nodes/propComp.js +5 -5
  61. package/dist/oas/nodes/propComp.js.map +1 -1
  62. package/dist/oas/nodes/propEn.js +3 -3
  63. package/dist/oas/nodes/propEn.js.map +1 -1
  64. package/dist/oas/nodes/propObj.js +5 -5
  65. package/dist/oas/nodes/propObj.js.map +1 -1
  66. package/dist/oas/nodes/propRef.js +8 -8
  67. package/dist/oas/nodes/propRef.js.map +1 -1
  68. package/dist/oas/nodes/propScalar.js +3 -3
  69. package/dist/oas/nodes/propScalar.js.map +1 -1
  70. package/dist/oas/nodes/ref.js +1 -1
  71. package/dist/oas/nodes/ref.js.map +1 -1
  72. package/dist/oas/nodes/res.js +1 -1
  73. package/dist/oas/nodes/res.js.map +1 -1
  74. package/dist/oas/nodes/scalar.js +4 -4
  75. package/dist/oas/nodes/scalar.js.map +1 -1
  76. package/dist/oas/nodes/union.js +16 -16
  77. package/dist/oas/nodes/union.js.map +1 -1
  78. package/dist/oas/oasGen.d.ts +0 -1
  79. package/dist/oas/oasGen.js +0 -8
  80. package/dist/oas/oasGen.js.map +1 -1
  81. package/dist/oas/utils/naming.js.map +1 -1
  82. package/dist/tests/runners.js +2 -2
  83. package/dist/tests/runners.js.map +1 -1
  84. package/dist/tsconfig.tsbuildinfo +1 -1
  85. package/package.json +1 -1
@@ -1,12 +1,11 @@
1
- import { JsonContext } from '../jsonContext.js';
2
- import { JsonType } from './jsonType.js';
1
+ import { JsonType, Context } from './jsonType.js';
3
2
  import { IWriter } from '../../io/writer.js';
4
3
  export declare class JsonScalar extends JsonType {
5
4
  private readonly type;
6
5
  constructor(name: string, parent: JsonType | null, type: string);
7
6
  getType(): string;
8
- write(context: JsonContext, writer: IWriter): void;
9
- select(context: JsonContext, writer: IWriter): void;
7
+ write(context: Context, writer: IWriter): void;
8
+ select(context: Context, writer: IWriter): void;
10
9
  toString(): string;
11
10
  id(): string;
12
11
  }
@@ -1,6 +1,6 @@
1
+ import { JsonType } from './jsonType.js';
1
2
  import { trace } from '../log/trace.js';
2
3
  import { sanitiseField, sanitiseFieldForSelect } from '../naming.js';
3
- import { JsonType } from './jsonType.js';
4
4
  export class JsonScalar extends JsonType {
5
5
  type;
6
6
  constructor(name, parent, type) {
@@ -11,21 +11,31 @@ export class JsonScalar extends JsonType {
11
11
  return this.type;
12
12
  }
13
13
  write(context, writer) {
14
- trace(context, '[scalar:write]', '-> in: ' + this.getName());
15
- writer.write(this.indent(context));
16
- const field = sanitiseField(this.getName());
14
+ const name = this.getName();
15
+ const isProtectedName = this.protectedName;
16
+ trace(context, '[scalar:write]', '-> in: ' + name);
17
+ writer.write(context.getIndent());
18
+ const field = isProtectedName ? '_value' : sanitiseField(name);
17
19
  writer.write(field);
18
20
  writer.write(': ');
19
21
  writer.write(this.getType());
22
+ // add a comment that you cannot use that name
23
+ if (isProtectedName)
24
+ writer.write(` # '${name}' cannot be used as a field name, it's been replaced by '_value'`);
20
25
  writer.write('\n');
21
- trace(context, '[scalar:write]', '<- out: ' + this.getName());
26
+ trace(context, '[scalar:write]', '<- out: ' + name);
22
27
  }
23
28
  select(context, writer) {
24
29
  trace(context, '[scalar:select]', '-> in: ' + this.getName());
25
- const originalName = this.getName();
26
- const fieldName = sanitiseFieldForSelect(originalName);
27
- writer.write(this.indent(context));
28
- writer.write(fieldName);
30
+ writer.write(context.getIndent());
31
+ if (!this.protectedName) {
32
+ const originalName = this.getName();
33
+ const fieldName = sanitiseFieldForSelect(originalName);
34
+ writer.write(fieldName);
35
+ }
36
+ else {
37
+ writer.write(`_value: ${this.getName()}`);
38
+ }
29
39
  writer.write('\n');
30
40
  trace(context, '[scalar:select]', '<- out: ' + this.getName());
31
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jsonScalar.js","sourceRoot":"","sources":["../../../../src/json/walker/types/jsonScalar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,OAAO,UAAW,SAAQ,QAAQ;IACrB,IAAI,CAAS;IAE9B,YAAY,IAAY,EAAE,MAAuB,EAAE,IAAY;QAC7D,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,OAAoB,EAAE,MAAe;QAChD,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,MAA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'../log/trace.js';\nimport { sanitiseField, sanitiseFieldForSelect } from '../naming.js';\nimport { JsonType } from './jsonType.js';\nimport { IWriter } from '../../io/writer.js';\n\nexport class JsonScalar extends JsonType {\n private readonly type: string;\n\n constructor(name: string, parent: JsonType | null, type: string) {\n super(name, parent);\n this.type = type;\n }\n\n public getType(): string {\n return this.type;\n }\n\n public write(context: JsonContext, writer: IWriter): void {\n trace(context, '[scalar:write]', '-> in: ' + this.getName());\n writer.write(this.indent(context));\n\n const field = sanitiseField(this.getName());\n writer.write(field);\n\n writer.write(': ');\n writer.write(this.getType());\n writer.write('\\n');\n trace(context, '[scalar:write]', '<- out: ' + this.getName());\n }\n\n public select(context: JsonContext, writer: IWriter): void {\n trace(context, '[scalar:select]', '-> in: ' + this.getName());\n\n const originalName = this.getName();\n const fieldName = sanitiseFieldForSelect(originalName);\n\n writer.write(this.indent(context));\n writer.write(fieldName);\n writer.write('\\n');\n\n trace(context, '[scalar:select]', '<- out: ' + this.getName());\n }\n\n public toString(): string {\n return this.id() + '{' + this.getType() + '}';\n }\n\n public id(): string {\n return 'scalar:#' + super.id();\n }\n\n // public equals(o: any): boolean {\n // if (this === o) return true;\n // if (!(o instanceof Scalar)) return false;\n // const nameIsEqual = this.getName() === o.getName();\n // const typeIsEqual = this.type === o.type;\n // return nameIsEqual && typeIsEqual;\n // }\n\n // public hashCode(): number {\n // let hash = 0;\n // const str = this.type;\n // for (let i = 0; i < str.length; i++) {\n // hash = (Math.imul(31, hash) + str.charCodeAt(i)) | 0;\n // }\n // return hash;\n // }\n}\n"]}
1
+ {"version":3,"file":"jsonScalar.js","sourceRoot":"","sources":["../../../../src/json/walker/types/jsonScalar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAW,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,OAAO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QAElC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,SAAS,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;YACvD,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEnB,KAAK,CAAC,OAAO,EAAE,iBAAiB,EAAE,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,EAAE,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC;IAChD,CAAC;IAEM,EAAE;QACP,OAAO,UAAU,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { JsonType, Context } from './jsonType.js';\nimport { IWriter } from '../../io/writer.js';\nimport { trace } from '../log/trace.js';\nimport { sanitiseField, sanitiseFieldForSelect } from '../naming.js';\n\nexport class JsonScalar extends JsonType {\n private readonly type: string;\n\n constructor(name: string, parent: JsonType | null, type: string) {\n super(name, parent);\n this.type = type;\n }\n\n public getType(): string {\n return this.type;\n }\n\n public write(context: Context, writer: IWriter): void {\n const name = this.getName();\n const isProtectedName = this.protectedName;\n\n trace(context, '[scalar:write]', '-> in: ' + name);\n writer.write(context.getIndent());\n\n const field = isProtectedName ? '_value' : sanitiseField(name);\n writer.write(field);\n\n writer.write(': ');\n writer.write(this.getType());\n\n // add a comment that you cannot use that name\n if (isProtectedName) writer.write(` # '${name}' cannot be used as a field name, it's been replaced by '_value'`);\n\n writer.write('\\n');\n trace(context, '[scalar:write]', '<- out: ' + name);\n }\n\n public select(context: Context, writer: IWriter): void {\n trace(context, '[scalar:select]', '-> in: ' + this.getName());\n\n writer.write(context.getIndent());\n\n if (!this.protectedName) {\n const originalName = this.getName();\n const fieldName = sanitiseFieldForSelect(originalName);\n writer.write(fieldName);\n } else {\n writer.write(`_value: ${this.getName()}`);\n }\n\n writer.write('\\n');\n\n trace(context, '[scalar:select]', '<- out: ' + this.getName());\n }\n\n public toString(): string {\n return this.id() + '{' + this.getType() + '}';\n }\n\n public id(): string {\n return 'scalar:#' + super.id();\n }\n}\n"]}
@@ -1,16 +1,14 @@
1
1
  import { IWriter } from '../../io/index.js';
2
- export interface Context {
3
- getStack(): any[];
4
- }
2
+ import { JsonContext } from '../jsonContext.js';
3
+ export type Context = JsonContext;
5
4
  export declare abstract class JsonType {
6
5
  private readonly name;
7
6
  private readonly parent;
7
+ protected readonly protectedName: boolean;
8
8
  constructor(name: string, parent: JsonType | null);
9
9
  getName(): string;
10
10
  getParent(): JsonType | null;
11
11
  abstract write(context: Context, writer: IWriter): void;
12
- protected indent(context: Context): string;
13
- protected indentWithSubstract(context: Context, subtract: number): string;
14
12
  abstract select(context: Context, writer: IWriter): void;
15
13
  id(): string;
16
14
  }
@@ -1,9 +1,13 @@
1
+ import { isProtected } from '../naming.js';
1
2
  export class JsonType {
2
3
  name;
3
4
  parent;
5
+ // if the name is a protected name and should be escaped
6
+ protectedName;
4
7
  constructor(name, parent) {
5
8
  this.name = name;
6
9
  this.parent = parent;
10
+ this.protectedName = isProtected(name);
7
11
  }
8
12
  getName() {
9
13
  return this.name;
@@ -11,12 +15,6 @@ export class JsonType {
11
15
  getParent() {
12
16
  return this.parent;
13
17
  }
14
- indent(context) {
15
- return ' '.repeat(context.getStack().length);
16
- }
17
- indentWithSubstract(context, subtract) {
18
- return ' '.repeat(context.getStack().length - subtract);
19
- }
20
18
  id() {
21
19
  let paths = '';
22
20
  // eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -1 +1 @@
1
- {"version":3,"file":"jsonType.js","sourceRoot":"","sources":["../../../../src/json/walker/types/jsonType.ts"],"names":[],"mappings":"AAOA,MAAM,OAAgB,QAAQ;IACX,IAAI,CAAS;IACb,MAAM,CAAkB;IAEzC,YAAY,IAAY,EAAE,MAAuB;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAIS,MAAM,CAAC,OAAgB;QAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAES,mBAAmB,CAAC,OAAgB,EAAE,QAAgB;QAC9D,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAIM,EAAE;QACP,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,4DAA4D;QAC5D,IAAI,MAAM,GAAoB,IAAI,CAAC;QACnC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9C,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC;QACzC,CAAC;QACD,OAAO,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;CAgBF","sourcesContent":["import { IWriter } from '../../io/index.js';\n\nexport interface Context {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getStack(): any[];\n}\n\nexport abstract class JsonType {\n private readonly name: string;\n private readonly parent: JsonType | null;\n\n constructor(name: string, parent: JsonType | null) {\n this.name = name;\n this.parent = parent;\n }\n\n public getName(): string {\n return this.name;\n }\n\n public getParent(): JsonType | null {\n return this.parent;\n }\n\n public abstract write(context: Context, writer: IWriter): void;\n\n protected indent(context: Context): string {\n return ' '.repeat(context.getStack().length);\n }\n\n protected indentWithSubstract(context: Context, subtract: number): string {\n return ' '.repeat(context.getStack().length - subtract);\n }\n\n public abstract select(context: Context, writer: IWriter): void;\n\n public id(): string {\n let paths = '';\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: JsonType | null = this;\n while ((parent = parent.getParent()) !== null) {\n paths = `/${parent.getName()}` + paths;\n }\n return paths + '/' + this.getName();\n }\n\n // public equals(o: any): boolean {\n // if (this === o) return true;\n // if (!(o instanceof Type)) return false;\n // return this.id() === o.id();\n // }\n\n // public hashCode(): number {\n // let hash = 0;\n // const id = this.id();\n // for (let i = 0; i < id.length; i++) {\n // hash = (Math.imul(31, hash) + id.charCodeAt(i)) | 0;\n // }\n // return hash;\n // }\n}\n"]}
1
+ {"version":3,"file":"jsonType.js","sourceRoot":"","sources":["../../../../src/json/walker/types/jsonType.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3C,MAAM,OAAgB,QAAQ;IACX,IAAI,CAAS;IACb,MAAM,CAAkB;IAEzC,wDAAwD;IACrC,aAAa,CAAU;IAE1C,YAAY,IAAY,EAAE,MAAuB;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAMM,EAAE;QACP,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,4DAA4D;QAC5D,IAAI,MAAM,GAAoB,IAAI,CAAC;QACnC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9C,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC;QACzC,CAAC;QACD,OAAO,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;CACF","sourcesContent":["import { IWriter } from '../../io/index.js';\nimport { isProtected } from '../naming.js';\nimport { JsonContext } from '../jsonContext.js';\n\nexport type Context = JsonContext;\n\nexport abstract class JsonType {\n private readonly name: string;\n private readonly parent: JsonType | null;\n\n // if the name is a protected name and should be escaped\n protected readonly protectedName: boolean;\n\n constructor(name: string, parent: JsonType | null) {\n this.name = name;\n this.parent = parent;\n this.protectedName = isProtected(name);\n }\n\n public getName(): string {\n return this.name;\n }\n\n public getParent(): JsonType | null {\n return this.parent;\n }\n\n public abstract write(context: Context, writer: IWriter): void;\n\n public abstract select(context: Context, writer: IWriter): void;\n\n public id(): string {\n let paths = '';\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: JsonType | null = this;\n while ((parent = parent.getParent()) !== null) {\n paths = `/${parent.getName()}` + paths;\n }\n return paths + '/' + this.getName();\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { OasContext } from '../oasContext.js';
2
+ import { OasGen } from '../oasGen.js';
3
+ import { IType } from '../nodes/internal.js';
4
+ import { Writer } from './writer.js';
5
+ export declare class OperationWriter {
6
+ private gen;
7
+ constructor(gen: OasGen);
8
+ writeQuery(context: OasContext, writer: Writer, collected: Map<string, IType>, selection: string[]): void;
9
+ writeMutations(context: OasContext, writer: Writer, collected: Map<string, IType>, selection: string[]): void;
10
+ writeConnector(context: OasContext, writer: Writer, type: IType, selection: string[]): void;
11
+ private requestMethod;
12
+ private writeSelection;
13
+ private writeBodySelection;
14
+ }
@@ -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.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAIvB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAE5B,UAAU,CAAC,OAAmB,E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C,CAAC,IAAI,cAAc,KAAK,OAAO,CAAC,CAAC;gBACvE,CAAC;gBAED,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACxB,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,GAAG,EAAE,CAAC,IAAY,CAAC;YAC7B,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAEO,cAAc,CAAC,OAAmB,EAAE,MAAc,EAAE,IAAW,EAAE,SAAmB;QAC1F,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;IAEO,kBAAkB,CAAC,OAAmB,EAAE,MAAc,EAAE,IAAU,EAAE,SAAmB;QAC7F,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACnB,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC1C,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,KAAa;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,OAAO,CAA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,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
  }