@h2nguyen/arc42-node-mcp-server 2.0.0 → 2.1.1
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/CHANGELOG.md +72 -0
- package/README.md +83 -6
- package/dist/templates/arc42-reference.d.ts +25 -7
- package/dist/templates/arc42-reference.d.ts.map +1 -1
- package/dist/templates/arc42-reference.js +96 -47
- package/dist/templates/arc42-reference.js.map +1 -1
- package/dist/templates/formats/asciidoc/index.d.ts +178 -0
- package/dist/templates/formats/asciidoc/index.d.ts.map +1 -0
- package/dist/templates/formats/asciidoc/index.js +225 -0
- package/dist/templates/formats/asciidoc/index.js.map +1 -0
- package/dist/templates/formats/index.d.ts +108 -0
- package/dist/templates/formats/index.d.ts.map +1 -0
- package/dist/templates/formats/index.js +149 -0
- package/dist/templates/formats/index.js.map +1 -0
- package/dist/templates/formats/markdown/index.d.ts +172 -0
- package/dist/templates/formats/markdown/index.d.ts.map +1 -0
- package/dist/templates/formats/markdown/index.js +211 -0
- package/dist/templates/formats/markdown/index.js.map +1 -0
- package/dist/templates/formats/output-format-factory.d.ts +125 -0
- package/dist/templates/formats/output-format-factory.d.ts.map +1 -0
- package/dist/templates/formats/output-format-factory.js +166 -0
- package/dist/templates/formats/output-format-factory.js.map +1 -0
- package/dist/templates/formats/output-format-registry.d.ts +114 -0
- package/dist/templates/formats/output-format-registry.d.ts.map +1 -0
- package/dist/templates/formats/output-format-registry.js +147 -0
- package/dist/templates/formats/output-format-registry.js.map +1 -0
- package/dist/templates/formats/output-format-strategy.d.ts +195 -0
- package/dist/templates/formats/output-format-strategy.d.ts.map +1 -0
- package/dist/templates/formats/output-format-strategy.js +69 -0
- package/dist/templates/formats/output-format-strategy.js.map +1 -0
- package/dist/templates/index.d.ts +9 -8
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +21 -10
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/locales/cz/index.d.ts +25 -3
- package/dist/templates/locales/cz/index.d.ts.map +1 -1
- package/dist/templates/locales/cz/index.js +34 -18
- package/dist/templates/locales/cz/index.js.map +1 -1
- package/dist/templates/locales/cz/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/cz/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/cz/templates-asciidoc.js +764 -0
- package/dist/templates/locales/cz/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/cz/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/cz/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/cz/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/cz/templates-markdown.js.map +1 -0
- package/dist/templates/locales/de/index.d.ts +14 -4
- package/dist/templates/locales/de/index.d.ts.map +1 -1
- package/dist/templates/locales/de/index.js +22 -25
- package/dist/templates/locales/de/index.js.map +1 -1
- package/dist/templates/locales/de/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/de/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/de/templates-asciidoc.js +814 -0
- package/dist/templates/locales/de/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/de/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/de/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/de/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/de/templates-markdown.js.map +1 -0
- package/dist/templates/locales/en/index.d.ts +14 -4
- package/dist/templates/locales/en/index.d.ts.map +1 -1
- package/dist/templates/locales/en/index.js +22 -25
- package/dist/templates/locales/en/index.js.map +1 -1
- package/dist/templates/locales/en/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/en/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/en/templates-asciidoc.js +764 -0
- package/dist/templates/locales/en/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/en/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/en/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/en/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/en/templates-markdown.js.map +1 -0
- package/dist/templates/locales/es/index.d.ts +15 -10
- package/dist/templates/locales/es/index.d.ts.map +1 -1
- package/dist/templates/locales/es/index.js +23 -31
- package/dist/templates/locales/es/index.js.map +1 -1
- package/dist/templates/locales/es/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/es/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/es/templates-asciidoc.js +764 -0
- package/dist/templates/locales/es/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/es/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/es/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/es/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/es/templates-markdown.js.map +1 -0
- package/dist/templates/locales/fr/index.d.ts +14 -9
- package/dist/templates/locales/fr/index.d.ts.map +1 -1
- package/dist/templates/locales/fr/index.js +22 -30
- package/dist/templates/locales/fr/index.js.map +1 -1
- package/dist/templates/locales/fr/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/fr/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/fr/templates-asciidoc.js +764 -0
- package/dist/templates/locales/fr/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/fr/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/fr/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/fr/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/fr/templates-markdown.js.map +1 -0
- package/dist/templates/locales/it/index.d.ts +14 -9
- package/dist/templates/locales/it/index.d.ts.map +1 -1
- package/dist/templates/locales/it/index.js +22 -30
- package/dist/templates/locales/it/index.js.map +1 -1
- package/dist/templates/locales/it/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/it/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/it/templates-asciidoc.js +764 -0
- package/dist/templates/locales/it/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/it/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/it/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/it/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/it/templates-markdown.js.map +1 -0
- package/dist/templates/locales/language-strategy-factory.d.ts +120 -0
- package/dist/templates/locales/language-strategy-factory.d.ts.map +1 -0
- package/dist/templates/locales/language-strategy-factory.js +127 -0
- package/dist/templates/locales/language-strategy-factory.js.map +1 -0
- package/dist/templates/locales/language-strategy.d.ts +16 -12
- package/dist/templates/locales/language-strategy.d.ts.map +1 -1
- package/dist/templates/locales/language-strategy.js.map +1 -1
- package/dist/templates/locales/nl/index.d.ts +14 -9
- package/dist/templates/locales/nl/index.d.ts.map +1 -1
- package/dist/templates/locales/nl/index.js +22 -30
- package/dist/templates/locales/nl/index.js.map +1 -1
- package/dist/templates/locales/nl/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/nl/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/nl/templates-asciidoc.js +764 -0
- package/dist/templates/locales/nl/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/nl/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/nl/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/nl/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/nl/templates-markdown.js.map +1 -0
- package/dist/templates/locales/pt/index.d.ts +14 -9
- package/dist/templates/locales/pt/index.d.ts.map +1 -1
- package/dist/templates/locales/pt/index.js +22 -30
- package/dist/templates/locales/pt/index.js.map +1 -1
- package/dist/templates/locales/pt/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/pt/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/pt/templates-asciidoc.js +764 -0
- package/dist/templates/locales/pt/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/pt/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/pt/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/pt/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/pt/templates-markdown.js.map +1 -0
- package/dist/templates/locales/ru/index.d.ts +19 -3
- package/dist/templates/locales/ru/index.d.ts.map +1 -1
- package/dist/templates/locales/ru/index.js +28 -24
- package/dist/templates/locales/ru/index.js.map +1 -1
- package/dist/templates/locales/ru/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/ru/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/ru/templates-asciidoc.js +996 -0
- package/dist/templates/locales/ru/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/ru/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/ru/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/ru/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/ru/templates-markdown.js.map +1 -0
- package/dist/templates/locales/template-provider.d.ts +22 -10
- package/dist/templates/locales/template-provider.d.ts.map +1 -1
- package/dist/templates/locales/template-provider.js +53 -14
- package/dist/templates/locales/template-provider.js.map +1 -1
- package/dist/templates/locales/ukr/index.d.ts +25 -3
- package/dist/templates/locales/ukr/index.d.ts.map +1 -1
- package/dist/templates/locales/ukr/index.js +34 -18
- package/dist/templates/locales/ukr/index.js.map +1 -1
- package/dist/templates/locales/ukr/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/ukr/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/ukr/templates-asciidoc.js +764 -0
- package/dist/templates/locales/ukr/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/ukr/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/ukr/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/ukr/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/ukr/templates-markdown.js.map +1 -0
- package/dist/templates/locales/zh/index.d.ts +25 -3
- package/dist/templates/locales/zh/index.d.ts.map +1 -1
- package/dist/templates/locales/zh/index.js +34 -18
- package/dist/templates/locales/zh/index.js.map +1 -1
- package/dist/templates/locales/zh/templates-asciidoc.d.ts +22 -0
- package/dist/templates/locales/zh/templates-asciidoc.d.ts.map +1 -0
- package/dist/templates/locales/zh/templates-asciidoc.js +764 -0
- package/dist/templates/locales/zh/templates-asciidoc.js.map +1 -0
- package/dist/templates/locales/zh/{templates.d.ts → templates-markdown.d.ts} +1 -1
- package/dist/templates/locales/zh/templates-markdown.d.ts.map +1 -0
- package/dist/templates/locales/zh/{templates.js → templates-markdown.js} +1 -1
- package/dist/templates/locales/zh/templates-markdown.js.map +1 -0
- package/dist/tools/arc42-init.d.ts +2 -1
- package/dist/tools/arc42-init.d.ts.map +1 -1
- package/dist/tools/arc42-init.js +154 -24
- package/dist/tools/arc42-init.js.map +1 -1
- package/dist/tools/arc42-status.d.ts.map +1 -1
- package/dist/tools/arc42-status.js +66 -10
- package/dist/tools/arc42-status.js.map +1 -1
- package/dist/tools/arc42-workflow-guide.d.ts +1 -0
- package/dist/tools/arc42-workflow-guide.d.ts.map +1 -1
- package/dist/tools/arc42-workflow-guide.js +16 -14
- package/dist/tools/arc42-workflow-guide.js.map +1 -1
- package/dist/tools/generate-template.d.ts +1 -0
- package/dist/tools/generate-template.d.ts.map +1 -1
- package/dist/tools/generate-template.js +16 -5
- package/dist/tools/generate-template.js.map +1 -1
- package/dist/tools/get-section.d.ts.map +1 -1
- package/dist/tools/get-section.js +28 -7
- package/dist/tools/get-section.js.map +1 -1
- package/dist/tools/update-section.d.ts +1 -1
- package/dist/tools/update-section.d.ts.map +1 -1
- package/dist/tools/update-section.js +71 -8
- package/dist/tools/update-section.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/templates/locales/cz/templates.d.ts.map +0 -1
- package/dist/templates/locales/cz/templates.js.map +0 -1
- package/dist/templates/locales/de/templates.d.ts.map +0 -1
- package/dist/templates/locales/de/templates.js.map +0 -1
- package/dist/templates/locales/en/templates.d.ts.map +0 -1
- package/dist/templates/locales/en/templates.js.map +0 -1
- package/dist/templates/locales/es/templates.d.ts.map +0 -1
- package/dist/templates/locales/es/templates.js.map +0 -1
- package/dist/templates/locales/fr/templates.d.ts.map +0 -1
- package/dist/templates/locales/fr/templates.js.map +0 -1
- package/dist/templates/locales/it/templates.d.ts.map +0 -1
- package/dist/templates/locales/it/templates.js.map +0 -1
- package/dist/templates/locales/nl/templates.d.ts.map +0 -1
- package/dist/templates/locales/nl/templates.js.map +0 -1
- package/dist/templates/locales/pt/templates.d.ts.map +0 -1
- package/dist/templates/locales/pt/templates.js.map +0 -1
- package/dist/templates/locales/ru/templates.d.ts.map +0 -1
- package/dist/templates/locales/ru/templates.js.map +0 -1
- package/dist/templates/locales/ukr/templates.d.ts.map +0 -1
- package/dist/templates/locales/ukr/templates.js.map +0 -1
- package/dist/templates/locales/zh/templates.d.ts.map +0 -1
- package/dist/templates/locales/zh/templates.js.map +0 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Format Registry
|
|
3
|
+
*
|
|
4
|
+
* Registry for storing and retrieving output format strategies.
|
|
5
|
+
* Uses Map for O(1) lookup by normalized format code.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/formats/output-format-registry
|
|
8
|
+
*
|
|
9
|
+
* S.O.L.I.D Principles:
|
|
10
|
+
* - SRP (Single Responsibility Principle): Only manages registration and lookup,
|
|
11
|
+
* not creation or content generation
|
|
12
|
+
*
|
|
13
|
+
* Design Patterns:
|
|
14
|
+
* - Registry Pattern: Single source of truth for format strategies
|
|
15
|
+
*/
|
|
16
|
+
import type { OutputFormatStrategy, OutputFormatCode } from './output-format-strategy.js';
|
|
17
|
+
/**
|
|
18
|
+
* Output Format Registry Class
|
|
19
|
+
*
|
|
20
|
+
* Manages the collection of output format strategies, providing registration,
|
|
21
|
+
* lookup, and enumeration capabilities with case-insensitive code handling.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const registry = new OutputFormatRegistry();
|
|
26
|
+
* registry.register(markdownStrategy);
|
|
27
|
+
* registry.register(asciidocStrategy);
|
|
28
|
+
*
|
|
29
|
+
* const strategy = registry.get('asciidoc'); // Case-insensitive
|
|
30
|
+
* const allCodes = registry.getAvailableCodes(); // ['markdown', 'asciidoc']
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class OutputFormatRegistry {
|
|
34
|
+
/**
|
|
35
|
+
* Internal map storing strategies by normalized (lowercase) format code
|
|
36
|
+
*/
|
|
37
|
+
private readonly strategies;
|
|
38
|
+
constructor();
|
|
39
|
+
/**
|
|
40
|
+
* Normalize a format code for consistent storage and lookup
|
|
41
|
+
*
|
|
42
|
+
* @param code - The format code to normalize
|
|
43
|
+
* @returns Lowercase, trimmed format code
|
|
44
|
+
*/
|
|
45
|
+
private normalizeCode;
|
|
46
|
+
/**
|
|
47
|
+
* Register an output format strategy
|
|
48
|
+
*
|
|
49
|
+
* Stores the strategy using its code (normalized to lowercase).
|
|
50
|
+
* If a strategy with the same code already exists, it will be overwritten.
|
|
51
|
+
*
|
|
52
|
+
* @param strategy - The output format strategy to register
|
|
53
|
+
* @returns This registry instance for method chaining
|
|
54
|
+
*/
|
|
55
|
+
register(strategy: OutputFormatStrategy): this;
|
|
56
|
+
/**
|
|
57
|
+
* Get an output format strategy by code
|
|
58
|
+
*
|
|
59
|
+
* Performs case-insensitive lookup.
|
|
60
|
+
*
|
|
61
|
+
* @param code - The format code to look up
|
|
62
|
+
* @returns The output format strategy, or undefined if not found
|
|
63
|
+
*/
|
|
64
|
+
get(code: string): OutputFormatStrategy | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Get an output format strategy by code, throwing if not found
|
|
67
|
+
*
|
|
68
|
+
* Performs case-insensitive lookup and throws a descriptive error
|
|
69
|
+
* if the requested format is not registered.
|
|
70
|
+
*
|
|
71
|
+
* @param code - The format code to look up
|
|
72
|
+
* @returns The output format strategy
|
|
73
|
+
* @throws Error if the format code is not registered
|
|
74
|
+
*/
|
|
75
|
+
getOrThrow(code: string): OutputFormatStrategy;
|
|
76
|
+
/**
|
|
77
|
+
* Get all registered output format strategies
|
|
78
|
+
*
|
|
79
|
+
* @returns Array of all registered strategies (copy, not the internal collection)
|
|
80
|
+
*/
|
|
81
|
+
getAll(): OutputFormatStrategy[];
|
|
82
|
+
/**
|
|
83
|
+
* Check if a format code is supported
|
|
84
|
+
*
|
|
85
|
+
* Performs case-insensitive check.
|
|
86
|
+
*
|
|
87
|
+
* @param code - The format code to check
|
|
88
|
+
* @returns True if the format is registered
|
|
89
|
+
*/
|
|
90
|
+
isSupported(code: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Get all available format codes
|
|
93
|
+
*
|
|
94
|
+
* @returns Array of all registered format codes (lowercase)
|
|
95
|
+
*/
|
|
96
|
+
getAvailableCodes(): OutputFormatCode[];
|
|
97
|
+
/**
|
|
98
|
+
* Get the default output format strategy (AsciiDoc)
|
|
99
|
+
*
|
|
100
|
+
* @returns The default (AsciiDoc) format strategy, or undefined if not registered
|
|
101
|
+
*/
|
|
102
|
+
getDefault(): OutputFormatStrategy | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Get the number of registered strategies
|
|
105
|
+
*/
|
|
106
|
+
get size(): number;
|
|
107
|
+
/**
|
|
108
|
+
* Remove all registered strategies
|
|
109
|
+
*
|
|
110
|
+
* @returns This registry instance for method chaining
|
|
111
|
+
*/
|
|
112
|
+
clear(): this;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=output-format-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-format-registry.d.ts","sourceRoot":"","sources":["../../../src/templates/formats/output-format-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG1F;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,oBAAoB;IAC/B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;;IAM/D;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI;IAM9C;;;;;;;OAOG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAKnD;;;;;;;;;OASG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB;IAY9C;;;;OAIG;IACH,MAAM,IAAI,oBAAoB,EAAE;IAIhC;;;;;;;OAOG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKlC;;;;OAIG;IACH,iBAAiB,IAAI,gBAAgB,EAAE;IAIvC;;;;OAIG;IACH,UAAU,IAAI,oBAAoB,GAAG,SAAS;IAI9C;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAId"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Format Registry
|
|
3
|
+
*
|
|
4
|
+
* Registry for storing and retrieving output format strategies.
|
|
5
|
+
* Uses Map for O(1) lookup by normalized format code.
|
|
6
|
+
*
|
|
7
|
+
* @module templates/formats/output-format-registry
|
|
8
|
+
*
|
|
9
|
+
* S.O.L.I.D Principles:
|
|
10
|
+
* - SRP (Single Responsibility Principle): Only manages registration and lookup,
|
|
11
|
+
* not creation or content generation
|
|
12
|
+
*
|
|
13
|
+
* Design Patterns:
|
|
14
|
+
* - Registry Pattern: Single source of truth for format strategies
|
|
15
|
+
*/
|
|
16
|
+
import { DEFAULT_OUTPUT_FORMAT } from './output-format-strategy.js';
|
|
17
|
+
/**
|
|
18
|
+
* Output Format Registry Class
|
|
19
|
+
*
|
|
20
|
+
* Manages the collection of output format strategies, providing registration,
|
|
21
|
+
* lookup, and enumeration capabilities with case-insensitive code handling.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const registry = new OutputFormatRegistry();
|
|
26
|
+
* registry.register(markdownStrategy);
|
|
27
|
+
* registry.register(asciidocStrategy);
|
|
28
|
+
*
|
|
29
|
+
* const strategy = registry.get('asciidoc'); // Case-insensitive
|
|
30
|
+
* const allCodes = registry.getAvailableCodes(); // ['markdown', 'asciidoc']
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export class OutputFormatRegistry {
|
|
34
|
+
/**
|
|
35
|
+
* Internal map storing strategies by normalized (lowercase) format code
|
|
36
|
+
*/
|
|
37
|
+
strategies;
|
|
38
|
+
constructor() {
|
|
39
|
+
this.strategies = new Map();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Normalize a format code for consistent storage and lookup
|
|
43
|
+
*
|
|
44
|
+
* @param code - The format code to normalize
|
|
45
|
+
* @returns Lowercase, trimmed format code
|
|
46
|
+
*/
|
|
47
|
+
normalizeCode(code) {
|
|
48
|
+
return code.trim().toLowerCase();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Register an output format strategy
|
|
52
|
+
*
|
|
53
|
+
* Stores the strategy using its code (normalized to lowercase).
|
|
54
|
+
* If a strategy with the same code already exists, it will be overwritten.
|
|
55
|
+
*
|
|
56
|
+
* @param strategy - The output format strategy to register
|
|
57
|
+
* @returns This registry instance for method chaining
|
|
58
|
+
*/
|
|
59
|
+
register(strategy) {
|
|
60
|
+
const normalizedCode = this.normalizeCode(strategy.code);
|
|
61
|
+
this.strategies.set(normalizedCode, strategy);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get an output format strategy by code
|
|
66
|
+
*
|
|
67
|
+
* Performs case-insensitive lookup.
|
|
68
|
+
*
|
|
69
|
+
* @param code - The format code to look up
|
|
70
|
+
* @returns The output format strategy, or undefined if not found
|
|
71
|
+
*/
|
|
72
|
+
get(code) {
|
|
73
|
+
const normalizedCode = this.normalizeCode(code);
|
|
74
|
+
return this.strategies.get(normalizedCode);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get an output format strategy by code, throwing if not found
|
|
78
|
+
*
|
|
79
|
+
* Performs case-insensitive lookup and throws a descriptive error
|
|
80
|
+
* if the requested format is not registered.
|
|
81
|
+
*
|
|
82
|
+
* @param code - The format code to look up
|
|
83
|
+
* @returns The output format strategy
|
|
84
|
+
* @throws Error if the format code is not registered
|
|
85
|
+
*/
|
|
86
|
+
getOrThrow(code) {
|
|
87
|
+
const strategy = this.get(code);
|
|
88
|
+
if (!strategy) {
|
|
89
|
+
const availableCodes = this.getAvailableCodes().join(', ');
|
|
90
|
+
throw new Error(`Output format "${code.trim().toLowerCase()}" is not registered. ` +
|
|
91
|
+
`Available formats: ${availableCodes || 'none'}`);
|
|
92
|
+
}
|
|
93
|
+
return strategy;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get all registered output format strategies
|
|
97
|
+
*
|
|
98
|
+
* @returns Array of all registered strategies (copy, not the internal collection)
|
|
99
|
+
*/
|
|
100
|
+
getAll() {
|
|
101
|
+
return Array.from(this.strategies.values());
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if a format code is supported
|
|
105
|
+
*
|
|
106
|
+
* Performs case-insensitive check.
|
|
107
|
+
*
|
|
108
|
+
* @param code - The format code to check
|
|
109
|
+
* @returns True if the format is registered
|
|
110
|
+
*/
|
|
111
|
+
isSupported(code) {
|
|
112
|
+
const normalizedCode = this.normalizeCode(code);
|
|
113
|
+
return this.strategies.has(normalizedCode);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get all available format codes
|
|
117
|
+
*
|
|
118
|
+
* @returns Array of all registered format codes (lowercase)
|
|
119
|
+
*/
|
|
120
|
+
getAvailableCodes() {
|
|
121
|
+
return Array.from(this.strategies.keys());
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the default output format strategy (AsciiDoc)
|
|
125
|
+
*
|
|
126
|
+
* @returns The default (AsciiDoc) format strategy, or undefined if not registered
|
|
127
|
+
*/
|
|
128
|
+
getDefault() {
|
|
129
|
+
return this.get(DEFAULT_OUTPUT_FORMAT);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get the number of registered strategies
|
|
133
|
+
*/
|
|
134
|
+
get size() {
|
|
135
|
+
return this.strategies.size;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Remove all registered strategies
|
|
139
|
+
*
|
|
140
|
+
* @returns This registry instance for method chaining
|
|
141
|
+
*/
|
|
142
|
+
clear() {
|
|
143
|
+
this.strategies.clear();
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=output-format-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-format-registry.js","sourceRoot":"","sources":["../../../src/templates/formats/output-format-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,oBAAoB;IAC/B;;OAEG;IACc,UAAU,CAAoC;IAE/D;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACK,aAAa,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAA8B;QACrC,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,IAAY;QACd,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;OASG;IACH,UAAU,CAAC,IAAY;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CACb,kBAAkB,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,uBAAuB;gBAClE,sBAAsB,cAAc,IAAI,MAAM,EAAE,CACjD,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;OAOG;IACH,WAAW,CAAC,IAAY;QACtB,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,iBAAiB;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAuB,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Format Strategy
|
|
3
|
+
*
|
|
4
|
+
* Defines the interface for output format strategies that handle
|
|
5
|
+
* format-specific syntax generation (Markdown, AsciiDoc, etc.).
|
|
6
|
+
*
|
|
7
|
+
* @module templates/formats/output-format-strategy
|
|
8
|
+
*
|
|
9
|
+
* S.O.L.I.D Principles:
|
|
10
|
+
* - SRP (Single Responsibility Principle): Each strategy only handles
|
|
11
|
+
* format-specific syntax generation
|
|
12
|
+
* - ISP (Interface Segregation Principle): Focused interface with only
|
|
13
|
+
* necessary methods for format conversion
|
|
14
|
+
*
|
|
15
|
+
* Design Patterns:
|
|
16
|
+
* - Strategy Pattern: Interchangeable format implementations
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Supported output format codes
|
|
20
|
+
*/
|
|
21
|
+
export type OutputFormatCode = 'markdown' | 'asciidoc';
|
|
22
|
+
/**
|
|
23
|
+
* Array of all supported output format codes
|
|
24
|
+
*/
|
|
25
|
+
export declare const SUPPORTED_OUTPUT_FORMAT_CODES: readonly OutputFormatCode[];
|
|
26
|
+
/**
|
|
27
|
+
* Alias mappings for format code normalization
|
|
28
|
+
*
|
|
29
|
+
* Maps common format aliases to their canonical format codes.
|
|
30
|
+
* Used by OutputFormatFactory for flexible format specification.
|
|
31
|
+
*/
|
|
32
|
+
export declare const OUTPUT_FORMAT_ALIASES: Record<string, OutputFormatCode>;
|
|
33
|
+
/**
|
|
34
|
+
* Default output format when not specified
|
|
35
|
+
*
|
|
36
|
+
* AsciiDoc is the default format for new projects.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_OUTPUT_FORMAT: OutputFormatCode;
|
|
39
|
+
/**
|
|
40
|
+
* Output Format Strategy Interface
|
|
41
|
+
*
|
|
42
|
+
* Defines the contract for all output format implementations.
|
|
43
|
+
* Each format strategy converts content to its specific syntax.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* class MarkdownFormatStrategy implements OutputFormatStrategy {
|
|
48
|
+
* code = 'markdown' as const;
|
|
49
|
+
* name = 'Markdown';
|
|
50
|
+
* fileExtension = '.md';
|
|
51
|
+
*
|
|
52
|
+
* formatHeading(text: string, level: number): string {
|
|
53
|
+
* return '#'.repeat(level) + ' ' + text;
|
|
54
|
+
* }
|
|
55
|
+
* // ... other methods
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export interface OutputFormatStrategy {
|
|
60
|
+
/**
|
|
61
|
+
* Unique format code identifier
|
|
62
|
+
*/
|
|
63
|
+
readonly code: OutputFormatCode;
|
|
64
|
+
/**
|
|
65
|
+
* Human-readable format name
|
|
66
|
+
*/
|
|
67
|
+
readonly name: string;
|
|
68
|
+
/**
|
|
69
|
+
* File extension for this format (including dot)
|
|
70
|
+
*/
|
|
71
|
+
readonly fileExtension: string;
|
|
72
|
+
/**
|
|
73
|
+
* Format a heading at the specified level
|
|
74
|
+
*
|
|
75
|
+
* @param text - The heading text
|
|
76
|
+
* @param level - Heading level (1-6)
|
|
77
|
+
* @returns Formatted heading string
|
|
78
|
+
*/
|
|
79
|
+
formatHeading(text: string, level: number): string;
|
|
80
|
+
/**
|
|
81
|
+
* Format text as bold
|
|
82
|
+
*
|
|
83
|
+
* @param text - The text to make bold
|
|
84
|
+
* @returns Bold formatted text
|
|
85
|
+
*/
|
|
86
|
+
formatBold(text: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* Format text as italic
|
|
89
|
+
*
|
|
90
|
+
* @param text - The text to make italic
|
|
91
|
+
* @returns Italic formatted text
|
|
92
|
+
*/
|
|
93
|
+
formatItalic(text: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Format a code block with optional language
|
|
96
|
+
*
|
|
97
|
+
* @param code - The code content
|
|
98
|
+
* @param language - Optional language identifier for syntax highlighting
|
|
99
|
+
* @returns Formatted code block
|
|
100
|
+
*/
|
|
101
|
+
formatCode(code: string, language?: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* Format inline code
|
|
104
|
+
*
|
|
105
|
+
* @param text - The code text
|
|
106
|
+
* @returns Inline code formatted text
|
|
107
|
+
*/
|
|
108
|
+
formatInlineCode(text: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Format an unordered (bulleted) list
|
|
111
|
+
*
|
|
112
|
+
* @param items - Array of list items
|
|
113
|
+
* @returns Formatted unordered list
|
|
114
|
+
*/
|
|
115
|
+
formatUnorderedList(items: string[]): string;
|
|
116
|
+
/**
|
|
117
|
+
* Format an ordered (numbered) list
|
|
118
|
+
*
|
|
119
|
+
* @param items - Array of list items
|
|
120
|
+
* @returns Formatted ordered list
|
|
121
|
+
*/
|
|
122
|
+
formatOrderedList(items: string[]): string;
|
|
123
|
+
/**
|
|
124
|
+
* Format a hyperlink
|
|
125
|
+
*
|
|
126
|
+
* @param text - Link display text
|
|
127
|
+
* @param url - Link URL
|
|
128
|
+
* @returns Formatted link
|
|
129
|
+
*/
|
|
130
|
+
formatLink(text: string, url: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Format an image
|
|
133
|
+
*
|
|
134
|
+
* @param alt - Alternative text for the image
|
|
135
|
+
* @param url - Image URL or path
|
|
136
|
+
* @returns Formatted image reference
|
|
137
|
+
*/
|
|
138
|
+
formatImage(alt: string, url: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Format a table
|
|
141
|
+
*
|
|
142
|
+
* @param headers - Array of column headers
|
|
143
|
+
* @param rows - 2D array of row data
|
|
144
|
+
* @returns Formatted table
|
|
145
|
+
*/
|
|
146
|
+
formatTable(headers: string[], rows: string[][]): string;
|
|
147
|
+
/**
|
|
148
|
+
* Format a blockquote
|
|
149
|
+
*
|
|
150
|
+
* @param text - The quote text (may contain newlines)
|
|
151
|
+
* @returns Formatted blockquote
|
|
152
|
+
*/
|
|
153
|
+
formatBlockquote(text: string): string;
|
|
154
|
+
/**
|
|
155
|
+
* Format a horizontal rule/divider
|
|
156
|
+
*
|
|
157
|
+
* @returns Formatted horizontal rule
|
|
158
|
+
*/
|
|
159
|
+
formatHorizontalRule(): string;
|
|
160
|
+
/**
|
|
161
|
+
* Format an anchor/bookmark
|
|
162
|
+
*
|
|
163
|
+
* @param id - The anchor identifier
|
|
164
|
+
* @returns Formatted anchor (maybe empty for formats that auto-generate anchors)
|
|
165
|
+
*/
|
|
166
|
+
formatAnchor(id: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* Get the README filename for this format
|
|
169
|
+
*
|
|
170
|
+
* @returns README filename (e.g., 'README.md', 'README.adoc')
|
|
171
|
+
*/
|
|
172
|
+
getReadmeFilename(): string;
|
|
173
|
+
/**
|
|
174
|
+
* Get the section filename for a given section
|
|
175
|
+
*
|
|
176
|
+
* @param section - The section identifier
|
|
177
|
+
* @returns Section filename with appropriate extension
|
|
178
|
+
*/
|
|
179
|
+
getSectionFilename(section: string): string;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Type guard to check if a string is a valid OutputFormatCode
|
|
183
|
+
*
|
|
184
|
+
* @param code - The code to check
|
|
185
|
+
* @returns True if the code is a valid OutputFormatCode
|
|
186
|
+
*/
|
|
187
|
+
export declare function isOutputFormatCode(code: string): code is OutputFormatCode;
|
|
188
|
+
/**
|
|
189
|
+
* Normalize a format code string to its canonical form
|
|
190
|
+
*
|
|
191
|
+
* @param code - The format code to normalize (case-insensitive)
|
|
192
|
+
* @returns The normalized format code, or undefined if not recognized
|
|
193
|
+
*/
|
|
194
|
+
export declare function normalizeOutputFormatCode(code: string): OutputFormatCode | undefined;
|
|
195
|
+
//# sourceMappingURL=output-format-strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-format-strategy.d.ts","sourceRoot":"","sources":["../../../src/templates/formats/output-format-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,UAAU,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,gBAAgB,EAG3D,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAalE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,gBAA6B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAM/B;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEnD;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAEjC;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAEnC;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEpD;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAMvC;;;;;OAKG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAE7C;;;;;OAKG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAM3C;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAE9C;;;;;;OAMG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAM9C;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC;IAEzD;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvC;;;;OAIG;IACH,oBAAoB,IAAI,MAAM,CAAC;IAE/B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAMjC;;;;OAIG;IACH,iBAAiB,IAAI,MAAM,CAAC;IAE5B;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,gBAAgB,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAGpF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Format Strategy
|
|
3
|
+
*
|
|
4
|
+
* Defines the interface for output format strategies that handle
|
|
5
|
+
* format-specific syntax generation (Markdown, AsciiDoc, etc.).
|
|
6
|
+
*
|
|
7
|
+
* @module templates/formats/output-format-strategy
|
|
8
|
+
*
|
|
9
|
+
* S.O.L.I.D Principles:
|
|
10
|
+
* - SRP (Single Responsibility Principle): Each strategy only handles
|
|
11
|
+
* format-specific syntax generation
|
|
12
|
+
* - ISP (Interface Segregation Principle): Focused interface with only
|
|
13
|
+
* necessary methods for format conversion
|
|
14
|
+
*
|
|
15
|
+
* Design Patterns:
|
|
16
|
+
* - Strategy Pattern: Interchangeable format implementations
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Array of all supported output format codes
|
|
20
|
+
*/
|
|
21
|
+
export const SUPPORTED_OUTPUT_FORMAT_CODES = [
|
|
22
|
+
'markdown',
|
|
23
|
+
'asciidoc'
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Alias mappings for format code normalization
|
|
27
|
+
*
|
|
28
|
+
* Maps common format aliases to their canonical format codes.
|
|
29
|
+
* Used by OutputFormatFactory for flexible format specification.
|
|
30
|
+
*/
|
|
31
|
+
export const OUTPUT_FORMAT_ALIASES = {
|
|
32
|
+
// Markdown aliases
|
|
33
|
+
'md': 'markdown',
|
|
34
|
+
'markdown': 'markdown',
|
|
35
|
+
'mdown': 'markdown',
|
|
36
|
+
'mkd': 'markdown',
|
|
37
|
+
// AsciiDoc aliases
|
|
38
|
+
'adoc': 'asciidoc',
|
|
39
|
+
'asciidoc': 'asciidoc',
|
|
40
|
+
'ascii': 'asciidoc',
|
|
41
|
+
'asciidoctor': 'asciidoc',
|
|
42
|
+
'asc': 'asciidoc'
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Default output format when not specified
|
|
46
|
+
*
|
|
47
|
+
* AsciiDoc is the default format for new projects.
|
|
48
|
+
*/
|
|
49
|
+
export const DEFAULT_OUTPUT_FORMAT = 'asciidoc';
|
|
50
|
+
/**
|
|
51
|
+
* Type guard to check if a string is a valid OutputFormatCode
|
|
52
|
+
*
|
|
53
|
+
* @param code - The code to check
|
|
54
|
+
* @returns True if the code is a valid OutputFormatCode
|
|
55
|
+
*/
|
|
56
|
+
export function isOutputFormatCode(code) {
|
|
57
|
+
return SUPPORTED_OUTPUT_FORMAT_CODES.includes(code);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Normalize a format code string to its canonical form
|
|
61
|
+
*
|
|
62
|
+
* @param code - The format code to normalize (case-insensitive)
|
|
63
|
+
* @returns The normalized format code, or undefined if not recognized
|
|
64
|
+
*/
|
|
65
|
+
export function normalizeOutputFormatCode(code) {
|
|
66
|
+
const normalized = code.trim().toLowerCase();
|
|
67
|
+
return OUTPUT_FORMAT_ALIASES[normalized];
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=output-format-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-format-strategy.js","sourceRoot":"","sources":["../../../src/templates/formats/output-format-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAgC;IACxE,UAAU;IACV,UAAU;CACF,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqC;IACrE,mBAAmB;IACnB,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,UAAU;IACtB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IAEjB,mBAAmB;IACnB,MAAM,EAAE,UAAU;IAClB,UAAU,EAAE,UAAU;IACtB,OAAO,EAAE,UAAU;IACnB,aAAa,EAAE,UAAU;IACzB,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqB,UAAU,CAAC;AAsLlE;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,6BAA6B,CAAC,QAAQ,CAAC,IAAwB,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7C,OAAO,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
* @module templates
|
|
9
9
|
*/
|
|
10
10
|
import { Arc42Section } from '../types.js';
|
|
11
|
+
import type { OutputFormatCode } from './formats/index.js';
|
|
11
12
|
export { ARC42_REFERENCE, Arc42Reference, getArc42ReferenceString, getArc42ReferenceMarkdown, getArc42ReferenceConfig, reloadArc42Reference } from './arc42-reference.js';
|
|
12
13
|
export { type LanguageCode, type SectionTitle, type SectionDescription, type LanguageInfo, type LanguageStrategy, type LocalizedSectionMetadata, SUPPORTED_LANGUAGE_CODES, isLanguageCode, normalizeLanguageCode, getDefaultLanguageCode, isInitialized, LanguageRegistry, LanguageFactory, LocalizedTemplateProvider, languageRegistry, languageFactory, templateProvider, englishStrategy } from './locales/index.js';
|
|
14
|
+
export { type OutputFormatStrategy, type OutputFormatCode, SUPPORTED_OUTPUT_FORMAT_CODES, OUTPUT_FORMAT_ALIASES, DEFAULT_OUTPUT_FORMAT, isOutputFormatCode, normalizeOutputFormatCode, isOutputFormatSupported, getSupportedOutputFormatCodes, detectOutputFormatFromExtension, detectOutputFormatFromFilename, OutputFormatRegistry, OutputFormatFactory, MarkdownFormatStrategy, AsciiDocFormatStrategy, outputFormatRegistry, outputFormatFactory, markdownFormatStrategy, asciidocFormatStrategy, getOutputFormatStrategy, getOutputFormatStrategyWithFallback, getDefaultOutputFormatStrategy } from './formats/index.js';
|
|
13
15
|
/**
|
|
14
|
-
* Get template for a specific arc42 section
|
|
15
|
-
*
|
|
16
|
-
* This function maintains backward compatibility with the original API
|
|
17
|
-
* while delegating to the new locales system.
|
|
16
|
+
* Get template for a specific arc42 section in a specific format
|
|
18
17
|
*
|
|
19
18
|
* @param section - The arc42 section to get the template for
|
|
20
19
|
* @param language - Optional language code (defaults to English)
|
|
21
|
-
* @
|
|
20
|
+
* @param format - Optional output format (defaults to AsciiDoc)
|
|
21
|
+
* @returns The template content in the specified format
|
|
22
22
|
*/
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function getTemplateForFormat(section: Arc42Section, language?: string, format?: OutputFormatCode): string;
|
|
24
24
|
/**
|
|
25
25
|
* Get localized section metadata
|
|
26
26
|
*
|
|
@@ -30,12 +30,13 @@ export declare function getSectionTemplate(section: Arc42Section, language?: str
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function getSectionMetadata(section: Arc42Section, language?: string): import("./locales/template-provider.js").LocalizedSectionMetadata;
|
|
32
32
|
/**
|
|
33
|
-
* Get the workflow guide
|
|
33
|
+
* Get the workflow guide in a specific format
|
|
34
34
|
*
|
|
35
35
|
* @param language - Optional language code (defaults to English)
|
|
36
|
+
* @param format - Optional output format (defaults to AsciiDoc)
|
|
36
37
|
* @returns The workflow guide content
|
|
37
38
|
*/
|
|
38
|
-
export declare function
|
|
39
|
+
export declare function getWorkflowGuideForFormat(language?: string, format?: OutputFormatCode): string;
|
|
39
40
|
/**
|
|
40
41
|
* Get available languages
|
|
41
42
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAG7B,wBAAwB,EAGxB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EAGb,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EAGzB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAGhB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAGrB,6BAA6B,EAC7B,qBAAqB,EACrB,qBAAqB,EAGrB,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,+BAA+B,EAC/B,8BAA8B,EAG9B,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EAGtB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EAGtB,uBAAuB,EACvB,mCAAmC,EACnC,8BAA8B,EAC/B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,YAAY,EACrB,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,gBAAgB,GACxB,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,qEAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAE9F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,4DAEpC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
package/dist/templates/index.js
CHANGED
|
@@ -22,18 +22,28 @@ LanguageRegistry, LanguageFactory, LocalizedTemplateProvider,
|
|
|
22
22
|
languageRegistry, languageFactory, templateProvider,
|
|
23
23
|
// English strategy
|
|
24
24
|
englishStrategy } from './locales/index.js';
|
|
25
|
+
// Re-export formats module for multi-format support
|
|
26
|
+
export {
|
|
27
|
+
// Constants
|
|
28
|
+
SUPPORTED_OUTPUT_FORMAT_CODES, OUTPUT_FORMAT_ALIASES, DEFAULT_OUTPUT_FORMAT,
|
|
29
|
+
// Utility functions
|
|
30
|
+
isOutputFormatCode, normalizeOutputFormatCode, isOutputFormatSupported, getSupportedOutputFormatCodes, detectOutputFormatFromExtension, detectOutputFormatFromFilename,
|
|
31
|
+
// Classes
|
|
32
|
+
OutputFormatRegistry, OutputFormatFactory, MarkdownFormatStrategy, AsciiDocFormatStrategy,
|
|
33
|
+
// Singleton instances
|
|
34
|
+
outputFormatRegistry, outputFormatFactory, markdownFormatStrategy, asciidocFormatStrategy,
|
|
35
|
+
// Convenience functions
|
|
36
|
+
getOutputFormatStrategy, getOutputFormatStrategyWithFallback, getDefaultOutputFormatStrategy } from './formats/index.js';
|
|
25
37
|
/**
|
|
26
|
-
* Get template for a specific arc42 section
|
|
27
|
-
*
|
|
28
|
-
* This function maintains backward compatibility with the original API
|
|
29
|
-
* while delegating to the new locales system.
|
|
38
|
+
* Get template for a specific arc42 section in a specific format
|
|
30
39
|
*
|
|
31
40
|
* @param section - The arc42 section to get the template for
|
|
32
41
|
* @param language - Optional language code (defaults to English)
|
|
33
|
-
* @
|
|
42
|
+
* @param format - Optional output format (defaults to AsciiDoc)
|
|
43
|
+
* @returns The template content in the specified format
|
|
34
44
|
*/
|
|
35
|
-
export function
|
|
36
|
-
return templateProvider.
|
|
45
|
+
export function getTemplateForFormat(section, language, format) {
|
|
46
|
+
return templateProvider.getTemplateForFormat(section, language, format);
|
|
37
47
|
}
|
|
38
48
|
/**
|
|
39
49
|
* Get localized section metadata
|
|
@@ -46,13 +56,14 @@ export function getSectionMetadata(section, language) {
|
|
|
46
56
|
return templateProvider.getSectionMetadata(section, language);
|
|
47
57
|
}
|
|
48
58
|
/**
|
|
49
|
-
* Get the workflow guide
|
|
59
|
+
* Get the workflow guide in a specific format
|
|
50
60
|
*
|
|
51
61
|
* @param language - Optional language code (defaults to English)
|
|
62
|
+
* @param format - Optional output format (defaults to AsciiDoc)
|
|
52
63
|
* @returns The workflow guide content
|
|
53
64
|
*/
|
|
54
|
-
export function
|
|
55
|
-
return templateProvider.
|
|
65
|
+
export function getWorkflowGuideForFormat(language, format) {
|
|
66
|
+
return templateProvider.getWorkflowGuideForFormat(language, format);
|
|
56
67
|
}
|
|
57
68
|
/**
|
|
58
69
|
* Get available languages
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,wCAAwC;AACxC,OAAO,EACL,eAAe,EAEf,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,sDAAsD;AACtD,OAAO;AASL,YAAY;AACZ,wBAAwB;AAExB,oBAAoB;AACpB,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,aAAa;AAEb,UAAU;AACV,gBAAgB,EAChB,eAAe,EACf,yBAAyB;AAEzB,sBAAsB;AACtB,gBAAgB,EAChB,eAAe,EACf,gBAAgB;AAEhB,mBAAmB;AACnB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAE5B,oDAAoD;AACpD,OAAO;AAKL,YAAY;AACZ,6BAA6B,EAC7B,qBAAqB,EACrB,qBAAqB;AAErB,oBAAoB;AACpB,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,+BAA+B,EAC/B,8BAA8B;AAE9B,UAAU;AACV,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB;AAEtB,sBAAsB;AACtB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB;AAEtB,wBAAwB;AACxB,uBAAuB,EACvB,mCAAmC,EACnC,8BAA8B,EAC/B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAqB,EACrB,QAAiB,EACjB,MAAyB;IAEzB,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAqB,EAAE,QAAiB;IACzE,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAiB,EAAE,MAAyB;IACpF,OAAO,gBAAgB,CAAC,yBAAyB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,gBAAgB,CAAC,qBAAqB,EAAE,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,OAAO,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC"}
|