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

Function templateToDocType

app/src/sqlite/template.ts:27–49  ·  view source on GitHub ↗
(template: Template)

Source from the content-addressed store, hash-verified

25} from 'shared/utility'
26
27function templateToDocType(template: Template) {
28 const now = C.getDate().getTime()
29 const templateDbId = toLDbId(template.id)
30 const insertTemplate = {
31 id: templateDbId,
32 name: template.name,
33 css: template.css,
34 created: now,
35 edited: now,
36 fields: JSON.stringify(template.fields),
37 templateType: JSON.stringify(template.templateType),
38 } satisfies InsertObject<DB, 'template'>
39 const remoteTemplates = objEntries(template.remotes).map(
40 ([nook, remote]) =>
41 ({
42 localId: templateDbId,
43 nook,
44 remoteId: toLDbId(remote?.remoteTemplateId ?? null),
45 uploadDate: remote?.uploadDate.getTime() ?? null,
46 }) satisfies RemoteTemplate,
47 )
48 return { insertTemplate, remoteTemplates }
49}
50
51function domainToCreateRemote(t: Template, nook?: NookId) {
52 const nooks = nook == null ? objKeys(t.remotes) : [nook]

Callers 1

upsertTemplateFunction · 0.85

Calls 1

toLDbIdFunction · 0.90

Tested by

no test coverage detected