@hardlydifficult/document-generator 1.0.2 → 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/dist/Document.d.ts +89 -1
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js +169 -0
- package/dist/Document.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- 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/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,8 +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
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,CAAC,MAAM,CAAe;IAE7B;;;;;;;;;;;;;;;;;;OAkBG;gBACS,OAAO,CAAC,EAAE,eAAe;IAoBrC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAWxD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS1B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAS3B,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAS3B,OAAO,IAAI,IAAI;IAQf,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS3B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAUrC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAW3B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IActC;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI5B;;;;;;;;;;;OAWG;IACH,QAAQ,CACN,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAC3D,OAAO,GAAE,eAAoB,GAC5B,IAAI;IAiBP;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,GAAE,oBAAoB,CAAC,CAAC,CAAM,GAAG,IAAI;IA2BzE;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,IAAI;IAkB/C;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,KAAK,IAAI,QAAQ;IAMjB;;OAEG;IACH,SAAS,IAAI,KAAK,EAAE;IAIpB;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,WAAW,IAAI,MAAM;CAGtB"}
|
package/dist/Document.js
CHANGED
|
@@ -5,6 +5,56 @@ const markdown_js_1 = require("./outputters/markdown.js");
|
|
|
5
5
|
const plainText_js_1 = require("./outputters/plainText.js");
|
|
6
6
|
class Document {
|
|
7
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
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
58
|
header(text) {
|
|
9
59
|
const block = {
|
|
10
60
|
type: 'header',
|
|
@@ -72,12 +122,131 @@ class Document {
|
|
|
72
122
|
this.blocks.push(block);
|
|
73
123
|
return this;
|
|
74
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
|
+
*/
|
|
75
238
|
getBlocks() {
|
|
76
239
|
return this.blocks;
|
|
77
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Convert document to markdown string.
|
|
243
|
+
*/
|
|
78
244
|
toMarkdown() {
|
|
79
245
|
return (0, markdown_js_1.toMarkdown)(this.blocks);
|
|
80
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Convert document to plain text string.
|
|
249
|
+
*/
|
|
81
250
|
toPlainText() {
|
|
82
251
|
return (0, plainText_js_1.toPlainText)(this.blocks);
|
|
83
252
|
}
|
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,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AAC,WAAW,EAAE,CAAC;QAC/B,IAAI,IAAY,CAAC;QACjB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YACxC,IAAI,GAAG,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;QAC3B,CAAC;aAAM,IAAI,KAAK,EAAE,CAAC;YACjB,IAAI,GAAG,MAAM,GAAG,EAAE,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,GAAG,CAAC;QACb,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,gFAAgF;IAChF,kBAAkB;IAClB,gFAAgF;IAEhF;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,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
1
|
export { Document } from './Document.js';
|
|
2
|
-
export type { Block, HeaderBlock, TextBlock, ListBlock, DividerBlock, ContextBlock, LinkBlock, CodeBlock, ImageBlock, Platform, } from './types.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,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,
|
|
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,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stripMarkdown = exports.convertMarkdown = exports.toPlainText = exports.toMarkdown = exports.Document = void 0;
|
|
4
|
-
// Main class
|
|
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
7
|
// Outputters (for direct use)
|
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,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;AAEtE,MAAM,MAAM,KAAK,GACb,WAAW,GACX,SAAS,GACT,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC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