@intrig/core 0.0.15-20 → 0.0.15-22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/main.js +64 -6
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -2845,7 +2845,8 @@ rest_resource_data_ts_decorate([
2845
2845
  ], Variable.prototype, "in", void 0);
2846
2846
  rest_resource_data_ts_decorate([
2847
2847
  (0,swagger.ApiProperty)({
2848
- description: 'Reference of the variable'
2848
+ description: 'Reference of the variable',
2849
+ required: false
2849
2850
  }),
2850
2851
  rest_resource_data_ts_metadata("design:type", String)
2851
2852
  ], Variable.prototype, "ref", void 0);
@@ -3234,13 +3235,18 @@ function jsonLiteral(path) {
3234
3235
 
3235
3236
  ;// ../../lib/common/src/lib/template/template-util.ts
3236
3237
  function getVariableName(ref) {
3238
+ if (!ref) return undefined;
3237
3239
  return ref.split('/').pop();
3238
3240
  }
3239
3241
  function getVariableImports(variables, source, prefix) {
3240
- return variables.map((a)=>getVariableName(a.ref)).map((ref)=>`import { ${ref} } from "${prefix}/${source}/components/schemas/${ref}"`).join("\n");
3242
+ return variables.filter((a)=>a.ref) // Skip variables without schema refs
3243
+ .map((a)=>getVariableName(a.ref)).filter((ref)=>!!ref).map((ref)=>`import { ${ref} } from "${prefix}/${source}/components/schemas/${ref}"`).join("\n");
3241
3244
  }
3242
3245
  function getVariableTypes(variables) {
3243
- return variables.map((p)=>`${p.name}${p.in === "path" ? "" : "?"}: ${getVariableName(p.ref)}`).join("\n");
3246
+ return variables.map((p)=>{
3247
+ const typeName = getVariableName(p.ref) ?? 'any'; // Use 'any' for inline schemas
3248
+ return `${p.name}${p.in === "path" ? "" : "?"}: ${typeName}`;
3249
+ }).join("\n");
3244
3250
  }
3245
3251
  function isParamMandatory(variables) {
3246
3252
  return variables.some((a)=>a.in === 'path');
@@ -7900,19 +7906,50 @@ class ExtractRequestsService {
7900
7906
  this.logger.debug(`Processing ${pathCount} paths from OpenAPI spec`);
7901
7907
  const requests = [];
7902
7908
  const skippedEndpoints = [];
7909
+ const httpMethods = [
7910
+ 'get',
7911
+ 'put',
7912
+ 'post',
7913
+ 'delete',
7914
+ 'options',
7915
+ 'head',
7916
+ 'patch',
7917
+ 'trace'
7918
+ ];
7903
7919
  for (const [path, pathData] of Object.entries(spec.paths)){
7904
7920
  this.logger.debug(`Processing path: ${path}`);
7921
+ // Extract path-level parameters
7922
+ const pathItem = pathData;
7923
+ const pathLevelParams = (pathItem.parameters ?? []).map((p)=>deref(spec)(p)).filter((p)=>!!p);
7905
7924
  for (const [method, methodData] of Object.entries(pathData)){
7925
+ // Skip non-HTTP method properties (parameters, summary, description, servers, $ref)
7926
+ if (!httpMethods.includes(method.toLowerCase())) {
7927
+ continue;
7928
+ }
7906
7929
  const operation = deref(spec)(methodData);
7907
7930
  if (this.isOperationObject(operation)) {
7908
7931
  this.logger.debug(`Processing operation: ${method.toUpperCase()} ${path} (${operation.operationId})`);
7909
- const variables = operation.parameters?.map((p)=>p)?.map((param)=>{
7932
+ // Merge path-level and operation-level parameters (operation params override path params)
7933
+ const operationParams = (operation.parameters ?? []).map((p)=>deref(spec)(p)).filter((p)=>!!p);
7934
+ const mergedParams = [
7935
+ ...pathLevelParams
7936
+ ];
7937
+ for (const opParam of operationParams){
7938
+ const existingIndex = mergedParams.findIndex((p)=>p.name === opParam.name && p.in === opParam.in);
7939
+ if (existingIndex >= 0) {
7940
+ mergedParams[existingIndex] = opParam; // Override path-level param
7941
+ } else {
7942
+ mergedParams.push(opParam);
7943
+ }
7944
+ }
7945
+ const variables = mergedParams.map((param)=>{
7910
7946
  return {
7911
7947
  name: param.name,
7912
7948
  in: param.in,
7913
- ref: isRef(param.schema) ? param.schema.$ref : "any"
7949
+ // Use undefined for inline schemas instead of "any" to avoid reserved keyword issues
7950
+ ref: isRef(param.schema) ? param.schema.$ref : undefined
7914
7951
  };
7915
- }) ?? [];
7952
+ });
7916
7953
  let params = {
7917
7954
  paths: [
7918
7955
  operation.tags?.[0]
@@ -19566,6 +19603,27 @@ async function bootstrapDaemon() {
19566
19603
  const discovery = app.get(DiscoveryService);
19567
19604
  const intrigConfig = app.get(IntrigConfigService).get();
19568
19605
  discovery.register(actualPort, url, intrigConfig.generator);
19606
+ // Handle crashes and cleanup discovery file
19607
+ let isCleaningUp = false;
19608
+ const cleanupAndExit = (reason, err)=>{
19609
+ if (isCleaningUp) return; // Prevent re-entrancy
19610
+ isCleaningUp = true;
19611
+ logger?.error(`Daemon crash (${reason}):`, err?.stack || err);
19612
+ // Synchronously cleanup discovery file - don't rely on async app.close()
19613
+ try {
19614
+ discovery.onApplicationShutdown(reason);
19615
+ } catch (cleanupErr) {
19616
+ logger?.error('Failed to cleanup discovery file:', cleanupErr);
19617
+ }
19618
+ // Give logs time to flush, then exit
19619
+ setImmediate(()=>process.exit(1));
19620
+ };
19621
+ process.on('uncaughtException', (err)=>{
19622
+ cleanupAndExit('uncaughtException', err);
19623
+ });
19624
+ process.on('unhandledRejection', (reason)=>{
19625
+ cleanupAndExit('unhandledRejection', reason instanceof Error ? reason : new Error(String(reason)));
19626
+ });
19569
19627
  logger?.log(`🚀 Application is running on: ${url}/${globalPrefix}`);
19570
19628
  logger?.log(`📖 Swagger docs available at: ${url}/docs`);
19571
19629
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intrig/core",
3
- "version": "0.0.15-20",
3
+ "version": "0.0.15-22",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {