@contractspec/integration.example-generator 10.0.0 → 11.0.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/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +34 -0
- package/dist/generator.d.ts +11 -0
- package/dist/generator.d.ts.map +1 -0
- package/dist/generator.js +86 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +89 -0
- package/dist/node/config.js +33 -0
- package/dist/node/generator.js +85 -0
- package/dist/node/index.js +88 -0
- package/dist/node/types.js +38 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +39 -0
- package/package.json +46 -20
- package/dist/index.d.mts +0 -123
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -91
- package/dist/index.mjs.map +0 -1
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ExampleGeneratorPluginConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration for the ExampleGeneratorPlugin
|
|
4
|
+
*/
|
|
5
|
+
export declare const defaultConfig: ExampleGeneratorPluginConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Merge user config with defaults
|
|
8
|
+
*/
|
|
9
|
+
export declare function mergeConfig(userConfig: Partial<ExampleGeneratorPluginConfig>): ExampleGeneratorPluginConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Validate configuration
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateConfig(config: ExampleGeneratorPluginConfig): void;
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,4BAM3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,OAAO,CAAC,4BAA4B,CAAC,GAChD,4BAA4B,CAK9B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,4BAA4B,GAAG,IAAI,CAmBzE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/config.ts
|
|
3
|
+
var defaultConfig = {
|
|
4
|
+
outputDir: "./docs",
|
|
5
|
+
format: "auto",
|
|
6
|
+
maxItems: 100,
|
|
7
|
+
maxDepth: 2,
|
|
8
|
+
excludeFields: []
|
|
9
|
+
};
|
|
10
|
+
function mergeConfig(userConfig) {
|
|
11
|
+
return {
|
|
12
|
+
...defaultConfig,
|
|
13
|
+
...userConfig
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function validateConfig(config) {
|
|
17
|
+
if (!config.outputDir) {
|
|
18
|
+
throw new Error("outputDir is required");
|
|
19
|
+
}
|
|
20
|
+
if (config.format && !["table", "list", "detail", "auto"].includes(config.format)) {
|
|
21
|
+
throw new Error("format must be one of: table, list, detail, auto");
|
|
22
|
+
}
|
|
23
|
+
if (config.maxItems !== undefined && config.maxItems < 1) {
|
|
24
|
+
throw new Error("maxItems must be greater than 0");
|
|
25
|
+
}
|
|
26
|
+
if (config.maxDepth !== undefined && config.maxDepth < 1) {
|
|
27
|
+
throw new Error("maxDepth must be greater than 0");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
validateConfig,
|
|
32
|
+
mergeConfig,
|
|
33
|
+
defaultConfig
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExampleGeneratorPluginConfig, GeneratorContext, GeneratorResult, PluginMetadata } from './types.js';
|
|
2
|
+
export declare class ExampleGeneratorPlugin {
|
|
3
|
+
private config;
|
|
4
|
+
private readonly metadata;
|
|
5
|
+
constructor(config?: Partial<ExampleGeneratorPluginConfig>);
|
|
6
|
+
getConfig(): ExampleGeneratorPluginConfig;
|
|
7
|
+
updateConfig(config: Partial<ExampleGeneratorPluginConfig>): void;
|
|
8
|
+
getMetadata(): PluginMetadata;
|
|
9
|
+
generate(context: GeneratorContext): Promise<GeneratorResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;gBAE9B,MAAM,GAAE,OAAO,CAAC,4BAA4B,CAAM;IAa9D,SAAS,IAAI,4BAA4B;IAIzC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,4BAA4B,CAAC,GAAG,IAAI;IAMjE,WAAW,IAAI,cAAc;IAIvB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;CA2BpE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/config.ts
|
|
3
|
+
var defaultConfig = {
|
|
4
|
+
outputDir: "./docs",
|
|
5
|
+
format: "auto",
|
|
6
|
+
maxItems: 100,
|
|
7
|
+
maxDepth: 2,
|
|
8
|
+
excludeFields: []
|
|
9
|
+
};
|
|
10
|
+
function mergeConfig(userConfig) {
|
|
11
|
+
return {
|
|
12
|
+
...defaultConfig,
|
|
13
|
+
...userConfig
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function validateConfig(config) {
|
|
17
|
+
if (!config.outputDir) {
|
|
18
|
+
throw new Error("outputDir is required");
|
|
19
|
+
}
|
|
20
|
+
if (config.format && !["table", "list", "detail", "auto"].includes(config.format)) {
|
|
21
|
+
throw new Error("format must be one of: table, list, detail, auto");
|
|
22
|
+
}
|
|
23
|
+
if (config.maxItems !== undefined && config.maxItems < 1) {
|
|
24
|
+
throw new Error("maxItems must be greater than 0");
|
|
25
|
+
}
|
|
26
|
+
if (config.maxDepth !== undefined && config.maxDepth < 1) {
|
|
27
|
+
throw new Error("maxDepth must be greater than 0");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/generator.ts
|
|
32
|
+
import { mkdirSync, writeFileSync } from "fs";
|
|
33
|
+
import { join } from "path";
|
|
34
|
+
class ExampleGeneratorPlugin {
|
|
35
|
+
config;
|
|
36
|
+
metadata;
|
|
37
|
+
constructor(config = {}) {
|
|
38
|
+
const merged = mergeConfig(config);
|
|
39
|
+
validateConfig(merged);
|
|
40
|
+
this.config = merged;
|
|
41
|
+
this.metadata = {
|
|
42
|
+
id: "example-generator",
|
|
43
|
+
name: "@contractspec/integration.example-generator",
|
|
44
|
+
version: "1.0.0",
|
|
45
|
+
description: "Example markdown documentation generator",
|
|
46
|
+
author: "ContractSpec"
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
getConfig() {
|
|
50
|
+
return { ...this.config };
|
|
51
|
+
}
|
|
52
|
+
updateConfig(config) {
|
|
53
|
+
const merged = mergeConfig({ ...this.config, ...config });
|
|
54
|
+
validateConfig(merged);
|
|
55
|
+
this.config = merged;
|
|
56
|
+
}
|
|
57
|
+
getMetadata() {
|
|
58
|
+
return { ...this.metadata };
|
|
59
|
+
}
|
|
60
|
+
async generate(context) {
|
|
61
|
+
if (!context.spec) {
|
|
62
|
+
throw new Error("Spec is required to generate documentation");
|
|
63
|
+
}
|
|
64
|
+
const outputDir = this.config.outputDir;
|
|
65
|
+
mkdirSync(outputDir, { recursive: true });
|
|
66
|
+
const fileName = "spec-" + Date.now() + ".md";
|
|
67
|
+
const outputPath = join(outputDir, fileName);
|
|
68
|
+
const content = `# Spec Documentation
|
|
69
|
+
|
|
70
|
+
Generated for spec: ${String(context.spec.id ?? "unknown")}`;
|
|
71
|
+
writeFileSync(outputPath, content, "utf8");
|
|
72
|
+
return {
|
|
73
|
+
outputPath,
|
|
74
|
+
itemCount: 1,
|
|
75
|
+
metadata: {
|
|
76
|
+
specId: String(context.spec.id ?? "unknown"),
|
|
77
|
+
generatedAt: new Date,
|
|
78
|
+
format: this.config.format ?? "auto",
|
|
79
|
+
config: this.config
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
ExampleGeneratorPlugin
|
|
86
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @contractspec/lib.plugin.example-generator
|
|
3
|
+
* Example plugin: Markdown documentation generator for ContractSpec specs
|
|
4
|
+
*/
|
|
5
|
+
export { ExampleGeneratorPlugin } from './generator.js';
|
|
6
|
+
export type { ExampleGeneratorPluginConfig, GeneratorResult, PluginMetadata, ExampleGeneratorError, ValidationError, ConfigurationError, GenerationError, } from './types.js';
|
|
7
|
+
export { defaultConfig, mergeConfig, validateConfig } from './config.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,YAAY,EACV,4BAA4B,EAC5B,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/config.ts
|
|
3
|
+
var defaultConfig = {
|
|
4
|
+
outputDir: "./docs",
|
|
5
|
+
format: "auto",
|
|
6
|
+
maxItems: 100,
|
|
7
|
+
maxDepth: 2,
|
|
8
|
+
excludeFields: []
|
|
9
|
+
};
|
|
10
|
+
function mergeConfig(userConfig) {
|
|
11
|
+
return {
|
|
12
|
+
...defaultConfig,
|
|
13
|
+
...userConfig
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function validateConfig(config) {
|
|
17
|
+
if (!config.outputDir) {
|
|
18
|
+
throw new Error("outputDir is required");
|
|
19
|
+
}
|
|
20
|
+
if (config.format && !["table", "list", "detail", "auto"].includes(config.format)) {
|
|
21
|
+
throw new Error("format must be one of: table, list, detail, auto");
|
|
22
|
+
}
|
|
23
|
+
if (config.maxItems !== undefined && config.maxItems < 1) {
|
|
24
|
+
throw new Error("maxItems must be greater than 0");
|
|
25
|
+
}
|
|
26
|
+
if (config.maxDepth !== undefined && config.maxDepth < 1) {
|
|
27
|
+
throw new Error("maxDepth must be greater than 0");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/generator.ts
|
|
32
|
+
import { mkdirSync, writeFileSync } from "fs";
|
|
33
|
+
import { join } from "path";
|
|
34
|
+
class ExampleGeneratorPlugin {
|
|
35
|
+
config;
|
|
36
|
+
metadata;
|
|
37
|
+
constructor(config = {}) {
|
|
38
|
+
const merged = mergeConfig(config);
|
|
39
|
+
validateConfig(merged);
|
|
40
|
+
this.config = merged;
|
|
41
|
+
this.metadata = {
|
|
42
|
+
id: "example-generator",
|
|
43
|
+
name: "@contractspec/integration.example-generator",
|
|
44
|
+
version: "1.0.0",
|
|
45
|
+
description: "Example markdown documentation generator",
|
|
46
|
+
author: "ContractSpec"
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
getConfig() {
|
|
50
|
+
return { ...this.config };
|
|
51
|
+
}
|
|
52
|
+
updateConfig(config) {
|
|
53
|
+
const merged = mergeConfig({ ...this.config, ...config });
|
|
54
|
+
validateConfig(merged);
|
|
55
|
+
this.config = merged;
|
|
56
|
+
}
|
|
57
|
+
getMetadata() {
|
|
58
|
+
return { ...this.metadata };
|
|
59
|
+
}
|
|
60
|
+
async generate(context) {
|
|
61
|
+
if (!context.spec) {
|
|
62
|
+
throw new Error("Spec is required to generate documentation");
|
|
63
|
+
}
|
|
64
|
+
const outputDir = this.config.outputDir;
|
|
65
|
+
mkdirSync(outputDir, { recursive: true });
|
|
66
|
+
const fileName = "spec-" + Date.now() + ".md";
|
|
67
|
+
const outputPath = join(outputDir, fileName);
|
|
68
|
+
const content = `# Spec Documentation
|
|
69
|
+
|
|
70
|
+
Generated for spec: ${String(context.spec.id ?? "unknown")}`;
|
|
71
|
+
writeFileSync(outputPath, content, "utf8");
|
|
72
|
+
return {
|
|
73
|
+
outputPath,
|
|
74
|
+
itemCount: 1,
|
|
75
|
+
metadata: {
|
|
76
|
+
specId: String(context.spec.id ?? "unknown"),
|
|
77
|
+
generatedAt: new Date,
|
|
78
|
+
format: this.config.format ?? "auto",
|
|
79
|
+
config: this.config
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
validateConfig,
|
|
86
|
+
mergeConfig,
|
|
87
|
+
defaultConfig,
|
|
88
|
+
ExampleGeneratorPlugin
|
|
89
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
var defaultConfig = {
|
|
3
|
+
outputDir: "./docs",
|
|
4
|
+
format: "auto",
|
|
5
|
+
maxItems: 100,
|
|
6
|
+
maxDepth: 2,
|
|
7
|
+
excludeFields: []
|
|
8
|
+
};
|
|
9
|
+
function mergeConfig(userConfig) {
|
|
10
|
+
return {
|
|
11
|
+
...defaultConfig,
|
|
12
|
+
...userConfig
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function validateConfig(config) {
|
|
16
|
+
if (!config.outputDir) {
|
|
17
|
+
throw new Error("outputDir is required");
|
|
18
|
+
}
|
|
19
|
+
if (config.format && !["table", "list", "detail", "auto"].includes(config.format)) {
|
|
20
|
+
throw new Error("format must be one of: table, list, detail, auto");
|
|
21
|
+
}
|
|
22
|
+
if (config.maxItems !== undefined && config.maxItems < 1) {
|
|
23
|
+
throw new Error("maxItems must be greater than 0");
|
|
24
|
+
}
|
|
25
|
+
if (config.maxDepth !== undefined && config.maxDepth < 1) {
|
|
26
|
+
throw new Error("maxDepth must be greater than 0");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
validateConfig,
|
|
31
|
+
mergeConfig,
|
|
32
|
+
defaultConfig
|
|
33
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
var defaultConfig = {
|
|
3
|
+
outputDir: "./docs",
|
|
4
|
+
format: "auto",
|
|
5
|
+
maxItems: 100,
|
|
6
|
+
maxDepth: 2,
|
|
7
|
+
excludeFields: []
|
|
8
|
+
};
|
|
9
|
+
function mergeConfig(userConfig) {
|
|
10
|
+
return {
|
|
11
|
+
...defaultConfig,
|
|
12
|
+
...userConfig
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function validateConfig(config) {
|
|
16
|
+
if (!config.outputDir) {
|
|
17
|
+
throw new Error("outputDir is required");
|
|
18
|
+
}
|
|
19
|
+
if (config.format && !["table", "list", "detail", "auto"].includes(config.format)) {
|
|
20
|
+
throw new Error("format must be one of: table, list, detail, auto");
|
|
21
|
+
}
|
|
22
|
+
if (config.maxItems !== undefined && config.maxItems < 1) {
|
|
23
|
+
throw new Error("maxItems must be greater than 0");
|
|
24
|
+
}
|
|
25
|
+
if (config.maxDepth !== undefined && config.maxDepth < 1) {
|
|
26
|
+
throw new Error("maxDepth must be greater than 0");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/generator.ts
|
|
31
|
+
import { mkdirSync, writeFileSync } from "fs";
|
|
32
|
+
import { join } from "path";
|
|
33
|
+
class ExampleGeneratorPlugin {
|
|
34
|
+
config;
|
|
35
|
+
metadata;
|
|
36
|
+
constructor(config = {}) {
|
|
37
|
+
const merged = mergeConfig(config);
|
|
38
|
+
validateConfig(merged);
|
|
39
|
+
this.config = merged;
|
|
40
|
+
this.metadata = {
|
|
41
|
+
id: "example-generator",
|
|
42
|
+
name: "@contractspec/integration.example-generator",
|
|
43
|
+
version: "1.0.0",
|
|
44
|
+
description: "Example markdown documentation generator",
|
|
45
|
+
author: "ContractSpec"
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
getConfig() {
|
|
49
|
+
return { ...this.config };
|
|
50
|
+
}
|
|
51
|
+
updateConfig(config) {
|
|
52
|
+
const merged = mergeConfig({ ...this.config, ...config });
|
|
53
|
+
validateConfig(merged);
|
|
54
|
+
this.config = merged;
|
|
55
|
+
}
|
|
56
|
+
getMetadata() {
|
|
57
|
+
return { ...this.metadata };
|
|
58
|
+
}
|
|
59
|
+
async generate(context) {
|
|
60
|
+
if (!context.spec) {
|
|
61
|
+
throw new Error("Spec is required to generate documentation");
|
|
62
|
+
}
|
|
63
|
+
const outputDir = this.config.outputDir;
|
|
64
|
+
mkdirSync(outputDir, { recursive: true });
|
|
65
|
+
const fileName = "spec-" + Date.now() + ".md";
|
|
66
|
+
const outputPath = join(outputDir, fileName);
|
|
67
|
+
const content = `# Spec Documentation
|
|
68
|
+
|
|
69
|
+
Generated for spec: ${String(context.spec.id ?? "unknown")}`;
|
|
70
|
+
writeFileSync(outputPath, content, "utf8");
|
|
71
|
+
return {
|
|
72
|
+
outputPath,
|
|
73
|
+
itemCount: 1,
|
|
74
|
+
metadata: {
|
|
75
|
+
specId: String(context.spec.id ?? "unknown"),
|
|
76
|
+
generatedAt: new Date,
|
|
77
|
+
format: this.config.format ?? "auto",
|
|
78
|
+
config: this.config
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
ExampleGeneratorPlugin
|
|
85
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
var defaultConfig = {
|
|
3
|
+
outputDir: "./docs",
|
|
4
|
+
format: "auto",
|
|
5
|
+
maxItems: 100,
|
|
6
|
+
maxDepth: 2,
|
|
7
|
+
excludeFields: []
|
|
8
|
+
};
|
|
9
|
+
function mergeConfig(userConfig) {
|
|
10
|
+
return {
|
|
11
|
+
...defaultConfig,
|
|
12
|
+
...userConfig
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function validateConfig(config) {
|
|
16
|
+
if (!config.outputDir) {
|
|
17
|
+
throw new Error("outputDir is required");
|
|
18
|
+
}
|
|
19
|
+
if (config.format && !["table", "list", "detail", "auto"].includes(config.format)) {
|
|
20
|
+
throw new Error("format must be one of: table, list, detail, auto");
|
|
21
|
+
}
|
|
22
|
+
if (config.maxItems !== undefined && config.maxItems < 1) {
|
|
23
|
+
throw new Error("maxItems must be greater than 0");
|
|
24
|
+
}
|
|
25
|
+
if (config.maxDepth !== undefined && config.maxDepth < 1) {
|
|
26
|
+
throw new Error("maxDepth must be greater than 0");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/generator.ts
|
|
31
|
+
import { mkdirSync, writeFileSync } from "fs";
|
|
32
|
+
import { join } from "path";
|
|
33
|
+
class ExampleGeneratorPlugin {
|
|
34
|
+
config;
|
|
35
|
+
metadata;
|
|
36
|
+
constructor(config = {}) {
|
|
37
|
+
const merged = mergeConfig(config);
|
|
38
|
+
validateConfig(merged);
|
|
39
|
+
this.config = merged;
|
|
40
|
+
this.metadata = {
|
|
41
|
+
id: "example-generator",
|
|
42
|
+
name: "@contractspec/integration.example-generator",
|
|
43
|
+
version: "1.0.0",
|
|
44
|
+
description: "Example markdown documentation generator",
|
|
45
|
+
author: "ContractSpec"
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
getConfig() {
|
|
49
|
+
return { ...this.config };
|
|
50
|
+
}
|
|
51
|
+
updateConfig(config) {
|
|
52
|
+
const merged = mergeConfig({ ...this.config, ...config });
|
|
53
|
+
validateConfig(merged);
|
|
54
|
+
this.config = merged;
|
|
55
|
+
}
|
|
56
|
+
getMetadata() {
|
|
57
|
+
return { ...this.metadata };
|
|
58
|
+
}
|
|
59
|
+
async generate(context) {
|
|
60
|
+
if (!context.spec) {
|
|
61
|
+
throw new Error("Spec is required to generate documentation");
|
|
62
|
+
}
|
|
63
|
+
const outputDir = this.config.outputDir;
|
|
64
|
+
mkdirSync(outputDir, { recursive: true });
|
|
65
|
+
const fileName = "spec-" + Date.now() + ".md";
|
|
66
|
+
const outputPath = join(outputDir, fileName);
|
|
67
|
+
const content = `# Spec Documentation
|
|
68
|
+
|
|
69
|
+
Generated for spec: ${String(context.spec.id ?? "unknown")}`;
|
|
70
|
+
writeFileSync(outputPath, content, "utf8");
|
|
71
|
+
return {
|
|
72
|
+
outputPath,
|
|
73
|
+
itemCount: 1,
|
|
74
|
+
metadata: {
|
|
75
|
+
specId: String(context.spec.id ?? "unknown"),
|
|
76
|
+
generatedAt: new Date,
|
|
77
|
+
format: this.config.format ?? "auto",
|
|
78
|
+
config: this.config
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
validateConfig,
|
|
85
|
+
mergeConfig,
|
|
86
|
+
defaultConfig,
|
|
87
|
+
ExampleGeneratorPlugin
|
|
88
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
class ExampleGeneratorError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
details;
|
|
5
|
+
constructor(message, code, details) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.details = details;
|
|
9
|
+
this.name = "ExampleGeneratorError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class ValidationError extends ExampleGeneratorError {
|
|
14
|
+
constructor(message, details) {
|
|
15
|
+
super(message, "VALIDATION_ERROR", details);
|
|
16
|
+
this.name = "ValidationError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class ConfigurationError extends ExampleGeneratorError {
|
|
21
|
+
constructor(message, details) {
|
|
22
|
+
super(message, "CONFIGURATION_ERROR", details);
|
|
23
|
+
this.name = "ConfigurationError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class GenerationError extends ExampleGeneratorError {
|
|
28
|
+
constructor(message, details) {
|
|
29
|
+
super(message, "GENERATION_ERROR", details);
|
|
30
|
+
this.name = "GenerationError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
ValidationError,
|
|
35
|
+
GenerationError,
|
|
36
|
+
ExampleGeneratorError,
|
|
37
|
+
ConfigurationError
|
|
38
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { AnySchemaModel } from '@contractspec/lib.schema';
|
|
2
|
+
export type SpecDefinition = unknown;
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the ExampleGeneratorPlugin
|
|
5
|
+
*/
|
|
6
|
+
export interface ExampleGeneratorPluginConfig {
|
|
7
|
+
/** Directory where markdown files will be generated */
|
|
8
|
+
outputDir: string;
|
|
9
|
+
/** Output format: table, list, detail, or auto */
|
|
10
|
+
format?: 'table' | 'list' | 'detail' | 'auto';
|
|
11
|
+
/** Title for the generated documentation */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** Description to include below the title */
|
|
14
|
+
description?: string;
|
|
15
|
+
/** Maximum number of items to render in tables */
|
|
16
|
+
maxItems?: number;
|
|
17
|
+
/** Maximum nesting depth for nested objects */
|
|
18
|
+
maxDepth?: number;
|
|
19
|
+
/** Only include these fields (if not specified, all fields are included) */
|
|
20
|
+
includeFields?: string[];
|
|
21
|
+
/** Exclude these fields from output */
|
|
22
|
+
excludeFields?: string[];
|
|
23
|
+
/** Custom field labels (field name -> display label) */
|
|
24
|
+
fieldLabels?: Record<string, string>;
|
|
25
|
+
/** Fields to use for summary in list format */
|
|
26
|
+
summaryFields?: string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Context provided during generation
|
|
30
|
+
*/
|
|
31
|
+
export interface GeneratorContext {
|
|
32
|
+
/** The spec definition being processed */
|
|
33
|
+
spec: SpecDefinition;
|
|
34
|
+
/** Schema models from the spec */
|
|
35
|
+
schemas: Record<string, AnySchemaModel>;
|
|
36
|
+
/** Instance data (optional) */
|
|
37
|
+
data?: unknown;
|
|
38
|
+
/** Additional metadata */
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result of generation
|
|
43
|
+
*/
|
|
44
|
+
export interface GeneratorResult {
|
|
45
|
+
/** Path to the generated file */
|
|
46
|
+
outputPath: string;
|
|
47
|
+
/** Number of items processed */
|
|
48
|
+
itemCount: number;
|
|
49
|
+
/** Generation metadata */
|
|
50
|
+
metadata: {
|
|
51
|
+
specId: string;
|
|
52
|
+
generatedAt: Date;
|
|
53
|
+
format: string;
|
|
54
|
+
config: Partial<ExampleGeneratorPluginConfig>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Plugin metadata
|
|
59
|
+
*/
|
|
60
|
+
export interface PluginMetadata {
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly version: string;
|
|
64
|
+
readonly description: string;
|
|
65
|
+
readonly author: string;
|
|
66
|
+
readonly homepage?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Error types for the plugin
|
|
70
|
+
*/
|
|
71
|
+
export declare class ExampleGeneratorError extends Error {
|
|
72
|
+
readonly code: string;
|
|
73
|
+
readonly details?: unknown | undefined;
|
|
74
|
+
constructor(message: string, code: string, details?: unknown | undefined);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validation errors
|
|
78
|
+
*/
|
|
79
|
+
export declare class ValidationError extends ExampleGeneratorError {
|
|
80
|
+
constructor(message: string, details?: unknown);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Configuration errors
|
|
84
|
+
*/
|
|
85
|
+
export declare class ConfigurationError extends ExampleGeneratorError {
|
|
86
|
+
constructor(message: string, details?: unknown);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Generation errors
|
|
90
|
+
*/
|
|
91
|
+
export declare class GenerationError extends ExampleGeneratorError {
|
|
92
|
+
constructor(message: string, details?: unknown);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,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AACH,qBAAa,eAAgB,SAAQ,qBAAqB;gBAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAI/C;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,qBAAqB;gBAC/C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAI/C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,qBAAqB;gBAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAI/C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/types.ts
|
|
3
|
+
class ExampleGeneratorError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
details;
|
|
6
|
+
constructor(message, code, details) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.details = details;
|
|
10
|
+
this.name = "ExampleGeneratorError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class ValidationError extends ExampleGeneratorError {
|
|
15
|
+
constructor(message, details) {
|
|
16
|
+
super(message, "VALIDATION_ERROR", details);
|
|
17
|
+
this.name = "ValidationError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class ConfigurationError extends ExampleGeneratorError {
|
|
22
|
+
constructor(message, details) {
|
|
23
|
+
super(message, "CONFIGURATION_ERROR", details);
|
|
24
|
+
this.name = "ConfigurationError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class GenerationError extends ExampleGeneratorError {
|
|
29
|
+
constructor(message, details) {
|
|
30
|
+
super(message, "GENERATION_ERROR", details);
|
|
31
|
+
this.name = "GenerationError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
ValidationError,
|
|
36
|
+
GenerationError,
|
|
37
|
+
ExampleGeneratorError,
|
|
38
|
+
ConfigurationError
|
|
39
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/integration.example-generator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Example plugin: Markdown documentation generator for ContractSpec specs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -14,11 +14,10 @@
|
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"exports": {
|
|
17
|
-
".": "./
|
|
18
|
-
"./
|
|
19
|
-
"./generator": "./
|
|
20
|
-
"./
|
|
21
|
-
"./*": "./*"
|
|
17
|
+
".": "./src/index.ts",
|
|
18
|
+
"./config": "./src/config.ts",
|
|
19
|
+
"./generator": "./src/generator.ts",
|
|
20
|
+
"./types": "./src/types.ts"
|
|
22
21
|
},
|
|
23
22
|
"files": [
|
|
24
23
|
"dist",
|
|
@@ -28,38 +27,65 @@
|
|
|
28
27
|
"scripts": {
|
|
29
28
|
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
30
29
|
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
31
|
-
"build": "bun build:
|
|
32
|
-
"build:bundle": "
|
|
33
|
-
"build:types": "
|
|
34
|
-
"dev": "bun
|
|
30
|
+
"build": "bun run prebuild && bun run build:bundle && bun run build:types",
|
|
31
|
+
"build:bundle": "contractspec-bun-build transpile",
|
|
32
|
+
"build:types": "contractspec-bun-build types",
|
|
33
|
+
"dev": "contractspec-bun-build dev",
|
|
35
34
|
"clean": "rimraf dist .turbo",
|
|
36
35
|
"lint": "bun lint:fix",
|
|
37
36
|
"lint:fix": "eslint src --fix",
|
|
38
37
|
"lint:check": "eslint src",
|
|
39
38
|
"test": "bun test",
|
|
40
39
|
"test:watch": "bun test --watch",
|
|
41
|
-
"test:coverage": "bun test --coverage"
|
|
40
|
+
"test:coverage": "bun test --coverage",
|
|
41
|
+
"prebuild": "contractspec-bun-build prebuild",
|
|
42
|
+
"typecheck": "tsc --noEmit"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@contractspec/lib.contracts": "1.
|
|
45
|
-
"@contractspec/lib.schema": "1.
|
|
45
|
+
"@contractspec/lib.contracts": "1.58.0",
|
|
46
|
+
"@contractspec/lib.schema": "1.58.0",
|
|
46
47
|
"zod": "^4.3.5"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@contractspec/tool.
|
|
50
|
-
"@contractspec/tool.typescript": "1.57.0",
|
|
51
|
-
"tsdown": "^0.20.3",
|
|
50
|
+
"@contractspec/tool.typescript": "1.58.0",
|
|
52
51
|
"typescript": "^5.9.3",
|
|
53
52
|
"@types/node": "^25.2.1",
|
|
54
|
-
"rimraf": "^6.0.1"
|
|
53
|
+
"rimraf": "^6.0.1",
|
|
54
|
+
"@contractspec/tool.bun": "1.57.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@contractspec/lib.contracts": "^1.
|
|
58
|
-
"@contractspec/lib.schema": "^1.
|
|
57
|
+
"@contractspec/lib.contracts": "^1.58.0",
|
|
58
|
+
"@contractspec/lib.schema": "^1.58.0"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public",
|
|
62
|
-
"registry": "https://registry.npmjs.org/"
|
|
62
|
+
"registry": "https://registry.npmjs.org/",
|
|
63
|
+
"exports": {
|
|
64
|
+
".": {
|
|
65
|
+
"types": "./dist/index.d.ts",
|
|
66
|
+
"bun": "./dist/index.js",
|
|
67
|
+
"node": "./dist/node/index.mjs",
|
|
68
|
+
"default": "./dist/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./config": {
|
|
71
|
+
"types": "./dist/config.d.ts",
|
|
72
|
+
"bun": "./dist/config.js",
|
|
73
|
+
"node": "./dist/node/config.mjs",
|
|
74
|
+
"default": "./dist/config.js"
|
|
75
|
+
},
|
|
76
|
+
"./generator": {
|
|
77
|
+
"types": "./dist/generator.d.ts",
|
|
78
|
+
"bun": "./dist/generator.js",
|
|
79
|
+
"node": "./dist/node/generator.mjs",
|
|
80
|
+
"default": "./dist/generator.js"
|
|
81
|
+
},
|
|
82
|
+
"./types": {
|
|
83
|
+
"types": "./dist/types.d.ts",
|
|
84
|
+
"bun": "./dist/types.js",
|
|
85
|
+
"node": "./dist/node/types.mjs",
|
|
86
|
+
"default": "./dist/types.js"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
63
89
|
},
|
|
64
90
|
"license": "MIT",
|
|
65
91
|
"repository": {
|
package/dist/index.d.mts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { AnySchemaModel } from "@contractspec/lib.schema";
|
|
2
|
-
|
|
3
|
-
//#region src/types.d.ts
|
|
4
|
-
type SpecDefinition = unknown;
|
|
5
|
-
/**
|
|
6
|
-
* Configuration for the ExampleGeneratorPlugin
|
|
7
|
-
*/
|
|
8
|
-
interface ExampleGeneratorPluginConfig {
|
|
9
|
-
/** Directory where markdown files will be generated */
|
|
10
|
-
outputDir: string;
|
|
11
|
-
/** Output format: table, list, detail, or auto */
|
|
12
|
-
format?: 'table' | 'list' | 'detail' | 'auto';
|
|
13
|
-
/** Title for the generated documentation */
|
|
14
|
-
title?: string;
|
|
15
|
-
/** Description to include below the title */
|
|
16
|
-
description?: string;
|
|
17
|
-
/** Maximum number of items to render in tables */
|
|
18
|
-
maxItems?: number;
|
|
19
|
-
/** Maximum nesting depth for nested objects */
|
|
20
|
-
maxDepth?: number;
|
|
21
|
-
/** Only include these fields (if not specified, all fields are included) */
|
|
22
|
-
includeFields?: string[];
|
|
23
|
-
/** Exclude these fields from output */
|
|
24
|
-
excludeFields?: string[];
|
|
25
|
-
/** Custom field labels (field name -> display label) */
|
|
26
|
-
fieldLabels?: Record<string, string>;
|
|
27
|
-
/** Fields to use for summary in list format */
|
|
28
|
-
summaryFields?: string[];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Context provided during generation
|
|
32
|
-
*/
|
|
33
|
-
interface GeneratorContext {
|
|
34
|
-
/** The spec definition being processed */
|
|
35
|
-
spec: SpecDefinition;
|
|
36
|
-
/** Schema models from the spec */
|
|
37
|
-
schemas: Record<string, AnySchemaModel>;
|
|
38
|
-
/** Instance data (optional) */
|
|
39
|
-
data?: unknown;
|
|
40
|
-
/** Additional metadata */
|
|
41
|
-
metadata?: Record<string, unknown>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Result of generation
|
|
45
|
-
*/
|
|
46
|
-
interface GeneratorResult {
|
|
47
|
-
/** Path to the generated file */
|
|
48
|
-
outputPath: string;
|
|
49
|
-
/** Number of items processed */
|
|
50
|
-
itemCount: number;
|
|
51
|
-
/** Generation metadata */
|
|
52
|
-
metadata: {
|
|
53
|
-
specId: string;
|
|
54
|
-
generatedAt: Date;
|
|
55
|
-
format: string;
|
|
56
|
-
config: Partial<ExampleGeneratorPluginConfig>;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Plugin metadata
|
|
61
|
-
*/
|
|
62
|
-
interface PluginMetadata {
|
|
63
|
-
readonly id: string;
|
|
64
|
-
readonly name: string;
|
|
65
|
-
readonly version: string;
|
|
66
|
-
readonly description: string;
|
|
67
|
-
readonly author: string;
|
|
68
|
-
readonly homepage?: string;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Error types for the plugin
|
|
72
|
-
*/
|
|
73
|
-
declare class ExampleGeneratorError extends Error {
|
|
74
|
-
readonly code: string;
|
|
75
|
-
readonly details?: unknown | undefined;
|
|
76
|
-
constructor(message: string, code: string, details?: unknown | undefined);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Validation errors
|
|
80
|
-
*/
|
|
81
|
-
declare class ValidationError extends ExampleGeneratorError {
|
|
82
|
-
constructor(message: string, details?: unknown);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Configuration errors
|
|
86
|
-
*/
|
|
87
|
-
declare class ConfigurationError extends ExampleGeneratorError {
|
|
88
|
-
constructor(message: string, details?: unknown);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Generation errors
|
|
92
|
-
*/
|
|
93
|
-
declare class GenerationError extends ExampleGeneratorError {
|
|
94
|
-
constructor(message: string, details?: unknown);
|
|
95
|
-
}
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/generator.d.ts
|
|
98
|
-
declare class ExampleGeneratorPlugin {
|
|
99
|
-
private config;
|
|
100
|
-
private readonly metadata;
|
|
101
|
-
constructor(config?: Partial<ExampleGeneratorPluginConfig>);
|
|
102
|
-
getConfig(): ExampleGeneratorPluginConfig;
|
|
103
|
-
updateConfig(config: Partial<ExampleGeneratorPluginConfig>): void;
|
|
104
|
-
getMetadata(): PluginMetadata;
|
|
105
|
-
generate(context: GeneratorContext): Promise<GeneratorResult>;
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/config.d.ts
|
|
109
|
-
/**
|
|
110
|
-
* Default configuration for the ExampleGeneratorPlugin
|
|
111
|
-
*/
|
|
112
|
-
declare const defaultConfig: ExampleGeneratorPluginConfig;
|
|
113
|
-
/**
|
|
114
|
-
* Merge user config with defaults
|
|
115
|
-
*/
|
|
116
|
-
declare function mergeConfig(userConfig: Partial<ExampleGeneratorPluginConfig>): ExampleGeneratorPluginConfig;
|
|
117
|
-
/**
|
|
118
|
-
* Validate configuration
|
|
119
|
-
*/
|
|
120
|
-
declare function validateConfig(config: ExampleGeneratorPluginConfig): void;
|
|
121
|
-
//#endregion
|
|
122
|
-
export { type ConfigurationError, type ExampleGeneratorError, ExampleGeneratorPlugin, type ExampleGeneratorPluginConfig, type GenerationError, type GeneratorResult, type PluginMetadata, type ValidationError, defaultConfig, mergeConfig, validateConfig };
|
|
123
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|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,WAAA,CAAA,GAAe,cAAA;EAIT,QAAA,CAAS,OAAA,EAAS,gBAAA,GAAmB,OAAA,CAAQ,eAAA;AAAA;;;;;ADxCrD;cEIa,aAAA,EAAe,4BAAA;;;;iBAWZ,WAAA,CACd,UAAA,EAAY,OAAA,CAAQ,4BAAA,IACnB,4BAAA;;;;iBAUa,cAAA,CAAe,MAAA,EAAQ,4BAAA"}
|
package/dist/index.mjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
|
|
4
|
-
//#region src/config.ts
|
|
5
|
-
/**
|
|
6
|
-
* Default configuration for the ExampleGeneratorPlugin
|
|
7
|
-
*/
|
|
8
|
-
const defaultConfig = {
|
|
9
|
-
outputDir: "./docs",
|
|
10
|
-
format: "auto",
|
|
11
|
-
maxItems: 100,
|
|
12
|
-
maxDepth: 2,
|
|
13
|
-
excludeFields: []
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Merge user config with defaults
|
|
17
|
-
*/
|
|
18
|
-
function mergeConfig(userConfig) {
|
|
19
|
-
return {
|
|
20
|
-
...defaultConfig,
|
|
21
|
-
...userConfig
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Validate configuration
|
|
26
|
-
*/
|
|
27
|
-
function validateConfig(config) {
|
|
28
|
-
if (!config.outputDir) throw new Error("outputDir is required");
|
|
29
|
-
if (config.format && ![
|
|
30
|
-
"table",
|
|
31
|
-
"list",
|
|
32
|
-
"detail",
|
|
33
|
-
"auto"
|
|
34
|
-
].includes(config.format)) throw new Error("format must be one of: table, list, detail, auto");
|
|
35
|
-
if (config.maxItems !== void 0 && config.maxItems < 1) throw new Error("maxItems must be greater than 0");
|
|
36
|
-
if (config.maxDepth !== void 0 && config.maxDepth < 1) throw new Error("maxDepth must be greater than 0");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/generator.ts
|
|
41
|
-
var ExampleGeneratorPlugin = class {
|
|
42
|
-
config;
|
|
43
|
-
metadata;
|
|
44
|
-
constructor(config = {}) {
|
|
45
|
-
const merged = mergeConfig(config);
|
|
46
|
-
validateConfig(merged);
|
|
47
|
-
this.config = merged;
|
|
48
|
-
this.metadata = {
|
|
49
|
-
id: "example-generator",
|
|
50
|
-
name: "@contractspec/integration.example-generator",
|
|
51
|
-
version: "1.0.0",
|
|
52
|
-
description: "Example markdown documentation generator",
|
|
53
|
-
author: "ContractSpec"
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
getConfig() {
|
|
57
|
-
return { ...this.config };
|
|
58
|
-
}
|
|
59
|
-
updateConfig(config) {
|
|
60
|
-
const merged = mergeConfig({
|
|
61
|
-
...this.config,
|
|
62
|
-
...config
|
|
63
|
-
});
|
|
64
|
-
validateConfig(merged);
|
|
65
|
-
this.config = merged;
|
|
66
|
-
}
|
|
67
|
-
getMetadata() {
|
|
68
|
-
return { ...this.metadata };
|
|
69
|
-
}
|
|
70
|
-
async generate(context) {
|
|
71
|
-
if (!context.spec) throw new Error("Spec is required to generate documentation");
|
|
72
|
-
const outputDir = this.config.outputDir;
|
|
73
|
-
mkdirSync(outputDir, { recursive: true });
|
|
74
|
-
const outputPath = join(outputDir, "spec-" + Date.now() + ".md");
|
|
75
|
-
writeFileSync(outputPath, `# Spec Documentation\n\nGenerated for spec: ${String(context.spec.id ?? "unknown")}`, "utf8");
|
|
76
|
-
return {
|
|
77
|
-
outputPath,
|
|
78
|
-
itemCount: 1,
|
|
79
|
-
metadata: {
|
|
80
|
-
specId: String(context.spec.id ?? "unknown"),
|
|
81
|
-
generatedAt: /* @__PURE__ */ new Date(),
|
|
82
|
-
format: this.config.format ?? "auto",
|
|
83
|
-
config: this.config
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
//#endregion
|
|
90
|
-
export { ExampleGeneratorPlugin, defaultConfig, mergeConfig, validateConfig };
|
|
91
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/config.ts","../src/generator.ts"],"sourcesContent":["import type { ExampleGeneratorPluginConfig } from './types.js';\n\n/**\n * Default configuration for the ExampleGeneratorPlugin\n */\nexport const defaultConfig: ExampleGeneratorPluginConfig = {\n outputDir: './docs',\n format: 'auto',\n maxItems: 100,\n maxDepth: 2,\n excludeFields: [],\n};\n\n/**\n * Merge user config with defaults\n */\nexport function mergeConfig(\n userConfig: Partial<ExampleGeneratorPluginConfig>\n): ExampleGeneratorPluginConfig {\n return {\n ...defaultConfig,\n ...userConfig,\n };\n}\n\n/**\n * Validate configuration\n */\nexport function validateConfig(config: ExampleGeneratorPluginConfig): void {\n if (!config.outputDir) {\n throw new Error('outputDir is required');\n }\n\n if (\n config.format &&\n !['table', 'list', 'detail', 'auto'].includes(config.format)\n ) {\n throw new Error('format must be one of: table, list, detail, auto');\n }\n\n if (config.maxItems !== undefined && config.maxItems < 1) {\n throw new Error('maxItems must be greater than 0');\n }\n\n if (config.maxDepth !== undefined && config.maxDepth < 1) {\n throw new Error('maxDepth must be greater than 0');\n }\n}\n","import { mkdirSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { mergeConfig, validateConfig } from './config.js';\nimport type {\n ExampleGeneratorPluginConfig,\n GeneratorContext,\n GeneratorResult,\n PluginMetadata,\n} from './types.js';\n\nexport class ExampleGeneratorPlugin {\n private config: ExampleGeneratorPluginConfig;\n private readonly metadata: PluginMetadata;\n\n constructor(config: Partial<ExampleGeneratorPluginConfig> = {}) {\n const merged = mergeConfig(config);\n validateConfig(merged);\n this.config = merged;\n this.metadata = {\n id: 'example-generator',\n name: '@contractspec/integration.example-generator',\n version: '1.0.0',\n description: 'Example markdown documentation generator',\n author: 'ContractSpec',\n };\n }\n\n getConfig(): ExampleGeneratorPluginConfig {\n return { ...this.config };\n }\n\n updateConfig(config: Partial<ExampleGeneratorPluginConfig>): void {\n const merged = mergeConfig({ ...this.config, ...config });\n validateConfig(merged);\n this.config = merged;\n }\n\n getMetadata(): PluginMetadata {\n return { ...this.metadata };\n }\n\n async generate(context: GeneratorContext): Promise<GeneratorResult> {\n if (!context.spec) {\n throw new Error('Spec is required to generate documentation');\n }\n\n const outputDir = this.config.outputDir;\n mkdirSync(outputDir, { recursive: true });\n\n const fileName = 'spec-' + Date.now() + '.md';\n const outputPath = join(outputDir, fileName);\n const content = `# Spec Documentation\\n\\nGenerated for spec: ${String(\n (context.spec as { id?: string }).id ?? 'unknown'\n )}`;\n\n writeFileSync(outputPath, content, 'utf8');\n\n return {\n outputPath,\n itemCount: 1,\n metadata: {\n specId: String((context.spec as { id?: string }).id ?? 'unknown'),\n generatedAt: new Date(),\n format: this.config.format ?? 'auto',\n config: this.config,\n },\n };\n }\n}\n"],"mappings":";;;;;;;AAKA,MAAa,gBAA8C;CACzD,WAAW;CACX,QAAQ;CACR,UAAU;CACV,UAAU;CACV,eAAe,EAAE;CAClB;;;;AAKD,SAAgB,YACd,YAC8B;AAC9B,QAAO;EACL,GAAG;EACH,GAAG;EACJ;;;;;AAMH,SAAgB,eAAe,QAA4C;AACzE,KAAI,CAAC,OAAO,UACV,OAAM,IAAI,MAAM,wBAAwB;AAG1C,KACE,OAAO,UACP,CAAC;EAAC;EAAS;EAAQ;EAAU;EAAO,CAAC,SAAS,OAAO,OAAO,CAE5D,OAAM,IAAI,MAAM,mDAAmD;AAGrE,KAAI,OAAO,aAAa,UAAa,OAAO,WAAW,EACrD,OAAM,IAAI,MAAM,kCAAkC;AAGpD,KAAI,OAAO,aAAa,UAAa,OAAO,WAAW,EACrD,OAAM,IAAI,MAAM,kCAAkC;;;;;ACnCtD,IAAa,yBAAb,MAAoC;CAClC,AAAQ;CACR,AAAiB;CAEjB,YAAY,SAAgD,EAAE,EAAE;EAC9D,MAAM,SAA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