@vscode/telemetry-extractor 1.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -0
  3. package/SECURITY.md +41 -0
  4. package/documentation/comment-code-annotations.md +197 -0
  5. package/documentation/typescript-code-annotations.md +187 -0
  6. package/documentation/using-the-tool.md +106 -0
  7. package/out/cli-help.js +30 -0
  8. package/out/cli-help.js.map +1 -0
  9. package/out/cli-options.js +52 -0
  10. package/out/cli-options.js.map +1 -0
  11. package/out/extractor.js +83 -0
  12. package/out/extractor.js.map +1 -0
  13. package/out/index.js +10 -0
  14. package/out/index.js.map +1 -0
  15. package/out/lib/common-properties.js +32 -0
  16. package/out/lib/common-properties.js.map +1 -0
  17. package/out/lib/debug-patch.js +17 -0
  18. package/out/lib/debug-patch.js.map +1 -0
  19. package/out/lib/declarations.js +121 -0
  20. package/out/lib/declarations.js.map +1 -0
  21. package/out/lib/events.js +55 -0
  22. package/out/lib/events.js.map +1 -0
  23. package/out/lib/file-writer.js +77 -0
  24. package/out/lib/file-writer.js.map +1 -0
  25. package/out/lib/fragments.js +21 -0
  26. package/out/lib/fragments.js.map +1 -0
  27. package/out/lib/keywords.js +11 -0
  28. package/out/lib/keywords.js.map +1 -0
  29. package/out/lib/logger.js +10 -0
  30. package/out/lib/logger.js.map +1 -0
  31. package/out/lib/object-converter.js +107 -0
  32. package/out/lib/object-converter.js.map +1 -0
  33. package/out/lib/operations.js +118 -0
  34. package/out/lib/operations.js.map +1 -0
  35. package/out/lib/parser.js +191 -0
  36. package/out/lib/parser.js.map +1 -0
  37. package/out/lib/save-declarations.js +94 -0
  38. package/out/lib/save-declarations.js.map +1 -0
  39. package/out/lib/source-spec.js +77 -0
  40. package/out/lib/source-spec.js.map +1 -0
  41. package/out/lib/telemetry-interfaces.js +3 -0
  42. package/out/lib/telemetry-interfaces.js.map +1 -0
  43. package/out/lib/ts-parser.js +219 -0
  44. package/out/lib/ts-parser.js.map +1 -0
  45. package/package.json +39 -0
  46. package/src/cli-help.ts +29 -0
  47. package/src/cli-options.ts +31 -0
  48. package/src/extractor.ts +57 -0
  49. package/src/index.ts +4 -0
  50. package/src/lib/common-properties.ts +41 -0
  51. package/src/lib/debug-patch.ts +13 -0
  52. package/src/lib/declarations.ts +131 -0
  53. package/src/lib/events.ts +56 -0
  54. package/src/lib/file-writer.ts +54 -0
  55. package/src/lib/fragments.ts +24 -0
  56. package/src/lib/keywords.ts +7 -0
  57. package/src/lib/logger.ts +5 -0
  58. package/src/lib/object-converter.ts +85 -0
  59. package/src/lib/operations.ts +89 -0
  60. package/src/lib/parser.ts +184 -0
  61. package/src/lib/save-declarations.ts +71 -0
  62. package/src/lib/source-spec.ts +67 -0
  63. package/src/lib/telemetry-interfaces.ts +40 -0
  64. package/src/lib/ts-parser.ts +206 -0
  65. package/tsconfig.json +67 -0
  66. package/vscode-telemetry-extractor.d.ts +72 -0
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.makeExclusionsRelativeToSource = exports.populateProperties = exports.mergeWildcards = exports.findOrCreate = exports.merge = void 0;
23
+ // Copyright (c) Microsoft Corporation.
24
+ // Licensed under the MIT license.
25
+ const fragments_1 = require("./fragments");
26
+ const events_1 = require("./events");
27
+ const common_properties_1 = require("./common-properties");
28
+ const keywords = __importStar(require("./keywords"));
29
+ function merge(target, source) {
30
+ for (const item of source.dataPoints) {
31
+ const found = target.dataPoints.find((f) => {
32
+ return f.name == item.name;
33
+ });
34
+ // We combine their properties together if the event already exists
35
+ if (found) {
36
+ found.properties = found.properties.concat(item.properties);
37
+ }
38
+ else {
39
+ target.dataPoints.push(item);
40
+ }
41
+ }
42
+ }
43
+ exports.merge = merge;
44
+ // Searches the object for an event or fragment of the specific name
45
+ // If found returns, if not found creates it, places it in the array, and then returns
46
+ function findOrCreate(searchTarget, name) {
47
+ let found = searchTarget.dataPoints.find((item) => {
48
+ return item.name === name;
49
+ });
50
+ if (!found) {
51
+ if (searchTarget instanceof events_1.Events) {
52
+ found = new events_1.Event(name);
53
+ }
54
+ else {
55
+ found = new fragments_1.Fragment(name);
56
+ }
57
+ }
58
+ searchTarget.dataPoints.push(found);
59
+ return found;
60
+ }
61
+ exports.findOrCreate = findOrCreate;
62
+ function mergeWildcards(wildcard, target, applyEndpoints) {
63
+ let wildCard = target.properties.find((item) => {
64
+ return item instanceof events_1.Wildcard;
65
+ });
66
+ // if we don't have a wildcard yet we make one
67
+ if (!wildCard) {
68
+ wildCard = new events_1.Wildcard();
69
+ target.properties.push(wildCard);
70
+ }
71
+ wildcard.forEach(w => {
72
+ if (applyEndpoints) {
73
+ wildCard.entries.push(new events_1.WildcardEntry(w[keywords.prefix], w[keywords.classification], 'none'));
74
+ }
75
+ else {
76
+ wildCard.entries.push(new events_1.WildcardEntry(w[keywords.prefix], w[keywords.classification]));
77
+ }
78
+ });
79
+ }
80
+ exports.mergeWildcards = mergeWildcards;
81
+ function populateProperties(properties, target, applyEndpoints = false) {
82
+ for (const propertyName in properties) {
83
+ const currentProperty = properties[propertyName];
84
+ if (propertyName === keywords.include) {
85
+ target.properties.push(new events_1.Include(currentProperty));
86
+ }
87
+ else if (currentProperty[keywords.inline]) {
88
+ // We consider the property name the inline name so when we resolve we can do prop.Inline for the new properties
89
+ target.properties.push(new events_1.Inline(propertyName, currentProperty[keywords.inline]));
90
+ }
91
+ else if (propertyName === keywords.wildcard) {
92
+ mergeWildcards(currentProperty, target, applyEndpoints);
93
+ }
94
+ else {
95
+ const prop = new common_properties_1.Property(propertyName, currentProperty.classification, currentProperty.purpose, currentProperty.expiration, currentProperty.owner, currentProperty.comment);
96
+ if (applyEndpoints) {
97
+ const endpoint = currentProperty.endpoint ? currentProperty.endpoint : 'none';
98
+ prop.endPoint = endpoint;
99
+ }
100
+ if (currentProperty.isMeasurement) {
101
+ prop.isMeasurement = currentProperty.isMeasurement;
102
+ }
103
+ target.properties.push(prop);
104
+ }
105
+ }
106
+ }
107
+ exports.populateProperties = populateProperties;
108
+ function makeExclusionsRelativeToSource(sourceDir, excludedDirs) {
109
+ const relativeExclusions = [];
110
+ for (const excluded of excludedDirs) {
111
+ if (excluded.includes(sourceDir)) {
112
+ relativeExclusions.push(excluded.replace(sourceDir, ''));
113
+ }
114
+ }
115
+ return relativeExclusions;
116
+ }
117
+ exports.makeExclusionsRelativeToSource = makeExclusionsRelativeToSource;
118
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/lib/operations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,2CAAkD;AAClD,qCAAmF;AACnF,2DAA+C;AAC/C,qDAAuC;AAEvC,SAAgB,KAAK,CAAC,MAA0B,EAAE,MAA0B;IACxE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,UAAU,EAAE;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;Y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E,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;YAC7K,IAAI,cAAc,EAAE;gBAChB,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;gBAC9E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;aAC5B;YACD,IAAI,eAAe,CAAC,aAAa,EAAE;gBAC/B,IAAI,CAAC,aAAa,GAAG,eAAe,CAAC,aAAa,CAAC;aACtD;YACD,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAChC;KACJ;AACL,CAAC;AAtBD,gDAsBC;AAED,SAAgB,8BAA8B,CAAC,SAAiB,EAAE,YAAsB;IACpF,MAAM,kBAAkB,GAAG,EAAE,CAAC;IAC9B,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;QACjC,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YAC9B,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;SAC5D;KACJ;IACD,OAAO,kBAAkB,CAAC;AAC9B,CAAC;AARD,wEAQC"}
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Parser = void 0;
23
+ // Copyright (c) Microsoft Corporation.
24
+ // Licensed under the MIT license.
25
+ const vscode_ripgrep_1 = require("vscode-ripgrep");
26
+ const path = __importStar(require("path"));
27
+ const cp = __importStar(require("child_process"));
28
+ const fs = __importStar(require("fs"));
29
+ const fragments_1 = require("./fragments");
30
+ const common_properties_1 = require("./common-properties");
31
+ const events_1 = require("./events");
32
+ const operations_1 = require("./operations");
33
+ class Parser {
34
+ sourceDirs;
35
+ excludedDirs;
36
+ applyEndpoints;
37
+ lowerCaseEvents;
38
+ constructor(sourceDirs, excludedDirs, applyEndpoints, lowerCaseEvents) {
39
+ this.sourceDirs = sourceDirs;
40
+ this.excludedDirs = excludedDirs;
41
+ this.applyEndpoints = applyEndpoints;
42
+ this.lowerCaseEvents = lowerCaseEvents;
43
+ }
44
+ toRipGrepOption(dir) {
45
+ while (dir.startsWith('/')) {
46
+ dir = dir.substr(1);
47
+ }
48
+ return `--glob "!${dir}/**" `;
49
+ }
50
+ extractComments(absoluteFilePaths, commentMatcher, collector) {
51
+ absoluteFilePaths.forEach(absoluteFilePath => {
52
+ if (absoluteFilePath) {
53
+ const fileContents = fs.readFileSync(absoluteFilePath);
54
+ let match;
55
+ while (match = commentMatcher.exec(fileContents.toString())) {
56
+ collector(absoluteFilePath, match);
57
+ }
58
+ }
59
+ });
60
+ }
61
+ // Converts relative paths to absolute utilizing the CWD
62
+ asAbsoluteFilePaths(relativeFilePaths) {
63
+ return relativeFilePaths.map(r => path.resolve(r));
64
+ }
65
+ // Finds all files containing common telemetry properties in the given directory
66
+ findFilesWithCommonProperties(sourceDir) {
67
+ const ripgrepPattern = '//\\s*__GDPR__COMMON__';
68
+ return this.findFiles(ripgrepPattern, sourceDir);
69
+ }
70
+ findCommonProperties(sourceDir) {
71
+ const filesWithCommonProperties = this.asAbsoluteFilePaths(this.findFilesWithCommonProperties(sourceDir));
72
+ const commonPropertyMatcher = /\/\/\s*__GDPR__COMMON__(.*)$/mg;
73
+ const commonPropertyDeclarations = new common_properties_1.CommonProperties();
74
+ this.extractComments(filesWithCommonProperties, commonPropertyMatcher, (filePath, match) => {
75
+ try {
76
+ const commonPropertyDeclaration = JSON.parse(`{ ${match[1]} }`);
77
+ const propertyName = Object.keys(commonPropertyDeclaration)[0];
78
+ const properties = commonPropertyDeclaration[propertyName];
79
+ // Add all the common properties to the common property object
80
+ const prop = new common_properties_1.Property(propertyName, properties.classification, properties.purpose);
81
+ if (this.applyEndpoints) {
82
+ const endpoint = properties.endPoint ? properties.endPoint : 'none';
83
+ prop.endPoint = endpoint;
84
+ }
85
+ if (properties.isMeasurement) {
86
+ prop.isMeasurement = properties.isMeasurement;
87
+ }
88
+ commonPropertyDeclarations.properties.push(prop);
89
+ }
90
+ catch (error) {
91
+ console.error(`Common Property Declaration Error: ${error} in file ${filePath}`);
92
+ console.error(`Source comment:\n${match[0]}`);
93
+ }
94
+ });
95
+ return commonPropertyDeclarations;
96
+ }
97
+ // Finds all files containing event fragments in the given directory
98
+ findFilesWithFragments(sourceDir) {
99
+ const ripgrepPattern = '/\*\\s*__GDPR__FRAGMENT__';
100
+ return this.findFiles(ripgrepPattern, sourceDir);
101
+ }
102
+ ///
103
+ findFragments(sourceDir) {
104
+ const filesWithFragments = this.asAbsoluteFilePaths(this.findFilesWithFragments(sourceDir));
105
+ // Using [\s\S]* instead of .* since the latter does not match when using /m option
106
+ const fragmentMatcher = /\/\*\s*__GDPR__FRAGMENT__([\s\S]*?)\*\//mg;
107
+ const fragmentDeclarations = new fragments_1.Fragments();
108
+ this.extractComments(filesWithFragments, fragmentMatcher, (filePath, match) => {
109
+ try {
110
+ const fragmentDeclaration = JSON.parse(`{ ${match[1]} }`);
111
+ // There's only ever one key per match
112
+ const fragmentName = Object.keys(fragmentDeclaration)[0];
113
+ // Checks to see if we have a fragment of the given name, else creates.
114
+ const fragment = (0, operations_1.findOrCreate)(fragmentDeclarations, fragmentName);
115
+ const fragmentProperties = fragmentDeclaration[fragmentName];
116
+ (0, operations_1.populateProperties)(fragmentProperties, fragment, this.applyEndpoints);
117
+ }
118
+ catch (error) {
119
+ console.error(`Fragment Declaration Error: ${error} in file ${filePath}`);
120
+ console.error(`Source comment:\n${match[0]}`);
121
+ }
122
+ });
123
+ return fragmentDeclarations;
124
+ }
125
+ // Find all files with complete events
126
+ findFilesWithEvents(sourceDir) {
127
+ const ripgrepPattern = '/\*\\s*__GDPR__\\b';
128
+ return this.findFiles(ripgrepPattern, sourceDir);
129
+ }
130
+ findEvents(sourceDir) {
131
+ const filesWithEvents = this.asAbsoluteFilePaths(this.findFilesWithEvents(sourceDir));
132
+ // Using [\s\S]* instead of .* since the latter does not match when using /m option
133
+ const eventMatcher = /\/\*\s*__GDPR__\b([\s\S]*?)\*\//mg;
134
+ const eventDeclarations = new events_1.Events();
135
+ this.extractComments(filesWithEvents, eventMatcher, (filePath, match) => {
136
+ try {
137
+ const eventDeclaration = JSON.parse(`{ ${match[1]} }`);
138
+ let eventName = Object.keys(eventDeclaration)[0];
139
+ eventName = this.lowerCaseEvents ? eventName.toLowerCase() : eventName;
140
+ const event = (0, operations_1.findOrCreate)(eventDeclarations, eventName);
141
+ // Get the propeties which the event possesses
142
+ const eventProperties = eventDeclaration[Object.keys(eventDeclaration)[0]];
143
+ (0, operations_1.populateProperties)(eventProperties, event, this.applyEndpoints);
144
+ }
145
+ catch (error) {
146
+ console.error(`Event Declaration Error: ${error} in file ${filePath}`);
147
+ console.error(`Source comment:\n${match[0]}`);
148
+ }
149
+ });
150
+ return eventDeclarations;
151
+ }
152
+ // Utilizes a regex to find the files containing the specific pattern
153
+ findFiles(ripgrepPattern, sourceDir) {
154
+ const relativeExclusions = (0, operations_1.makeExclusionsRelativeToSource)(sourceDir, this.excludedDirs);
155
+ const exclusions = relativeExclusions.length === 0 || relativeExclusions[0] === '' ? '' : relativeExclusions.map(this.toRipGrepOption).join('');
156
+ const cmd = `${vscode_ripgrep_1.rgPath} --files-with-matches --glob "*.ts" ${exclusions} --regexp "${ripgrepPattern}" -- ${sourceDir}`;
157
+ try {
158
+ let filePaths = cp.execSync(cmd, { encoding: 'ascii', cwd: `${sourceDir}` });
159
+ return filePaths.split(/(?:\r\n|\r|\n)/g).filter(path => path && path.length > 0);
160
+ }
161
+ catch (err) {
162
+ // ripgrep's return code != 0 if there are no matches
163
+ return [];
164
+ }
165
+ }
166
+ async parse(sourceDir) {
167
+ const fragments = this.findFragments(sourceDir);
168
+ const events = this.findEvents(sourceDir);
169
+ const commonProperties = this.findCommonProperties(sourceDir);
170
+ return { fragments: fragments, events: events, commonProperties: commonProperties };
171
+ }
172
+ extractDeclarations() {
173
+ return new Promise((resolve, reject) => {
174
+ // Find all the properties for all files
175
+ const promises = this.sourceDirs.map(sd => this.parse(sd));
176
+ // Now we must merge them into one superset of all declarations
177
+ Promise.all(promises).then(parseResult => {
178
+ const declarations = { fragments: new fragments_1.Fragments(), events: new events_1.Events(), commonProperties: new common_properties_1.CommonProperties() };
179
+ for (const currentResult of parseResult) {
180
+ (0, operations_1.merge)(declarations.fragments, currentResult.fragments);
181
+ (0, operations_1.merge)(declarations.events, currentResult.events);
182
+ // We just concatenate common properties
183
+ declarations.commonProperties.properties = declarations.commonProperties.properties.concat(currentResult.commonProperties.properties);
184
+ }
185
+ return resolve(declarations);
186
+ });
187
+ });
188
+ }
189
+ }
190
+ exports.Parser = Parser;
191
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/lib/parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,mDAAwC;AACxC,2CAA6B;AAC7B,kDAAoC;AACpC,uCAAyB;AACzB,2CAAwC;AACxC,2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createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.extractAndResolveDeclarations = exports.getResolvedDeclaration = exports.writeToFile = void 0;
23
+ // Copyright (c) Microsoft Corporation.
24
+ // Licensed under the MIT license.
25
+ const path = __importStar(require("path"));
26
+ const parser_1 = require("./parser");
27
+ const fileWriter = __importStar(require("./file-writer"));
28
+ const declarations_1 = require("./declarations");
29
+ const object_converter_1 = require("./object-converter");
30
+ const events_1 = require("./events");
31
+ const common_properties_1 = require("./common-properties");
32
+ const ts_parser_1 = require("./ts-parser");
33
+ const debug_patch_1 = require("./debug-patch");
34
+ const logger_1 = require("./logger");
35
+ function writeToFile(outputDir, contents, fileName, emitProgressMessage) {
36
+ const json = JSON.stringify(contents);
37
+ const outputFile = path.resolve(outputDir, `${fileName}.json`);
38
+ (0, logger_1.logMessage)(`...writing ${outputFile}`, !emitProgressMessage);
39
+ return fileWriter.writeFile(outputFile, json);
40
+ }
41
+ exports.writeToFile = writeToFile;
42
+ async function getResolvedDeclaration(sourceDirs, excludedDirs, options) {
43
+ (0, logger_1.logMessage)('...extracting', options.silenceOutput);
44
+ const parser = new parser_1.Parser(sourceDirs, excludedDirs, options.applyEndpoints, options.lowerCaseEvents);
45
+ let declarations = await parser.extractDeclarations();
46
+ declarations = (0, declarations_1.resolveDeclarations)(declarations, options.verbose);
47
+ return declarations;
48
+ }
49
+ exports.getResolvedDeclaration = getResolvedDeclaration;
50
+ async function extractAndResolveDeclarations(sourceSpecs) {
51
+ try {
52
+ const allDeclarations = { events: new events_1.Events(), commonProperties: new common_properties_1.CommonProperties() };
53
+ const allTypeScriptDeclarations = Object.create(null);
54
+ for (const spec of sourceSpecs) {
55
+ const declarations = await getResolvedDeclaration(spec.sourceDirs, spec.excludedDirs, spec.parserOptions);
56
+ let typescriptDeclarations = Object.create(null);
57
+ // The parser does not know how to handle multiple source directories due to different TS configs, so we manually have to parse each source dir
58
+ spec.sourceDirs.forEach((dir) => {
59
+ Object.assign(typescriptDeclarations, new ts_parser_1.TsParser(dir, spec.excludedDirs, spec.parserOptions.applyEndpoints, spec.parserOptions.lowerCaseEvents).parseFiles());
60
+ });
61
+ if (spec.parserOptions.eventPrefix !== '') {
62
+ declarations.events.dataPoints = declarations.events.dataPoints.map((event) => {
63
+ event.name = spec.parserOptions.eventPrefix + event.name;
64
+ return event;
65
+ });
66
+ const modifiedDeclartions = Object.create(null);
67
+ // Modify the object keys to be prefixed with the specified prefix
68
+ for (const key in typescriptDeclarations) {
69
+ modifiedDeclartions[spec.parserOptions.eventPrefix + key] = typescriptDeclarations[key];
70
+ }
71
+ typescriptDeclarations = modifiedDeclartions;
72
+ }
73
+ if (spec.parserOptions.patchDebugEvents) {
74
+ (0, debug_patch_1.patchDebugEvents)(declarations.events, spec.parserOptions.eventPrefix);
75
+ }
76
+ // We concatenate each extensions properties into a central one
77
+ // Throwing out fragments as they have already been used to resolve that extensions declarations
78
+ allDeclarations.commonProperties.properties = allDeclarations.commonProperties.properties.concat(declarations.commonProperties.properties);
79
+ allDeclarations.events.dataPoints = allDeclarations.events.dataPoints.concat(declarations.events.dataPoints);
80
+ Object.assign(allTypeScriptDeclarations, typescriptDeclarations);
81
+ }
82
+ const formattedDeclarations = await (0, object_converter_1.transformOutput)(allDeclarations);
83
+ for (const dec in allTypeScriptDeclarations) {
84
+ formattedDeclarations.events[dec] = allTypeScriptDeclarations[dec];
85
+ }
86
+ return Promise.resolve(formattedDeclarations);
87
+ }
88
+ catch (error) {
89
+ console.error(`Error: ${error}`);
90
+ return Promise.reject(error);
91
+ }
92
+ }
93
+ exports.extractAndResolveDeclarations = extractAndResolveDeclarations;
94
+ //# sourceMappingURL=save-declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-declarations.js","sourceRoot":"","sources":["../../src/lib/save-declarations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,2CAA6B;AAC7B,qCAAkC;AAClC,0DAA4C;AAC5C,iDAA4E;AAC5E,yDAAqD;AACrD,qCAAkC;AAClC,2DAAuD;AACvD,2CAAuC;AACvC,+CAAiD;AAEjD,qCAAsC;AAEtC,SAAgB,WAAW,CAAC,SAAiB,EAAE,QAAgB,EAAE,QAAgB,EAAE,mBAA4B;IAC3G,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,QAAQ,OAAO,CAAC,CAAC;IAC/D,IAAA,mBAAU,EAAC,cAAc,UAAU,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC;IAC7D,OAAO,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC;AALD,kCAKC;AAEM,KAAK,UAAU,sBAAsB,CAAC,UAAyB,EAAE,YAA2B,EAAE,OAAsB;IACvH,IAAA,mBAAU,EAAC,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,cAA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U,KAAK,EAAE,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KAChC;AACL,CAAC;AAzCD,sEAyCC"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.convertConfigToSourceSpecs = void 0;
23
+ // Copyright (c) Microsoft Corporation.
24
+ // Licensed under the MIT license.
25
+ const fs_1 = require("fs");
26
+ const path = __importStar(require("path"));
27
+ const process_1 = require("process");
28
+ ;
29
+ function convertConfigToSourceSpecs(file) {
30
+ try {
31
+ const config = JSON.parse((0, fs_1.readFileSync)(file).toString());
32
+ const sourceSpecs = [];
33
+ for (const key in config) {
34
+ const spec = config[key];
35
+ // Some defaults
36
+ spec.excludedDirs = spec.excludedDirs ? spec.excludedDirs : [];
37
+ spec.workingDir = spec.workingDir ? spec.workingDir : (0, process_1.cwd)();
38
+ spec.patchDebugEvents = spec.patchDebugEvents ? spec.patchDebugEvents : false;
39
+ spec.lowerCaseEvents = spec.lowerCaseEvents ? spec.lowerCaseEvents : false;
40
+ const parserOptions = {
41
+ eventPrefix: spec.eventPrefix ? spec.eventPrefix : '',
42
+ applyEndpoints: spec.applyEndpoints,
43
+ patchDebugEvents: spec.patchDebugEvents,
44
+ lowerCaseEvents: spec.lowerCaseEvents,
45
+ silenceOutput: spec.silenceOuput,
46
+ verbose: spec.verbose
47
+ };
48
+ const sourceSpec = {
49
+ sourceDirs: resolveDirectories(spec.sourceDirs, spec.workingDir),
50
+ excludedDirs: resolveDirectories(spec.excludedDirs, spec.workingDir),
51
+ parserOptions: parserOptions
52
+ };
53
+ sourceSpecs.push(sourceSpec);
54
+ }
55
+ return sourceSpecs;
56
+ }
57
+ catch (err) {
58
+ console.error(err);
59
+ return [];
60
+ }
61
+ }
62
+ exports.convertConfigToSourceSpecs = convertConfigToSourceSpecs;
63
+ // Resolves an array of paths
64
+ function resolveDirectories(dirs, workingDir) {
65
+ if (workingDir) {
66
+ if (path.isAbsolute(workingDir)) {
67
+ return dirs.map(s => path.resolve(workingDir, s));
68
+ }
69
+ else {
70
+ return dirs.map(s => path.resolve((0, process_1.cwd)(), workingDir, s));
71
+ }
72
+ }
73
+ else {
74
+ return dirs.map(s => path.resolve((0, process_1.cwd)(), s));
75
+ }
76
+ }
77
+ //# sourceMappingURL=source-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-spec.js","sourceRoot":"","sources":["../../src/lib/source-spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,2BAA4C;AAC5C,2CAA6B;AAC7B,qCAA8B;AAgB7B,CAAC;AAEF,SAAgB,0BAA0B,CAAC,IAAc;IACrD,IAAI;QACA,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzD,MAAM,WAAW,GAAiB,EAAE,CAAC;QACrC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;YACtB,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG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CAAC;KACb;AACL,CAAC;AA/BD,gEA+BC;AAED,6BAA6B;AAC7B,SAAS,kBAAkB,CAAC,IAAc,EAAE,UAAmB;IAC3D,IAAI,UAAU,EAAE;QACZ,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;SACrD;aAAM;YACH,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAA,aAAG,GAAE,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;SAC5D;KACJ;SAAM;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAA,aAAG,GAAE,EAAE,CAAC,CAAC,CAAC,CAAC;KAChD;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=telemetry-interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-interfaces.js","sourceRoot":"","sources":["../../src/lib/telemetry-interfaces.ts"],"names":[],"mappings":""}