@lapis-notes/lapis-plugin-contacts 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +661 -0
  3. package/README.md +125 -2
  4. package/dist/ContactMarkdownEditor-DoTuV5ka.js +69 -0
  5. package/dist/apl-B2DGVGxc.js +76 -0
  6. package/dist/asciiarmor-2LVJmxlE.js +34 -0
  7. package/dist/asn1-jKiBa2Ya.js +95 -0
  8. package/dist/asterisk-DS281yxp.js +271 -0
  9. package/dist/brainfuck-C_p9pTT8.js +34 -0
  10. package/dist/clike-BMALKCNj.js +620 -0
  11. package/dist/clojure-CCKyeQKf.js +800 -0
  12. package/dist/cmake-CuaCgAKt.js +28 -0
  13. package/dist/cobol-BlTKFDRj.js +72 -0
  14. package/dist/coffeescript-BVCvwO8I.js +179 -0
  15. package/dist/commonlisp-D_kxz07b.js +75 -0
  16. package/dist/crystal-D309uH6_.js +217 -0
  17. package/dist/css-BkF-NPzE.js +1553 -0
  18. package/dist/cypher-BMq4Fwjl.js +68 -0
  19. package/dist/d-BZcgY6La.js +127 -0
  20. package/dist/diff-Cg9d_RX2.js +18 -0
  21. package/dist/dist--69zc0xf.js +247 -0
  22. package/dist/dist-3FBhTVCW.js +260 -0
  23. package/dist/dist-BIUwdsPJ.js +300 -0
  24. package/dist/dist-BKba7kvs.js +75 -0
  25. package/dist/dist-BqWvrEwT.js +98 -0
  26. package/dist/dist-ByOxufTQ.js +58 -0
  27. package/dist/dist-CU8VWvs8.js +288 -0
  28. package/dist/dist-C_EduL9A.js +268 -0
  29. package/dist/dist-Cqfbp9Nb.js +310 -0
  30. package/dist/dist-DLu2t1SV.js +611 -0
  31. package/dist/dist-DPPvU9Yj.js +134 -0
  32. package/dist/dist-DufK_s_A.js +564 -0
  33. package/dist/dist-Dug8cDx1.js +93 -0
  34. package/dist/dist-IBryJBJR.js +137 -0
  35. package/dist/dist-ciD_jrkE.js +158 -0
  36. package/dist/dist-v6nTmcwY.js +71 -0
  37. package/dist/dockerfile-DFX8bq9N.js +194 -0
  38. package/dist/dtd-CtLokQ-U.js +84 -0
  39. package/dist/dylan-QYeExnWK.js +234 -0
  40. package/dist/ebnf-DUPDuY4r.js +78 -0
  41. package/dist/ecl-CiXN-g_D.js +121 -0
  42. package/dist/eiffel-yQhjl4T1.js +110 -0
  43. package/dist/elm-CNT9vbN0.js +108 -0
  44. package/dist/erlang-CFOYdy9e.js +487 -0
  45. package/dist/factor-Clf6BoVk.js +65 -0
  46. package/dist/fcl-CPC2WYrI.js +103 -0
  47. package/dist/forth-BmxRyE9S.js +60 -0
  48. package/dist/fortran-9bvPyrOW.js +442 -0
  49. package/dist/gas-cpmYfFX2.js +183 -0
  50. package/dist/gherkin-CJuwpceU.js +34 -0
  51. package/dist/groovy-DZeT_VM-.js +146 -0
  52. package/dist/haskell-CxiO_7JL.js +375 -0
  53. package/dist/haxe-70NVW1pR.js +359 -0
  54. package/dist/http-D9LttvKF.js +44 -0
  55. package/dist/idl-B6TRFYjl.js +947 -0
  56. package/dist/index-BGQ4A2O3.js +148265 -0
  57. package/dist/index.js +16 -0
  58. package/dist/javascript-DOuB9oqA.js +691 -0
  59. package/dist/julia-DpvXAuO6.js +241 -0
  60. package/dist/livescript-CanGTf8u.js +272 -0
  61. package/dist/lua-DBWH1E3Q.js +217 -0
  62. package/dist/mathematica-jaRHnSxC.js +35 -0
  63. package/dist/mbox-BctzC1hL.js +76 -0
  64. package/dist/mirc-CFBPAOaF.js +72 -0
  65. package/dist/mllike-BSnXJBGA.js +272 -0
  66. package/dist/modelica-vUgVs--1.js +93 -0
  67. package/dist/module-BFIPY8X5.js +2973 -0
  68. package/dist/mscgen-Cpl0NYLN.js +104 -0
  69. package/dist/mumps-CQoS1kWX.js +25 -0
  70. package/dist/native-CDi4YD_s.js +13 -0
  71. package/dist/nginx-zDPm3Z74.js +89 -0
  72. package/dist/nsis-DAjtFbMY.js +62 -0
  73. package/dist/ntriples-CsNjv2QF.js +79 -0
  74. package/dist/octave-C8PmmSRH.js +143 -0
  75. package/dist/oz-Ce8aN8oE.js +151 -0
  76. package/dist/pascal-De0D6mP7.js +77 -0
  77. package/dist/perl-B4bSCe1C.js +915 -0
  78. package/dist/pig-D24Z8EXi.js +54 -0
  79. package/dist/powershell-DkYVfTzP.js +249 -0
  80. package/dist/properties-Dn9wna3M.js +26 -0
  81. package/dist/protobuf-BPIjwpzm.js +49 -0
  82. package/dist/pug-TGXr6c5j.js +248 -0
  83. package/dist/puppet-nyd4dhjf.js +45 -0
  84. package/dist/python-BkR3uSy8.js +313 -0
  85. package/dist/q-DyHZGnqm.js +86 -0
  86. package/dist/r-LKEuhEGI.js +104 -0
  87. package/dist/rpm-IznJm2Xc.js +57 -0
  88. package/dist/ruby-DjGRFiOI.js +228 -0
  89. package/dist/sas-7E8yHoCW.js +105 -0
  90. package/dist/scheme-DjibxsNh.js +124 -0
  91. package/dist/shell-C0C2sNA_.js +182 -0
  92. package/dist/sieve-Bwz7vjP5.js +72 -0
  93. package/dist/simple-mode-mNVtnu0l.js +89 -0
  94. package/dist/smalltalk-Bhddl2pB.js +48 -0
  95. package/dist/solr-BNlsLglM.js +41 -0
  96. package/dist/sparql-FarWu_Gb.js +197 -0
  97. package/dist/spreadsheet-C-cy4P5N.js +49 -0
  98. package/dist/sql-CfG5lQ3l.js +282 -0
  99. package/dist/styles.css +1 -0
  100. package/dist/stylus-CAdqWld3.js +250 -0
  101. package/dist/swift-DSxqR9R6.js +230 -0
  102. package/dist/tcl-xfoLljhY.js +81 -0
  103. package/dist/textile-D1AWE-pc.js +295 -0
  104. package/dist/tiddlywiki-5wqsXtSk.js +155 -0
  105. package/dist/tiki-__Kn3CeS.js +181 -0
  106. package/dist/toml-DWAmxCjl.js +58 -0
  107. package/dist/troff-D2UO-fKf.js +35 -0
  108. package/dist/ttcn-Bsa4sfRm.js +123 -0
  109. package/dist/ttcn-cfg-Bac_acMi.js +88 -0
  110. package/dist/turtle-xwJUxoPV.js +80 -0
  111. package/dist/types/contacts/contact-fields.d.ts +28 -0
  112. package/dist/types/contacts/contact-list-view.d.ts +41 -0
  113. package/dist/types/contacts/contact-methods.d.ts +38 -0
  114. package/dist/types/contacts/contact-selection.d.ts +23 -0
  115. package/dist/types/contacts/markdown-session-types.d.ts +8 -0
  116. package/dist/types/contacts/model.d.ts +103 -0
  117. package/dist/types/contacts/person.d.ts +49 -0
  118. package/dist/types/contacts/validate-frontmatter.d.ts +1 -0
  119. package/dist/types/lib/contacts-plugin.d.ts +34 -0
  120. package/dist/types/lib/contacts-settings-definition.d.ts +24 -0
  121. package/dist/types/lib/contacts-settings.d.ts +48 -0
  122. package/dist/types/lib/contacts-view.d.ts +22 -0
  123. package/dist/types/lib/google/conflict-queue.d.ts +35 -0
  124. package/dist/types/lib/google/google-person.d.ts +54 -0
  125. package/dist/types/lib/google/google-sync.d.ts +50 -0
  126. package/dist/types/lib/google/people-client.d.ts +50 -0
  127. package/dist/types/lib/google/people-import.d.ts +61 -0
  128. package/dist/types/lib/google/people-push.d.ts +30 -0
  129. package/dist/types/lib/google/reconcile.d.ts +62 -0
  130. package/dist/types/lib/google/vault-contact-files.d.ts +8 -0
  131. package/dist/types/lib/google-conflicts-view.d.ts +15 -0
  132. package/dist/types/lib/index.d.ts +4 -0
  133. package/dist/types/lib/vault-contacts.d.ts +64 -0
  134. package/dist/vb-c2kQGd6-.js +74 -0
  135. package/dist/vbscript-1f_Dhg5H.js +324 -0
  136. package/dist/velocity-DJd0pTTC.js +96 -0
  137. package/dist/verilog-CiS1jyi5.js +262 -0
  138. package/dist/vhdl-T9HkrbI2.js +106 -0
  139. package/dist/webidl-CjfDENEo.js +155 -0
  140. package/dist/xquery-Ct6lEb4B.js +422 -0
  141. package/dist/yacas-C0absKBh.js +73 -0
  142. package/dist/z80-Pki2zAjW.js +61 -0
  143. package/manifest.json +43 -0
  144. package/package.json +116 -4
  145. package/schemas/contact.schema.json +619 -0
