@mccaskie-labs/workbench-contacts 0.0.0-stage → 0.1.1
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 +11 -0
- package/README.md +76 -2
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +124 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +59 -0
- package/dist/contacts.d.ts +128 -0
- package/dist/contacts.js +269 -0
- package/dist/csv.d.ts +9 -0
- package/dist/csv.js +42 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +10 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +16 -0
- package/dist/migration.d.ts +4 -0
- package/dist/migration.js +346 -0
- package/dist/starters.d.ts +9 -0
- package/dist/starters.js +11 -0
- package/dist/styles.d.ts +34 -0
- package/dist/styles.js +84 -0
- package/dist/tidy.d.ts +17 -0
- package/dist/tidy.js +68 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.js +3 -0
- package/dist/ui.d.ts +69 -0
- package/dist/ui.js +121 -0
- package/dist/words.d.ts +4 -0
- package/dist/words.js +167 -0
- package/package.json +48 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type Lang = "en" | "tl" | "taglish";
|
|
2
|
+
/** Where a person came from: the tool that met them. There is no SMS: Workbench apps message on WhatsApp and Messenger only. */
|
|
3
|
+
export type SourceKind = "form" | "booking" | "payment" | "quote" | "review" | "message" | "manual";
|
|
4
|
+
export declare const SOURCE_KINDS: readonly SourceKind[];
|
|
5
|
+
/** A detail the list can keep. A WhatsApp number is a phone; a Messenger id is the page-scoped id Meta gives the business's Page. */
|
|
6
|
+
export type DetailKind = "name" | "email" | "phone" | "messenger";
|
|
7
|
+
export declare const DETAIL_KINDS: readonly DetailKind[];
|
|
8
|
+
/** workbench/contacts.json, checked. */
|
|
9
|
+
export interface ContactSettings {
|
|
10
|
+
format: 1;
|
|
11
|
+
/** Which tools add people to the list. A record() from another is skipped, writing nothing. */
|
|
12
|
+
sources: readonly SourceKind[];
|
|
13
|
+
/** Which details the list keeps; the rest are dropped before anything is written (keep the least that does the job). Must include email, phone or messenger, so a person can be found again. */
|
|
14
|
+
keep: readonly DetailKind[];
|
|
15
|
+
/** A person who hasn't been back (no record, no edit) in this many months is deleted by cleanup(). 1 to 120; default 24. */
|
|
16
|
+
retention_months?: number;
|
|
17
|
+
/** "ask": the app may record a person's yes to news and offers, from a box they ticked themselves. "off": the app sends no marketing, so the list keeps no consent and export never offers a mailing list. */
|
|
18
|
+
marketing: "ask" | "off";
|
|
19
|
+
/** The time zone dates are shown in (IANA name), from the country pack. */
|
|
20
|
+
time_zone: string;
|
|
21
|
+
/** Let the owner keep a short note of their own on each person (up to 1,000 characters). Default true. */
|
|
22
|
+
notes?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A person's details as a tool hands them over. Empty strings count as missing. */
|
|
25
|
+
export interface PersonDetails {
|
|
26
|
+
name?: string | null;
|
|
27
|
+
email?: string | null;
|
|
28
|
+
/** Any common way of writing it; kept as +<country code><number>. */
|
|
29
|
+
phone?: string | null;
|
|
30
|
+
/** The Messenger page-scoped id (PSID) from the Page's webhook. */
|
|
31
|
+
messenger?: string | null;
|
|
32
|
+
}
|
|
33
|
+
/** The app's row that met the person: { kind: "booking", type: "booking", id }. Only its id is kept. */
|
|
34
|
+
export interface Source {
|
|
35
|
+
kind: SourceKind;
|
|
36
|
+
/** The app's own table or type for it (booking, invoice, enquiry). */
|
|
37
|
+
type: string;
|
|
38
|
+
id: string;
|
|
39
|
+
/** When it happened. Default now. */
|
|
40
|
+
at?: Date;
|
|
41
|
+
}
|
|
42
|
+
export type Marketing = "unknown" | "yes" | "no";
|
|
43
|
+
export interface Contact {
|
|
44
|
+
id: string;
|
|
45
|
+
account: string;
|
|
46
|
+
name: string | null;
|
|
47
|
+
email: string | null;
|
|
48
|
+
phone: string | null;
|
|
49
|
+
messenger: string | null;
|
|
50
|
+
/** unknown until the person says; yes only from their own ticked box; no stays no until they say yes again themselves. */
|
|
51
|
+
marketing: Marketing;
|
|
52
|
+
marketing_at: string | null;
|
|
53
|
+
/** The tool the yes or no came from (form, message, manual for the owner's stop). */
|
|
54
|
+
marketing_source: string | null;
|
|
55
|
+
/** The words the person agreed to, as proof of consent. */
|
|
56
|
+
marketing_wording: string | null;
|
|
57
|
+
note: string | null;
|
|
58
|
+
first_seen_at: string;
|
|
59
|
+
last_seen_at: string;
|
|
60
|
+
/** How many of each kind of record point at this person. */
|
|
61
|
+
counts: Readonly<Partial<Record<SourceKind, number>>>;
|
|
62
|
+
}
|
|
63
|
+
export interface ContactEvent {
|
|
64
|
+
kind: SourceKind;
|
|
65
|
+
type: string;
|
|
66
|
+
id: string;
|
|
67
|
+
at: string;
|
|
68
|
+
}
|
|
69
|
+
/** A contact with what pointed at them, the latest first (at most 200). */
|
|
70
|
+
export interface ContactDetail extends Contact {
|
|
71
|
+
events: readonly ContactEvent[];
|
|
72
|
+
}
|
|
73
|
+
export interface SearchResult {
|
|
74
|
+
/** How many match in all. */
|
|
75
|
+
total: number;
|
|
76
|
+
contacts: Contact[];
|
|
77
|
+
/** The next page's offset, when there is one. */
|
|
78
|
+
next?: number;
|
|
79
|
+
}
|
package/dist/types.js
ADDED
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Contacts } from "./contacts.ts";
|
|
2
|
+
import { ContactsError } from "./errors.ts";
|
|
3
|
+
import type { Contact, ContactDetail, Lang, SearchResult } from "./types.ts";
|
|
4
|
+
/** The project's strings lookup: `t('ui.wbcontact.save')`. Undefined falls back to the words of `lang`. */
|
|
5
|
+
export type Words = (key: string, params?: Readonly<Record<string, string | number>>) => string | undefined;
|
|
6
|
+
interface Common {
|
|
7
|
+
t?: Words;
|
|
8
|
+
/** The words' language when `t` has none. Default en. */
|
|
9
|
+
lang?: Lang;
|
|
10
|
+
/** Dates are shown in this time zone: contacts.settings.time_zone. */
|
|
11
|
+
timeZone: string;
|
|
12
|
+
/** The locale dates are written in. Default en-AU for en, fil-PH otherwise. */
|
|
13
|
+
locale?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ListOptions extends Common {
|
|
16
|
+
/** The list page's own address: the search form gets it, and Show more adds ?offset=. */
|
|
17
|
+
endpoint: string;
|
|
18
|
+
/** Each customer's page. */
|
|
19
|
+
contactUrl: (c: Contact) => string;
|
|
20
|
+
/** What was searched for, shown back in the box. */
|
|
21
|
+
query?: string;
|
|
22
|
+
/** Where Download the list goes (the app serves exportCsv there). Left out: no link. */
|
|
23
|
+
exportUrl?: string;
|
|
24
|
+
/** Where Download the mailing list goes (exportCsv with marketing). Left out: no link. */
|
|
25
|
+
mailingListUrl?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ContactPageOptions extends Common {
|
|
28
|
+
/** The project's route that hands the posted fields to contactAction. */
|
|
29
|
+
endpoint: string;
|
|
30
|
+
/** Where Download their details goes (the app serves exportPerson there). Left out: no link. */
|
|
31
|
+
downloadUrl?: string;
|
|
32
|
+
/** Which details to offer for correcting: contacts.settings.keep. */
|
|
33
|
+
keep: readonly string[];
|
|
34
|
+
/** Offer the note: contacts.settings.notes !== false. */
|
|
35
|
+
notes?: boolean;
|
|
36
|
+
/** Offer Stop news and offers: contacts.settings.marketing === "ask". */
|
|
37
|
+
marketing?: boolean;
|
|
38
|
+
/** What just happened, from contactAction's answer: shows "Saved." on the page. */
|
|
39
|
+
done?: "save" | "stop_marketing";
|
|
40
|
+
}
|
|
41
|
+
/** What a customer is called: their name, else their email, phone or Messenger id. */
|
|
42
|
+
export declare function contactLabel(c: Contact): string;
|
|
43
|
+
/** The account's customer list (from search()), with its search box, downloads and Show more. */
|
|
44
|
+
export declare function renderContactList(r: SearchResult, o: ListOptions): string;
|
|
45
|
+
/** One customer's page: what is kept, their history, the details to correct, Stop news and offers, Download, Delete. */
|
|
46
|
+
export declare function renderContact(c: ContactDetail, o: ContactPageOptions): string;
|
|
47
|
+
export interface ActionResult {
|
|
48
|
+
status: number;
|
|
49
|
+
/** What to answer with, as JSON. It never holds the database's or the settings check's own words. */
|
|
50
|
+
body: {
|
|
51
|
+
ok: true;
|
|
52
|
+
action: "save" | "stop_marketing" | "forget";
|
|
53
|
+
contact: string;
|
|
54
|
+
} | {
|
|
55
|
+
ok: false;
|
|
56
|
+
error: string;
|
|
57
|
+
message: string;
|
|
58
|
+
};
|
|
59
|
+
/** The error behind a refusal, for the app's own log. Never send it: for store_failed and bad_config its message is the database's or the settings check's. */
|
|
60
|
+
cause?: ContactsError;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The project's endpoint (behind the owner's sign-in) hands the posted form
|
|
64
|
+
* 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
|
+
*/
|
|
68
|
+
export declare function contactAction(contacts: Contacts, body: Record<string, unknown>, account: string): Promise<ActionResult>;
|
|
69
|
+
export {};
|
package/dist/ui.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// The owner's customer list and a customer's page: plain HTML strings, no
|
|
2
|
+
// script of their own, mobile first. Search is a GET form; every change is a
|
|
3
|
+
// form post to the project's endpoint (behind the owner's sign-in), which
|
|
4
|
+
// hands the fields to contactAction with the signed-in owner's account. Every
|
|
5
|
+
// element carries a wb-contact-* class (CONTACT_STYLES), and every control is
|
|
6
|
+
// at least 44 px tall.
|
|
7
|
+
//
|
|
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.
|
|
10
|
+
import { ContactsError } from "./errors.js";
|
|
11
|
+
import { CONTACT_WORDS } from "./words.js";
|
|
12
|
+
const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
13
|
+
function fill(text, params = {}) {
|
|
14
|
+
return text.replace(/\{(\w+)\}/g, (m, k) => (Object.hasOwn(params, k) ? String(params[k]) : m));
|
|
15
|
+
}
|
|
16
|
+
function words(o) {
|
|
17
|
+
const base = CONTACT_WORDS[o.lang ?? "en"] ?? CONTACT_WORDS.en;
|
|
18
|
+
return (key, params = {}) => o.t?.(`ui.wbcontact.${key}`, params) ?? fill(base[key], params);
|
|
19
|
+
}
|
|
20
|
+
function dateText(at, o) {
|
|
21
|
+
const locale = o.locale ?? (o.lang && o.lang !== "en" ? "fil-PH" : "en-AU");
|
|
22
|
+
return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: o.timeZone }).format(new Date(at));
|
|
23
|
+
}
|
|
24
|
+
/** What a customer is called: their name, else their email, phone or Messenger id. */
|
|
25
|
+
export function contactLabel(c) {
|
|
26
|
+
return c.name ?? c.email ?? c.phone ?? (c.messenger ? `Messenger ${c.messenger}` : c.id);
|
|
27
|
+
}
|
|
28
|
+
const withParam = (url, key, value) => `${url}${url.includes("?") ? "&" : "?"}${key}=${encodeURIComponent(String(value))}`;
|
|
29
|
+
/** The account's customer list (from search()), with its search box, downloads and Show more. */
|
|
30
|
+
export function renderContactList(r, o) {
|
|
31
|
+
const w = words(o);
|
|
32
|
+
const q = o.query?.trim() ?? "";
|
|
33
|
+
const search = `<form class="wb-contact-search" method="get" action="${esc(o.endpoint)}" role="search"><label class="wb-contact-search-label" for="wb-contact-q">${esc(w("search.label"))}</label><input class="wb-contact-query" id="wb-contact-q" type="search" name="q" value="${esc(q)}" maxlength="100" autocomplete="off"><button class="wb-contact-find" type="submit">${esc(w("search.button"))}</button></form>`;
|
|
34
|
+
const exports = [
|
|
35
|
+
o.exportUrl ? `<a class="wb-contact-export" href="${esc(o.exportUrl)}" download>${esc(w("export.all"))}</a>` : "",
|
|
36
|
+
o.mailingListUrl ? `<a class="wb-contact-export" href="${esc(o.mailingListUrl)}" download>${esc(w("export.marketing"))}</a>` : "",
|
|
37
|
+
].join("");
|
|
38
|
+
const title = `<h2 class="wb-contact-list-title">${esc(w("list.title"))} <span class="wb-contact-count">${r.total}</span></h2>`;
|
|
39
|
+
if (r.contacts.length === 0) {
|
|
40
|
+
return `<section class="wb-contact-list">${title}${search}<p class="wb-contact-empty">${esc(w(q ? "list.none_found" : "list.empty"))}</p></section>`;
|
|
41
|
+
}
|
|
42
|
+
const items = r.contacts
|
|
43
|
+
.map((c) => {
|
|
44
|
+
const detail = [c.email, c.phone].filter(Boolean).join(" · ");
|
|
45
|
+
const badge = c.marketing === "yes" ? `<span class="wb-contact-badge">${esc(w("marketing.yes"))}</span>` : "";
|
|
46
|
+
return `<li class="wb-contact-item"><a class="wb-contact-link" href="${esc(o.contactUrl(c))}"><span class="wb-contact-name">${esc(contactLabel(c))}</span>${detail && c.name ? `<span class="wb-contact-detail">${esc(detail)}</span>` : ""}<span class="wb-contact-seen">${esc(w("seen", { date: dateText(c.last_seen_at, o) }))}</span>${badge}</a></li>`;
|
|
47
|
+
})
|
|
48
|
+
.join("");
|
|
49
|
+
const more = r.next !== undefined ? `<a class="wb-contact-more" href="${esc(withParam(q ? withParam(o.endpoint, "q", q) : o.endpoint, "offset", r.next))}">${esc(w("list.more"))}</a>` : "";
|
|
50
|
+
return `<section class="wb-contact-list">${title}${search}${exports ? `<div class="wb-contact-exports">${exports}</div>` : ""}<ul class="wb-contact-items">${items}</ul>${more}</section>`;
|
|
51
|
+
}
|
|
52
|
+
/** One customer's page: what is kept, their history, the details to correct, Stop news and offers, Download, Delete. */
|
|
53
|
+
export function renderContact(c, o) {
|
|
54
|
+
const w = words(o);
|
|
55
|
+
const hidden = (action) => `<input type="hidden" name="contact" value="${esc(c.id)}"><input type="hidden" name="action" value="${action}">`;
|
|
56
|
+
const fact = (term, value) => `<div class="wb-contact-fact"><dt class="wb-contact-term">${esc(term)}</dt><dd class="wb-contact-value">${esc(value)}</dd></div>`;
|
|
57
|
+
const facts = [
|
|
58
|
+
o.marketing ? fact(w("field.marketing"), w(`marketing.${c.marketing}`)) : "",
|
|
59
|
+
fact(w("field.first_seen"), dateText(c.first_seen_at, o)),
|
|
60
|
+
fact(w("field.last_seen"), dateText(c.last_seen_at, o)),
|
|
61
|
+
].join("");
|
|
62
|
+
const field = (name, type, auto) => o.keep.includes(name)
|
|
63
|
+
? `<div class="wb-contact-field"><label class="wb-contact-label" for="wb-contact-${name}">${esc(w(`field.${name}`))}</label><input class="wb-contact-input" id="wb-contact-${name}" type="${type}" name="${name}" value="${esc(c[name] ?? "")}" autocomplete="${auto}"${name === "messenger" ? ' inputmode="numeric"' : ""}></div>`
|
|
64
|
+
: "";
|
|
65
|
+
const note = o.notes !== false
|
|
66
|
+
? `<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
|
+
: "";
|
|
68
|
+
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>`;
|
|
69
|
+
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>`
|
|
71
|
+
: "";
|
|
72
|
+
const download = o.downloadUrl ? `<a class="wb-contact-download" href="${esc(o.downloadUrl)}" download>${esc(w("download"))}</a>` : "";
|
|
73
|
+
const events = c.events.length
|
|
74
|
+
? `<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
|
+
: `<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>`;
|
|
77
|
+
const done = o.done ? `<p class="wb-contact-done" role="status">${esc(w(`done.${o.done}`))}</p>` : "";
|
|
78
|
+
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
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The project's endpoint (behind the owner's sign-in) hands the posted form
|
|
82
|
+
* 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.
|
|
85
|
+
*/
|
|
86
|
+
export async function contactAction(contacts, body, account) {
|
|
87
|
+
try {
|
|
88
|
+
const action = String(body.action ?? "");
|
|
89
|
+
if (action !== "save" && action !== "stop_marketing" && action !== "forget")
|
|
90
|
+
throw new ContactsError("bad_input", "action must be save, stop_marketing or forget");
|
|
91
|
+
const id = String(body.contact ?? "");
|
|
92
|
+
if (action === "save") {
|
|
93
|
+
const changes = {};
|
|
94
|
+
for (const k of ["name", "email", "phone", "messenger", "note"]) {
|
|
95
|
+
if (!Object.hasOwn(body, k))
|
|
96
|
+
continue;
|
|
97
|
+
const v = body[k];
|
|
98
|
+
changes[k] = typeof v === "string" && v.trim() ? v : null;
|
|
99
|
+
}
|
|
100
|
+
await contacts.update(account, id, changes);
|
|
101
|
+
}
|
|
102
|
+
else if (action === "stop_marketing") {
|
|
103
|
+
await contacts.setMarketing(account, id, { marketing: "no", source: "owner" });
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
if (body.confirm !== "yes")
|
|
107
|
+
throw new ContactsError("bad_input", "tick the box to delete this customer");
|
|
108
|
+
if (!(await contacts.forget(account, id)))
|
|
109
|
+
throw new ContactsError("unknown_contact", "no such contact");
|
|
110
|
+
}
|
|
111
|
+
return { status: 200, body: { ok: true, action, contact: id } };
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
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;
|
|
116
|
+
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
|
+
return { status, body: { ok: false, error: e.code, message }, cause: e };
|
|
118
|
+
}
|
|
119
|
+
throw e;
|
|
120
|
+
}
|
|
121
|
+
}
|
package/dist/words.d.ts
ADDED
|
@@ -0,0 +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"];
|
|
2
|
+
export type ContactWordKey = (typeof CONTACT_WORD_KEYS)[number];
|
|
3
|
+
/** The words by language, as `ui.wbcontact.<key>` would hold them. */
|
|
4
|
+
export declare const CONTACT_WORDS: Readonly<Record<"en" | "tl" | "taglish", Readonly<Record<ContactWordKey, string>>>>;
|
package/dist/words.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// The customer list's words, keyed as the project's strings catalogue keys
|
|
2
|
+
// them (`ui.wbcontact.*`), in English, Tagalog and Taglish. A project copies
|
|
3
|
+
// them into its catalogue (or keeps its own) and passes its `t`; a word the
|
|
4
|
+
// catalogue lacks falls back to the words here. The Tagalog and Taglish are
|
|
5
|
+
// starter words: have a fluent reader check them before a client sees them.
|
|
6
|
+
export const CONTACT_WORD_KEYS = [
|
|
7
|
+
"list.title",
|
|
8
|
+
"list.empty",
|
|
9
|
+
"list.none_found",
|
|
10
|
+
"list.more",
|
|
11
|
+
"search.label",
|
|
12
|
+
"search.button",
|
|
13
|
+
"export.all",
|
|
14
|
+
"export.marketing",
|
|
15
|
+
"marketing.yes",
|
|
16
|
+
"marketing.no",
|
|
17
|
+
"marketing.unknown",
|
|
18
|
+
"seen",
|
|
19
|
+
"field.name",
|
|
20
|
+
"field.email",
|
|
21
|
+
"field.phone",
|
|
22
|
+
"field.messenger",
|
|
23
|
+
"field.note",
|
|
24
|
+
"field.marketing",
|
|
25
|
+
"field.first_seen",
|
|
26
|
+
"field.last_seen",
|
|
27
|
+
"history.title",
|
|
28
|
+
"history.empty",
|
|
29
|
+
"kind.form",
|
|
30
|
+
"kind.booking",
|
|
31
|
+
"kind.payment",
|
|
32
|
+
"kind.quote",
|
|
33
|
+
"kind.review",
|
|
34
|
+
"kind.message",
|
|
35
|
+
"kind.manual",
|
|
36
|
+
"save",
|
|
37
|
+
"stop_marketing",
|
|
38
|
+
"download",
|
|
39
|
+
"forget.confirm",
|
|
40
|
+
"forget.button",
|
|
41
|
+
"forget.note",
|
|
42
|
+
"done.save",
|
|
43
|
+
"done.stop_marketing",
|
|
44
|
+
"done.forget",
|
|
45
|
+
];
|
|
46
|
+
const en = {
|
|
47
|
+
"list.title": "Customers",
|
|
48
|
+
"list.empty": "No customers yet. People are added here when they fill in a form, book, pay, get a quote, leave a review or message you.",
|
|
49
|
+
"list.none_found": "Nobody matches that.",
|
|
50
|
+
"list.more": "Show more",
|
|
51
|
+
"search.label": "Find a customer",
|
|
52
|
+
"search.button": "Find",
|
|
53
|
+
"export.all": "Download the list",
|
|
54
|
+
"export.marketing": "Download the mailing list",
|
|
55
|
+
"marketing.yes": "Said yes to news and offers",
|
|
56
|
+
"marketing.no": "No news or offers",
|
|
57
|
+
"marketing.unknown": "Hasn't said about news and offers",
|
|
58
|
+
seen: "Last in touch {date}",
|
|
59
|
+
"field.name": "Name",
|
|
60
|
+
"field.email": "Email",
|
|
61
|
+
"field.phone": "Phone",
|
|
62
|
+
"field.messenger": "Messenger id",
|
|
63
|
+
"field.note": "Your note",
|
|
64
|
+
"field.marketing": "News and offers",
|
|
65
|
+
"field.first_seen": "First in touch",
|
|
66
|
+
"field.last_seen": "Last in touch",
|
|
67
|
+
"history.title": "History",
|
|
68
|
+
"history.empty": "Nothing yet.",
|
|
69
|
+
"kind.form": "Form",
|
|
70
|
+
"kind.booking": "Booking",
|
|
71
|
+
"kind.payment": "Payment",
|
|
72
|
+
"kind.quote": "Quote",
|
|
73
|
+
"kind.review": "Review",
|
|
74
|
+
"kind.message": "Message",
|
|
75
|
+
"kind.manual": "Added by you",
|
|
76
|
+
save: "Save",
|
|
77
|
+
stop_marketing: "Stop news and offers",
|
|
78
|
+
download: "Download their details",
|
|
79
|
+
"forget.confirm": "Yes, delete this customer and their history",
|
|
80
|
+
"forget.button": "Delete customer",
|
|
81
|
+
"forget.note": "Do this when they ask you to. Their bookings, payments and quotes stay; only this record goes.",
|
|
82
|
+
"done.save": "Saved.",
|
|
83
|
+
"done.stop_marketing": "They won't get news or offers.",
|
|
84
|
+
"done.forget": "Deleted.",
|
|
85
|
+
};
|
|
86
|
+
const tl = {
|
|
87
|
+
"list.title": "Mga customer",
|
|
88
|
+
"list.empty": "Wala pang customer. Nadadagdag dito ang mga tao kapag nag-fill up sila ng form, nag-book, nagbayad, humingi ng quote, nag-review o nag-message sa inyo.",
|
|
89
|
+
"list.none_found": "Walang tumugma diyan.",
|
|
90
|
+
"list.more": "Ipakita pa",
|
|
91
|
+
"search.label": "Maghanap ng customer",
|
|
92
|
+
"search.button": "Hanapin",
|
|
93
|
+
"export.all": "I-download ang listahan",
|
|
94
|
+
"export.marketing": "I-download ang mailing list",
|
|
95
|
+
"marketing.yes": "Pumayag sa balita at alok",
|
|
96
|
+
"marketing.no": "Walang balita o alok",
|
|
97
|
+
"marketing.unknown": "Hindi pa sinasabi kung gusto ng balita at alok",
|
|
98
|
+
seen: "Huling nakipag-ugnayan {date}",
|
|
99
|
+
"field.name": "Pangalan",
|
|
100
|
+
"field.email": "Email",
|
|
101
|
+
"field.phone": "Telepono",
|
|
102
|
+
"field.messenger": "Messenger id",
|
|
103
|
+
"field.note": "Tala ninyo",
|
|
104
|
+
"field.marketing": "Balita at alok",
|
|
105
|
+
"field.first_seen": "Unang nakipag-ugnayan",
|
|
106
|
+
"field.last_seen": "Huling nakipag-ugnayan",
|
|
107
|
+
"history.title": "Kasaysayan",
|
|
108
|
+
"history.empty": "Wala pa.",
|
|
109
|
+
"kind.form": "Form",
|
|
110
|
+
"kind.booking": "Booking",
|
|
111
|
+
"kind.payment": "Bayad",
|
|
112
|
+
"kind.quote": "Quote",
|
|
113
|
+
"kind.review": "Review",
|
|
114
|
+
"kind.message": "Mensahe",
|
|
115
|
+
"kind.manual": "Idinagdag ninyo",
|
|
116
|
+
save: "I-save",
|
|
117
|
+
stop_marketing: "Itigil ang balita at alok",
|
|
118
|
+
download: "I-download ang kanilang detalye",
|
|
119
|
+
"forget.confirm": "Oo, burahin ang customer na ito at ang kasaysayan niya",
|
|
120
|
+
"forget.button": "Burahin ang customer",
|
|
121
|
+
"forget.note": "Gawin ito kapag hiniling nila. Mananatili ang kanilang booking, bayad at quote; ang record lang na ito ang mawawala.",
|
|
122
|
+
"done.save": "Na-save na.",
|
|
123
|
+
"done.stop_marketing": "Hindi na sila makakatanggap ng balita o alok.",
|
|
124
|
+
"done.forget": "Nabura na.",
|
|
125
|
+
};
|
|
126
|
+
const taglish = {
|
|
127
|
+
"list.title": "Customers",
|
|
128
|
+
"list.empty": "Wala pang customers. Nadadagdag dito ang mga tao kapag nag-fill up ng form, nag-book, nagbayad, nag-request ng quote, nag-review o nag-message sa inyo.",
|
|
129
|
+
"list.none_found": "Walang nag-match diyan.",
|
|
130
|
+
"list.more": "Show more",
|
|
131
|
+
"search.label": "Mag-search ng customer",
|
|
132
|
+
"search.button": "Search",
|
|
133
|
+
"export.all": "I-download ang list",
|
|
134
|
+
"export.marketing": "I-download ang mailing list",
|
|
135
|
+
"marketing.yes": "Okay sa news and offers",
|
|
136
|
+
"marketing.no": "Walang news or offers",
|
|
137
|
+
"marketing.unknown": "Hindi pa nagsasabi about news and offers",
|
|
138
|
+
seen: "Last in touch {date}",
|
|
139
|
+
"field.name": "Name",
|
|
140
|
+
"field.email": "Email",
|
|
141
|
+
"field.phone": "Phone",
|
|
142
|
+
"field.messenger": "Messenger id",
|
|
143
|
+
"field.note": "Note n'yo",
|
|
144
|
+
"field.marketing": "News and offers",
|
|
145
|
+
"field.first_seen": "First in touch",
|
|
146
|
+
"field.last_seen": "Last in touch",
|
|
147
|
+
"history.title": "History",
|
|
148
|
+
"history.empty": "Wala pa.",
|
|
149
|
+
"kind.form": "Form",
|
|
150
|
+
"kind.booking": "Booking",
|
|
151
|
+
"kind.payment": "Payment",
|
|
152
|
+
"kind.quote": "Quote",
|
|
153
|
+
"kind.review": "Review",
|
|
154
|
+
"kind.message": "Message",
|
|
155
|
+
"kind.manual": "Added n'yo",
|
|
156
|
+
save: "I-save",
|
|
157
|
+
stop_marketing: "I-stop ang news and offers",
|
|
158
|
+
download: "I-download ang details nila",
|
|
159
|
+
"forget.confirm": "Oo, i-delete ang customer na ito at ang history niya",
|
|
160
|
+
"forget.button": "I-delete ang customer",
|
|
161
|
+
"forget.note": "Gawin ito kapag ni-request nila. Maiiwan ang bookings, payments at quotes nila; itong record lang ang mawawala.",
|
|
162
|
+
"done.save": "Saved na.",
|
|
163
|
+
"done.stop_marketing": "Hindi na sila makaka-receive ng news or offers.",
|
|
164
|
+
"done.forget": "Deleted na.",
|
|
165
|
+
};
|
|
166
|
+
/** The words by language, as `ui.wbcontact.<key>` would hold them. */
|
|
167
|
+
export const CONTACT_WORDS = { en, tl, taglish };
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-contacts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
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
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mccaskie-labs/workbench.git",
|
|
10
|
+
"directory": "packages/contacts"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24"
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./styles": {
|
|
22
|
+
"types": "./dist/styles.d.ts",
|
|
23
|
+
"default": "./dist/styles.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"workbench-contacts": "./dist/cli.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"typecheck": "tsc -p tsconfig.check.json && tsc -p test/tsconfig.json",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:store": "vitest run --config vitest.db.config.ts",
|
|
42
|
+
"build": "node scripts/build.mjs",
|
|
43
|
+
"prepack": "node scripts/build.mjs"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "24.19.2",
|
|
47
|
+
"postgres": "4.1.0",
|
|
48
|
+
"vitest": "^5.1.0"
|
|
49
|
+
}
|
|
50
|
+
}
|