apcore-toolkit 0.1.0 → 0.2.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/CHANGELOG.md +36 -0
- package/README.md +26 -0
- package/dist/ai-enhancer.d.ts +34 -0
- package/dist/ai-enhancer.d.ts.map +1 -0
- package/dist/ai-enhancer.js +313 -0
- package/dist/ai-enhancer.js.map +1 -0
- package/dist/flatten-params.d.ts +16 -0
- package/dist/flatten-params.d.ts.map +1 -0
- package/dist/flatten-params.js +18 -0
- package/dist/flatten-params.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/output/errors.d.ts +5 -0
- package/dist/output/errors.d.ts.map +1 -0
- package/dist/output/errors.js +9 -0
- package/dist/output/errors.js.map +1 -0
- package/dist/output/index.d.ts +4 -0
- package/dist/output/index.d.ts.map +1 -1
- package/dist/output/index.js +3 -0
- package/dist/output/index.js.map +1 -1
- package/dist/output/registry-writer.d.ts +5 -1
- package/dist/output/registry-writer.d.ts.map +1 -1
- package/dist/output/registry-writer.js +21 -4
- package/dist/output/registry-writer.js.map +1 -1
- package/dist/output/types.d.ts +15 -0
- package/dist/output/types.d.ts.map +1 -0
- package/dist/output/types.js +4 -0
- package/dist/output/types.js.map +1 -0
- package/dist/output/typescript-writer.d.ts +4 -1
- package/dist/output/typescript-writer.d.ts.map +1 -1
- package/dist/output/typescript-writer.js +36 -10
- package/dist/output/typescript-writer.js.map +1 -1
- package/dist/output/verifiers.d.ts +26 -0
- package/dist/output/verifiers.d.ts.map +1 -0
- package/dist/output/verifiers.js +103 -0
- package/dist/output/verifiers.js.map +1 -0
- package/dist/output/yaml-writer.d.ts +4 -1
- package/dist/output/yaml-writer.d.ts.map +1 -1
- package/dist/output/yaml-writer.js +48 -23
- package/dist/output/yaml-writer.js.map +1 -1
- package/dist/resolve-target.d.ts +7 -1
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +17 -1
- package/dist/resolve-target.js.map +1 -1
- package/dist/scanner.d.ts +5 -0
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.js +50 -5
- package/dist/scanner.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2026-03-12
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `AIEnhancer` class — SLM-based metadata enhancement using OpenAI-compatible
|
|
8
|
+
APIs (Ollama, vLLM, LM Studio). Fills missing descriptions, infers behavioral
|
|
9
|
+
annotations (all 11 fields: `readonly`, `destructive`, `idempotent`,
|
|
10
|
+
`requires_approval`, `open_world`, `streaming`, `cacheable`, `cache_ttl`,
|
|
11
|
+
`cache_key_fields`, `paginated`, `pagination_style`), and generates input
|
|
12
|
+
schemas. AI-generated fields tagged with `x-generated-by: slm` for auditability.
|
|
13
|
+
- `createWriteResult()` factory and `runVerifierChain()` helper for writer operations.
|
|
14
|
+
`verify: true` runs the built-in verifier (`YAMLVerifier`, `SyntaxVerifier`,
|
|
15
|
+
`RegistryVerifier`) even when no custom `verifiers` are provided.
|
|
16
|
+
- `allowedPrefixes` parameter on `resolveTarget()` for path restriction security
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- `inferAnnotationsFromMethod()` — `GET` now infers `cacheable: true` in addition
|
|
21
|
+
to `readonly: true`, matching Python parity
|
|
22
|
+
- `filterModules()` — use `safeRegExp()` that tries regex first and falls back
|
|
23
|
+
to escaped literal on invalid patterns (balances spec compliance with safety)
|
|
24
|
+
- `YAMLWriter._buildBinding()` — use `structuredClone()` for deep cloning nested
|
|
25
|
+
schemas instead of shallow spread
|
|
26
|
+
- `WriteError` — use native ES2022 `Error.cause` instead of shadowing the property
|
|
27
|
+
- `JSONVerifier` — restored `schema` constructor parameter for cross-language
|
|
28
|
+
API parity with Python SDK
|
|
29
|
+
|
|
30
|
+
### Tests
|
|
31
|
+
|
|
32
|
+
- 171 tests across 14 files, all passing
|
|
33
|
+
- Added `RegistryVerifier` test coverage (pass, fail, missing method)
|
|
34
|
+
- Added `resolveTarget` allowedPrefixes tests
|
|
35
|
+
- Full AIEnhancer test suite (15 tests)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
3
39
|
## [0.1.0] - 2026-03-07
|
|
4
40
|
|
|
5
41
|
### Added
|
package/README.md
CHANGED
|
@@ -12,6 +12,15 @@ Shared scanner, schema extraction, and output toolkit for apcore framework adapt
|
|
|
12
12
|
npm install apcore-toolkit
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Abstract `BaseScanner` for framework-specific endpoint scanning
|
|
18
|
+
- OpenAPI schema extraction (`extractInputSchema`, `extractOutputSchema`)
|
|
19
|
+
- Multi-format output writers (YAML, TypeScript, Registry) with pluggable verification
|
|
20
|
+
- Markdown formatting with depth control and table heuristics
|
|
21
|
+
- Module serialization utilities
|
|
22
|
+
- `flattenParams` for Zod-based parameter flattening
|
|
23
|
+
|
|
15
24
|
## Usage
|
|
16
25
|
|
|
17
26
|
### ScannedModule
|
|
@@ -127,8 +136,25 @@ const dicts = modulesToDicts(modules); // batch conversion
|
|
|
127
136
|
| `modulesToDicts()` | Batch serialize modules |
|
|
128
137
|
| `annotationsToDict()` | Convert annotations to plain dict |
|
|
129
138
|
| `resolveTarget()` | Dynamic import + named export resolution |
|
|
139
|
+
| `flattenParams()` | Flatten Zod schema params into keyword args |
|
|
140
|
+
| `WriteResult` | Structured result type for writer operations |
|
|
141
|
+
| `Verifier` | Interface for pluggable output verification |
|
|
142
|
+
| `VerifyResult` | Result type for verification operations |
|
|
143
|
+
| `WriteError` | Error class for I/O failures during write |
|
|
144
|
+
| `YAMLVerifier` | Verifies YAML binding file structure |
|
|
145
|
+
| `SyntaxVerifier` | Verifies file is non-empty and readable |
|
|
146
|
+
| `RegistryVerifier` | Verifies module registered in registry |
|
|
147
|
+
| `MagicBytesVerifier` | Verifies file header matches expected bytes |
|
|
148
|
+
| `JSONVerifier` | Verifies valid JSON, optional schema check |
|
|
149
|
+
| `createWriteResult()` | Factory for WriteResult with defaults |
|
|
150
|
+
| `runVerifierChain()` | Run verifier chain, short-circuit on first failure |
|
|
151
|
+
| `AIEnhancer` | SLM-based metadata enhancement for scanned modules |
|
|
130
152
|
| `VERSION` | Package version string |
|
|
131
153
|
|
|
154
|
+
## Documentation
|
|
155
|
+
|
|
156
|
+
See the [apcore-toolkit documentation](https://github.com/aipartnerup/apcore-toolkit) for full API reference and guides.
|
|
157
|
+
|
|
132
158
|
## License
|
|
133
159
|
|
|
134
160
|
Apache-2.0
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-driven metadata enhancement using local SLMs.
|
|
3
|
+
*
|
|
4
|
+
* Uses an OpenAI-compatible local API (e.g., Ollama, vLLM, LM Studio) to fill
|
|
5
|
+
* metadata gaps that static analysis cannot resolve: missing descriptions,
|
|
6
|
+
* behavioral annotation inference, and schema inference for untyped functions.
|
|
7
|
+
*
|
|
8
|
+
* All AI-generated fields are tagged with `x-generated-by: slm` in the module's
|
|
9
|
+
* metadata dict for auditability.
|
|
10
|
+
*/
|
|
11
|
+
import type { ScannedModule } from './types.js';
|
|
12
|
+
export interface AIEnhancerOptions {
|
|
13
|
+
endpoint?: string;
|
|
14
|
+
model?: string;
|
|
15
|
+
threshold?: number;
|
|
16
|
+
batchSize?: number;
|
|
17
|
+
timeout?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class AIEnhancer {
|
|
20
|
+
readonly endpoint: string;
|
|
21
|
+
readonly model: string;
|
|
22
|
+
readonly threshold: number;
|
|
23
|
+
readonly batchSize: number;
|
|
24
|
+
readonly timeout: number;
|
|
25
|
+
constructor(options?: AIEnhancerOptions);
|
|
26
|
+
static isEnabled(): boolean;
|
|
27
|
+
enhance(modules: ScannedModule[]): Promise<ScannedModule[]>;
|
|
28
|
+
private _identifyGaps;
|
|
29
|
+
private _enhanceModule;
|
|
30
|
+
private _buildPrompt;
|
|
31
|
+
private _callLLM;
|
|
32
|
+
static _parseResponse(response: string): Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ai-enhancer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-enhancer.d.ts","sourceRoot":"","sources":["../src/ai-enhancer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAyBhD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,UAAU;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,CAAC,EAAE,iBAAiB;IAkBvC,MAAM,CAAC,SAAS,IAAI,OAAO;IAKrB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA0BjE,OAAO,CAAC,aAAa;YAkBP,cAAc;IAkH5B,OAAO,CAAC,YAAY;YAkDN,QAAQ;IAuCtB,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAcjE"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-driven metadata enhancement using local SLMs.
|
|
3
|
+
*
|
|
4
|
+
* Uses an OpenAI-compatible local API (e.g., Ollama, vLLM, LM Studio) to fill
|
|
5
|
+
* metadata gaps that static analysis cannot resolve: missing descriptions,
|
|
6
|
+
* behavioral annotation inference, and schema inference for untyped functions.
|
|
7
|
+
*
|
|
8
|
+
* All AI-generated fields are tagged with `x-generated-by: slm` in the module's
|
|
9
|
+
* metadata dict for auditability.
|
|
10
|
+
*/
|
|
11
|
+
import { DEFAULT_ANNOTATIONS } from 'apcore-js';
|
|
12
|
+
import { cloneModule } from './types.js';
|
|
13
|
+
const _DEFAULT_ENDPOINT = 'http://localhost:11434/v1';
|
|
14
|
+
const _DEFAULT_MODEL = 'qwen:0.6b';
|
|
15
|
+
const _DEFAULT_THRESHOLD = 0.7;
|
|
16
|
+
const _DEFAULT_BATCH_SIZE = 5;
|
|
17
|
+
const _DEFAULT_TIMEOUT = 30;
|
|
18
|
+
function parseFloatEnv(name, fallback) {
|
|
19
|
+
const raw = process.env[name];
|
|
20
|
+
if (raw == null)
|
|
21
|
+
return fallback;
|
|
22
|
+
const val = Number(raw);
|
|
23
|
+
if (Number.isNaN(val))
|
|
24
|
+
throw new Error(`${name} must be a valid number, got "${raw}"`);
|
|
25
|
+
return val;
|
|
26
|
+
}
|
|
27
|
+
function parseIntEnv(name, fallback) {
|
|
28
|
+
const raw = process.env[name];
|
|
29
|
+
if (raw == null)
|
|
30
|
+
return fallback;
|
|
31
|
+
const val = parseInt(raw, 10);
|
|
32
|
+
if (Number.isNaN(val))
|
|
33
|
+
throw new Error(`${name} must be a valid integer, got "${raw}"`);
|
|
34
|
+
return val;
|
|
35
|
+
}
|
|
36
|
+
export class AIEnhancer {
|
|
37
|
+
endpoint;
|
|
38
|
+
model;
|
|
39
|
+
threshold;
|
|
40
|
+
batchSize;
|
|
41
|
+
timeout;
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.endpoint = options?.endpoint ?? process.env.APCORE_AI_ENDPOINT ?? _DEFAULT_ENDPOINT;
|
|
44
|
+
this.model = options?.model ?? process.env.APCORE_AI_MODEL ?? _DEFAULT_MODEL;
|
|
45
|
+
this.threshold = options?.threshold ?? parseFloatEnv('APCORE_AI_THRESHOLD', _DEFAULT_THRESHOLD);
|
|
46
|
+
this.batchSize = options?.batchSize ?? parseIntEnv('APCORE_AI_BATCH_SIZE', _DEFAULT_BATCH_SIZE);
|
|
47
|
+
this.timeout = options?.timeout ?? parseIntEnv('APCORE_AI_TIMEOUT', _DEFAULT_TIMEOUT);
|
|
48
|
+
if (this.threshold < 0 || this.threshold > 1) {
|
|
49
|
+
throw new Error('APCORE_AI_THRESHOLD must be a number between 0.0 and 1.0');
|
|
50
|
+
}
|
|
51
|
+
if (this.batchSize <= 0) {
|
|
52
|
+
throw new Error('APCORE_AI_BATCH_SIZE must be a positive integer');
|
|
53
|
+
}
|
|
54
|
+
if (this.timeout <= 0) {
|
|
55
|
+
throw new Error('APCORE_AI_TIMEOUT must be a positive integer');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
static isEnabled() {
|
|
59
|
+
const val = (process.env.APCORE_AI_ENABLED ?? 'false').toLowerCase();
|
|
60
|
+
return val === 'true' || val === '1' || val === 'yes';
|
|
61
|
+
}
|
|
62
|
+
async enhance(modules) {
|
|
63
|
+
const results = [...modules];
|
|
64
|
+
const pending = [];
|
|
65
|
+
for (let i = 0; i < modules.length; i++) {
|
|
66
|
+
const gaps = this._identifyGaps(modules[i]);
|
|
67
|
+
if (gaps.length > 0) {
|
|
68
|
+
pending.push({ idx: i, module: modules[i], gaps });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (let batchStart = 0; batchStart < pending.length; batchStart += this.batchSize) {
|
|
72
|
+
const batch = pending.slice(batchStart, batchStart + this.batchSize);
|
|
73
|
+
for (const { idx, module, gaps } of batch) {
|
|
74
|
+
try {
|
|
75
|
+
const enhanced = await this._enhanceModule(module, gaps);
|
|
76
|
+
results[idx] = enhanced;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// AI enhancement failed — keep original
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return results;
|
|
84
|
+
}
|
|
85
|
+
_identifyGaps(module) {
|
|
86
|
+
const gaps = [];
|
|
87
|
+
if (!module.description || module.description === module.moduleId) {
|
|
88
|
+
gaps.push('description');
|
|
89
|
+
}
|
|
90
|
+
if (!module.documentation) {
|
|
91
|
+
gaps.push('documentation');
|
|
92
|
+
}
|
|
93
|
+
if (module.annotations == null || JSON.stringify(module.annotations) === JSON.stringify(DEFAULT_ANNOTATIONS)) {
|
|
94
|
+
gaps.push('annotations');
|
|
95
|
+
}
|
|
96
|
+
const props = module.inputSchema.properties;
|
|
97
|
+
if (!props || (typeof props === 'object' && Object.keys(props).length === 0)) {
|
|
98
|
+
gaps.push('input_schema');
|
|
99
|
+
}
|
|
100
|
+
return gaps;
|
|
101
|
+
}
|
|
102
|
+
async _enhanceModule(module, gaps) {
|
|
103
|
+
const prompt = this._buildPrompt(module, gaps);
|
|
104
|
+
const response = await this._callLLM(prompt);
|
|
105
|
+
const parsed = AIEnhancer._parseResponse(response);
|
|
106
|
+
const updates = {};
|
|
107
|
+
const parsedConf = (parsed.confidence ?? {});
|
|
108
|
+
const confidence = {};
|
|
109
|
+
const warnings = [...module.warnings];
|
|
110
|
+
if (gaps.includes('description') && parsed.description) {
|
|
111
|
+
const conf = parsedConf.description ?? 0;
|
|
112
|
+
confidence.description = conf;
|
|
113
|
+
if (conf >= this.threshold) {
|
|
114
|
+
updates.description = parsed.description;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
warnings.push(`Low confidence (${conf.toFixed(2)}) for description — skipped. Review manually.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (gaps.includes('documentation') && parsed.documentation) {
|
|
121
|
+
const conf = parsedConf.documentation ?? 0;
|
|
122
|
+
confidence.documentation = conf;
|
|
123
|
+
if (conf >= this.threshold) {
|
|
124
|
+
updates.documentation = parsed.documentation;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
warnings.push(`Low confidence (${conf.toFixed(2)}) for documentation — skipped. Review manually.`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (gaps.includes('annotations') && parsed.annotations && typeof parsed.annotations === 'object') {
|
|
131
|
+
const annData = parsed.annotations;
|
|
132
|
+
const accepted = {};
|
|
133
|
+
const boolFields = [
|
|
134
|
+
'readonly', 'destructive', 'idempotent', 'requires_approval',
|
|
135
|
+
'open_world', 'streaming', 'cacheable', 'paginated',
|
|
136
|
+
];
|
|
137
|
+
for (const field of boolFields) {
|
|
138
|
+
if (typeof annData[field] === 'boolean') {
|
|
139
|
+
const fieldConf = parsedConf[`annotations.${field}`] ?? parsedConf[field] ?? 0;
|
|
140
|
+
confidence[`annotations.${field}`] = fieldConf;
|
|
141
|
+
if (fieldConf >= this.threshold) {
|
|
142
|
+
accepted[field] = annData[field];
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
warnings.push(`Low confidence (${fieldConf.toFixed(2)}) for annotations.${field} — skipped. Review manually.`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Handle integer annotation fields
|
|
150
|
+
const intFields = ['cache_ttl'];
|
|
151
|
+
for (const field of intFields) {
|
|
152
|
+
if (typeof annData[field] === 'number') {
|
|
153
|
+
const fieldConf = parsedConf[`annotations.${field}`] ?? parsedConf[field] ?? 0;
|
|
154
|
+
confidence[`annotations.${field}`] = fieldConf;
|
|
155
|
+
if (fieldConf >= this.threshold) {
|
|
156
|
+
accepted[field] = annData[field];
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
warnings.push(`Low confidence (${fieldConf.toFixed(2)}) for annotations.${field} — skipped. Review manually.`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Handle string annotation fields
|
|
164
|
+
const strFields = ['pagination_style'];
|
|
165
|
+
for (const field of strFields) {
|
|
166
|
+
if (typeof annData[field] === 'string') {
|
|
167
|
+
const fieldConf = parsedConf[`annotations.${field}`] ?? parsedConf[field] ?? 0;
|
|
168
|
+
confidence[`annotations.${field}`] = fieldConf;
|
|
169
|
+
if (fieldConf >= this.threshold) {
|
|
170
|
+
accepted[field] = annData[field];
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
warnings.push(`Low confidence (${fieldConf.toFixed(2)}) for annotations.${field} — skipped. Review manually.`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Handle list annotation fields
|
|
178
|
+
if (Array.isArray(annData['cache_key_fields'])) {
|
|
179
|
+
const fieldConf = parsedConf['annotations.cache_key_fields'] ?? parsedConf['cache_key_fields'] ?? 0;
|
|
180
|
+
confidence['annotations.cache_key_fields'] = fieldConf;
|
|
181
|
+
if (fieldConf >= this.threshold) {
|
|
182
|
+
accepted['cache_key_fields'] = annData['cache_key_fields'];
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
warnings.push(`Low confidence (${fieldConf.toFixed(2)}) for annotations.cache_key_fields — skipped. Review manually.`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (Object.keys(accepted).length > 0) {
|
|
189
|
+
const base = module.annotations ?? { ...DEFAULT_ANNOTATIONS };
|
|
190
|
+
updates.annotations = { ...base, ...accepted };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (gaps.includes('input_schema') && parsed.input_schema) {
|
|
194
|
+
const conf = parsedConf.input_schema ?? 0;
|
|
195
|
+
confidence.input_schema = conf;
|
|
196
|
+
if (conf >= this.threshold) {
|
|
197
|
+
updates.inputSchema = parsed.input_schema;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
warnings.push(`Low confidence (${conf.toFixed(2)}) for input_schema — skipped. Review manually.`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (Object.keys(updates).length === 0) {
|
|
204
|
+
if (warnings.length !== module.warnings.length) {
|
|
205
|
+
return cloneModule(module, { warnings });
|
|
206
|
+
}
|
|
207
|
+
return module;
|
|
208
|
+
}
|
|
209
|
+
const metadata = { ...module.metadata };
|
|
210
|
+
metadata['x-generated-by'] = 'slm';
|
|
211
|
+
metadata['x-ai-confidence'] = confidence;
|
|
212
|
+
return cloneModule(module, { ...updates, metadata, warnings });
|
|
213
|
+
}
|
|
214
|
+
_buildPrompt(module, gaps) {
|
|
215
|
+
const parts = [
|
|
216
|
+
'You are analyzing a function to generate metadata for an AI-perceivable module system.',
|
|
217
|
+
'',
|
|
218
|
+
`Module ID: ${module.moduleId}`,
|
|
219
|
+
`Target: ${module.target}`,
|
|
220
|
+
];
|
|
221
|
+
if (module.description) {
|
|
222
|
+
parts.push(`Current description: ${module.description}`);
|
|
223
|
+
}
|
|
224
|
+
parts.push('');
|
|
225
|
+
parts.push('Please provide the following missing metadata as JSON:');
|
|
226
|
+
parts.push('{');
|
|
227
|
+
if (gaps.includes('description')) {
|
|
228
|
+
parts.push(' "description": "<≤200 chars, what this function does>",');
|
|
229
|
+
}
|
|
230
|
+
if (gaps.includes('documentation')) {
|
|
231
|
+
parts.push(' "documentation": "<detailed Markdown explanation>",');
|
|
232
|
+
}
|
|
233
|
+
if (gaps.includes('annotations')) {
|
|
234
|
+
parts.push(' "annotations": {');
|
|
235
|
+
parts.push(' "readonly": <true if no side effects>,');
|
|
236
|
+
parts.push(' "destructive": <true if deletes/overwrites data>,');
|
|
237
|
+
parts.push(' "idempotent": <true if safe to retry>,');
|
|
238
|
+
parts.push(' "requires_approval": <true if dangerous operation>,');
|
|
239
|
+
parts.push(' "open_world": <true if calls external systems>,');
|
|
240
|
+
parts.push(' "streaming": <true if yields results incrementally>,');
|
|
241
|
+
parts.push(' "cacheable": <true if results can be cached>,');
|
|
242
|
+
parts.push(' "cache_ttl": <seconds, 0 for no expiry>,');
|
|
243
|
+
parts.push(' "cache_key_fields": <list of input field names for cache key, or null for all>,');
|
|
244
|
+
parts.push(' "paginated": <true if supports pagination>,');
|
|
245
|
+
parts.push(' "pagination_style": <"cursor" or "offset" or "page">');
|
|
246
|
+
parts.push(' },');
|
|
247
|
+
}
|
|
248
|
+
if (gaps.includes('input_schema')) {
|
|
249
|
+
parts.push(' "input_schema": <JSON Schema object for function parameters>,');
|
|
250
|
+
}
|
|
251
|
+
parts.push(' "confidence": {');
|
|
252
|
+
parts.push(' "description": 0.0, "documentation": 0.0');
|
|
253
|
+
parts.push(' }');
|
|
254
|
+
parts.push('}');
|
|
255
|
+
parts.push('');
|
|
256
|
+
parts.push('Respond with ONLY valid JSON, no markdown fences or explanation.');
|
|
257
|
+
return parts.join('\n');
|
|
258
|
+
}
|
|
259
|
+
async _callLLM(prompt) {
|
|
260
|
+
const url = `${this.endpoint.replace(/\/+$/, '')}/chat/completions`;
|
|
261
|
+
const payload = JSON.stringify({
|
|
262
|
+
model: this.model,
|
|
263
|
+
messages: [{ role: 'user', content: prompt }],
|
|
264
|
+
temperature: 0.1,
|
|
265
|
+
});
|
|
266
|
+
const controller = new AbortController();
|
|
267
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout * 1000);
|
|
268
|
+
try {
|
|
269
|
+
const resp = await fetch(url, {
|
|
270
|
+
method: 'POST',
|
|
271
|
+
headers: { 'Content-Type': 'application/json' },
|
|
272
|
+
body: payload,
|
|
273
|
+
signal: controller.signal,
|
|
274
|
+
});
|
|
275
|
+
if (!resp.ok) {
|
|
276
|
+
throw new Error(`SLM API returned ${resp.status}: ${resp.statusText}`);
|
|
277
|
+
}
|
|
278
|
+
const data = (await resp.json());
|
|
279
|
+
const choices = data.choices;
|
|
280
|
+
if (!choices?.[0]?.message?.content) {
|
|
281
|
+
throw new Error('Unexpected API response structure');
|
|
282
|
+
}
|
|
283
|
+
return choices[0].message.content;
|
|
284
|
+
}
|
|
285
|
+
catch (err) {
|
|
286
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
287
|
+
throw new Error(`SLM request timed out after ${this.timeout}s`);
|
|
288
|
+
}
|
|
289
|
+
throw err;
|
|
290
|
+
}
|
|
291
|
+
finally {
|
|
292
|
+
clearTimeout(timeoutId);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
static _parseResponse(response) {
|
|
296
|
+
let text = response.trim();
|
|
297
|
+
if (text.startsWith('```')) {
|
|
298
|
+
const lines = text.split('\n');
|
|
299
|
+
if (lines[0].startsWith('```'))
|
|
300
|
+
lines.shift();
|
|
301
|
+
if (lines.length > 0 && lines[lines.length - 1].trim() === '```')
|
|
302
|
+
lines.pop();
|
|
303
|
+
text = lines.join('\n');
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
return JSON.parse(text);
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
throw new Error(`SLM returned invalid JSON: ${err.message}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=ai-enhancer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-enhancer.js","sourceRoot":"","sources":["../src/ai-enhancer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;AACtD,MAAM,cAAc,GAAG,WAAW,CAAC;AACnC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,SAAS,aAAa,CAAC,IAAY,EAAE,QAAgB;IACnD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,GAAG,IA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AC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a function, converting Zod schema parameters into flat keyword arguments.
|
|
3
|
+
*
|
|
4
|
+
* This is the TypeScript equivalent of Python's `flatten_pydantic_params()`.
|
|
5
|
+
* It takes a function whose first parameter is a Zod-validated object and returns
|
|
6
|
+
* a new function that accepts the object's fields as individual keyword arguments.
|
|
7
|
+
*
|
|
8
|
+
* @param func - The original function accepting a single object parameter
|
|
9
|
+
* @param zodSchema - A Zod schema describing the object's shape
|
|
10
|
+
* @returns A new function that accepts flattened parameters
|
|
11
|
+
*/
|
|
12
|
+
export declare function flattenParams<T extends Record<string, unknown>>(func: (input: T) => unknown, zodSchema: {
|
|
13
|
+
parse(data: unknown): T;
|
|
14
|
+
shape?: Record<string, unknown>;
|
|
15
|
+
}): (args: Record<string, unknown>) => unknown;
|
|
16
|
+
//# sourceMappingURL=flatten-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten-params.d.ts","sourceRoot":"","sources":["../src/flatten-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EAC3B,SAAS,EAAE;IAAE,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACtE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAK5C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a function, converting Zod schema parameters into flat keyword arguments.
|
|
3
|
+
*
|
|
4
|
+
* This is the TypeScript equivalent of Python's `flatten_pydantic_params()`.
|
|
5
|
+
* It takes a function whose first parameter is a Zod-validated object and returns
|
|
6
|
+
* a new function that accepts the object's fields as individual keyword arguments.
|
|
7
|
+
*
|
|
8
|
+
* @param func - The original function accepting a single object parameter
|
|
9
|
+
* @param zodSchema - A Zod schema describing the object's shape
|
|
10
|
+
* @returns A new function that accepts flattened parameters
|
|
11
|
+
*/
|
|
12
|
+
export function flattenParams(func, zodSchema) {
|
|
13
|
+
return (args) => {
|
|
14
|
+
const parsed = zodSchema.parse(args);
|
|
15
|
+
return func(parsed);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=flatten-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten-params.js","sourceRoot":"","sources":["../src/flatten-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAC3B,IAA2B,EAC3B,SAAuE;IAEvE,OAAO,CAAC,IAA6B,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,9 +6,16 @@ export { resolveRef, resolveSchema, extractInputSchema, extractOutputSchema, } f
|
|
|
6
6
|
export { annotationsToDict, moduleToDict, modulesToDicts, } from './serializers.js';
|
|
7
7
|
export { resolveTarget } from './resolve-target.js';
|
|
8
8
|
export { toMarkdown } from './formatting/index.js';
|
|
9
|
+
export { flattenParams } from './flatten-params.js';
|
|
10
|
+
export { AIEnhancer } from './ai-enhancer.js';
|
|
11
|
+
export type { AIEnhancerOptions } from './ai-enhancer.js';
|
|
9
12
|
export { YAMLWriter } from './output/yaml-writer.js';
|
|
10
13
|
export { TypeScriptWriter } from './output/typescript-writer.js';
|
|
11
14
|
export { RegistryWriter } from './output/registry-writer.js';
|
|
12
15
|
export { getWriter } from './output/factory.js';
|
|
16
|
+
export type { WriteResult, VerifyResult, Verifier } from './output/types.js';
|
|
17
|
+
export { createWriteResult } from './output/types.js';
|
|
18
|
+
export { WriteError } from './output/errors.js';
|
|
19
|
+
export { YAMLVerifier, SyntaxVerifier, RegistryVerifier, MagicBytesVerifier, JSONVerifier, runVerifierChain, } from './output/verifiers.js';
|
|
13
20
|
export declare const VERSION: string;
|
|
14
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAK/B,eAAO,MAAM,OAAO,EAAE,MAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,10 +5,15 @@ export { resolveRef, resolveSchema, extractInputSchema, extractOutputSchema, } f
|
|
|
5
5
|
export { annotationsToDict, moduleToDict, modulesToDicts, } from './serializers.js';
|
|
6
6
|
export { resolveTarget } from './resolve-target.js';
|
|
7
7
|
export { toMarkdown } from './formatting/index.js';
|
|
8
|
+
export { flattenParams } from './flatten-params.js';
|
|
9
|
+
export { AIEnhancer } from './ai-enhancer.js';
|
|
8
10
|
export { YAMLWriter } from './output/yaml-writer.js';
|
|
9
11
|
export { TypeScriptWriter } from './output/typescript-writer.js';
|
|
10
12
|
export { RegistryWriter } from './output/registry-writer.js';
|
|
11
13
|
export { getWriter } from './output/factory.js';
|
|
14
|
+
export { createWriteResult } from './output/types.js';
|
|
15
|
+
export { WriteError } from './output/errors.js';
|
|
16
|
+
export { YAMLVerifier, SyntaxVerifier, RegistryVerifier, MagicBytesVerifier, JSONVerifier, runVerifierChain, } from './output/verifiers.js';
|
|
12
17
|
import { createRequire } from 'node:module';
|
|
13
18
|
const _require = createRequire(import.meta.url);
|
|
14
19
|
const _pkg = _require('../package.json');
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAA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oB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,iBAAiB,CAAwB,CAAC;AAChE,MAAM,CAAC,MAAM,OAAO,GAAW,IAAI,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/output/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAKvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/output/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,KAAY;QACpC,KAAK,CAAC,oBAAoB,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
package/dist/output/index.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ export { YAMLWriter } from './yaml-writer.js';
|
|
|
2
2
|
export { TypeScriptWriter } from './typescript-writer.js';
|
|
3
3
|
export { RegistryWriter } from './registry-writer.js';
|
|
4
4
|
export { getWriter } from './factory.js';
|
|
5
|
+
export type { WriteResult, VerifyResult, Verifier } from './types.js';
|
|
6
|
+
export { createWriteResult } from './types.js';
|
|
7
|
+
export { WriteError } from './errors.js';
|
|
8
|
+
export { YAMLVerifier, SyntaxVerifier, RegistryVerifier, MagicBytesVerifier, JSONVerifier, runVerifierChain, } from './verifiers.js';
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/output/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/output/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
|
package/dist/output/index.js
CHANGED
|
@@ -2,4 +2,7 @@ export { YAMLWriter } from './yaml-writer.js';
|
|
|
2
2
|
export { TypeScriptWriter } from './typescript-writer.js';
|
|
3
3
|
export { RegistryWriter } from './registry-writer.js';
|
|
4
4
|
export { getWriter } from './factory.js';
|
|
5
|
+
export { createWriteResult } from './types.js';
|
|
6
|
+
export { WriteError } from './errors.js';
|
|
7
|
+
export { YAMLVerifier, SyntaxVerifier, RegistryVerifier, MagicBytesVerifier, JSONVerifier, runVerifierChain, } from './verifiers.js';
|
|
5
8
|
//# sourceMappingURL=index.js.map
|
package/dist/output/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { ScannedModule } from '../types.js';
|
|
2
|
+
import type { WriteResult, Verifier } from './types.js';
|
|
2
3
|
export declare class RegistryWriter {
|
|
3
4
|
write(modules: ScannedModule[], registry: {
|
|
4
5
|
register(moduleId: string, module: unknown): void;
|
|
6
|
+
getModule?(id: string): unknown;
|
|
5
7
|
}, options?: {
|
|
6
8
|
dryRun?: boolean;
|
|
7
|
-
|
|
9
|
+
verify?: boolean;
|
|
10
|
+
verifiers?: Verifier[];
|
|
11
|
+
}): Promise<WriteResult[]>;
|
|
8
12
|
private _toFunctionModule;
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=registry-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-writer.d.ts","sourceRoot":"","sources":["../../src/output/registry-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"registry-writer.d.ts","sourceRoot":"","sources":["../../src/output/registry-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAIxD,qBAAa,cAAc;IACnB,KAAK,CACT,OAAO,EAAE,aAAa,EAAE,EACxB,QAAQ,EAAE;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;QAAC,SAAS,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,EAChG,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;KAAE,GACvE,OAAO,CAAC,WAAW,EAAE,CAAC;YA+BX,iBAAiB;CAwBhC"}
|