@mccaskie-labs/workbench-quotes 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.
@@ -0,0 +1,9 @@
1
+ export declare const QUOTE_WORD_KEYS: readonly ["doc.quote", "doc.estimate", "doc.estimate_note", "title", "number", "date", "valid_until", "prepared_for", "col.item", "col.quantity", "col.unit", "col.amount", "subtotal", "tax_included", "tax_added", "total", "deposit", "note", "terms", "accept_online", "pdf", "accept.heading", "accept.name", "accept.agree", "accept.button", "accept.error.name", "accept.error.agree", "decline.heading", "decline.reason", "decline.button", "reason.price", "reason.timing", "reason.elsewhere", "reason.not_needed", "reason.other", "state.accepted", "state.accepted_you", "state.declined", "state.withdrawn", "state.expired", "state.not_found", "state.draft"];
2
+ export type QuoteWordKey = (typeof QUOTE_WORD_KEYS)[number];
3
+ export type QuoteLang = "en" | "tl" | "taglish";
4
+ /** The words by language, as `ui.wbquote.<key>` would hold them. */
5
+ export declare const QUOTE_WORDS: Readonly<Record<QuoteLang, Readonly<Record<QuoteWordKey, string>>>>;
6
+ /** The app's own words for a key, or undefined to use the package's. */
7
+ export type QuoteStrings = (key: `ui.wbquote.${QuoteWordKey}`, lang: QuoteLang) => string | undefined;
8
+ /** A word, from the app's catalogue first, then the package's, with {name} filled in. */
9
+ export declare function quoteWord(key: QuoteWordKey, lang: QuoteLang, values?: Readonly<Record<string, string>>, t?: QuoteStrings): string;
package/dist/words.js ADDED
@@ -0,0 +1,189 @@
1
+ // The accept page's and the PDF's words, keyed as the project's strings
2
+ // catalogue keys them (`ui.wbquote.*`), in English, Tagalog and Taglish. A
3
+ // project copies them into its catalogue (or keeps its own) and passes its
4
+ // `t`; a word the catalogue lacks falls back to the English here. The Tagalog
5
+ // and Taglish are starter words: have a fluent reader check them before a
6
+ // client sees them.
7
+ export const QUOTE_WORD_KEYS = [
8
+ "doc.quote",
9
+ "doc.estimate",
10
+ "doc.estimate_note",
11
+ "title",
12
+ "number",
13
+ "date",
14
+ "valid_until",
15
+ "prepared_for",
16
+ "col.item",
17
+ "col.quantity",
18
+ "col.unit",
19
+ "col.amount",
20
+ "subtotal",
21
+ "tax_included",
22
+ "tax_added",
23
+ "total",
24
+ "deposit",
25
+ "note",
26
+ "terms",
27
+ "accept_online",
28
+ "pdf",
29
+ "accept.heading",
30
+ "accept.name",
31
+ "accept.agree",
32
+ "accept.button",
33
+ "accept.error.name",
34
+ "accept.error.agree",
35
+ "decline.heading",
36
+ "decline.reason",
37
+ "decline.button",
38
+ "reason.price",
39
+ "reason.timing",
40
+ "reason.elsewhere",
41
+ "reason.not_needed",
42
+ "reason.other",
43
+ "state.accepted",
44
+ "state.accepted_you",
45
+ "state.declined",
46
+ "state.withdrawn",
47
+ "state.expired",
48
+ "state.not_found",
49
+ "state.draft",
50
+ ];
51
+ const en = {
52
+ "doc.quote": "Quote",
53
+ "doc.estimate": "Estimate",
54
+ "doc.estimate_note": "This is an estimate: the final price may change once the work is done.",
55
+ title: "{document} {number} from {business}",
56
+ number: "Number",
57
+ date: "Date",
58
+ valid_until: "Valid until",
59
+ prepared_for: "Prepared for",
60
+ "col.item": "Item",
61
+ "col.quantity": "Qty",
62
+ "col.unit": "Unit price",
63
+ "col.amount": "Amount",
64
+ subtotal: "Subtotal",
65
+ tax_included: "Includes {tax}",
66
+ tax_added: "{tax}",
67
+ total: "Total",
68
+ deposit: "Deposit to go ahead",
69
+ note: "Note",
70
+ terms: "Terms",
71
+ accept_online: "Accept or decline online: {url}",
72
+ pdf: "Download PDF",
73
+ "accept.heading": "Happy to go ahead?",
74
+ "accept.name": "Your full name",
75
+ "accept.agree": "I accept this {document} and its terms",
76
+ "accept.button": "Accept",
77
+ "accept.error.name": "Type your full name to accept.",
78
+ "accept.error.agree": "Tick the box to accept.",
79
+ "decline.heading": "Not going ahead?",
80
+ "decline.reason": "What's the main reason?",
81
+ "decline.button": "Decline",
82
+ "reason.price": "The price",
83
+ "reason.timing": "The timing",
84
+ "reason.elsewhere": "Going with someone else",
85
+ "reason.not_needed": "No longer needed",
86
+ "reason.other": "Another reason",
87
+ "state.accepted": "Accepted by {name} on {date}.",
88
+ "state.accepted_you": "Thank you, it's accepted. {business} will be in touch about the next step.",
89
+ "state.declined": "You declined this {document}. Thanks for letting {business} know.",
90
+ "state.withdrawn": "This {document} is no longer current. Ask {business} for the latest one.",
91
+ "state.expired": "This {document} ended on {date}. Ask {business} for a new one.",
92
+ "state.not_found": "This link doesn't open a quote. Check you have the whole link, or ask the business for a new one.",
93
+ "state.draft": "Draft: not sent yet.",
94
+ };
95
+ const tl = {
96
+ "doc.quote": "Quote",
97
+ "doc.estimate": "Tantiya",
98
+ "doc.estimate_note": "Tantiya ito: maaaring magbago ang huling presyo kapag tapos na ang trabaho.",
99
+ title: "{document} {number} mula sa {business}",
100
+ number: "Numero",
101
+ date: "Petsa",
102
+ valid_until: "May bisa hanggang",
103
+ prepared_for: "Para kay",
104
+ "col.item": "Item",
105
+ "col.quantity": "Dami",
106
+ "col.unit": "Presyo bawat isa",
107
+ "col.amount": "Halaga",
108
+ subtotal: "Subtotal",
109
+ tax_included: "Kasama ang {tax}",
110
+ tax_added: "{tax}",
111
+ total: "Kabuuan",
112
+ deposit: "Deposito para magsimula",
113
+ note: "Paalala",
114
+ terms: "Mga tuntunin",
115
+ accept_online: "Tanggapin o tanggihan online: {url}",
116
+ pdf: "I-download ang PDF",
117
+ "accept.heading": "Tuloy na po ba tayo?",
118
+ "accept.name": "Buong pangalan ninyo",
119
+ "accept.agree": "Tinatanggap ko ang {document} na ito at ang mga tuntunin nito",
120
+ "accept.button": "Tanggapin",
121
+ "accept.error.name": "Ilagay ang buong pangalan ninyo para tanggapin.",
122
+ "accept.error.agree": "Lagyan ng tsek ang kahon para tanggapin.",
123
+ "decline.heading": "Hindi na po tutuloy?",
124
+ "decline.reason": "Ano po ang pangunahing dahilan?",
125
+ "decline.button": "Tanggihan",
126
+ "reason.price": "Ang presyo",
127
+ "reason.timing": "Ang oras o petsa",
128
+ "reason.elsewhere": "Sa iba na po kukuha",
129
+ "reason.not_needed": "Hindi na kailangan",
130
+ "reason.other": "Ibang dahilan",
131
+ "state.accepted": "Tinanggap ni {name} noong {date}.",
132
+ "state.accepted_you": "Salamat po, tinanggap na. Makikipag-ugnayan ang {business} para sa susunod na hakbang.",
133
+ "state.declined": "Tinanggihan ninyo ang {document} na ito. Salamat po sa pagsabi sa {business}.",
134
+ "state.withdrawn": "Hindi na kasalukuyan ang {document} na ito. Humingi po ng pinakabago sa {business}.",
135
+ "state.expired": "Natapos ang {document} na ito noong {date}. Humingi po ng bago sa {business}.",
136
+ "state.not_found": "Hindi nagbubukas ng quote ang link na ito. Tingnan kung buo ang link, o humingi ng bago sa negosyo.",
137
+ "state.draft": "Draft: hindi pa naipapadala.",
138
+ };
139
+ const taglish = {
140
+ "doc.quote": "Quote",
141
+ "doc.estimate": "Estimate",
142
+ "doc.estimate_note": "Estimate lang ito: pwedeng magbago ang final price kapag tapos na ang work.",
143
+ title: "{document} {number} from {business}",
144
+ number: "Number",
145
+ date: "Date",
146
+ valid_until: "Valid until",
147
+ prepared_for: "Para kay",
148
+ "col.item": "Item",
149
+ "col.quantity": "Qty",
150
+ "col.unit": "Unit price",
151
+ "col.amount": "Amount",
152
+ subtotal: "Subtotal",
153
+ tax_included: "Kasama ang {tax}",
154
+ tax_added: "{tax}",
155
+ total: "Total",
156
+ deposit: "Deposit para mag-start",
157
+ note: "Note",
158
+ terms: "Terms",
159
+ accept_online: "I-accept o i-decline online: {url}",
160
+ pdf: "I-download ang PDF",
161
+ "accept.heading": "Go na po ba tayo?",
162
+ "accept.name": "Full name n'yo",
163
+ "accept.agree": "Ina-accept ko ang {document} na ito at ang terms nito",
164
+ "accept.button": "Accept",
165
+ "accept.error.name": "I-type ang full name n'yo para mag-accept.",
166
+ "accept.error.agree": "I-tick ang box para mag-accept.",
167
+ "decline.heading": "Hindi na po tutuloy?",
168
+ "decline.reason": "Ano po ang main reason?",
169
+ "decline.button": "Decline",
170
+ "reason.price": "Ang price",
171
+ "reason.timing": "Ang timing",
172
+ "reason.elsewhere": "Sa iba na po kukuha",
173
+ "reason.not_needed": "Hindi na kailangan",
174
+ "reason.other": "Ibang reason",
175
+ "state.accepted": "Na-accept ni {name} noong {date}.",
176
+ "state.accepted_you": "Thank you po, accepted na. Magme-message ang {business} para sa next step.",
177
+ "state.declined": "Na-decline n'yo ang {document} na ito. Thanks po sa pag-inform sa {business}.",
178
+ "state.withdrawn": "Hindi na current ang {document} na ito. Humingi po ng latest sa {business}.",
179
+ "state.expired": "Nag-end ang {document} na ito noong {date}. Humingi po ng bago sa {business}.",
180
+ "state.not_found": "Hindi nagbubukas ng quote ang link na ito. I-check kung buo ang link, o humingi ng bago sa business.",
181
+ "state.draft": "Draft: hindi pa na-send.",
182
+ };
183
+ /** The words by language, as `ui.wbquote.<key>` would hold them. */
184
+ export const QUOTE_WORDS = { en, tl, taglish };
185
+ /** A word, from the app's catalogue first, then the package's, with {name} filled in. */
186
+ export function quoteWord(key, lang, values = {}, t) {
187
+ const text = t?.(`ui.wbquote.${key}`, lang) ?? QUOTE_WORDS[lang][key] ?? QUOTE_WORDS.en[key];
188
+ return text.replace(/\{(\w+)\}/g, (m, name) => (Object.hasOwn(values, name) ? values[name] : m));
189
+ }
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-quotes",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Quotes and estimates for Workbench apps: a price list prices a form's answers in whole cents with GST, the quote is sent as a link and a branded PDF, and the customer accepts or declines online. An accepted quote hands over to the payments and invoices tool. Runs in the app's own Worker and database, with no Gateway call.",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mccaskie-labs/workbench.git",
10
+ "directory": "packages/quotes"
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-quotes": "./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
+ "dependencies": {
46
+ "@mccaskie-labs/workbench-country": "^0.2.3",
47
+ "@mccaskie-labs/workbench-forms": "^0.10.0"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "24.19.2",
51
+ "postgres": "4.1.0",
52
+ "vitest": "^5.1.0"
53
+ }
54
+ }