@mccaskie-labs/workbench-contacts 0.1.1 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mccaskie-labs/workbench-contacts
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Deleting a customer and stopping their news and offers ask "Are you sure?" first. On a customer's page (`renderContact`), Delete customer no longer has a tick box: it opens a question that names the customer ("Delete Maria Santos and their history?"), says it can't be undone and, with the new `emails: true` (pass `contacts.emails`) and an email on the record, that they'll be emailed, with "Yes, delete this customer and their history" and "No, keep them". Stop news and offers opens a question that says only the customer can turn it back on, with "Yes, stop news and offers" and "No, leave it". Both are a `<details>`, so they work with no script.
8
+ - **Breaking:** `contactAction`'s `stop_marketing`, and `forget`, refuse a post without `confirm=yes` (the question's button sends it) with the new failure `confirm_needed` (409, "Please confirm first. Nothing has changed."), and nothing is written. Before, `forget` without it answered `bad_input` (400) and `stop_marketing` needed nothing. It takes an optional fourth argument `{ t, lang }` for the refusal's words. The store methods (`setMarketing()`, `forget()`) need no flag.
9
+ - New optional `mailer` (the same shape bookings takes), `business` (the name and reply-to for emails; default the account), `t`, `lang` and `onEmailError` on `createContacts`. With a mailer, `forget()` emails the person, when the record has an email, that the business deleted their record and that their bookings, payments and quotes aren't changed (template `contacts.deleted`); a failed email is reported to `onEmailError` and never fails the delete. With no mailer nothing changes. New `contacts.emails` (true with a mailer), and the types `ContactsMailer` and `ContactsBusiness`.
10
+ - `renderConfirm`, `confirmed` and `ConfirmOptions` are exported for an app's own pages. New words `forget.question`, `.consequence`, `.consequence_emailed` and `.no`, `stop_marketing.question`, `.consequence`, `.yes` and `.no`, `error.confirm_needed`, `email.deleted.subject`, `.body`, `.kept` and `.next`, `email.hello` and `email.hello_plain`, in English, Tagalog and Taglish; `forget.confirm` is now the question's yes button. New classes `wb-contact-confirm` (now the question's `<details>`), `-confirm-open`, `-confirm-ask`, `-confirm-keep`, `-confirm-form`, `-confirm-question`, `-confirm-consequence` and `-confirm-yes`. **Breaking** for a project's own CSS: `wb-contact-confirm` was the tick box's label and is now the question; `wb-contact-check` (the tick box) is gone; `wb-contact-forget-form` is now a `<div>`; `wb-contact-stop` and `wb-contact-forget` are now on the `<summary>` that opens the question.
11
+
12
+ ## 0.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - Every tool follows the project's look (docs/theming.md step 2, Robert, 24 November 2026). Each tool's colour, font and corner variables now default to the shared theme tokens with a Clean, light fallback (`--wb-booking-accent: var(--wb-accent, #2563eb)`), and tool colours with no token of their own (a recessed panel, a status mark, a tinted pill) are worked out from the tokens with `color-mix()`. So a page drawn with these tools takes the look in the project's workbench.css: light (Clean) by default, or whatever brand.json and project.css say. Breaking for a project page that relied on the old dark defaults: give brand.json the look you want, or set the tokens in project.css. Variable and class names are unchanged, so existing project.css overrides still win. workbench-ui: `styleProblems` refuses a tool's text, muted, surface, line, background, accent, focus, danger, success, warning, font or radius variable whose default doesn't read its token (email, PDF and image follow in step 3); the `wb-ui` class no longer forces dark, and Workbench's own pages (`STYLE`, `UI_CSS`) keep their dark values; `shell` with `stylesheets` (a project page) no longer says dark in its meta tag.
17
+
3
18
  ## 0.1.1
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -25,7 +25,8 @@ import { createContacts } from '@mccaskie-labs/workbench-contacts'
25
25
  import { packFor } from '@mccaskie-labs/workbench-country'
26
26
  import { CONTACT_SETTINGS } from './contacts.generated'
27
27
 
28
- const contacts = createContacts({ db: serviceClient, settings: CONTACT_SETTINGS, phone: packFor('AU').phone })
28
+ const contacts = createContacts({ db: serviceClient, settings: CONTACT_SETTINGS, phone: packFor('AU').phone,
29
+ mailer, business: async (account) => ({ name: 'Riverside Kayaks', replyTo: 'hello@riverside.example' }) }) // both optional
29
30
 
30
31
  // Where each tool succeeds. Never let it undo the booking:
31
32
  ctx.waitUntil(contacts.record({
@@ -46,7 +47,7 @@ ctx.waitUntil(contacts.cleanup())
46
47
  - **Ids, not content.** The history is the tool's kind and the app's own row id (`booking 7f…`). Never a message, a review's words, an amount or a card.
47
48
  - **Least kept.** A detail not in `keep` is dropped before anything is written, and named in the result's `dropped`. A source not in `sources`, or a person with no email, phone or Messenger id, is skipped (`skipped: "source_off" | "no_detail"`), writing nothing.
48
49
  - **Consent.** `marketing` is `unknown` until the person says. A yes needs `wording`, the words next to the box they ticked (proof of consent). `optOut({ email })` (an unsubscribe link or a stop reply) and the owner's Stop news and offers make it `no`, which sticks: only the person's own newer yes undoes it. With `marketing: "off"` no yes is kept at all.
49
- - **Rights.** `exportPerson(account, id)` is everything kept about one person, as JSON, for their request to see it; `update()` corrects; `forget()` deletes them and their history. `cleanup()` deletes people not in touch for `retention_months`.
50
+ - **Rights.** `exportPerson(account, id)` is everything kept about one person, as JSON, for their request to see it; `update()` corrects; `forget()` deletes them and their history; with a `mailer`, the person is emailed that it's done (when the record has an email; template `contacts.deleted`, and a failed email never fails the delete). `cleanup()` deletes people not in touch for `retention_months`.
50
51
  - `search(account, { query, marketing, limit, offset })`: part of a name or email (wildcards taken literally) or three or more digits of a phone; latest seen first.
51
52
  - `exportCsv(account, { marketing })`: UTF-8 with a byte order mark for Excel, dates in the project's time zone, a column per kind of history, and formulas defused.
52
53
 
@@ -56,12 +57,12 @@ ctx.waitUntil(contacts.cleanup())
56
57
  import { contactAction, renderContact, renderContactList } from '@mccaskie-labs/workbench-contacts'
57
58
 
58
59
  html = renderContactList(await contacts.search(account, { query: q }), { endpoint: '/app/customers', query: q, contactUrl: (c) => `/app/customers/${c.id}`, exportUrl: '/app/customers.csv', timeZone: contacts.settings.time_zone })
59
- html = renderContact(await contacts.get(account, id), { endpoint: '/app/customers/action', keep: contacts.settings.keep, marketing: contacts.settings.marketing === 'ask', downloadUrl: `/app/customers/${id}.json`, timeZone: contacts.settings.time_zone })
60
+ html = renderContact(await contacts.get(account, id), { endpoint: '/app/customers/action', keep: contacts.settings.keep, marketing: contacts.settings.marketing === 'ask', downloadUrl: `/app/customers/${id}.json`, timeZone: contacts.settings.time_zone, emails: contacts.emails })
60
61
  // Its forms post here, behind the owner's sign-in:
61
- const r = await contactAction(contacts, fields, account) // save, stop_marketing, or forget (needs confirm=yes)
62
+ const r = await contactAction(contacts, fields, account) // save, stop_marketing or forget (the last two need confirm=yes)
62
63
  ```
63
64
 
64
- The owner's page offers Stop news and offers, never a yes. Delete needs its tick box. Every element carries a `wb-contact-*` class with a default style (`CONTACT_STYLES`, written by `npx workbench-ui styles`). Words are in `CONTACT_WORDS` (English, Tagalog, Taglish) under `ui.wbcontact.*`.
65
+ The owner's page offers Stop news and offers, never a yes. Stop news and offers and Delete customer ask "Are you sure?" first: the first button only opens a question that names the customer, and its button posts `confirm=yes`. `contactAction` refuses `stop_marketing` and `forget` without it (`confirm_needed`, 409), so a page that draws its own one-click button can't skip the question. Every element carries a `wb-contact-*` class with a default style (`CONTACT_STYLES`, written by `npx workbench-ui styles`). Words are in `CONTACT_WORDS` (English, Tagalog, Taglish) under `ui.wbcontact.*`.
65
66
 
66
67
  ## Data
67
68
 
@@ -0,0 +1,60 @@
1
+ export interface ConfirmOptions {
2
+ /** The tool's class prefix, without the trailing dash: "wb-booking". */
3
+ prefix: string;
4
+ /** Where the form posts. */
5
+ endpoint: string;
6
+ /** The hidden fields that say what to do: action, the thing's id or token. */
7
+ fields: Readonly<Record<string, string>>;
8
+ /** The first button's words: "Cancel". */
9
+ ask: string;
10
+ /** The first button's class, so it keeps the look it has in the tool's styles. */
11
+ askClass: string;
12
+ /** The question, naming the thing: "Cancel Sam's booking for Yoga on Monday 7 December at 6:00 pm?" */
13
+ question: string;
14
+ /** What happens next and who is told: "We'll email Sam to say it's cancelled." */
15
+ consequence?: string;
16
+ /** The button that does it, in its own words: "Yes, cancel this booking". */
17
+ yes: string;
18
+ /** The words that close the question again: "No, keep it". */
19
+ no: string;
20
+ /** A reason to send with it, when the action takes one. */
21
+ reason?: {
22
+ label: string;
23
+ name?: string;
24
+ maxlength?: number;
25
+ required?: boolean;
26
+ };
27
+ /** For deleting a lot at once: a word the person must type before the button works. */
28
+ type?: {
29
+ label: string;
30
+ word: string;
31
+ };
32
+ /** More fields for the question's form, as HTML the tool has already escaped (a second box, a choice). Drawn above the button. */
33
+ extra?: string;
34
+ /** Draw the question already showing: the page was drawn again to ask it. */
35
+ open?: boolean;
36
+ }
37
+ /** The button and its question. */
38
+ export declare function renderConfirm(o: ConfirmOptions): string;
39
+ /** Whether a post answered the question: confirm=yes and, where a word had to be typed, that word. */
40
+ export declare function confirmed(body: Readonly<Record<string, unknown>>, word?: string): boolean;
41
+ interface ConfirmStyle {
42
+ name: string;
43
+ element: string;
44
+ about: string;
45
+ css: string;
46
+ states?: readonly {
47
+ selector: string;
48
+ about: string;
49
+ css: string;
50
+ }[];
51
+ }
52
+ /**
53
+ * The question's classes with their default rules, for the tool's styles.
54
+ * `v` reads one of the tool's own variables (text, muted, line, sunk, surface,
55
+ * radius, danger, on-danger, focus).
56
+ */
57
+ export declare function confirmStyles(prefix: string, v: (name: string) => string, o?: {
58
+ reason?: boolean;
59
+ }): ConfirmStyle[];
60
+ export {};
@@ -0,0 +1,85 @@
1
+ // "Are you sure?" for the actions that cancel, decline or delete
2
+ // (docs/critical-actions-audit.md, "The standard"). The button a person presses first only opens
3
+ // the question: what is about to happen, named in full, and who will be told.
4
+ // The second button does it. It is a <details>, so it works with no script,
5
+ // and the post carries confirm=yes, which the action helpers insist on: a page
6
+ // that draws its own one-click button is refused with `confirm_needed`.
7
+ //
8
+ // This file is the same in every tool that asks (only the prefix differs), so
9
+ // a project restyles each tool's question by that tool's own class names.
10
+ const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
11
+ const pattern = (word) => word.replace(/[.*+?^${}()|[\]\\\/-]/g, "\\$&");
12
+ /** The button and its question. */
13
+ export function renderConfirm(o) {
14
+ const p = o.prefix;
15
+ const hidden = Object.entries({ ...o.fields, confirm: "yes" })
16
+ .map(([k, v]) => `<input type="hidden" name="${esc(k)}" value="${esc(v)}">`)
17
+ .join("");
18
+ const reason = o.reason
19
+ ? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.reason.label)}</span><input class="${p}-confirm-input" type="text" name="${esc(o.reason.name ?? "reason")}" maxlength="${o.reason.maxlength ?? 200}"${o.reason.required ? " required" : ""}></label>`
20
+ : "";
21
+ const type = o.type
22
+ ? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.type.label)}</span><input class="${p}-confirm-input" type="text" name="confirm_word" required pattern="${esc(pattern(o.type.word))}" autocomplete="off" autocapitalize="off" spellcheck="false"></label>`
23
+ : "";
24
+ return `<details class="${p}-confirm"${o.open ? " open" : ""}><summary class="${p}-confirm-open ${esc(o.askClass)}"><span class="${p}-confirm-ask">${esc(o.ask)}</span><span class="${p}-confirm-keep">${esc(o.no)}</span></summary><form class="${p}-confirm-form" method="post" action="${esc(o.endpoint)}">${hidden}<p class="${p}-confirm-question">${esc(o.question)}</p>${o.consequence ? `<p class="${p}-confirm-consequence">${esc(o.consequence)}</p>` : ""}${reason}${o.extra ?? ""}${type}<button class="${p}-confirm-yes" type="submit">${esc(o.yes)}</button></form></details>`;
25
+ }
26
+ /** Whether a post answered the question: confirm=yes and, where a word had to be typed, that word. */
27
+ export function confirmed(body, word) {
28
+ if (body.confirm !== "yes" && body.confirm !== true)
29
+ return false;
30
+ return word === undefined || (typeof body.confirm_word === "string" && body.confirm_word.trim() === word);
31
+ }
32
+ /**
33
+ * The question's classes with their default rules, for the tool's styles.
34
+ * `v` reads one of the tool's own variables (text, muted, line, sunk, surface,
35
+ * radius, danger, on-danger, focus).
36
+ */
37
+ export function confirmStyles(prefix, v, o = {}) {
38
+ const focus = { selector: ":focus-visible", about: "Has focus", css: `outline:none;box-shadow:0 0 0 3px ${v("focus")}` };
39
+ return [
40
+ {
41
+ name: `${prefix}-confirm`,
42
+ element: "details",
43
+ about: "A button that asks \"Are you sure?\" before it cancels, declines or deletes",
44
+ css: "display:block",
45
+ states: [
46
+ { selector: `[open]`, about: "The question is showing", css: `display:flex;flex-direction:column;align-items:flex-start;gap:.75rem;box-sizing:border-box;width:100%;padding:1rem;background:${v("sunk")};border:1px solid ${v("line")};border-radius:${v("radius")}` },
47
+ { selector: `[open] > summary`, about: "\"No, keep it\" sits under the button that does it", css: "order:2" },
48
+ { selector: `[open] .${prefix}-confirm-ask`, about: "The first button's words, hidden while the question shows", css: "display:none" },
49
+ { selector: `[open] .${prefix}-confirm-keep`, about: "\"No, keep it\", shown while the question shows", css: "display:inline" },
50
+ ],
51
+ },
52
+ {
53
+ name: `${prefix}-confirm-open`,
54
+ element: "summary",
55
+ about: "The first button: it only opens the question",
56
+ css: "list-style:none",
57
+ states: [{ selector: "::-webkit-details-marker", about: "No arrow beside the button", css: "display:none" }],
58
+ },
59
+ { name: `${prefix}-confirm-ask`, element: "span", about: "The first button's words", css: "display:inline" },
60
+ { name: `${prefix}-confirm-keep`, element: "span", about: "\"No, keep it\": closes the question", css: `display:none;color:${v("text")}` },
61
+ { name: `${prefix}-confirm-form`, element: "form", about: "The question and the button that does it", css: "display:grid;gap:.75rem;justify-items:start;width:100%" },
62
+ { name: `${prefix}-confirm-question`, element: "p", about: "What is about to happen, naming the thing", css: `margin:0;font-weight:600;color:${v("text")}` },
63
+ { name: `${prefix}-confirm-consequence`, element: "p", about: "What happens next and who is told", css: `margin:0;color:${v("muted")}` },
64
+ ...(o.reason
65
+ ? [
66
+ { name: `${prefix}-confirm-field`, element: "label", about: "The reason, or the word to type", css: "display:grid;gap:.25rem;width:100%" },
67
+ { name: `${prefix}-confirm-label`, element: "span", about: "What to type there", css: `color:${v("muted")}` },
68
+ {
69
+ name: `${prefix}-confirm-input`,
70
+ element: "input",
71
+ about: "Where it is typed",
72
+ css: `box-sizing:border-box;width:100%;min-height:2.75rem;padding:.5rem .75rem;font:inherit;color:${v("text")};background:${v("surface")};border:1px solid ${v("line")};border-radius:${v("radius")}`,
73
+ states: [focus],
74
+ },
75
+ ]
76
+ : []),
77
+ {
78
+ name: `${prefix}-confirm-yes`,
79
+ element: "button",
80
+ about: "The button that does it",
81
+ css: `display:inline-flex;align-items:center;justify-content:center;min-height:2.75rem;padding:0 1rem;font:inherit;font-weight:600;border-radius:${v("radius")};cursor:pointer;color:${v("on-danger")};background:${v("danger")};border:1px solid ${v("danger")}`,
82
+ states: [focus],
83
+ },
84
+ ];
85
+ }
@@ -12,9 +12,42 @@ export interface ContactsClient {
12
12
  error: DbError;
13
13
  }>;
14
14
  }
15
+ /** The part of workbench-email's createMailer(...) contacts use (the same shape bookings takes). */
16
+ export interface ContactsMailer {
17
+ send(mail: {
18
+ to: string | string[];
19
+ subject: string;
20
+ text: string;
21
+ template: string;
22
+ replyTo?: string;
23
+ attachments?: {
24
+ filename: string;
25
+ mimeType: string;
26
+ bytes: Uint8Array;
27
+ }[];
28
+ idempotencyKey?: string;
29
+ }): Promise<unknown>;
30
+ }
31
+ /** What the emails say about the business. */
32
+ export interface ContactsBusiness {
33
+ /** "Riverside Kayaks". */
34
+ name: string;
35
+ /** Replies to the person's email go here. */
36
+ replyTo?: string;
37
+ }
15
38
  export interface ContactsOptions {
16
39
  /** The service client. */
17
40
  db: ContactsClient;
41
+ /** createMailer(...). With it, forget() emails the person (when the record has an email) to say their record was deleted. Without it no email goes, as before. */
42
+ mailer?: ContactsMailer;
43
+ /** The business's name for emails. Default: the account. */
44
+ business?: (account: string) => Promise<ContactsBusiness>;
45
+ /** The project's strings lookup for the emails (`ui.wbcontact.email.*`). */
46
+ t?: (key: string, params?: Readonly<Record<string, string | number>>) => string | undefined;
47
+ /** The emails' language when `t` has none. Default en. */
48
+ lang?: Lang;
49
+ /** Told when an email didn't go. Default: console.error, without the address. */
50
+ onEmailError?: (error: unknown, what: string) => void;
18
51
  /** workbench/contacts.json, or CONTACT_SETTINGS from src/contacts.generated.ts. Checked here. */
19
52
  settings: unknown;
20
53
  /** The country pack's phone shape (workbench-country's pack.phone), so "0412 345 678" or "0917 123 4567" is read. Without it only numbers with their country code are kept. */
@@ -103,7 +136,7 @@ export interface Contacts {
103
136
  }): Promise<Contact>;
104
137
  /** An unsubscribe link or a stop reply: whoever in the account has this email, phone or Messenger id says no. How many changed. */
105
138
  optOut(account: string, who: PersonDetails): Promise<number>;
106
- /** Deletes the person and what pointed at them. True when there was one. */
139
+ /** Deletes the person and what pointed at them. True when there was one. With a mailer, the person is emailed that it's done (when the record has an email); a failed email never fails the delete. */
107
140
  forget(account: string, id: string): Promise<boolean>;
108
141
  /** The account's list as a CSV for Excel or Google Sheets (UTF-8, formulas defused). */
109
142
  exportCsv(account: string, opts?: ExportOptions): Promise<string>;
@@ -114,6 +147,8 @@ export interface Contacts {
114
147
  contacts: number;
115
148
  }>;
116
149
  readonly settings: ContactSettings;
150
+ /** True when createContacts has a mailer, so a page can say the person will be emailed. */
151
+ readonly emails: boolean;
117
152
  }
118
153
  /** What exportPerson() hands over: the details, the consent, and what pointed at them. */
119
154
  export interface PersonExport {
package/dist/contacts.js CHANGED
@@ -15,6 +15,12 @@ import { toCsv } from "./csv.js";
15
15
  import { ContactsError } from "./errors.js";
16
16
  import { tidyEmail, tidyMessenger, tidyName, tidyPhone } from "./tidy.js";
17
17
  import { SOURCE_KINDS } from "./types.js";
18
+ import { CONTACT_WORDS } from "./words.js";
19
+ function fill(text, params) {
20
+ return text.replace(/\{(\w+)\}/g, (m, k) => (Object.hasOwn(params, k) ? String(params[k]) : m));
21
+ }
22
+ const hex = (b) => [...new Uint8Array(b)].map((x) => x.toString(16).padStart(2, "0")).join("");
23
+ const mailKey = async (key, email) => `contacts:${hex(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${key}\n${email.trim().toLowerCase()}`)))}`;
18
24
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
19
25
  const DAY = 86_400_000;
20
26
  async function call(db, what, fn, args) {
@@ -241,8 +247,36 @@ export function createContacts(opts) {
241
247
  const at = now().toISOString();
242
248
  return call(db, "opt out", "contacts_opt_out", { p_account: text(account, "account", 200), p_email: email, p_phone: phone, p_messenger: messenger, p_source: "unsubscribe", p_at: at, p_now: at });
243
249
  }
250
+ const say = (key, p = {}) => opts.t?.(`ui.wbcontact.${key}`, p) ?? fill((CONTACT_WORDS[opts.lang ?? "en"] ?? CONTACT_WORDS.en)[key], p);
251
+ const report = opts.onEmailError ?? ((_e, what) => console.error(`workbench-contacts: the ${what} email didn't go`));
252
+ /** The person is told their record is gone. Reported, never thrown: the delete stands. */
253
+ async function mailDeleted(account, c) {
254
+ try {
255
+ const biz = opts.business ? await opts.business(account) : { name: account };
256
+ const p = { business: biz.name };
257
+ const body = [c.name ? say("email.hello", { name: c.name }) : say("email.hello_plain"), "", say("email.deleted.body", p), "", say("email.deleted.kept", p), "", say("email.deleted.next", p)].join("\n");
258
+ await opts.mailer.send({
259
+ to: c.email,
260
+ subject: say("email.deleted.subject", p),
261
+ text: body,
262
+ template: "contacts.deleted",
263
+ ...(biz.replyTo ? { replyTo: biz.replyTo } : {}),
264
+ idempotencyKey: await mailKey(`deleted:${c.id}`, c.email),
265
+ });
266
+ }
267
+ catch (e) {
268
+ report(e, "deleted");
269
+ }
270
+ }
244
271
  async function forget(account, id) {
245
- return call(db, "forget", "contacts_forget", { p_account: text(account, "account", 200), p_id: contactId(id) });
272
+ const acc = text(account, "account", 200);
273
+ const cid = contactId(id);
274
+ // With a mailer, read the person first: their email goes with the record.
275
+ const c = opts.mailer ? await get(acc, cid) : null;
276
+ const gone = await call(db, "forget", "contacts_forget", { p_account: acc, p_id: cid });
277
+ if (gone && c?.email)
278
+ await mailDeleted(acc, c);
279
+ return gone;
246
280
  }
247
281
  async function exportCsv(account, o = {}) {
248
282
  if (o.marketing && settings.marketing === "off")
@@ -265,5 +299,5 @@ export function createContacts(opts) {
265
299
  const n = await call(db, "cleanup", "contacts_cleanup", { p_now: now().toISOString(), p_months: settings.retention_months ?? 24 });
266
300
  return { contacts: n };
267
301
  }
268
- return { record, recordForm, get, search, update, setMarketing, optOut, forget, exportCsv, exportPerson, cleanup, settings };
302
+ return { record, recordForm, get, search, update, setMarketing, optOut, forget, exportCsv, exportPerson, cleanup, settings, emails: opts.mailer !== undefined };
269
303
  }
package/dist/errors.d.ts CHANGED
@@ -7,6 +7,8 @@ export type ContactsErrorCode =
7
7
  | "unknown_contact"
8
8
  /** The email, phone or Messenger id belongs to another contact in this account. Nothing was changed. */
9
9
  | "taken"
10
+ /** A delete or a stop of news and offers arrived without the answer to "Are you sure?" (confirm=yes). Nothing was changed. */
11
+ | "confirm_needed"
10
12
  /** The database refused or failed. */
11
13
  | "store_failed";
12
14
  export declare class ContactsError extends Error {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- export { createContacts, likePattern, type ConsentGiven, type ContactChanges, type Contacts, type ContactsClient, type ContactsOptions, type ExportOptions, type FormFieldInfo, type FormRecordRequest, type PersonExport, type RecordRequest, type RecordResult, type SearchOptions } from "./contacts.ts";
1
+ export { createContacts, likePattern, type ConsentGiven, type ContactChanges, type Contacts, type ContactsBusiness, type ContactsClient, type ContactsMailer, type ContactsOptions, type ExportOptions, type FormFieldInfo, type FormRecordRequest, type PersonExport, type RecordRequest, type RecordResult, type SearchOptions } from "./contacts.ts";
2
2
  export { checkContactSettings, contactProblems } from "./config.ts";
3
3
  export { contactsMigration } from "./migration.ts";
4
4
  export { STARTER_CONTACTS } from "./starters.ts";
5
5
  export { contactAction, contactLabel, renderContact, renderContactList, type ActionResult, type ContactPageOptions, type ListOptions, type Words } from "./ui.ts";
6
+ export { confirmed, renderConfirm, type ConfirmOptions } from "./confirm.ts";
6
7
  export { CONTACT_WORDS, CONTACT_WORD_KEYS, type ContactWordKey } from "./words.ts";
7
8
  export { CONTACT_STYLES } from "./styles.ts";
8
9
  export { ContactsError, type ContactsErrorCode } from "./errors.ts";
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export { checkContactSettings, contactProblems } from "./config.js";
8
8
  export { contactsMigration } from "./migration.js";
9
9
  export { STARTER_CONTACTS } from "./starters.js";
10
10
  export { contactAction, contactLabel, renderContact, renderContactList } from "./ui.js";
11
+ export { confirmed, renderConfirm } from "./confirm.js";
11
12
  export { CONTACT_WORDS, CONTACT_WORD_KEYS } from "./words.js";
12
13
  export { CONTACT_STYLES } from "./styles.js";
13
14
  export { ContactsError } from "./errors.js";
package/dist/styles.js CHANGED
@@ -5,6 +5,7 @@
5
5
  // restyles them from its own CSS by the same names. `npx workbench-ui styles`
6
6
  // writes these into the project's public/styles/workbench.css inside
7
7
  // `@layer workbench`. The names are public: renaming one is a breaking change.
8
+ import { confirmStyles } from "./confirm.js";
8
9
  const v = (name) => `var(--wb-contact-${name})`;
9
10
  const focus = { selector: ":focus-visible", about: "Has focus", css: `outline:none;box-shadow:0 0 0 3px ${v("focus")}` };
10
11
  const button = `display:inline-flex;align-items:center;justify-content:center;min-height:2.75rem;padding:0 1rem;font:inherit;font-weight:600;border-radius:${v("radius")};cursor:pointer;text-decoration:none`;
@@ -17,17 +18,17 @@ export const CONTACT_STYLES = {
17
18
  title: "Customer records",
18
19
  prefix: "wb-contact-",
19
20
  variables: [
20
- { name: "--wb-contact-text", value: "#e8e8ec", about: "Text: names, details, labels" },
21
- { name: "--wb-contact-muted", value: "#9a9aa6", about: "Quieter text: when last in touch, hints, the empty list" },
22
- { name: "--wb-contact-surface", value: "#1b1b1f", about: "Background of each customer and of the page's panels" },
23
- { name: "--wb-contact-sunk", value: "#141417", about: "Background of the list and of inputs" },
24
- { name: "--wb-contact-line", value: "#33333b", about: "Borders" },
25
- { name: "--wb-contact-accent", value: "#4c8dff", about: "Main buttons and links: Find, Save" },
26
- { name: "--wb-contact-on-accent", value: "#ffffff", about: "Text on a main button" },
27
- { name: "--wb-contact-yes", value: "#3fb27f", about: "The said-yes-to-news badge" },
28
- { name: "--wb-contact-danger", value: "#e5484d", about: "Delete customer" },
29
- { name: "--wb-contact-focus", value: "rgba(76,141,255,.4)", about: "The ring round a control with focus" },
30
- { name: "--wb-contact-radius", value: "8px", about: "Corner rounding" },
21
+ { name: "--wb-contact-text", value: "var(--wb-text, #1f2937)", about: "Text: names, details, labels" },
22
+ { name: "--wb-contact-muted", value: "var(--wb-muted, #5b6472)", about: "Quieter text: when last in touch, hints, the empty list" },
23
+ { name: "--wb-contact-surface", value: "var(--wb-surface, #f7f8f8)", about: "Background of each customer and of the page's panels" },
24
+ { name: "--wb-contact-sunk", value: "color-mix(in srgb, var(--wb-background, #ffffff), var(--wb-text, #1f2937) 3%)", about: "Background of the list and of inputs" },
25
+ { name: "--wb-contact-line", value: "var(--wb-line, #d7d8db)", about: "Borders" },
26
+ { name: "--wb-contact-accent", value: "var(--wb-accent, #2563eb)", about: "Main buttons and links: Find, Save" },
27
+ { name: "--wb-contact-on-accent", value: "var(--wb-on-accent, #ffffff)", about: "Text on a main button" },
28
+ { name: "--wb-contact-yes", value: "var(--wb-success, #15803d)", about: "The said-yes-to-news badge" },
29
+ { name: "--wb-contact-danger", value: "var(--wb-danger, #b42318)", about: "Delete customer" },
30
+ { name: "--wb-contact-focus", value: "var(--wb-focus, rgba(37,99,235,0.4))", about: "The ring round a control with focus" },
31
+ { name: "--wb-contact-radius", value: "var(--wb-radius, 8px)", about: "Corner rounding" },
31
32
  ],
32
33
  classes: [
33
34
  { name: "wb-contact-list", element: "section", about: "The whole customer list", css: `display:grid;gap:.75rem;color:${v("text")};background:${v("sunk")};padding:.75rem;border-radius:${v("radius")}` },
@@ -61,13 +62,13 @@ export const CONTACT_STYLES = {
61
62
  { name: "wb-contact-fact", element: "div", about: "One fact: its term and value", css: "display:grid;gap:.1rem" },
62
63
  { name: "wb-contact-term", element: "dt", about: "What the fact is", css: `color:${v("muted")};font-size:.85rem` },
63
64
  { name: "wb-contact-value", element: "dd", about: "The fact", css: "margin:0;overflow-wrap:anywhere" },
64
- { name: "wb-contact-form", element: "form", about: "The details to correct, and Stop news and offers", css: `display:grid;gap:.75rem;padding:.75rem;background:${v("surface")};border:1px solid ${v("line")};border-radius:${v("radius")}` },
65
+ { name: "wb-contact-form", element: "form", about: "The details to correct", css: `display:grid;gap:.75rem;padding:.75rem;background:${v("surface")};border:1px solid ${v("line")};border-radius:${v("radius")}` },
65
66
  { name: "wb-contact-field", element: "div", about: "One detail: its label and input", css: "display:grid;gap:.25rem" },
66
67
  { name: "wb-contact-label", element: "label", about: "A detail's name", css: "font-size:.9rem;font-weight:600" },
67
68
  { name: "wb-contact-input", element: "input", about: "A detail to correct", css: input, states: [focus] },
68
69
  { name: "wb-contact-note", element: "textarea", about: "The owner's own note", css: `${input};min-height:5rem;resize:vertical;line-height:1.45`, states: [focus] },
69
70
  { name: "wb-contact-save", element: "button", about: "Save", css: `${button};justify-self:start;color:${v("on-accent")};background:${v("accent")};border:1px solid ${v("accent")}`, states: [focus] },
70
- { name: "wb-contact-stop", element: "button", about: "Stop news and offers", css: `${button};justify-self:start;color:${v("text")};background:transparent;border:1px solid ${v("line")}`, states: [focus] },
71
+ { name: "wb-contact-stop", element: "summary", about: "Stop news and offers: opens \"Are you sure?\"", css: `${button};justify-self:start;color:${v("text")};background:transparent;border:1px solid ${v("line")}`, states: [focus] },
71
72
  { name: "wb-contact-download", element: "a", about: "Download their details (for their request to see what is kept)", css: `${button};justify-self:start;color:${v("text")};background:transparent;border:1px solid ${v("line")}`, states: [focus] },
72
73
  { name: "wb-contact-history", element: "section", about: "What pointed at them: forms, bookings, payments", css: "display:grid;gap:.5rem" },
73
74
  { name: "wb-contact-heading", element: "h3", about: "\"History\"", css: "margin:0;font-size:1rem;font-weight:600" },
@@ -75,10 +76,9 @@ export const CONTACT_STYLES = {
75
76
  { name: "wb-contact-event", element: "li", about: "One booking, payment or form, with when", css: `display:flex;flex-wrap:wrap;gap:.5rem;justify-content:space-between;padding:.4rem 0;border-bottom:1px solid ${v("line")}` },
76
77
  { name: "wb-contact-kind", element: "span", about: "Booking, Payment, Form", css: "font-weight:600" },
77
78
  { name: "wb-contact-when", element: "time", about: "When it happened", css: `color:${v("muted")};font-size:.9rem` },
78
- { name: "wb-contact-forget-form", element: "form", about: "Delete customer, with its tick box", css: `display:grid;gap:.5rem;padding:.75rem;border:1px solid ${v("danger")};border-radius:${v("radius")}` },
79
+ { name: "wb-contact-forget-form", element: "div", about: "Delete customer, with when to do it", css: `display:grid;gap:.5rem;padding:.75rem;border:1px solid ${v("danger")};border-radius:${v("radius")}` },
79
80
  { name: "wb-contact-hint", element: "p", about: "When to delete a customer", css: `margin:0;color:${v("muted")};font-size:.9rem` },
80
- { name: "wb-contact-confirm", element: "label", about: "Yes, delete this customer", css: "display:flex;gap:.5rem;align-items:center;min-height:2.75rem" },
81
- { name: "wb-contact-check", element: "input", about: "The tick box Delete needs", css: `width:1.25rem;height:1.25rem;accent-color:${v("danger")}`, states: [focus] },
82
- { name: "wb-contact-forget", element: "button", about: "Delete customer", css: `${button};justify-self:start;color:${v("on-accent")};background:${v("danger")};border:1px solid ${v("danger")}`, states: [focus] },
81
+ { name: "wb-contact-forget", element: "summary", about: "Delete customer: opens \"Are you sure?\"", css: `${button};justify-self:start;color:${v("on-accent")};background:${v("danger")};border:1px solid ${v("danger")}`, states: [focus] },
82
+ ...confirmStyles("wb-contact", (n) => v({ "on-danger": "on-accent" }[n] ?? n)),
83
83
  ],
84
84
  };
package/dist/ui.d.ts CHANGED
@@ -37,6 +37,8 @@ export interface ContactPageOptions extends Common {
37
37
  marketing?: boolean;
38
38
  /** What just happened, from contactAction's answer: shows "Saved." on the page. */
39
39
  done?: "save" | "stop_marketing";
40
+ /** contacts.emails: true when the package emails the person after a delete, so the question says so only when it's true. */
41
+ emails?: boolean;
40
42
  }
41
43
  /** What a customer is called: their name, else their email, phone or Messenger id. */
42
44
  export declare function contactLabel(c: Contact): string;
@@ -62,8 +64,14 @@ export interface ActionResult {
62
64
  /**
63
65
  * The project's endpoint (behind the owner's sign-in) hands the posted form
64
66
  * fields here with the signed-in owner's account: `save` (the owner's
65
- * corrections), `stop_marketing`, or `forget` (needs confirm=yes). A contact
66
- * of another account is answered as unknown.
67
+ * corrections), `stop_marketing` or `forget`. The last two can't be undone by
68
+ * the owner, so they need confirm=yes (the question's button sends it) and
69
+ * are refused with `confirm_needed` (409) without it, with nothing changed.
70
+ * A contact of another account is answered as unknown. `o` gives the
71
+ * refusal's words in the page's language.
67
72
  */
68
- export declare function contactAction(contacts: Contacts, body: Record<string, unknown>, account: string): Promise<ActionResult>;
73
+ export declare function contactAction(contacts: Contacts, body: Record<string, unknown>, account: string, o?: {
74
+ t?: Words;
75
+ lang?: Lang;
76
+ }): Promise<ActionResult>;
69
77
  export {};
package/dist/ui.js CHANGED
@@ -6,7 +6,10 @@
6
6
  // at least 44 px tall.
7
7
  //
8
8
  // The owner's page offers Stop news and offers, never a yes: only the person
9
- // says yes, by ticking a box on the app's own form. Delete needs its tick box.
9
+ // says yes, by ticking a box on the app's own form. Stop news and offers and
10
+ // Delete customer ask "Are you sure?" first (renderConfirm), and contactAction
11
+ // refuses both without confirm=yes.
12
+ import { confirmed, renderConfirm } from "./confirm.js";
10
13
  import { ContactsError } from "./errors.js";
11
14
  import { CONTACT_WORDS } from "./words.js";
12
15
  const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
@@ -66,28 +69,56 @@ export function renderContact(c, o) {
66
69
  ? `<div class="wb-contact-field"><label class="wb-contact-label" for="wb-contact-note">${esc(w("field.note"))}</label><textarea class="wb-contact-note" id="wb-contact-note" name="note" maxlength="1000" rows="3">${esc(c.note ?? "")}</textarea></div>`
67
70
  : "";
68
71
  const edit = `<form class="wb-contact-form" method="post" action="${esc(o.endpoint)}">${hidden("save")}${field("name", "text", "off")}${field("email", "email", "off")}${field("phone", "tel", "off")}${field("messenger", "text", "off")}${note}<button class="wb-contact-save" type="submit">${esc(w("save"))}</button></form>`;
72
+ const who = contactLabel(c);
73
+ // Stop news and offers asks first: the owner can never turn it back on, only the person can.
69
74
  const stop = o.marketing && c.marketing !== "no"
70
- ? `<form class="wb-contact-form" method="post" action="${esc(o.endpoint)}">${hidden("stop_marketing")}<button class="wb-contact-stop" type="submit">${esc(w("stop_marketing"))}</button></form>`
75
+ ? renderConfirm({
76
+ prefix: "wb-contact",
77
+ endpoint: o.endpoint,
78
+ fields: { contact: c.id, action: "stop_marketing" },
79
+ ask: w("stop_marketing"),
80
+ askClass: "wb-contact-stop",
81
+ question: w("stop_marketing.question", { name: who }),
82
+ consequence: w("stop_marketing.consequence"),
83
+ yes: w("stop_marketing.yes"),
84
+ no: w("stop_marketing.no"),
85
+ })
71
86
  : "";
72
87
  const download = o.downloadUrl ? `<a class="wb-contact-download" href="${esc(o.downloadUrl)}" download>${esc(w("download"))}</a>` : "";
73
88
  const events = c.events.length
74
89
  ? `<ul class="wb-contact-events">${c.events.map((e) => `<li class="wb-contact-event"><span class="wb-contact-kind">${esc(w(`kind.${e.kind}`))}</span><time class="wb-contact-when" datetime="${esc(e.at)}">${esc(dateText(e.at, o))}</time></li>`).join("")}</ul>`
75
90
  : `<p class="wb-contact-empty">${esc(w("history.empty"))}</p>`;
76
- const forget = `<form class="wb-contact-forget-form" method="post" action="${esc(o.endpoint)}">${hidden("forget")}<p class="wb-contact-hint">${esc(w("forget.note"))}</p><label class="wb-contact-confirm"><input class="wb-contact-check" type="checkbox" name="confirm" value="yes" required> ${esc(w("forget.confirm"))}</label><button class="wb-contact-forget" type="submit">${esc(w("forget.button"))}</button></form>`;
91
+ // Delete asks first, naming the customer, and says they're emailed only when the package really emails them.
92
+ const forget = `<div class="wb-contact-forget-form"><p class="wb-contact-hint">${esc(w("forget.note"))}</p>${renderConfirm({
93
+ prefix: "wb-contact",
94
+ endpoint: o.endpoint,
95
+ fields: { contact: c.id, action: "forget" },
96
+ ask: w("forget.button"),
97
+ askClass: "wb-contact-forget",
98
+ question: w("forget.question", { name: who }),
99
+ consequence: o.emails === true && c.email ? w("forget.consequence_emailed", { email: c.email }) : w("forget.consequence"),
100
+ yes: w("forget.confirm"),
101
+ no: w("forget.no"),
102
+ })}</div>`;
77
103
  const done = o.done ? `<p class="wb-contact-done" role="status">${esc(w(`done.${o.done}`))}</p>` : "";
78
104
  return `<article class="wb-contact" id="wb-contact-${esc(c.id)}"><h2 class="wb-contact-title">${esc(contactLabel(c))}</h2>${done}<dl class="wb-contact-facts">${facts}</dl>${edit}${stop}${download}<section class="wb-contact-history"><h3 class="wb-contact-heading">${esc(w("history.title"))}</h3>${events}</section>${forget}</article>`;
79
105
  }
80
106
  /**
81
107
  * The project's endpoint (behind the owner's sign-in) hands the posted form
82
108
  * fields here with the signed-in owner's account: `save` (the owner's
83
- * corrections), `stop_marketing`, or `forget` (needs confirm=yes). A contact
84
- * of another account is answered as unknown.
109
+ * corrections), `stop_marketing` or `forget`. The last two can't be undone by
110
+ * the owner, so they need confirm=yes (the question's button sends it) and
111
+ * are refused with `confirm_needed` (409) without it, with nothing changed.
112
+ * A contact of another account is answered as unknown. `o` gives the
113
+ * refusal's words in the page's language.
85
114
  */
86
- export async function contactAction(contacts, body, account) {
115
+ export async function contactAction(contacts, body, account, o = {}) {
87
116
  try {
88
117
  const action = String(body.action ?? "");
89
118
  if (action !== "save" && action !== "stop_marketing" && action !== "forget")
90
119
  throw new ContactsError("bad_input", "action must be save, stop_marketing or forget");
120
+ if (action !== "save" && !confirmed(body))
121
+ throw new ContactsError("confirm_needed", words(o)("error.confirm_needed"));
91
122
  const id = String(body.contact ?? "");
92
123
  if (action === "save") {
93
124
  const changes = {};
@@ -103,8 +134,6 @@ export async function contactAction(contacts, body, account) {
103
134
  await contacts.setMarketing(account, id, { marketing: "no", source: "owner" });
104
135
  }
105
136
  else {
106
- if (body.confirm !== "yes")
107
- throw new ContactsError("bad_input", "tick the box to delete this customer");
108
137
  if (!(await contacts.forget(account, id)))
109
138
  throw new ContactsError("unknown_contact", "no such contact");
110
139
  }
@@ -112,7 +141,7 @@ export async function contactAction(contacts, body, account) {
112
141
  }
113
142
  catch (e) {
114
143
  if (e instanceof ContactsError) {
115
- const status = e.code === "unknown_contact" ? 404 : e.code === "taken" ? 409 : e.code === "store_failed" ? 502 : e.code === "bad_config" ? 500 : 400;
144
+ const status = e.code === "unknown_contact" ? 404 : e.code === "taken" || e.code === "confirm_needed" ? 409 : e.code === "store_failed" ? 502 : e.code === "bad_config" ? 500 : 400;
116
145
  const message = e.code === "store_failed" || e.code === "bad_config" ? "contacts: it failed on the app's side (the detail is in the result's cause, for the log)" : e.message;
117
146
  return { status, body: { ok: false, error: e.code, message }, cause: e };
118
147
  }
package/dist/words.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const CONTACT_WORD_KEYS: readonly ["list.title", "list.empty", "list.none_found", "list.more", "search.label", "search.button", "export.all", "export.marketing", "marketing.yes", "marketing.no", "marketing.unknown", "seen", "field.name", "field.email", "field.phone", "field.messenger", "field.note", "field.marketing", "field.first_seen", "field.last_seen", "history.title", "history.empty", "kind.form", "kind.booking", "kind.payment", "kind.quote", "kind.review", "kind.message", "kind.manual", "save", "stop_marketing", "download", "forget.confirm", "forget.button", "forget.note", "done.save", "done.stop_marketing", "done.forget"];
1
+ export declare const CONTACT_WORD_KEYS: readonly ["list.title", "list.empty", "list.none_found", "list.more", "search.label", "search.button", "export.all", "export.marketing", "marketing.yes", "marketing.no", "marketing.unknown", "seen", "field.name", "field.email", "field.phone", "field.messenger", "field.note", "field.marketing", "field.first_seen", "field.last_seen", "history.title", "history.empty", "kind.form", "kind.booking", "kind.payment", "kind.quote", "kind.review", "kind.message", "kind.manual", "save", "stop_marketing", "download", "forget.confirm", "forget.button", "forget.note", "done.save", "done.stop_marketing", "done.forget", "forget.question", "forget.consequence", "forget.consequence_emailed", "forget.no", "stop_marketing.question", "stop_marketing.consequence", "stop_marketing.yes", "stop_marketing.no", "error.confirm_needed", "email.deleted.subject", "email.hello", "email.hello_plain", "email.deleted.body", "email.deleted.kept", "email.deleted.next"];
2
2
  export type ContactWordKey = (typeof CONTACT_WORD_KEYS)[number];
3
3
  /** The words by language, as `ui.wbcontact.<key>` would hold them. */
4
4
  export declare const CONTACT_WORDS: Readonly<Record<"en" | "tl" | "taglish", Readonly<Record<ContactWordKey, string>>>>;
package/dist/words.js CHANGED
@@ -42,6 +42,21 @@ export const CONTACT_WORD_KEYS = [
42
42
  "done.save",
43
43
  "done.stop_marketing",
44
44
  "done.forget",
45
+ "forget.question",
46
+ "forget.consequence",
47
+ "forget.consequence_emailed",
48
+ "forget.no",
49
+ "stop_marketing.question",
50
+ "stop_marketing.consequence",
51
+ "stop_marketing.yes",
52
+ "stop_marketing.no",
53
+ "error.confirm_needed",
54
+ "email.deleted.subject",
55
+ "email.hello",
56
+ "email.hello_plain",
57
+ "email.deleted.body",
58
+ "email.deleted.kept",
59
+ "email.deleted.next",
45
60
  ];
46
61
  const en = {
47
62
  "list.title": "Customers",
@@ -82,6 +97,21 @@ const en = {
82
97
  "done.save": "Saved.",
83
98
  "done.stop_marketing": "They won't get news or offers.",
84
99
  "done.forget": "Deleted.",
100
+ "forget.question": "Delete {name} and their history?",
101
+ "forget.consequence": "This can't be undone.",
102
+ "forget.consequence_emailed": "We'll email {email} to say it's done. This can't be undone.",
103
+ "forget.no": "No, keep them",
104
+ "stop_marketing.question": "Stop news and offers for {name}?",
105
+ "stop_marketing.consequence": "They won't get news or offers from you. You can't turn this back on: only they can, by saying yes again themselves.",
106
+ "stop_marketing.yes": "Yes, stop news and offers",
107
+ "stop_marketing.no": "No, leave it",
108
+ "error.confirm_needed": "Please confirm first. Nothing has changed.",
109
+ "email.deleted.subject": "{business} has deleted your details",
110
+ "email.hello": "Hi {name},",
111
+ "email.hello_plain": "Hi,",
112
+ "email.deleted.body": "{business} has deleted your record from its customer list: the contact details it kept about you and the list of your dealings with it. You won't get news or offers from that list.",
113
+ "email.deleted.kept": "Any bookings, payments or quotes you have with {business} are kept separately and aren't changed by this.",
114
+ "email.deleted.next": "You don't need to do anything. If you have a question, please contact {business}.",
85
115
  };
86
116
  const tl = {
87
117
  "list.title": "Mga customer",
@@ -122,6 +152,21 @@ const tl = {
122
152
  "done.save": "Na-save na.",
123
153
  "done.stop_marketing": "Hindi na sila makakatanggap ng balita o alok.",
124
154
  "done.forget": "Nabura na.",
155
+ "forget.question": "Burahin ang {name} at ang kasaysayan niya?",
156
+ "forget.consequence": "Hindi na ito maibabalik.",
157
+ "forget.consequence_emailed": "Mag-e-email kami sa {email} para sabihing tapos na. Hindi na ito maibabalik.",
158
+ "forget.no": "Hindi, huwag burahin",
159
+ "stop_marketing.question": "Itigil ang balita at alok para kay {name}?",
160
+ "stop_marketing.consequence": "Hindi na sila makakatanggap ng balita o alok mula sa inyo. Hindi na ninyo ito maibabalik: sila lang ang makakapagbalik nito, kung sila mismo ang papayag ulit.",
161
+ "stop_marketing.yes": "Oo, itigil na",
162
+ "stop_marketing.no": "Hindi, hayaan lang",
163
+ "error.confirm_needed": "Pakikumpirma muna. Walang nabago.",
164
+ "email.deleted.subject": "Binura ng {business} ang iyong detalye",
165
+ "email.hello": "Hi {name},",
166
+ "email.hello_plain": "Hi,",
167
+ "email.deleted.body": "Binura ng {business} ang record mo sa listahan nito ng mga customer: ang mga detalyeng itinago nito tungkol sa iyo at ang listahan ng mga naging transaksyon mo rito. Hindi ka na makakatanggap ng balita o alok mula sa listahang iyon.",
168
+ "email.deleted.kept": "Hiwalay na nakatago ang anumang booking, bayad o quote mo sa {business}, at hindi ito nabago.",
169
+ "email.deleted.next": "Wala kang kailangang gawin. Kung may tanong ka, makipag-ugnayan sa {business}.",
125
170
  };
126
171
  const taglish = {
127
172
  "list.title": "Customers",
@@ -162,6 +207,21 @@ const taglish = {
162
207
  "done.save": "Saved na.",
163
208
  "done.stop_marketing": "Hindi na sila makaka-receive ng news or offers.",
164
209
  "done.forget": "Deleted na.",
210
+ "forget.question": "I-delete ang {name} at ang history niya?",
211
+ "forget.consequence": "Hindi na ito ma-u-undo.",
212
+ "forget.consequence_emailed": "Mag-e-email kami sa {email} para sabihing done na. Hindi na ito ma-u-undo.",
213
+ "forget.no": "Hindi, i-keep siya",
214
+ "stop_marketing.question": "I-stop ang news and offers para kay {name}?",
215
+ "stop_marketing.consequence": "Hindi na sila makaka-receive ng news or offers from you. Hindi n'yo na ito ma-turn on ulit: sila lang, kung sila mismo ang mag-yes ulit.",
216
+ "stop_marketing.yes": "Yes, i-stop na",
217
+ "stop_marketing.no": "Hindi, hayaan lang",
218
+ "error.confirm_needed": "Paki-confirm muna. Walang nagbago.",
219
+ "email.deleted.subject": "Na-delete ng {business} ang details mo",
220
+ "email.hello": "Hi {name},",
221
+ "email.hello_plain": "Hi,",
222
+ "email.deleted.body": "Na-delete ng {business} ang record mo sa customer list nito: ang contact details mo at ang list ng mga transactions mo with them. Hindi ka na makaka-receive ng news or offers mula sa list na iyon.",
223
+ "email.deleted.kept": "Hiwalay na naka-keep ang bookings, payments or quotes mo with {business}, at hindi sila nagbago.",
224
+ "email.deleted.next": "Wala kang kailangang gawin. Kung may tanong ka, i-contact lang ang {business}.",
165
225
  };
166
226
  /** The words by language, as `ui.wbcontact.<key>` would hold them. */
167
227
  export const CONTACT_WORDS = { en, tl, taglish };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-contacts",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "Simple customer records for Workbench apps: one list of the people a business deals with, kept in the app's own database and filled from its forms, bookings, payments, quotes, reviews and WhatsApp and Messenger messages, with search, a spreadsheet export, a person's own copy on request, opt-outs that stick, and a clean-up of people who haven't been back.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",