@k-msg/template 0.5.0 → 0.6.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/README.md +25 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,24 +21,13 @@ bun add @k-msg/template @k-msg/core
|
|
|
21
21
|
## Basic Usage
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
|
-
import {
|
|
25
|
-
import { IWINVAdapter } from '@k-msg/provider';
|
|
26
|
-
|
|
27
|
-
const adapter = new IWINVAdapter(config);
|
|
28
|
-
const templateService = new TemplateService(adapter);
|
|
24
|
+
import { interpolate } from '@k-msg/template';
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
code: 'OTP_001',
|
|
33
|
-
name: 'OTP Verification',
|
|
34
|
-
content: '[MyApp] Your verification code is #{code}.',
|
|
35
|
-
category: 'AUTHENTICATION'
|
|
26
|
+
const text = interpolate('[MyApp] Your verification code is #{code}.', {
|
|
27
|
+
code: '123456',
|
|
36
28
|
});
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
const template = result.value;
|
|
40
|
-
console.log('Template created:', template.id);
|
|
41
|
-
}
|
|
30
|
+
console.log(text); // "[MyApp] Your verification code is 123456."
|
|
42
31
|
```
|
|
43
32
|
|
|
44
33
|
## Template Registry
|
|
@@ -63,6 +52,26 @@ const templates = await registry.search({
|
|
|
63
52
|
});
|
|
64
53
|
```
|
|
65
54
|
|
|
55
|
+
## Provider-backed TemplateService (Optional)
|
|
56
|
+
|
|
57
|
+
`TemplateService` is a small helper around the `TemplateProvider` interface from
|
|
58
|
+
`@k-msg/core`.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { TemplateService } from '@k-msg/template';
|
|
62
|
+
import type { TemplateProvider } from '@k-msg/core';
|
|
63
|
+
|
|
64
|
+
const provider: TemplateProvider = /* your implementation */;
|
|
65
|
+
const templateService = new TemplateService(provider);
|
|
66
|
+
|
|
67
|
+
await templateService.create({
|
|
68
|
+
code: 'OTP_001',
|
|
69
|
+
name: 'OTP Verification',
|
|
70
|
+
content: '[MyApp] Your verification code is #{code}.',
|
|
71
|
+
category: 'AUTHENTICATION'
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
66
75
|
## License
|
|
67
76
|
|
|
68
|
-
MIT
|
|
77
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k-msg/template",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"packageManager": "bun@1.3.8",
|
|
5
5
|
"description": "AlimTalk template engine for parsing, building and managing templates",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"publish": "bun publish --access public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@k-msg/core": "0.
|
|
32
|
+
"@k-msg/core": "0.6.0",
|
|
33
33
|
"zod": "^4.0.14"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|