@hardlydifficult/document-generator 1.0.1 → 1.0.3
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 +8 -8
- package/dist/Document.d.ts +89 -2
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js +169 -4
- package/dist/Document.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@ npm install @hardlydifficult/document-generator
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
14
|
+
import { Document, toMarkdown, toPlainText } from '@hardlydifficult/document-generator';
|
|
15
15
|
|
|
16
|
-
const document =
|
|
16
|
+
const document = new Document()
|
|
17
17
|
.header("Weekly Report")
|
|
18
18
|
.text("Summary of this week's **key highlights**.")
|
|
19
19
|
.list(["Completed feature A", "Fixed bug B", "Started project C"])
|
|
@@ -30,7 +30,7 @@ console.log(toPlainText(document.getBlocks()));
|
|
|
30
30
|
|
|
31
31
|
## API
|
|
32
32
|
|
|
33
|
-
### `
|
|
33
|
+
### `new Document()`
|
|
34
34
|
|
|
35
35
|
Create a new document builder. All methods are chainable.
|
|
36
36
|
|
|
@@ -56,7 +56,7 @@ Get the internal block representation for custom processing.
|
|
|
56
56
|
Text blocks support standard inline markdown that gets auto-converted per platform:
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
|
-
|
|
59
|
+
new Document().text('This has **bold**, *italic*, and ~~strikethrough~~ text.');
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
- Standard markdown: `**bold**`, `*italic*`, `~~strike~~`
|
|
@@ -72,10 +72,10 @@ The `.code()` method auto-detects format:
|
|
|
72
72
|
|
|
73
73
|
```typescript
|
|
74
74
|
// Single line → inline code
|
|
75
|
-
|
|
75
|
+
new Document().code('const x = 1'); // → `const x = 1`
|
|
76
76
|
|
|
77
77
|
// Multiline → code block
|
|
78
|
-
|
|
78
|
+
new Document().code('const x = 1;\nconst y = 2;');
|
|
79
79
|
// → ```
|
|
80
80
|
// const x = 1;
|
|
81
81
|
// const y = 2;
|
|
@@ -113,13 +113,13 @@ type Block =
|
|
|
113
113
|
Documents integrate seamlessly with the chat package for Slack and Discord:
|
|
114
114
|
|
|
115
115
|
```typescript
|
|
116
|
-
import {
|
|
116
|
+
import { Document } from '@hardlydifficult/document-generator';
|
|
117
117
|
import { createChatClient } from '@hardlydifficult/chat';
|
|
118
118
|
|
|
119
119
|
const client = createChatClient({ type: 'slack' });
|
|
120
120
|
const channel = await client.connect(channelId);
|
|
121
121
|
|
|
122
|
-
const report =
|
|
122
|
+
const report = new Document()
|
|
123
123
|
.header("Daily Metrics")
|
|
124
124
|
.text("Here are today's **key numbers**:")
|
|
125
125
|
.list(["Users: 1,234", "Revenue: $5,678", "Errors: 0"])
|
package/dist/Document.d.ts
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
import type { Block } from './types.js';
|
|
1
|
+
import type { Block, DocumentOptions, KeyValueOptions, TruncatedListOptions, TimestampOptions } from './types.js';
|
|
2
2
|
export declare class Document {
|
|
3
3
|
private blocks;
|
|
4
|
+
/**
|
|
5
|
+
* Create a new Document, optionally with initial content.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Empty document
|
|
10
|
+
* const doc = new Document();
|
|
11
|
+
*
|
|
12
|
+
* // Document with initial content
|
|
13
|
+
* const doc = new Document({
|
|
14
|
+
* header: 'Report Title',
|
|
15
|
+
* sections: [
|
|
16
|
+
* { title: 'Summary', content: 'All systems operational' },
|
|
17
|
+
* { content: 'No issues found' },
|
|
18
|
+
* ],
|
|
19
|
+
* context: { Network: 'mainnet', Status: 'active' },
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
constructor(options?: DocumentOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Truncate text to a maximum length with ellipsis.
|
|
26
|
+
*/
|
|
27
|
+
static truncate(text: string, maxLength: number): string;
|
|
4
28
|
header(text: string): this;
|
|
5
29
|
text(content: string): this;
|
|
6
30
|
list(items: string[]): this;
|
|
@@ -9,9 +33,72 @@ export declare class Document {
|
|
|
9
33
|
link(text: string, url: string): this;
|
|
10
34
|
code(content: string): this;
|
|
11
35
|
image(url: string, alt?: string): this;
|
|
36
|
+
/**
|
|
37
|
+
* Add a section with header and divider.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* doc.section('Customer Details').text('Name: Alice');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
section(title: string): this;
|
|
45
|
+
/**
|
|
46
|
+
* Add key-value pairs formatted as **Key:** value.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* doc.keyValue({ Network: 'mainnet', Status: 'active' });
|
|
51
|
+
* // Output: **Network:** mainnet\n**Status:** active
|
|
52
|
+
*
|
|
53
|
+
* doc.keyValue({ Name: 'Alice', Role: 'Admin' }, { style: 'bullet' });
|
|
54
|
+
* // Output: • **Name:** Alice\n• **Role:** Admin
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
keyValue(data: Record<string, string | number | boolean | undefined>, options?: KeyValueOptions): this;
|
|
58
|
+
/**
|
|
59
|
+
* Add a list with automatic truncation and "X more" message.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* doc.truncatedList(['a', 'b', 'c', 'd', 'e', 'f'], { limit: 3 });
|
|
64
|
+
* // Output:
|
|
65
|
+
* // • a
|
|
66
|
+
* // • b
|
|
67
|
+
* // • c
|
|
68
|
+
* // _... and 3 more_
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
truncatedList<T>(items: T[], options?: TruncatedListOptions<T>): this;
|
|
72
|
+
/**
|
|
73
|
+
* Add a timestamp in context format.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* doc.timestamp(); // 🕐 2024-02-04T12:00:00.000Z
|
|
78
|
+
* doc.timestamp({ emoji: false }); // 2024-02-04T12:00:00.000Z
|
|
79
|
+
* doc.timestamp({ label: 'Generated' }); // Generated 2024-02-04T...
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
timestamp(options?: TimestampOptions): this;
|
|
83
|
+
/**
|
|
84
|
+
* Check if the document has no content.
|
|
85
|
+
*/
|
|
86
|
+
isEmpty(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Create a shallow copy of the document.
|
|
89
|
+
*/
|
|
90
|
+
clone(): Document;
|
|
91
|
+
/**
|
|
92
|
+
* Get the raw blocks array.
|
|
93
|
+
*/
|
|
12
94
|
getBlocks(): Block[];
|
|
95
|
+
/**
|
|
96
|
+
* Convert document to markdown string.
|
|
97
|
+
*/
|
|
13
98
|
toMarkdown(): string;
|
|
99
|
+
/**
|
|
100
|
+
* Convert document to plain text string.
|
|
101
|
+
*/
|
|
14
102
|
toPlainText(): string;
|
|
15
103
|
}
|
|
16
|
-
export declare function doc(): Document;
|
|
17
104
|
//# sourceMappingURL=Document.d.ts.map
|
package/dist/Document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../src/Document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,
|
|
1
|
+
{"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../src/Document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EASL,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAIpB,qBAAa,QAAQ;IACnB,OAAO,CA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IAAI,MAAM;CAGtB"}
|
package/dist/Document.js
CHANGED
|
@@ -1,11 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Document = void 0;
|
|
4
|
-
exports.doc = doc;
|
|
5
4
|
const markdown_js_1 = require("./outputters/markdown.js");
|
|
6
5
|
const plainText_js_1 = require("./outputters/plainText.js");
|
|
7
6
|
class Document {
|
|
8
7
|
blocks = [];
|
|
8
|
+
/**
|
|
9
|
+
* Create a new Document, optionally with initial content.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Empty document
|
|
14
|
+
* const doc = new Document();
|
|
15
|
+
*
|
|
16
|
+
* // Document with initial content
|
|
17
|
+
* const doc = new Document({
|
|
18
|
+
* header: 'Report Title',
|
|
19
|
+
* sections: [
|
|
20
|
+
* { title: 'Summary', content: 'All systems operational' },
|
|
21
|
+
* { content: 'No issues found' },
|
|
22
|
+
* ],
|
|
23
|
+
* context: { Network: 'mainnet', Status: 'active' },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
constructor(options) {
|
|
28
|
+
if (options !== undefined) {
|
|
29
|
+
if (options.header !== undefined && options.header !== '') {
|
|
30
|
+
this.header(options.header);
|
|
31
|
+
}
|
|
32
|
+
if (options.sections !== undefined) {
|
|
33
|
+
for (const section of options.sections) {
|
|
34
|
+
if (section.title !== undefined && section.title !== '') {
|
|
35
|
+
this.section(section.title);
|
|
36
|
+
}
|
|
37
|
+
this.text(section.content);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (options.context !== undefined) {
|
|
41
|
+
this.divider();
|
|
42
|
+
this.keyValue(options.context);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Truncate text to a maximum length with ellipsis.
|
|
48
|
+
*/
|
|
49
|
+
static truncate(text, maxLength) {
|
|
50
|
+
if (text.length <= maxLength) {
|
|
51
|
+
return text;
|
|
52
|
+
}
|
|
53
|
+
return `${text.slice(0, maxLength - 3)}...`;
|
|
54
|
+
}
|
|
55
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
56
|
+
// Core block methods
|
|
57
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
9
58
|
header(text) {
|
|
10
59
|
const block = {
|
|
11
60
|
type: 'header',
|
|
@@ -73,18 +122,134 @@ class Document {
|
|
|
73
122
|
this.blocks.push(block);
|
|
74
123
|
return this;
|
|
75
124
|
}
|
|
125
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
126
|
+
// Convenience methods
|
|
127
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
128
|
+
/**
|
|
129
|
+
* Add a section with header and divider.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* doc.section('Customer Details').text('Name: Alice');
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
section(title) {
|
|
137
|
+
return this.header(title).divider();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Add key-value pairs formatted as **Key:** value.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* doc.keyValue({ Network: 'mainnet', Status: 'active' });
|
|
145
|
+
* // Output: **Network:** mainnet\n**Status:** active
|
|
146
|
+
*
|
|
147
|
+
* doc.keyValue({ Name: 'Alice', Role: 'Admin' }, { style: 'bullet' });
|
|
148
|
+
* // Output: • **Name:** Alice\n• **Role:** Admin
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
keyValue(data, options = {}) {
|
|
152
|
+
const { style = 'plain', separator = ':', bold = true } = options;
|
|
153
|
+
const entries = Object.entries(data).filter(([, v]) => v !== undefined);
|
|
154
|
+
if (entries.length === 0) {
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
const lines = entries.map(([key, value], i) => {
|
|
158
|
+
const formattedKey = bold ? `**${key}**` : key;
|
|
159
|
+
const prefix = style === 'bullet' ? '• ' : style === 'numbered' ? `${String(i + 1)}. ` : '';
|
|
160
|
+
return `${prefix}${formattedKey}${separator} ${String(value)}`;
|
|
161
|
+
});
|
|
162
|
+
return this.text(lines.join('\n'));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Add a list with automatic truncation and "X more" message.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* doc.truncatedList(['a', 'b', 'c', 'd', 'e', 'f'], { limit: 3 });
|
|
170
|
+
* // Output:
|
|
171
|
+
* // • a
|
|
172
|
+
* // • b
|
|
173
|
+
* // • c
|
|
174
|
+
* // _... and 3 more_
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
truncatedList(items, options = {}) {
|
|
178
|
+
const { limit = 10, format = (item) => String(item), moreText = (n) => `_... and ${String(n)} more_`, ordered = false, } = options;
|
|
179
|
+
if (items.length === 0) {
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
const visible = items.slice(0, limit);
|
|
183
|
+
const remaining = items.length - limit;
|
|
184
|
+
const lines = visible.map((item, i) => {
|
|
185
|
+
const prefix = ordered ? `${String(i + 1)}. ` : '• ';
|
|
186
|
+
return `${prefix}${format(item, i)}`;
|
|
187
|
+
});
|
|
188
|
+
if (remaining > 0) {
|
|
189
|
+
lines.push(moreText(remaining));
|
|
190
|
+
}
|
|
191
|
+
return this.text(lines.join('\n'));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Add a timestamp in context format.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* doc.timestamp(); // 🕐 2024-02-04T12:00:00.000Z
|
|
199
|
+
* doc.timestamp({ emoji: false }); // 2024-02-04T12:00:00.000Z
|
|
200
|
+
* doc.timestamp({ label: 'Generated' }); // Generated 2024-02-04T...
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
timestamp(options = {}) {
|
|
204
|
+
const { date = new Date(), emoji = true, label } = options;
|
|
205
|
+
const iso = date.toISOString();
|
|
206
|
+
let text;
|
|
207
|
+
if (label !== undefined && label !== '') {
|
|
208
|
+
text = `${label} ${iso}`;
|
|
209
|
+
}
|
|
210
|
+
else if (emoji) {
|
|
211
|
+
text = `🕐 ${iso}`;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
text = iso;
|
|
215
|
+
}
|
|
216
|
+
return this.context(text);
|
|
217
|
+
}
|
|
218
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
219
|
+
// Utility methods
|
|
220
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
221
|
+
/**
|
|
222
|
+
* Check if the document has no content.
|
|
223
|
+
*/
|
|
224
|
+
isEmpty() {
|
|
225
|
+
return this.blocks.length === 0;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Create a shallow copy of the document.
|
|
229
|
+
*/
|
|
230
|
+
clone() {
|
|
231
|
+
const copy = new Document();
|
|
232
|
+
copy.blocks = [...this.blocks];
|
|
233
|
+
return copy;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get the raw blocks array.
|
|
237
|
+
*/
|
|
76
238
|
getBlocks() {
|
|
77
239
|
return this.blocks;
|
|
78
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Convert document to markdown string.
|
|
243
|
+
*/
|
|
79
244
|
toMarkdown() {
|
|
80
245
|
return (0, markdown_js_1.toMarkdown)(this.blocks);
|
|
81
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Convert document to plain text string.
|
|
249
|
+
*/
|
|
82
250
|
toPlainText() {
|
|
83
251
|
return (0, plainText_js_1.toPlainText)(this.blocks);
|
|
84
252
|
}
|
|
85
253
|
}
|
|
86
254
|
exports.Document = Document;
|
|
87
|
-
function doc() {
|
|
88
|
-
return new Document();
|
|
89
|
-
}
|
|
90
255
|
//# sourceMappingURL=Document.js.map
|
package/dist/Document.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Document.js","sourceRoot":"","sources":["../src/Document.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Document.js","sourceRoot":"","sources":["../src/Document.ts"],"names":[],"mappings":";;;AAeA,0DAAwE;AACxE,4DAA2E;AAE3E,MAAa,QAAQ;IACX,MAAM,GAAY,EAAE,CAAC;IAE7B;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,OAAyB;QACnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;gBAC1D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC9B,CAAC;YACD,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACnC,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;oBACvC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,EAAE,EAAE,CAAC;wBACxD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;oBAC9B,CAAC;oBACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;YACD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBAClC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,SAAiB;QAC7C,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,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CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAA,wBAAc,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAA,0BAAe,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AA3RD,4BA2RC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Document
|
|
2
|
-
export type { Block, HeaderBlock, TextBlock, ListBlock, DividerBlock, ContextBlock, LinkBlock, CodeBlock, ImageBlock, Platform, } from './types.js';
|
|
1
|
+
export { Document } from './Document.js';
|
|
2
|
+
export type { Block, HeaderBlock, TextBlock, ListBlock, DividerBlock, ContextBlock, LinkBlock, CodeBlock, ImageBlock, Platform, DocumentOptions, DocumentSection, KeyValueOptions, TruncatedListOptions, TimestampOptions, } from './types.js';
|
|
3
3
|
export { toMarkdown } from './outputters/markdown.js';
|
|
4
4
|
export { toPlainText } from './outputters/plainText.js';
|
|
5
5
|
export { convertMarkdown, stripMarkdown } from './markdownConverter.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,YAAY,EACV,KAAK,EACL,WAAW,EACX,SAAS,EACT,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EAER,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stripMarkdown = exports.convertMarkdown = exports.toPlainText = exports.toMarkdown = exports.
|
|
4
|
-
// Main
|
|
3
|
+
exports.stripMarkdown = exports.convertMarkdown = exports.toPlainText = exports.toMarkdown = exports.Document = void 0;
|
|
4
|
+
// Main class and factory
|
|
5
5
|
var Document_js_1 = require("./Document.js");
|
|
6
6
|
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return Document_js_1.Document; } });
|
|
7
|
-
Object.defineProperty(exports, "doc", { enumerable: true, get: function () { return Document_js_1.doc; } });
|
|
8
7
|
// Outputters (for direct use)
|
|
9
8
|
var markdown_js_1 = require("./outputters/markdown.js");
|
|
10
9
|
Object.defineProperty(exports, "toMarkdown", { enumerable: true, get: function () { return markdown_js_1.toMarkdown; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AAsBjB,8BAA8B;AAC9B,wDAAsD;AAA7C,yGAAA,UAAU,OAAA;AACnB,0DAAwD;AAA/C,2GAAA,WAAW,OAAA;AAEpB,6CAA6C;AAC7C,+DAAwE;AAA/D,uHAAA,eAAe,OAAA;AAAE,qHAAA,aAAa,OAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -34,4 +34,39 @@ export interface ImageBlock {
|
|
|
34
34
|
url: string;
|
|
35
35
|
alt?: string;
|
|
36
36
|
}
|
|
37
|
+
export interface DocumentSection {
|
|
38
|
+
title?: string;
|
|
39
|
+
content: string;
|
|
40
|
+
}
|
|
41
|
+
export interface DocumentOptions {
|
|
42
|
+
header?: string;
|
|
43
|
+
sections?: DocumentSection[];
|
|
44
|
+
context?: Record<string, string | number | boolean | undefined>;
|
|
45
|
+
}
|
|
46
|
+
export interface KeyValueOptions {
|
|
47
|
+
/** List style: plain (default), bullet, or numbered */
|
|
48
|
+
style?: 'plain' | 'bullet' | 'numbered';
|
|
49
|
+
/** Separator between key and value. Default: ':' */
|
|
50
|
+
separator?: string;
|
|
51
|
+
/** Whether to bold keys. Default: true */
|
|
52
|
+
bold?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface TruncatedListOptions<T = string> {
|
|
55
|
+
/** Maximum items to show. Default: 10 */
|
|
56
|
+
limit?: number;
|
|
57
|
+
/** Custom formatter for each item. Default: String(item) */
|
|
58
|
+
format?: (item: T, index: number) => string;
|
|
59
|
+
/** Custom "more" text. Default: "_... and N more_" */
|
|
60
|
+
moreText?: (remaining: number) => string;
|
|
61
|
+
/** Use numbered list instead of bullets. Default: false */
|
|
62
|
+
ordered?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface TimestampOptions {
|
|
65
|
+
/** Custom date to use. Default: new Date() */
|
|
66
|
+
date?: Date;
|
|
67
|
+
/** Include clock emoji. Default: true */
|
|
68
|
+
emoji?: boolean;
|
|
69
|
+
/** Custom label text */
|
|
70
|
+
label?: string;
|
|
71
|
+
}
|
|
37
72
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,UAAU,GA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