@@ -0,0 +1,24 @@
1
+ import type { PluginSettingsDefinition, TFolder } from "@lapis-notes/api";
2
+ import type { ContactsPlugin } from "./contacts-plugin";
3
+ export declare const CONTACTS_SETTINGS_SECTION_ID = "contacts";
4
+ /** Field ids are the setting keys under one section, so the key is the id. */
5
+ export declare const CONTACTS_SETTING_IDS: {
6
+ readonly folder: "contacts.folder";
7
+ readonly replyIntervalDays: "contacts.replyIntervalDays";
8
+ readonly defaultFilter: "contacts.defaultFilter";
9
+ readonly sortKey: "contacts.sortKey";
10
+ readonly sortDirection: "contacts.sortDirection";
11
+ readonly showActivitySidebar: "contacts.showActivitySidebar";
12
+ };
13
+ /** Vault folders as settings store them: `/contacts`, with the root as `/`. */
14
+ export declare function vaultFolderValues(folders: readonly TFolder[]): string[];
15
+ /** Vault folders matching a typed query, in settings form (`/contacts`). */
16
+ export declare function suggestVaultFolders(folders: readonly TFolder[], query: string): {
17
+ value: string;
18
+ }[];
19
+ /**
20
+ * The one declarative description of the Contacts settings. Workspace Settings
21
+ * and the legacy plugin tab both render it; the plugin keeps ownership of the
22
+ * values and their validation.
23
+ */
24
+ export declare function createContactsSettingsDefinition(plugin: ContactsPlugin): PluginSettingsDefinition;
@@ -0,0 +1,48 @@
1
+ import { type SortDirection, type SortKey } from "../contacts/contact-list-view";
2
+ export declare const DEFAULT_FILTERS: readonly ["all", "favourites", "mine", "theirs"];
3
+ export type DefaultFilter = (typeof DEFAULT_FILTERS)[number];
4
+ export type ContactsSettings = {
5
+ /** Vault folder holding one Markdown file per contact, e.g. `/contacts`. */
6
+ folder: string;
7
+ /** Calendar days until a new follow-up is due. */
8
+ replyIntervalDays: number;
9
+ /** Directory list shown when Contacts opens. */
10
+ defaultFilter: DefaultFilter;
11
+ /** How the directory is ordered when Contacts opens. */
12
+ sortKey: SortKey;
13
+ sortDirection: SortDirection;
14
+ /** Whether the activity sidebar starts open on wide screens. */
15
+ showActivitySidebar: boolean;
16
+ };
17
+ export type ContactsSettingsPatch = Partial<ContactsSettings>;
18
+ /** A linked Google account and what the last import left behind. */
19
+ export type GoogleLink = {
20
+ /** The host's connection handle; the host holds the tokens. */
21
+ connectionId: string;
22
+ /** The account that scopes every remote identity. */
23
+ account: string;
24
+ /** The account was linked with permission to edit contacts. */
25
+ write?: boolean;
26
+ state: {
27
+ syncToken?: string;
28
+ snapshots: Record<string, string>;
29
+ };
30
+ };
31
+ export type ContactsPluginData = {
32
+ version: 1;
33
+ settings: ContactsSettings;
34
+ google?: GoogleLink;
35
+ };
36
+ export declare const CONTACTS_DATA_VERSION = 1;
37
+ export declare const DEFAULT_CONTACTS_SETTINGS: Readonly<ContactsSettings>;
38
+ export declare class ContactsSettingsError extends Error {
39
+ name: string;
40
+ }
41
+ export declare function validateReplyInterval(value: unknown): number;
42
+ export declare function validateFolder(value: unknown): string;
43
+ export declare function patchContactsSettings(current: ContactsSettings, patch: ContactsSettingsPatch): ContactsSettings;
44
+ /** Reads stored plugin data, falling back per field to the defaults. */
45
+ export declare function migrateContactsData(raw: unknown): ContactsPluginData;
46
+ /** The local calendar date as `YYYY-MM-DD`. */
47
+ export declare function localDate(date: Date): string;
48
+ export declare const cloneSettings: (settings: ContactsSettings) => ContactsSettings;
@@ -0,0 +1,22 @@
1
+ import { View, type App, type WorkspaceLeaf } from "@lapis-notes/api";
2
+ import type { ContactsStore } from "../contacts/model";
3
+ import type { OpenMarkdownSession } from "../contacts/markdown-session-types";
4
+ import { type ContactsSettings } from "./contacts-settings";
5
+ export declare const CONTACTS_VIEW_TYPE = "contacts";
6
+ /** The host owns the App, so the editor borrows it and releases nothing. */
7
+ export declare function hostMarkdownSession(app: App): OpenMarkdownSession;
8
+ /** Reads tag suggestions from the host metadata index, including other notes. */
9
+ export declare function hostVaultTags(app: App): () => Promise<string[]>;
10
+ export declare class ContactsView extends View {
11
+ private readonly store;
12
+ private readonly settings;
13
+ private component;
14
+ constructor(leaf: WorkspaceLeaf, store: ContactsStore, settings?: () => ContactsSettings);
15
+ getViewType(): string;
16
+ getDisplayText(): string;
17
+ getIcon(): string;
18
+ protected onOpen(): Promise<void>;
19
+ protected onClose(): Promise<void>;
20
+ onload(): void;
21
+ onunload(): void;
22
+ }
@@ -0,0 +1,35 @@
1
+ import type { GooglePerson } from "./google-person";
2
+ import type { ContactFiles, ImportOutcome, ImportState } from "./people-import";
3
+ /** One contact whose Google and local fields both changed the same lines. */
4
+ export interface GoogleConflict {
5
+ path: string;
6
+ person: string;
7
+ account: string;
8
+ left: string;
9
+ base: string;
10
+ right: string;
11
+ remote: GooglePerson;
12
+ }
13
+ type Listener = (entries: readonly GoogleConflict[]) => void;
14
+ /**
15
+ * Conflicts waiting for review. A newer import of the same contact replaces
16
+ * its entry; resolving writes the reviewed text and advances the snapshot.
17
+ */
18
+ export declare class GoogleConflictQueue {
19
+ #private;
20
+ private readonly files;
21
+ private readonly state;
22
+ constructor(files: ContactFiles, state: {
23
+ get(): ImportState;
24
+ set(next: ImportState): void | Promise<void>;
25
+ });
26
+ get entries(): readonly GoogleConflict[];
27
+ subscribe(listener: Listener): () => undefined;
28
+ /** Queue the conflicts from an import; drop entries for contacts that no longer conflict. */
29
+ record(outcomes: readonly ImportOutcome[], account: string): void;
30
+ /** Write the reviewed Google fields; the vault changes only if the file is unchanged. */
31
+ resolve(path: string, resolved: string): Promise<void>;
32
+ /** Forget a conflict without writing; the next import reports it again. */
33
+ dismiss(path: string): void;
34
+ }
35
+ export {};
@@ -0,0 +1,54 @@
1
+ /** The slice of a Google People `Person` that Contacts imports. */
2
+ export interface GooglePerson {
3
+ resourceName: string;
4
+ etag?: string;
5
+ metadata?: {
6
+ deleted?: boolean;
7
+ sources?: {
8
+ type?: string;
9
+ id?: string;
10
+ etag?: string;
11
+ }[];
12
+ };
13
+ names?: unknown[];
14
+ organizations?: unknown[];
15
+ birthdays?: unknown[];
16
+ photos?: unknown[];
17
+ emailAddresses?: unknown[];
18
+ phoneNumbers?: unknown[];
19
+ urls?: unknown[];
20
+ userDefined?: unknown[];
21
+ addresses?: unknown[];
22
+ memberships?: {
23
+ contactGroupMembership?: {
24
+ contactGroupResourceName?: string;
25
+ };
26
+ }[];
27
+ }
28
+ /**
29
+ * Frontmatter keys that Google owns. Everything else (interactions, follow-ups,
30
+ * tags, groups, favourite, notes, related people) is Lapis-owned and is never
31
+ * part of a merge, so it cannot conflict or be overwritten.
32
+ */
33
+ export declare const GOOGLE_KEYS: readonly ["names", "organizations", "birthdays", "photos", "emailAddresses", "phoneNumbers", "urls", "userDefined", "addresses"];
34
+ export type GoogleKey = (typeof GOOGLE_KEYS)[number];
35
+ /** Read, validate and rewrite a contact so equal content has equal text. */
36
+ export declare function canonicalContact(path: string, source: string): string;
37
+ /** The Google link a contact file carries, if any. */
38
+ export declare function googleLinkOf(path: string, source: string): {
39
+ resourceName: string;
40
+ account: string;
41
+ etag: string | undefined;
42
+ } | undefined;
43
+ /** The Google-owned fields of a contact file, as stable YAML text. */
44
+ export declare function localProjection(path: string, source: string): string;
45
+ /**
46
+ * The Google-owned fields of a remote Person. A key missing from the read
47
+ * mask was not read, so it keeps the local value instead of reading as removed.
48
+ */
49
+ export declare function personProjection(person: GooglePerson, localText: string, readMask?: readonly string[]): string;
50
+ /**
51
+ * Write projected Google fields and the link back into a contact, leaving
52
+ * every Lapis-owned field and its address date ranges untouched.
53
+ */
54
+ export declare function applyProjection(path: string, local: string, projection: string, person: GooglePerson, account: string): string;
@@ -0,0 +1,50 @@
1
+ import type { PluginOAuth } from "@lapis-notes/api";
2
+ import type { GoogleLink } from "../contacts-settings";
3
+ import { GoogleConflictQueue } from "./conflict-queue";
4
+ import { type PushOutcome } from "./people-push";
5
+ import { type ContactFiles, type ImportOutcome } from "./people-import";
6
+ export declare const GOOGLE_PROVIDER = "google";
7
+ export declare const GOOGLE_SCOPES: string[];
8
+ export declare const GOOGLE_WRITE_SCOPES: string[];
9
+ export interface SyncSummary {
10
+ created: number;
11
+ merged: number;
12
+ unchanged: number;
13
+ conflicts: number;
14
+ deleted: number;
15
+ ambiguous: number;
16
+ pushed: number;
17
+ stale: number;
18
+ }
19
+ export declare function summarise(outcomes: readonly (ImportOutcome | PushOutcome)[]): SyncSummary;
20
+ export declare class GoogleSyncUnavailable extends Error {
21
+ name: string;
22
+ }
23
+ /**
24
+ * Links a Google account through the host's OAuth and imports its contacts.
25
+ * The plugin holds the connection handle and import state, never a token.
26
+ */
27
+ export declare class GoogleSync {
28
+ #private;
29
+ private readonly deps;
30
+ constructor(deps: {
31
+ /** The host's OAuth, or undefined when the host does not provide it. */
32
+ oauth: () => PluginOAuth | undefined;
33
+ files: ContactFiles;
34
+ folder: () => string;
35
+ link: () => GoogleLink | undefined;
36
+ saveLink: (link: GoogleLink | undefined) => Promise<void>;
37
+ queue: GoogleConflictQueue;
38
+ sleep?: (ms: number) => Promise<void>;
39
+ });
40
+ get available(): boolean;
41
+ get link(): GoogleLink | undefined;
42
+ /** Run consent in the host and remember the account. */
43
+ connect(options?: {
44
+ write?: boolean;
45
+ }): Promise<GoogleLink>;
46
+ /** Import now; a second call while one runs shares its result. */
47
+ sync(): Promise<SyncSummary>;
48
+ /** Revoke the account in the host and forget the import state. */
49
+ disconnect(): Promise<void>;
50
+ }
@@ -0,0 +1,50 @@
1
+ import type { GooglePerson } from "./google-person";
2
+ /** One authenticated request to the People API; the host attaches the token. */
3
+ export type PeopleTransport = (url: string, init?: {
4
+ method?: "GET" | "PATCH";
5
+ headers?: Record<string, string>;
6
+ body?: string;
7
+ }) => Promise<{
8
+ status: number;
9
+ headers: Record<string, string>;
10
+ body: string;
11
+ }>;
12
+ export declare const PEOPLE_ORIGIN = "https://people.googleapis.com";
13
+ export declare const PERSON_FIELDS: readonly ["names", "organizations", "birthdays", "photos", "emailAddresses", "phoneNumbers", "urls", "userDefined", "addresses", "memberships", "metadata"];
14
+ export declare class PeopleApiError extends Error {
15
+ readonly status: number;
16
+ /** Google's `error.status`, such as `FAILED_PRECONDITION`. */
17
+ readonly code?: string | undefined;
18
+ constructor(message: string, status: number,
19
+ /** Google's `error.status`, such as `FAILED_PRECONDITION`. */
20
+ code?: string | undefined);
21
+ }
22
+ export interface ListOptions {
23
+ /** A token from a previous full import; omit for a full import. */
24
+ syncToken?: string;
25
+ pageSize?: number;
26
+ /** Test seam: waits between retries. */
27
+ sleep?: (ms: number) => Promise<void>;
28
+ /** Retries for 429 and 5xx; default 3. */
29
+ retries?: number;
30
+ }
31
+ export interface ListResult {
32
+ people: GooglePerson[];
33
+ /** Pass this next time for an incremental import. */
34
+ nextSyncToken?: string;
35
+ /** The stored token expired; this result is a full import instead. */
36
+ fullResync: boolean;
37
+ }
38
+ /** Every connection, following pages; an expired sync token falls back to a full import. */
39
+ export declare function listConnections(transport: PeopleTransport, options?: ListOptions): Promise<ListResult>;
40
+ /** Google rejected an edit because the contact changed since it was imported. */
41
+ export declare class StaleContactError extends Error {
42
+ name: string;
43
+ }
44
+ /**
45
+ * Update the Google-owned fields in `fields` of one contact. `person.etag`
46
+ * must be the etag last imported; Google refuses the edit if it changed.
47
+ */
48
+ export declare function updateContact(transport: PeopleTransport, person: GooglePerson, fields: readonly string[], options?: Pick<ListOptions, "sleep" | "retries">): Promise<GooglePerson>;
49
+ /** Names of the user's own contact groups, by resource name. */
50
+ export declare function listContactGroups(transport: PeopleTransport, options?: Pick<ListOptions, "sleep" | "retries">): Promise<Map<string, string>>;
@@ -0,0 +1,61 @@
1
+ import { type GooglePerson } from "./google-person";
2
+ import { type PeopleTransport } from "./people-client";
3
+ /** The vault, as the importer sees it. */
4
+ export interface ContactFiles {
5
+ list(): {
6
+ path: string;
7
+ source: string;
8
+ }[];
9
+ /** Creates the file at the given path or a free sibling; returns the path used. */
10
+ create(path: string, source: string): Promise<string>;
11
+ /** Replaces `expected` with `source`, or rejects when the file changed. */
12
+ write(path: string, source: string, expected: string): Promise<void>;
13
+ }
14
+ /** Durable per-account state; the caller persists it between imports. */
15
+ export interface ImportState {
16
+ syncToken?: string;
17
+ /** The last imported Google fields, by local contact path. */
18
+ snapshots: Record<string, string>;
19
+ }
20
+ export type ImportOutcome = {
21
+ kind: "created" | "merged" | "unchanged" | "deleted";
22
+ person: string;
23
+ path: string;
24
+ } | {
25
+ kind: "conflict";
26
+ person: string;
27
+ path: string;
28
+ left: string;
29
+ base: string;
30
+ right: string;
31
+ remote: GooglePerson;
32
+ }
33
+ /** Several local contacts share an email; someone must choose. */
34
+ | {
35
+ kind: "ambiguous";
36
+ person: string;
37
+ paths: string[];
38
+ };
39
+ export interface ImportResult {
40
+ outcomes: ImportOutcome[];
41
+ state: ImportState;
42
+ fullResync: boolean;
43
+ }
44
+ /** Group names Google files a person under, from the user's own groups. */
45
+ export declare function groupNames(person: GooglePerson, groups: ReadonlyMap<string, string>): string[];
46
+ /** Add missing group names to a contact; Lapis groups are never removed. */
47
+ export declare function withGroups(path: string, source: string, names: string[]): string;
48
+ /** A new contact file for a Person that has no local contact yet. */
49
+ export declare function contactFromPerson(person: GooglePerson, account: string): string;
50
+ /**
51
+ * Import the connections the People API returns: link, merge or create each
52
+ * Person and report what needs review. Nothing is written for a conflict.
53
+ */
54
+ export declare function importContacts(options: {
55
+ transport: PeopleTransport;
56
+ account: string;
57
+ folder: string;
58
+ files: ContactFiles;
59
+ state: ImportState;
60
+ sleep?: (ms: number) => Promise<void>;
61
+ }): Promise<ImportResult>;
@@ -0,0 +1,30 @@
1
+ import { type PeopleTransport } from "./people-client";
2
+ import type { ContactFiles, ImportState } from "./people-import";
3
+ export type PushOutcome = {
4
+ kind: "pushed";
5
+ path: string;
6
+ fields: string[];
7
+ }
8
+ /** Google changed the contact since the last import; import again first. */
9
+ | {
10
+ kind: "stale";
11
+ path: string;
12
+ };
13
+ export interface PushResult {
14
+ outcomes: PushOutcome[];
15
+ state: ImportState;
16
+ }
17
+ /**
18
+ * Send local edits to Google-owned fields of linked contacts. Only fields that
19
+ * differ from the last imported snapshot are sent, and Google refuses the
20
+ * edit when its copy changed, so a remote edit is never overwritten.
21
+ */
22
+ export declare function pushContacts(options: {
23
+ transport: PeopleTransport;
24
+ account: string;
25
+ files: ContactFiles;
26
+ state: ImportState;
27
+ /** Contacts waiting for conflict review are left alone. */
28
+ skip?: ReadonlySet<string>;
29
+ sleep?: (ms: number) => Promise<void>;
30
+ }): Promise<PushResult>;
@@ -0,0 +1,62 @@
1
+ import { type GooglePerson } from "./google-person";
2
+ export interface ReconcileInput {
3
+ /** Vault path of the linked contact. */
4
+ path: string;
5
+ /** The contact file as it is now. */
6
+ local: string;
7
+ /** The Google fields last imported (`snapshot` from the previous result). */
8
+ base?: string;
9
+ person: GooglePerson;
10
+ account: string;
11
+ /** Person fields that were requested; others are treated as not read. */
12
+ readMask?: readonly string[];
13
+ }
14
+ export type Reconciliation =
15
+ /** Nothing changed on either side. */
16
+ {
17
+ kind: "unchanged";
18
+ snapshot: string;
19
+ }
20
+ /** Every difference merged without conflict; write `source`. */
21
+ | {
22
+ kind: "merged";
23
+ source: string;
24
+ snapshot: string;
25
+ }
26
+ /** Both sides changed the same lines; review with a three-way merge. */
27
+ | {
28
+ kind: "conflict";
29
+ left: string;
30
+ base: string;
31
+ right: string;
32
+ unresolved: number;
33
+ snapshot: string;
34
+ }
35
+ /** Google reports the contact as deleted; the caller decides what to do. */
36
+ | {
37
+ kind: "deleted";
38
+ };
39
+ /**
40
+ * Three-way reconcile the Google-owned fields of one linked contact. Only
41
+ * those fields are merged, so Lapis-owned data cannot conflict or be lost.
42
+ */
43
+ export declare function reconcile(input: ReconcileInput): Reconciliation;
44
+ /** Write the text a reviewer resolved in the three-way merge editor. */
45
+ export declare function resolveConflict(input: Pick<ReconcileInput, "path" | "local" | "person" | "account">, resolved: string): string;
46
+ export type Match = {
47
+ kind: "linked";
48
+ path: string;
49
+ } | {
50
+ kind: "ambiguous";
51
+ paths: string[];
52
+ } | {
53
+ kind: "none";
54
+ };
55
+ /**
56
+ * Find the local contact for a Person: the account-scoped link first, then
57
+ * shared email addresses, which are never linked without a decision.
58
+ */
59
+ export declare function matchContact(files: readonly {
60
+ path: string;
61
+ source: string;
62
+ }[], person: GooglePerson, account: string): Match;
@@ -0,0 +1,8 @@
1
+ import type { Vault } from "@lapis-notes/api";
2
+ import type { ContactFiles } from "./people-import";
3
+ import type { VaultContacts } from "../vault-contacts";
4
+ /**
5
+ * The importer's view of the vault: the contacts the store already read, with
6
+ * guarded writes through it, and new files created beside them.
7
+ */
8
+ export declare function vaultContactFiles(vault: Vault, store: VaultContacts): ContactFiles;
@@ -0,0 +1,15 @@
1
+ import { View, type WorkspaceLeaf } from "@lapis-notes/api";
2
+ import type { GoogleConflictQueue } from "./google/conflict-queue";
3
+ export declare const GOOGLE_CONFLICTS_VIEW_TYPE = "contacts-google-conflicts";
4
+ export declare class GoogleConflictsView extends View {
5
+ private readonly queue;
6
+ private component;
7
+ constructor(leaf: WorkspaceLeaf, queue: GoogleConflictQueue);
8
+ getViewType(): string;
9
+ getDisplayText(): string;
10
+ getIcon(): string;
11
+ protected onOpen(): Promise<void>;
12
+ protected onClose(): Promise<void>;
13
+ onload(): void;
14
+ onunload(): void;
15
+ }
@@ -0,0 +1,4 @@
1
+ export { ContactsPlugin, CONTACTS_PLUGIN_ID, default } from "./contacts-plugin";
2
+ export { CONTACTS_VIEW_TYPE, ContactsView, hostMarkdownSession, hostVaultTags, } from "./contacts-view";
3
+ export { VaultContacts, type ContactProblem } from "./vault-contacts";
4
+ export { CONTACTS_DATA_VERSION, DEFAULT_CONTACTS_SETTINGS, ContactsSettingsError, migrateContactsData, patchContactsSettings, type ContactsPluginData, type ContactsSettings, type ContactsSettingsPatch, } from "./contacts-settings";
@@ -0,0 +1,64 @@
1
+ import type { Vault } from "@lapis-notes/api";
2
+ import { MemoryContacts, folderPath, type Contact, type ContactsStore, type Direction, type Interaction, type Profile } from "../contacts/model";
3
+ import type { DropTarget } from "../contacts/contact-selection";
4
+ export type ContactProblem = {
5
+ path: string;
6
+ message: string;
7
+ };
8
+ /**
9
+ * A contacts directory backed by Markdown files in the owning App's vault.
10
+ *
11
+ * Reads are served from a cache of the configured folder, kept current by
12
+ * vault events. Each mutation runs the same validated, frontmatter-preserving
13
+ * update as the in-memory store against that cache, then writes the changed
14
+ * files with a compare-and-write against what the store last read. If a write
15
+ * is refused the cache is restored, so a failed or conflicting write leaves
16
+ * the on-disk content untouched and the caller's draft intact.
17
+ */
18
+ export declare class VaultContacts implements ContactsStore {
19
+ private readonly vault;
20
+ private readonly onProblem;
21
+ private readonly core;
22
+ /** Malformed files in the folder; the rest of the directory stays usable. */
23
+ problems: ContactProblem[];
24
+ private tail;
25
+ private readonly listeners;
26
+ private refs;
27
+ private reported;
28
+ constructor(vault: Vault, today: () => string, onProblem?: (problem: ContactProblem) => void);
29
+ private get files();
30
+ get today(): string;
31
+ get folder(): string;
32
+ get interval(): number;
33
+ source(path: string): string;
34
+ /** Reads the configured folder and starts following vault changes. */
35
+ start(): Promise<() => void>;
36
+ stop(): void;
37
+ subscribe(listener: () => void): () => undefined;
38
+ notify(): void;
39
+ /** Sets the folder and interval before the first read. */
40
+ configure(folder: string, interval: number): void;
41
+ /** Applies new settings and re-reads the folder. Files are never moved. */
42
+ apply(folder: string, interval: number): Promise<void>;
43
+ reload(): Promise<void>;
44
+ list(): Contact[];
45
+ /** Persists a missing permanent identity without disturbing other fields. */
46
+ private adoptIdentity;
47
+ private report;
48
+ private refresh;
49
+ private enqueue;
50
+ /** Writes one file, refusing when the vault changed since it was read. */
51
+ private write;
52
+ private mutate;
53
+ private reconcile;
54
+ save(profile: Profile, existing?: Contact): Promise<string>;
55
+ replaceSource(path: string, source: string, expected: string): Promise<void>;
56
+ log(contact: Contact, interaction: Interaction): Promise<void>;
57
+ open(contact: Contact, topic: string, direction: Direction, due?: string): Promise<void>;
58
+ edit(contact: Contact, id: string, changes: Parameters<MemoryContacts["edit"]>[2]): Promise<void>;
59
+ resolve(contact: Contact, id: string): Promise<void>;
60
+ reopen(contact: Contact, id: string): Promise<void>;
61
+ remove(contact: Contact, id: string): Promise<void>;
62
+ file(contacts: Contact[], target: DropTarget): Promise<number>;
63
+ }
64
+ export { folderPath };
@@ -0,0 +1,74 @@
1
+ var u = "error";
2
+ function o(e) {
3
+ return new RegExp("^((" + e.join(")|(") + "))\\b", "i");
4
+ }
5
+ var b = new RegExp("^[\\+\\-\\*/%&\\\\|\\^~<>!]"), k = new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"), x = new RegExp("^((==)|(<>)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))"), m = new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"), I = new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))"), R = new RegExp("^[_A-Za-z][_A-Za-z0-9]*"), a = ["class", "module", "sub", "enum", "select", "while", "if", "function", "get", "set", "property", "try", "structure", "synclock", "using", "with"], f = ["else", "elseif", "case", "catch", "finally"], h = ["next", "loop"], s = ["and", "andalso", "or", "orelse", "xor", "in", "not", "is", "isnot", "like"], O = o(s), v = ["#const", "#else", "#elseif", "#end", "#if", "#region", "addhandler", "addressof", "alias", "as", "byref", "byval", "cbool", "cbyte", "cchar", "cdate", "cdbl", "cdec", "cint", "clng", "cobj", "compare", "const", "continue", "csbyte", "cshort", "csng", "cstr", "cuint", "culng", "cushort", "declare", "default", "delegate", "dim", "directcast", "each", "erase", "error", "event", "exit", "explicit", "false", "for", "friend", "gettype", "goto", "handles", "implements", "imports", "infer", "inherits", "interface", "isfalse", "istrue", "lib", "me", "mod", "mustinherit", "mustoverride", "my", "mybase", "myclass", "namespace", "narrowing", "new", "nothing", "notinheritable", "notoverridable", "of", "off", "on", "operator", "option", "optional", "out", "overloads", "overridable", "overrides", "paramarray", "partial", "private", "protected", "public", "raiseevent", "readonly", "redim", "removehandler", "resume", "return", "shadows", "shared", "static", "step", "stop", "strict", "then", "throw", "to", "true", "trycast", "typeof", "until", "until", "when", "widening", "withevents", "writeonly"], p = ["object", "boolean", "char", "string", "byte", "sbyte", "short", "ushort", "int16", "uint16", "integer", "uinteger", "int32", "uint32", "long", "ulong", "int64", "uint64", "decimal", "single", "double", "float", "date", "datetime", "intptr", "uintptr"], z = o(v), E = o(p), C = '"', S = o(a), g = o(f), y = o(h), w = o(["end"]), T = o(["do"]);
6
+ function l(e, n) {
7
+ n.currentIndent++;
8
+ }
9
+ function c(e, n) {
10
+ n.currentIndent--;
11
+ }
12
+ function d(e, n) {
13
+ if (e.eatSpace())
14
+ return null;
15
+ var i = e.peek();
16
+ if (i === "'")
17
+ return e.skipToEnd(), "comment";
18
+ if (e.match(/^((&H)|(&O))?[0-9\.a-f]/i, !1)) {
19
+ var r = !1;
20
+ if ((e.match(/^\d*\.\d+F?/i) || e.match(/^\d+\.\d*F?/) || e.match(/^\.\d+F?/)) && (r = !0), r)
21
+ return e.eat(/J/i), "number";
22
+ var t = !1;
23
+ if (e.match(/^&H[0-9a-f]+/i) || e.match(/^&O[0-7]+/i) ? t = !0 : e.match(/^[1-9]\d*F?/) ? (e.eat(/J/i), t = !0) : e.match(/^0(?![\dx])/i) && (t = !0), t)
24
+ return e.eat(/L/i), "number";
25
+ }
26
+ return e.match(C) ? (n.tokenize = F(e.current()), n.tokenize(e, n)) : e.match(I) || e.match(m) ? null : e.match(x) || e.match(b) || e.match(O) ? "operator" : e.match(k) ? null : e.match(T) ? (l(e, n), n.doInCurrentLine = !0, "keyword") : e.match(S) ? (n.doInCurrentLine ? n.doInCurrentLine = !1 : l(e, n), "keyword") : e.match(g) ? "keyword" : e.match(w) ? (c(e, n), c(e, n), "keyword") : e.match(y) ? (c(e, n), "keyword") : e.match(E) || e.match(z) ? "keyword" : e.match(R) ? "variable" : (e.next(), u);
27
+ }
28
+ function F(e) {
29
+ var n = e.length == 1, i = "string";
30
+ return function(r, t) {
31
+ for (; !r.eol(); ) {
32
+ if (r.eatWhile(/[^'"]/), r.match(e))
33
+ return t.tokenize = d, i;
34
+ r.eat(/['"]/);
35
+ }
36
+ return n && (t.tokenize = d), i;
37
+ };
38
+ }
39
+ function K(e, n) {
40
+ var i = n.tokenize(e, n), r = e.current();
41
+ if (r === ".")
42
+ return i = n.tokenize(e, n), i === "variable" ? "variable" : u;
43
+ var t = "[({".indexOf(r);
44
+ return t !== -1 && l(e, n), t = "])}".indexOf(r), t !== -1 && c(e, n) ? u : i;
45
+ }
46
+ const L = {
47
+ name: "vb",
48
+ startState: function() {
49
+ return {
50
+ tokenize: d,
51
+ lastToken: null,
52
+ currentIndent: 0,
53
+ nextLineIndent: 0,
54
+ doInCurrentLine: !1
55
+ };
56
+ },
57
+ token: function(e, n) {
58
+ e.sol() && (n.currentIndent += n.nextLineIndent, n.nextLineIndent = 0, n.doInCurrentLine = 0);
59
+ var i = K(e, n);
60
+ return n.lastToken = { style: i, content: e.current() }, i;
61
+ },
62
+ indent: function(e, n, i) {
63
+ var r = n.replace(/^\s+|\s+$/g, "");
64
+ return r.match(y) || r.match(w) || r.match(g) ? i.unit * (e.currentIndent - 1) : e.currentIndent < 0 ? 0 : e.currentIndent * i.unit;
65
+ },
66
+ languageData: {
67
+ closeBrackets: { brackets: ["(", "[", "{", '"'] },
68
+ commentTokens: { line: "'" },
69
+ autocomplete: a.concat(f).concat(h).concat(s).concat(v).concat(p)
70
+ }
71
+ };
72
+ export {
73
+ L as vb
74
+ };