@sharpee/lang-en-us 0.9.61-beta
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/LICENSE +21 -0
- package/README.md +105 -0
- package/dist-npm/actions/about.d.ts +35 -0
- package/dist-npm/actions/about.d.ts.map +1 -0
- package/dist-npm/actions/about.js +50 -0
- package/dist-npm/actions/about.js.map +1 -0
- package/dist-npm/actions/again.d.ts +16 -0
- package/dist-npm/actions/again.d.ts.map +1 -0
- package/dist-npm/actions/again.js +23 -0
- package/dist-npm/actions/again.js.map +1 -0
- package/dist-npm/actions/answering.d.ts +29 -0
- package/dist-npm/actions/answering.d.ts.map +1 -0
- package/dist-npm/actions/answering.js +44 -0
- package/dist-npm/actions/answering.js.map +1 -0
- package/dist-npm/actions/asking.d.ts +31 -0
- package/dist-npm/actions/asking.d.ts.map +1 -0
- package/dist-npm/actions/asking.js +44 -0
- package/dist-npm/actions/asking.js.map +1 -0
- package/dist-npm/actions/attacking.d.ts +82 -0
- package/dist-npm/actions/attacking.d.ts.map +1 -0
- package/dist-npm/actions/attacking.js +111 -0
- package/dist-npm/actions/attacking.js.map +1 -0
- package/dist-npm/actions/climbing.d.ts +27 -0
- package/dist-npm/actions/climbing.d.ts.map +1 -0
- package/dist-npm/actions/climbing.js +48 -0
- package/dist-npm/actions/climbing.js.map +1 -0
- package/dist-npm/actions/closing.d.ts +21 -0
- package/dist-npm/actions/closing.d.ts.map +1 -0
- package/dist-npm/actions/closing.js +27 -0
- package/dist-npm/actions/closing.js.map +1 -0
- package/dist-npm/actions/drinking.d.ts +40 -0
- package/dist-npm/actions/drinking.d.ts.map +1 -0
- package/dist-npm/actions/drinking.js +57 -0
- package/dist-npm/actions/drinking.js.map +1 -0
- package/dist-npm/actions/dropping.d.ts +22 -0
- package/dist-npm/actions/dropping.d.ts.map +1 -0
- package/dist-npm/actions/dropping.js +31 -0
- package/dist-npm/actions/dropping.js.map +1 -0
- package/dist-npm/actions/eating.d.ts +37 -0
- package/dist-npm/actions/eating.d.ts.map +1 -0
- package/dist-npm/actions/eating.js +54 -0
- package/dist-npm/actions/eating.js.map +1 -0
- package/dist-npm/actions/entering.d.ts +26 -0
- package/dist-npm/actions/entering.d.ts.map +1 -0
- package/dist-npm/actions/entering.js +49 -0
- package/dist-npm/actions/entering.js.map +1 -0
- package/dist-npm/actions/examining.d.ts +37 -0
- package/dist-npm/actions/examining.d.ts.map +1 -0
- package/dist-npm/actions/examining.js +50 -0
- package/dist-npm/actions/examining.js.map +1 -0
- package/dist-npm/actions/exiting.d.ts +23 -0
- package/dist-npm/actions/exiting.d.ts.map +1 -0
- package/dist-npm/actions/exiting.js +40 -0
- package/dist-npm/actions/exiting.js.map +1 -0
- package/dist-npm/actions/giving.d.ts +30 -0
- package/dist-npm/actions/giving.d.ts.map +1 -0
- package/dist-npm/actions/giving.js +45 -0
- package/dist-npm/actions/giving.js.map +1 -0
- package/dist-npm/actions/going.d.ts +35 -0
- package/dist-npm/actions/going.d.ts.map +1 -0
- package/dist-npm/actions/going.js +45 -0
- package/dist-npm/actions/going.js.map +1 -0
- package/dist-npm/actions/help.d.ts +26 -0
- package/dist-npm/actions/help.d.ts.map +1 -0
- package/dist-npm/actions/help.js +44 -0
- package/dist-npm/actions/help.js.map +1 -0
- package/dist-npm/actions/index.d.ts +1327 -0
- package/dist-npm/actions/index.d.ts.map +1 -0
- package/dist-npm/actions/index.js +208 -0
- package/dist-npm/actions/index.js.map +1 -0
- package/dist-npm/actions/inserting.d.ts +25 -0
- package/dist-npm/actions/inserting.d.ts.map +1 -0
- package/dist-npm/actions/inserting.js +33 -0
- package/dist-npm/actions/inserting.js.map +1 -0
- package/dist-npm/actions/inventory.d.ts +32 -0
- package/dist-npm/actions/inventory.d.ts.map +1 -0
- package/dist-npm/actions/inventory.js +41 -0
- package/dist-npm/actions/inventory.js.map +1 -0
- package/dist-npm/actions/listening.d.ts +26 -0
- package/dist-npm/actions/listening.d.ts.map +1 -0
- package/dist-npm/actions/listening.js +37 -0
- package/dist-npm/actions/listening.js.map +1 -0
- package/dist-npm/actions/locking.d.ts +25 -0
- package/dist-npm/actions/locking.d.ts.map +1 -0
- package/dist-npm/actions/locking.js +33 -0
- package/dist-npm/actions/locking.js.map +1 -0
- package/dist-npm/actions/looking.d.ts +23 -0
- package/dist-npm/actions/looking.d.ts.map +1 -0
- package/dist-npm/actions/looking.js +34 -0
- package/dist-npm/actions/looking.js.map +1 -0
- package/dist-npm/actions/lowering.d.ts +22 -0
- package/dist-npm/actions/lowering.d.ts.map +1 -0
- package/dist-npm/actions/lowering.js +29 -0
- package/dist-npm/actions/lowering.js.map +1 -0
- package/dist-npm/actions/opening.d.ts +23 -0
- package/dist-npm/actions/opening.d.ts.map +1 -0
- package/dist-npm/actions/opening.js +30 -0
- package/dist-npm/actions/opening.js.map +1 -0
- package/dist-npm/actions/pulling.d.ts +35 -0
- package/dist-npm/actions/pulling.d.ts.map +1 -0
- package/dist-npm/actions/pulling.js +53 -0
- package/dist-npm/actions/pulling.js.map +1 -0
- package/dist-npm/actions/pushing.d.ts +30 -0
- package/dist-npm/actions/pushing.d.ts.map +1 -0
- package/dist-npm/actions/pushing.js +45 -0
- package/dist-npm/actions/pushing.js.map +1 -0
- package/dist-npm/actions/putting.d.ts +28 -0
- package/dist-npm/actions/putting.d.ts.map +1 -0
- package/dist-npm/actions/putting.js +40 -0
- package/dist-npm/actions/putting.js.map +1 -0
- package/dist-npm/actions/quitting.d.ts +31 -0
- package/dist-npm/actions/quitting.d.ts.map +1 -0
- package/dist-npm/actions/quitting.js +47 -0
- package/dist-npm/actions/quitting.js.map +1 -0
- package/dist-npm/actions/raising.d.ts +22 -0
- package/dist-npm/actions/raising.d.ts.map +1 -0
- package/dist-npm/actions/raising.js +30 -0
- package/dist-npm/actions/raising.js.map +1 -0
- package/dist-npm/actions/reading.d.ts +23 -0
- package/dist-npm/actions/reading.d.ts.map +1 -0
- package/dist-npm/actions/reading.js +32 -0
- package/dist-npm/actions/reading.js.map +1 -0
- package/dist-npm/actions/removing.d.ts +25 -0
- package/dist-npm/actions/removing.d.ts.map +1 -0
- package/dist-npm/actions/removing.js +34 -0
- package/dist-npm/actions/removing.js.map +1 -0
- package/dist-npm/actions/restoring.d.ts +35 -0
- package/dist-npm/actions/restoring.d.ts.map +1 -0
- package/dist-npm/actions/restoring.js +51 -0
- package/dist-npm/actions/restoring.js.map +1 -0
- package/dist-npm/actions/saving.d.ts +33 -0
- package/dist-npm/actions/saving.d.ts.map +1 -0
- package/dist-npm/actions/saving.js +48 -0
- package/dist-npm/actions/saving.js.map +1 -0
- package/dist-npm/actions/scoring.d.ts +42 -0
- package/dist-npm/actions/scoring.d.ts.map +1 -0
- package/dist-npm/actions/scoring.js +70 -0
- package/dist-npm/actions/scoring.js.map +1 -0
- package/dist-npm/actions/searching.d.ts +26 -0
- package/dist-npm/actions/searching.d.ts.map +1 -0
- package/dist-npm/actions/searching.js +40 -0
- package/dist-npm/actions/searching.js.map +1 -0
- package/dist-npm/actions/showing.d.ts +29 -0
- package/dist-npm/actions/showing.d.ts.map +1 -0
- package/dist-npm/actions/showing.js +40 -0
- package/dist-npm/actions/showing.js.map +1 -0
- package/dist-npm/actions/sleeping.d.ts +28 -0
- package/dist-npm/actions/sleeping.d.ts.map +1 -0
- package/dist-npm/actions/sleeping.js +41 -0
- package/dist-npm/actions/sleeping.js.map +1 -0
- package/dist-npm/actions/smelling.d.ts +30 -0
- package/dist-npm/actions/smelling.d.ts.map +1 -0
- package/dist-npm/actions/smelling.js +43 -0
- package/dist-npm/actions/smelling.js.map +1 -0
- package/dist-npm/actions/switching-off.d.ts +28 -0
- package/dist-npm/actions/switching-off.d.ts.map +1 -0
- package/dist-npm/actions/switching-off.js +42 -0
- package/dist-npm/actions/switching-off.js.map +1 -0
- package/dist-npm/actions/switching-on.d.ts +28 -0
- package/dist-npm/actions/switching-on.d.ts.map +1 -0
- package/dist-npm/actions/switching-on.js +42 -0
- package/dist-npm/actions/switching-on.js.map +1 -0
- package/dist-npm/actions/taking-off.d.ts +20 -0
- package/dist-npm/actions/taking-off.d.ts.map +1 -0
- package/dist-npm/actions/taking-off.js +28 -0
- package/dist-npm/actions/taking-off.js.map +1 -0
- package/dist-npm/actions/taking.d.ts +26 -0
- package/dist-npm/actions/taking.d.ts.map +1 -0
- package/dist-npm/actions/taking.js +36 -0
- package/dist-npm/actions/taking.js.map +1 -0
- package/dist-npm/actions/talking.d.ts +33 -0
- package/dist-npm/actions/talking.d.ts.map +1 -0
- package/dist-npm/actions/talking.js +49 -0
- package/dist-npm/actions/talking.js.map +1 -0
- package/dist-npm/actions/telling.d.ts +30 -0
- package/dist-npm/actions/telling.d.ts.map +1 -0
- package/dist-npm/actions/telling.js +42 -0
- package/dist-npm/actions/telling.js.map +1 -0
- package/dist-npm/actions/throwing.d.ts +39 -0
- package/dist-npm/actions/throwing.d.ts.map +1 -0
- package/dist-npm/actions/throwing.js +60 -0
- package/dist-npm/actions/throwing.js.map +1 -0
- package/dist-npm/actions/touching.d.ts +36 -0
- package/dist-npm/actions/touching.d.ts.map +1 -0
- package/dist-npm/actions/touching.js +50 -0
- package/dist-npm/actions/touching.js.map +1 -0
- package/dist-npm/actions/turning.d.ts +40 -0
- package/dist-npm/actions/turning.d.ts.map +1 -0
- package/dist-npm/actions/turning.js +62 -0
- package/dist-npm/actions/turning.js.map +1 -0
- package/dist-npm/actions/undoing.d.ts +19 -0
- package/dist-npm/actions/undoing.d.ts.map +1 -0
- package/dist-npm/actions/undoing.js +26 -0
- package/dist-npm/actions/undoing.js.map +1 -0
- package/dist-npm/actions/unlocking.d.ts +25 -0
- package/dist-npm/actions/unlocking.d.ts.map +1 -0
- package/dist-npm/actions/unlocking.js +32 -0
- package/dist-npm/actions/unlocking.js.map +1 -0
- package/dist-npm/actions/using.d.ts +43 -0
- package/dist-npm/actions/using.d.ts.map +1 -0
- package/dist-npm/actions/using.js +61 -0
- package/dist-npm/actions/using.js.map +1 -0
- package/dist-npm/actions/version.d.ts +18 -0
- package/dist-npm/actions/version.d.ts.map +1 -0
- package/dist-npm/actions/version.js +26 -0
- package/dist-npm/actions/version.js.map +1 -0
- package/dist-npm/actions/waiting.d.ts +27 -0
- package/dist-npm/actions/waiting.d.ts.map +1 -0
- package/dist-npm/actions/waiting.js +36 -0
- package/dist-npm/actions/waiting.js.map +1 -0
- package/dist-npm/actions/wearing.d.ts +22 -0
- package/dist-npm/actions/wearing.d.ts.map +1 -0
- package/dist-npm/actions/wearing.js +30 -0
- package/dist-npm/actions/wearing.js.map +1 -0
- package/dist-npm/data/events.d.ts +134 -0
- package/dist-npm/data/events.d.ts.map +1 -0
- package/dist-npm/data/events.js +301 -0
- package/dist-npm/data/events.js.map +1 -0
- package/dist-npm/data/messages.d.ts +141 -0
- package/dist-npm/data/messages.d.ts.map +1 -0
- package/dist-npm/data/messages.js +300 -0
- package/dist-npm/data/messages.js.map +1 -0
- package/dist-npm/data/templates.d.ts +257 -0
- package/dist-npm/data/templates.d.ts.map +1 -0
- package/dist-npm/data/templates.js +289 -0
- package/dist-npm/data/templates.js.map +1 -0
- package/dist-npm/data/verbs.d.ts +68 -0
- package/dist-npm/data/verbs.d.ts.map +1 -0
- package/dist-npm/data/verbs.js +324 -0
- package/dist-npm/data/verbs.js.map +1 -0
- package/dist-npm/data/words.d.ts +79 -0
- package/dist-npm/data/words.d.ts.map +1 -0
- package/dist-npm/data/words.js +218 -0
- package/dist-npm/data/words.js.map +1 -0
- package/dist-npm/formatters/article.d.ts +41 -0
- package/dist-npm/formatters/article.d.ts.map +1 -0
- package/dist-npm/formatters/article.js +143 -0
- package/dist-npm/formatters/article.js.map +1 -0
- package/dist-npm/formatters/index.d.ts +18 -0
- package/dist-npm/formatters/index.d.ts.map +1 -0
- package/dist-npm/formatters/index.js +38 -0
- package/dist-npm/formatters/index.js.map +1 -0
- package/dist-npm/formatters/list.d.ts +38 -0
- package/dist-npm/formatters/list.d.ts.map +1 -0
- package/dist-npm/formatters/list.js +94 -0
- package/dist-npm/formatters/list.js.map +1 -0
- package/dist-npm/formatters/registry.d.ts +48 -0
- package/dist-npm/formatters/registry.d.ts.map +1 -0
- package/dist-npm/formatters/registry.js +128 -0
- package/dist-npm/formatters/registry.js.map +1 -0
- package/dist-npm/formatters/text.d.ts +33 -0
- package/dist-npm/formatters/text.d.ts.map +1 -0
- package/dist-npm/formatters/text.js +80 -0
- package/dist-npm/formatters/text.js.map +1 -0
- package/dist-npm/formatters/types.d.ts +41 -0
- package/dist-npm/formatters/types.d.ts.map +1 -0
- package/dist-npm/formatters/types.js +14 -0
- package/dist-npm/formatters/types.js.map +1 -0
- package/dist-npm/grammar.d.ts +189 -0
- package/dist-npm/grammar.d.ts.map +1 -0
- package/dist-npm/grammar.js +203 -0
- package/dist-npm/grammar.js.map +1 -0
- package/dist-npm/index.d.ts +22 -0
- package/dist-npm/index.d.ts.map +1 -0
- package/dist-npm/index.js +59 -0
- package/dist-npm/index.js.map +1 -0
- package/dist-npm/language-provider.d.ts +159 -0
- package/dist-npm/language-provider.d.ts.map +1 -0
- package/dist-npm/language-provider.js +527 -0
- package/dist-npm/language-provider.js.map +1 -0
- package/dist-npm/npc/index.d.ts +5 -0
- package/dist-npm/npc/index.d.ts.map +1 -0
- package/dist-npm/npc/index.js +21 -0
- package/dist-npm/npc/index.js.map +1 -0
- package/dist-npm/npc/npc.d.ts +43 -0
- package/dist-npm/npc/npc.d.ts.map +1 -0
- package/dist-npm/npc/npc.js +55 -0
- package/dist-npm/npc/npc.js.map +1 -0
- package/dist-npm/perspective/index.d.ts +5 -0
- package/dist-npm/perspective/index.d.ts.map +1 -0
- package/dist-npm/perspective/index.js +12 -0
- package/dist-npm/perspective/index.js.map +1 -0
- package/dist-npm/perspective/placeholder-resolver.d.ts +102 -0
- package/dist-npm/perspective/placeholder-resolver.d.ts.map +1 -0
- package/dist-npm/perspective/placeholder-resolver.js +275 -0
- package/dist-npm/perspective/placeholder-resolver.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Article Formatters
|
|
3
|
+
*
|
|
4
|
+
* Formatters for adding articles to nouns based on noun type.
|
|
5
|
+
*
|
|
6
|
+
* @see ADR-095 Message Templates with Formatters
|
|
7
|
+
*/
|
|
8
|
+
import type { Formatter } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* "a" formatter - indefinite article
|
|
11
|
+
*
|
|
12
|
+
* Respects nounType:
|
|
13
|
+
* - common: "a sword" / "an apple"
|
|
14
|
+
* - proper: "John" (no article)
|
|
15
|
+
* - mass: "some water"
|
|
16
|
+
* - unique: "the sun"
|
|
17
|
+
* - plural: "swords" (no article for indefinite plural)
|
|
18
|
+
*/
|
|
19
|
+
export declare const aFormatter: Formatter;
|
|
20
|
+
/**
|
|
21
|
+
* "the" formatter - definite article
|
|
22
|
+
*
|
|
23
|
+
* Respects nounType:
|
|
24
|
+
* - proper: "John" (no article)
|
|
25
|
+
* - all others: "the X"
|
|
26
|
+
*/
|
|
27
|
+
export declare const theFormatter: Formatter;
|
|
28
|
+
/**
|
|
29
|
+
* "some" formatter - partitive article
|
|
30
|
+
*
|
|
31
|
+
* Primarily for mass nouns: "some water"
|
|
32
|
+
* Also works for plurals: "some coins"
|
|
33
|
+
*/
|
|
34
|
+
export declare const someFormatter: Formatter;
|
|
35
|
+
/**
|
|
36
|
+
* "your" formatter - possessive
|
|
37
|
+
*
|
|
38
|
+
* Creates "your X" phrases
|
|
39
|
+
*/
|
|
40
|
+
export declare const yourFormatter: Formatter;
|
|
41
|
+
//# sourceMappingURL=article.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article.d.ts","sourceRoot":"","sources":["../../src/formatters/article.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAgC,MAAM,YAAY,CAAC;AAwC1E;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,EAAE,SA6BxB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,SAiB1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,SAiB3B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,SAQ3B,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Article Formatters
|
|
4
|
+
*
|
|
5
|
+
* Formatters for adding articles to nouns based on noun type.
|
|
6
|
+
*
|
|
7
|
+
* @see ADR-095 Message Templates with Formatters
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.yourFormatter = exports.someFormatter = exports.theFormatter = exports.aFormatter = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Get indefinite article for a word (a/an)
|
|
13
|
+
*/
|
|
14
|
+
function getIndefiniteArticle(word) {
|
|
15
|
+
if (!word || word.length === 0)
|
|
16
|
+
return 'a';
|
|
17
|
+
const lower = word.toLowerCase();
|
|
18
|
+
// Special cases
|
|
19
|
+
if (lower.startsWith('hour'))
|
|
20
|
+
return 'an';
|
|
21
|
+
if (lower.startsWith('honest'))
|
|
22
|
+
return 'an';
|
|
23
|
+
if (lower.startsWith('heir'))
|
|
24
|
+
return 'an';
|
|
25
|
+
if (lower.startsWith('uni'))
|
|
26
|
+
return 'a'; // university
|
|
27
|
+
if (lower.startsWith('one'))
|
|
28
|
+
return 'a'; // one-way
|
|
29
|
+
const firstChar = lower[0];
|
|
30
|
+
const vowels = ['a', 'e', 'i', 'o', 'u'];
|
|
31
|
+
return vowels.includes(firstChar) ? 'an' : 'a';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Extract name from value (string or EntityInfo)
|
|
35
|
+
*/
|
|
36
|
+
function getName(value) {
|
|
37
|
+
return typeof value === 'string' ? value : value.name;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get entity info from value
|
|
41
|
+
*/
|
|
42
|
+
function getEntityInfo(value) {
|
|
43
|
+
if (typeof value === 'string') {
|
|
44
|
+
return { name: value };
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* "a" formatter - indefinite article
|
|
50
|
+
*
|
|
51
|
+
* Respects nounType:
|
|
52
|
+
* - common: "a sword" / "an apple"
|
|
53
|
+
* - proper: "John" (no article)
|
|
54
|
+
* - mass: "some water"
|
|
55
|
+
* - unique: "the sun"
|
|
56
|
+
* - plural: "swords" (no article for indefinite plural)
|
|
57
|
+
*/
|
|
58
|
+
const aFormatter = (value, _context) => {
|
|
59
|
+
// Handle arrays - format each item
|
|
60
|
+
if (Array.isArray(value)) {
|
|
61
|
+
return value.map((v) => (0, exports.aFormatter)(v, _context)).join(', ');
|
|
62
|
+
}
|
|
63
|
+
const info = getEntityInfo(value);
|
|
64
|
+
const name = info.name;
|
|
65
|
+
// Check noun type
|
|
66
|
+
const nounType = info.nounType ?? (info.properName ? 'proper' : 'common');
|
|
67
|
+
switch (nounType) {
|
|
68
|
+
case 'proper':
|
|
69
|
+
return name; // No article for proper names
|
|
70
|
+
case 'mass':
|
|
71
|
+
return `some ${name}`;
|
|
72
|
+
case 'unique':
|
|
73
|
+
return `the ${name}`;
|
|
74
|
+
case 'plural':
|
|
75
|
+
return name; // No article for indefinite plurals
|
|
76
|
+
case 'common':
|
|
77
|
+
default:
|
|
78
|
+
// Check if entity has custom article
|
|
79
|
+
if (info.article && info.article !== 'a' && info.article !== 'an') {
|
|
80
|
+
return `${info.article} ${name}`;
|
|
81
|
+
}
|
|
82
|
+
return `${getIndefiniteArticle(name)} ${name}`;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.aFormatter = aFormatter;
|
|
86
|
+
/**
|
|
87
|
+
* "the" formatter - definite article
|
|
88
|
+
*
|
|
89
|
+
* Respects nounType:
|
|
90
|
+
* - proper: "John" (no article)
|
|
91
|
+
* - all others: "the X"
|
|
92
|
+
*/
|
|
93
|
+
const theFormatter = (value, _context) => {
|
|
94
|
+
// Handle arrays - format each item
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
return value.map((v) => (0, exports.theFormatter)(v, _context)).join(', ');
|
|
97
|
+
}
|
|
98
|
+
const info = getEntityInfo(value);
|
|
99
|
+
const name = info.name;
|
|
100
|
+
// Check noun type
|
|
101
|
+
const nounType = info.nounType ?? (info.properName ? 'proper' : 'common');
|
|
102
|
+
if (nounType === 'proper') {
|
|
103
|
+
return name; // No article for proper names
|
|
104
|
+
}
|
|
105
|
+
return `the ${name}`;
|
|
106
|
+
};
|
|
107
|
+
exports.theFormatter = theFormatter;
|
|
108
|
+
/**
|
|
109
|
+
* "some" formatter - partitive article
|
|
110
|
+
*
|
|
111
|
+
* Primarily for mass nouns: "some water"
|
|
112
|
+
* Also works for plurals: "some coins"
|
|
113
|
+
*/
|
|
114
|
+
const someFormatter = (value, _context) => {
|
|
115
|
+
// Handle arrays - format each item
|
|
116
|
+
if (Array.isArray(value)) {
|
|
117
|
+
return value.map((v) => (0, exports.someFormatter)(v, _context)).join(', ');
|
|
118
|
+
}
|
|
119
|
+
const info = getEntityInfo(value);
|
|
120
|
+
const name = info.name;
|
|
121
|
+
// Check noun type
|
|
122
|
+
const nounType = info.nounType ?? (info.properName ? 'proper' : 'common');
|
|
123
|
+
if (nounType === 'proper') {
|
|
124
|
+
return name; // No article for proper names
|
|
125
|
+
}
|
|
126
|
+
return `some ${name}`;
|
|
127
|
+
};
|
|
128
|
+
exports.someFormatter = someFormatter;
|
|
129
|
+
/**
|
|
130
|
+
* "your" formatter - possessive
|
|
131
|
+
*
|
|
132
|
+
* Creates "your X" phrases
|
|
133
|
+
*/
|
|
134
|
+
const yourFormatter = (value, _context) => {
|
|
135
|
+
// Handle arrays
|
|
136
|
+
if (Array.isArray(value)) {
|
|
137
|
+
return value.map((v) => (0, exports.yourFormatter)(v, _context)).join(', ');
|
|
138
|
+
}
|
|
139
|
+
const name = getName(value);
|
|
140
|
+
return `your ${name}`;
|
|
141
|
+
};
|
|
142
|
+
exports.yourFormatter = yourFormatter;
|
|
143
|
+
//# sourceMappingURL=article.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article.js","sourceRoot":"","sources":["../../src/formatters/article.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAAY;IACxC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAE3C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAEjC,gBAAgB;IAChB,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC,CAAE,aAAa;IACvD,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC,CAAG,UAAU;IAErD,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,KAA0B;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC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M,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAEvB,kBAAkB;IAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAE1E,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,CAAC,8BAA8B;IAC7C,CAAC;IAED,OAAO,QAAQ,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC;AAjBW,QAAA,aAAa,iBAiBxB;AAEF;;;;GAIG;AACI,MAAM,aAAa,GAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;IAC1D,gBAAgB;IAChB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,qBAAa,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,QAAQ,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatter System
|
|
3
|
+
*
|
|
4
|
+
* Formatters transform placeholder values in message templates.
|
|
5
|
+
*
|
|
6
|
+
* Syntax: {formatter:formatter:...:placeholder}
|
|
7
|
+
* Example: {a:item} → "a sword"
|
|
8
|
+
* Example: {items:list} → "a sword, a key, and a coin"
|
|
9
|
+
* Example: {a:items:list} → applies 'a' to each item, then 'list' to join
|
|
10
|
+
*
|
|
11
|
+
* @see ADR-095 Message Templates with Formatters
|
|
12
|
+
*/
|
|
13
|
+
export type { Formatter, FormatterRegistry, FormatterContext, EntityInfo, } from './types.js';
|
|
14
|
+
export { createFormatterRegistry, parsePlaceholder, applyFormatters, formatMessage, } from './registry.js';
|
|
15
|
+
export { aFormatter, theFormatter, someFormatter, yourFormatter } from './article.js';
|
|
16
|
+
export { listFormatter, orListFormatter, commaListFormatter, countFormatter } from './list.js';
|
|
17
|
+
export { capFormatter, upperFormatter, lowerFormatter, titleFormatter } from './text.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Formatter System
|
|
4
|
+
*
|
|
5
|
+
* Formatters transform placeholder values in message templates.
|
|
6
|
+
*
|
|
7
|
+
* Syntax: {formatter:formatter:...:placeholder}
|
|
8
|
+
* Example: {a:item} → "a sword"
|
|
9
|
+
* Example: {items:list} → "a sword, a key, and a coin"
|
|
10
|
+
* Example: {a:items:list} → applies 'a' to each item, then 'list' to join
|
|
11
|
+
*
|
|
12
|
+
* @see ADR-095 Message Templates with Formatters
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.titleFormatter = exports.lowerFormatter = exports.upperFormatter = exports.capFormatter = exports.countFormatter = exports.commaListFormatter = exports.orListFormatter = exports.listFormatter = exports.yourFormatter = exports.someFormatter = exports.theFormatter = exports.aFormatter = exports.formatMessage = exports.applyFormatters = exports.parsePlaceholder = exports.createFormatterRegistry = void 0;
|
|
16
|
+
// Registry and utilities
|
|
17
|
+
var registry_js_1 = require("./registry.js");
|
|
18
|
+
Object.defineProperty(exports, "createFormatterRegistry", { enumerable: true, get: function () { return registry_js_1.createFormatterRegistry; } });
|
|
19
|
+
Object.defineProperty(exports, "parsePlaceholder", { enumerable: true, get: function () { return registry_js_1.parsePlaceholder; } });
|
|
20
|
+
Object.defineProperty(exports, "applyFormatters", { enumerable: true, get: function () { return registry_js_1.applyFormatters; } });
|
|
21
|
+
Object.defineProperty(exports, "formatMessage", { enumerable: true, get: function () { return registry_js_1.formatMessage; } });
|
|
22
|
+
// Individual formatters (for direct use or testing)
|
|
23
|
+
var article_js_1 = require("./article.js");
|
|
24
|
+
Object.defineProperty(exports, "aFormatter", { enumerable: true, get: function () { return article_js_1.aFormatter; } });
|
|
25
|
+
Object.defineProperty(exports, "theFormatter", { enumerable: true, get: function () { return article_js_1.theFormatter; } });
|
|
26
|
+
Object.defineProperty(exports, "someFormatter", { enumerable: true, get: function () { return article_js_1.someFormatter; } });
|
|
27
|
+
Object.defineProperty(exports, "yourFormatter", { enumerable: true, get: function () { return article_js_1.yourFormatter; } });
|
|
28
|
+
var list_js_1 = require("./list.js");
|
|
29
|
+
Object.defineProperty(exports, "listFormatter", { enumerable: true, get: function () { return list_js_1.listFormatter; } });
|
|
30
|
+
Object.defineProperty(exports, "orListFormatter", { enumerable: true, get: function () { return list_js_1.orListFormatter; } });
|
|
31
|
+
Object.defineProperty(exports, "commaListFormatter", { enumerable: true, get: function () { return list_js_1.commaListFormatter; } });
|
|
32
|
+
Object.defineProperty(exports, "countFormatter", { enumerable: true, get: function () { return list_js_1.countFormatter; } });
|
|
33
|
+
var text_js_1 = require("./text.js");
|
|
34
|
+
Object.defineProperty(exports, "capFormatter", { enumerable: true, get: function () { return text_js_1.capFormatter; } });
|
|
35
|
+
Object.defineProperty(exports, "upperFormatter", { enumerable: true, get: function () { return text_js_1.upperFormatter; } });
|
|
36
|
+
Object.defineProperty(exports, "lowerFormatter", { enumerable: true, get: function () { return text_js_1.lowerFormatter; } });
|
|
37
|
+
Object.defineProperty(exports, "titleFormatter", { enumerable: true, get: function () { return text_js_1.titleFormatter; } });
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAUH,yBAAyB;AACzB,6CAKuB;AAJrB,sHAAA,uBAAuB,OAAA;AACvB,+GAAA,gBAAgB,OAAA;AAChB,8GAAA,eAAe,OAAA;AACf,4GAAA,aAAa,OAAA;AAGf,oDAAoD;AACpD,2CAAsF;AAA7E,wGAAA,UAAU,OAAA;AAAE,0GAAA,YAAY,OAAA;AAAE,2GAAA,aAAa,OAAA;AAAE,2GAAA,aAAa,OAAA;AAC/D,qCAA+F;AAAtF,wGAAA,aAAa,OAAA;AAAE,0GAAA,eAAe,OAAA;AAAE,6GAAA,kBAAkB,OAAA;AAAE,yGAAA,cAAc,OAAA;AAC3E,qCAAyF;AAAhF,uGAAA,YAAY,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,yGAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List Formatters
|
|
3
|
+
*
|
|
4
|
+
* Formatters for joining arrays of items into prose.
|
|
5
|
+
*
|
|
6
|
+
* @see ADR-095 Message Templates with Formatters
|
|
7
|
+
*/
|
|
8
|
+
import type { Formatter } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* "list" formatter - join with commas and "and"
|
|
11
|
+
*
|
|
12
|
+
* Single: "a sword"
|
|
13
|
+
* Two: "a sword and a key"
|
|
14
|
+
* Three+: "a sword, a key, and a coin"
|
|
15
|
+
*/
|
|
16
|
+
export declare const listFormatter: Formatter;
|
|
17
|
+
/**
|
|
18
|
+
* "or-list" formatter - join with commas and "or"
|
|
19
|
+
*
|
|
20
|
+
* Single: "north"
|
|
21
|
+
* Two: "north or south"
|
|
22
|
+
* Three+: "north, south, or east"
|
|
23
|
+
*/
|
|
24
|
+
export declare const orListFormatter: Formatter;
|
|
25
|
+
/**
|
|
26
|
+
* "comma-list" formatter - join with commas only (no conjunction)
|
|
27
|
+
*
|
|
28
|
+
* "a sword, a key, a coin"
|
|
29
|
+
*/
|
|
30
|
+
export declare const commaListFormatter: Formatter;
|
|
31
|
+
/**
|
|
32
|
+
* "count" formatter - number + noun (with pluralization)
|
|
33
|
+
*
|
|
34
|
+
* Example: {items:count} with 3 swords → "3 swords"
|
|
35
|
+
* Example: {items:count} with 1 sword → "1 sword"
|
|
36
|
+
*/
|
|
37
|
+
export declare const countFormatter: Formatter;
|
|
38
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/formatters/list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,YAAY,CAAC;AAmBxD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,SAU3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,SAU7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAGhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,SAU5B,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* List Formatters
|
|
4
|
+
*
|
|
5
|
+
* Formatters for joining arrays of items into prose.
|
|
6
|
+
*
|
|
7
|
+
* @see ADR-095 Message Templates with Formatters
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.countFormatter = exports.commaListFormatter = exports.orListFormatter = exports.listFormatter = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Extract name from value (string or EntityInfo)
|
|
13
|
+
*/
|
|
14
|
+
function getName(value) {
|
|
15
|
+
return typeof value === 'string' ? value : value.name;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Ensure value is an array
|
|
19
|
+
*/
|
|
20
|
+
function ensureArray(value) {
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return value.map((v) => getName(v));
|
|
23
|
+
}
|
|
24
|
+
return [getName(value)];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* "list" formatter - join with commas and "and"
|
|
28
|
+
*
|
|
29
|
+
* Single: "a sword"
|
|
30
|
+
* Two: "a sword and a key"
|
|
31
|
+
* Three+: "a sword, a key, and a coin"
|
|
32
|
+
*/
|
|
33
|
+
const listFormatter = (value, _context) => {
|
|
34
|
+
const items = ensureArray(value);
|
|
35
|
+
if (items.length === 0)
|
|
36
|
+
return '';
|
|
37
|
+
if (items.length === 1)
|
|
38
|
+
return items[0];
|
|
39
|
+
if (items.length === 2)
|
|
40
|
+
return `${items[0]} and ${items[1]}`;
|
|
41
|
+
const allButLast = items.slice(0, -1);
|
|
42
|
+
const last = items[items.length - 1];
|
|
43
|
+
return `${allButLast.join(', ')}, and ${last}`;
|
|
44
|
+
};
|
|
45
|
+
exports.listFormatter = listFormatter;
|
|
46
|
+
/**
|
|
47
|
+
* "or-list" formatter - join with commas and "or"
|
|
48
|
+
*
|
|
49
|
+
* Single: "north"
|
|
50
|
+
* Two: "north or south"
|
|
51
|
+
* Three+: "north, south, or east"
|
|
52
|
+
*/
|
|
53
|
+
const orListFormatter = (value, _context) => {
|
|
54
|
+
const items = ensureArray(value);
|
|
55
|
+
if (items.length === 0)
|
|
56
|
+
return '';
|
|
57
|
+
if (items.length === 1)
|
|
58
|
+
return items[0];
|
|
59
|
+
if (items.length === 2)
|
|
60
|
+
return `${items[0]} or ${items[1]}`;
|
|
61
|
+
const allButLast = items.slice(0, -1);
|
|
62
|
+
const last = items[items.length - 1];
|
|
63
|
+
return `${allButLast.join(', ')}, or ${last}`;
|
|
64
|
+
};
|
|
65
|
+
exports.orListFormatter = orListFormatter;
|
|
66
|
+
/**
|
|
67
|
+
* "comma-list" formatter - join with commas only (no conjunction)
|
|
68
|
+
*
|
|
69
|
+
* "a sword, a key, a coin"
|
|
70
|
+
*/
|
|
71
|
+
const commaListFormatter = (value, _context) => {
|
|
72
|
+
const items = ensureArray(value);
|
|
73
|
+
return items.join(', ');
|
|
74
|
+
};
|
|
75
|
+
exports.commaListFormatter = commaListFormatter;
|
|
76
|
+
/**
|
|
77
|
+
* "count" formatter - number + noun (with pluralization)
|
|
78
|
+
*
|
|
79
|
+
* Example: {items:count} with 3 swords → "3 swords"
|
|
80
|
+
* Example: {items:count} with 1 sword → "1 sword"
|
|
81
|
+
*/
|
|
82
|
+
const countFormatter = (value, _context) => {
|
|
83
|
+
const items = ensureArray(value);
|
|
84
|
+
const count = items.length;
|
|
85
|
+
if (count === 0)
|
|
86
|
+
return 'nothing';
|
|
87
|
+
if (count === 1)
|
|
88
|
+
return `1 ${items[0]}`;
|
|
89
|
+
// For count > 1, assume the items are already formatted
|
|
90
|
+
// The item name should be pluralized by caller or be inherently plural
|
|
91
|
+
return `${count} items`;
|
|
92
|
+
};
|
|
93
|
+
exports.countFormatter = countFormatter;
|
|
94
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/formatters/list.ts"],"names":[],"mapp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KAAK,QAAQ,CAAC;AAC1B,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatter Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry of all formatters, with support for story extensions.
|
|
5
|
+
*
|
|
6
|
+
* @see ADR-095 Message Templates with Formatters
|
|
7
|
+
*/
|
|
8
|
+
import type { FormatterRegistry, FormatterContext, EntityInfo } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create the default formatter registry with all built-in formatters
|
|
11
|
+
*/
|
|
12
|
+
export declare function createFormatterRegistry(): FormatterRegistry;
|
|
13
|
+
/**
|
|
14
|
+
* Parse a placeholder with formatters
|
|
15
|
+
*
|
|
16
|
+
* Syntax: {formatter:formatter:...:placeholder}
|
|
17
|
+
*
|
|
18
|
+
* @returns Object with formatters array and final placeholder name
|
|
19
|
+
*/
|
|
20
|
+
export declare function parsePlaceholder(placeholder: string): {
|
|
21
|
+
formatters: string[];
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Apply formatters to a value in sequence
|
|
26
|
+
*
|
|
27
|
+
* @param value - The value to format
|
|
28
|
+
* @param formatters - Array of formatter names to apply in order
|
|
29
|
+
* @param registry - The formatter registry
|
|
30
|
+
* @param context - Formatting context
|
|
31
|
+
* @returns Formatted string
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyFormatters(value: string | number | boolean | string[] | EntityInfo | EntityInfo[], formatters: string[], registry: FormatterRegistry, context: FormatterContext): string;
|
|
34
|
+
/**
|
|
35
|
+
* Format a message template with placeholders
|
|
36
|
+
*
|
|
37
|
+
* Supports both:
|
|
38
|
+
* - Simple placeholders: {item}
|
|
39
|
+
* - Formatted placeholders: {a:item}, {items:list}, {a:items:list}
|
|
40
|
+
*
|
|
41
|
+
* @param template - Message template with {placeholder} syntax
|
|
42
|
+
* @param params - Values for placeholders
|
|
43
|
+
* @param registry - Formatter registry
|
|
44
|
+
* @param context - Formatting context
|
|
45
|
+
* @returns Formatted message
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatMessage(template: string, params: Record<string, string | number | boolean | string[] | EntityInfo | EntityInfo[]>, registry: FormatterRegistry, context?: FormatterContext): string;
|
|
48
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/formatters/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAa,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7F;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAuB3D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG;IACrD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAYA;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,UAAU,EAAE,EACvE,UAAU,EAAE,MAAM,EAAE,EACpB,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,MAAM,CAuBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,UAAU,EAAE,CAAC,EACxF,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CA8BR"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Formatter Registry
|
|
4
|
+
*
|
|
5
|
+
* Central registry of all formatters, with support for story extensions.
|
|
6
|
+
*
|
|
7
|
+
* @see ADR-095 Message Templates with Formatters
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createFormatterRegistry = createFormatterRegistry;
|
|
11
|
+
exports.parsePlaceholder = parsePlaceholder;
|
|
12
|
+
exports.applyFormatters = applyFormatters;
|
|
13
|
+
exports.formatMessage = formatMessage;
|
|
14
|
+
const article_js_1 = require("./article.js");
|
|
15
|
+
const list_js_1 = require("./list.js");
|
|
16
|
+
const text_js_1 = require("./text.js");
|
|
17
|
+
/**
|
|
18
|
+
* Create the default formatter registry with all built-in formatters
|
|
19
|
+
*/
|
|
20
|
+
function createFormatterRegistry() {
|
|
21
|
+
const registry = new Map();
|
|
22
|
+
// Article formatters
|
|
23
|
+
registry.set('a', article_js_1.aFormatter);
|
|
24
|
+
registry.set('an', article_js_1.aFormatter); // Alias
|
|
25
|
+
registry.set('the', article_js_1.theFormatter);
|
|
26
|
+
registry.set('some', article_js_1.someFormatter);
|
|
27
|
+
registry.set('your', article_js_1.yourFormatter);
|
|
28
|
+
// List formatters
|
|
29
|
+
registry.set('list', list_js_1.listFormatter);
|
|
30
|
+
registry.set('or-list', list_js_1.orListFormatter);
|
|
31
|
+
registry.set('comma-list', list_js_1.commaListFormatter);
|
|
32
|
+
registry.set('count', list_js_1.countFormatter);
|
|
33
|
+
// Text formatters
|
|
34
|
+
registry.set('cap', text_js_1.capFormatter);
|
|
35
|
+
registry.set('upper', text_js_1.upperFormatter);
|
|
36
|
+
registry.set('lower', text_js_1.lowerFormatter);
|
|
37
|
+
registry.set('title', text_js_1.titleFormatter);
|
|
38
|
+
return registry;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parse a placeholder with formatters
|
|
42
|
+
*
|
|
43
|
+
* Syntax: {formatter:formatter:...:placeholder}
|
|
44
|
+
*
|
|
45
|
+
* @returns Object with formatters array and final placeholder name
|
|
46
|
+
*/
|
|
47
|
+
function parsePlaceholder(placeholder) {
|
|
48
|
+
const parts = placeholder.split(':');
|
|
49
|
+
if (parts.length === 1) {
|
|
50
|
+
return { formatters: [], name: parts[0] };
|
|
51
|
+
}
|
|
52
|
+
// Last part is the placeholder name, everything before is formatters
|
|
53
|
+
const name = parts[parts.length - 1];
|
|
54
|
+
const formatters = parts.slice(0, -1);
|
|
55
|
+
return { formatters, name };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Apply formatters to a value in sequence
|
|
59
|
+
*
|
|
60
|
+
* @param value - The value to format
|
|
61
|
+
* @param formatters - Array of formatter names to apply in order
|
|
62
|
+
* @param registry - The formatter registry
|
|
63
|
+
* @param context - Formatting context
|
|
64
|
+
* @returns Formatted string
|
|
65
|
+
*/
|
|
66
|
+
function applyFormatters(value, formatters, registry, context) {
|
|
67
|
+
// Convert numbers/booleans to strings first
|
|
68
|
+
let result = (typeof value === 'number' || typeof value === 'boolean') ? String(value) : value;
|
|
69
|
+
for (const formatterName of formatters) {
|
|
70
|
+
const formatter = registry.get(formatterName);
|
|
71
|
+
if (formatter) {
|
|
72
|
+
// Apply formatter - result becomes a string
|
|
73
|
+
const formatted = formatter(result, context);
|
|
74
|
+
result = formatted;
|
|
75
|
+
}
|
|
76
|
+
// If formatter not found, skip it (could log warning)
|
|
77
|
+
}
|
|
78
|
+
// Ensure we return a string
|
|
79
|
+
if (Array.isArray(result)) {
|
|
80
|
+
return result.map((v) => (typeof v === 'string' ? v : v.name)).join(', ');
|
|
81
|
+
}
|
|
82
|
+
if (typeof result === 'string') {
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
return result.name;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Format a message template with placeholders
|
|
89
|
+
*
|
|
90
|
+
* Supports both:
|
|
91
|
+
* - Simple placeholders: {item}
|
|
92
|
+
* - Formatted placeholders: {a:item}, {items:list}, {a:items:list}
|
|
93
|
+
*
|
|
94
|
+
* @param template - Message template with {placeholder} syntax
|
|
95
|
+
* @param params - Values for placeholders
|
|
96
|
+
* @param registry - Formatter registry
|
|
97
|
+
* @param context - Formatting context
|
|
98
|
+
* @returns Formatted message
|
|
99
|
+
*/
|
|
100
|
+
function formatMessage(template, params, registry, context = {}) {
|
|
101
|
+
// Match {anything} placeholders
|
|
102
|
+
return template.replace(/\{([^}]+)\}/g, (match, placeholder) => {
|
|
103
|
+
const { formatters, name } = parsePlaceholder(placeholder);
|
|
104
|
+
// Get the value for this placeholder
|
|
105
|
+
const value = params[name];
|
|
106
|
+
if (value === undefined) {
|
|
107
|
+
// Placeholder not found in params - leave it as is
|
|
108
|
+
// (might be a perspective placeholder like {You})
|
|
109
|
+
return match;
|
|
110
|
+
}
|
|
111
|
+
// Apply formatters
|
|
112
|
+
if (formatters.length > 0) {
|
|
113
|
+
return applyFormatters(value, formatters, registry, context);
|
|
114
|
+
}
|
|
115
|
+
// No formatters - just convert to string
|
|
116
|
+
if (Array.isArray(value)) {
|
|
117
|
+
return value.map((v) => (typeof v === 'string' ? v : v.name)).join(', ');
|
|
118
|
+
}
|
|
119
|
+
if (typeof value === 'string') {
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
123
|
+
return String(value);
|
|
124
|
+
}
|
|
125
|
+
return value.name;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/formatters/registry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAUH,0DAuBC;AASD,4CAeC;AAWD,0CA4BC;AAeD,sCAmCC;AA/ID,6CAAsF;AACtF,uCAA+F;AAC/F,uCAAyF;AAEzF;;GAEG;AACH,SAAgB,uBAAuB;IACrC,MAAM,QAAQ,GAAsB,IAAI,GAAG,EAAE,CAAC;IAE9C,qBAAqB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|
|
4
|
+
* Formatters for case transformation and text manipulation.
|
|
5
|
+
*
|
|
6
|
+
* @see ADR-095 Message Templates with Formatters
|
|
7
|
+
*/
|
|
8
|
+
import type { Formatter } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* "cap" formatter - capitalize first letter
|
|
11
|
+
*
|
|
12
|
+
* "sword" → "Sword"
|
|
13
|
+
*/
|
|
14
|
+
export declare const capFormatter: Formatter;
|
|
15
|
+
/**
|
|
16
|
+
* "upper" formatter - all uppercase
|
|
17
|
+
*
|
|
18
|
+
* "sword" → "SWORD"
|
|
19
|
+
*/
|
|
20
|
+
export declare const upperFormatter: Formatter;
|
|
21
|
+
/**
|
|
22
|
+
* "lower" formatter - all lowercase
|
|
23
|
+
*
|
|
24
|
+
* "SWORD" → "sword"
|
|
25
|
+
*/
|
|
26
|
+
export declare const lowerFormatter: Formatter;
|
|
27
|
+
/**
|
|
28
|
+
* "title" formatter - title case (capitalize each word)
|
|
29
|
+
*
|
|
30
|
+
* "brass lantern" → "Brass Lantern"
|
|
31
|
+
*/
|
|
32
|
+
export declare const titleFormatter: Formatter;
|
|
33
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/formatters/text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,YAAY,CAAC;AASxD;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,SAU1B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,SAQ5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,SAQ5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,SAa5B,CAAC"}
|