• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 8421671885

25 Mar 2024 02:23PM CUT coverage: 79.959% (+53.9%) from 26.087%
8421671885

Pull #496

github

web-flow
Merge f587f00fb into 9313e45fb
Pull Request #496: fix: unexpected link convert

3265 of 3865 branches covered (84.48%)

63 of 63 new or added lines in 4 files covered. (100.0%)

762 existing lines in 27 files now uncovered.

25183 of 31495 relevant lines covered (79.96%)

1188.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

39.71
/apps/nestjs-backend/src/features/automation/actions/records/update-record/update-record.ts
1
import { Injectable, Logger, Scope } from '@nestjs/common';
2✔
2
import { FieldKeyType } from '@teable/core';
2✔
3
import type { IUpdateRecordRo } from '@teable/openapi';
2✔
4
import type { Almanac, Event, RuleResult } from 'json-rules-engine';
2✔
5
import { RecordOpenApiService } from '../../../../record/open-api/record-open-api.service';
2✔
6
import type {
2✔
7
  IActionResponse,
2✔
8
  IConstSchema,
2✔
9
  IObjectSchema,
2✔
10
  ITemplateSchema,
2✔
11
} from '../../action-core';
2✔
12
import { actionConst, ActionCore, ActionResponseStatus } from '../../action-core';
2✔
13

2✔
14
export interface IUpdateRecordSchema extends Record<string, unknown> {
2✔
15
  tableId: IConstSchema;
2✔
16
  recordId: ITemplateSchema;
2✔
17
  fields: IObjectSchema;
2✔
18
}
2✔
19

2✔
20
export interface IUpdateRecordOptions {
2✔
21
  tableId: string;
2✔
22
  recordId: string;
2✔
23
  fields: { [fieldIdOrName: string]: unknown };
2✔
24
}
2✔
25

2✔
26
@Injectable({ scope: Scope.REQUEST })
2✔
27
export class UpdateRecord extends ActionCore {
2✔
UNCOV
28
  private logger = new Logger(UpdateRecord.name);
×
UNCOV
29

×
UNCOV
30
  constructor(private readonly recordOpenApiService: RecordOpenApiService) {
×
UNCOV
31
    super();
×
UNCOV
32
  }
×
UNCOV
33

×
UNCOV
34
  bindParams(id: string, params: IUpdateRecordSchema, priority?: number): this {
×
UNCOV
35
    return this.setName(id).setEvent({ type: id, params: params }).setPriority(priority);
×
UNCOV
36
  }
×
UNCOV
37

×
UNCOV
38
  onSuccess = async (event: Event, almanac: Almanac, _ruleResult: RuleResult): Promise<void> => {
×
UNCOV
39
    const { tableId, recordId, fields } = await this.parseInputSchema<IUpdateRecordOptions>(
×
UNCOV
40
      event.params as IUpdateRecordSchema,
×
UNCOV
41
      almanac
×
UNCOV
42
    );
×
UNCOV
43

×
UNCOV
44
    const updateData: IUpdateRecordRo = {
×
UNCOV
45
      fieldKeyType: FieldKeyType.Id,
×
UNCOV
46
      record: { fields },
×
UNCOV
47
    };
×
UNCOV
48

×
UNCOV
49
    let outPut: IActionResponse<unknown>;
×
UNCOV
50

×
UNCOV
51
    await this.recordOpenApiService
×
UNCOV
52
      .updateRecord(tableId, recordId, updateData)
×
UNCOV
53
      .then((record) => {
×
UNCOV
54
        outPut = { data: record, status: ActionResponseStatus.OK };
×
UNCOV
55
      })
×
UNCOV
56
      .catch((error) => {
×
57
        this.logger.error(error.message, error?.stack);
×
58
        outPut = {
×
59
          error: error.message,
×
60
          data: undefined,
×
61
          status: ActionResponseStatus.InternalServerError,
×
62
        };
×
63
      })
×
UNCOV
64
      .finally(() => {
×
UNCOV
65
        almanac.addRuntimeFact(`${actionConst.OutPutFlag}${this.name}`, outPut);
×
UNCOV
66
      });
×
UNCOV
67
  };
×
UNCOV
68
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc