@dxos/protobuf-compiler 2.15.1 → 2.15.2

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 (103) hide show
  1. package/dist/src/configure.d.ts +5 -0
  2. package/dist/src/configure.d.ts.map +1 -0
  3. package/dist/src/configure.js +19 -0
  4. package/dist/src/configure.js.map +1 -0
  5. package/dist/src/generator/declaration-generator.d.ts +0 -1
  6. package/dist/src/generator/declaration-generator.d.ts.map +1 -1
  7. package/dist/src/generator/declaration-generator.js +7 -70
  8. package/dist/src/generator/declaration-generator.js.map +1 -1
  9. package/dist/src/generator/doc-comment.d.ts +3 -0
  10. package/dist/src/generator/doc-comment.d.ts.map +1 -0
  11. package/dist/src/generator/doc-comment.js +15 -0
  12. package/dist/src/generator/doc-comment.js.map +1 -0
  13. package/dist/src/generator/enum.d.ts +4 -0
  14. package/dist/src/generator/enum.d.ts.map +1 -0
  15. package/dist/src/generator/enum.js +32 -0
  16. package/dist/src/generator/enum.js.map +1 -0
  17. package/dist/src/generator/field.d.ts +6 -0
  18. package/dist/src/generator/field.d.ts.map +1 -0
  19. package/dist/src/generator/field.js +56 -0
  20. package/dist/src/generator/field.js.map +1 -0
  21. package/dist/src/generator/file-generator.d.ts +8 -0
  22. package/dist/src/generator/file-generator.d.ts.map +1 -0
  23. package/dist/src/generator/file-generator.js +79 -0
  24. package/dist/src/generator/file-generator.js.map +1 -0
  25. package/dist/src/generator/message.d.ts +5 -0
  26. package/dist/src/generator/message.d.ts.map +1 -0
  27. package/dist/src/generator/message.js +44 -0
  28. package/dist/src/generator/message.js.map +1 -0
  29. package/dist/src/generator/service.d.ts +6 -0
  30. package/dist/src/generator/service.d.ts.map +1 -0
  31. package/dist/src/generator/service.js +77 -0
  32. package/dist/src/generator/service.js.map +1 -0
  33. package/dist/src/namespaces.test.js +4 -1
  34. package/dist/src/namespaces.test.js.map +1 -1
  35. package/dist/src/parser/resolver.js +3 -3
  36. package/dist/src/parser/resolver.js.map +1 -1
  37. package/dist/src/type-generator.d.ts.map +1 -1
  38. package/dist/src/type-generator.js +6 -49
  39. package/dist/src/type-generator.js.map +1 -1
  40. package/dist/test/{gen → proto/gen}/dxos/test/another.d.ts +0 -0
  41. package/dist/test/proto/gen/dxos/test/another.d.ts.map +1 -0
  42. package/dist/test/{gen → proto/gen}/dxos/test/another.js +0 -0
  43. package/dist/test/proto/gen/dxos/test/another.js.map +1 -0
  44. package/dist/test/{gen → proto/gen}/dxos/test/any.d.ts +0 -0
  45. package/dist/test/proto/gen/dxos/test/any.d.ts.map +1 -0
  46. package/dist/test/{gen → proto/gen}/dxos/test/any.js +0 -0
  47. package/dist/test/proto/gen/dxos/test/any.js.map +1 -0
  48. package/dist/test/proto/gen/dxos/test/extensions.d.ts +4 -0
  49. package/dist/test/proto/gen/dxos/test/extensions.d.ts.map +1 -0
  50. package/dist/test/proto/gen/dxos/test/extensions.js +3 -0
  51. package/dist/test/proto/gen/dxos/test/extensions.js.map +1 -0
  52. package/dist/test/{gen → proto/gen}/dxos/test/testfoo.d.ts +0 -0
  53. package/dist/test/proto/gen/dxos/test/testfoo.d.ts.map +1 -0
  54. package/dist/test/{gen → proto/gen}/dxos/test/testfoo.js +0 -0
  55. package/dist/test/proto/gen/dxos/test/testfoo.js.map +1 -0
  56. package/dist/test/{gen → proto/gen}/dxos/test.d.ts +23 -0
  57. package/dist/test/proto/gen/dxos/test.d.ts.map +1 -0
  58. package/dist/test/{gen → proto/gen}/dxos/test.js +0 -0
  59. package/dist/test/proto/gen/dxos/test.js.map +1 -0
  60. package/dist/test/{gen → proto/gen}/google/protobuf.d.ts +0 -0
  61. package/dist/test/proto/gen/google/protobuf.d.ts.map +1 -0
  62. package/dist/test/{gen → proto/gen}/google/protobuf.js +0 -0
  63. package/dist/test/proto/gen/google/protobuf.js.map +1 -0
  64. package/dist/test/{gen → proto/gen}/index.d.ts +2 -0
  65. package/dist/test/proto/gen/index.d.ts.map +1 -0
  66. package/dist/test/proto/gen/index.js +11 -0
  67. package/dist/test/proto/gen/index.js.map +1 -0
  68. package/dist/test/{substitutions.d.ts → proto/substitutions.d.ts} +2 -2
  69. package/dist/test/proto/substitutions.d.ts.map +1 -0
  70. package/dist/test/{substitutions.js → proto/substitutions.js} +1 -1
  71. package/dist/test/proto/substitutions.js.map +1 -0
  72. package/dist/test/schema.test.js +3 -3
  73. package/dist/test/schema.test.js.map +1 -1
  74. package/dist/test/service.test.js +2 -2
  75. package/dist/test/service.test.js.map +1 -1
  76. package/dist/tsconfig.tsbuildinfo +1 -1
  77. package/package.json +4 -4
  78. package/src/configure.ts +13 -0
  79. package/src/generator/declaration-generator.ts +4 -128
  80. package/src/generator/doc-comment.ts +14 -0
  81. package/src/generator/enum.ts +20 -0
  82. package/src/generator/field.ts +31 -0
  83. package/src/generator/file-generator.ts +102 -0
  84. package/src/generator/message.ts +42 -0
  85. package/src/generator/service.ts +99 -0
  86. package/src/namespaces.test.ts +4 -1
  87. package/src/parser/resolver.ts +3 -3
  88. package/src/type-generator.ts +6 -93
  89. package/dist/test/gen/dxos/test/another.d.ts.map +0 -1
  90. package/dist/test/gen/dxos/test/another.js.map +0 -1
  91. package/dist/test/gen/dxos/test/any.d.ts.map +0 -1
  92. package/dist/test/gen/dxos/test/any.js.map +0 -1
  93. package/dist/test/gen/dxos/test/testfoo.d.ts.map +0 -1
  94. package/dist/test/gen/dxos/test/testfoo.js.map +0 -1
  95. package/dist/test/gen/dxos/test.d.ts.map +0 -1
  96. package/dist/test/gen/dxos/test.js.map +0 -1
  97. package/dist/test/gen/google/protobuf.d.ts.map +0 -1
  98. package/dist/test/gen/google/protobuf.js.map +0 -1
  99. package/dist/test/gen/index.d.ts.map +0 -1
  100. package/dist/test/gen/index.js +0 -11
  101. package/dist/test/gen/index.js.map +0 -1
  102. package/dist/test/substitutions.d.ts.map +0 -1
  103. package/dist/test/substitutions.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Manually adds descriptor proto to the list of common protobuf definitions.
3
+ */
4
+ export declare function preconfigureProtobufjs(): void;
5
+ //# sourceMappingURL=configure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../src/configure.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,sBAAsB,SAGrC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2021 DXOS.org
4
+ //
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.preconfigureProtobufjs = void 0;
10
+ const protobufjs_1 = __importDefault(require("protobufjs"));
11
+ /**
12
+ * Manually adds descriptor proto to the list of common protobuf definitions.
13
+ */
14
+ function preconfigureProtobufjs() {
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ protobufjs_1.default.common('descriptor', require('protobufjs/google/protobuf/descriptor.json'));
17
+ }
18
+ exports.preconfigureProtobufjs = preconfigureProtobufjs;
19
+ //# sourceMappingURL=configure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/configure.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;AAEF,4DAA4B;AAE5B;;GAEG;AACH,SAAgB,sBAAsB;IACpC,8DAA8D;IAC9D,oBAAE,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,4CAA4C,CAAC,CAAC,CAAC;AACjF,CAAC;AAHD,wDAGC"}
@@ -3,5 +3,4 @@ import * as ts from 'typescript';
3
3
  import { SubstitutionsMap } from '../parser';
4
4
  export declare function createDeclarations(types: protobufjs.ReflectionObject[], subs: SubstitutionsMap): Generator<ts.Statement>;
5
5
  export declare function createTypeDictionary(root: protobufjs.NamespaceBase): ts.InterfaceDeclaration;
6
- export declare function createServicesDictionary(root: protobufjs.NamespaceBase): ts.InterfaceDeclaration;
7
6
  //# sourceMappingURL=declaration-generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"declaration-generator.d.ts","sourceRoot":"","sources":["../../../src/generator/declaration-generator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAsG7C,wBAAkB,kBAAkB,CAAE,KAAK,EAAE,UAAU,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,gBAAgB,GAAG,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAuB3H;AAeD,wBAAgB,oBAAoB,CAAE,IAAI,EAAE,UAAU,CAAC,aAAa,2BAgBnE;AAaD,wBAAgB,wBAAwB,CAAE,IAAI,EAAE,UAAU,CAAC,aAAa,2BAgBvE"}
1
+ {"version":3,"file":"declaration-generator.d.ts","sourceRoot":"","sources":["../../../src/generator/declaration-generator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAQ7C,wBAAkB,kBAAkB,CAAE,KAAK,EAAE,UAAU,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,gBAAgB,GAAG,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAuB3H;AAeD,wBAAgB,oBAAoB,CAAE,IAAI,EAAE,UAAU,CAAC,aAAa,2BAgBnE"}
@@ -21,72 +21,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
21
21
  __setModuleDefault(result, mod);
22
22
  return result;
23
23
  };
