@contractspec/bundle.library 3.8.4 → 3.8.5
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/.turbo/turbo-build.log +126 -112
- package/CHANGELOG.md +6 -0
- package/dist/application/index.js +806 -131
- package/dist/application/mcp/cliMcp.js +21 -2
- package/dist/application/mcp/common.js +21 -2
- package/dist/application/mcp/common.test.d.ts +1 -0
- package/dist/application/mcp/contractsMcp.js +21 -2
- package/dist/application/mcp/docsMcp.catalog.d.ts +2 -0
- package/dist/application/mcp/docsMcp.catalog.js +382 -0
- package/dist/application/mcp/docsMcp.d.ts +5 -1
- package/dist/application/mcp/docsMcp.data.d.ts +85 -0
- package/dist/application/mcp/docsMcp.data.js +148 -0
- package/dist/application/mcp/docsMcp.js +776 -101
- package/dist/application/mcp/docsMcp.prompts.d.ts +3 -0
- package/dist/application/mcp/docsMcp.prompts.js +522 -0
- package/dist/application/mcp/docsMcp.reference.d.ts +24 -0
- package/dist/application/mcp/docsMcp.reference.js +236 -0
- package/dist/application/mcp/docsMcp.resources.d.ts +3 -0
- package/dist/application/mcp/docsMcp.resources.js +520 -0
- package/dist/application/mcp/docsMcp.test.d.ts +1 -0
- package/dist/application/mcp/docsMcp.tools.d.ts +3 -0
- package/dist/application/mcp/docsMcp.tools.js +519 -0
- package/dist/application/mcp/index.js +806 -131
- package/dist/application/mcp/internalMcp.js +21 -2
- package/dist/application/mcp/normalizeMcpRequest.d.ts +1 -0
- package/dist/application/mcp/normalizeMcpRequest.js +22 -0
- package/dist/application/mcp/providerRankingMcp.js +21 -2
- package/dist/features/index.js +15 -15
- package/dist/index.js +171 -171
- package/dist/node/application/index.js +806 -131
- package/dist/node/application/mcp/cliMcp.js +21 -2
- package/dist/node/application/mcp/common.js +21 -2
- package/dist/node/application/mcp/contractsMcp.js +21 -2
- package/dist/node/application/mcp/docsMcp.catalog.js +381 -0
- package/dist/node/application/mcp/docsMcp.data.js +147 -0
- package/dist/node/application/mcp/docsMcp.js +776 -101
- package/dist/node/application/mcp/docsMcp.prompts.js +521 -0
- package/dist/node/application/mcp/docsMcp.reference.js +235 -0
- package/dist/node/application/mcp/docsMcp.resources.js +519 -0
- package/dist/node/application/mcp/docsMcp.tools.js +518 -0
- package/dist/node/application/mcp/index.js +806 -131
- package/dist/node/application/mcp/internalMcp.js +21 -2
- package/dist/node/application/mcp/normalizeMcpRequest.js +21 -0
- package/dist/node/application/mcp/providerRankingMcp.js +21 -2
- package/dist/node/features/index.js +15 -15
- package/dist/node/index.js +171 -171
- package/dist/node/presentation/features/hooks/index.js +12 -12
- package/dist/node/presentation/features/hooks/useContractsRegistry.js +12 -12
- package/dist/node/presentation/features/index.js +12 -12
- package/dist/node/presentation/features/organisms/FeatureDataViewsList.js +12 -12
- package/dist/node/presentation/features/organisms/FeatureEventsList.js +12 -12
- package/dist/node/presentation/features/organisms/FeatureFormsList.js +12 -12
- package/dist/node/presentation/features/organisms/FeaturePresentationsList.js +12 -12
- package/dist/node/presentation/features/organisms/index.js +12 -12
- package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +12 -12
- package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/index.js +12 -12
- package/dist/node/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +12 -12
- package/dist/node/presentation/features/templates/FeatureEventsTemplate/index.js +12 -12
- package/dist/node/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +12 -12
- package/dist/node/presentation/features/templates/FeatureFormsTemplate/index.js +12 -12
- package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +12 -12
- package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/index.js +12 -12
- package/dist/presentation/features/hooks/index.js +12 -12
- package/dist/presentation/features/hooks/useContractsRegistry.js +12 -12
- package/dist/presentation/features/index.js +12 -12
- package/dist/presentation/features/organisms/FeatureDataViewsList.js +12 -12
- package/dist/presentation/features/organisms/FeatureEventsList.js +12 -12
- package/dist/presentation/features/organisms/FeatureFormsList.js +12 -12
- package/dist/presentation/features/organisms/FeaturePresentationsList.js +12 -12
- package/dist/presentation/features/organisms/index.js +12 -12
- package/dist/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +12 -12
- package/dist/presentation/features/templates/FeatureDataViewsTemplate/index.js +12 -12
- package/dist/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +12 -12
- package/dist/presentation/features/templates/FeatureEventsTemplate/index.js +12 -12
- package/dist/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +12 -12
- package/dist/presentation/features/templates/FeatureFormsTemplate/index.js +12 -12
- package/dist/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +12 -12
- package/dist/presentation/features/templates/FeaturePresentationsTemplate/index.js +12 -12
- package/package.json +85 -1
- package/src/application/mcp/common.test.ts +64 -0
- package/src/application/mcp/common.ts +5 -2
- package/src/application/mcp/docsMcp.catalog.ts +2 -0
- package/src/application/mcp/docsMcp.data.ts +196 -0
- package/src/application/mcp/docsMcp.prompts.ts +165 -0
- package/src/application/mcp/docsMcp.reference.ts +152 -0
- package/src/application/mcp/docsMcp.resources.ts +194 -0
- package/src/application/mcp/docsMcp.test.ts +148 -0
- package/src/application/mcp/docsMcp.tools.ts +183 -0
- package/src/application/mcp/docsMcp.ts +13 -177
- package/src/application/mcp/normalizeMcpRequest.ts +30 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/features/contracts-registry.ts
|
|
3
|
+
import {
|
|
4
|
+
EventRegistry,
|
|
5
|
+
OperationSpecRegistry
|
|
6
|
+
} from "@contractspec/lib.contracts-spec";
|
|
7
|
+
import {
|
|
8
|
+
DataViewRegistry
|
|
9
|
+
} from "@contractspec/lib.contracts-spec/data-views";
|
|
10
|
+
import {
|
|
11
|
+
ContractReferenceDataView,
|
|
12
|
+
ContractReferenceQuery,
|
|
13
|
+
DocsGenerateCommand,
|
|
14
|
+
DocsGeneratedEvent,
|
|
15
|
+
DocsIndexDataView,
|
|
16
|
+
DocsIndexQuery,
|
|
17
|
+
DocsLayoutPresentation,
|
|
18
|
+
DocsPublishCommand,
|
|
19
|
+
DocsPublishedEvent,
|
|
20
|
+
DocsReferencePagePresentation,
|
|
21
|
+
DocsSearchForm,
|
|
22
|
+
ExampleCatalogDataView
|
|
23
|
+
} from "@contractspec/lib.contracts-spec/docs";
|
|
24
|
+
import { FormRegistry } from "@contractspec/lib.contracts-spec/forms";
|
|
25
|
+
import {
|
|
26
|
+
PresentationRegistry
|
|
27
|
+
} from "@contractspec/lib.contracts-spec/presentations";
|
|
28
|
+
import {
|
|
29
|
+
serializeDataViewSpec,
|
|
30
|
+
serializeEventSpec,
|
|
31
|
+
serializeFormSpec,
|
|
32
|
+
serializeOperationSpec,
|
|
33
|
+
serializePresentationSpec
|
|
34
|
+
} from "@contractspec/lib.contracts-spec/serialization";
|
|
35
|
+
var operationRegistry = null;
|
|
36
|
+
function createContractSpecOperationRegistry() {
|
|
37
|
+
const registry = new OperationSpecRegistry;
|
|
38
|
+
registry.register(DocsIndexQuery).register(ContractReferenceQuery).register(DocsGenerateCommand).register(DocsPublishCommand);
|
|
39
|
+
return registry;
|
|
40
|
+
}
|
|
41
|
+
function getContractSpecOperationRegistry() {
|
|
42
|
+
if (!operationRegistry) {
|
|
43
|
+
operationRegistry = createContractSpecOperationRegistry();
|
|
44
|
+
}
|
|
45
|
+
return operationRegistry;
|
|
46
|
+
}
|
|
47
|
+
function resolveOperationSpec(key, version) {
|
|
48
|
+
return getContractSpecOperationRegistry().get(key, version);
|
|
49
|
+
}
|
|
50
|
+
var eventRegistry = null;
|
|
51
|
+
function createContractSpecEventRegistry() {
|
|
52
|
+
const registry = new EventRegistry;
|
|
53
|
+
registry.register(DocsGeneratedEvent).register(DocsPublishedEvent);
|
|
54
|
+
return registry;
|
|
55
|
+
}
|
|
56
|
+
function getContractSpecEventRegistry() {
|
|
57
|
+
if (!eventRegistry) {
|
|
58
|
+
eventRegistry = createContractSpecEventRegistry();
|
|
59
|
+
}
|
|
60
|
+
return eventRegistry;
|
|
61
|
+
}
|
|
62
|
+
function resolveEventSpec(key, version) {
|
|
63
|
+
return getContractSpecEventRegistry().get(key, version);
|
|
64
|
+
}
|
|
65
|
+
var presentationRegistry = null;
|
|
66
|
+
function createContractSpecPresentationRegistry() {
|
|
67
|
+
const registry = new PresentationRegistry;
|
|
68
|
+
registry.register(DocsLayoutPresentation).register(DocsReferencePagePresentation);
|
|
69
|
+
return registry;
|
|
70
|
+
}
|
|
71
|
+
function getContractSpecPresentationRegistry() {
|
|
72
|
+
if (!presentationRegistry) {
|
|
73
|
+
presentationRegistry = createContractSpecPresentationRegistry();
|
|
74
|
+
}
|
|
75
|
+
return presentationRegistry;
|
|
76
|
+
}
|
|
77
|
+
function resolvePresentationSpec(key, version) {
|
|
78
|
+
return getContractSpecPresentationRegistry().get(key, version);
|
|
79
|
+
}
|
|
80
|
+
var dataViewRegistry = null;
|
|
81
|
+
function createContractSpecDataViewRegistry() {
|
|
82
|
+
const registry = new DataViewRegistry;
|
|
83
|
+
registry.register(DocsIndexDataView).register(ContractReferenceDataView).register(ExampleCatalogDataView);
|
|
84
|
+
return registry;
|
|
85
|
+
}
|
|
86
|
+
function getContractSpecDataViewRegistry() {
|
|
87
|
+
if (!dataViewRegistry) {
|
|
88
|
+
dataViewRegistry = createContractSpecDataViewRegistry();
|
|
89
|
+
}
|
|
90
|
+
return dataViewRegistry;
|
|
91
|
+
}
|
|
92
|
+
function resolveDataViewSpec(key, version) {
|
|
93
|
+
return getContractSpecDataViewRegistry().get(key, version);
|
|
94
|
+
}
|
|
95
|
+
var formRegistry = null;
|
|
96
|
+
function createContractSpecFormRegistry() {
|
|
97
|
+
const registry = new FormRegistry;
|
|
98
|
+
registry.register(DocsSearchForm);
|
|
99
|
+
return registry;
|
|
100
|
+
}
|
|
101
|
+
function getContractSpecFormRegistry() {
|
|
102
|
+
if (!formRegistry) {
|
|
103
|
+
formRegistry = createContractSpecFormRegistry();
|
|
104
|
+
}
|
|
105
|
+
return formRegistry;
|
|
106
|
+
}
|
|
107
|
+
function resolveFormSpec(key, _version) {
|
|
108
|
+
return getContractSpecFormRegistry().get(key);
|
|
109
|
+
}
|
|
110
|
+
function resolveSerializedOperationSpec(key, version) {
|
|
111
|
+
const spec = resolveOperationSpec(key, version);
|
|
112
|
+
return serializeOperationSpec(spec) ?? undefined;
|
|
113
|
+
}
|
|
114
|
+
function resolveSerializedEventSpec(key, version) {
|
|
115
|
+
const spec = resolveEventSpec(key, version);
|
|
116
|
+
return serializeEventSpec(spec) ?? undefined;
|
|
117
|
+
}
|
|
118
|
+
function resolveSerializedPresentationSpec(key, version) {
|
|
119
|
+
const spec = resolvePresentationSpec(key, version);
|
|
120
|
+
return serializePresentationSpec(spec) ?? undefined;
|
|
121
|
+
}
|
|
122
|
+
function resolveSerializedDataViewSpec(key, version) {
|
|
123
|
+
const spec = resolveDataViewSpec(key, version);
|
|
124
|
+
return serializeDataViewSpec(spec) ?? undefined;
|
|
125
|
+
}
|
|
126
|
+
function resolveSerializedFormSpec(key, version) {
|
|
127
|
+
const spec = resolveFormSpec(key, version);
|
|
128
|
+
return serializeFormSpec(spec) ?? undefined;
|
|
129
|
+
}
|
|
130
|
+
function resetContractSpecOperationRegistry() {
|
|
131
|
+
operationRegistry = null;
|
|
132
|
+
}
|
|
133
|
+
function resetContractSpecEventRegistry() {
|
|
134
|
+
eventRegistry = null;
|
|
135
|
+
}
|
|
136
|
+
function resetContractSpecPresentationRegistry() {
|
|
137
|
+
presentationRegistry = null;
|
|
138
|
+
}
|
|
139
|
+
function resetContractSpecDataViewRegistry() {
|
|
140
|
+
dataViewRegistry = null;
|
|
141
|
+
}
|
|
142
|
+
function resetContractSpecFormRegistry() {
|
|
143
|
+
formRegistry = null;
|
|
144
|
+
}
|
|
145
|
+
function resetAllContractSpecRegistries() {
|
|
146
|
+
resetContractSpecOperationRegistry();
|
|
147
|
+
resetContractSpecEventRegistry();
|
|
148
|
+
resetContractSpecPresentationRegistry();
|
|
149
|
+
resetContractSpecDataViewRegistry();
|
|
150
|
+
resetContractSpecFormRegistry();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/application/mcp/docsMcp.reference.ts
|
|
154
|
+
import { defaultDocRegistry } from "@contractspec/lib.contracts-spec/docs";
|
|
155
|
+
function normalizeText(value) {
|
|
156
|
+
return value?.trim().toLowerCase() ?? "";
|
|
157
|
+
}
|
|
158
|
+
function routeFromDocIds(docIds) {
|
|
159
|
+
for (const docId of docIds ?? []) {
|
|
160
|
+
const doc = defaultDocRegistry.get(docId);
|
|
161
|
+
if (doc)
|
|
162
|
+
return doc.route;
|
|
163
|
+
}
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
function toReference(spec, type, schema, policy) {
|
|
167
|
+
const title = spec.meta.title ?? spec.meta.key;
|
|
168
|
+
const route = routeFromDocIds(spec.meta.docId);
|
|
169
|
+
const description = spec.meta.description;
|
|
170
|
+
return {
|
|
171
|
+
key: spec.meta.key,
|
|
172
|
+
version: spec.meta.version,
|
|
173
|
+
type,
|
|
174
|
+
title,
|
|
175
|
+
description,
|
|
176
|
+
markdown: [
|
|
177
|
+
`# ${title}`,
|
|
178
|
+
`- Key: ${spec.meta.key}`,
|
|
179
|
+
`- Type: ${type}`,
|
|
180
|
+
`- Version: ${spec.meta.version}`,
|
|
181
|
+
route ? `- Docs route: ${route}` : "",
|
|
182
|
+
description ? `
|
|
183
|
+
${description}` : ""
|
|
184
|
+
].filter(Boolean).join(`
|
|
185
|
+
`),
|
|
186
|
+
...route ? { route } : {},
|
|
187
|
+
...schema ? { schema } : {},
|
|
188
|
+
...policy ? { policy } : {},
|
|
189
|
+
tags: spec.meta.tags ?? [],
|
|
190
|
+
owners: spec.meta.owners ?? [],
|
|
191
|
+
stability: spec.meta.stability
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function resolveContractReference(args) {
|
|
195
|
+
const includeSchema = args.includeSchema ?? false;
|
|
196
|
+
const requestedType = normalizeText(args.type);
|
|
197
|
+
const operation = resolveOperationSpec(args.key, args.version);
|
|
198
|
+
if (operation && (!requestedType || requestedType === "operation" || requestedType === operation.meta.kind)) {
|
|
199
|
+
return {
|
|
200
|
+
reference: toReference(operation, operation.meta.kind, includeSchema ? resolveSerializedOperationSpec(args.key, args.version) : undefined, operation.policy)
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const resolvers = [
|
|
204
|
+
{
|
|
205
|
+
type: "data-view",
|
|
206
|
+
spec: resolveDataViewSpec(args.key, args.version),
|
|
207
|
+
schema: includeSchema ? resolveSerializedDataViewSpec(args.key, args.version) : undefined
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
type: "form",
|
|
211
|
+
spec: resolveFormSpec(args.key, args.version),
|
|
212
|
+
schema: includeSchema ? resolveSerializedFormSpec(args.key, args.version) : undefined
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
type: "presentation",
|
|
216
|
+
spec: resolvePresentationSpec(args.key, args.version),
|
|
217
|
+
schema: includeSchema ? resolveSerializedPresentationSpec(args.key, args.version) : undefined
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
type: "event",
|
|
221
|
+
spec: resolveEventSpec(args.key, args.version),
|
|
222
|
+
schema: includeSchema ? resolveSerializedEventSpec(args.key, args.version) : undefined
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
for (const candidate of resolvers) {
|
|
226
|
+
if (candidate.spec && (!requestedType || requestedType === candidate.type)) {
|
|
227
|
+
return {
|
|
228
|
+
reference: toReference(candidate.spec, candidate.type, candidate.schema)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
throw new Error(`Contract reference not found: ${args.key}`);
|
|
233
|
+
}
|
|
234
|
+
export {
|
|
235
|
+
resolveContractReference
|
|
236
|
+
};
|