@microsoft/power-apps-cli 0.5.4 → 0.5.7

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 (138) hide show
  1. package/lib/Constants/HelpStrings.d.ts +3 -3
  2. package/lib/Constants/HelpStrings.js +3 -3
  3. package/lib/Constants/HelpStrings.js.map +1 -1
  4. package/lib/HttpClient/CliHttpClient.d.ts.map +1 -1
  5. package/lib/HttpClient/CliHttpClient.js +8 -1
  6. package/lib/HttpClient/CliHttpClient.js.map +1 -1
  7. package/lib/Verbs/AddDataSource.d.ts.map +1 -1
  8. package/lib/Verbs/AddDataSource.js +7 -6
  9. package/lib/Verbs/AddDataSource.js.map +1 -1
  10. package/lib/Verbs/DeleteDataSource.d.ts +1 -1
  11. package/lib/Verbs/DeleteDataSource.d.ts.map +1 -1
  12. package/lib/Verbs/DeleteDataSource.js +2 -1
  13. package/lib/Verbs/DeleteDataSource.js.map +1 -1
  14. package/lib/Verbs/ListConnectionReferences.js +6 -6
  15. package/lib/Verbs/ListConnectionReferences.js.map +1 -1
  16. package/lib/Verbs/ListEnvironmentVariables.js +6 -6
  17. package/lib/Verbs/ListEnvironmentVariables.js.map +1 -1
  18. package/lib/Verbs/Push.js +7 -10
  19. package/lib/Verbs/Push.js.map +1 -1
  20. package/lib/Verbs/VerbConstants.d.ts +1 -1
  21. package/lib/Verbs/VerbConstants.js +3 -3
  22. package/lib/Verbs/VerbConstants.js.map +1 -1
  23. package/lib/__tests__/E2eTests/addAndDeleteDataverseDS.test.js +4 -3
  24. package/lib/__tests__/E2eTests/addAndDeleteDataverseDS.test.js.map +1 -1
  25. package/lib/__tests__/E2eTests/addTop10Datasources.test.js +3 -2
  26. package/lib/__tests__/E2eTests/addTop10Datasources.test.js.map +1 -1
  27. package/lib/__tests__/E2eTests/cliHelp.test.js +4 -11
  28. package/lib/__tests__/E2eTests/cliHelp.test.js.map +1 -1
  29. package/lib/__tests__/helpers/e2eTestHelpers.d.ts +24 -0
  30. package/lib/__tests__/helpers/e2eTestHelpers.d.ts.map +1 -0
  31. package/lib/__tests__/helpers/e2eTestHelpers.js +28 -0
  32. package/lib/__tests__/helpers/e2eTestHelpers.js.map +1 -0
  33. package/lib-cjs/Constants/HelpStrings.d.ts +3 -3
  34. package/lib-cjs/Constants/HelpStrings.js +3 -3
  35. package/lib-cjs/Constants/HelpStrings.js.map +1 -1
  36. package/lib-cjs/HttpClient/CliHttpClient.d.ts.map +1 -1
  37. package/lib-cjs/HttpClient/CliHttpClient.js +8 -2
  38. package/lib-cjs/HttpClient/CliHttpClient.js.map +1 -1
  39. package/lib-cjs/Verbs/AddDataSource.d.ts.map +1 -1
  40. package/lib-cjs/Verbs/AddDataSource.js +7 -6
  41. package/lib-cjs/Verbs/AddDataSource.js.map +1 -1
  42. package/lib-cjs/Verbs/DeleteDataSource.d.ts +1 -1
  43. package/lib-cjs/Verbs/DeleteDataSource.d.ts.map +1 -1
  44. package/lib-cjs/Verbs/DeleteDataSource.js +5 -1
  45. package/lib-cjs/Verbs/DeleteDataSource.js.map +1 -1
  46. package/lib-cjs/Verbs/ListConnectionReferences.js +6 -6
  47. package/lib-cjs/Verbs/ListConnectionReferences.js.map +1 -1
  48. package/lib-cjs/Verbs/ListEnvironmentVariables.js +6 -6
  49. package/lib-cjs/Verbs/ListEnvironmentVariables.js.map +1 -1
  50. package/lib-cjs/Verbs/Push.js +11 -16
  51. package/lib-cjs/Verbs/Push.js.map +1 -1
  52. package/lib-cjs/Verbs/VerbConstants.d.ts +1 -1
  53. package/lib-cjs/Verbs/VerbConstants.js +3 -3
  54. package/lib-cjs/Verbs/VerbConstants.js.map +1 -1
  55. package/lib-cjs/__tests__/E2eTests/addAndDeleteDataverseDS.test.js +3 -2
  56. package/lib-cjs/__tests__/E2eTests/addAndDeleteDataverseDS.test.js.map +1 -1
  57. package/lib-cjs/__tests__/E2eTests/addTop10Datasources.test.js +2 -1
  58. package/lib-cjs/__tests__/E2eTests/addTop10Datasources.test.js.map +1 -1
  59. package/lib-cjs/__tests__/E2eTests/cliHelp.test.js +4 -11
  60. package/lib-cjs/__tests__/E2eTests/cliHelp.test.js.map +1 -1
  61. package/lib-cjs/__tests__/helpers/e2eTestHelpers.d.ts +23 -0
  62. package/lib-cjs/__tests__/helpers/e2eTestHelpers.d.ts.map +1 -0
  63. package/lib-cjs/__tests__/helpers/e2eTestHelpers.js +31 -0
  64. package/lib-cjs/__tests__/helpers/e2eTestHelpers.js.map +1 -0
  65. package/node_modules/@microsoft/powerapps-data/package.json +2 -2
  66. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/PushApp.js +10 -3
  67. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/PushApp.js.map +1 -1
  68. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/codeGenUtils.d.ts +20 -0
  69. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/codeGenUtils.d.ts.map +1 -1
  70. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/codeGenUtils.js +79 -0
  71. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/codeGenUtils.js.map +1 -1
  72. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/dataSourceInfoProcessor.d.ts +2 -2
  73. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/dataSourceInfoProcessor.d.ts.map +1 -1
  74. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/dataSourceInfoProcessor.js +27 -68
  75. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/dataSourceInfoProcessor.js.map +1 -1
  76. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/modelServiceGenerator.d.ts +0 -59
  77. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/modelServiceGenerator.d.ts.map +1 -1
  78. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/modelServiceGenerator.js +69 -281
  79. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/modelServiceGenerator.js.map +1 -1
  80. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/nameUtility.d.ts +26 -0
  81. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/nameUtility.d.ts.map +1 -1
  82. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/nameUtility.js +153 -0
  83. package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/nameUtility.js.map +1 -1
  84. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/AzureDevOpsModelServiceGenerator.spec.d.ts +5 -0
  85. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/AzureDevOpsModelServiceGenerator.spec.d.ts.map +1 -0
  86. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/AzureDevOpsModelServiceGenerator.spec.js +93 -0
  87. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/AzureDevOpsModelServiceGenerator.spec.js.map +1 -0
  88. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/DataSourceInfoProcessor.spec.js +897 -2
  89. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/DataSourceInfoProcessor.spec.js.map +1 -1
  90. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/ModelServiceGenerator.spec.js +1 -17
  91. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/ModelServiceGenerator.spec.js.map +1 -1
  92. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/arrayTypeGeneration.spec.d.ts +5 -0
  93. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/arrayTypeGeneration.spec.d.ts.map +1 -0
  94. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/arrayTypeGeneration.spec.js +63 -0
  95. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/arrayTypeGeneration.spec.js.map +1 -0
  96. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/PushApp.js +9 -4
  97. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/PushApp.js.map +1 -1
  98. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/codeGenUtils.d.ts +20 -0
  99. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/codeGenUtils.d.ts.map +1 -1
  100. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/codeGenUtils.js +86 -1
  101. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/codeGenUtils.js.map +1 -1
  102. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/dataSourceInfoProcessor.d.ts +2 -2
  103. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/dataSourceInfoProcessor.d.ts.map +1 -1
  104. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/dataSourceInfoProcessor.js +25 -67
  105. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/dataSourceInfoProcessor.js.map +1 -1
  106. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.d.ts +0 -59
  107. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.d.ts.map +1 -1
  108. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.js +65 -279
  109. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.js.map +1 -1
  110. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/nameUtility.d.ts +26 -0
  111. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/nameUtility.d.ts.map +1 -1
  112. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/nameUtility.js +161 -1
  113. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/nameUtility.js.map +1 -1
  114. package/node_modules/@microsoft/{powerapps-data/lib/components/codeGen/dataSourceInfo.js → powerapps-player-actions/lib-cjs/__tests__/AzureDevOpsModelServiceGenerator.spec.d.ts} +0 -1
  115. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/AzureDevOpsModelServiceGenerator.spec.d.ts.map +1 -0
  116. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/AzureDevOpsModelServiceGenerator.spec.js +206 -0
  117. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/AzureDevOpsModelServiceGenerator.spec.js.map +1 -0
  118. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/DataSourceInfoProcessor.spec.js +1277 -1
  119. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/DataSourceInfoProcessor.spec.js.map +1 -1
  120. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/ModelServiceGenerator.spec.js +0 -32
  121. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/ModelServiceGenerator.spec.js.map +1 -1
  122. package/node_modules/@microsoft/{powerapps-data/lib/__tests__/dataSourceInfoProcessor.test.d.ts → powerapps-player-actions/lib-cjs/__tests__/arrayTypeGeneration.spec.d.ts} +0 -1
  123. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/arrayTypeGeneration.spec.d.ts.map +1 -0
  124. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/arrayTypeGeneration.spec.js +171 -0
  125. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/arrayTypeGeneration.spec.js.map +1 -0
  126. package/node_modules/@microsoft/powerapps-player-actions/package.json +2 -2
  127. package/node_modules/@pa-client/powerapps-player-services/package.json +1 -1
  128. package/package.json +4 -4
  129. package/node_modules/@microsoft/powerapps-data/lib/__tests__/dataSourceInfoProcessor.test.d.ts.map +0 -1
  130. package/node_modules/@microsoft/powerapps-data/lib/__tests__/dataSourceInfoProcessor.test.js +0 -782
  131. package/node_modules/@microsoft/powerapps-data/lib/__tests__/dataSourceInfoProcessor.test.js.map +0 -1
  132. package/node_modules/@microsoft/powerapps-data/lib/components/codeGen/dataSourceInfo.d.ts +0 -28
  133. package/node_modules/@microsoft/powerapps-data/lib/components/codeGen/dataSourceInfo.d.ts.map +0 -1
  134. package/node_modules/@microsoft/powerapps-data/lib/components/codeGen/dataSourceInfo.js.map +0 -1
  135. package/node_modules/@microsoft/powerapps-data/lib/components/codeGen/dataSourceInfoProcessor.d.ts +0 -10
  136. package/node_modules/@microsoft/powerapps-data/lib/components/codeGen/dataSourceInfoProcessor.d.ts.map +0 -1
  137. package/node_modules/@microsoft/powerapps-data/lib/components/codeGen/dataSourceInfoProcessor.js +0 -530
  138. package/node_modules/@microsoft/powerapps-data/lib/components/codeGen/dataSourceInfoProcessor.js.map +0 -1
