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

popstas / planfix-mcp-server / 16464842119

23 Jul 2025 07:53AM UTC coverage: 81.624% (+0.7%) from 80.957%
16464842119

push

github

web-flow
Fix typecheck and update contact tests (#46)

* fix typecheck and update tests

* fix lint

435 of 599 branches covered (72.62%)

Branch coverage included in aggregate %.

6 of 6 new or added lines in 2 files covered. (100.0%)

85 existing lines in 6 files now uncovered.

3043 of 3662 relevant lines covered (83.1%)

2.47 hits per line

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

68.18
/src/lib/extendPostBodyWithCustomFields.ts
1
import type {
2
  ContactResponse,
3
  CustomFieldDataType,
4
  TaskResponse,
5
} from "../types.js";
6
import type { CustomField } from "./extendSchemaWithCustomFields.js";
7
import { addDirectoryEntries, addDirectoryEntry } from "../lib/planfixDirectory.js"
1✔
8

9
export interface HasCustomFieldData {
10
  customFieldData?: CustomFieldDataType[];
11
  template: {
12
    id: number,
13
  }
14
}
15

16
export async function extendPostBodyWithCustomFields(
9✔
17
  postBody: HasCustomFieldData,
9✔
18
  args: Record<string, unknown>,
9✔
19
  fields: CustomField[],
9✔
20
  task?: TaskResponse,
9✔
21
  contact?: ContactResponse,
9✔
22
  forceUpdate?: boolean,
9✔
23
): Promise<void> {
9✔
24
  if (!fields.length) return;
9✔
25
  for (const field of fields) {
4✔
26
    const value =
4✔
27
      (args[field.argName as keyof typeof args] as unknown) || field.default;
4✔
28
    if (value === undefined || value === null || value === "") continue;
4!
29

30
    const current = task || contact;
4✔
31
    const currentField = current?.customFieldData?.find(
4✔
32
      (f) => f.field.id === Number(field.id),
4✔
33
    );
4✔
34
    let currentValue;
4✔
35
    if (field.type === "enum") {
4✔
36
      currentValue =
2✔
37
        currentField && Array.isArray(currentField.value)
2✔
38
          ? currentField?.value?.[0]
2!
UNCOV
39
          : "";
×
40
    }
2✔
41
    if (field.type === "handbook_record") {
4!
UNCOV
42
      await addDirectoryEntry({
×
UNCOV
43
        objectId: postBody.template.id,
×
UNCOV
44
        fieldId: field.id,
×
UNCOV
45
        value: value as string,
×
UNCOV
46
        postBody,
×
UNCOV
47
      });
×
UNCOV
48
      continue;
×
UNCOV
49
    }
×
50
    if (field.type === "handbook_record_multiple") {
4!
UNCOV
51
      await addDirectoryEntries({
×
UNCOV
52
        objectId: postBody.template.id,
×
UNCOV
53
        fieldId: field.id,
×
UNCOV
54
        values: value as string[],
×
UNCOV
55
        postBody,
×
UNCOV
56
      });
×
UNCOV
57
      continue;
×
UNCOV
58
    }
×
59
    if (!forceUpdate && currentValue === value) continue;
4✔
60

61
    if (!postBody.customFieldData) postBody.customFieldData = [];
3✔
62
    postBody.customFieldData.push({
3✔
63
      field: { id: Number(field.id) },
3✔
64
      value: value as
3✔
65
        | string
66
        | number
67
        | string[]
68
        | { id: number }
69
        | { id: number }[],
70
    });
3✔
71
  }
3✔
72
}
4✔
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

© 2026 Coveralls, Inc