@intrig/core 0.0.14-6 → 0.0.15-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.js CHANGED
@@ -618,6 +618,12 @@ class SyncCommand extends external_nest_commander_namespaceObject.CommandRunner
618
618
  constructor(pm, httpService){
619
619
  super(), this.pm = pm, this.httpService = httpService;
620
620
  }
621
+ parseAllOption() {
622
+ return true;
623
+ }
624
+ parseIdOption(val) {
625
+ return val;
626
+ }
621
627
  async run(passedParams, options) {
622
628
  // 1) fetch metadata
623
629
  const metadata = await this.pm.getMetadata();
@@ -633,25 +639,34 @@ class SyncCommand extends external_nest_commander_namespaceObject.CommandRunner
633
639
  Accept: 'application/json'
634
640
  }
635
641
  }));
636
- // 3) prompt user to select one or all
637
- const choices = [
638
- {
639
- name: '→ All sources',
640
- value: ''
641
- },
642
- ...sources.map((s)=>({
643
- name: `→ ${s.id} (${s.name ?? 'N/A'})`,
644
- value: s.id
645
- }))
646
- ];
647
- const { id } = await external_inquirer_default().prompt([
648
- {
649
- type: 'list',
650
- name: 'id',
651
- message: external_chalk_default().yellow('Which source would you like to sync?'),
652
- choices
653
- }
654
- ]);
642
+ // 3) determine source id to sync (from flags or prompt)
643
+ let id = '';
644
+ // Check if --id flag was provided
645
+ if (options?.id) {
646
+ id = options.id;
647
+ } else if (options?.all) {
648
+ id = ''; // Empty id means all sources
649
+ } else {
650
+ const choices = [
651
+ {
652
+ name: '→ All sources',
653
+ value: ''
654
+ },
655
+ ...sources.map((s)=>({
656
+ name: `→ ${s.id} (${s.name ?? 'N/A'})`,
657
+ value: s.id
658
+ }))
659
+ ];
660
+ const result = await external_inquirer_default().prompt([
661
+ {
662
+ type: 'list',
663
+ name: 'id',
664
+ message: external_chalk_default().yellow('Which source would you like to sync?'),
665
+ choices
666
+ }
667
+ ]);
668
+ id = result.id;
669
+ }
655
670
  // 4) build sync URL with optional query parameter
656
671
  let syncUrl = `${metadata.url}/api/operations/sync`;
657
672
  if (id) {
@@ -712,6 +727,26 @@ class SyncCommand extends external_nest_commander_namespaceObject.CommandRunner
712
727
  });
713
728
  }
714
729
  }