@@ -74,6 +74,21 @@ var Utils_1 = require("./Utils");
74
74
  var dataSourceInfoProcessor_1 = require("../CodeGen/dataSourceInfoProcessor");
75
75
  var globals_2 = require("@jest/globals");
76
76
  var Logger_mock_1 = require("./mocks/Logger.mock");
77
+ /**
78
+ * Parses the generated TypeScript content and returns the DataSourcesInfo object.
79
+ * This provides type-safe access to the generated data structure instead of fragile string checks.
80
+ * @param generatedContent The generated TypeScript file content
81
+ * @returns The parsed DataSourcesInfo object
82
+ */
83
+ function parseDataSourcesInfo(generatedContent) {
84
+ var jsonMatch = generatedContent.match(/export const dataSourcesInfo = ({[\s\S]*});?\s*$/);
85
+ if (!jsonMatch) {
86
+ throw new Error('Could not extract dataSourcesInfo from generated content');
87
+ }
88
+ // Remove trailing semicolon if present
89
+ var jsonStr = jsonMatch[1].replace(/;\s*$/, '');
90
+ return JSON.parse(jsonStr);
91
+ }
77
92
  function setupMockSchemas() {
78
93
  return __awaiter(this, void 0, void 0, function () {
79
94
  var basePath, sharepointSchema;
@@ -101,7 +116,7 @@ var localFilePaths = {
101
116
  codeGenPath: "".concat(baseTestDir, "\\src"),
102
117
  };
103
118
  var mockLogger = (0, Logger_mock_1.getMockLogger)();
104
- (0, globals_1.describe)('ModelServiceGenerator', function () {
119
+ (0, globals_1.describe)('dataSourceInfoProcessor with real schema files', function () {
105
120
  (0, globals_2.beforeAll)(function () { return __awaiter(void 0, void 0, void 0, function () {
106
121
  return __generator(this, function (_a) {
107
122
  switch (_a.label) {
@@ -153,4 +168,1265 @@ var mockLogger = (0, Logger_mock_1.getMockLogger)();
153
168
  }); });
154
169
  });
155
170
  });
171
+ (0, globals_1.describe)('dataSourceInfoProcessor with mocked schema files', function () {
172
+ (0, globals_1.beforeEach)(function () {
173
+ globals_1.jest.clearAllMocks();
174
+ mockVfs_1.default.reset();
175
+ (0, VfsManager_1.setVfs)(mockVfs_1.default);
176
+ });
177
+ (0, globals_1.afterEach)(function () {
178
+ (0, VfsManager_1.clearVfs)();
179
+ });
180
+ (0, globals_1.describe)('processDataSourceInfo', function () {
181
+ (0, globals_1.it)('should process empty folder without errors', function () { return __awaiter(void 0, void 0, void 0, function () {
182
+ var folderPath;
183
+ return __generator(this, function (_a) {
184
+ switch (_a.label) {
185
+ case 0:
186
+ folderPath = '/test/folder';
187
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
188
+ case 1:
189
+ _a.sent();
190
+ // Act & Assert
191
+ return [4 /*yield*/, (0, globals_2.expect)((0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)).resolves.not.toThrow()];
192
+ case 2:
193
+ // Act & Assert
194
+ _a.sent();
195
+ return [2 /*return*/];
196
+ }
197
+ });
198
+ }); });
199
+ (0, globals_1.it)('should process folder with JSON files and generate output', function () { return __awaiter(void 0, void 0, void 0, function () {
200
+ var folderPath, jsonContent, outputPath, outputExists;
201
+ return __generator(this, function (_a) {
202
+ switch (_a.label) {
203
+ case 0:
204
+ folderPath = '/test/folder';
205
+ jsonContent = JSON.stringify({
206
+ name: 'test-api',
207
+ type: 'Microsoft.PowerApps/apis',
208
+ properties: {
209
+ swagger: {
210
+ paths: {
211
+ '/test': {
212
+ get: {
213
+ operationId: 'GetTest',
214
+ responses: {
215
+ '200': {
216
+ description: 'Success',
217
+ },
218
+ },
219
+ },
220
+ },
221
+ },
222
+ },
223
+ },
224
+ });
225
+ // Setup mock file system
226
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
227
+ case 1:
228
+ // Setup mock file system
229
+ _a.sent();
230
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'test.json'), jsonContent)];
231
+ case 2:
232
+ _a.sent();
233
+ // Act
234
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
235
+ case 3:
236
+ // Act
237
+ _a.sent();
238
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
239
+ return [4 /*yield*/, mockVfs_1.default.exists(outputPath)];
240
+ case 4:
241
+ outputExists = _a.sent();
242
+ (0, globals_2.expect)(outputExists).toBe(true);
243
+ return [2 /*return*/];
244
+ }
245
+ });
246
+ }); });
247
+ (0, globals_1.it)('should handle file processing errors with file path context', function () { return __awaiter(void 0, void 0, void 0, function () {
248
+ var folderPath, invalidJsonContent;
249
+ return __generator(this, function (_a) {
250
+ switch (_a.label) {
251
+ case 0:
252
+ folderPath = '/test/folder';
253
+ invalidJsonContent = '{ invalid json';
254
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
255
+ case 1:
256
+ _a.sent();
257
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'invalid.json'), invalidJsonContent)];
258
+ case 2:
259
+ _a.sent();
260
+ // Act & Assert
261
+ return [4 /*yield*/, (0, globals_2.expect)((0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)).rejects.toThrow(/Error processing file.*invalid\.json/)];
262
+ case 3:
263
+ // Act & Assert
264
+ _a.sent();
265
+ return [2 /*return*/];
266
+ }
267
+ });
268
+ }); });
269
+ (0, globals_1.it)('should create output directory if it does not exist', function () { return __awaiter(void 0, void 0, void 0, function () {
270
+ var folderPath, outputDir, dirExists;
271
+ return __generator(this, function (_a) {
272
+ switch (_a.label) {
273
+ case 0:
274
+ folderPath = '/test/folder';
275
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
276
+ case 1:
277
+ _a.sent();
278
+ // Act
279
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
280
+ case 2:
281
+ // Act
282
+ _a.sent();
283
+ outputDir = mockVfs_1.default.join(folderPath, 'appschemas');
284
+ return [4 /*yield*/, mockVfs_1.default.exists(outputDir)];
285
+ case 3:
286
+ dirExists = _a.sent();
287
+ (0, globals_2.expect)(dirExists).toBe(true);
288
+ return [2 /*return*/];
289
+ }
290
+ });
291
+ }); });
292
+ });
293
+ (0, globals_1.describe)('Swagger API processing', function () {
294
+ (0, globals_1.it)('should process Microsoft.PowerApps/apis type with swagger paths', function () { return __awaiter(void 0, void 0, void 0, function () {
295
+ var folderPath, swaggerJson, outputPath, generatedContent, parsed, dataSource, getUsersApi, createUserApi;
296
+ var _a, _b, _c, _d, _e, _f;
297
+ return __generator(this, function (_g) {
298
+ switch (_g.label) {
299
+ case 0:
300
+ folderPath = '/test/folder';
301
+ swaggerJson = {
302
+ name: 'users-api',
303
+ type: 'Microsoft.PowerApps/apis',
304
+ properties: {
305
+ swagger: {
306
+ paths: {
307
+ '/users': {
308
+ get: {
309
+ operationId: 'GetUsers',
310
+ parameters: [
311
+ {
312
+ name: 'limit',
313
+ in: 'query',
314
+ required: false,
315
+ type: 'integer',
316
+ },
317
+ ],
318
+ responses: {
319
+ '200': {
320
+ description: 'Success',
321
+ schema: {
322
+ type: 'array',
323
+ },
324
+ },
325
+ },
326
+ },
327
+ post: {
328
+ operationId: 'CreateUser',
329
+ responses: {
330
+ '201': {
331
+ description: 'Created',
332
+ },
333
+ },
334
+ },
335
+ },
336
+ },
337
+ },
338
+ },
339
+ };
340
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
341
+ case 1:
342
+ _g.sent();
343
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'swagger.json'), JSON.stringify(swaggerJson))];
344
+ case 2:
345
+ _g.sent();
346
+ // Act
347
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
348
+ case 3:
349
+ // Act
350
+ _g.sent();
351
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
352
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
353
+ case 4:
354
+ generatedContent = _g.sent();
355
+ parsed = parseDataSourcesInfo(generatedContent);
356
+ // Verify the data source exists with sanitized name (hyphens become underscores)
357
+ (0, globals_2.expect)(parsed).toHaveProperty('users_api');
358
+ dataSource = parsed.users_api;
359
+ // Verify APIs are generated correctly
360
+ (0, globals_2.expect)(dataSource.apis).toHaveProperty('GetUsers');
361
+ (0, globals_2.expect)(dataSource.apis).toHaveProperty('CreateUser');
362
+ getUsersApi = dataSource.apis.GetUsers;
363
+ (0, globals_2.expect)(getUsersApi.path).toBe('/users');
364
+ (0, globals_2.expect)(getUsersApi.method).toBe('GET');
365
+ (0, globals_2.expect)(getUsersApi.parameters).toBeDefined();
366
+ (0, globals_2.expect)((_a = getUsersApi.parameters) === null || _a === void 0 ? void 0 : _a.length).toBe(1);
367
+ (0, globals_2.expect)((_b = getUsersApi.parameters) === null || _b === void 0 ? void 0 : _b[0].name).toBe('limit');
368
+ (0, globals_2.expect)((_d = (_c = getUsersApi.responseInfo) === null || _c === void 0 ? void 0 : _c['200']) === null || _d === void 0 ? void 0 : _d.type).toBe('array');
369
+ createUserApi = dataSource.apis.CreateUser;
370
+ (0, globals_2.expect)(createUserApi.path).toBe('/users');
371
+ (0, globals_2.expect)(createUserApi.method).toBe('POST');
372
+ (0, globals_2.expect)((_f = (_e = createUserApi.responseInfo) === null || _e === void 0 ? void 0 : _e['201']) === null || _f === void 0 ? void 0 : _f.type).toBe('void');
373
+ return [2 /*return*/];
374
+ }
375
+ });
376
+ }); });
377
+ (0, globals_1.it)('should handle swagger with parameter references', function () { return __awaiter(void 0, void 0, void 0, function () {
378
+ var folderPath, swaggerJson, outputPath, generatedContent;
379
+ return __generator(this, function (_a) {
380
+ switch (_a.label) {
381
+ case 0:
382
+ folderPath = '/test/folder';
383
+ swaggerJson = {
384
+ name: 'items-api',
385
+ type: 'Microsoft.PowerApps/apis',
386
+ properties: {
387
+ swagger: {
388
+ paths: {
389
+ '/items': {
390
+ get: {
391
+ operationId: 'GetItems',
392
+ parameters: [
393
+ {
394
+ $ref: '#/swagger/parameters/CommonParam',
395
+ },
396
+ ],
397
+ responses: {
398
+ '200': {
399
+ description: 'Success',
400
+ },
401
+ },
402
+ },
403
+ },
404
+ },
405
+ parameters: {
406
+ CommonParam: {
407
+ name: 'commonParam',
408
+ in: 'header',
409
+ required: true,
410
+ type: 'string',
411
+ },
412
+ },
413
+ },
414
+ },
415
+ };
416
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
417
+ case 1:
418
+ _a.sent();
419
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'swagger-ref.json'), JSON.stringify(swaggerJson))];
420
+ case 2:
421
+ _a.sent();
422
+ // Act
423
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
424
+ case 3:
425
+ // Act
426
+ _a.sent();
427
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
428
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
429
+ case 4:
430
+ generatedContent = _a.sent();
431
+ (0, globals_2.expect)(generatedContent).toContain('items_api');
432
+ (0, globals_2.expect)(generatedContent).toContain('GetItems');
433
+ return [2 /*return*/];
434
+ }
435
+ });
436
+ }); });
437
+ (0, globals_1.it)('should handle responses with schema references', function () { return __awaiter(void 0, void 0, void 0, function () {
438
+ var folderPath, swaggerJson, outputPath, generatedContent;
439
+ return __generator(this, function (_a) {
440
+ switch (_a.label) {
441
+ case 0:
442
+ folderPath = '/test/folder';
443
+ swaggerJson = {
444
+ name: 'models-api',
445
+ type: 'Microsoft.PowerApps/apis',
446
+ properties: {
447
+ swagger: {
448
+ paths: {
449
+ '/models': {
450
+ get: {
451
+ operationId: 'GetModels',
452
+ responses: {
453
+ '200': {
454
+ description: 'Success',
455
+ schema: {
456
+ $ref: '#/definitions/ModelResponse',
457
+ },
458
+ },
459
+ },
460
+ },
461
+ },
462
+ },
463
+ definitions: {
464
+ ModelResponse: {
465
+ type: 'object',
466
+ },
467
+ },
468
+ },
469
+ },
470
+ };
471
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
472
+ case 1:
473
+ _a.sent();
474
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'models.json'), JSON.stringify(swaggerJson))];
475
+ case 2:
476
+ _a.sent();
477
+ // Act
478
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
479
+ case 3:
480
+ // Act
481
+ _a.sent();
482
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
483
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
484
+ case 4:
485
+ generatedContent = _a.sent();
486
+ (0, globals_2.expect)(generatedContent).toContain('GetModels');
487
+ (0, globals_2.expect)(generatedContent).toContain('"type": "object"');
488
+ return [2 /*return*/];
489
+ }
490
+ });
491
+ }); });
492
+ });
493
+ (0, globals_1.describe)('SQL stored procedure processing', function () {
494
+ (0, globals_1.it)('should process SQL stored procedure with input parameters', function () { return __awaiter(void 0, void 0, void 0, function () {
495
+ var folderPath, procedureJson, outputPath, generatedContent, parsed, dataSource, procApi, paramNames;
496
+ var _a, _b;
497
+ return __generator(this, function (_c) {
498
+ switch (_c.label) {
499
+ case 0:
500
+ folderPath = '/test/procedures/GetUserById';
501
+ procedureJson = {
502
+ name: '[dbo].[GetUserById]',
503
+ schema: {
504
+ procedureresultschema: {
505
+ type: 'object',
506
+ },
507
+ inputparameters: {
508
+ properties: {
509
+ UserId: {
510
+ type: 'integer',
511
+ required: true,
512
+ },
513
+ IncludeDetails: {
514
+ type: 'boolean',
515
+ required: false,
516
+ },
517
+ },
518
+ },
519
+ },
520
+ };
521
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
522
+ case 1:
523
+ _c.sent();
524
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'procedure.json'), JSON.stringify(procedureJson))];
525
+ case 2:
526
+ _c.sent();
527
+ // Act
528
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
529
+ case 3:
530
+ // Act
531
+ _c.sent();
532
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
533
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
534
+ case 4:
535
+ generatedContent = _c.sent();
536
+ parsed = parseDataSourcesInfo(generatedContent);
537
+ // Verify the data source exists (uses parent folder name as key)
538
+ (0, globals_2.expect)(parsed).toHaveProperty('getuserbyid');
539
+ dataSource = parsed.getuserbyid;
540
+ // Verify the stored procedure API
541
+ (0, globals_2.expect)(dataSource.apis).toHaveProperty('GetUserById');
542
+ procApi = dataSource.apis.GetUserById;
543
+ (0, globals_2.expect)(procApi.path).toBe('/dbo.GetUserById');
544
+ (0, globals_2.expect)(procApi.method).toBe('POST');
545
+ // Verify parameters are present
546
+ (0, globals_2.expect)(procApi.parameters).toBeDefined();
547
+ paramNames = (_b = (_a = procApi.parameters) === null || _a === void 0 ? void 0 : _a.map(function (p) { return p.name; })) !== null && _b !== void 0 ? _b : [];
548
+ (0, globals_2.expect)(paramNames).toContain('UserId');
549
+ (0, globals_2.expect)(paramNames).toContain('IncludeDetails');
550
+ return [2 /*return*/];
551
+ }
552
+ });
553
+ }); });
554
+ (0, globals_1.it)('should handle stored procedure without input parameters', function () { return __awaiter(void 0, void 0, void 0, function () {
555
+ var folderPath, procedureJson, outputPath, generatedContent;
556
+ return __generator(this, function (_a) {
557
+ switch (_a.label) {
558
+ case 0:
559
+ folderPath = '/test/procedures/GetAllUsers';
560
+ procedureJson = {
561
+ name: '[dbo].[GetAllUsers]',
562
+ schema: {
563
+ procedureresultschema: {
564
+ type: 'array',
565
+ },
566
+ },
567
+ };
568
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
569
+ case 1:
570
+ _a.sent();
571
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'procedure.json'), JSON.stringify(procedureJson))];
572
+ case 2:
573
+ _a.sent();
574
+ // Act
575
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
576
+ case 3:
577
+ // Act
578
+ _a.sent();
579
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
580
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
581
+ case 4:
582
+ generatedContent = _a.sent();
583
+ (0, globals_2.expect)(generatedContent).toContain('getallusers');
584
+ (0, globals_2.expect)(generatedContent).toContain('"/dbo.GetAllUsers"');
585
+ return [2 /*return*/];
586
+ }
587
+ });
588
+ }); });
589
+ (0, globals_1.it)('should determine property key from parent folder for stored procedures', function () { return __awaiter(void 0, void 0, void 0, function () {
590
+ var folderPath, procedureJson, outputPath, generatedContent;
591
+ return __generator(this, function (_a) {
592
+ switch (_a.label) {
593
+ case 0:
594
+ folderPath = '/test/procedures/UserProcedures';
595
+ procedureJson = {
596
+ name: '[dbo].[GetUser]',
597
+ schema: {
598
+ procedureresultschema: {
599
+ type: 'object',
600
+ },
601
+ },
602
+ };
603
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
604
+ case 1:
605
+ _a.sent();
606
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'procedure.json'), JSON.stringify(procedureJson))];
607
+ case 2:
608
+ _a.sent();
609
+ // Act
610
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
611
+ case 3:
612
+ // Act
613
+ _a.sent();
614
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
615
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
616
+ case 4:
617
+ generatedContent = _a.sent();
618
+ (0, globals_2.expect)(generatedContent).toContain('userprocedures');
619
+ return [2 /*return*/];
620
+ }
621
+ });
622
+ }); });
623
+ (0, globals_1.it)('should handle non-dbo schemas', function () { return __awaiter(void 0, void 0, void 0, function () {
624
+ var folderPath, procedureJson, outputPath, generatedContent;
625
+ return __generator(this, function (_a) {
626
+ switch (_a.label) {
627
+ case 0:
628
+ folderPath = '/test/procedures/GetAllUsers';
629
+ procedureJson = {
630
+ name: '[foo].[GetAllUsers]',
631
+ schema: {
632
+ procedureresultschema: {
633
+ type: 'array',
634
+ },
635
+ },
636
+ };
637
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
638
+ case 1:
639
+ _a.sent();
640
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'procedure.json'), JSON.stringify(procedureJson))];
641
+ case 2:
642
+ _a.sent();
643
+ // Act
644
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
645
+ case 3:
646
+ // Act
647
+ _a.sent();
648
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
649
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
650
+ case 4:
651
+ generatedContent = _a.sent();
652
+ (0, globals_2.expect)(generatedContent).toContain('getallusers');
653
+ (0, globals_2.expect)(generatedContent).toContain('"/foo.GetAllUsers"');
654
+ return [2 /*return*/];
655
+ }
656
+ });
657
+ }); });
658
+ });
659
+ (0, globals_1.describe)('SQL table processing', function () {
660
+ (0, globals_1.it)('should process SQL table schema with primary key', function () { return __awaiter(void 0, void 0, void 0, function () {
661
+ var folderPath, tableJson, outputPath, generatedContent, parsed, expectedKey, dataSource;
662
+ return __generator(this, function (_a) {
663
+ switch (_a.label) {
664
+ case 0:
665
+ folderPath = '/test/tables';
666
+ tableJson = {
667
+ name: '[dbo].[Users]',
668
+ schema: {
669
+ items: {
670
+ properties: {
671
+ Id: {
672
+ type: 'integer',
673
+ 'x-ms-keyType': 'primary',
674
+ },
675
+ Name: {
676
+ type: 'string',
677
+ },
678
+ Email: {
679
+ type: 'string',
680
+ },
681
+ },
682
+ },
683
+ },
684
+ };
685
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
686
+ case 1:
687
+ _a.sent();
688
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'users.json'), JSON.stringify(tableJson))];
689
+ case 2:
690
+ _a.sent();
691
+ // Act
692
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
693
+ case 3:
694
+ // Act
695
+ _a.sent();
696
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
697
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
698
+ case 4:
699
+ generatedContent = _a.sent();
700
+ parsed = parseDataSourcesInfo(generatedContent);
701
+ expectedKey = '_dbo___users_';
702
+ (0, globals_2.expect)(parsed).toHaveProperty(expectedKey);
703
+ dataSource = parsed[expectedKey];
704
+ // Verify SQL table properties - tableId gets the cleaned name from sanitizeSqlName
705
+ (0, globals_2.expect)(dataSource.tableId).toBe('Users');
706
+ (0, globals_2.expect)(dataSource.version).toBe('v2');
707
+ (0, globals_2.expect)(dataSource.primaryKey).toBe('Id');
708
+ (0, globals_2.expect)(dataSource.dataSourceType).toBe('Connector');
709
+ return [2 /*return*/];
710
+ }
711
+ });
712
+ }); });
713
+ (0, globals_1.it)('should handle table without primary key', function () { return __awaiter(void 0, void 0, void 0, function () {
714
+ var folderPath, tableJson, outputPath, generatedContent, parsed, expectedKey, dataSource;
715
+ return __generator(this, function (_a) {
716
+ switch (_a.label) {
717
+ case 0:
718
+ folderPath = '/test/sql/tables';
719
+ tableJson = {
720
+ name: '[dbo].[Logs]',
721
+ schema: {
722
+ items: {
723
+ properties: {
724
+ Message: {
725
+ type: 'string',
726
+ },
727
+ Timestamp: {
728
+ type: 'string',
729
+ },
730
+ },
731
+ },
732
+ },
733
+ };
734
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
735
+ case 1:
736
+ _a.sent();
737
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'logs.json'), JSON.stringify(tableJson))];
738
+ case 2:
739
+ _a.sent();
740
+ // Act
741
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
742
+ case 3:
743
+ // Act
744
+ _a.sent();
745
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
746
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
747
+ case 4:
748
+ generatedContent = _a.sent();
749
+ parsed = parseDataSourcesInfo(generatedContent);
750
+ expectedKey = 'logs';
751
+ (0, globals_2.expect)(parsed).toHaveProperty(expectedKey);
752
+ dataSource = parsed[expectedKey];
753
+ // Verify primary key is empty when not specified
754
+ (0, globals_2.expect)(dataSource.tableId).toBe('Logs');
755
+ (0, globals_2.expect)(dataSource.primaryKey).toBe('');
756
+ return [2 /*return*/];
757
+ }
758
+ });
759
+ }); });
760
+ });
761
+ (0, globals_1.describe)('Property key determination', function () {
762
+ (0, globals_1.it)('should remove [dbo]. prefix and brackets from SQL table names', function () { return __awaiter(void 0, void 0, void 0, function () {
763
+ var folderPath, tableJson, outputPath, generatedContent;
764
+ return __generator(this, function (_a) {
765
+ switch (_a.label) {
766
+ case 0:
767
+ folderPath = '/test/tables';
768
+ tableJson = {
769
+ name: '[dbo].[ComplexTableName]',
770
+ schema: {
771
+ items: {
772
+ properties: {},
773
+ },
774
+ },
775
+ };
776
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
777
+ case 1:
778
+ _a.sent();
779
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'table.json'), JSON.stringify(tableJson))];
780
+ case 2:
781
+ _a.sent();
782
+ // Act
783
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
784
+ case 3:
785
+ // Act
786
+ _a.sent();
787
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
788
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
789
+ case 4:
790
+ generatedContent = _a.sent();
791
+ (0, globals_2.expect)(generatedContent).toContain('ComplexTableName');
792
+ return [2 /*return*/];
793
+ }
794
+ });
795
+ }); });
796
+ (0, globals_1.it)('should remove [custom_schema]. prefix and brackets from SQL table names', function () { return __awaiter(void 0, void 0, void 0, function () {
797
+ var folderPath, tableJson, outputPath, generatedContent;
798
+ return __generator(this, function (_a) {
799
+ switch (_a.label) {
800
+ case 0:
801
+ folderPath = '/test/tables';
802
+ tableJson = {
803
+ name: '[custom_schema].[ComplexTableName]',
804
+ schema: {
805
+ items: {
806
+ properties: {},
807
+ },
808
+ },
809
+ };
810
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
811
+ case 1:
812
+ _a.sent();
813
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'table.json'), JSON.stringify(tableJson))];
814
+ case 2:
815
+ _a.sent();
816
+ // Act
817
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
818
+ case 3:
819
+ // Act
820
+ _a.sent();
821
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
822
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
823
+ case 4:
824
+ generatedContent = _a.sent();
825
+ (0, globals_2.expect)(generatedContent).toContain('ComplexTableName');
826
+ return [2 /*return*/];
827
+ }
828
+ });
829
+ }); });
830
+ (0, globals_1.it)('should remove shared_ prefix from non-tabular names', function () { return __awaiter(void 0, void 0, void 0, function () {
831
+ var folderPath, sharedJson, outputPath, generatedContent;
832
+ return __generator(this, function (_a) {
833
+ switch (_a.label) {
834
+ case 0:
835
+ folderPath = '/test/shared';
836
+ sharedJson = {
837
+ name: 'shared_commonservice',
838
+ properties: {
839
+ displayName: 'CommonService',
840
+ },
841
+ schema: {
842
+ type: 'object',
843
+ },
844
+ };
845
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
846
+ case 1:
847
+ _a.sent();
848
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'service.json'), JSON.stringify(sharedJson))];
849
+ case 2:
850
+ _a.sent();
851
+ // Act
852
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
853
+ case 3:
854
+ // Act
855
+ _a.sent();
856
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
857
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
858
+ case 4:
859
+ generatedContent = _a.sent();
860
+ (0, globals_2.expect)(generatedContent).toContain('commonservice');
861
+ return [2 /*return*/];
862
+ }
863
+ });
864
+ }); });
865
+ (0, globals_1.it)('should use title property when available', function () { return __awaiter(void 0, void 0, void 0, function () {
866
+ var folderPath, tabularJson, outputPath, generatedContent;
867
+ return __generator(this, function (_a) {
868
+ switch (_a.label) {
869
+ case 0:
870
+ folderPath = '/test/tabular';
871
+ tabularJson = {
872
+ title: 'UserManagement',
873
+ name: 'internal_name',
874
+ schema: {
875
+ type: 'object',
876
+ },
877
+ };
878
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
879
+ case 1:
880
+ _a.sent();
881
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'service.json'), JSON.stringify(tabularJson))];
882
+ case 2:
883
+ _a.sent();
884
+ // Act
885
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
886
+ case 3:
887
+ // Act
888
+ _a.sent();
889
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
890
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
891
+ case 4:
892
+ generatedContent = _a.sent();
893
+ (0, globals_2.expect)(generatedContent).toContain('internal_name');
894
+ return [2 /*return*/];
895
+ }
896
+ });
897
+ }); });
898
+ (0, globals_1.it)('should fallback to filename when name property is missing', function () { return __awaiter(void 0, void 0, void 0, function () {
899
+ var folderPath, jsonWithoutName, outputPath, generatedContent, parsed, expectedKey;
900
+ return __generator(this, function (_a) {
901
+ switch (_a.label) {
902
+ case 0:
903
+ folderPath = '/test/fallback';
904
+ jsonWithoutName = {
905
+ schema: {
906
+ type: 'object',
907
+ },
908
+ };
909
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
910
+ case 1:
911
+ _a.sent();
912
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'FallbackService.Schema.json'), JSON.stringify(jsonWithoutName))];
913
+ case 2:
914
+ _a.sent();
915
+ // Act
916
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
917
+ case 3:
918
+ // Act
919
+ _a.sent();
920
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
921
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
922
+ case 4:
923
+ generatedContent = _a.sent();
924
+ parsed = parseDataSourcesInfo(generatedContent);
925
+ expectedKey = 'fallbackservice.schema';
926
+ (0, globals_2.expect)(parsed).toHaveProperty([expectedKey]);
927
+ return [2 /*return*/];
928
+ }
929
+ });
930
+ }); });
931
+ (0, globals_1.it)('should handle names with spaces and underscores', function () { return __awaiter(void 0, void 0, void 0, function () {
932
+ var folderPath, complexNameJson, outputPath, generatedContent;
933
+ return __generator(this, function (_a) {
934
+ switch (_a.label) {
935
+ case 0:
936
+ folderPath = '/test/complexnames';
937
+ complexNameJson = {
938
+ name: ' Complex_Name With Spaces ',
939
+ title: ' Complex_Name With Spaces ',
940
+ schema: {
941
+ type: 'object',
942
+ },
943
+ };
944
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
945
+ case 1:
946
+ _a.sent();
947
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'complex.json'), JSON.stringify(complexNameJson))];
948
+ case 2:
949
+ _a.sent();
950
+ // Act
951
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
952
+ case 3:
953
+ // Act
954
+ _a.sent();
955
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
956
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
957
+ case 4:
958
+ generatedContent = _a.sent();
959
+ // Keys are now lowercase
960
+ (0, globals_2.expect)(generatedContent).toContain('complex_namewithspaces');
961
+ return [2 /*return*/];
962
+ }
963
+ });
964
+ }); });
965
+ (0, globals_1.it)('should use name property for SharePoint list with underscores and hyphens', function () { return __awaiter(void 0, void 0, void 0, function () {
966
+ var folderPath, sharepointListJson, outputPath, generatedContent, parsed, expectedKey, dataSource;
967
+ return __generator(this, function (_a) {
968
+ switch (_a.label) {
969
+ case 0:
970
+ folderPath = '/test/sharepointspecialname';
971
+ sharepointListJson = {
972
+ name: 'PaKeMpar_list with underscores-and hype-ns',
973
+ title: 'PaKeMpar_list with underscores-and hype-ns',
974
+ 'x-ms-permission': 'read-write',
975
+ 'x-ms-capabilities': {
976
+ sortRestrictions: {
977
+ sortable: true,
978
+ unsortableProperties: [],
979
+ },
980
+ },
981
+ schema: {
982
+ type: 'array',
983
+ items: {
984
+ type: 'object',
985
+ properties: {
986
+ ID: {
987
+ title: 'ID',
988
+ type: 'integer',
989
+ 'x-ms-keyType': 'primary',
990
+ },
991
+ Title: {
992
+ title: 'Title',
993
+ type: 'string',
994
+ },
995
+ },
996
+ },
997
+ },
998
+ referencedEntities: {
999
+ Author: {
1000
+ lookupEndpoint: {
1001
+ path: '/tables/e34fc1b5-7e29-473a-9863-553afa820351/entities/Author',
1002
+ },
1003
+ },
1004
+ Editor: {
1005
+ lookupEndpoint: {
1006
+ path: '/tables/e34fc1b5-7e29-473a-9863-553afa820351/entities/Editor',
1007
+ },
1008
+ },
1009
+ },
1010
+ };
1011
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
1012
+ case 1:
1013
+ _a.sent();
1014
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'speciallist.json'), JSON.stringify(sharepointListJson))];
1015
+ case 2:
1016
+ _a.sent();
1017
+ // Act
1018
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
1019
+ case 3:
1020
+ // Act
1021
+ _a.sent();
1022
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
1023
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
1024
+ case 4:
1025
+ generatedContent = _a.sent();
1026
+ parsed = parseDataSourcesInfo(generatedContent);
1027
+ expectedKey = 'pakempar_listwithunderscores_andhype_ns';
1028
+ (0, globals_2.expect)(parsed).toHaveProperty(expectedKey);
1029
+ dataSource = parsed[expectedKey];
1030
+ // tableId should preserve the original name from the schema
1031
+ (0, globals_2.expect)(dataSource.tableId).toBe('PaKeMpar_list with underscores-and hype-ns');
1032
+ (0, globals_2.expect)(dataSource.primaryKey).toBe('ID');
1033
+ (0, globals_2.expect)(dataSource.dataSourceType).toBe('Connector');
1034
+ // Should have APIs generated from referencedEntities
1035
+ (0, globals_2.expect)(dataSource.apis).toHaveProperty('GetAuthor');
1036
+ (0, globals_2.expect)(dataSource.apis).toHaveProperty('GetEditor');
1037
+ // Verify API paths have GUIDs without hyphens
1038
+ (0, globals_2.expect)(dataSource.apis.GetAuthor.path).toContain('e34fc1b57e29473a9863553afa820351');
1039
+ return [2 /*return*/];
1040
+ }
1041
+ });
1042
+ }); });
1043
+ });
1044
+ (0, globals_1.describe)('Merge functionality', function () {
1045
+ (0, globals_1.it)('should merge APIs when processing multiple files for same data source', function () { return __awaiter(void 0, void 0, void 0, function () {
1046
+ var folderPath, api1Json, api2Json, outputPath, generatedContent;
1047
+ return __generator(this, function (_a) {
1048
+ switch (_a.label) {
1049
+ case 0:
1050
+ folderPath = '/test/merge';
1051
+ api1Json = {
1052
+ name: 'shared_testservice',
1053
+ type: 'Microsoft.PowerApps/apis',
1054
+ properties: {
1055
+ displayName: 'TestService',
1056
+ swagger: {
1057
+ paths: {
1058
+ '/api1': {
1059
+ get: {
1060
+ operationId: 'GetApi1',
1061
+ responses: { '200': { description: 'Success' } },
1062
+ },
1063
+ },
1064
+ },
1065
+ },
1066
+ },
1067
+ };
1068
+ api2Json = {
1069
+ name: 'shared_testservice',
1070
+ type: 'Microsoft.PowerApps/apis',
1071
+ properties: {
1072
+ displayName: 'TestService',
1073
+ swagger: {
1074
+ paths: {
1075
+ '/api2': {
1076
+ post: {
1077
+ operationId: 'PostApi2',
1078
+ responses: { '201': { description: 'Created' } },
1079
+ },
1080
+ },
1081
+ },
1082
+ },
1083
+ },
1084
+ };
1085
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
1086
+ case 1:
1087
+ _a.sent();
1088
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'api1.json'), JSON.stringify(api1Json))];
1089
+ case 2:
1090
+ _a.sent();
1091
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'api2.json'), JSON.stringify(api2Json))];
1092
+ case 3:
1093
+ _a.sent();
1094
+ // Act
1095
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
1096
+ case 4:
1097
+ // Act
1098
+ _a.sent();
1099
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
1100
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
1101
+ case 5:
1102
+ generatedContent = _a.sent();
1103
+ (0, globals_2.expect)(generatedContent).toContain('GetApi1');
1104
+ (0, globals_2.expect)(generatedContent).toContain('PostApi2');
1105
+ (0, globals_2.expect)(generatedContent).toContain('testservice');
1106
+ return [2 /*return*/];
1107
+ }
1108
+ });
1109
+ }); });
1110
+ (0, globals_1.it)('should handle duplicate stored procedures gracefully', function () { return __awaiter(void 0, void 0, void 0, function () {
1111
+ var folderPath, procedureJson;
1112
+ return __generator(this, function (_a) {
1113
+ switch (_a.label) {
1114
+ case 0:
1115
+ folderPath = '/test/duplicate';
1116
+ procedureJson = {
1117
+ name: '[dbo].[DuplicateProc]',
1118
+ schema: {
1119
+ procedureresultschema: { type: 'object' },
1120
+ },
1121
+ };
1122
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
1123
+ case 1:
1124
+ _a.sent();
1125
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'proc1.json'), JSON.stringify(procedureJson))];
1126
+ case 2:
1127
+ _a.sent();
1128
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'proc2.json'), JSON.stringify(procedureJson))];
1129
+ case 3:
1130
+ _a.sent();
1131
+ // Act & Assert
1132
+ // Note: The current implementation merges APIs instead of throwing an error
1133
+ // This test verifies that duplicate stored procedures are handled gracefully
1134
+ return [4 /*yield*/, (0, globals_2.expect)((0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)).resolves.not.toThrow()];
1135
+ case 4:
1136
+ // Act & Assert
1137
+ // Note: The current implementation merges APIs instead of throwing an error
1138
+ // This test verifies that duplicate stored procedures are handled gracefully
1139
+ _a.sent();
1140
+ return [2 /*return*/];
1141
+ }
1142
+ });
1143
+ }); });
1144
+ });
1145
+ (0, globals_1.describe)('Response processing', function () {
1146
+ (0, globals_1.it)('should handle array responses correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
1147
+ var folderPath, swaggerJson, outputPath, generatedContent, parsed, dataSource, getArrayApi;
1148
+ var _a, _b, _c, _d;
1149
+ return __generator(this, function (_e) {
1150
+ switch (_e.label) {
1151
+ case 0:
1152
+ folderPath = '/test/responses';
1153
+ swaggerJson = {
1154
+ name: 'array-api',
1155
+ type: 'Microsoft.PowerApps/apis',
1156
+ properties: {
1157
+ swagger: {
1158
+ paths: {
1159
+ '/array-endpoint': {
1160
+ get: {
1161
+ operationId: 'GetArray',
1162
+ responses: {
1163
+ '200': {
1164
+ description: 'Success',
1165
+ schema: {
1166
+ type: 'array',
1167
+ format: 'custom',
1168
+ },
1169
+ },
1170
+ },
1171
+ },
1172
+ },
1173
+ },
1174
+ },
1175
+ },
1176
+ };
1177
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
1178
+ case 1:
1179
+ _e.sent();
1180
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'array-response.json'), JSON.stringify(swaggerJson))];
1181
+ case 2:
1182
+ _e.sent();
1183
+ // Act
1184
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
1185
+ case 3:
1186
+ // Act
1187
+ _e.sent();
1188
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
1189
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
1190
+ case 4:
1191
+ generatedContent = _e.sent();
1192
+ parsed = parseDataSourcesInfo(generatedContent);
1193
+ // Verify the data source exists with sanitized name
1194
+ (0, globals_2.expect)(parsed).toHaveProperty('array_api');
1195
+ dataSource = parsed.array_api;
1196
+ getArrayApi = dataSource.apis.GetArray;
1197
+ (0, globals_2.expect)((_b = (_a = getArrayApi.responseInfo) === null || _a === void 0 ? void 0 : _a['200']) === null || _b === void 0 ? void 0 : _b.type).toBe('array');
1198
+ (0, globals_2.expect)((_d = (_c = getArrayApi.responseInfo) === null || _c === void 0 ? void 0 : _c['200']) === null || _d === void 0 ? void 0 : _d.format).toBe('custom');
1199
+ return [2 /*return*/];
1200
+ }
1201
+ });
1202
+ }); });
1203
+ (0, globals_1.it)('should handle void responses when no schema provided', function () { return __awaiter(void 0, void 0, void 0, function () {
1204
+ var folderPath, swaggerJson, outputPath, generatedContent, parsed, dataSource, deleteApi;
1205
+ var _a, _b;
1206
+ return __generator(this, function (_c) {
1207
+ switch (_c.label) {
1208
+ case 0:
1209
+ folderPath = '/test/responses';
1210
+ swaggerJson = {
1211
+ name: 'void-api',
1212
+ type: 'Microsoft.PowerApps/apis',
1213
+ properties: {
1214
+ swagger: {
1215
+ paths: {
1216
+ '/void-endpoint': {
1217
+ delete: {
1218
+ operationId: 'DeleteItem',
1219
+ responses: {
1220
+ '204': {
1221
+ description: 'No Content',
1222
+ },
1223
+ },
1224
+ },
1225
+ },
1226
+ },
1227
+ },
1228
+ },
1229
+ };
1230
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
1231
+ case 1:
1232
+ _c.sent();
1233
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'void-response.json'), JSON.stringify(swaggerJson))];
1234
+ case 2:
1235
+ _c.sent();
1236
+ // Act
1237
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
1238
+ case 3:
1239
+ // Act
1240
+ _c.sent();
1241
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
1242
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
1243
+ case 4:
1244
+ generatedContent = _c.sent();
1245
+ parsed = parseDataSourcesInfo(generatedContent);
1246
+ // Verify the data source exists with sanitized name
1247
+ (0, globals_2.expect)(parsed).toHaveProperty('void_api');
1248
+ dataSource = parsed.void_api;
1249
+ deleteApi = dataSource.apis.DeleteItem;
1250
+ (0, globals_2.expect)((_b = (_a = deleteApi.responseInfo) === null || _a === void 0 ? void 0 : _a['204']) === null || _b === void 0 ? void 0 : _b.type).toBe('void');
1251
+ return [2 /*return*/];
1252
+ }
1253
+ });
1254
+ }); });
1255
+ });
1256
+ (0, globals_1.describe)('Error handling', function () {
1257
+ (0, globals_1.it)('should throw descriptive error for invalid JSON structure', function () { return __awaiter(void 0, void 0, void 0, function () {
1258
+ var folderPath, invalidJson;
1259
+ return __generator(this, function (_a) {
1260
+ switch (_a.label) {
1261
+ case 0:
1262
+ folderPath = '/test/invalid';
1263
+ invalidJson = {
1264
+ invalidStructure: true,
1265
+ };
1266
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
1267
+ case 1:
1268
+ _a.sent();
1269
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'invalid.json'), JSON.stringify(invalidJson))];
1270
+ case 2:
1271
+ _a.sent();
1272
+ // Act & Assert
1273
+ return [4 /*yield*/, (0, globals_2.expect)((0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)).rejects.toThrow('The JSON does not represent a valid data source')];
1274
+ case 3:
1275
+ // Act & Assert
1276
+ _a.sent();
1277
+ return [2 /*return*/];
1278
+ }
1279
+ });
1280
+ }); });
1281
+ (0, globals_1.it)('should handle nested directory traversal', function () { return __awaiter(void 0, void 0, void 0, function () {
1282
+ var folderPath, subfolderPath, nestedJson, outputPath, outputExists;
1283
+ return __generator(this, function (_a) {
1284
+ switch (_a.label) {
1285
+ case 0:
1286
+ folderPath = '/test/nested';
1287
+ subfolderPath = mockVfs_1.default.join(folderPath, 'subfolder');
1288
+ nestedJson = {
1289
+ name: 'nested-service',
1290
+ schema: { type: 'object' },
1291
+ };
1292
+ return [4 /*yield*/, mockVfs_1.default.mkdir(subfolderPath, { recursive: true })];
1293
+ case 1:
1294
+ _a.sent();
1295
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(subfolderPath, 'nested.json'), JSON.stringify(nestedJson))];
1296
+ case 2:
1297
+ _a.sent();
1298
+ // Act
1299
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
1300
+ case 3:
1301
+ // Act
1302
+ _a.sent();
1303
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
1304
+ return [4 /*yield*/, mockVfs_1.default.exists(outputPath)];
1305
+ case 4:
1306
+ outputExists = _a.sent();
1307
+ (0, globals_2.expect)(outputExists).toBe(true);
1308
+ return [2 /*return*/];
1309
+ }
1310
+ });
1311
+ }); });
1312
+ });
1313
+ (0, globals_1.describe)('Parameter sorting', function () {
1314
+ (0, globals_1.it)('should sort parameters with required first', function () { return __awaiter(void 0, void 0, void 0, function () {
1315
+ var folderPath, swaggerJson, outputPath, generatedContent, parsed, dataSource, operation, parameters;
1316
+ return __generator(this, function (_a) {
1317
+ switch (_a.label) {
1318
+ case 0:
1319
+ folderPath = '/test/sorting';
1320
+ swaggerJson = {
1321
+ name: 'sorting-api',
1322
+ type: 'Microsoft.PowerApps/apis',
1323
+ properties: {
1324
+ swagger: {
1325
+ paths: {
1326
+ '/sorted-params': {
1327
+ post: {
1328
+ operationId: 'PostWithSortedParams',
1329
+ parameters: [
1330
+ {
1331
+ name: 'optional1',
1332
+ in: 'query',
1333
+ required: false,
1334
+ type: 'string',
1335
+ },
1336
+ {
1337
+ name: 'required1',
1338
+ in: 'body',
1339
+ required: true,
1340
+ type: 'object',
1341
+ },
1342
+ {
1343
+ name: 'optional2',
1344
+ in: 'header',
1345
+ required: false,
1346
+ type: 'string',
1347
+ },
1348
+ {
1349
+ name: 'required2',
1350
+ in: 'path',
1351
+ required: true,
1352
+ type: 'string',
1353
+ },
1354
+ ],
1355
+ responses: {
1356
+ '200': { description: 'Success' },
1357
+ },
1358
+ },
1359
+ },
1360
+ },
1361
+ },
1362
+ },
1363
+ };
1364
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
1365
+ case 1:
1366
+ _a.sent();
1367
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'sorted.json'), JSON.stringify(swaggerJson))];
1368
+ case 2:
1369
+ _a.sent();
1370
+ // Act
1371
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
1372
+ case 3:
1373
+ // Act
1374
+ _a.sent();
1375
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
1376
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
1377
+ case 4:
1378
+ generatedContent = _a.sent();
1379
+ parsed = parseDataSourcesInfo(generatedContent);
1380
+ // Verify data source exists with sanitized name
1381
+ (0, globals_2.expect)(parsed).toHaveProperty('sorting_api');
1382
+ dataSource = parsed.sorting_api;
1383
+ operation = dataSource.apis.PostWithSortedParams;
1384
+ parameters = operation.parameters;
1385
+ // Required parameters should come first
1386
+ (0, globals_2.expect)(parameters === null || parameters === void 0 ? void 0 : parameters[0].required).toBe(true);
1387
+ (0, globals_2.expect)(parameters === null || parameters === void 0 ? void 0 : parameters[1].required).toBe(true);
1388
+ (0, globals_2.expect)(parameters === null || parameters === void 0 ? void 0 : parameters[2].required).toBe(false);
1389
+ (0, globals_2.expect)(parameters === null || parameters === void 0 ? void 0 : parameters[3].required).toBe(false);
1390
+ return [2 /*return*/];
1391
+ }
1392
+ });
1393
+ }); });
1394
+ });
1395
+ (0, globals_1.describe)('Output generation', function () {
1396
+ (0, globals_1.it)('should generate properly formatted TypeScript output', function () { return __awaiter(void 0, void 0, void 0, function () {
1397
+ var folderPath, simpleJson, outputPath, content;
1398
+ return __generator(this, function (_a) {
1399
+ switch (_a.label) {
1400
+ case 0:
1401
+ folderPath = '/test/output';
1402
+ simpleJson = {
1403
+ name: 'test-service',
1404
+ schema: { type: 'object' },
1405
+ };
1406
+ return [4 /*yield*/, mockVfs_1.default.mkdir(folderPath, { recursive: true })];
1407
+ case 1:
1408
+ _a.sent();
1409
+ return [4 /*yield*/, mockVfs_1.default.writeFile(mockVfs_1.default.join(folderPath, 'simple.json'), JSON.stringify(simpleJson))];
1410
+ case 2:
1411
+ _a.sent();
1412
+ // Act
1413
+ return [4 /*yield*/, (0, dataSourceInfoProcessor_1.processDataSourceInfo)(folderPath, mockLogger)];
1414
+ case 3:
1415
+ // Act
1416
+ _a.sent();
1417
+ outputPath = mockVfs_1.default.join(folderPath, 'appschemas', 'dataSourcesInfo.ts');
1418
+ return [4 /*yield*/, mockVfs_1.default.readFile(outputPath)];
1419
+ case 4:
1420
+ content = _a.sent();
1421
+ (0, globals_2.expect)(content).toContain('/*!');
1422
+ (0, globals_2.expect)(content).toContain(' * Copyright (C) Microsoft Corporation. All rights reserved.');
1423
+ (0, globals_2.expect)(content).toContain(' * This file is auto-generated. Do not modify it manually.');
1424
+ (0, globals_2.expect)(content).toContain('export const dataSourcesInfo = ');
1425
+ (0, globals_2.expect)(content).toMatch(/;\s*$/); // Should end with semicolon
1426
+ return [2 /*return*/];
1427
+ }
1428
+ });
1429
+ }); });
1430
+ });
1431
+ });
156
1432
  //# sourceMappingURL=DataSourceInfoProcessor.spec.js.map