http-request-manager 18.16.25 → 18.16.26

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.
@@ -6610,16 +6610,19 @@ class DatabaseManagerService extends DbService {
6610
6610
  }
6611
6611
  updateTableRecord(table, record) {
6612
6612
  const tableName = this.cleanTableName(table);
6613
+ console.log(`🔵 updateTableRecord: INPUT table='${table}' CLEANED='${tableName}'`);
6613
6614
  return this.updateTableRecords(tableName, [record])
6614
6615
  .pipe(map(item => item.length > 0 ? item[0] : null));
6615
6616
  }
6616
6617
  updateTableRecords(table, records) {
6617
6618
  const tableName = this.cleanTableName(table);
6619
+ console.log(`🔵 updateTableRecords: INPUT table='${table}' CLEANED='${tableName}' recordCount=${records.length}`);
6618
6620
  return this.getDatabaseTable(tableName).pipe(switchMap((tableData) => {
6619
6621
  if (!tableData) {
6620
- console.warn(`updateTableRecords: Table '${tableName}' not found`);
6622
+ console.warn(`❌ updateTableRecords: Table '${tableName}' not found`);
6621
6623
  return EMPTY;
6622
6624
  }
6625
+ console.log(`✅ updateTableRecords: Table '${tableName}' FOUND, executing bulkPut with ${records.length} records`);
6623
6626
  const insertRecords = records.map((record) => {
6624
6627
  const payload = { ...(record || {}) };
6625
6628
  if (payload.id === undefined || payload.id === null || payload.id === '') {
@@ -7372,13 +7375,18 @@ class HTTPManagerStateService extends ComponentStore {
7372
7375
  let adaptedData = this.applyAdapter(data);
7373
7376
  adaptedData = (!adaptedData) ? (this.dataType === DataType.ARRAY) ? [] : {} : adaptedData;
7374
7377
  const id = options.path?.length ? options.path[options.path.length - 1] : null;
7378
+ // For single-record operations (CREATE, UPDATE, DELETE), extract from array if needed
7379
+ let singleRecord = adaptedData;
7380
+ if (Array.isArray(adaptedData) && adaptedData.length > 0) {
7381
+ singleRecord = adaptedData[0];
7382
+ }
7375
7383
  if (method === 'DELETE') {
7376
7384
  console.log('🗑️ Deleting record with id:', id);
7377
7385
  this.deleteData$({ id });
7378
7386
  }
7379
7387
  if (method === 'UPDATE') {
7380
- console.log('✏️ Updating record:', adaptedData);
7381
- this.updateData$(adaptedData);
7388
+ console.log('✏️ Updating record:', singleRecord);
7389
+ this.updateData$(singleRecord);
7382
7390
  }
7383
7391
  if (method === 'CREATE') {
7384
7392
  console.log('➕ Adding record:', adaptedData);
@@ -7388,6 +7396,11 @@ class HTTPManagerStateService extends ComponentStore {
7388
7396
  const adaptedData = this.applyAdapter(data);
7389
7397
  const tableName = this.databaseOptions?.table;
7390
7398
  const idFromPath = options.path?.length ? options.path[options.path.length - 1] : null;
7399
+ // For single-record operations, extract from array if needed
7400
+ let singleRecord = adaptedData;
7401
+ if (Array.isArray(adaptedData) && adaptedData.length > 0) {
7402
+ singleRecord = adaptedData[0];
7403
+ }
7391
7404
  if (this.hasDatabase && tableName) {
7392
7405
  switch (method) {
7393
7406
  case 'DELETE':
@@ -7398,11 +7411,11 @@ class HTTPManagerStateService extends ComponentStore {
7398
7411
  this.logger.warn('fetchRecord', 'DELETE method called but id is missing from path', { options });
7399
7412
  break;
7400
7413
  case 'UPDATE':
7401
- if (adaptedData && adaptedData.id != null) {
7402
- this.logger.debug('fetchRecord', 'Updating database record', { table: tableName, id: adaptedData.id, data: adaptedData });
7403
- return this.dbManagerService.updateTableRecord(tableName, adaptedData);
7414
+ if (singleRecord && singleRecord.id != null) {
7415
+ this.logger.debug('fetchRecord', 'Updating database record', { table: tableName, id: singleRecord.id, data: singleRecord });
7416
+ return this.dbManagerService.updateTableRecord(tableName, singleRecord);
7404
7417
  }
7405
- this.logger.warn('fetchRecord', 'UPDATE method called but adaptedData or id is missing', { adaptedData, hasData: !!adaptedData, hasId: !!adaptedData?.id });
7418
+ this.logger.warn('fetchRecord', 'UPDATE method called but singleRecord or id is missing', { singleRecord, hasData: !!singleRecord, hasId: !!singleRecord?.id });
7406
7419
  break;
7407
7420
  case 'CREATE':
7408
7421
  if (adaptedData && adaptedData.id != null && adaptedData.id !== '') {