730
+ sync_command_ts_decorate([
731
+ (0,external_nest_commander_namespaceObject.Option)({
732
+ flags: '--all',
733
+ description: 'Bypass source selection and sync all sources'
734
+ }),
735
+ sync_command_ts_metadata("design:type", Function),
736
+ sync_command_ts_metadata("design:paramtypes", []),
737
+ sync_command_ts_metadata("design:returntype", Boolean)
738
+ ], SyncCommand.prototype, "parseAllOption", null);
739
+ sync_command_ts_decorate([
740
+ (0,external_nest_commander_namespaceObject.Option)({
741
+ flags: '--id [id]',
742
+ description: 'Bypass source selection and use the given id as the source to sync'
743
+ }),
744
+ sync_command_ts_metadata("design:type", Function),
745
+ sync_command_ts_metadata("design:paramtypes", [
746
+ String
747
+ ]),
748
+ sync_command_ts_metadata("design:returntype", String)
749
+ ], SyncCommand.prototype, "parseIdOption", null);
715
750
  SyncCommand = sync_command_ts_decorate([
716
751
  (0,external_nest_commander_namespaceObject.Command)({
717
752
  name: "sync",
@@ -1304,12 +1339,12 @@ SourceManagementService = source_management_service_ts_decorate([
1304
1339
  (0,common_namespaceObject.Injectable)()
1305
1340
  ], SourceManagementService);
1306
1341
 
1307
- ;// external "nypm"
1308
- const external_nypm_namespaceObject = await import("nypm");
1309
1342
  ;// external "util"
1310
1343
  const external_util_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("util");
1311
1344
  ;// external "child_process"
1312
1345
  const external_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("child_process");
1346
+ ;// external "nypm"
1347
+ const external_nypm_namespaceObject = await import("nypm");
1313
1348
  ;// ../../lib/common/src/lib/package-manager.service.ts
1314
1349
  function package_manager_service_ts_decorate(decorators, target, key, desc) {
1315
1350
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1618,6 +1653,7 @@ class IntrigConfigImpl {
1618
1653
  this.sources = config.sources;
1619
1654
  this.generator = config.generator;
1620
1655
  this.restOptions = config.restOptions;
1656
+ this.codeAnalyzer = config.codeAnalyzer;
1621
1657
  }
1622
1658
  }
1623
1659
 
@@ -2683,7 +2719,7 @@ DiscoveryModule = discovery_module_ts_decorate([
2683
2719
  ;// ../../lib/next-binding/src/lib/templates/network-state.template.ts
2684
2720
 
2685
2721
 
2686
- function networkStateTemplate(_path) {
2722
+ function nextNetworkStateTemplate(_path) {
2687
2723
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "network-state.tsx"));
2688
2724
  return ts`import { ZodError } from 'zod';
2689
2725
 
@@ -3138,7 +3174,7 @@ export function isResponseValidationError<T, E>(value: IntrigError<T, E>): value
3138
3174
  ;// ../../lib/next-binding/src/lib/templates/provider.template.ts
3139
3175
 
3140
3176
 
3141
- function providerTemplate(_path) {
3177
+ function nextProviderTemplate(_path) {
3142
3178
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "intrig-provider.tsx"));
3143
3179
  return ts`
3144
3180
  "use client"
@@ -3597,7 +3633,7 @@ export function useCentralPendingState() {
3597
3633
  ;// ../../lib/next-binding/src/lib/templates/index.template.ts
3598
3634
 
3599
3635
 
3600
- function indexTemplate(_path) {
3636
+ function nextIndexTemplate(_path) {
3601
3637
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "index.ts"));
3602
3638
  return ts`
3603
3639
  export * from './intrig-provider';
@@ -3610,7 +3646,7 @@ function indexTemplate(_path) {
3610
3646
  ;// ../../lib/next-binding/src/lib/templates/tsconfig.template.ts
3611
3647
 
3612
3648
 
3613
- function tsConfigTemplate(_path) {
3649
+ function nextTsConfigTemplate(_path) {
3614
3650
  const json = jsonLiteral(external_path_namespaceObject.resolve(_path, 'tsconfig.json'));
3615
3651
  return json`
3616
3652
  {
@@ -3647,7 +3683,7 @@ function tsConfigTemplate(_path) {
3647
3683
  ;// ../../lib/next-binding/src/lib/templates/packageJson.template.ts
3648
3684
 
3649
3685
 
3650
- function packageJsonTemplate(_path) {
3686
+ function nextPackageJsonTemplate(_path) {
3651
3687
  const json = jsonLiteral(external_path_namespaceObject.resolve(_path, 'package.json'));
3652
3688
  return json`
3653
3689
  {
@@ -3708,7 +3744,7 @@ function packageJsonTemplate(_path) {
3708
3744
  ;// ../../lib/next-binding/src/lib/templates/media-type-utils.template.ts
3709
3745
 
3710
3746
 
3711
- function mediaTypeUtilsTemplate(_path) {
3747
+ function nextMediaTypeUtilsTemplate(_path) {
3712
3748
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "media-type-utils.ts"));
3713
3749
  return ts`
3714
3750
  import { ZodSchema } from 'zod';
@@ -3906,7 +3942,7 @@ export async function transformResponse<T>(
3906
3942
  ;// ../../lib/next-binding/src/lib/templates/intrigMiddleware.template.ts
3907
3943
 
3908
3944
 
3909
- function intrigMiddlewareTemplate(_path) {
3945
+ function nextIntrigMiddlewareTemplate(_path) {
3910
3946
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', 'intrig-middleware.ts'));
3911
3947
  return ts`
3912
3948
  import axios, {AxiosInstance} from 'axios';
@@ -3970,7 +4006,7 @@ export async function addResponseToHydrate(key: string, responseData: any) {
3970
4006
  ;// ../../lib/next-binding/src/lib/templates/context.template.ts
3971
4007
 
3972
4008
 
3973
- function contextTemplate(_path) {
4009
+ function nextContextTemplate(_path) {
3974
4010
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "intrig-context.ts"));
3975
4011
  return ts`
3976
4012
  "use client"
@@ -4046,7 +4082,7 @@ export {
4046
4082
  ;// ../../lib/next-binding/src/lib/templates/extra.template.ts
4047
4083
 
4048
4084
 
4049
- function extraTemplate(_path) {
4085
+ function nextExtraTemplate(_path) {
4050
4086
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "extra.ts"));
4051
4087
  return ts`
4052
4088
  "use client"
@@ -4246,7 +4282,7 @@ export function useResolvedCachedValue<P, B, T, E>(hook: IntrigHook<P, B, T, E>,
4246
4282
  ;// ../../lib/next-binding/src/lib/templates/logger.template.ts
4247
4283
 
4248
4284
 
4249
- function loggerTemplate(_path) {
4285
+ function nextLoggerTemplate(_path) {
4250
4286
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', 'logger.ts'));
4251
4287
  return ts`
4252
4288
  import log from 'loglevel';
@@ -4268,7 +4304,7 @@ export default logWrapper;
4268
4304
  ;// ../../lib/next-binding/src/lib/templates/intrig-layout.template.ts
4269
4305
 
4270
4306
 
4271
- function intrigLayoutTemplate(_path) {
4307
+ function nextIntrigLayoutTemplate(_path) {
4272
4308
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "intrig-layout.tsx"));
4273
4309
  return ts`
4274
4310
  "use server"
@@ -4301,7 +4337,7 @@ var external_picomatch_default = /*#__PURE__*/__webpack_require__.n(external_pic
4301
4337
  ;// ../../lib/next-binding/src/lib/templates/source/controller/method/params.template.ts
4302
4338
 
4303
4339
 
4304
- function paramsTemplate({ source, data: { paths, operationId, requestUrl, variables } }, clientExports, serverExports, sourcePath) {
4340
+ function nextParamsTemplate({ source, data: { paths, operationId, requestUrl, variables } }, clientExports, serverExports, sourcePath) {
4305
4341
  const ts = typescript(external_path_namespaceObject.resolve(sourcePath, 'src', source, ...paths, camelCase(operationId), `${pascalCase(operationId)}.params.ts`));
4306
4342
  const { variableImports, variableTypes } = decodeVariables(variables ?? [], source, '@intrig/next');
4307
4343
  clientExports.push(`export type {${pascalCase(operationId)}Params} from './${pascalCase(operationId)}.params'`);
@@ -4393,7 +4429,7 @@ function extractErrorParams(errorTypes) {
4393
4429
  const errorSchema = z.union([${errorTypes.map((a)=>`${a}Schema`).join(', ')}])`;
4394
4430
  }
4395
4431
  }
4396
- function requestHookTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, clientExports = [], serverExports = [], _path) {
4432
+ function nextRequestHookTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, clientExports = [], serverExports = [], _path) {
4397
4433
  const ts = typescript(external_path_default().resolve(_path, 'src', source, ...paths, camelCase(operationId), `use${pascalCase(operationId)}${generatePostfix(contentType, responseType)}.ts`));
4398
4434
  const modifiedRequestUrl = `/api/${source}${requestUrl?.replace(/\{/g, '${')}`;
4399
4435
  const imports = new Set();
@@ -4554,7 +4590,7 @@ function requestMethod_template_extractErrorParams(errorTypes) {
4554
4590
  const errorSchema = z.union([${errorTypes.map((a)=>`${a}Schema`).join(', ')}])`;
4555
4591
  }
4556
4592
  }
4557
- function requestMethodTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, clientExports = [], serverExports = [], _path) {
4593
+ function nextRequestMethodTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, clientExports = [], serverExports = [], _path) {
4558
4594
  const ts = typescript(external_path_default().resolve(_path, 'src', source, ...paths, camelCase(operationId), `${camelCase(operationId)}${generatePostfix(contentType, responseType)}.ts`));
4559
4595
  const modifiedRequestUrl = `${requestUrl?.replace(/\{/g, '${')}`;
4560
4596
  serverExports.push(`export { ${camelCase(operationId)} } from './${camelCase(operationId)}${generatePostfix(contentType, responseType)}'`);
@@ -4662,7 +4698,7 @@ function requestMethodTemplate({ source, data: { paths, operationId, response, r
4662
4698
  ;// ../../lib/next-binding/src/lib/templates/source/controller/method/download.template.ts
4663
4699
 
4664
4700
 
4665
- function downloadHookTemplate({ source, data: { paths, operationId, requestUrl, variables, contentType, responseType } }, clientExports = [], serverExports = [], _path) {
4701
+ function nextDownloadHookTemplate({ source, data: { paths, operationId, requestUrl, variables, contentType, responseType } }, clientExports = [], serverExports = [], _path) {
4666
4702
  const ts = typescript(external_path_default().resolve(_path, 'src', source, ...paths, camelCase(operationId), `${pascalCase(operationId)}${generatePostfix(contentType, responseType)}Link.tsx`));
4667
4703
  const modifiedRequestUrl = `/api/${source}${requestUrl?.replace(/\{/g, '${')}`;
4668
4704
  const imports = new Set();
@@ -4703,7 +4739,7 @@ function downloadHookTemplate({ source, data: { paths, operationId, requestUrl,
4703
4739
 
4704
4740
 
4705
4741
 
4706
- function clientIndexTemplate(requestProperties, clientExports = [], _path) {
4742
+ function nextClientIndexTemplate(requestProperties, clientExports = [], _path) {
4707
4743
  const { source, data: { paths, operationId } } = requestProperties[0];
4708
4744
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', source, ...paths, camelCase(operationId), `client.ts`));
4709
4745
  // if (requestProperties.length === 1)
@@ -4725,7 +4761,7 @@ function clientIndexTemplate(requestProperties, clientExports = [], _path) {
4725
4761
 
4726
4762
 
4727
4763
 
4728
- function serverIndexTemplate(requestProperties, serverExports = [], _path) {
4764
+ function nextServerIndexTemplate(requestProperties, serverExports = [], _path) {
4729
4765
  const { source, data: { paths, operationId } } = requestProperties[0];
4730
4766
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', source, ...paths, camelCase(operationId), `server.ts`));
4731
4767
  return ts`
@@ -4736,7 +4772,7 @@ function serverIndexTemplate(requestProperties, serverExports = [], _path) {
4736
4772
  ;// ../../lib/next-binding/src/lib/templates/source/type/typeTemplate.ts
4737
4773
 
4738
4774
 
4739
- async function typeTemplate({ typeName, schema, sourcePath, paths }) {
4775
+ async function nextTypeTemplate({ typeName, schema, sourcePath, paths }) {
4740
4776
  const { imports, zodSchema, tsType } = openApiSchemaToZod(schema);
4741
4777
  const ts = typescript(external_path_namespaceObject.resolve(sourcePath, 'src', ...paths, `${typeName}.ts`));
4742
4778
  const simpleType = (await jsonLiteral('')`${JSON.stringify(schema)}`).content;
@@ -5002,7 +5038,7 @@ function handleComplexSchema(schema, imports) {
5002
5038
  ;// ../../lib/next-binding/src/lib/templates/source/controller/method/requestRouteTemplate.ts
5003
5039
 
5004
5040
 
5005
- async function requestRouteTemplate(requestUrl, paths, _path) {
5041
+ async function nextRequestRouteTemplate(requestUrl, paths, _path) {
5006
5042
  const parts = requestUrl.replace(/\{/g, "[").replace(/\}/g, "]").split('/');
5007
5043
  const { source } = paths[0];
5008
5044
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', "api", "(generated)", source, ...parts, `route.ts`));
@@ -5160,7 +5196,7 @@ async function requestRouteTemplate(requestUrl, paths, _path) {
5160
5196
  ;// ../../lib/next-binding/src/lib/templates/swcrc.template.ts
5161
5197
 
5162
5198
 
5163
- function swcrcTemplate(_path) {
5199
+ function nextSwcrcTemplate(_path) {
5164
5200
  const json = jsonLiteral(external_path_namespaceObject.resolve(_path, '.swcrc'));
5165
5201
  return json`
5166
5202
  {
@@ -5184,7 +5220,7 @@ function swcrcTemplate(_path) {
5184
5220
 
5185
5221
  ;// ../../lib/next-binding/src/lib/templates/docs/react-hook.ts
5186
5222
 
5187
- function reactHookDocs(descriptor) {
5223
+ function nextReactHookDocs(descriptor) {
5188
5224
  const md = mdLiteral('react-hook.md');
5189
5225
  const requestBody = descriptor.data.requestBody ? camelCase(descriptor.data.requestBody) : undefined;
5190
5226
  const params = descriptor.data.variables?.filter((a)=>a.in.toUpperCase() === 'PATH')?.length ? 'params' : undefined;
@@ -5629,18 +5665,18 @@ class IntrigNextBindingService extends GeneratorBinding {
5629
5665
  return "next";
5630
5666
  }
5631
5667
  async generateGlobal() {
5632
- await this.dump(networkStateTemplate(this._path));
5633
- await this.dump(providerTemplate(this._path));
5634
- await this.dump(intrigLayoutTemplate(this._path));
5635
- await this.dump(indexTemplate(this._path));
5636
- await this.dump(tsConfigTemplate(this._path));
5637
- await this.dump(packageJsonTemplate(this._path));
5638
- await this.dump(mediaTypeUtilsTemplate(this._path));
5639
- await this.dump(intrigMiddlewareTemplate(this._path));
5640
- await this.dump(contextTemplate(this._path));
5641
- await this.dump(extraTemplate(this._path));
5642
- await this.dump(loggerTemplate(this._path));
5643
- await this.dump(swcrcTemplate(this._path));
5668
+ await this.dump(nextNetworkStateTemplate(this._path));
5669
+ await this.dump(nextProviderTemplate(this._path));
5670
+ await this.dump(nextIntrigLayoutTemplate(this._path));
5671
+ await this.dump(nextIndexTemplate(this._path));
5672
+ await this.dump(nextTsConfigTemplate(this._path));
5673
+ await this.dump(nextPackageJsonTemplate(this._path));
5674
+ await this.dump(nextMediaTypeUtilsTemplate(this._path));
5675
+ await this.dump(nextIntrigMiddlewareTemplate(this._path));
5676
+ await this.dump(nextContextTemplate(this._path));
5677
+ await this.dump(nextExtraTemplate(this._path));
5678
+ await this.dump(nextLoggerTemplate(this._path));
5679
+ await this.dump(nextSwcrcTemplate(this._path));
5644
5680
  }
5645
5681
  async generateSource(descriptors, source) {
5646
5682
  const groupedByPath = {};
@@ -5654,28 +5690,28 @@ class IntrigNextBindingService extends GeneratorBinding {
5654
5690
  }
5655
5691
  }
5656
5692
  for (const [requestUrl, matchingPaths] of Object.entries(groupedByPath)){
5657
- await this.dump(requestRouteTemplate(requestUrl, matchingPaths, this._path));
5693
+ await this.dump(nextRequestRouteTemplate(requestUrl, matchingPaths, this._path));
5658
5694
  }
5659
5695
  }
5660
5696
  async generateRestSource(source, descriptor) {
5661
5697
  const clientExports = [];
5662
5698
  const serverExports = [];
5663
- await this.dump(paramsTemplate(descriptor, clientExports, serverExports, this._path));
5664
- await this.dump(requestHookTemplate(descriptor, clientExports, serverExports, this._path));
5665
- await this.dump(requestMethodTemplate(descriptor, clientExports, serverExports, this._path));
5699
+ await this.dump(nextParamsTemplate(descriptor, clientExports, serverExports, this._path));
5700
+ await this.dump(nextRequestHookTemplate(descriptor, clientExports, serverExports, this._path));
5701
+ await this.dump(nextRequestMethodTemplate(descriptor, clientExports, serverExports, this._path));
5666
5702
  //TODO incorporate rest options.
5667
5703
  if (descriptor.data.method.toUpperCase() === 'GET' && !nonDownloadMimePatterns(descriptor.data.responseType)) {
5668
- await this.dump(downloadHookTemplate(descriptor, clientExports, serverExports, this._path));
5704
+ await this.dump(nextDownloadHookTemplate(descriptor, clientExports, serverExports, this._path));
5669
5705
  }
5670
- await this.dump(clientIndexTemplate([
5706
+ await this.dump(nextClientIndexTemplate([
5671
5707
  descriptor
5672
5708
  ], clientExports, this._path));
5673
- await this.dump(serverIndexTemplate([
5709
+ await this.dump(nextServerIndexTemplate([
5674
5710
  descriptor
5675
5711
  ], serverExports, this._path));
5676
5712
  }
5677
5713
  async generateSchemaSource(source, descriptor) {
5678
- await this.dump(typeTemplate({
5714
+ await this.dump(nextTypeTemplate({
5679
5715
  schema: descriptor.data.schema,
5680
5716
  typeName: descriptor.data.name,
5681
5717
  sourcePath: this._path,
@@ -5758,7 +5794,7 @@ ${"```"}
5758
5794
  } else {
5759
5795
  tabs.push({
5760
5796
  name: 'React Hook',
5761
- content: (await reactHookDocs(result)).content
5797
+ content: (await nextReactHookDocs(result)).content
5762
5798
  });
5763
5799
  }
5764
5800
  return RestDocumentation.from({
@@ -5916,17 +5952,22 @@ class SearchCommand extends external_nest_commander_namespaceObject.CommandRunne
5916
5952
  constructor(pm, httpService){
5917
5953
  super(), this.pm = pm, this.httpService = httpService;
5918
5954
  }
5919
- async run(passedParams, options) {
5955
+ parseNoInteractiveOption(val) {
5956
+ return val;
5957
+ }
5958
+ parseOptionIndexOption(val) {
5959
+ return parseInt(val, 10);
5960
+ }
5961
+ async validateMetadata() {
5920
5962
  const metadata = await this.pm.getMetadata();
5921
5963
  if (!metadata) {
5922
5964
  console.error(external_chalk_default().red.bold('Error:'), external_chalk_default().red('No metadata found.'));
5923
5965
  process.exit(1);
5924
5966
  }
5925
- const query = passedParams[0] || '';
5926
- const page = 1;
5927
- const size = 20;
5967
+ return metadata;
5968
+ }
5969
+ async fetchSearchResults(metadata, query, page, size) {
5928
5970
  try {
5929
- // Call the search API
5930
5971
  const response = await (0,external_rxjs_namespaceObject.lastValueFrom)(this.httpService.get(`${metadata.url}/api/data/search`, {
5931
5972
  params: {
5932
5973
  query,
@@ -5934,42 +5975,110 @@ class SearchCommand extends external_nest_commander_namespaceObject.CommandRunne
5934
5975
  size
5935
5976
  }
5936
5977
  }));
5937
- const resultPage = response.data;
5938
- if (!resultPage.data.length) {
5939
- console.log('No resources found.');
5940
- return;
5978
+ return response.data;
5979
+ } catch (err) {
5980
+ console.error('Search failed:', err.message || err);
5981
+ process.exit(1);
5982
+ }
5983
+ }
5984
+ buildChoices(resultPage) {
5985
+ if (!resultPage.data.length) {
5986
+ console.log('No resources found.');
5987
+ return null;
5988
+ }
5989
+ return resultPage.data.map((desc)=>{
5990
+ let title = desc.name;
5991
+ if (desc.type === 'rest' && desc.data) {
5992
+ const rest = desc.data;
5993
+ const method = rest.method?.toUpperCase() || '';
5994
+ const path = Array.isArray(rest.paths) && rest.paths.length ? rest.paths[0] : '';
5995
+ const summary = rest.summary ? ` — ${rest.summary}` : '';
5996
+ title = `${method} ${path}${summary}`.trim();
5941
5997
  }
5942
- // Build choices for inquirer prompt
5943
- const choices = resultPage.data.map((desc)=>{
5944
- let title = desc.name;
5945
- if (desc.type === 'rest' && desc.data) {
5946
- const rest = desc.data;
5947
- const method = rest.method?.toUpperCase() || '';
5948
- const path = Array.isArray(rest.paths) && rest.paths.length ? rest.paths[0] : '';
5949
- const summary = rest.summary ? ` — ${rest.summary}` : '';
5950
- title = `${method} ${path}${summary}`.trim();
5951
- }
5952
- return {
5953
- name: title,
5954
- value: desc.id
5955
- };
5998
+ return {
5999
+ name: title,
6000
+ value: desc.id,
6001
+ type: desc.type,
6002
+ source: desc.source
6003
+ };
6004
+ });
6005
+ }
6006
+ handleNonInteractiveMode(choices, options) {
6007
+ if (!options?.option) {
6008
+ console.log('Select a resource.');
6009
+ choices.forEach((choice, index)=>{
6010
+ console.log(` ${index + 1}. ${choice.name}`);
5956
6011
  });
5957
- // Prompt user to select one
5958
- const answers = await external_inquirer_default().prompt([
5959
- {
5960
- type: 'list',
5961
- name: 'id',
5962
- message: 'Select a resource:',
5963
- choices,
5964
- pageSize: size
5965
- }
5966
- ]);
5967
- console.log(`Selected resource ID: ${answers.id}`);
6012
+ return null;
6013
+ } else {
6014
+ const optionIndex = options.option;
6015
+ if (optionIndex < 1 || optionIndex > choices.length) {
6016
+ console.error(`Error: Option index out of range. Must be between 1 and ${choices.length}.`);
6017
+ process.exit(1);
6018
+ }
6019
+ const selected = choices[optionIndex - 1];
6020
+ console.log(`Selected resource: ID: ${selected.value}, Type: ${selected.type}`);
6021
+ return selected;
6022
+ }
6023
+ }
6024
+ async handleInteractiveMode(choices, size) {
6025
+ const answers = await external_inquirer_default().prompt([
6026
+ {
6027
+ type: 'list',
6028
+ name: 'id',
6029
+ message: 'Select a resource:',
6030
+ choices,
6031
+ pageSize: size
6032
+ }
6033
+ ]);
6034
+ // Find the selected resource to get its type
6035
+ const selectedResource = choices.find((choice)=>choice.value === answers.id);
6036
+ console.log(`Selected resource: ID: ${answers.id}, Type: ${selectedResource?.type}`);
6037
+ return selectedResource;
6038
+ }
6039
+ async run(passedParams, options) {
6040
+ try {
6041
+ const metadata = await this.validateMetadata();
6042
+ const query = passedParams[0] || '';
6043
+ const page = 1;
6044
+ const size = 20;
6045
+ const resultPage = await this.fetchSearchResults(metadata, query, page, size);
6046
+ const choices = this.buildChoices(resultPage);
6047
+ if (!choices) return;
6048
+ // Handle non-interactive mode
6049
+ if (!options?.interactive) {
6050
+ this.handleNonInteractiveMode(choices, options);
6051
+ return;
6052
+ }
6053
+ // Interactive mode
6054
+ await this.handleInteractiveMode(choices, size);
5968
6055
  } catch (err) {
5969
6056
  console.error('Search failed:', err.message || err);
5970
6057
  }
5971
6058
  }
5972
6059
  }
6060
+ search_command_ts_decorate([
6061
+ (0,external_nest_commander_namespaceObject.Option)({
6062
+ flags: '--no-interactive',
6063
+ description: 'Display options without an interactive prompt'
6064
+ }),
6065
+ search_command_ts_metadata("design:type", Function),
6066
+ search_command_ts_metadata("design:paramtypes", [
6067
+ Boolean
6068
+ ]),
6069
+ search_command_ts_metadata("design:returntype", Boolean)
6070
+ ], SearchCommand.prototype, "parseNoInteractiveOption", null);
6071
+ search_command_ts_decorate([
6072
+ (0,external_nest_commander_namespaceObject.Option)({
6073
+ flags: '--option [index]',
6074
+ description: 'Select option by index (works with --no-interactive)'
6075
+ }),
6076
+ search_command_ts_metadata("design:type", Function),
6077
+ search_command_ts_metadata("design:paramtypes", [
6078
+ String
6079
+ ]),
6080
+ search_command_ts_metadata("design:returntype", Number)
6081
+ ], SearchCommand.prototype, "parseOptionIndexOption", null);
5973
6082
  SearchCommand = search_command_ts_decorate([
5974
6083
  (0,external_nest_commander_namespaceObject.Command)({
5975
6084
  name: 'search',
@@ -5985,8 +6094,12 @@ SearchCommand = search_command_ts_decorate([
5985
6094
  ;// ../../lib/react-binding/src/lib/templates/context.template.ts
5986
6095
 
5987
6096
 
5988
- function context_template_contextTemplate(_path) {
6097
+ function reactContextTemplate(_path, apisToSync) {
5989
6098
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "intrig-context.ts"));
6099
+ const configType = `{
6100
+ defaults?: DefaultConfigs,
6101
+ ${apisToSync.map((a)=>`${a.id}?: DefaultConfigs`).join(",\n ")}
6102
+ }`;
5990
6103
  return ts`
5991
6104
  import { NetworkAction, NetworkState } from '@intrig/react/network-state';
5992
6105
  import { AxiosProgressEvent, AxiosRequestConfig } from 'axios';
@@ -6015,7 +6128,7 @@ export interface ContextType {
6015
6128
  state: GlobalState;
6016
6129
  filteredState: GlobalState;
6017
6130
  dispatch: Dispatch<NetworkAction<unknown, unknown>>;
6018
- configs: DefaultConfigs;
6131
+ configs: ${configType};
6019
6132
  execute: <T>(request: RequestType, dispatch: (state: NetworkState<T>) => void, schema: ZodSchema<T> | undefined, errorSchema: ZodSchema<T> | undefined) => Promise<void>;
6020
6133
  }
6021
6134
 
@@ -6050,7 +6163,7 @@ export {
6050
6163
  ;// ../../lib/react-binding/src/lib/templates/extra.template.ts
6051
6164
 
6052
6165
 
6053
- function extra_template_extraTemplate(_path) {
6166
+ function reactExtraTemplate(_path) {
6054
6167
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "extra.ts"));
6055
6168
  return ts`
6056
6169
  import {
@@ -6254,7 +6367,7 @@ export function useResolvedCachedValue<P, B, T, E>(hook: IntrigHook<P, B, T, E>,
6254
6367
  ;// ../../lib/react-binding/src/lib/templates/index.template.ts
6255
6368
 
6256
6369
 
6257
- function index_template_indexTemplate(_path) {
6370
+ function reactIndexTemplate(_path) {
6258
6371
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "index.ts"));
6259
6372
  return ts`
6260
6373
  export * from './intrig-provider';
@@ -6267,7 +6380,7 @@ function index_template_indexTemplate(_path) {
6267
6380
  ;// ../../lib/react-binding/src/lib/templates/logger.template.ts
6268
6381
 
6269
6382
 
6270
- function logger_template_loggerTemplate(_path) {
6383
+ function reactLoggerTemplate(_path) {
6271
6384
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', 'logger.ts'));
6272
6385
  return ts`
6273
6386
  // logger.ts
@@ -6334,7 +6447,7 @@ export default logger;
6334
6447
  ;// ../../lib/react-binding/src/lib/templates/media-type-utils.template.ts
6335
6448
 
6336
6449
 
6337
- function media_type_utils_template_mediaTypeUtilsTemplate(_path) {
6450
+ function reactMediaTypeUtilsTemplate(_path) {
6338
6451
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "media-type-utils.ts"));
6339
6452
  return ts`
6340
6453
  import { ZodSchema } from 'zod';
@@ -6532,7 +6645,7 @@ export async function transformResponse<T>(
6532
6645
  ;// ../../lib/react-binding/src/lib/templates/network-state.template.ts
6533
6646
 
6534
6647
 
6535
- function network_state_template_networkStateTemplate(_path) {
6648
+ function reactNetworkStateTemplate(_path) {
6536
6649
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "network-state.tsx"));
6537
6650
  return ts`import { ZodError } from 'zod';
6538
6651
 
@@ -7014,7 +7127,7 @@ export function isResponseValidationError<T, E>(value: IntrigError<T, E>): value
7014
7127
 
7015
7128
 
7016
7129
 
7017
- function packageJson_template_packageJsonTemplate(_path) {
7130
+ function reactPackageJsonTemplate(_path) {
7018
7131
  const packageJson = external_fs_extra_namespaceObject.readJsonSync(external_path_namespaceObject.resolve(_path, '..', '..', 'package.json'));
7019
7132
  const json = jsonLiteral(external_path_namespaceObject.resolve(_path, 'package.json'));
7020
7133
  return json`
@@ -7076,10 +7189,14 @@ function packageJson_template_packageJsonTemplate(_path) {
7076
7189
  ;// ../../lib/react-binding/src/lib/templates/provider.template.ts
7077
7190
 
7078
7191
 
7079
- function provider_template_providerTemplate(_path, apisToSync) {
7192
+ function reactProviderTemplate(_path, apisToSync) {
7080
7193
  const axiosConfigs = apisToSync.map((a)=>`
7081
7194
  ${a.id}: createAxiosInstance(configs.defaults, configs['${a.id}']),
7082
7195
  `).join("\n");
7196
+ const configType = `{
7197
+ defaults?: DefaultConfigs,
7198
+ ${apisToSync.map((a)=>`${a.id}?: DefaultConfigs`).join(",\n ")}
7199
+ }`;
7083
7200
  const ts = typescript(external_path_namespaceObject.resolve(_path, "src", "intrig-provider.tsx"));
7084
7201
  return ts`
7085
7202
  import React, {
@@ -7148,7 +7265,7 @@ export interface DefaultConfigs extends CreateAxiosDefaults {
7148
7265
  }
7149
7266
 
7150
7267
  export interface IntrigProviderProps {
7151
- configs?: Record<string, DefaultConfigs>;
7268
+ configs?: ${configType};
7152
7269
  children: React.ReactNode;
7153
7270
  }
7154
7271
 
@@ -7293,7 +7410,7 @@ export type WithStubSupport<T> = T & {
7293
7410
  }
7294
7411
 
7295
7412
  export interface IntrigProviderStubProps {
7296
- configs?: DefaultConfigs;
7413
+ configs?: ${configType};
7297
7414
  stubs?: (stub: StubType<any, any, any>) => void;
7298
7415
  children: React.ReactNode;
7299
7416
  }
@@ -7478,8 +7595,8 @@ export function useNetworkState<T, E = unknown>({
7478
7595
  );
7479
7596
 
7480
7597
  const debounceDelay = useMemo(() => {
7481
- return requestDebounceDelay ?? context.configs?.debounceDelay ?? 0;
7482
- }, [context.configs, requestDebounceDelay]);
7598
+ return requestDebounceDelay ?? context.configs?.[source]?.debounceDelay ?? 0;
7599
+ }, [context.configs, requestDebounceDelay, source]);
7483
7600
 
7484
7601
  const execute = useCallback(
7485
7602
  async (request: RequestType) => {
@@ -7659,7 +7776,7 @@ export function useCentralPendingState() {
7659
7776
  ;// ../../lib/react-binding/src/lib/templates/tsconfig.template.ts
7660
7777
 
7661
7778
 
7662
- function tsconfig_template_tsConfigTemplate(_path) {
7779
+ function reactTsConfigTemplate(_path) {
7663
7780
  const json = jsonLiteral(external_path_namespaceObject.resolve(_path, 'tsconfig.json'));
7664
7781
  return json`
7665
7782
  {
@@ -7682,7 +7799,8 @@ function tsconfig_template_tsConfigTemplate(_path) {
7682
7799
  ],
7683
7800
  "intrig-hook": ["src/config/intrig"]
7684
7801
  },
7685
- "jsx": "react-jsx"
7802
+ "jsx": "react-jsx",
7803
+ "skipLibCheck": true
7686
7804
  },
7687
7805
  "exclude": [
7688
7806
  "node_modules",
@@ -7696,7 +7814,7 @@ function tsconfig_template_tsConfigTemplate(_path) {
7696
7814
  ;// ../../lib/react-binding/src/lib/templates/source/controller/method/clientIndex.template.ts
7697
7815
 
7698
7816
 
7699
- async function clientIndex_template_clientIndexTemplate(descriptors, _path) {
7817
+ async function reactClientIndexTemplate(descriptors, _path) {
7700
7818
  const { source, data: { paths, operationId, responseType, contentType } } = descriptors[0];
7701
7819
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', source, ...paths, camelCase(operationId), `client.ts`));
7702
7820
  if (descriptors.length === 1) return ts`
@@ -7717,7 +7835,7 @@ async function clientIndex_template_clientIndexTemplate(descriptors, _path) {
7717
7835
  ;// ../../lib/react-binding/src/lib/templates/source/controller/method/params.template.ts
7718
7836
 
7719
7837
 
7720
- async function params_template_paramsTemplate({ source, data: { paths, operationId, variables } }, _path) {
7838
+ async function reactParamsTemplate({ source, data: { paths, operationId, variables } }, _path) {
7721
7839
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', source, ...paths, camelCase(operationId), `${pascalCase(operationId)}.params.ts`));
7722
7840
  const { variableImports, variableTypes } = decodeVariables(variables ?? [], source, "@intrig/react");
7723
7841
  return ts`
@@ -7807,7 +7925,7 @@ function requestHook_template_extractErrorParams(errorTypes) {
7807
7925
  const errorSchema = z.union([${errorTypes.map((a)=>`${a}Schema`).join(', ')}])`;
7808
7926
  }
7809
7927
  }
7810
- async function requestHook_template_requestHookTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, _path) {
7928
+ async function reactRequestHookTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, _path) {
7811
7929
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', source, ...paths, camelCase(operationId), `use${pascalCase(operationId)}${generatePostfix(contentType, responseType)}.ts`));
7812
7930
  const modifiedRequestUrl = `${requestUrl?.replace(/\{/g, "${")}`;
7813
7931
  const imports = new Set();
@@ -7987,7 +8105,7 @@ function download_template_extractErrorParams(errorTypes) {
7987
8105
  const errorSchema = z.union([${errorTypes.map((a)=>`${a}Schema`).join(', ')}])`;
7988
8106
  }
7989
8107
  }
7990
- async function download_template_downloadHookTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, _path) {
8108
+ async function reactDownloadHookTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, _path) {
7991
8109
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', source, ...paths, camelCase(operationId), `use${pascalCase(operationId)}${generatePostfix(contentType, responseType)}Download.ts`));
7992
8110
  const modifiedRequestUrl = `/api/${source}${requestUrl?.replace(/\{/g, "${")}`;
7993
8111
  const imports = new Set();
@@ -8092,7 +8210,7 @@ async function download_template_downloadHookTemplate({ source, data: { paths, o
8092
8210
  ;// ../../lib/react-binding/src/lib/templates/source/type/typeTemplate.ts
8093
8211
 
8094
8212
 
8095
- async function typeTemplate_typeTemplate({ typeName, schema, sourcePath, paths }) {
8213
+ async function reactTypeTemplate({ typeName, schema, sourcePath, paths }) {
8096
8214
  const { imports, zodSchema, tsType } = typeTemplate_openApiSchemaToZod(schema);
8097
8215
  const ts = typescript(external_path_namespaceObject.resolve(sourcePath, 'src', ...paths, `${typeName}.ts`));
8098
8216
  const simpleType = (await jsonLiteral('')`${JSON.stringify(schema)}`).content;
@@ -8367,7 +8485,7 @@ function typeTemplate_handleComplexSchema(schema, imports) {
8367
8485
  ;// ../../lib/react-binding/src/lib/templates/swcrc.template.ts
8368
8486
 
8369
8487
 
8370
- function swcrc_template_swcrcTemplate(_path) {
8488
+ function reactSwcrcTemplate(_path) {
8371
8489
  const json = jsonLiteral(external_path_namespaceObject.resolve(_path, '.swcrc'));
8372
8490
  return json`
8373
8491
  {
@@ -8392,7 +8510,7 @@ function swcrc_template_swcrcTemplate(_path) {
8392
8510
 
8393
8511
  ;// ../../lib/react-binding/src/lib/templates/docs/react-hook.ts
8394
8512
 
8395
- function react_hook_reactHookDocs(descriptor) {
8513
+ function reactHookDocs(descriptor) {
8396
8514
  const md = mdLiteral('react-hook.md');
8397
8515
  const requestBody = descriptor.data.requestBody ? camelCase(descriptor.data.requestBody) : undefined;
8398
8516
  const params = descriptor.data.variables?.filter((a)=>a.in.toUpperCase() === 'PATH')?.length ? 'params' : undefined;
@@ -8769,7 +8887,7 @@ ${'```'}
8769
8887
 
8770
8888
  ;// ../../lib/react-binding/src/lib/templates/docs/sse-hook.ts
8771
8889
 
8772
- function sseHookDocs(descriptor) {
8890
+ function reactSseHookDocs(descriptor) {
8773
8891
  const md = mdLiteral('sse-hook.md');
8774
8892
  const requestBody = descriptor.data.requestBody ? camelCase(descriptor.data.requestBody) : undefined;
8775
8893
  const params = descriptor.data.variables?.filter((a)=>a.in.toUpperCase() === 'PATH')?.length ? 'params' : undefined;
@@ -9001,7 +9119,7 @@ function asyncFunctionHook_template_extractParamDeconstruction(variables, reques
9001
9119
  }
9002
9120
  }
9003
9121
  }
9004
- async function asyncFunctionHookTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, _path) {
9122
+ async function reactAsyncFunctionHookTemplate({ source, data: { paths, operationId, response, requestUrl, variables, requestBody, contentType, responseType, errorResponses, method } }, _path) {
9005
9123
  const ts = typescript(external_path_namespaceObject.resolve(_path, 'src', source, ...paths, camelCase(operationId), `use${pascalCase(operationId)}Async${generatePostfix(contentType, responseType)}.ts`));
9006
9124
  const modifiedRequestUrl = `${requestUrl?.replace(/\{/g, "${")}`;
9007
9125
  const imports = new Set();
@@ -9089,7 +9207,7 @@ export const use${pascalCase(operationId)}Async: ${hookShape} = use${pascalCase(
9089
9207
 
9090
9208
  ;// ../../lib/react-binding/src/lib/templates/docs/async-hook.ts
9091
9209
 
9092
- function asyncFunctionHookDocs(descriptor) {
9210
+ function reactAsyncFunctionHookDocs(descriptor) {
9093
9211
  const md = mdLiteral('async-hook.md');
9094
9212
  const requestBody = descriptor.data.requestBody ? camelCase(descriptor.data.requestBody) : undefined;
9095
9213
  const params = descriptor.data.variables?.filter((a)=>a.in.toUpperCase() === 'PATH')?.length ? 'params' : undefined;
@@ -9225,17 +9343,17 @@ class ReactBindingService extends GeneratorBinding {
9225
9343
  super(), this.sourceManagementService = sourceManagementService, this.config = config, this.logger = new common_namespaceObject.Logger(ReactBindingService.name), this.dump = this.sourceManagementService.dump, this._path = this.config.get("generatedDir") ?? external_path_default().resolve(external_node_process_default().cwd(), '.intrig', 'generated');
9226
9344
  }
9227
9345
  async generateGlobal(apisToSync) {
9228
- await this.dump(context_template_contextTemplate(this._path));
9229
- await this.dump(extra_template_extraTemplate(this._path));
9230
- await this.dump(index_template_indexTemplate(this._path));
9231
- // await this.dump(intrigMiddlewareTemplate(this._path))
9232
- await this.dump(swcrc_template_swcrcTemplate(this._path));
9233
- await this.dump(logger_template_loggerTemplate(this._path));
9234
- await this.dump(media_type_utils_template_mediaTypeUtilsTemplate(this._path));
9235
- await this.dump(network_state_template_networkStateTemplate(this._path));
9236
- await this.dump(packageJson_template_packageJsonTemplate(this._path));
9237
- await this.dump(provider_template_providerTemplate(this._path, apisToSync));
9238
- await this.dump(tsconfig_template_tsConfigTemplate(this._path));
9346
+ await this.dump(reactContextTemplate(this._path, apisToSync));
9347
+ await this.dump(reactExtraTemplate(this._path));
9348
+ await this.dump(reactIndexTemplate(this._path));
9349
+ // await this.dump(reactIntrigMiddlewareTemplate(this._path))
9350
+ await this.dump(reactSwcrcTemplate(this._path));
9351
+ await this.dump(reactLoggerTemplate(this._path));
9352
+ await this.dump(reactMediaTypeUtilsTemplate(this._path));
9353
+ await this.dump(reactNetworkStateTemplate(this._path));
9354
+ await this.dump(reactPackageJsonTemplate(this._path));
9355
+ await this.dump(reactProviderTemplate(this._path, apisToSync));
9356
+ await this.dump(reactTsConfigTemplate(this._path));
9239
9357
  }
9240
9358
  async generateSource(descriptors, source) {
9241
9359
  for (const descriptor of descriptors){
@@ -9254,18 +9372,18 @@ class ReactBindingService extends GeneratorBinding {
9254
9372
  return Promise.resolve(undefined);
9255
9373
  }
9256
9374
  async generateRestSource(source, descriptor) {
9257
- await this.dump(clientIndex_template_clientIndexTemplate([
9375
+ await this.dump(reactClientIndexTemplate([
9258
9376
  descriptor
9259
9377
  ], this._path));
9260
- await this.dump(params_template_paramsTemplate(descriptor, this._path));
9261
- await this.dump(requestHook_template_requestHookTemplate(descriptor, this._path));
9262
- await this.dump(asyncFunctionHookTemplate(descriptor, this._path));
9378
+ await this.dump(reactParamsTemplate(descriptor, this._path));
9379
+ await this.dump(reactRequestHookTemplate(descriptor, this._path));
9380
+ await this.dump(reactAsyncFunctionHookTemplate(descriptor, this._path));
9263
9381
  if (descriptor.data.method.toUpperCase() === 'GET' && !react_binding_service_nonDownloadMimePatterns(descriptor.data.responseType)) {
9264
- await this.dump(download_template_downloadHookTemplate(descriptor, this._path));
9382
+ await this.dump(reactDownloadHookTemplate(descriptor, this._path));
9265
9383
  }
9266
9384
  }
9267
9385
  async generateSchemaSource(source, descriptor) {
9268
- await this.dump(typeTemplate_typeTemplate({
9386
+ await this.dump(reactTypeTemplate({
9269
9387
  schema: descriptor.data.schema,
9270
9388
  typeName: descriptor.data.name,
9271
9389
  sourcePath: this._path,
@@ -9343,17 +9461,17 @@ ${"```"}
9343
9461
  if (result.data.responseType === 'text/event-stream') {
9344
9462
  tabs.push({
9345
9463
  name: 'SSE Hook',
9346
- content: (await sseHookDocs(result)).content
9464
+ content: (await reactSseHookDocs(result)).content
9347
9465
  });
9348
9466
  } else {
9349
9467
  tabs.push({
9350
- name: 'React Hook',
9351
- content: (await react_hook_reactHookDocs(result)).content
9468
+ name: 'Stateful Hook',
9469
+ content: (await reactHookDocs(result)).content
9352
9470
  });
9353
9471
  }
9354
9472
  tabs.push({
9355
- name: 'Async Function Hook',
9356
- content: (await asyncFunctionHookDocs(result)).content
9473
+ name: 'Stateless Hook',
9474
+ content: (await reactAsyncFunctionHookDocs(result)).content
9357
9475
  });
9358
9476
  return RestDocumentation.from({
9359
9477
  id: result.id,
@@ -9478,6 +9596,344 @@ ReactCliModule = react_cli_module_ts_decorate([
9478
9596
 
9479
9597
 
9480
9598
 
9599
+ ;// external "express"
9600
+ const external_express_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("express");
9601
+ ;// external "url"
9602
+ const external_url_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("url");
9603
+ ;// ./src/app/insight-assets.ts
9604
+ // Import insight assets using webpack's require.context
9605
+ // These will be bundled into main.js
9606
+
9607
+
9608
+
9609
+ // Function to load assets at runtime
9610
+ function loadInsightAssets() {
9611
+ const __filename = (0,external_url_namespaceObject.fileURLToPath)("file:///home/tiran-intrigsoft/IdeaProjects/intrig-core/app/intrig/src/app/insight-assets.ts");
9612
+ const __dirname = external_path_namespaceObject.dirname(__filename);
9613
+ // In production, the assets are in the dist directory
9614
+ // The path structure is different between development and production
9615
+ let insightDistPath;
9616
+ // Try the dist path first (production)
9617
+ insightDistPath = external_path_namespaceObject.resolve(__dirname, '..', 'assets', 'insight');
9618
+ // If that doesn't exist, try the development path
9619
+ if (!external_fs_namespaceObject.existsSync(insightDistPath)) {
9620
+ insightDistPath = external_path_namespaceObject.resolve(process.cwd(), 'dist', 'app', 'intrig', 'assets', 'insight');
9621
+ }
9622
+ // Check if the assets directory exists
9623
+ if (!external_fs_namespaceObject.existsSync(insightDistPath)) {
9624
+ throw new Error(`Insight assets directory not found at ${insightDistPath}`);
9625
+ }
9626
+ // Load the assets
9627
+ const html = external_fs_namespaceObject.readFileSync(external_path_namespaceObject.join(insightDistPath, 'index.html'), 'utf8');
9628
+ // Find the CSS and JS files in the assets directory
9629
+ const assetsDir = external_path_namespaceObject.join(insightDistPath, 'assets');
9630
+ const files = external_fs_namespaceObject.readdirSync(assetsDir);
9631
+ const cssFile = files.find((file)=>file.endsWith('.css'));
9632
+ const jsFile = files.find((file)=>file.endsWith('.js'));
9633
+ if (!cssFile || !jsFile) {
9634
+ throw new Error('CSS or JS file not found in insight assets directory');
9635
+ }
9636
+ const css = external_fs_namespaceObject.readFileSync(external_path_namespaceObject.join(assetsDir, cssFile), 'utf8');
9637
+ const js = external_fs_namespaceObject.readFileSync(external_path_namespaceObject.join(assetsDir, jsFile), 'utf8');
9638
+ // Load favicon and package.json
9639
+ const favicon = external_fs_namespaceObject.readFileSync(external_path_namespaceObject.join(insightDistPath, 'favicon.ico'));
9640
+ const packageJson = external_fs_namespaceObject.readFileSync(external_path_namespaceObject.join(insightDistPath, 'package.json'), 'utf8');
9641
+ return {
9642
+ html,
9643
+ css,
9644
+ js,
9645
+ favicon,
9646
+ packageJson: JSON.parse(packageJson)
9647
+ };
9648
+ }
9649
+
9650
+ ;// external "open"
9651
+ const external_open_namespaceObject = await import("open");
9652
+ var external_open_default = /*#__PURE__*/__webpack_require__.n(external_open_namespaceObject);
9653
+ ;// external "net"
9654
+ const external_net_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net");
9655
+ ;// ./src/app/cli/commands/insight.command.ts
9656
+ function insight_command_ts_decorate(decorators, target, key, desc) {
9657
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9658
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9659
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9660
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9661
+ }
9662
+ function insight_command_ts_metadata(k, v) {
9663
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9664
+ }
9665
+
9666
+
9667
+
9668
+
9669
+
9670
+
9671
+
9672
+
9673
+
9674
+ const SOCIAL_NUMBERS = [
9675
+ 12496,
9676
+ 14288,
9677
+ 15472,
9678
+ 14536,
9679
+ 14264,
9680
+ 12496
9681
+ ];
9682
+ class InsightCommand extends external_nest_commander_namespaceObject.CommandRunner {
9683
+ constructor(pm, httpService){
9684
+ super(), this.pm = pm, this.httpService = httpService, this.logger = new common_namespaceObject.Logger(InsightCommand.name);
9685
+ }
9686
+ parsePathOption(val) {
9687
+ this.logger.warn('The --path option is deprecated as insight assets are now bundled into main.js');
9688
+ return val;
9689
+ }
9690
+ parseSilentOption() {
9691
+ return true;
9692
+ }
9693
+ parsePortOption(val) {
9694
+ return parseInt(val, 10);
9695
+ }
9696
+ async run(passedParams, options) {
9697
+ await this.validateMetadata();
9698
+ const app = external_express_namespaceObject();
9699
+ // Get the port from options or find an available one
9700
+ const port = await this.findAvailablePort(options?.port);
9701
+ // Load insight assets
9702
+ let insightAssets;
9703
+ try {
9704
+ insightAssets = loadInsightAssets();
9705
+ this.logger.log('Successfully loaded insight assets');
9706
+ } catch (error) {
9707
+ this.logger.error(`Failed to load insight assets: ${error.message}`);
9708
+ throw error;
9709
+ }
9710
+ // Set up middleware to serve bundled assets
9711
+ app.use(external_express_namespaceObject["static"]('public'));
9712
+ // Serve CSS file
9713
+ app.get('/assets/index-*.css', (req, res)=>{
9714
+ res.type('text/css');
9715
+ res.send(insightAssets.css);
9716
+ });
9717
+ // Serve JS file
9718
+ app.get('/assets/index-*.js', (req, res)=>{
9719
+ res.type('application/javascript');
9720
+ res.send(insightAssets.js);
9721
+ });
9722
+ // Serve favicon
9723
+ app.get('/favicon.ico', (req, res)=>{
9724
+ res.type('image/x-icon');
9725
+ res.send(insightAssets.favicon);
9726
+ });
9727
+ // API route - parse JSON body
9728
+ app.use(external_express_namespaceObject.json());
9729
+ app.use(external_express_namespaceObject.urlencoded({
9730
+ extended: true
9731
+ }));
9732
+ app.use('/api', async (req, res)=>await this.handleApiRequests(req, res));
9733
+ // Fallback to index.html for SPA routing
9734
+ app.get('*', (req, res)=>{
9735
+ res.type('text/html');
9736
+ res.send(insightAssets.html);
9737
+ });
9738
+ this.server = app.listen(port, ()=>{
9739
+ // Clear console for a cleaner look
9740
+ console.clear();
9741
+ // Print a decorative header
9742
+ console.log('\n' + external_chalk_default().bold.cyan('╔════════════════════════════════════════════════════════════╗'));
9743
+ console.log(external_chalk_default().bold.cyan('║ ') + external_chalk_default().bold.yellow('INTRIG INSIGHT SERVER') + external_chalk_default().bold.cyan(' ║'));
9744
+ console.log(external_chalk_default().bold.cyan('╚════════════════════════════════════════════════════════════╝\n'));
9745
+ // Server URL with prominent styling
9746
+ console.log(external_chalk_default().bold.green('✓ ') + external_chalk_default().bold('Server Status: ') + external_chalk_default().green('Running'));
9747
+ console.log(external_chalk_default().bold.green('✓ ') + external_chalk_default().bold('Server URL: ') + external_chalk_default().blue.underline(`http://localhost:${port}`) + '\n');
9748
+ // Port information with appropriate styling
9749
+ console.log(external_chalk_default().bold.magenta('ℹ ') + external_chalk_default().bold('Port: ') + external_chalk_default().magenta(`${port}`));
9750
+ // Routes information
9751
+ console.log(external_chalk_default().bold.magenta('ℹ ') + external_chalk_default().bold('Routes: '));
9752
+ console.log(external_chalk_default().bold.gray(' ├─ ') + external_chalk_default().gray('API ') + external_chalk_default().blue.underline(`http://localhost:${port}/api`));
9753
+ console.log(external_chalk_default().bold.gray(' └─ ') + external_chalk_default().gray('ASSETS ') + external_chalk_default().blue.underline(`http://localhost:${port}/assets`));
9754
+ // Footer with helpful information
9755
+ console.log('\n' + external_chalk_default().cyan('Press Ctrl+C to stop the server') + '\n');
9756
+ });
9757
+ // Handle graceful shutdown
9758
+ process.on('SIGINT', ()=>this.shutdown());
9759
+ process.on('SIGTERM', ()=>this.shutdown());
9760
+ // Only open the browser if the silent flag is not set
9761
+ if (!options?.silent) {
9762
+ await external_open_default().default(`http://localhost:${port}`);
9763
+ }
9764
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
9765
+ return new Promise(()=>{});
9766
+ }
9767
+ shutdown() {
9768
+ if (this.server) {
9769
+ console.log('\n' + external_chalk_default().yellow('⏳ ') + external_chalk_default().bold('Shutting down insight server...'));
9770
+ this.server.close(()=>{
9771
+ console.log(external_chalk_default().green('✓ ') + external_chalk_default().bold('Insight server has been shut down successfully'));
9772
+ process.exit(0);
9773
+ });
9774
+ } else {
9775
+ process.exit(0);
9776
+ }
9777
+ }
9778
+ /**
9779
+ * Checks if a port is available
9780
+ * @param port The port to check
9781
+ * @returns Promise that resolves to true if port is available, false otherwise
9782
+ */ isPortAvailable(port) {
9783
+ return new Promise((resolve)=>{
9784
+ const server = external_net_namespaceObject.createServer();
9785
+ server.once('error', ()=>{
9786
+ resolve(false);
9787
+ });
9788
+ server.once('listening', ()=>{
9789
+ server.close();
9790
+ resolve(true);
9791
+ });
9792
+ server.listen(port);
9793
+ });
9794
+ }
9795
+ async validateMetadata() {
9796
+ const metadata = await this.pm.getMetadata();
9797
+ if (!metadata) {
9798
+ console.error(external_chalk_default().red.bold('Error:'), external_chalk_default().red('No metadata found.'));
9799
+ process.exit(1);
9800
+ }
9801
+ return metadata;
9802
+ }
9803
+ /**
9804
+ * Finds an available port based on the following logic:
9805
+ * 1. If user specified a port, use it
9806
+ * 2. Otherwise try ports from SOCIAL_NUMBERS array
9807
+ * 3. If all are unavailable, start from 7007 and go upward
9808
+ * @param userPort Optional user-specified port
9809
+ * @returns Promise that resolves to an available port
9810
+ */ /**
9811
+ * Handles API requests by proxying them to the backend server
9812
+ * @param req Express request object
9813
+ * @param res Express response object
9814
+ */ async handleApiRequests(req, res) {
9815
+ try {
9816
+ // Get metadata which contains the base URL
9817
+ const metadata = await this.validateMetadata();
9818
+ const baseUrl = metadata.url;
9819
+ // Construct the target URL by combining base URL with the request path
9820
+ // Keep the original path as-is, the server expects the full path
9821
+ const path = req.url;
9822
+ // Make sure baseUrl doesn't end with a slash and path starts with a slash
9823
+ const cleanBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
9824
+ const targetUrl = `${cleanBaseUrl}/api${path}`;
9825
+ // Create config for the HTTP request
9826
+ const config = {
9827
+ method: req.method,
9828
+ url: targetUrl,
9829
+ headers: {
9830
+ ...req.headers
9831
+ },
9832
+ data: req.body,
9833
+ responseType: 'arraybuffer'
9834
+ };
9835
+ // Remove headers that might cause issues
9836
+ delete config.headers.host;
9837
+ delete config.headers.connection;
9838
+ // Forward the request to the backend server
9839
+ const response = await this.httpService.axiosRef.request(config);
9840
+ // Set response headers
9841
+ Object.keys(response.headers).forEach((header)=>{
9842
+ res.setHeader(header, response.headers[header]);
9843
+ });
9844
+ // Send the response with the same status code
9845
+ res.status(response.status).send(response.data);
9846
+ } catch (error) {
9847
+ // Handle errors
9848
+ this.logger.error(`API proxy error: ${error.message}`);
9849
+ // If we have a response from the server, forward it
9850
+ if (error.response) {
9851
+ const { status, headers, data } = error.response;
9852
+ // Set response headers
9853
+ Object.keys(headers).forEach((header)=>{
9854
+ res.setHeader(header, headers[header]);
9855
+ });
9856
+ // Send the error response with the same status code
9857
+ res.status(status).send(data);
9858
+ } else {
9859
+ // If there's no response, send a generic error
9860
+ res.status(500).json({
9861
+ error: 'Internal Server Error',
9862
+ message: error.message
9863
+ });
9864
+ }
9865
+ }
9866
+ }
9867
+ async findAvailablePort(userPort) {
9868
+ // If user specified a port, try to use it
9869
+ if (userPort) {
9870
+ const isAvailable = await this.isPortAvailable(userPort);
9871
+ if (isAvailable) {
9872
+ return userPort;
9873
+ }
9874
+ this.logger.warn(`Port ${userPort} is not available, trying alternative ports`);
9875
+ }
9876
+ // Try ports from SOCIAL_NUMBERS
9877
+ for (const port of SOCIAL_NUMBERS){
9878
+ const isAvailable = await this.isPortAvailable(port);
9879
+ if (isAvailable) {
9880
+ return port;
9881
+ }
9882
+ }
9883
+ // If all SOCIAL_NUMBERS ports are unavailable, start from 7007
9884
+ let port = 7007;
9885
+ while(true){
9886
+ const isAvailable = await this.isPortAvailable(port);
9887
+ if (isAvailable) {
9888
+ return port;
9889
+ }
9890
+ port++;
9891
+ }
9892
+ }
9893
+ }
9894
+ insight_command_ts_decorate([
9895
+ (0,external_nest_commander_namespaceObject.Option)({
9896
+ flags: '-p, --path [path]',
9897
+ description: 'Path to custom insight build directory (Note: This option is deprecated as assets are now bundled)'
9898
+ }),
9899
+ insight_command_ts_metadata("design:type", Function),
9900
+ insight_command_ts_metadata("design:paramtypes", [
9901
+ String
9902
+ ]),
9903
+ insight_command_ts_metadata("design:returntype", String)
9904
+ ], InsightCommand.prototype, "parsePathOption", null);
9905
+ insight_command_ts_decorate([
9906
+ (0,external_nest_commander_namespaceObject.Option)({
9907
+ flags: '-s, --silent',
9908
+ description: 'Start the server without automatically opening the browser'
9909
+ }),
9910
+ insight_command_ts_metadata("design:type", Function),
9911
+ insight_command_ts_metadata("design:paramtypes", []),
9912
+ insight_command_ts_metadata("design:returntype", Boolean)
9913
+ ], InsightCommand.prototype, "parseSilentOption", null);
9914
+ insight_command_ts_decorate([
9915
+ (0,external_nest_commander_namespaceObject.Option)({
9916
+ flags: '--port [port]',
9917
+ description: 'Specify the port to run the server on'
9918
+ }),
9919
+ insight_command_ts_metadata("design:type", Function),
9920
+ insight_command_ts_metadata("design:paramtypes", [
9921
+ String
9922
+ ]),
9923
+ insight_command_ts_metadata("design:returntype", Number)
9924
+ ], InsightCommand.prototype, "parsePortOption", null);
9925
+ InsightCommand = insight_command_ts_decorate([
9926
+ (0,external_nest_commander_namespaceObject.Command)({
9927
+ name: "insight",
9928
+ description: "Start insight server and host insight assets."
9929
+ }),
9930
+ insight_command_ts_metadata("design:type", Function),
9931
+ insight_command_ts_metadata("design:paramtypes", [
9932
+ typeof ProcessManagerService === "undefined" ? Object : ProcessManagerService,
9933
+ typeof axios_namespaceObject.HttpService === "undefined" ? Object : axios_namespaceObject.HttpService
9934
+ ])
9935
+ ], InsightCommand);
9936
+
9481
9937
  ;// ./src/app/cli/commands/prebuild.command.ts
9482
9938
  function prebuild_command_ts_decorate(decorators, target, key, desc) {
9483
9939
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -9591,71 +10047,294 @@ PostbuildCommand = postbuild_command_ts_decorate([
9591
10047
  ])
9592
10048
  ], PostbuildCommand);
9593
10049
 
9594
- ;// ./src/app/cli/cli.module.ts
9595
- function cli_module_ts_decorate(decorators, target, key, desc) {
10050
+ ;// ./src/app/cli/commands/view.command.ts
10051
+ function view_command_ts_decorate(decorators, target, key, desc) {
9596
10052
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9597
10053
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9598
10054
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9599
10055
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9600
10056
  }
10057
+ function view_command_ts_metadata(k, v) {
10058
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10059
+ }
9601
10060
 
9602
10061
 
9603
10062
 
9604
10063
 
9605
10064
 
9606
10065
 
9607
-
9608
-
9609
-
9610
-
9611
-
9612
-
9613
-
9614
-
9615
-
9616
-
9617
- class CliModule {
9618
- }
9619
- CliModule = cli_module_ts_decorate([
9620
- (0,common_namespaceObject.Module)({
9621
- imports: [
9622
- CommonModule,
9623
- DiscoveryModule,
9624
- axios_namespaceObject.HttpModule,
9625
- NextCliModule,
9626
- ReactCliModule
9627
- ],
9628
- providers: [
9629
- ProcessManagerService,
9630
- ...DeamonCommand.registerWithSubCommands(),
9631
- GenerateCommand,
9632
- InitCommand,
9633
- ...SourcesCommand.registerWithSubCommands(),
9634
- SyncCommand,
9635
- SearchCommand,
9636
- axios_namespaceObject.HttpModule,
9637
- PrebuildCommand,
9638
- PostbuildCommand,
9639
- {
9640
- provide: GENERATORS,
9641
- inject: [
9642
- NextCliService,
9643
- ReactCliService
9644
- ],
9645
- useFactory (nextCliService, reactCliService) {
9646
- return [
9647
- nextCliService,
9648
- reactCliService
9649
- ];
10066
+ class ViewCommand extends external_nest_commander_namespaceObject.CommandRunner {
10067
+ constructor(pm, httpService){
10068
+ super(), this.pm = pm, this.httpService = httpService;
10069
+ }
10070
+ parseNoInteractiveOption(val) {
10071
+ return val;
10072
+ }
10073
+ parseTypeOption(val) {
10074
+ return val;
10075
+ }
10076
+ parseTabOptionIndexOption(val) {
10077
+ return parseInt(val, 10);
10078
+ }
10079
+ async validateMetadata() {
10080
+ const metadata = await this.pm.getMetadata();
10081
+ if (!metadata) {
10082
+ console.error(external_chalk_default().red.bold('Error:'), external_chalk_default().red('No metadata found.'));
10083
+ process.exit(1);
10084
+ }
10085
+ return metadata;
10086
+ }
10087
+ validateId(id) {
10088
+ if (!id) {
10089
+ console.error(external_chalk_default().red.bold('Error:'), external_chalk_default().red('Resource ID is required.'));
10090
+ process.exit(1);
10091
+ }
10092
+ return id;
10093
+ }
10094
+ async fetchInitialResource(metadata, id) {
10095
+ const initialEndpoint = `/api/data/get/${id}`;
10096
+ console.log(external_chalk_default().gray(`\n→ Fetching resource details from ${metadata.url}${initialEndpoint}`));
10097
+ try {
10098
+ const initialResponse = await (0,external_rxjs_namespaceObject.lastValueFrom)(this.httpService.get(`${metadata.url}${initialEndpoint}`, {
10099
+ headers: {
10100
+ Accept: 'application/json'
9650
10101
  }
10102
+ }));
10103
+ const initialResource = initialResponse.data;
10104
+ if (!initialResource) {
10105
+ console.error(external_chalk_default().red.bold('Error:'), external_chalk_default().red(`Resource with ID ${id} not found.`));
10106
+ process.exit(1);
9651
10107
  }
9652
- ]
9653
- })
9654
- ], CliModule);
9655
-
9656
- ;// external "js-yaml"
9657
- const external_js_yaml_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("js-yaml");
9658
- ;// ./src/app/deamon/services/openapi.service.ts
10108
+ return {
10109
+ initialResource,
10110
+ initialEndpoint
10111
+ };
10112
+ } catch (err) {
10113
+ console.error(external_chalk_default().red.bold('Error:'), external_chalk_default().red(err.message || 'Failed to fetch resource details.'));
10114
+ process.exit(1);
10115
+ }
10116
+ }
10117
+ async determineResourceType(initialResource) {
10118
+ return initialResource.type || process.exit(1);
10119
+ }
10120
+ async fetchDetailedResource(metadata, id, resourceType) {
10121
+ let detailedEndpoint = '';
10122
+ if (resourceType === 'schema') {
10123
+ detailedEndpoint = `/api/data/get/schema/${id}`;
10124
+ } else if (resourceType === 'rest') {
10125
+ detailedEndpoint = `/api/data/get/endpoint/${id}`;
10126
+ }
10127
+ try {
10128
+ const detailedResponse = await (0,external_rxjs_namespaceObject.lastValueFrom)(this.httpService.get(`${metadata.url}${detailedEndpoint}`, {
10129
+ headers: {
10130
+ Accept: 'application/json'
10131
+ }
10132
+ }));
10133
+ return detailedResponse.data;
10134
+ } catch (err) {
10135
+ console.log(external_chalk_default().yellow(`\n⚠ Could not fetch detailed ${resourceType} data. Using basic resource information.`));
10136
+ return undefined;
10137
+ }
10138
+ }
10139
+ async handleTabSelection(tabs, options) {
10140
+ if (!tabs || tabs.length === 0) {
10141
+ return null;
10142
+ }
10143
+ // Create choices for tab selection
10144
+ const tabChoices = tabs.map((tab)=>({
10145
+ name: tab.name,
10146
+ value: tab
10147
+ }));
10148
+ let selectedTab;
10149
+ console.log(options);
10150
+ // Handle non-interactive mode for tab selection
10151
+ if (!options?.interactive) {
10152
+ // Check if tab option is provided
10153
+ if (options?.tabOption) {
10154
+ const tabOptionIndex = options.tabOption;
10155
+ if (tabOptionIndex < 1 || tabOptionIndex > tabChoices.length) {
10156
+ console.error(`Error: Tab option index out of range. Must be between 1 and ${tabChoices.length}.`);
10157
+ process.exit(1);
10158
+ }
10159
+ selectedTab = tabChoices[tabOptionIndex - 1].value;
10160
+ } else {
10161
+ console.log('\nSelect a tab to view ( use \'--tab-option\' flag. eg: intrig view xxx --type \'Endpoint\' --tab-option 1 )');
10162
+ tabChoices.forEach((choice, index)=>{
10163
+ console.log(` ${index + 1}. ${choice.name}`);
10164
+ });
10165
+ // Exit after displaying options
10166
+ process.exit(0);
10167
+ }
10168
+ } else {
10169
+ // Interactive mode: prompt user to select a tab
10170
+ const tabAnswer = await external_inquirer_default().prompt([
10171
+ {
10172
+ type: 'list',
10173
+ name: 'selectedTab',
10174
+ message: 'Select a tab to view:',
10175
+ choices: tabChoices
10176
+ }
10177
+ ]);
10178
+ selectedTab = tabAnswer.selectedTab;
10179
+ }
10180
+ return selectedTab;
10181
+ }
10182
+ displayResourceContent(selectedTab, resourceType, detailedResource) {
10183
+ if (selectedTab) {
10184
+ // Display the selected tab content
10185
+ console.log(external_chalk_default().green.bold(`\n✔ ${selectedTab.name} Content:`));
10186
+ console.log(selectedTab.content);
10187
+ } else {
10188
+ // If no tabs are available, display the entire resource
10189
+ console.log(external_chalk_default().green.bold(`\n✔ ${resourceType.charAt(0).toUpperCase() + resourceType.slice(1)} Details:`));
10190
+ console.log(JSON.stringify(detailedResource, null, 2));
10191
+ }
10192
+ }
10193
+ async recordVisit(metadata, resource, resourceType) {
10194
+ if (resource.id && (resourceType === 'schema' || resourceType === 'endpoint')) {
10195
+ try {
10196
+ await (0,external_rxjs_namespaceObject.lastValueFrom)(this.httpService.post(`${metadata.url}/api/data/visit`, {
10197
+ id: resource.id,
10198
+ type: resourceType,
10199
+ source: resource.source || '',
10200
+ name: resource.name || resource.id
10201
+ }));
10202
+ } catch (err) {
10203
+ // Silently ignore errors when recording visit
10204
+ }
10205
+ }
10206
+ }
10207
+ async run(passedParams, options) {
10208
+ try {
10209
+ const metadata = await this.validateMetadata();
10210
+ const id = this.validateId(passedParams[0]);
10211
+ const { initialResource } = await this.fetchInitialResource(metadata, id);
10212
+ const resourceType = await this.determineResourceType(initialResource);
10213
+ const detailedResource = await this.fetchDetailedResource(metadata, id, resourceType);
10214
+ const tabs = detailedResource?.tabs;
10215
+ const selectedTab = await this.handleTabSelection(tabs, options);
10216
+ this.displayResourceContent(selectedTab, resourceType, detailedResource);
10217
+ await this.recordVisit(metadata, initialResource, resourceType);
10218
+ } catch (err) {
10219
+ console.error(external_chalk_default().red.bold('Error:'), external_chalk_default().red(err.message || 'Failed to fetch resource details.'));
10220
+ process.exit(1);
10221
+ }
10222
+ }
10223
+ }
10224
+ view_command_ts_decorate([
10225
+ (0,external_nest_commander_namespaceObject.Option)({
10226
+ flags: '--no-interactive',
10227
+ description: 'Display options without an interactive prompt'
10228
+ }),
10229
+ view_command_ts_metadata("design:type", Function),
10230
+ view_command_ts_metadata("design:paramtypes", [
10231
+ Boolean
10232
+ ]),
10233
+ view_command_ts_metadata("design:returntype", Boolean)
10234
+ ], ViewCommand.prototype, "parseNoInteractiveOption", null);
10235
+ view_command_ts_decorate([
10236
+ (0,external_nest_commander_namespaceObject.Option)({
10237
+ flags: '--type [type]',
10238
+ description: 'Resource type (schema or endpoint)'
10239
+ }),
10240
+ view_command_ts_metadata("design:type", Function),
10241
+ view_command_ts_metadata("design:paramtypes", [
10242
+ String
10243
+ ]),
10244
+ view_command_ts_metadata("design:returntype", String)
10245
+ ], ViewCommand.prototype, "parseTypeOption", null);
10246
+ view_command_ts_decorate([
10247
+ (0,external_nest_commander_namespaceObject.Option)({
10248
+ flags: '--tab-option [index]',
10249
+ description: 'Select tab by index (works with --no-interactive)'
10250
+ }),
10251
+ view_command_ts_metadata("design:type", Function),
10252
+ view_command_ts_metadata("design:paramtypes", [
10253
+ String
10254
+ ]),
10255
+ view_command_ts_metadata("design:returntype", Number)
10256
+ ], ViewCommand.prototype, "parseTabOptionIndexOption", null);
10257
+ ViewCommand = view_command_ts_decorate([
10258
+ (0,external_nest_commander_namespaceObject.Command)({
10259
+ name: 'view',
10260
+ description: 'View resource details by ID'
10261
+ }),
10262
+ view_command_ts_metadata("design:type", Function),
10263
+ view_command_ts_metadata("design:paramtypes", [
10264
+ typeof ProcessManagerService === "undefined" ? Object : ProcessManagerService,
10265
+ typeof axios_namespaceObject.HttpService === "undefined" ? Object : axios_namespaceObject.HttpService
10266
+ ])
10267
+ ], ViewCommand);
10268
+
10269
+ ;// ./src/app/cli/cli.module.ts
10270
+ function cli_module_ts_decorate(decorators, target, key, desc) {
10271
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10272
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10273
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10274
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10275
+ }
10276
+
10277
+
10278
+
10279
+
10280
+
10281
+
10282
+
10283
+
10284
+
10285
+
10286
+
10287
+
10288
+
10289
+
10290
+
10291
+
10292
+
10293
+
10294
+ class CliModule {
10295
+ }
10296
+ CliModule = cli_module_ts_decorate([
10297
+ (0,common_namespaceObject.Module)({
10298
+ imports: [
10299
+ CommonModule,
10300
+ DiscoveryModule,
10301
+ axios_namespaceObject.HttpModule,
10302
+ NextCliModule,
10303
+ ReactCliModule
10304
+ ],
10305
+ providers: [
10306
+ ProcessManagerService,
10307
+ ...DeamonCommand.registerWithSubCommands(),
10308
+ GenerateCommand,
10309
+ InitCommand,
10310
+ ...SourcesCommand.registerWithSubCommands(),
10311
+ SyncCommand,
10312
+ SearchCommand,
10313
+ ViewCommand,
10314
+ axios_namespaceObject.HttpModule,
10315
+ InsightCommand,
10316
+ PrebuildCommand,
10317
+ PostbuildCommand,
10318
+ {
10319
+ provide: GENERATORS,
10320
+ inject: [
10321
+ NextCliService,
10322
+ ReactCliService
10323
+ ],
10324
+ useFactory (nextCliService, reactCliService) {
10325
+ return [
10326
+ nextCliService,
10327
+ reactCliService
10328
+ ];
10329
+ }
10330
+ }
10331
+ ]
10332
+ })
10333
+ ], CliModule);
10334
+
10335
+ ;// external "js-yaml"
10336
+ const external_js_yaml_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("js-yaml");
10337
+ ;// ./src/app/deamon/services/openapi.service.ts
9659
10338
  function openapi_service_ts_decorate(decorators, target, key, desc) {
9660
10339
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9661
10340
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -9835,6 +10514,14 @@ class SourcesController {
9835
10514
  this.logger.log('Listing all sources');
9836
10515
  return this.configService.list();
9837
10516
  }
10517
+ getById(id) {
10518
+ this.logger.log(`Getting source with id: ${id}`);
10519
+ const source = this.configService.list().find((source)=>source.id === id);
10520
+ if (!source) {
10521
+ throw new common_namespaceObject.NotFoundException(`Source with id ${id} not found`);
10522
+ }
10523
+ return source;
10524
+ }
9838
10525
  }
9839
10526
  sources_controller_ts_decorate([
9840
10527
  (0,swagger_namespaceObject.ApiBody)({
@@ -9892,6 +10579,23 @@ sources_controller_ts_decorate([
9892
10579
  sources_controller_ts_metadata("design:paramtypes", []),
9893
10580
  sources_controller_ts_metadata("design:returntype", Array)
9894
10581
  ], SourcesController.prototype, "list", null);
10582
+ sources_controller_ts_decorate([
10583
+ (0,swagger_namespaceObject.ApiResponse)({
10584
+ status: 200,
10585
+ type: IntrigSourceConfig
10586
+ }),
10587
+ (0,swagger_namespaceObject.ApiResponse)({
10588
+ status: 404,
10589
+ description: 'Source not found'
10590
+ }),
10591
+ (0,common_namespaceObject.Get)(":id"),
10592
+ sources_controller_ts_param(0, (0,common_namespaceObject.Param)('id')),
10593
+ sources_controller_ts_metadata("design:type", Function),
10594
+ sources_controller_ts_metadata("design:paramtypes", [
10595
+ String
10596
+ ]),
10597
+ sources_controller_ts_metadata("design:returntype", typeof IntrigSourceConfig === "undefined" ? Object : IntrigSourceConfig)
10598
+ ], SourcesController.prototype, "getById", null);
9895
10599
  SourcesController = sources_controller_ts_decorate([
9896
10600
  (0,swagger_namespaceObject.ApiTags)('Sources'),
9897
10601
  (0,swagger_namespaceObject.ApiExtraModels)(IntrigSourceConfig),
@@ -10396,14 +11100,15 @@ function source_stats_ts_metadata(k, v) {
10396
11100
  }
10397
11101
 
10398
11102
  class SourceStats {
10399
- constructor(total, countsByType, uniqueSources, uniqueSourcesCount){
11103
+ constructor(total, countsByType, uniqueSources, uniqueSourcesCount, controllerCount){
10400
11104
  this.total = total;
10401
11105
  this.countsByType = countsByType;
10402
11106
  this.uniqueSources = uniqueSources;
10403
11107
  this.uniqueSourcesCount = uniqueSourcesCount;
11108
+ this.controllerCount = controllerCount;
10404
11109
  }
10405
11110
  static from(stats) {
10406
- return new SourceStats(stats.total, stats.countsByType, stats.uniqueSources, stats.uniqueSourcesCount);
11111
+ return new SourceStats(stats.total, stats.countsByType, stats.uniqueSources, stats.uniqueSourcesCount, stats.controllerCount);
10407
11112
  }
10408
11113
  }
10409
11114
  source_stats_ts_decorate([
@@ -10433,6 +11138,319 @@ source_stats_ts_decorate([
10433
11138
  }),
10434
11139
  source_stats_ts_metadata("design:type", Number)
10435
11140
  ], SourceStats.prototype, "uniqueSourcesCount", void 0);
11141
+ source_stats_ts_decorate([
11142
+ (0,swagger_namespaceObject.ApiProperty)({
11143
+ description: 'Number of unique paths in endpoints'
11144
+ }),
11145
+ source_stats_ts_metadata("design:type", Number)
11146
+ ], SourceStats.prototype, "controllerCount", void 0);
11147
+
11148
+ ;// ./src/app/deamon/models/data-stats.ts
11149
+ function data_stats_ts_decorate(decorators, target, key, desc) {
11150
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11151
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11152
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11153
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11154
+ }
11155
+ function data_stats_ts_metadata(k, v) {
11156
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11157
+ }
11158
+
11159
+ class DataStats {
11160
+ constructor(sourceCount, endpointCount, dataTypeCount, controllerCount, usedEndpointCount = 0, usedDataTypeCount = 0, usedSourceCount = 0, usedControllerCount = 0){
11161
+ this.sourceCount = sourceCount;
11162
+ this.endpointCount = endpointCount;
11163
+ this.dataTypeCount = dataTypeCount;
11164
+ this.controllerCount = controllerCount;
11165
+ this.usedEndpointCount = usedEndpointCount;
11166
+ this.usedDataTypeCount = usedDataTypeCount;
11167
+ this.usedSourceCount = usedSourceCount;
11168
+ this.usedControllerCount = usedControllerCount;
11169
+ }
11170
+ static from(stats) {
11171
+ return new DataStats(stats.sourceCount, stats.endpointCount, stats.dataTypeCount, stats.controllerCount, stats.usedEndpointCount, stats.usedDataTypeCount, stats.usedSourceCount, stats.usedControllerCount);
11172
+ }
11173
+ }
11174
+ data_stats_ts_decorate([
11175
+ (0,swagger_namespaceObject.ApiProperty)({
11176
+ description: 'Number of unique sources'
11177
+ }),
11178
+ data_stats_ts_metadata("design:type", Number)
11179
+ ], DataStats.prototype, "sourceCount", void 0);
11180
+ data_stats_ts_decorate([
11181
+ (0,swagger_namespaceObject.ApiProperty)({
11182
+ description: 'Number of endpoints'
11183
+ }),
11184
+ data_stats_ts_metadata("design:type", Number)
11185
+ ], DataStats.prototype, "endpointCount", void 0);
11186
+ data_stats_ts_decorate([
11187
+ (0,swagger_namespaceObject.ApiProperty)({
11188
+ description: 'Number of data types'
11189
+ }),
11190
+ data_stats_ts_metadata("design:type", Number)
11191
+ ], DataStats.prototype, "dataTypeCount", void 0);
11192
+ data_stats_ts_decorate([
11193
+ (0,swagger_namespaceObject.ApiProperty)({
11194
+ description: 'Number of unique paths in endpoints'
11195
+ }),
11196
+ data_stats_ts_metadata("design:type", Number)
11197
+ ], DataStats.prototype, "controllerCount", void 0);
11198
+ data_stats_ts_decorate([
11199
+ (0,swagger_namespaceObject.ApiProperty)({
11200
+ description: 'Number of unique endpoints used in the codebase'
11201
+ }),
11202
+ data_stats_ts_metadata("design:type", Number)
11203
+ ], DataStats.prototype, "usedEndpointCount", void 0);
11204
+ data_stats_ts_decorate([
11205
+ (0,swagger_namespaceObject.ApiProperty)({
11206
+ description: 'Number of data types used in the codebase'
11207
+ }),
11208
+ data_stats_ts_metadata("design:type", Number)
11209
+ ], DataStats.prototype, "usedDataTypeCount", void 0);
11210
+ data_stats_ts_decorate([
11211
+ (0,swagger_namespaceObject.ApiProperty)({
11212
+ description: 'Number of sources used in the codebase'
11213
+ }),
11214
+ data_stats_ts_metadata("design:type", Number)
11215
+ ], DataStats.prototype, "usedSourceCount", void 0);
11216
+ data_stats_ts_decorate([
11217
+ (0,swagger_namespaceObject.ApiProperty)({
11218
+ description: 'Number of controllers used in the codebase'
11219
+ }),
11220
+ data_stats_ts_metadata("design:type", Number)
11221
+ ], DataStats.prototype, "usedControllerCount", void 0);
11222
+
11223
+ ;// external "ts-morph"
11224
+ const external_ts_morph_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("ts-morph");
11225
+ ;// ./src/app/utils/code-analyzer.ts
11226
+ function code_analyzer_ts_decorate(decorators, target, key, desc) {
11227
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11228
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11229
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11230
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11231
+ }
11232
+ function code_analyzer_ts_metadata(k, v) {
11233
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11234
+ }
11235
+
11236
+
11237
+
11238
+
11239
+
11240
+ class CodeAnalyzer {
11241
+ /**
11242
+ * Creates a new CodeAnalyzer instance
11243
+ */ constructor(configService, intrigConfigService){
11244
+ this.configService = configService;
11245
+ this.intrigConfigService = intrigConfigService;
11246
+ this.logger = new common_namespaceObject.Logger(CodeAnalyzer.name);
11247
+ this.sourceUsageMap = new Map();
11248
+ this.dataTypeUsageMap = new Map();
11249
+ this.controllerUsageMap = new Map();
11250
+ this.endpointUsageMap = new Map();
11251
+ // Current list of resource descriptors
11252
+ this.currentDescriptors = [];
11253
+ const projectRootPath = process.cwd();
11254
+ const config = this.intrigConfigService.get();
11255
+ const tsConfigPath = config.codeAnalyzer?.tsConfigPath || 'tsconfig.json';
11256
+ this.project = new external_ts_morph_namespaceObject.Project({
11257
+ tsConfigFilePath: external_path_namespaceObject.join(projectRootPath, tsConfigPath)
11258
+ });
11259
+ }
11260
+ /**
11261
+ * Set the current list of resource descriptors
11262
+ * @param descriptors List of resource descriptors to analyze against
11263
+ */ setResourceDescriptors(descriptors) {
11264
+ this.logger.debug(`Setting ${descriptors.length} resource descriptors for analysis`);
11265
+ this.currentDescriptors = descriptors;
11266
+ }
11267
+ /**
11268
+ * Get the current list of resource descriptors
11269
+ */ getResourceDescriptors() {
11270
+ return this.currentDescriptors;
11271
+ }
11272
+ /**
11273
+ * Check if an endpoint is used in the codebase
11274
+ * @param endpointName The name of the endpoint to check
11275
+ * @param includeAsync Whether to check async variants as well
11276
+ */ isEndpointUsed(endpointName, includeAsync = true) {
11277
+ return this.endpointUsageMap.has(endpointName);
11278
+ }
11279
+ /**
11280
+ * Check if a data type is used in the codebase
11281
+ * @param typeName The name of the data type to check
11282
+ */ isDataTypeUsed(typeName) {
11283
+ return this.dataTypeUsageMap.has(typeName);
11284
+ }
11285
+ /**
11286
+ * Get usage statistics for the current resource descriptors
11287
+ */ getUsageStats() {
11288
+ const usedEndpoints = [];
11289
+ const unusedEndpoints = [];
11290
+ const usedDataTypes = [];
11291
+ const unusedDataTypes = [];
11292
+ // Process endpoints
11293
+ const endpointDescriptors = this.currentDescriptors.filter((d)=>d.type === 'rest');
11294
+ endpointDescriptors.forEach((descriptor)=>{
11295
+ const name = descriptor.name;
11296
+ if (this.isEndpointUsed(name)) {
11297
+ usedEndpoints.push(name);
11298
+ } else {
11299
+ unusedEndpoints.push(name);
11300
+ }
11301
+ });
11302
+ // Process data types
11303
+ const dataTypeDescriptors = this.currentDescriptors.filter((d)=>d.type === 'schema');
11304
+ dataTypeDescriptors.forEach((descriptor)=>{
11305
+ const name = descriptor.name;
11306
+ if (this.isDataTypeUsed(name)) {
11307
+ usedDataTypes.push(name);
11308
+ } else {
11309
+ unusedDataTypes.push(name);
11310
+ }
11311
+ });
11312
+ return {
11313
+ usedEndpoints,
11314
+ unusedEndpoints,
11315
+ usedDataTypes,
11316
+ unusedDataTypes
11317
+ };
11318
+ }
11319
+ /**
11320
+ * Trigger reindexing of the codebase
11321
+ * @param sourceGlobs Optional glob patterns to limit the analysis to specific files
11322
+ */ reindex(sourceGlobs = [
11323
+ '**/*.ts',
11324
+ '**/*.tsx'
11325
+ ]) {
11326
+ this.logger.debug(`Reindexing codebase with patterns: ${sourceGlobs.join(', ')}`);
11327
+ // Clear previous analysis results
11328
+ this.clearAnalysisResults();
11329
+ // Perform the analysis
11330
+ this.analyze(sourceGlobs);
11331
+ }
11332
+ /**
11333
+ * Clear all analysis results
11334
+ */ clearAnalysisResults() {
11335
+ this.sourceUsageMap.clear();
11336
+ this.dataTypeUsageMap.clear();
11337
+ this.controllerUsageMap.clear();
11338
+ this.endpointUsageMap.clear();
11339
+ }
11340
+ /**
11341
+ * Analyze the project to find endpoint and data-type usage
11342
+ * @param sourceGlobs Optional glob patterns to limit the analysis to specific files
11343
+ */ analyze(sourceGlobs = [
11344
+ '**/*.ts',
11345
+ '**/*.tsx'
11346
+ ]) {
11347
+ // Add source files to the project
11348
+ sourceGlobs.forEach((glob)=>{
11349
+ this.project.addSourceFilesAtPaths(glob);
11350
+ });
11351
+ // Process each source file
11352
+ const sourceFiles = this.project.getSourceFiles();
11353
+ sourceFiles.forEach((sourceFile)=>{
11354
+ sourceFile.getImportDeclarations().map((importDecl)=>importDecl.getModuleSpecifier()?.getText().slice(1, -1).split('/')).filter((path)=>path[0] === '@intrig' && path?.length > 4).forEach((_path)=>{
11355
+ const source = _path[2];
11356
+ if (!this.sourceUsageMap.has(source)) {
11357
+ this.sourceUsageMap.set(source, new Set());
11358
+ }
11359
+ const filePath = external_path_namespaceObject.relative(this.configService.get('rootDir') ?? process.cwd(), sourceFile.getFilePath());
11360
+ this.sourceUsageMap.get(source)?.add(filePath);
11361
+ if (_path[3] === 'components') {
11362
+ const dataType = _path?.pop() ?? '';
11363
+ if (!this.dataTypeUsageMap.has(source)) {
11364
+ this.dataTypeUsageMap.set(source, new Map());
11365
+ }
11366
+ if (!this.dataTypeUsageMap.get(source)?.has(dataType)) {
11367
+ this.dataTypeUsageMap.get(source)?.set(dataType, new Set());
11368
+ }
11369
+ this.dataTypeUsageMap.get(source)?.get(dataType)?.add(filePath);
11370
+ } else {
11371
+ const controller = _path[3];
11372
+ if (!this.controllerUsageMap.has(source)) {
11373
+ this.controllerUsageMap.set(source, new Map());
11374
+ }
11375
+ if (!this.controllerUsageMap.get(source)?.has(controller)) {
11376
+ this.controllerUsageMap.get(source)?.set(controller, new Set());
11377
+ }
11378
+ this.controllerUsageMap.get(source)?.get(controller)?.add(filePath);
11379
+ const endpointName = _path[4];
11380
+ if (!this.endpointUsageMap.has(source)) {
11381
+ this.endpointUsageMap.set(source, new Map());
11382
+ }
11383
+ if (!this.endpointUsageMap.get(source)?.has(endpointName)) {
11384
+ this.endpointUsageMap.get(source)?.set(endpointName, new Set());
11385
+ }
11386
+ this.endpointUsageMap.get(source)?.get(endpointName)?.add(filePath);
11387
+ }
11388
+ });
11389
+ });
11390
+ }
11391
+ /**
11392
+ * Get the count of resources that match the specified filters
11393
+ * @param source Optional source to filter by
11394
+ * @param type Optional type to filter by ('rest' or 'schema')
11395
+ * @returns The count of resources that match the filters
11396
+ */ getUsageCounts(source, type) {
11397
+ this.logger.debug(`Getting usage counts with filters - source: ${source || 'all'}, type: ${type || 'all'}`);
11398
+ switch(type){
11399
+ case 'source':
11400
+ if (source) {
11401
+ return this.sourceUsageMap.get(source)?.size ?? 0;
11402
+ }
11403
+ return this.sourceUsageMap.size;
11404
+ case 'controller':
11405
+ if (source) {
11406
+ return this.controllerUsageMap.get(source)?.size ?? 0;
11407
+ }
11408
+ return [
11409
+ ...this.controllerUsageMap.values()
11410
+ ].reduce((acc, val)=>acc + val.size, 0) ?? 0;
11411
+ case 'endpoint':
11412
+ if (source) {
11413
+ return this.endpointUsageMap.get(source)?.size ?? 0;
11414
+ }
11415
+ return [
11416
+ ...this.endpointUsageMap.values()
11417
+ ].reduce((acc, val)=>acc + val.size, 0) ?? 0;
11418
+ case 'datatype':
11419
+ if (source) {
11420
+ return this.dataTypeUsageMap.get(source)?.size ?? 0;
11421
+ }
11422
+ return [
11423
+ ...this.dataTypeUsageMap.values()
11424
+ ].reduce((acc, val)=>acc + val.size, 0) ?? 0;
11425
+ default:
11426
+ return 0;
11427
+ }
11428
+ }
11429
+ /**
11430
+ * Get the list of files where a specific endpoint or datatype is used
11431
+ * @param sourceId The source identifier
11432
+ * @param type The type ('endpoint' or 'datatype')
11433
+ * @param id The endpoint or datatype identifier
11434
+ * @returns Array of file paths where the endpoint or datatype is used
11435
+ */ getFileList(sourceId, type, id) {
11436
+ this.logger.debug(`Getting file list for ${type} '${id}' in source '${sourceId}'`);
11437
+ const name = this.getResourceDescriptors().find((d)=>d.id === id)?.name ?? '';
11438
+ if (type === 'endpoint') {
11439
+ return Array.from(this.endpointUsageMap.get(sourceId)?.get(name) || []);
11440
+ } else if (type === 'datatype') {
11441
+ return Array.from(this.dataTypeUsageMap.get(sourceId)?.get(name) || []);
11442
+ }
11443
+ return [];
11444
+ }
11445
+ }
11446
+ CodeAnalyzer = code_analyzer_ts_decorate([
11447
+ (0,common_namespaceObject.Injectable)(),
11448
+ code_analyzer_ts_metadata("design:type", Function),
11449
+ code_analyzer_ts_metadata("design:paramtypes", [
11450
+ typeof config_namespaceObject.ConfigService === "undefined" ? Object : config_namespaceObject.ConfigService,
11451
+ typeof IntrigConfigService === "undefined" ? Object : IntrigConfigService
11452
+ ])
11453
+ ], CodeAnalyzer);
10436
11454
 
10437
11455
  ;// ./src/app/deamon/services/search.service.ts
10438
11456
  function search_service_ts_decorate(decorators, target, key, desc) {
@@ -10451,10 +11469,13 @@ function search_service_ts_metadata(k, v) {
10451
11469
 
10452
11470
 
10453
11471
 
11472
+
11473
+
10454
11474
  class SearchService {
10455
- constructor(configService, openApiService){
11475
+ constructor(configService, openApiService, codeAnalyzer){
10456
11476
  this.configService = configService;
10457
11477
  this.openApiService = openApiService;
11478
+ this.codeAnalyzer = codeAnalyzer;
10458
11479
  /** In-memory map of all descriptors */ this.descriptors = new Map();
10459
11480
  /** Weight on text relevance vs. recency */ this.alpha = 0.75;
10460
11481
  /** Half-life in hours for recency decay */ this.halfLifeHours = 24;
@@ -10488,13 +11509,34 @@ class SearchService {
10488
11509
  const descriptors = await this.openApiService.getResourceDescriptors(source.id);
10489
11510
  descriptors.forEach((descriptor)=>this.addDescriptor(descriptor));
10490
11511
  }
11512
+ // Update the CodeAnalyzer with all descriptors
11513
+ this.updateCodeAnalyzer();
11514
+ // Perform initial code analysis
11515
+ this.reindexCodebase();
10491
11516
  } catch (e) {}
10492
11517
  }
10493
11518
  /**
11519
+ * Update the CodeAnalyzer with the current descriptors
11520
+ */ updateCodeAnalyzer() {
11521
+ const descriptors = Array.from(this.descriptors.values());
11522
+ this.codeAnalyzer.setResourceDescriptors(descriptors);
11523
+ }
11524
+ /**
11525
+ * Trigger reindexing of the codebase
11526
+ */ reindexCodebase() {
11527
+ // Focus analysis on app/insight directory where React components are likely to be
11528
+ this.codeAnalyzer.reindex([
11529
+ 'app/insight/src/**/*.ts',
11530
+ 'app/insight/src/**/*.tsx'
11531
+ ]);
11532
+ }
11533
+ /**
10494
11534
  * Add a new descriptor to the index (or re-index an updated one).
10495
11535
  */ addDescriptor(desc) {
10496
11536
  this.descriptors.set(desc.id, desc);
10497
11537
  this.indexDescriptor(desc);
11538
+ // Update the CodeAnalyzer with the updated descriptors
11539
+ this.updateCodeAnalyzer();
10498
11540
  }
10499
11541
  /**
10500
11542
  * Get a descriptor by its ID.
@@ -10522,6 +11564,8 @@ class SearchService {
10522
11564
  this.mini.remove(base);
10523
11565
  }
10524
11566
  }
11567
+ // Update the CodeAnalyzer with the updated descriptors
11568
+ this.updateCodeAnalyzer();
10525
11569
  }
10526
11570
  /**
10527
11571
  * (Optional) Clear the entire index and map.
@@ -10582,10 +11626,11 @@ class SearchService {
10582
11626
  this.indexDescriptor(desc);
10583
11627
  }
10584
11628
  /**
10585
- * Search by free-text; returns up to `limit` descriptors
10586
- * sorted by α·relevance + (1-α)·recencyBoost.
10587
- */ search(query, opts = {}) {
10588
- const now = Date.now();
11629
+ * Get the total count of search results without applying pagination
11630
+ * @param query Search query
11631
+ * @param opts Search options (excluding pagination)
11632
+ * @returns Total count of matching results
11633
+ */ getTotalCount(query, opts = {}) {
10589
11634
  const fuzzy = opts.fuzzy ?? 0.2;
10590
11635
  const q = query.trim().length ? query.trim() : '__all__';
10591
11636
  const rawHits = this.mini.search(q, {
@@ -10595,11 +11640,27 @@ class SearchService {
10595
11640
  return (!opts.type || doc.type === opts.type) && (!opts.pkg || doc.package === opts.pkg) && (!opts.source || doc.source === opts.source) && (!opts.dataTypes || external_lodash_default().intersection(opts.dataTypes, doc.dataTypes)?.length > 0) && (!opts.names || opts.names.includes(doc.name));
10596
11641
  }
10597
11642
  });
10598
- // normalize the text-match scores to [0,1]
10599
- const maxScore = Math.max(...rawHits.map((h)=>h.score), 1);
10600
- const scored = rawHits.map((hit)=>{
10601
- const desc = this.descriptors.get(hit.id);
10602
- const rel = hit.score / maxScore;
11643
+ return rawHits.length;
11644
+ }
11645
+ /**
11646
+ * Search by free-text; returns up to `limit` descriptors
11647
+ * sorted by α·relevance + (1-α)·recencyBoost.
11648
+ */ search(query, opts = {}) {
11649
+ const now = Date.now();
11650
+ const fuzzy = opts.fuzzy ?? 0.2;
11651
+ const q = query.trim().length ? query.trim() : '__all__';
11652
+ const rawHits = this.mini.search(q, {
11653
+ prefix: true,
11654
+ fuzzy,
11655
+ filter (doc) {
11656
+ return (!opts.type || doc.type === opts.type) && (!opts.pkg || doc.package === opts.pkg) && (!opts.source || doc.source === opts.source) && (!opts.dataTypes || external_lodash_default().intersection(opts.dataTypes, doc.dataTypes)?.length > 0) && (!opts.names || opts.names.includes(doc.name));
11657
+ }
11658
+ });
11659
+ // normalize the text-match scores to [0,1]
11660
+ const maxScore = Math.max(...rawHits.map((h)=>h.score), 1);
11661
+ const scored = rawHits.map((hit)=>{
11662
+ const desc = this.descriptors.get(hit.id);
11663
+ const rel = hit.score / maxScore;
10603
11664
  const hours = (now - (desc.lastAccessed ?? 0)) / (1000 * 60 * 60);
10604
11665
  const decay = 1 / (1 + hours / this.halfLifeHours);
10605
11666
  const combined = this.alpha * rel + (1 - this.alpha) * decay;
@@ -10608,7 +11669,11 @@ class SearchService {
10608
11669
  combined
10609
11670
  };
10610
11671
  });
10611
- return scored.sort((a, b)=>b.combined - a.combined).slice(0, opts.limit ?? 20).map((x)=>x.desc);
11672
+ const sorted = scored.sort((a, b)=>b.combined - a.combined);
11673
+ // Apply offset and limit for pagination
11674
+ const offset = opts.offset ?? 0;
11675
+ const limit = opts.limit ?? 20;
11676
+ return sorted.slice(offset, offset + limit).map((x)=>x.desc);
10612
11677
  }
10613
11678
  /**
10614
11679
  * Return the N most-recently used descriptors.
@@ -10619,6 +11684,7 @@ class SearchService {
10619
11684
  * Get simple stats for a given source (or _all_ sources if none specified):
10620
11685
  * - counts per `type`
10621
11686
  * - list of unique `package` values (and its count)
11687
+ * - count of unique paths in endpoints (controllers)
10622
11688
  */ getStatsBySource() {
10623
11689
  // 1) grab all descriptors (or only those matching the given source)
10624
11690
  const all = Array.from(this.descriptors.values());
@@ -10634,11 +11700,64 @@ class SearchService {
10634
11700
  sources.add(d.source);
10635
11701
  }
10636
11702
  });
11703
+ // 4) count unique paths in endpoints (controllers)
11704
+ const paths = new Set();
11705
+ all.forEach((d)=>{
11706
+ if (isRestDescriptor(d) && d.path) {
11707
+ paths.add(d.path);
11708
+ }
11709
+ });
11710
+ const controllerCount = paths.size;
10637
11711
  return SourceStats.from({
10638
11712
  total: all.length,
10639
11713
  countsByType,
10640
11714
  uniqueSources: Array.from(sources),
10641
- uniqueSourcesCount: sources.size
11715
+ uniqueSourcesCount: sources.size,
11716
+ controllerCount
11717
+ });
11718
+ }
11719
+ /**
11720
+ * Get data stats including source count, endpoint count, data type count, controller count,
11721
+ * used endpoint count, and used data type count.
11722
+ * Optionally filter by source.
11723
+ * @param source Optional source to filter by
11724
+ * @param forceReindex Whether to force reindexing before calculating stats
11725
+ */ getDataStats(source, forceReindex = false) {
11726
+ // Get all descriptors or filter by source if provided
11727
+ const all = Array.from(this.descriptors.values()).filter((d)=>!source || d.source === source);
11728
+ // Count unique sources
11729
+ const sources = new Set();
11730
+ all.forEach((d)=>{
11731
+ if (d.source) {
11732
+ sources.add(d.source);
11733
+ }
11734
+ });
11735
+ // Count endpoints (REST descriptors)
11736
+ const endpointCount = all.filter((d)=>isRestDescriptor(d)).length;
11737
+ // Count data types (Schema descriptors)
11738
+ const dataTypeCount = all.filter((d)=>isSchemaDescriptor(d)).length;
11739
+ // Count unique paths in endpoints (controllers)
11740
+ const paths = new Set();
11741
+ all.forEach((d)=>{
11742
+ if (isRestDescriptor(d) && d.data.paths && d.data.paths.length > 0) {
11743
+ d.data.paths.forEach((p)=>paths.add(p));
11744
+ }
11745
+ });
11746
+ const controllerCount = paths.size;
11747
+ // Get usage counts from the cached analysis
11748
+ const usedEndpointCount = this.codeAnalyzer.getUsageCounts(source, 'endpoint');
11749
+ const usedDataTypeCount = this.codeAnalyzer.getUsageCounts(source, 'datatype');
11750
+ const usedSourceCount = this.codeAnalyzer.getUsageCounts(source, 'source');
11751
+ const usedControllerCount = this.codeAnalyzer.getUsageCounts(source, 'controller');
11752
+ return DataStats.from({
11753
+ sourceCount: sources.size,
11754
+ endpointCount,
11755
+ dataTypeCount,
11756
+ controllerCount,
11757
+ usedEndpointCount,
11758
+ usedDataTypeCount,
11759
+ usedSourceCount,
11760
+ usedControllerCount
10642
11761
  });
10643
11762
  }
10644
11763
  }
@@ -10647,7 +11766,8 @@ SearchService = search_service_ts_decorate([
10647
11766
  search_service_ts_metadata("design:type", Function),
10648
11767
  search_service_ts_metadata("design:paramtypes", [
10649
11768
  typeof IntrigConfigService === "undefined" ? Object : IntrigConfigService,
10650
- typeof IntrigOpenapiService === "undefined" ? Object : IntrigOpenapiService
11769
+ typeof IntrigOpenapiService === "undefined" ? Object : IntrigOpenapiService,
11770
+ typeof CodeAnalyzer === "undefined" ? Object : CodeAnalyzer
10651
11771
  ])
10652
11772
  ], SearchService);
10653
11773
 
@@ -10669,7 +11789,6 @@ function operations_service_ts_metadata(k, v) {
10669
11789
 
10670
11790
 
10671
11791
 
10672
-
10673
11792
  class OperationsService {
10674
11793
  constructor(openApiService, configService, generatorBinding, packageManagerService, config, searchService){
10675
11794
  this.openApiService = openApiService;
@@ -10699,16 +11818,8 @@ class OperationsService {
10699
11818
  await this.indexDiff(ctx, prevDescriptors, newDescriptors);
10700
11819
  }
10701
11820
  async indexDiff(ctx, prevDescriptors, newDescriptors) {
10702
- const diff = await this.diffDescriptors(prevDescriptors, newDescriptors);
10703
- [
10704
- ...diff.added,
10705
- ...diff.modified
10706
- ].forEach((descriptor)=>{
10707
- this.searchService.addDescriptor(descriptor);
10708
- });
10709
- diff.removed.forEach((descriptor)=>{
10710
- this.searchService.removeDescriptor(descriptor.id);
10711
- });
11821
+ this.searchService.clearAll();
11822
+ newDescriptors.forEach(this.searchService.addDescriptor.bind(this.searchService));
10712
11823
  }
10713
11824
  async getPreviousState(ctx, config) {
10714
11825
  let prevDescriptors = [];
@@ -10734,27 +11845,27 @@ class OperationsService {
10734
11845
  }
10735
11846
  return prevDescriptors;
10736
11847
  }
10737
- async diffDescriptors(oldArr, newArr) {
10738
- // 1. Added: in newArr but not in oldArr (by id)
10739
- const added = external_lodash_default().differenceBy(newArr, oldArr, 'id');
10740
- // 2. Removed: in oldArr but not in newArr (by id)
10741
- const removed = external_lodash_default().differenceBy(oldArr, newArr, 'id');
10742
- // 3. Intersection: items present in both sets (by id)
10743
- const intersection = external_lodash_default().intersectionBy(newArr, oldArr, 'id');
10744
- // 4. Modified: same id but deep-shape differs (including data, or any other prop)
10745
- const modified = intersection.filter((newItem)=>{
10746
- const oldItem = external_lodash_default().find(oldArr, [
10747
- 'id',
10748
- newItem.id
10749
- ]);
10750
- return !external_lodash_default().isEqual(oldItem, newItem);
10751
- });
10752
- return {
10753
- added,
10754
- removed,
10755
- modified
10756
- };
10757
- }
11848
+ // private async diffDescriptors<T>(
11849
+ // oldArr: ResourceDescriptor<T>[],
11850
+ // newArr: ResourceDescriptor<T>[]
11851
+ // ) {
11852
+ // // 1. Added: in newArr but not in oldArr (by id)
11853
+ // const added = _.differenceBy(newArr, oldArr, 'id');
11854
+ //
11855
+ // // 2. Removed: in oldArr but not in newArr (by id)
11856
+ // const removed = _.differenceBy(oldArr, newArr, 'id');
11857
+ //
11858
+ // // 3. Intersection: items present in both sets (by id)
11859
+ // const intersection = _.intersectionBy(newArr, oldArr, 'id');
11860
+ //
11861
+ // // 4. Modified: same id but deep-shape differs (including data, or any other prop)
11862
+ // const modified = intersection.filter(newItem => {
11863
+ // const oldItem = _.find(oldArr, ['id', newItem.id])!;
11864
+ // return !_.isEqual(oldItem, newItem);
11865
+ // });
11866
+ //
11867
+ // return { added, removed, modified };
11868
+ // }
10758
11869
  async generate(ctx) {
10759
11870
  const config = await this.getConfig(ctx);
10760
11871
  await this.clearGenerateDir(ctx);
@@ -10765,7 +11876,12 @@ class OperationsService {
10765
11876
  await this.generateGlobalContent(ctx, config.sources);
10766
11877
  await this.installDependencies(ctx);
10767
11878
  await this.buildContent(ctx);
10768
- await this.copyContentToNodeModules(ctx);
11879
+ const tempBuildContext = config.__dangorouslyOverrideBuild;
11880
+ if (tempBuildContext) {
11881
+ this.copyContentToSource(ctx, tempBuildContext);
11882
+ } else {
11883
+ await this.copyContentToNodeModules(ctx);
11884
+ }
10769
11885
  await this.executePostBuild(ctx);
10770
11886
  }
10771
11887
  async executePostBuild(ctx) {
@@ -10813,6 +11929,17 @@ class OperationsService {
10813
11929
  throw error;
10814
11930
  }
10815
11931
  }
11932
+ async copyContentToSource(ctx, tempBuildContext) {
11933
+ const targetLibDir = external_path_namespaceObject.join(this.config.get('rootDir') ?? process.cwd(), tempBuildContext.srcDir, '@intrig', this.generatorBinding.getLibName());
11934
+ if (external_fs_extra_namespaceObject.pathExistsSync(targetLibDir)) {
11935
+ await external_fs_extra_namespaceObject.remove(targetLibDir);
11936
+ this.logger.log(`Removed existing ${targetLibDir}`);
11937
+ }
11938
+ await external_fs_extra_namespaceObject.ensureDir(targetLibDir);
11939
+ await external_fs_extra_namespaceObject.copy(external_path_namespaceObject.join(this.generateDir, 'src'), targetLibDir);
11940
+ this.logger.log(`Copied ${targetLibDir}`);
11941
+ return "";
11942
+ }
10816
11943
  async buildContent(ctx) {
10817
11944
  return await this.packageManagerService.build(this.generateDir);
10818
11945
  }
@@ -10916,6 +12043,18 @@ operations_service_ts_decorate([
10916
12043
  ]),
10917
12044
  operations_service_ts_metadata("design:returntype", Promise)
10918
12045
  ], OperationsService.prototype, "copyContentToNodeModules", null);
12046
+ operations_service_ts_decorate([
12047
+ WithStatus((event)=>({
12048
+ sourceId: '',
12049
+ step: 'copy-to-node-modules'
12050
+ })),
12051
+ operations_service_ts_metadata("design:type", Function),
12052
+ operations_service_ts_metadata("design:paramtypes", [
12053
+ typeof GenerateEventContext === "undefined" ? Object : GenerateEventContext,
12054
+ typeof TempBuildContext === "undefined" ? Object : TempBuildContext
12055
+ ]),
12056
+ operations_service_ts_metadata("design:returntype", Promise)
12057
+ ], OperationsService.prototype, "copyContentToSource", null);
10919
12058
  operations_service_ts_decorate([
10920
12059
  WithStatus((event)=>({
10921
12060
  sourceId: '',
@@ -11159,6 +12298,355 @@ GeneratorModule = generator_module_ts_decorate([
11159
12298
  (0,common_namespaceObject.Module)({})
11160
12299
  ], GeneratorModule);
11161
12300
 
12301
+ ;// external "lowdb"
12302
+ const external_lowdb_namespaceObject = await import("lowdb");
12303
+ ;// external "lowdb/node"
12304
+ const node_namespaceObject = await import("lowdb/node");
12305
+ ;// ./src/app/deamon/models/entity-view.model.ts
12306
+ function entity_view_model_ts_decorate(decorators, target, key, desc) {
12307
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12308
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12309
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12310
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12311
+ }
12312
+ function entity_view_model_ts_metadata(k, v) {
12313
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12314
+ }
12315
+
12316
+ // Define the class for our tracked items
12317
+ class EntityView {
12318
+ constructor(data){
12319
+ this.id = data.id;
12320
+ this.name = data.name;
12321
+ this.source = data.source;
12322
+ this.accessTime = data.accessTime || new Date().toISOString();
12323
+ this.type = data.type;
12324
+ this.pinned = data.pinned || false;
12325
+ }
12326
+ }
12327
+ entity_view_model_ts_decorate([
12328
+ (0,swagger_namespaceObject.ApiProperty)({
12329
+ description: 'Unique identifier of the item',
12330
+ example: '123456'
12331
+ }),
12332
+ entity_view_model_ts_metadata("design:type", String)
12333
+ ], EntityView.prototype, "id", void 0);
12334
+ entity_view_model_ts_decorate([
12335
+ (0,swagger_namespaceObject.ApiProperty)({
12336
+ description: 'Name of the item',
12337
+ example: 'User Schema'
12338
+ }),
12339
+ entity_view_model_ts_metadata("design:type", String)
12340
+ ], EntityView.prototype, "name", void 0);
12341
+ entity_view_model_ts_decorate([
12342
+ (0,swagger_namespaceObject.ApiProperty)({
12343
+ description: 'Source of the item',
12344
+ example: 'petstore'
12345
+ }),
12346
+ entity_view_model_ts_metadata("design:type", String)
12347
+ ], EntityView.prototype, "source", void 0);
12348
+ entity_view_model_ts_decorate([
12349
+ (0,swagger_namespaceObject.ApiProperty)({
12350
+ description: 'Timestamp when the item was last accessed',
12351
+ example: '2025-08-05T21:07:00.000Z'
12352
+ }),
12353
+ entity_view_model_ts_metadata("design:type", String)
12354
+ ], EntityView.prototype, "accessTime", void 0);
12355
+ entity_view_model_ts_decorate([
12356
+ (0,swagger_namespaceObject.ApiProperty)({
12357
+ description: 'Type of the item',
12358
+ enum: [
12359
+ 'schema',
12360
+ 'endpoint'
12361
+ ],
12362
+ example: 'schema'
12363
+ }),
12364
+ entity_view_model_ts_metadata("design:type", String)
12365
+ ], EntityView.prototype, "type", void 0);
12366
+ entity_view_model_ts_decorate([
12367
+ (0,swagger_namespaceObject.ApiProperty)({
12368
+ description: 'Whether the item is pinned',
12369
+ required: false,
12370
+ example: false
12371
+ }),
12372
+ entity_view_model_ts_metadata("design:type", Boolean)
12373
+ ], EntityView.prototype, "pinned", void 0);
12374
+
12375
+ ;// ./src/app/deamon/services/last-visit.service.ts
12376
+ function last_visit_service_ts_decorate(decorators, target, key, desc) {
12377
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12378
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12379
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12380
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12381
+ }
12382
+ function last_visit_service_ts_metadata(k, v) {
12383
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12384
+ }
12385
+
12386
+
12387
+
12388
+
12389
+
12390
+
12391
+
12392
+ class LastVisitService {
12393
+ constructor(configService){
12394
+ this.configService = configService;
12395
+ this.logger = new common_namespaceObject.Logger(LastVisitService.name);
12396
+ this.MAX_ITEMS = 50; // Maximum number of items to keep in history
12397
+ const rootDir = this.configService.get('rootDir');
12398
+ this.configDir = (0,external_path_namespaceObject.join)(rootDir, '.intrig', '.config');
12399
+ this.dbFile = (0,external_path_namespaceObject.join)(this.configDir, 'last-visit.json');
12400
+ // Ensure the config directory exists
12401
+ (0,external_fs_extra_namespaceObject.ensureDirSync)(this.configDir);
12402
+ // Initialize the database
12403
+ const adapter = new node_namespaceObject.JSONFile(this.dbFile);
12404
+ this.db = new external_lowdb_namespaceObject.Low(adapter, {
12405
+ items: [],
12406
+ pinnedItems: []
12407
+ });
12408
+ // Load the database
12409
+ this.loadDb();
12410
+ }
12411
+ async loadDb() {
12412
+ try {
12413
+ await this.db.read();
12414
+ // Initialize if data is null
12415
+ this.db.data = this.db.data || {
12416
+ items: [],
12417
+ pinnedItems: []
12418
+ };
12419
+ // Ensure pinnedItems exists (for backward compatibility)
12420
+ if (!this.db.data.pinnedItems) {
12421
+ this.db.data.pinnedItems = [];
12422
+ }
12423
+ this.logger.debug(`Loaded last visit database with ${this.db.data.items.length} items and ${this.db.data.pinnedItems.length} pinned items`);
12424
+ } catch (error) {
12425
+ this.logger.error('Failed to load last visit database', error);
12426
+ // Initialize with empty data if there's an error
12427
+ this.db.data = {
12428
+ items: [],
12429
+ pinnedItems: []
12430
+ };
12431
+ }
12432
+ }
12433
+ async saveDb() {
12434
+ try {
12435
+ await this.db.write();
12436
+ this.logger.debug('Last visit database saved successfully');
12437
+ } catch (error) {
12438
+ this.logger.error('Failed to save last visit database', error);
12439
+ }
12440
+ }
12441
+ /**
12442
+ * Track a schema view
12443
+ * @param id Schema ID
12444
+ * @param name Schema name
12445
+ * @param source Schema source
12446
+ */ async trackSchemaView(id, name, source) {
12447
+ await this.trackItem(new EntityView({
12448
+ id,
12449
+ name,
12450
+ source,
12451
+ type: 'schema'
12452
+ }));
12453
+ }
12454
+ /**
12455
+ * Track an endpoint view
12456
+ * @param id Endpoint ID
12457
+ * @param name Endpoint name
12458
+ * @param source Endpoint source
12459
+ */ async trackEndpointView(id, name, source) {
12460
+ await this.trackItem(new EntityView({
12461
+ id,
12462
+ name,
12463
+ source,
12464
+ type: 'endpoint'
12465
+ }));
12466
+ }
12467
+ /**
12468
+ * Track an item view
12469
+ * @param item The item to track
12470
+ * @private
12471
+ */ async trackItem(item) {
12472
+ // Ensure the database is loaded
12473
+ if (!this.db.data) {
12474
+ await this.loadDb();
12475
+ }
12476
+ // Remove the item if it already exists (to avoid duplicates)
12477
+ this.db.data.items = this.db.data.items.filter((i)=>!(i.id === item.id && i.type === item.type));
12478
+ // Add the new item at the beginning of the array
12479
+ this.db.data.items.unshift(item);
12480
+ // Limit the number of items
12481
+ if (this.db.data.items.length > this.MAX_ITEMS) {
12482
+ this.db.data.items = this.db.data.items.slice(0, this.MAX_ITEMS);
12483
+ }
12484
+ // Save the database
12485
+ await this.saveDb();
12486
+ this.logger.debug(`Tracked ${item.type} view: ${item.name} (${item.id})`);
12487
+ }
12488
+ /**
12489
+ * Get all tracked items
12490
+ */ async getItems() {
12491
+ // Ensure the database is loaded
12492
+ if (!this.db.data) {
12493
+ await this.loadDb();
12494
+ }
12495
+ return this.db.data.items;
12496
+ }
12497
+ /**
12498
+ * Get tracked items by type
12499
+ * @param type The type of items to get
12500
+ */ async getItemsByType(type) {
12501
+ // Ensure the database is loaded
12502
+ if (!this.db.data) {
12503
+ await this.loadDb();
12504
+ }
12505
+ return this.db.data.items.filter((item)=>item.type === type);
12506
+ }
12507
+ /**
12508
+ * Get the last n visited items
12509
+ * @param limit Number of items to return (default: 10)
12510
+ * @param type Optional filter by item type
12511
+ */ async getLastNItems(limit = 10, type) {
12512
+ // Ensure the database is loaded
12513
+ if (!this.db.data) {
12514
+ await this.loadDb();
12515
+ }
12516
+ // Filter by type if specified
12517
+ const items = type ? this.db.data.items.filter((item)=>item.type === type) : this.db.data.items;
12518
+ // Return the first n items (they're already sorted by most recent first)
12519
+ return items.slice(0, limit);
12520
+ }
12521
+ /**
12522
+ * Toggle pin status of an item
12523
+ * @param id Item ID
12524
+ * @param type Item type ('schema' or 'endpoint')
12525
+ * @param source Item source (optional if item exists in last visit)
12526
+ * @param name Item name (optional if item exists in last visit)
12527
+ * @returns Object containing success status and the new pin state (true if pinned, false if unpinned)
12528
+ */ async togglePinItem(id, type, source, name) {
12529
+ // Ensure the database is loaded
12530
+ if (!this.db.data) {
12531
+ await this.loadDb();
12532
+ }
12533
+ // Check if the item is already pinned
12534
+ const alreadyPinned = this.db.data.pinnedItems.some((i)=>i.id === id && i.type === type);
12535
+ if (alreadyPinned) {
12536
+ // Item is already pinned, so unpin it
12537
+ const pinnedItemIndex = this.db.data.pinnedItems.findIndex((i)=>i.id === id && i.type === type);
12538
+ if (pinnedItemIndex === -1) {
12539
+ // This shouldn't happen since we already checked alreadyPinned
12540
+ this.logger.warn(`Inconsistent state: Item marked as pinned but not found in pinnedItems: ${id} (${type})`);
12541
+ return {
12542
+ success: false,
12543
+ pinned: false
12544
+ };
12545
+ }
12546
+ // Get the pinned item before removing it (for logging)
12547
+ const pinnedItem = this.db.data.pinnedItems[pinnedItemIndex];
12548
+ // Remove the item from pinnedItems
12549
+ this.db.data.pinnedItems.splice(pinnedItemIndex, 1);
12550
+ // Also update the item in the items array if it exists
12551
+ const itemIndex = this.db.data.items.findIndex((i)=>i.id === id && i.type === type);
12552
+ if (itemIndex !== -1) {
12553
+ this.db.data.items[itemIndex].pinned = false;
12554
+ }
12555
+ // Save the database
12556
+ await this.saveDb();
12557
+ this.logger.debug(`Unpinned ${type}: ${pinnedItem.name} (${id})`);
12558
+ return {
12559
+ success: true,
12560
+ pinned: false
12561
+ };
12562
+ } else {
12563
+ // Item is not pinned, so pin it
12564
+ // Find the item in the items array
12565
+ let item = this.db.data.items.find((i)=>i.id === id && i.type === type);
12566
+ // If item doesn't exist in last visit but we have source and name, we can still pin it
12567
+ if (!item) {
12568
+ if (!source) {
12569
+ this.logger.warn(`Item not found for pinning and source not provided: ${id} (${type})`);
12570
+ return {
12571
+ success: false,
12572
+ pinned: false
12573
+ };
12574
+ }
12575
+ // Create a new item with the provided information
12576
+ item = new EntityView({
12577
+ id,
12578
+ type,
12579
+ source,
12580
+ name: name || id
12581
+ });
12582
+ this.logger.debug(`Creating new pin for item not in last visit: ${id} (${type})`);
12583
+ }
12584
+ // Add the item to pinnedItems
12585
+ const pinnedItem = new EntityView({
12586
+ id: item.id,
12587
+ name: item.name,
12588
+ source: item.source,
12589
+ type: item.type,
12590
+ pinned: true,
12591
+ accessTime: new Date().toISOString()
12592
+ });
12593
+ this.db.data.pinnedItems.push(pinnedItem);
12594
+ // Also update the item in the items array if it exists
12595
+ const itemIndex = this.db.data.items.findIndex((i)=>i.id === id && i.type === type);
12596
+ if (itemIndex !== -1) {
12597
+ this.db.data.items[itemIndex].pinned = true;
12598
+ }
12599
+ // Save the database
12600
+ await this.saveDb();
12601
+ this.logger.debug(`Pinned ${type}: ${pinnedItem.name} (${id})`);
12602
+ return {
12603
+ success: true,
12604
+ pinned: true
12605
+ };
12606
+ }
12607
+ }
12608
+ /**
12609
+ * Pin an item (deprecated, use togglePinItem instead)
12610
+ * @param id Item ID
12611
+ * @param type Item type ('schema' or 'endpoint')
12612
+ * @param source Item source (optional if item exists in last visit)
12613
+ * @param name Item name (optional if item exists in last visit)
12614
+ * @deprecated Use togglePinItem instead
12615
+ */ async pinItem(id, type, source, name) {
12616
+ const result = await this.togglePinItem(id, type, source, name);
12617
+ return result.success && result.pinned;
12618
+ }
12619
+ /**
12620
+ * Unpin an item (deprecated, use togglePinItem instead)
12621
+ * @param id Item ID
12622
+ * @param type Item type ('schema' or 'endpoint')
12623
+ * @deprecated Use togglePinItem instead
12624
+ */ async unpinItem(id, type) {
12625
+ // If the item is not pinned, this will return success: true, pinned: false
12626
+ // If the item is pinned, it will be unpinned and return success: true, pinned: false
12627
+ const result = await this.togglePinItem(id, type);
12628
+ return result.success;
12629
+ }
12630
+ /**
12631
+ * Get all pinned items
12632
+ * @param type Optional filter by item type
12633
+ */ async getPinnedItems(type) {
12634
+ // Ensure the database is loaded
12635
+ if (!this.db.data) {
12636
+ await this.loadDb();
12637
+ }
12638
+ // Filter by type if specified
12639
+ return type ? this.db.data.pinnedItems.filter((item)=>item.type === type) : this.db.data.pinnedItems;
12640
+ }
12641
+ }
12642
+ LastVisitService = last_visit_service_ts_decorate([
12643
+ (0,common_namespaceObject.Injectable)(),
12644
+ last_visit_service_ts_metadata("design:type", Function),
12645
+ last_visit_service_ts_metadata("design:paramtypes", [
12646
+ typeof config_namespaceObject.ConfigService === "undefined" ? Object : config_namespaceObject.ConfigService
12647
+ ])
12648
+ ], LastVisitService);
12649
+
11162
12650
  ;// ./src/app/deamon/services/data-search.service.ts
11163
12651
  function data_search_service_ts_decorate(decorators, target, key, desc) {
11164
12652
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -11172,10 +12660,12 @@ function data_search_service_ts_metadata(k, v) {
11172
12660
 
11173
12661
 
11174
12662
 
12663
+
11175
12664
  class DataSearchService {
11176
- constructor(searchService, generatorBinding){
12665
+ constructor(searchService, generatorBinding, lastVisitService){
11177
12666
  this.searchService = searchService;
11178
12667
  this.generatorBinding = generatorBinding;
12668
+ this.lastVisitService = lastVisitService;
11179
12669
  this.logger = new common_namespaceObject.Logger(DataSearchService.name);
11180
12670
  }
11181
12671
  /**
@@ -11185,17 +12675,18 @@ class DataSearchService {
11185
12675
  * @param opts
11186
12676
  */ async search(query, page, size, opts) {
11187
12677
  this.logger.debug(`Searching with query: "${query}", page: ${page}, size: ${size}, opts: ${JSON.stringify(opts)}`);
11188
- const maxResults = page * size;
11189
- // 1) Get the raw, sorted list of descriptors
11190
- const allResults = this.searchService.search(query ?? '', {
11191
- limit: maxResults,
12678
+ // 1) Get the total count of all matching results using the new method
12679
+ const total = this.searchService.getTotalCount(query ?? '', opts);
12680
+ this.logger.debug(`Total matching results: ${total} (without pagination)`);
12681
+ // 2) Get the paginated results
12682
+ const startIdx = (page - 1) * size;
12683
+ const pageData = this.searchService.search(query ?? '', {
12684
+ limit: size,
12685
+ offset: startIdx,
11192
12686
  ...opts
11193
12687
  });
11194
- // 2) Compute pagination metadata
11195
- const total = allResults.length;
12688
+ // 3) Compute pagination metadata
11196
12689
  const totalPages = Math.ceil(total / size);
11197
- const startIdx = (page - 1) * size;
11198
- const pageData = allResults.slice(startIdx, startIdx + size);
11199
12690
  // 3) Return the Page<T>
11200
12691
  const result = Page.from({
11201
12692
  data: pageData,
@@ -11219,11 +12710,17 @@ class DataSearchService {
11219
12710
  async getStats() {
11220
12711
  return this.searchService.getStatsBySource();
11221
12712
  }
12713
+ async getDataStats(source) {
12714
+ this.logger.debug(`Getting data stats${source ? ` for source: ${source}` : ''}`);
12715
+ return this.searchService.getDataStats(source);
12716
+ }
11222
12717
  async getSchemaDocsById(id) {
11223
12718
  this.logger.debug(`Getting resource by id: ${id}`);
11224
12719
  const result = this.searchService.getById(id);
11225
12720
  this.logger.debug(`Resource ${id} ${result ? 'found' : 'not found'}`);
11226
12721
  if (!result) return;
12722
+ // Track the schema view
12723
+ await this.lastVisitService.trackSchemaView(id, result.name, result.source);
11227
12724
  const dataTypes = this.searchService.search("", {
11228
12725
  dataTypes: [
11229
12726
  result.name
@@ -11244,6 +12741,8 @@ class DataSearchService {
11244
12741
  const result = this.searchService.getById(id);
11245
12742
  this.logger.debug(`Resource ${id} ${result ? 'found' : 'not found'}`);
11246
12743
  if (!result) return;
12744
+ // Track the endpoint view
12745
+ await this.lastVisitService.trackEndpointView(id, result.name, result.source);
11247
12746
  const restData = result.data;
11248
12747
  const schemas = this.searchService.search("", {
11249
12748
  type: 'schema',
@@ -11261,7 +12760,8 @@ DataSearchService = data_search_service_ts_decorate([
11261
12760
  data_search_service_ts_metadata("design:type", Function),
11262
12761
  data_search_service_ts_metadata("design:paramtypes", [
11263
12762
  typeof SearchService === "undefined" ? Object : SearchService,
11264
- typeof GeneratorBinding === "undefined" ? Object : GeneratorBinding
12763
+ typeof GeneratorBinding === "undefined" ? Object : GeneratorBinding,
12764
+ typeof LastVisitService === "undefined" ? Object : LastVisitService
11265
12765
  ])
11266
12766
  ], DataSearchService);
11267
12767
 
@@ -11354,6 +12854,93 @@ search_query_ts_decorate([
11354
12854
  (0,external_class_validator_namespaceObject.Min)(1)
11355
12855
  ], SearchQuery.prototype, "size", void 0);
11356
12856
 
12857
+ ;// ./src/app/deamon/models/pin-item.dto.ts
12858
+ function pin_item_dto_ts_decorate(decorators, target, key, desc) {
12859
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12860
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12861
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12862
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12863
+ }
12864
+ function pin_item_dto_ts_metadata(k, v) {
12865
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12866
+ }
12867
+
12868
+
12869
+ class PinItemDto {
12870
+ }
12871
+ pin_item_dto_ts_decorate([
12872
+ (0,swagger_namespaceObject.ApiProperty)({
12873
+ description: 'Item ID',
12874
+ example: '123456'
12875
+ }),
12876
+ (0,external_class_validator_namespaceObject.IsNotEmpty)(),
12877
+ pin_item_dto_ts_metadata("design:type", String)
12878
+ ], PinItemDto.prototype, "id", void 0);
12879
+ pin_item_dto_ts_decorate([
12880
+ (0,swagger_namespaceObject.ApiProperty)({
12881
+ description: 'Item type',
12882
+ enum: [
12883
+ 'schema',
12884
+ 'endpoint'
12885
+ ],
12886
+ example: 'schema'
12887
+ }),
12888
+ (0,external_class_validator_namespaceObject.IsNotEmpty)(),
12889
+ (0,external_class_validator_namespaceObject.IsEnum)([
12890
+ 'schema',
12891
+ 'endpoint'
12892
+ ]),
12893
+ pin_item_dto_ts_metadata("design:type", String)
12894
+ ], PinItemDto.prototype, "type", void 0);
12895
+ pin_item_dto_ts_decorate([
12896
+ (0,swagger_namespaceObject.ApiProperty)({
12897
+ description: 'Item source',
12898
+ required: false,
12899
+ example: 'petstore'
12900
+ }),
12901
+ (0,external_class_validator_namespaceObject.IsOptional)(),
12902
+ pin_item_dto_ts_metadata("design:type", String)
12903
+ ], PinItemDto.prototype, "source", void 0);
12904
+ pin_item_dto_ts_decorate([
12905
+ (0,swagger_namespaceObject.ApiProperty)({
12906
+ description: 'Item name',
12907
+ required: false,
12908
+ example: 'Pet'
12909
+ }),
12910
+ (0,external_class_validator_namespaceObject.IsOptional)(),
12911
+ pin_item_dto_ts_metadata("design:type", String)
12912
+ ], PinItemDto.prototype, "name", void 0);
12913
+
12914
+ ;// ./src/app/deamon/models/file-list-response.dto.ts
12915
+ function file_list_response_dto_ts_decorate(decorators, target, key, desc) {
12916
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12917
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12918
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12919
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12920
+ }
12921
+ function file_list_response_dto_ts_metadata(k, v) {
12922
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12923
+ }
12924
+
12925
+ class FileListResponseDto {
12926
+ constructor(files){
12927
+ this.files = files;
12928
+ }
12929
+ }
12930
+ file_list_response_dto_ts_decorate([
12931
+ (0,swagger_namespaceObject.ApiProperty)({
12932
+ description: 'List of files where the endpoint/datatype is used',
12933
+ type: [
12934
+ String
12935
+ ],
12936
+ example: [
12937
+ 'src/app/components/user-profile.tsx',
12938
+ 'src/app/services/user-service.ts'
12939
+ ]
12940
+ }),
12941
+ file_list_response_dto_ts_metadata("design:type", Array)
12942
+ ], FileListResponseDto.prototype, "files", void 0);
12943
+
11357
12944
  ;// ./src/app/deamon/controllers/data-search.controller.ts
11358
12945
  function data_search_controller_ts_decorate(decorators, target, key, desc) {
11359
12946
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -11375,9 +12962,17 @@ function data_search_controller_ts_param(paramIndex, decorator) {
11375
12962
 
11376
12963
 
11377
12964
 
12965
+
12966
+
12967
+
12968
+
12969
+
12970
+
11378
12971
  class DataSearchController {
11379
- constructor(dataSearchService){
12972
+ constructor(dataSearchService, lastVisitService, codeAnalyzer){
11380
12973
  this.dataSearchService = dataSearchService;
12974
+ this.lastVisitService = lastVisitService;
12975
+ this.codeAnalyzer = codeAnalyzer;
11381
12976
  }
11382
12977
  async search(params) {
11383
12978
  const { query, type, source, pkg, page, size } = params;
@@ -11411,6 +13006,54 @@ class DataSearchController {
11411
13006
  async getStats() {
11412
13007
  return await this.dataSearchService.getStats();
11413
13008
  }
13009
+ async getDataStats(source) {
13010
+ return await this.dataSearchService.getDataStats(source);
13011
+ }
13012
+ async getLastVisitedItems(limit, type) {
13013
+ return await this.lastVisitService.getLastNItems(limit, type);
13014
+ }
13015
+ async getPinnedItems(type) {
13016
+ return await this.lastVisitService.getPinnedItems(type);
13017
+ }
13018
+ async togglePinItem(pinItemDto) {
13019
+ const { id, type, source, name } = pinItemDto;
13020
+ const result = await this.lastVisitService.togglePinItem(id, type, source, name);
13021
+ if (!result.success) {
13022
+ throw new common_namespaceObject.NotFoundException(`Item with id ${id} and type ${type} not found and source not provided`);
13023
+ }
13024
+ return pinItemDto;
13025
+ }
13026
+ async pinItem(pinItemDto) {
13027
+ const { id, type, source, name } = pinItemDto;
13028
+ const success = await this.lastVisitService.pinItem(id, type, source, name);
13029
+ if (!success) {
13030
+ throw new common_namespaceObject.NotFoundException(`Item with id ${id} and type ${type} not found and source not provided`);
13031
+ }
13032
+ return {
13033
+ success,
13034
+ message: `Item ${id} pinned successfully`
13035
+ };
13036
+ }
13037
+ async unpinItem(id, type) {
13038
+ if (!id || !type) {
13039
+ throw new common_namespaceObject.NotFoundException('Missing required parameters: id and type are required');
13040
+ }
13041
+ const success = await this.lastVisitService.unpinItem(id, type);
13042
+ if (!success) {
13043
+ throw new common_namespaceObject.NotFoundException(`Pinned item with id ${id} and type ${type} not found`);
13044
+ }
13045
+ return {
13046
+ success,
13047
+ message: `Item ${id} unpinned successfully`
13048
+ };
13049
+ }
13050
+ async getFileList(sourceId, type, id) {
13051
+ if (!sourceId || !type || !id) {
13052
+ throw new common_namespaceObject.NotFoundException('Missing required parameters: sourceId, type, and id are required');
13053
+ }
13054
+ const files = this.codeAnalyzer.getFileList(sourceId, type, id);
13055
+ return new FileListResponseDto(files);
13056
+ }
11414
13057
  }
11415
13058
  data_search_controller_ts_decorate([
11416
13059
  (0,common_namespaceObject.Get)("/search"),
@@ -11525,12 +13168,223 @@ data_search_controller_ts_decorate([
11525
13168
  data_search_controller_ts_metadata("design:paramtypes", []),
11526
13169
  data_search_controller_ts_metadata("design:returntype", Promise)
11527
13170
  ], DataSearchController.prototype, "getStats", null);
13171
+ data_search_controller_ts_decorate([
13172
+ (0,common_namespaceObject.Get)("/data-stats"),
13173
+ (0,swagger_namespaceObject.ApiOperation)({
13174
+ summary: 'Get data statistics including source count, endpoint count, and data type count'
13175
+ }),
13176
+ (0,swagger_namespaceObject.ApiResponse)({
13177
+ status: 200,
13178
+ description: 'Returns data statistics',
13179
+ type: DataStats
13180
+ }),
13181
+ data_search_controller_ts_param(0, (0,common_namespaceObject.Query)('source')),
13182
+ data_search_controller_ts_metadata("design:type", Function),
13183
+ data_search_controller_ts_metadata("design:paramtypes", [
13184
+ String
13185
+ ]),
13186
+ data_search_controller_ts_metadata("design:returntype", Promise)
13187
+ ], DataSearchController.prototype, "getDataStats", null);
13188
+ data_search_controller_ts_decorate([
13189
+ (0,common_namespaceObject.Get)("/last-visited"),
13190
+ (0,swagger_namespaceObject.ApiOperation)({
13191
+ summary: 'Get the last visited items'
13192
+ }),
13193
+ (0,swagger_namespaceObject.ApiResponse)({
13194
+ status: 200,
13195
+ description: 'Returns the last visited items',
13196
+ type: [
13197
+ EntityView
13198
+ ]
13199
+ }),
13200
+ (0,swagger_namespaceObject.ApiQuery)({
13201
+ name: 'limit',
13202
+ required: false,
13203
+ type: Number,
13204
+ description: 'Maximum number of items to return (default: 10)'
13205
+ }),
13206
+ (0,swagger_namespaceObject.ApiQuery)({
13207
+ name: 'type',
13208
+ required: false,
13209
+ enum: [
13210
+ 'schema',
13211
+ 'endpoint'
13212
+ ],
13213
+ description: 'Filter by item type'
13214
+ }),
13215
+ data_search_controller_ts_param(0, (0,common_namespaceObject.Query)('limit')),
13216
+ data_search_controller_ts_param(1, (0,common_namespaceObject.Query)('type')),
13217
+ data_search_controller_ts_metadata("design:type", Function),
13218
+ data_search_controller_ts_metadata("design:paramtypes", [
13219
+ Number,
13220
+ String
13221
+ ]),
13222
+ data_search_controller_ts_metadata("design:returntype", Promise)
13223
+ ], DataSearchController.prototype, "getLastVisitedItems", null);
13224
+ data_search_controller_ts_decorate([
13225
+ (0,common_namespaceObject.Get)("/pinned"),
13226
+ (0,swagger_namespaceObject.ApiOperation)({
13227
+ summary: 'Get all pinned items'
13228
+ }),
13229
+ (0,swagger_namespaceObject.ApiResponse)({
13230
+ status: 200,
13231
+ description: 'Returns all pinned items',
13232
+ type: [
13233
+ EntityView
13234
+ ]
13235
+ }),
13236
+ (0,swagger_namespaceObject.ApiQuery)({
13237
+ name: 'type',
13238
+ required: false,
13239
+ enum: [
13240
+ 'schema',
13241
+ 'endpoint'
13242
+ ],
13243
+ description: 'Filter by item type'
13244
+ }),
13245
+ data_search_controller_ts_param(0, (0,common_namespaceObject.Query)('type')),
13246
+ data_search_controller_ts_metadata("design:type", Function),
13247
+ data_search_controller_ts_metadata("design:paramtypes", [
13248
+ String
13249
+ ]),
13250
+ data_search_controller_ts_metadata("design:returntype", Promise)
13251
+ ], DataSearchController.prototype, "getPinnedItems", null);
13252
+ data_search_controller_ts_decorate([
13253
+ (0,common_namespaceObject.Post)("/toggle-pin"),
13254
+ (0,swagger_namespaceObject.ApiOperation)({
13255
+ summary: 'Toggle pin status of an item'
13256
+ }),
13257
+ (0,swagger_namespaceObject.ApiResponse)({
13258
+ status: 200,
13259
+ description: 'Item pin status toggled successfully',
13260
+ type: [
13261
+ PinItemDto
13262
+ ]
13263
+ }),
13264
+ (0,swagger_namespaceObject.ApiResponse)({
13265
+ status: 404,
13266
+ description: 'Item not found or missing required parameters'
13267
+ }),
13268
+ (0,swagger_namespaceObject.ApiBody)({
13269
+ type: PinItemDto
13270
+ }),
13271
+ (0,common_namespaceObject.HttpCode)(common_namespaceObject.HttpStatus.OK),
13272
+ (0,common_namespaceObject.UsePipes)(new common_namespaceObject.ValidationPipe({
13273
+ transform: true
13274
+ })),
13275
+ data_search_controller_ts_param(0, (0,common_namespaceObject.Body)()),
13276
+ data_search_controller_ts_metadata("design:type", Function),
13277
+ data_search_controller_ts_metadata("design:paramtypes", [
13278
+ typeof PinItemDto === "undefined" ? Object : PinItemDto
13279
+ ]),
13280
+ data_search_controller_ts_metadata("design:returntype", Promise)
13281
+ ], DataSearchController.prototype, "togglePinItem", null);
13282
+ data_search_controller_ts_decorate([
13283
+ (0,common_namespaceObject.Post)("/pin"),
13284
+ (0,swagger_namespaceObject.ApiOperation)({
13285
+ summary: 'Pin an item',
13286
+ deprecated: true
13287
+ }),
13288
+ (0,swagger_namespaceObject.ApiResponse)({
13289
+ status: 200,
13290
+ description: 'Item pinned successfully'
13291
+ }),
13292
+ (0,swagger_namespaceObject.ApiResponse)({
13293
+ status: 404,
13294
+ description: 'Item not found or missing required parameters'
13295
+ }),
13296
+ (0,swagger_namespaceObject.ApiBody)({
13297
+ type: PinItemDto
13298
+ }),
13299
+ (0,common_namespaceObject.HttpCode)(common_namespaceObject.HttpStatus.OK),
13300
+ (0,common_namespaceObject.UsePipes)(new common_namespaceObject.ValidationPipe({
13301
+ transform: true
13302
+ })),
13303
+ data_search_controller_ts_param(0, (0,common_namespaceObject.Body)()),
13304
+ data_search_controller_ts_metadata("design:type", Function),
13305
+ data_search_controller_ts_metadata("design:paramtypes", [
13306
+ typeof PinItemDto === "undefined" ? Object : PinItemDto
13307
+ ]),
13308
+ data_search_controller_ts_metadata("design:returntype", Promise)
13309
+ ], DataSearchController.prototype, "pinItem", null);
13310
+ data_search_controller_ts_decorate([
13311
+ (0,common_namespaceObject.Delete)("/pin"),
13312
+ (0,swagger_namespaceObject.ApiOperation)({
13313
+ summary: 'Unpin an item',
13314
+ deprecated: true
13315
+ }),
13316
+ (0,swagger_namespaceObject.ApiResponse)({
13317
+ status: 200,
13318
+ description: 'Item unpinned successfully'
13319
+ }),
13320
+ (0,swagger_namespaceObject.ApiResponse)({
13321
+ status: 404,
13322
+ description: 'Item not found or not pinned or missing required parameters'
13323
+ }),
13324
+ (0,common_namespaceObject.HttpCode)(common_namespaceObject.HttpStatus.OK),
13325
+ data_search_controller_ts_param(0, (0,common_namespaceObject.Query)('id')),
13326
+ data_search_controller_ts_param(1, (0,common_namespaceObject.Query)('type')),
13327
+ data_search_controller_ts_metadata("design:type", Function),
13328
+ data_search_controller_ts_metadata("design:paramtypes", [
13329
+ String,
13330
+ String
13331
+ ]),
13332
+ data_search_controller_ts_metadata("design:returntype", Promise)
13333
+ ], DataSearchController.prototype, "unpinItem", null);
13334
+ data_search_controller_ts_decorate([
13335
+ (0,common_namespaceObject.Get)("/files"),
13336
+ (0,swagger_namespaceObject.ApiOperation)({
13337
+ summary: 'Get list of files per endpoint/datatype'
13338
+ }),
13339
+ (0,swagger_namespaceObject.ApiResponse)({
13340
+ status: 200,
13341
+ description: 'Returns list of files where the endpoint/datatype is used',
13342
+ type: FileListResponseDto
13343
+ }),
13344
+ (0,swagger_namespaceObject.ApiResponse)({
13345
+ status: 404,
13346
+ description: 'Resource not found or missing required parameters'
13347
+ }),
13348
+ (0,swagger_namespaceObject.ApiQuery)({
13349
+ name: 'sourceId',
13350
+ required: true,
13351
+ type: String,
13352
+ description: 'Source identifier'
13353
+ }),
13354
+ (0,swagger_namespaceObject.ApiQuery)({
13355
+ name: 'type',
13356
+ required: true,
13357
+ enum: [
13358
+ 'endpoint',
13359
+ 'datatype'
13360
+ ],
13361
+ description: 'Type of resource'
13362
+ }),
13363
+ (0,swagger_namespaceObject.ApiQuery)({
13364
+ name: 'id',
13365
+ required: true,
13366
+ type: String,
13367
+ description: 'Endpoint or datatype identifier'
13368
+ }),
13369
+ data_search_controller_ts_param(0, (0,common_namespaceObject.Query)('sourceId')),
13370
+ data_search_controller_ts_param(1, (0,common_namespaceObject.Query)('type')),
13371
+ data_search_controller_ts_param(2, (0,common_namespaceObject.Query)('id')),
13372
+ data_search_controller_ts_metadata("design:type", Function),
13373
+ data_search_controller_ts_metadata("design:paramtypes", [
13374
+ String,
13375
+ String,
13376
+ String
13377
+ ]),
13378
+ data_search_controller_ts_metadata("design:returntype", Promise)
13379
+ ], DataSearchController.prototype, "getFileList", null);
11528
13380
  DataSearchController = data_search_controller_ts_decorate([
11529
13381
  (0,common_namespaceObject.Controller)('data'),
11530
- (0,swagger_namespaceObject.ApiExtraModels)(ResourceDescriptor, Page, SchemaDocumentation, RestDocumentation, SourceStats, SearchQuery),
13382
+ (0,swagger_namespaceObject.ApiExtraModels)(ResourceDescriptor, Page, SchemaDocumentation, RestDocumentation, SourceStats, DataStats, SearchQuery, EntityView, PinItemDto, FileListResponseDto),
11531
13383
  data_search_controller_ts_metadata("design:type", Function),
11532
13384
  data_search_controller_ts_metadata("design:paramtypes", [
11533
- typeof DataSearchService === "undefined" ? Object : DataSearchService
13385
+ typeof DataSearchService === "undefined" ? Object : DataSearchService,
13386
+ typeof LastVisitService === "undefined" ? Object : LastVisitService,
13387
+ typeof CodeAnalyzer === "undefined" ? Object : CodeAnalyzer
11534
13388
  ])
11535
13389
  ], DataSearchController);
11536
13390
 
@@ -11554,6 +13408,8 @@ function deamon_module_ts_decorate(decorators, target, key, desc) {
11554
13408
 
11555
13409
 
11556
13410
 
13411
+
13412
+
11557
13413
  class DeamonModule {
11558
13414
  }
11559
13415
  DeamonModule = deamon_module_ts_decorate([
@@ -11574,7 +13430,9 @@ DeamonModule = deamon_module_ts_decorate([
11574
13430
  OpenapiService,
11575
13431
  OperationsService,
11576
13432
  DataSearchService,
11577
- SearchService
13433
+ SearchService,
13434
+ LastVisitService,
13435
+ CodeAnalyzer
11578
13436
  ]
11579
13437
  })
11580
13438
  ], DeamonModule);
@@ -11590,6 +13448,60 @@ DeamonModule = deamon_module_ts_decorate([
11590
13448
  };
11591
13449
  });
11592
13450
 
13451
+ ;// external "process"
13452
+ const external_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("process");
13453
+ ;// ./src/app/debug/debug.controller.ts
13454
+ function debug_controller_ts_decorate(decorators, target, key, desc) {
13455
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13456
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13457
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13458
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
13459
+ }
13460
+ function debug_controller_ts_metadata(k, v) {
13461
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
13462
+ }
13463
+
13464
+
13465
+
13466
+
13467
+ // Get the directory name in ES modules
13468
+ const debug_controller_filename = (0,external_url_namespaceObject.fileURLToPath)("file:///home/tiran-intrigsoft/IdeaProjects/intrig-core/app/intrig/src/app/debug/debug.controller.ts");
13469
+ const debug_controller_dirname = (0,external_path_namespaceObject.dirname)(debug_controller_filename);
13470
+ class DebugController {
13471
+ getDirname() {
13472
+ // Calculate paths that might be relevant for debugging
13473
+ const assetsPath = (0,external_path_namespaceObject.join)(external_process_namespaceObject.cwd(), 'dist', 'app', 'intrig', 'assets', 'insight');
13474
+ const appDirname = (0,external_path_namespaceObject.dirname)(debug_controller_dirname);
13475
+ return {
13476
+ // ES Module specific values
13477
+ dirname: debug_controller_dirname,
13478
+ filename: debug_controller_filename,
13479
+ meta_url: "file:///home/tiran-intrigsoft/IdeaProjects/intrig-core/app/intrig/src/app/debug/debug.controller.ts",
13480
+ // Calculated paths
13481
+ assetsPath,
13482
+ appDirname,
13483
+ // Process information
13484
+ cwd: external_process_namespaceObject.cwd(),
13485
+ execPath: external_process_namespaceObject.execPath,
13486
+ // Environment
13487
+ nodeEnv: external_process_namespaceObject.env.NODE_ENV,
13488
+ // Module type
13489
+ isESM: "function" === 'undefined',
13490
+ // Timestamp for cache busting
13491
+ timestamp: new Date().toISOString()
13492
+ };
13493
+ }
13494
+ }
13495
+ debug_controller_ts_decorate([
13496
+ (0,common_namespaceObject.Get)('dirname'),
13497
+ debug_controller_ts_metadata("design:type", Function),
13498
+ debug_controller_ts_metadata("design:paramtypes", []),
13499
+ debug_controller_ts_metadata("design:returntype", void 0)
13500
+ ], DebugController.prototype, "getDirname", null);
13501
+ DebugController = debug_controller_ts_decorate([
13502
+ (0,common_namespaceObject.Controller)('debug')
13503
+ ], DebugController);
13504
+
11593
13505
  ;// ./src/app/app.module.ts
11594
13506
  function app_module_ts_decorate(decorators, target, key, desc) {
11595
13507
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -11604,6 +13516,8 @@ function app_module_ts_decorate(decorators, target, key, desc) {
11604
13516
 
11605
13517
 
11606
13518
 
13519
+ // import {McpModule} from "./mcp/mcp.module";
13520
+
11607
13521
  class AppModule {
11608
13522
  }
11609
13523
  AppModule = app_module_ts_decorate([
@@ -11620,7 +13534,9 @@ AppModule = app_module_ts_decorate([
11620
13534
  DiscoveryModule,
11621
13535
  DeamonModule
11622
13536
  ],
11623
- controllers: [],
13537
+ controllers: [
13538
+ DebugController
13539
+ ],
11624
13540
  providers: []
11625
13541
  })
11626
13542
  ], AppModule);
@@ -11671,10 +13587,16 @@ async function bootstrap() {
11671
13587
  const cmd = process.argv[2];
11672
13588
  if (cmd === 'run') {
11673
13589
  await bootstrapDeamon();
13590
+ } else if (cmd === "mcp") {
13591
+ const app = await core_namespaceObject.NestFactory.createApplicationContext(AppModule, {
13592
+ logger: false
13593
+ });
13594
+ await app.init();
13595
+ process.stdin.resume();
11674
13596
  } else {
11675
13597
  try {
11676
13598
  await external_nest_commander_namespaceObject.CommandFactory.run(AppModule, {
11677
- logger: logger ?? undefined,
13599
+ // logger: false,
11678
13600
  errorHandler (err) {
11679
13601
  if (err.code === 'commander.help') {
11680
13602
  return process.exit(0);