MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / note

Function note

app-playwright/src/arbitraryNote.ts:12–50  ·  view source on GitHub ↗
(template: Template)

Source from the content-addressed store, hash-verified

10import type { Template } from 'shared/domain/template'
11
12export function note(template: Template) {
13 return recordWithOptionalFields<Note>(
14 {
15 id: fc.uuid({ version: 4 }).map((x) => x as NoteId),
16 templateId: fc.constant(template.id),
17 fieldValues: fc
18 .constant(template)
19 .map((t) => t.fields.map((f) => f.name))
20 .chain((fieldNames) =>
21 fc
22 .array(fc.string(), {
23 minLength: fieldNames.length,
24 maxLength: fieldNames.length,
25 })
26 .map((values) =>
27 Object.fromEntries(
28 values.map((value, i) => [fieldNames[i]!, value] as const),
29 ),
30 ),
31 ),
32 tags: fc.array(fc.string()).map((x) => new Set(x)),
33 created: reasonableDates,
34 edited: reasonableDates,
35 remotes: fc.dictionary(
36 arbitraryNookId,
37 fc.oneof(
38 fc.constant(null),
39 fc.record<NoteRemote>({
40 remoteNoteId: arbitraryUlid<RemoteNoteId>(),
41 uploadDate: reasonableDates,
42 }),
43 ),
44 ),
45 },
46 {
47 ankiNoteId: fc.integer(),
48 },
49 )
50}

Callers

nothing calls this directly

Calls 2

recordWithOptionalFieldsFunction · 0.90
arbitraryUlidFunction · 0.90

Tested by

no test coverage detected