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

teableio / teable / 8432338669

26 Mar 2024 07:31AM UTC coverage: 79.758% (+53.7%) from 26.106%
8432338669

Pull #493

github

web-flow
Merge 5e65977dd into 98543ea09
Pull Request #493: feat: export csv

3271 of 3870 branches covered (84.52%)

48 of 141 new or added lines in 5 files covered. (34.04%)

762 existing lines in 27 files now uncovered.

25230 of 31633 relevant lines covered (79.76%)

1183.33 hits per line

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

31.25
/apps/nestjs-backend/src/features/automation/actions/records/create-record/create-record.ts
1
import { Injectable, Logger, Scope } from '@nestjs/common';
2✔
2
import { FieldKeyType } from '@teable/core';
2✔
3
import type { ICreateRecordsRo } 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 { IActionResponse, IConstSchema, IObjectSchema } from '../../action-core';
2✔
7
import { actionConst, ActionCore, ActionResponseStatus } from '../../action-core';
2✔
8

2✔
9
export interface ICreateRecordSchema extends Record<string, unknown> {
2✔
10
  tableId: IConstSchema;
2✔
11
  fields: IObjectSchema;
2✔
12
}
2✔
13

2✔
14
export interface ICreateRecordOptions {
2✔
15
  tableId: string;
2✔
16
  fields: { [fieldIdOrName: string]: unknown };
2✔
17
}
2✔
18

2✔
19
@Injectable({ scope: Scope.REQUEST })
2✔
20
export class CreateRecord extends ActionCore {
2✔
UNCOV
21
  private logger = new Logger(CreateRecord.name);
×
UNCOV
22

×
UNCOV
23
  constructor(private readonly recordOpenApiService: RecordOpenApiService) {
×
UNCOV
24
    super();
×
UNCOV
25
  }
×
UNCOV
26

×
UNCOV
27
  bindParams(id: string, params: ICreateRecordSchema, priority?: number): this {
×
UNCOV
28
    return this.setName(id).setEvent({ type: id, params: params }).setPriority(priority);
×
UNCOV
29
  }
×
UNCOV
30

×
UNCOV
31
  onSuccess = async (event: Event, almanac: Almanac, _ruleResult: RuleResult): Promise<void> => {
×
UNCOV
32
    const { tableId, fields } = await this.parseInputSchema<ICreateRecordOptions>(
×
UNCOV
33
      event.params as ICreateRecordSchema,
×
UNCOV
34
      almanac
×
UNCOV
35
    );
×
UNCOV
36

×
UNCOV
37
    const createData: ICreateRecordsRo = {
×
UNCOV
38
      fieldKeyType: FieldKeyType.Id,
×
UNCOV
39
      records: [{ fields }],
×
UNCOV
40
    };
×
UNCOV
41

×
UNCOV
42
    let outPut: IActionResponse<unknown>;
×
UNCOV
43

×
UNCOV
44
    await this.recordOpenApiService
×
UNCOV
45
      .multipleCreateRecords(tableId, createData)
×
UNCOV
46
      .then((recordsVo) => {
×
UNCOV
47
        const {
×
UNCOV
48
          records: [record],
×
UNCOV
49
        } = recordsVo;
×
UNCOV
50
        outPut = { data: record, status: ActionResponseStatus.OK };
×
UNCOV
51
      })
×
UNCOV
52
      .catch((error) => {
×
53
        this.logger.error(error.message, error?.stack);
×
54
        outPut = {
×
55
          error: error.message,
×
56
          data: undefined,
×
57
          status: ActionResponseStatus.InternalServerError,
×
58
        };
×
59
      })
×
UNCOV
60
      .finally(() => {
×
UNCOV
61
        almanac.addRuntimeFact(`${actionConst.OutPutFlag}${this.name}`, outPut);
×
UNCOV
62
      });
×
UNCOV
63
  };
×
UNCOV
64
}
×
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

© 2024 Coveralls, Inc