24
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
24
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.createServicesDictionary = exports.createTypeDictionary = exports.createDeclarations = void 0;
29
- const assert_1 = __importDefault(require("assert"));
25
+ exports.createTypeDictionary = exports.createDeclarations = void 0;
30
26
  const protobufjs = __importStar(require("protobufjs"));
31
27
  const ts = __importStar(require("typescript"));
32
28
  const namespaces_1 = require("../namespaces");
29
+ const enum_1 = require("./enum");
30
+ const message_1 = require("./message");
31
+ const service_1 = require("./service");
33
32
  const types_1 = require("./types");
34
33
  const f = ts.factory;
35
- function getFieldType(field, subs) {
36
- if (field.repeated) {
37
- return f.createArrayTypeNode(getScalarFieldType(field, subs));
38
- }
39
- else if (field.map && field instanceof protobufjs.MapField) {
40
- return f.createTypeReferenceNode('Partial', [f.createTypeReferenceNode('Record', [
41
- f.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
42
- getScalarFieldType(field, subs)
43
- ])]);
44
- }
45
- else {
46
- return getScalarFieldType(field, subs);
47
- }
48
- }
49
- function getScalarFieldType(field, subs) {
50
- var _a;
51
- assert_1.default(field.message);
52
- field.resolve();
53
- return types_1.types((_a = field.resolvedType) !== null && _a !== void 0 ? _a : field.type, field.message, subs);
54
- }
55
- function getRpcTypes(method, service, subs) {
56
- var _a, _b;
57
- method.resolve();
58
- return [
59
- types_1.types((_a = method.resolvedRequestType) !== null && _a !== void 0 ? _a : method.requestType, service, subs),
60
- types_1.types((_b = method.resolvedResponseType) !== null && _b !== void 0 ? _b : method.responseType, service, subs)
61
- ];
62
- }
63
- function createMessageDeclaration(type, subs) {
64
- return f.createInterfaceDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], type.name, undefined, undefined, type.fieldsArray.map(field => f.createPropertySignature(undefined, field.name.includes('.') ? f.createStringLiteral(field.name) : field.name, field.required ? undefined : f.createToken(ts.SyntaxKind.QuestionToken), getFieldType(field, subs))));
65
- }
66
- function createEnumDeclaration(type) {
67
- return f.createEnumDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], type.name, Object.entries(type.values).map(([name, id]) => f.createEnumMember(name, f.createNumericLiteral(id))));
68
- }
69
- function createRpcMethodType(method, service, subs) {
70
- assert_1.default(!method.requestStream, 'Streaming RPC requests are not supported.');
71
- const [requestType, responseType] = getRpcTypes(method, service, subs);
72
- const outputTypeMonad = method.responseStream ? f.createIdentifier('Stream') : f.createIdentifier('Promise');
73
- return f.createFunctionTypeNode(undefined, [f.createParameterDeclaration(undefined, undefined, undefined, 'request', undefined, requestType)], f.createTypeReferenceNode(outputTypeMonad, [responseType]));
74
- }
75
- function createServiceDeclaration(type, subs) {
76
- return f.createInterfaceDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], type.name, undefined, undefined, type.methodsArray
77
- .filter(m => !m.requestStream)
78
- .map(method => f.createPropertySignature(undefined, method.name, undefined, createRpcMethodType(method, type, subs))));
79
- }
80
34
  function* createDeclarations(types, subs) {
81
35
  for (const obj of types) {
82
36
  if (obj instanceof protobufjs.Enum) {
83
- yield createEnumDeclaration(obj);
37
+ yield enum_1.createEnumDeclaration(obj);
84
38
  }
85
39
  else if (obj instanceof protobufjs.Service) {
86
- yield createServiceDeclaration(obj, subs);
40
+ yield service_1.createServiceDeclaration(obj, subs);
87
41
  }
88
42
  else if (obj instanceof protobufjs.Type) {
89
- yield createMessageDeclaration(obj, subs);
43
+ yield message_1.createMessageDeclaration(obj, subs);
90
44
  const nested = Array.from(createDeclarations(obj.nestedArray, subs));
91
45
  if (nested.length > 0) {
92
46
  yield f.createModuleDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], f.createIdentifier(obj.name), f.createModuleBlock(nested), ts.NodeFlags.Namespace);
@@ -118,21 +72,4 @@ function createTypeDictionary(root) {
118
72
  .map(type => f.createPropertySignature(undefined, f.createStringLiteral(namespaces_1.normalizeFullyQualifiedName(type.fullName)), undefined, types_1.getTypeReference(type))));
119
73
  }
120
74
  exports.createTypeDictionary = createTypeDictionary;
121
- function* getServices(root) {
122
- for (const obj of root.nestedArray) {
123
- if (obj instanceof protobufjs.Service) {
124
- yield obj;
125
- yield* getServices(obj);
126
- }
127
- else if (obj instanceof protobufjs.Namespace) {
128
- yield* getServices(obj);
129
- }
130
- }
131
- }
132
- function createServicesDictionary(root) {
133
- return f.createInterfaceDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], 'SERVICES', undefined, undefined, Array.from(getServices(root))
134
- .sort((b, a) => b.fullName.localeCompare(a.fullName))
135
- .map(type => f.createPropertySignature(undefined, f.createStringLiteral(namespaces_1.normalizeFullyQualifiedName(type.fullName)), undefined, types_1.getTypeReference(type))));
136
- }
137
- exports.createServicesDictionary = createServicesDictionary;
138
75
  //# sourceMappingURL=declaration-generator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"declaration-generator.js","sourceRoot":"","sources":["../../../src/generator/declaration-generator.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,oDAA4B;AAC5B,uDAAyC;AACzC,+CAAiC;AAEjC,8CAA4D;AAE5D,mCAAkD;AAElD,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;AAErB,SAAS,YAAY,CAAE,KAAuB,EAAE,IAAsB;IACpE,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,CAAC,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;KAC/D;SAAM,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,YAAY,UAAU,CAAC,QAAQ,EAAE;QAC5D,OAAO,CAAC,CAAC,uBAAuB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,uBAAuB,CAAC,QAAQ,EAAE;gBAC/E,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;gBACpD,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC;aAChC,CAAC,CAAC,CAAC,CAAC;KACN;SAAM;QACL,OAAO,kBAAkB,CAAC,KAAK,EAAE,IAA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,CACL,CAAC;AACJ,CAAC;AAhBD,oDAgBC;AAED,QAAS,CAAC,CAAC,WAAW,CAAE,IAA8B;IACpD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,EAAE;QAClC,IAAI,GAAG,YAAY,UAAU,CAAC,OAAO,EAAE;YACrC,MAAM,GAAG,CAAC;YACV,KAAM,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;SAC1B;aAAM,IAAI,GAAG,YAAY,UAAU,CAAC,SAAS,EAAE;YAC9C,KAAM,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;SAC1B;KACF;AACH,CAAC;AAED,SAAgB,wBAAwB,CAAE,IAA8B;IACtE,OAAO,CAAC,CAAC,0BAA0B,CACjC,SAAS,EACT,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAC5C,UAAU,EACV,SAAS,EACT,SAAS,EACT,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;SACpD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,uBAAuB,CACpC,SAAS,EACT,CAAC,CAAC,mBAAmB,CAAC,wCAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EACjE,SAAS,EACT,wBAAgB,CAAC,IAAI,CAAC,CACvB,CAAC,CACL,CAAC;AACJ,CAAC;AAhBD,4DAgBC"}
1
+ {"version":3,"file":"declaration-generator.js","sourceRoot":"","sources":["../../../src/generator/declaration-generator.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;AAEF,uDAAyC;AACzC,+CAAiC;AAEjC,8CAA4D;AAE5D,iCAA+C;AAC/C,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AAG,YAAY,UAAU,CAAC,IAAI,EAAE;YAClC,MAAM,GAAG,CAAC;SACX;aAAM,IAAI,GAAG,YAAY,UAAU,CAAC,IAAI,EAAE;YACzC,MAAM,GAAG,CAAC;YACV,KAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;SACjC;aAAM,IAAI,GAAG,YAAY,UAAU,CAAC,SAAS,EAAE;YAC9C,KAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;SACjC;KACF;AACH,CAAC;AAED,SAAgB,oBAAoB,CAAE,IAA8B;IAClE,OAAO,CAAC,CAAC,0BAA0B,CACjC,SAAS,EACT,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAC5C,OAAO,EACP,SAAS,EACT,SAAS,EACT,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;SACjC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;SACpD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,uBAAuB,CACpC,SAAS,EACT,CAAC,CAAC,mBAAmB,CAAC,wCAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EACjE,SAAS,EACT,wBAAgB,CAAC,IAAI,CAAC,CACvB,CAAC,CACL,CAAC;AACJ,CAAC;AAhBD,oDAgBC"}
@@ -0,0 +1,3 @@
1
+ import ts from 'typescript';
2
+ export declare function attachDocComment<T extends ts.Node>(node: T, comment: string): T;
3
+ //# sourceMappingURL=doc-comment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc-comment.d.ts","sourceRoot":"","sources":["../../../src/generator/doc-comment.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,EAAE,CAAC,IAAI,EAAG,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAOhF"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2021 DXOS.org
4
+ //
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.attachDocComment = void 0;
10
+ const typescript_1 = __importDefault(require("typescript"));
11
+ function attachDocComment(node, comment) {
12
+ return typescript_1.default.addSyntheticLeadingComment(node, typescript_1.default.SyntaxKind.MultiLineCommentTrivia, `*\n${comment.split('\n').map(line => ` * ${line}`).join('\n')}\n `, true);
13
+ }
14
+ exports.attachDocComment = attachDocComment;
15
+ //# sourceMappingURL=doc-comment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc-comment.js","sourceRoot":"","sources":["../../../src/generator/doc-comment.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;AAEF,4DAA4B;AAE5B,SAAgB,gBAAgB,CAAqB,IAAO,EAAE,OAAe;IAC3E,OAAO,oBAAE,CAAC,0BAA0B,CAClC,IAAI,EACJ,oBAAE,CAAC,UAAU,CAAC,sBAAsB,EACpC,MAAM,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EACnE,IAAI,CACL,CAAC;AACJ,CAAC;AAPD,4CAOC"}
@@ -0,0 +1,4 @@
1
+ import * as protobufjs from 'protobufjs';
2
+ import * as ts from 'typescript';
3
+ export declare function createEnumDeclaration(type: protobufjs.Enum): ts.EnumDeclaration;
4
+ //# sourceMappingURL=enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../src/generator/enum.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,wBAAgB,qBAAqB,CAAE,IAAI,EAAE,UAAU,CAAC,IAAI,sBAU3D"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2020 DXOS.org
4
+ //
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.createEnumDeclaration = void 0;
26
+ const ts = __importStar(require("typescript"));
27
+ const f = ts.factory;
28
+ function createEnumDeclaration(type) {
29
+ return f.createEnumDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], type.name, Object.entries(type.values).map(([name, id]) => f.createEnumMember(name, f.createNumericLiteral(id))));
30
+ }
31
+ exports.createEnumDeclaration = createEnumDeclaration;
32
+ //# sourceMappingURL=enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/generator/enum.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;AAGF,+CAAiC;AAEjC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;AAErB,SAAgB,qBAAqB,CAAE,IAAqB;IAC1D,OAAO,CAAC,CAAC,qBAAqB,CAC5B,SAAS,EACT,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAC5C,IAAI,CAAC,IAAI,EACT,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAChE,IAAI,EACJ,CAAC,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAC3B,CAAC,CACH,CAAC;AACJ,CAAC;AAVD,sDAUC"}
@@ -0,0 +1,6 @@
1
+ import * as protobufjs from 'protobufjs';
2
+ import * as ts from 'typescript';
3
+ import { SubstitutionsMap } from '../parser';
4
+ export declare function getFieldType(field: protobufjs.Field, subs: SubstitutionsMap): ts.TypeNode;
5
+ export declare function getScalarFieldType(field: protobufjs.Field, subs: SubstitutionsMap): ts.TypeNode;
6
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../src/generator/field.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAK7C,wBAAgB,YAAY,CAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,EAAE,CAAC,QAAQ,CAW1F;AAED,wBAAgB,kBAAkB,CAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,EAAE,CAAC,QAAQ,CAIhG"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2020 DXOS.org
4
+ //
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.getScalarFieldType = exports.getFieldType = void 0;
29
+ const assert_1 = __importDefault(require("assert"));
30
+ const protobufjs = __importStar(require("protobufjs"));
31
+ const ts = __importStar(require("typescript"));
32
+ const types_1 = require("./types");
33
+ const f = ts.factory;
34
+ function getFieldType(field, subs) {
35
+ if (field.repeated) {
36
+ return f.createArrayTypeNode(getScalarFieldType(field, subs));
37
+ }
38
+ else if (field.map && field instanceof protobufjs.MapField) {
39
+ return f.createTypeReferenceNode('Partial', [f.createTypeReferenceNode('Record', [
40
+ f.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
41
+ getScalarFieldType(field, subs)
42
+ ])]);
43
+ }
44
+ else {
45
+ return getScalarFieldType(field, subs);
46
+ }
47
+ }
48
+ exports.getFieldType = getFieldType;
49
+ function getScalarFieldType(field, subs) {
50
+ var _a;
51
+ assert_1.default(field.message);
52
+ field.resolve();
53
+ return types_1.types((_a = field.resolvedType) !== null && _a !== void 0 ? _a : field.type, field.message, subs);
54
+ }
55
+ exports.getScalarFieldType = getScalarFieldType;
56
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.js","sourceRoot":"","sources":["../../../src/generator/field.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,oDAA4B;AAC5B,uDAAyC;AACzC,+CAAiC;AAGjC,mCAAgC;AAEhC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;AAErB,SAAgB,YAAY,CAAE,KAAuB,EAAE,IAAsB;IAC3E,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,CAAC,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;KAC/D;SAAM,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,YAAY,UAAU,CAAC,QAAQ,EAAE;QAC5D,OAAO,CAAC,CAAC,uBAAuB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,uBAAuB,CAAC,QAAQ,EAAE;gBAC/E,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;gBACpD,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC;aAChC,CAAC,CAAC,CAAC,CAAC;KACN;SAAM;QACL,OAAO,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KACxC;AACH,CAAC;AAXD,oCAWC;AAED,SAAgB,kBAAkB,CAAE,KAAuB,EAAE,IAAsB;;IACjF,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC,MAAA,KAAK,CAAC,YAAY,mCAAI,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACtE,CAAC;AAJD,gDAIC"}
@@ -0,0 +1,8 @@
1
+ import pb from 'protobufjs';
2
+ import * as ts from 'typescript';
3
+ import { ModuleSpecifier } from '../module-specifier';
4
+ import { SubstitutionsMap } from '../parser';
5
+ export declare function createNamespaceSourceFile(types: pb.ReflectionObject[], substitutions: SubstitutionsMap, outDir: string, namespace: string, substitutionsModule: ModuleSpecifier | undefined, otherNamespaces: string[]): ts.SourceFile;
6
+ export declare function createIndexSourceFile(substitutionsModule: ModuleSpecifier | undefined, root: pb.Root, outDirPath: string, namespaces: string[]): ts.SourceFile;
7
+ export declare function getFileNameForNamespace(namespace: string): string;
8
+ //# sourceMappingURL=file-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-generator.d.ts","sourceRoot":"","sources":["../../../src/generator/file-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAgB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAgB7C,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,EAAE,CAAC,gBAAgB,EAAE,EAC5B,aAAa,EAAE,gBAAgB,EAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,eAAe,GAAG,SAAS,EAChD,eAAe,EAAE,MAAM,EAAE,iBAmB1B;AAED,wBAAgB,qBAAqB,CAAE,mBAAmB,EAAE,eAAe,GAAG,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAqB/I;AAaD,wBAAgB,uBAAuB,CAAE,SAAS,EAAE,MAAM,UAGzD"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2021 DXOS.org
4
+ //
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.getFileNameForNamespace = exports.createIndexSourceFile = exports.createNamespaceSourceFile = void 0;
26
+ const path_1 = require("path");
27
+ const ts = __importStar(require("typescript"));
28
+ const module_specifier_1 = require("../module-specifier");
29
+ const namespaces_1 = require("../namespaces");
30
+ const declaration_generator_1 = require("./declaration-generator");
31
+ const serializer_definition_generator_1 = require("./serializer-definition-generator");
32
+ const service_1 = require("./service");
33
+ const f = ts.factory;
34
+ function createSubstitutionsImport(substitutionsModule, context) {
35
+ return substitutionsModule && ts.factory.createImportDeclaration([], [], ts.factory.createImportClause(false, ts.factory.createIdentifier('substitutions'), undefined), ts.factory.createStringLiteral(substitutionsModule.importSpecifier(context)));
36
+ }
37
+ function createNamespaceSourceFile(types, substitutions, outDir, namespace, substitutionsModule, otherNamespaces) {
38
+ const outFile = path_1.join(outDir, getFileNameForNamespace(namespace));
39
+ const declarations = Array.from(declaration_generator_1.createDeclarations(types, substitutions));
40
+ const substitutionsImport = substitutionsModule && createSubstitutionsImport(substitutionsModule, path_1.dirname(outFile));
41
+ const otherNamespaceImports = createNamespaceImports(otherNamespaces.filter(ns => ns !== namespace), outDir, path_1.dirname(outFile));
42
+ return ts.factory.createSourceFile([
43
+ createStreamImport(),
44
+ ...(substitutionsImport ? [substitutionsImport] : []),
45
+ ...otherNamespaceImports,
46
+ ...declarations
47
+ ], ts.factory.createToken(ts.SyntaxKind.EndOfFileToken), ts.NodeFlags.None);
48
+ }
49
+ exports.createNamespaceSourceFile = createNamespaceSourceFile;
50
+ function createIndexSourceFile(substitutionsModule, root, outDirPath, namespaces) {
51
+ const { imports: schemaImports, exports: schemaExports } = serializer_definition_generator_1.createSerializerDefinition(substitutionsModule, root, outDirPath);
52
+ const substitutionsImport = substitutionsModule && createSubstitutionsImport(substitutionsModule, outDirPath);
53
+ const otherNamespaceImports = createNamespaceImports(namespaces, outDirPath, outDirPath);
54
+ return ts.factory.createSourceFile([
55
+ ...schemaImports,
56
+ ...otherNamespaceImports,
57
+ ...(substitutionsImport ? [substitutionsImport] : []),
58
+ declaration_generator_1.createTypeDictionary(root),
59
+ service_1.createServicesDictionary(root),
60
+ ...schemaExports
61
+ ], ts.factory.createToken(ts.SyntaxKind.EndOfFileToken), ts.NodeFlags.None);
62
+ }
63
+ exports.createIndexSourceFile = createIndexSourceFile;
64
+ function createNamespaceImports(namespaces, outDirPath, context) {
65
+ return namespaces
66
+ .sort((b, a) => b.localeCompare(a))
67
+ .map(ns => f.createImportDeclaration([], [], f.createImportClause(false, undefined, f.createNamespaceImport(f.createIdentifier(namespaces_1.getSafeNamespaceIdentifier(namespaces_1.parseFullyQualifiedName(ns))))), f.createStringLiteral(module_specifier_1.ModuleSpecifier.resolveFromFilePath(getFileNameForNamespace(ns), outDirPath).importSpecifier(context))));
68
+ }
69
+ function getFileNameForNamespace(namespace) {
70
+ const name = namespaces_1.parseFullyQualifiedName(namespace);
71
+ return `${name.join('/')}.ts`;
72
+ }
73
+ exports.getFileNameForNamespace = getFileNameForNamespace;
74
+ function createStreamImport() {
75
+ return f.createImportDeclaration([], [], f.createImportClause(false, undefined, f.createNamedImports([
76
+ f.createImportSpecifier(undefined, f.createIdentifier('Stream'))
77
+ ])), f.createStringLiteral(module_specifier_1.CODEC_MODULE.importSpecifier('')));
78
+ }
79
+ //# sourceMappingURL=file-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-generator.js","sourceRoot":"","sources":["../../../src/generator/file-generator.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;AAEF,+BAAqC;AAErC,+CAAiC;AAEjC,0DAAoE;AACpE,8CAAoF;AAEpF,mEAAmF;AACnF,uFAA+E;AAC/E,uCAAqD;AAErD,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;AAErB,SAAS,yBAAyB,CAAE,mBAAoC,EAAE,OAAe;IACvF,OAAO,mBAAmB,IAAI,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAC9D,EAAE,EACF,EAAE,EACF,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,EAAE,SAAS,CAAC,EAC7F,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED,SAAgB,yBAAyB,CACvC,KAA4B,EAC5B,aAA+B,EAC/B,MAAc,EACd,SAAiB,EACjB,mBAAgD,EAChD,eAAyB;IAEzB,MAAM,OAAO,GAAG,WAAI,CAAC,MAAM,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC,CAAC;IACjE,MAAM,YAAY,GAAmB,KAAK,CAAC,IAAI,CAAC,0CAAkB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;IAE1F,MAAM,mBAAmB,GAAG,mBAAmB,IAAI,yBAAyB,CAAC,mBAAmB,EAAE,cAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpH,MAAM,qBAAqB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,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as protobufjs from 'protobufjs';
2
+ import * as ts from 'typescript';
3
+ import { SubstitutionsMap } from '../parser';
4
+ export declare function createMessageDeclaration(type: protobufjs.Type, subs: SubstitutionsMap): ts.InterfaceDeclaration;
5
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/generator/message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAM7C,wBAAgB,wBAAwB,CAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,2BA4BtF"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2020 DXOS.org
4
+ //
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.createMessageDeclaration = void 0;
26
+ const ts = __importStar(require("typescript"));
27
+ const doc_comment_1 = require("./doc-comment");
28
+ const field_1 = require("./field");
29
+ const f = ts.factory;
30
+ function createMessageDeclaration(type, subs) {
31
+ const declaration = f.createInterfaceDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], type.name, undefined, undefined, type.fieldsArray.map(field => {
32
+ const signature = f.createPropertySignature(undefined, field.name.includes('.') ? f.createStringLiteral(field.name) : field.name, field.required ? undefined : f.createToken(ts.SyntaxKind.QuestionToken), field_1.getFieldType(field, subs));
33
+ if (!field.comment) {
34
+ return signature;
35
+ }
36
+ return doc_comment_1.attachDocComment(signature, field.comment);
37
+ }));
38
+ if (!type.comment) {
39
+ return declaration;
40
+ }
41
+ return doc_comment_1.attachDocComment(declaration, type.comment);
42
+ }
43
+ exports.createMessageDeclaration = createMessageDeclaration;
44
+ //# sourceMappingURL=message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/generator/message.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;AAGF,+CAAiC;AAGjC,+CAAiD;AACjD,mCAAuC;AAEvC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;AAErB,SAAgB,wBAAwB,CAAE,IAAqB,EAAE,IAAsB;IACrF,MAAM,WAAW,GAAG,CAAC,CAAC,0BAA0B,CAC9C,SAAS,EACT,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAC5C,IAAI,CAAC,IAAI,EACT,SAAS,EACT,SAAS,EACT,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAC3B,MAAM,SAAS,GAAG,CAAC,CAAC,uBAAuB,CACzC,SAAS,EACT,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EACzE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EACvE,oBAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAC1B,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YAClB,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,8BAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC,CAAC,CACH,CAAC;IAEF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjB,OAAO,WAAW,CAAC;KACpB;IAED,OAAO,8BAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC;AA5BD,4DA4BC"}
@@ -0,0 +1,6 @@
1
+ import * as protobufjs from 'protobufjs';
2
+ import * as ts from 'typescript';
3
+ import { SubstitutionsMap } from '../parser';
4
+ export declare function createServiceDeclaration(type: protobufjs.Service, subs: SubstitutionsMap): ts.InterfaceDeclaration;
5
+ export declare function createServicesDictionary(root: protobufjs.NamespaceBase): ts.InterfaceDeclaration;
6
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/generator/service.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAsC7C,wBAAgB,wBAAwB,CAAE,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,GAAG,EAAE,CAAC,oBAAoB,CAsBnH;AAaD,wBAAgB,wBAAwB,CAAE,IAAI,EAAE,UAAU,CAAC,aAAa,2BAgBvE"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2020 DXOS.org
4
+ //
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.createServicesDictionary = exports.createServiceDeclaration = void 0;
29
+ const assert_1 = __importDefault(require("assert"));
30
+ const protobufjs = __importStar(require("protobufjs"));
31
+ const ts = __importStar(require("typescript"));
32
+ const namespaces_1 = require("../namespaces");
33
+ const doc_comment_1 = require("./doc-comment");
34
+ const types_1 = require("./types");
35
+ const f = ts.factory;
36
+ function getRpcTypes(method, service, subs) {
37
+ var _a, _b;
38
+ method.resolve();
39
+ return [
40
+ types_1.types((_a = method.resolvedRequestType) !== null && _a !== void 0 ? _a : method.requestType, service, subs),
41
+ types_1.types((_b = method.resolvedResponseType) !== null && _b !== void 0 ? _b : method.responseType, service, subs)
42
+ ];
43
+ }
44
+ function createRpcMethodType(method, service, subs) {
45
+ assert_1.default(!method.requestStream, 'Streaming RPC requests are not supported.');
46
+ const [requestType, responseType] = getRpcTypes(method, service, subs);
47
+ const outputTypeMonad = method.responseStream ? f.createIdentifier('Stream') : f.createIdentifier('Promise');
48
+ return f.createFunctionTypeNode(undefined, [f.createParameterDeclaration(undefined, undefined, undefined, 'request', undefined, requestType)], f.createTypeReferenceNode(outputTypeMonad, [responseType]));
49
+ }
50
+ function createServiceDeclaration(type, subs) {
51
+ const declaration = f.createInterfaceDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], type.name, undefined, undefined, type.methodsArray
52
+ .filter(m => !m.requestStream)
53
+ .map(method => {
54
+ const sig = f.createPropertySignature(undefined, method.name, undefined, createRpcMethodType(method, type, subs));
55
+ return method.comment ? doc_comment_1.attachDocComment(sig, method.comment) : sig;
56
+ }));
57
+ return type.comment ? doc_comment_1.attachDocComment(declaration, type.comment) : declaration;
58
+ }
59
+ exports.createServiceDeclaration = createServiceDeclaration;
60
+ function* getServices(root) {
61
+ for (const obj of root.nestedArray) {
62
+ if (obj instanceof protobufjs.Service) {
63
+ yield obj;
64
+ yield* getServices(obj);
65
+ }
66
+ else if (obj instanceof protobufjs.Namespace) {
67
+ yield* getServices(obj);
68
+ }
69
+ }
70
+ }
71
+ function createServicesDictionary(root) {
72
+ return f.createInterfaceDeclaration(undefined, [f.createToken(ts.SyntaxKind.ExportKeyword)], 'SERVICES', undefined, undefined, Array.from(getServices(root))
73
+ .sort((b, a) => b.fullName.localeCompare(a.fullName))
74
+ .map(type => f.createPropertySignature(undefined, f.createStringLiteral(namespaces_1.normalizeFullyQualifiedName(type.fullName)), undefined, types_1.getTypeReference(type))));
75
+ }
76
+ exports.createServicesDictionary = createServicesDictionary;
77
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/generator/service.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,oDAA4B;AAC5B,uDAAyC;AACzC,+CAAiC;AAEjC,8CAA4D;AAE5D,+CAAiD;A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AAC;SAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;SACpD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,uBAAuB,CACpC,SAAS,EACT,CAAC,CAAC,mBAAmB,CAAC,wCAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EACjE,SAAS,EACT,wBAAgB,CAAC,IAAI,CAAC,CACvB,CAAC,CACL,CAAC;AACJ,CAAC;AAhBD,4DAgBC"}
@@ -24,15 +24,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  const path_1 = require("path");
26
26
  const pb = __importStar(require("protobufjs"));
27
+ const configure_1 = require("./configure");
27
28
  const namespaces_1 = require("./namespaces");
28
29
  const parser_1 = require("./parser");
29
30
  parser_1.registerResolver();
31
+ configure_1.preconfigureProtobufjs();
30
32
  test('split namespaces', async () => {
31
- const root = await pb.load(path_1.join(__dirname, '../test/schema.proto'));
33
+ const root = await pb.load(path_1.join(__dirname, '../test/proto/schema.proto'));
32
34
  const namespaces = namespaces_1.splitSchemaIntoNamespaces(root);
33
35
  expect(Array.from(namespaces.keys()).sort()).toEqual([
34
36
  'dxos.test',
35
37
  'dxos.test.any',
38
+ 'dxos.test.extensions',
36
39
  'dxos.test.testfoo',
37
40
  'google.protobuf'
38
41
  ].sort());
@@ -1 +1 @@
1
- {"version":3,"file":"namespaces.test.js","sourceRoot":"","sources":["../../src/namespaces.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;AAEF,+BAA4B;AAC5B,+CAAiC;AAEjC,6CAAyD;AACzD,qCAA4C;AAE5C,yBAAgB,EAAE,CAAC;AAEnB,IAAI,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;IAClC,MAAM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