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

teableio / teable / 8421654220

25 Mar 2024 02:22PM CUT coverage: 79.934% (+53.8%) from 26.087%
8421654220

Pull #495

github

web-flow
Merge 4faeebea5 into 1869c986d
Pull Request #495: chore: add licenses for non-NPM packages

3256 of 3853 branches covered (84.51%)

25152 of 31466 relevant lines covered (79.93%)

1188.29 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✔
28
  private logger = new Logger(UpdateRecord.name);
×
29

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

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

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

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

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

×
51
    await this.recordOpenApiService
×
52
      .updateRecord(tableId, recordId, updateData)
×
53
      .then((record) => {
×
54
        outPut = { data: record, status: ActionResponseStatus.OK };
×
55
      })
×
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
      })
×
64
      .finally(() => {
×
65
        almanac.addRuntimeFact(`${actionConst.OutPutFlag}${this.name}`, outPut);
×
66
      });
×
67
  };
×
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