@macss/modular-api 0.4.6 → 0.5.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/README.md +76 -8
- package/dist/core/logger/logger.d.ts +1 -0
- package/dist/core/logger/logger.js +1 -0
- package/dist/core/logger/logging_middleware.js +11 -0
- package/dist/core/modular_api.d.ts +8 -0
- package/dist/core/modular_api.js +99 -42
- package/dist/core/official_plugins.d.ts +41 -0
- package/dist/core/official_plugins.js +237 -0
- package/dist/core/plugin.d.ts +182 -0
- package/dist/core/plugin.js +314 -0
- package/dist/core/request_pipeline_audit.d.ts +15 -0
- package/dist/core/request_pipeline_audit.js +29 -0
- package/dist/core/unhandled_request_error_handler.d.ts +2 -0
- package/dist/core/unhandled_request_error_handler.js +17 -0
- package/dist/graphql/catalog/graphql_catalog_builder.d.ts +149 -0
- package/dist/graphql/catalog/graphql_catalog_builder.js +564 -0
- package/dist/graphql/metadata/graphql_metadata_parser.d.ts +53 -0
- package/dist/graphql/metadata/graphql_metadata_parser.js +373 -0
- package/dist/graphql/read/sql_read_contract.d.ts +155 -0
- package/dist/graphql/read/sql_read_contract.js +194 -0
- package/dist/graphql/read/sqlserver_read_compiler.d.ts +58 -0
- package/dist/graphql/read/sqlserver_read_compiler.js +279 -0
- package/dist/graphql/runtime/graphql_artifacts.d.ts +43 -0
- package/dist/graphql/runtime/graphql_artifacts.js +512 -0
- package/dist/graphql/runtime/graphql_runtime_options.d.ts +52 -0
- package/dist/graphql/runtime/graphql_runtime_options.js +60 -0
- package/dist/graphql/runtime/graphql_runtime_plugin.d.ts +18 -0
- package/dist/graphql/runtime/graphql_runtime_plugin.js +946 -0
- package/dist/graphql/schema/graphql_schema_sdl_generator.d.ts +17 -0
- package/dist/graphql/schema/graphql_schema_sdl_generator.js +221 -0
- package/dist/graphql/sqlserver/physical_model.d.ts +28 -0
- package/dist/graphql/sqlserver/physical_model.js +8 -0
- package/dist/graphql/sqlserver/sql_server_connection_settings.d.ts +15 -0
- package/dist/graphql/sqlserver/sql_server_connection_settings.js +28 -0
- package/dist/graphql/sqlserver/sql_server_metadata_reader.d.ts +39 -0
- package/dist/graphql/sqlserver/sql_server_metadata_reader.js +294 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +58 -1
- package/dist/openapi/swagger_docs.d.ts +4 -0
- package/dist/openapi/swagger_docs.js +6 -2
- package/package.json +8 -6
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimePluginHost = exports.PluginHostError = exports.HOST_API_VERSION = void 0;
|
|
4
|
+
exports.orderPlugins = orderPlugins;
|
|
5
|
+
const logging_middleware_1 = require("./logger/logging_middleware");
|
|
6
|
+
const request_pipeline_audit_1 = require("./request_pipeline_audit");
|
|
7
|
+
const registry_1 = require("./registry");
|
|
8
|
+
exports.HOST_API_VERSION = '0.1.0';
|
|
9
|
+
const ALLOWED_MIDDLEWARE_SLOTS = new Set(['preRouting', 'preHandler', 'postHandler']);
|
|
10
|
+
class PluginHostError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
pluginId;
|
|
13
|
+
resourceId;
|
|
14
|
+
constructor(code, message, pluginId, resourceId) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.pluginId = pluginId;
|
|
18
|
+
this.resourceId = resourceId;
|
|
19
|
+
this.name = 'PluginHostError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PluginHostError = PluginHostError;
|
|
23
|
+
class RuntimePluginHost {
|
|
24
|
+
metadataValue;
|
|
25
|
+
registeredRoutes = [];
|
|
26
|
+
middlewares = [];
|
|
27
|
+
capabilitiesMap = new Map();
|
|
28
|
+
extensionPoints = new Map();
|
|
29
|
+
extensionValues = new Map();
|
|
30
|
+
startupValidations = [];
|
|
31
|
+
shutdownCallbacks = [];
|
|
32
|
+
routeKeys = new Set();
|
|
33
|
+
middlewareSequence = 0;
|
|
34
|
+
activePluginId;
|
|
35
|
+
frozen = false;
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.metadataValue = {
|
|
38
|
+
basePath: normalizeBasePath(options.basePath),
|
|
39
|
+
title: options.title,
|
|
40
|
+
version: options.version,
|
|
41
|
+
hostApiVersion: exports.HOST_API_VERSION,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
metadata() {
|
|
45
|
+
return { ...this.metadataValue };
|
|
46
|
+
}
|
|
47
|
+
modules() {
|
|
48
|
+
return [...new Set(registry_1.apiRegistry.routes.map((route) => route.module))].map((name) => ({ name }));
|
|
49
|
+
}
|
|
50
|
+
useCases() {
|
|
51
|
+
return registry_1.apiRegistry.routes.map((route) => ({
|
|
52
|
+
module: route.module,
|
|
53
|
+
command: route.command,
|
|
54
|
+
method: route.method,
|
|
55
|
+
path: route.path,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
registerRoute(route) {
|
|
59
|
+
this.assertMutable();
|
|
60
|
+
const finalPath = joinPath(this.metadataValue.basePath, route.path);
|
|
61
|
+
const key = `${route.method.toUpperCase()} ${finalPath}`;
|
|
62
|
+
if (this.routeKeys.has(key)) {
|
|
63
|
+
throw new PluginHostError('ROUTE_CONFLICT', `Route conflict for ${key}`, undefined, key);
|
|
64
|
+
}
|
|
65
|
+
this.routeKeys.add(key);
|
|
66
|
+
this.registeredRoutes.push({ finalPath, route, pluginId: this.activePluginId });
|
|
67
|
+
}
|
|
68
|
+
routes() {
|
|
69
|
+
return this.registeredRoutes.map((registration) => ({
|
|
70
|
+
pluginId: registration.pluginId,
|
|
71
|
+
id: registration.route.id,
|
|
72
|
+
method: registration.route.method,
|
|
73
|
+
path: registration.finalPath,
|
|
74
|
+
visibility: registration.route.visibility,
|
|
75
|
+
openapi: registration.route.openapi,
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
registerMiddleware(middleware) {
|
|
79
|
+
this.assertMutable();
|
|
80
|
+
if (!ALLOWED_MIDDLEWARE_SLOTS.has(middleware.slot)) {
|
|
81
|
+
throw new PluginHostError('PLUGIN_VALIDATION_FAILED', `Unknown middleware slot: ${middleware.slot}`, undefined, middleware.id);
|
|
82
|
+
}
|
|
83
|
+
this.middlewares.push({
|
|
84
|
+
definition: {
|
|
85
|
+
...middleware,
|
|
86
|
+
order: middleware.order ?? 0,
|
|
87
|
+
handler: instrumentPluginMiddleware({ ...middleware, order: middleware.order ?? 0 }, this.activePluginId),
|
|
88
|
+
},
|
|
89
|
+
sequence: this.middlewareSequence++,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
beginPluginSetup(pluginId) {
|
|
93
|
+
this.assertMutable();
|
|
94
|
+
this.activePluginId = pluginId;
|
|
95
|
+
}
|
|
96
|
+
endPluginSetup() {
|
|
97
|
+
this.activePluginId = undefined;
|
|
98
|
+
}
|
|
99
|
+
exposeCapability(capability) {
|
|
100
|
+
this.assertMutable();
|
|
101
|
+
if (this.capabilitiesMap.has(capability.id)) {
|
|
102
|
+
throw new PluginHostError('CAPABILITY_CONFLICT', `Capability already exposed: ${capability.id}`, undefined, capability.id);
|
|
103
|
+
}
|
|
104
|
+
this.capabilitiesMap.set(capability.id, { ...capability });
|
|
105
|
+
}
|
|
106
|
+
resolveCapability(id) {
|
|
107
|
+
return this.capabilitiesMap.get(id) ?? null;
|
|
108
|
+
}
|
|
109
|
+
requireCapability(id) {
|
|
110
|
+
const capability = this.resolveCapability(id);
|
|
111
|
+
if (!capability) {
|
|
112
|
+
throw new PluginHostError('CAPABILITY_REQUIRED_MISSING', `Missing capability: ${id}`, undefined, id);
|
|
113
|
+
}
|
|
114
|
+
return capability;
|
|
115
|
+
}
|
|
116
|
+
declareModuleExtensionPoint(point) {
|
|
117
|
+
this.assertMutable();
|
|
118
|
+
if (this.extensionPoints.has(point.id)) {
|
|
119
|
+
throw new PluginHostError('MODULE_EXTENSION_POINT_CONFLICT', `Duplicate extension point: ${point.id}`, undefined, point.id);
|
|
120
|
+
}
|
|
121
|
+
this.extensionPoints.set(point.id, point);
|
|
122
|
+
}
|
|
123
|
+
contributeModuleExtension(contribution) {
|
|
124
|
+
this.assertMutable();
|
|
125
|
+
const point = this.extensionPoints.get(contribution.extensionPointId);
|
|
126
|
+
if (!point) {
|
|
127
|
+
throw new PluginHostError('MODULE_EXTENSION_CONFLICT', `Unknown extension point: ${contribution.extensionPointId}`, undefined, contribution.extensionPointId);
|
|
128
|
+
}
|
|
129
|
+
const key = `${contribution.extensionPointId}:${contribution.moduleName}`;
|
|
130
|
+
const values = this.extensionValues.get(key) ?? [];
|
|
131
|
+
if (point.mode === 'single' && values.length > 0) {
|
|
132
|
+
throw new PluginHostError('MODULE_EXTENSION_CONFLICT', `Duplicate contribution for single extension point ${key}`, undefined, key);
|
|
133
|
+
}
|
|
134
|
+
values.push(contribution.value);
|
|
135
|
+
this.extensionValues.set(key, values);
|
|
136
|
+
}
|
|
137
|
+
addStartupValidation(validation) {
|
|
138
|
+
this.assertMutable();
|
|
139
|
+
this.startupValidations.push(validation);
|
|
140
|
+
}
|
|
141
|
+
onShutdown(callback) {
|
|
142
|
+
this.assertMutable();
|
|
143
|
+
this.shutdownCallbacks.push(callback);
|
|
144
|
+
}
|
|
145
|
+
freeze() {
|
|
146
|
+
this.frozen = true;
|
|
147
|
+
}
|
|
148
|
+
assertValid(additionalValidations = []) {
|
|
149
|
+
const blocking = [...this.startupValidations, ...additionalValidations].find((validation) => validation.blocking !== false);
|
|
150
|
+
if (blocking) {
|
|
151
|
+
throw new PluginHostError(blocking.code, blocking.message, blocking.pluginId, blocking.resourceId);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
applyRoutes(router) {
|
|
155
|
+
for (const registration of this.registeredRoutes) {
|
|
156
|
+
const method = registration.route.method.toLowerCase();
|
|
157
|
+
router[method](registration.finalPath, buildPluginRouteHandler(registration.route, this.capabilitiesMap));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
applyMiddlewares(slot, app) {
|
|
161
|
+
for (const middleware of this.middlewares
|
|
162
|
+
.filter((candidate) => candidate.definition.slot === slot)
|
|
163
|
+
.sort((left, right) => {
|
|
164
|
+
const orderDelta = (left.definition.order ?? 0) - (right.definition.order ?? 0);
|
|
165
|
+
return orderDelta !== 0 ? orderDelta : left.sequence - right.sequence;
|
|
166
|
+
})) {
|
|
167
|
+
app.use(middleware.definition.handler);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async shutdown() {
|
|
171
|
+
for (const callback of [...this.shutdownCallbacks].reverse()) {
|
|
172
|
+
await callback();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
assertMutable() {
|
|
176
|
+
if (this.frozen) {
|
|
177
|
+
throw new PluginHostError('PLUGIN_VALIDATION_FAILED', 'Plugin host registration is frozen');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.RuntimePluginHost = RuntimePluginHost;
|
|
182
|
+
function orderPlugins(plugins) {
|
|
183
|
+
const pluginsById = new Map();
|
|
184
|
+
for (const plugin of plugins) {
|
|
185
|
+
pluginsById.set(plugin.manifest.id, plugin);
|
|
186
|
+
}
|
|
187
|
+
const visitState = new Map();
|
|
188
|
+
const ordered = [];
|
|
189
|
+
const visit = (plugin) => {
|
|
190
|
+
const pluginId = plugin.manifest.id;
|
|
191
|
+
const state = visitState.get(pluginId);
|
|
192
|
+
if (state === 'visited') {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (state === 'visiting') {
|
|
196
|
+
throw new PluginHostError('PLUGIN_DEPENDENCY_CYCLE', `Plugin dependency cycle detected at ${pluginId}`, pluginId, pluginId);
|
|
197
|
+
}
|
|
198
|
+
visitState.set(pluginId, 'visiting');
|
|
199
|
+
for (const requirement of plugin.manifest.requires ?? []) {
|
|
200
|
+
if (requirement.type !== 'plugin') {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const dependency = pluginsById.get(requirement.id);
|
|
204
|
+
if (!dependency) {
|
|
205
|
+
throw new PluginHostError('PLUGIN_DEPENDENCY_MISSING', `Missing required plugin dependency ${requirement.id} for ${pluginId}`, pluginId, requirement.id);
|
|
206
|
+
}
|
|
207
|
+
visit(dependency);
|
|
208
|
+
}
|
|
209
|
+
visitState.set(pluginId, 'visited');
|
|
210
|
+
ordered.push(plugin);
|
|
211
|
+
};
|
|
212
|
+
for (const plugin of plugins) {
|
|
213
|
+
visit(plugin);
|
|
214
|
+
}
|
|
215
|
+
return ordered;
|
|
216
|
+
}
|
|
217
|
+
function buildPluginRouteHandler(route, capabilities) {
|
|
218
|
+
return async (req, res, next) => {
|
|
219
|
+
try {
|
|
220
|
+
const logger = res.locals[logging_middleware_1.LOGGER_LOCALS_KEY];
|
|
221
|
+
const response = await route.handler({
|
|
222
|
+
requestId: readRequestId(req, res),
|
|
223
|
+
logger,
|
|
224
|
+
method: req.method,
|
|
225
|
+
path: req.path,
|
|
226
|
+
headers: req.headers,
|
|
227
|
+
query: req.query,
|
|
228
|
+
body: req.body,
|
|
229
|
+
pathParams: Object.fromEntries(Object.entries(req.params).map(([key, value]) => [
|
|
230
|
+
key,
|
|
231
|
+
Array.isArray(value) ? (value[0] ?? '') : value,
|
|
232
|
+
])),
|
|
233
|
+
capabilities: () => capabilities,
|
|
234
|
+
});
|
|
235
|
+
if (response.headers) {
|
|
236
|
+
for (const [name, value] of Object.entries(response.headers)) {
|
|
237
|
+
res.setHeader(name, value);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (response.contentType) {
|
|
241
|
+
res.setHeader('Content-Type', response.contentType);
|
|
242
|
+
}
|
|
243
|
+
const status = response.status ?? 200;
|
|
244
|
+
const body = response.body;
|
|
245
|
+
if (body === undefined) {
|
|
246
|
+
res.sendStatus(status);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (typeof body === 'string' || Buffer.isBuffer(body)) {
|
|
250
|
+
res.status(status).send(body);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
res.status(status).json(body);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
next(error);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function readRequestId(req, res) {
|
|
261
|
+
const fromHeader = req.header('X-Request-ID');
|
|
262
|
+
if (fromHeader) {
|
|
263
|
+
return fromHeader;
|
|
264
|
+
}
|
|
265
|
+
const fromLogger = res.locals[logging_middleware_1.LOGGER_LOCALS_KEY];
|
|
266
|
+
return fromLogger?.traceId ?? 'unknown';
|
|
267
|
+
}
|
|
268
|
+
function normalizeBasePath(basePath) {
|
|
269
|
+
if (!basePath || basePath === '/') {
|
|
270
|
+
return '/';
|
|
271
|
+
}
|
|
272
|
+
return `/${basePath.trim().replace(/^\/+|\/+$/g, '')}`;
|
|
273
|
+
}
|
|
274
|
+
function normalizeRelativePath(path) {
|
|
275
|
+
const trimmed = path.trim();
|
|
276
|
+
if (!trimmed) {
|
|
277
|
+
throw new PluginHostError('PLUGIN_VALIDATION_FAILED', 'Plugin route path cannot be empty');
|
|
278
|
+
}
|
|
279
|
+
return `/${trimmed.replace(/^\/+|\/+$/g, '')}`;
|
|
280
|
+
}
|
|
281
|
+
function joinPath(basePath, relativePath) {
|
|
282
|
+
const normalizedBasePath = normalizeBasePath(basePath);
|
|
283
|
+
const normalizedRelativePath = normalizeRelativePath(relativePath);
|
|
284
|
+
if (normalizedBasePath === '/') {
|
|
285
|
+
return normalizedRelativePath;
|
|
286
|
+
}
|
|
287
|
+
return `${normalizedBasePath}${normalizedRelativePath}`.replace(/\/+/g, '/');
|
|
288
|
+
}
|
|
289
|
+
function instrumentPluginMiddleware(middleware, pluginId) {
|
|
290
|
+
return (req, res, next) => {
|
|
291
|
+
(0, request_pipeline_audit_1.setShortCircuitCandidate)(res, {
|
|
292
|
+
pluginId: pluginId ?? 'unknown',
|
|
293
|
+
middlewareId: middleware.id,
|
|
294
|
+
slot: middleware.slot,
|
|
295
|
+
});
|
|
296
|
+
const observedNext = (error) => {
|
|
297
|
+
(0, request_pipeline_audit_1.clearShortCircuitCandidate)(res, middleware.id);
|
|
298
|
+
next(error);
|
|
299
|
+
};
|
|
300
|
+
try {
|
|
301
|
+
const result = middleware.handler(req, res, observedNext);
|
|
302
|
+
if (result && typeof result.then === 'function') {
|
|
303
|
+
void Promise.resolve(result).catch((error) => {
|
|
304
|
+
(0, request_pipeline_audit_1.clearShortCircuitCandidate)(res, middleware.id);
|
|
305
|
+
next(error);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
(0, request_pipeline_audit_1.clearShortCircuitCandidate)(res, middleware.id);
|
|
311
|
+
next(error);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Response } from 'express';
|
|
2
|
+
export interface ShortCircuitAuditEntry {
|
|
3
|
+
pluginId: string;
|
|
4
|
+
middlewareId: string;
|
|
5
|
+
slot: string;
|
|
6
|
+
}
|
|
7
|
+
interface RequestPipelineAuditState {
|
|
8
|
+
shortCircuit?: ShortCircuitAuditEntry;
|
|
9
|
+
}
|
|
10
|
+
export declare const REQUEST_PIPELINE_AUDIT_LOCALS_KEY = "requestPipelineAudit";
|
|
11
|
+
export declare function ensureRequestPipelineAudit(res: Response): RequestPipelineAuditState;
|
|
12
|
+
export declare function setShortCircuitCandidate(res: Response, candidate: ShortCircuitAuditEntry): void;
|
|
13
|
+
export declare function clearShortCircuitCandidate(res: Response, middlewareId: string): void;
|
|
14
|
+
export declare function readShortCircuitCandidate(res: Response): ShortCircuitAuditEntry | undefined;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REQUEST_PIPELINE_AUDIT_LOCALS_KEY = void 0;
|
|
4
|
+
exports.ensureRequestPipelineAudit = ensureRequestPipelineAudit;
|
|
5
|
+
exports.setShortCircuitCandidate = setShortCircuitCandidate;
|
|
6
|
+
exports.clearShortCircuitCandidate = clearShortCircuitCandidate;
|
|
7
|
+
exports.readShortCircuitCandidate = readShortCircuitCandidate;
|
|
8
|
+
exports.REQUEST_PIPELINE_AUDIT_LOCALS_KEY = 'requestPipelineAudit';
|
|
9
|
+
function ensureRequestPipelineAudit(res) {
|
|
10
|
+
const existing = res.locals[exports.REQUEST_PIPELINE_AUDIT_LOCALS_KEY];
|
|
11
|
+
if (existing) {
|
|
12
|
+
return existing;
|
|
13
|
+
}
|
|
14
|
+
const created = {};
|
|
15
|
+
res.locals[exports.REQUEST_PIPELINE_AUDIT_LOCALS_KEY] = created;
|
|
16
|
+
return created;
|
|
17
|
+
}
|
|
18
|
+
function setShortCircuitCandidate(res, candidate) {
|
|
19
|
+
ensureRequestPipelineAudit(res).shortCircuit = candidate;
|
|
20
|
+
}
|
|
21
|
+
function clearShortCircuitCandidate(res, middlewareId) {
|
|
22
|
+
const audit = ensureRequestPipelineAudit(res);
|
|
23
|
+
if (audit.shortCircuit?.middlewareId === middlewareId) {
|
|
24
|
+
delete audit.shortCircuit;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function readShortCircuitCandidate(res) {
|
|
28
|
+
return ensureRequestPipelineAudit(res).shortCircuit;
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unhandledRequestErrorHandler = void 0;
|
|
4
|
+
const logging_middleware_1 = require("./logger/logging_middleware");
|
|
5
|
+
const unhandledRequestErrorHandler = (error, _req, res, next) => {
|
|
6
|
+
if (res.headersSent) {
|
|
7
|
+
next(error);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const logger = res.locals[logging_middleware_1.LOGGER_LOCALS_KEY];
|
|
11
|
+
logger?.error('Unhandled error in request pipeline', {
|
|
12
|
+
error: String(error),
|
|
13
|
+
status: 500,
|
|
14
|
+
});
|
|
15
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
16
|
+
};
|
|
17
|
+
exports.unhandledRequestErrorHandler = unhandledRequestErrorHandler;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { GraphqlMetadataFile } from '../metadata/graphql_metadata_parser';
|
|
2
|
+
import { PhysicalObjectKind, type PhysicalCatalog } from '../sqlserver/physical_model';
|
|
3
|
+
export declare enum GraphqlCatalogBuildMode {
|
|
4
|
+
Compile = "compile",
|
|
5
|
+
Runtime = "runtime"
|
|
6
|
+
}
|
|
7
|
+
export declare enum GraphqlCatalogDiagnosticSeverity {
|
|
8
|
+
Error = "error",
|
|
9
|
+
Warning = "warning",
|
|
10
|
+
Info = "info"
|
|
11
|
+
}
|
|
12
|
+
export declare enum GraphqlCatalogOrigin {
|
|
13
|
+
Inferred = "inferred",
|
|
14
|
+
Annotated = "annotated"
|
|
15
|
+
}
|
|
16
|
+
export declare enum GraphqlCatalogIdentityMode {
|
|
17
|
+
Single = "single",
|
|
18
|
+
Composite = "composite",
|
|
19
|
+
None = "none"
|
|
20
|
+
}
|
|
21
|
+
export declare enum GraphqlCatalogFieldVisibility {
|
|
22
|
+
Public = "public",
|
|
23
|
+
Hidden = "hidden"
|
|
24
|
+
}
|
|
25
|
+
export declare enum GraphqlCatalogRelationCardinality {
|
|
26
|
+
One = "one",
|
|
27
|
+
Many = "many"
|
|
28
|
+
}
|
|
29
|
+
export declare enum GraphqlCatalogPaginationMode {
|
|
30
|
+
Offset = "offset",
|
|
31
|
+
None = "none"
|
|
32
|
+
}
|
|
33
|
+
export interface GraphqlCatalogDiagnostic {
|
|
34
|
+
readonly severity: GraphqlCatalogDiagnosticSeverity;
|
|
35
|
+
readonly code: string;
|
|
36
|
+
readonly message: string;
|
|
37
|
+
readonly objectId?: string;
|
|
38
|
+
readonly field?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface GraphqlCatalogProvider {
|
|
41
|
+
readonly kind: string;
|
|
42
|
+
readonly engine: string;
|
|
43
|
+
readonly providerVersion: string;
|
|
44
|
+
}
|
|
45
|
+
export interface GraphqlCatalogBuild {
|
|
46
|
+
readonly mode: GraphqlCatalogBuildMode;
|
|
47
|
+
readonly sourceRoot: string;
|
|
48
|
+
readonly sourceDigest: string;
|
|
49
|
+
}
|
|
50
|
+
export interface GraphqlCatalogGraphqlNames {
|
|
51
|
+
readonly typeName: string;
|
|
52
|
+
readonly collectionField: string;
|
|
53
|
+
readonly itemField?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface GraphqlCatalogSource {
|
|
56
|
+
readonly schemaName: string;
|
|
57
|
+
readonly objectName: string;
|
|
58
|
+
readonly sourceFile?: string;
|
|
59
|
+
readonly providerObjectId?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface GraphqlCatalogIdentity {
|
|
62
|
+
readonly mode: GraphqlCatalogIdentityMode;
|
|
63
|
+
readonly fields: readonly string[];
|
|
64
|
+
readonly origin: GraphqlCatalogOrigin;
|
|
65
|
+
}
|
|
66
|
+
export interface GraphqlCatalogField {
|
|
67
|
+
readonly column: string;
|
|
68
|
+
readonly publicName: string;
|
|
69
|
+
readonly type: string;
|
|
70
|
+
readonly nullable: boolean;
|
|
71
|
+
readonly visibility: GraphqlCatalogFieldVisibility;
|
|
72
|
+
readonly filterable: boolean;
|
|
73
|
+
readonly sortable: boolean;
|
|
74
|
+
readonly sensitive: boolean;
|
|
75
|
+
readonly origin: GraphqlCatalogOrigin;
|
|
76
|
+
}
|
|
77
|
+
export interface GraphqlCatalogRelation {
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly target: string;
|
|
80
|
+
readonly cardinality: GraphqlCatalogRelationCardinality;
|
|
81
|
+
readonly sourceFields: readonly string[];
|
|
82
|
+
readonly targetFields: readonly string[];
|
|
83
|
+
readonly origin: GraphqlCatalogOrigin;
|
|
84
|
+
}
|
|
85
|
+
export interface GraphqlCatalogPagination {
|
|
86
|
+
readonly mode: GraphqlCatalogPaginationMode;
|
|
87
|
+
readonly defaultLimit: number;
|
|
88
|
+
readonly maxLimit: number;
|
|
89
|
+
}
|
|
90
|
+
export interface GraphqlCatalogCapabilities {
|
|
91
|
+
readonly item: boolean;
|
|
92
|
+
readonly collection: boolean;
|
|
93
|
+
readonly filter: boolean;
|
|
94
|
+
readonly sort: boolean;
|
|
95
|
+
readonly pagination: GraphqlCatalogPagination;
|
|
96
|
+
}
|
|
97
|
+
export interface GraphqlPublishedObject {
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly kind: PhysicalObjectKind;
|
|
100
|
+
readonly readonly: boolean;
|
|
101
|
+
readonly source: GraphqlCatalogSource;
|
|
102
|
+
readonly graphql: GraphqlCatalogGraphqlNames;
|
|
103
|
+
readonly identity: GraphqlCatalogIdentity;
|
|
104
|
+
readonly fields: readonly GraphqlCatalogField[];
|
|
105
|
+
readonly relations: readonly GraphqlCatalogRelation[];
|
|
106
|
+
readonly capabilities: GraphqlCatalogCapabilities;
|
|
107
|
+
}
|
|
108
|
+
export interface GraphqlCatalog {
|
|
109
|
+
readonly catalogVersion: string;
|
|
110
|
+
readonly provider: GraphqlCatalogProvider;
|
|
111
|
+
readonly build: GraphqlCatalogBuild;
|
|
112
|
+
readonly objects: readonly GraphqlPublishedObject[];
|
|
113
|
+
readonly diagnostics: readonly GraphqlCatalogDiagnostic[];
|
|
114
|
+
}
|
|
115
|
+
export declare class GraphqlCatalogNaming {
|
|
116
|
+
static typeNameForObjectName(value: string): string;
|
|
117
|
+
static publicFieldNameForColumn(value: string): string;
|
|
118
|
+
private static tokenize;
|
|
119
|
+
private static pascalToken;
|
|
120
|
+
private static camelToken;
|
|
121
|
+
}
|
|
122
|
+
export declare class GraphqlCatalogBuilder {
|
|
123
|
+
private readonly providerVersion;
|
|
124
|
+
private readonly sourceRoot;
|
|
125
|
+
private readonly buildMode;
|
|
126
|
+
private readonly engine;
|
|
127
|
+
constructor(options: {
|
|
128
|
+
providerVersion: string;
|
|
129
|
+
sourceRoot: string;
|
|
130
|
+
buildMode: GraphqlCatalogBuildMode;
|
|
131
|
+
engine: string;
|
|
132
|
+
});
|
|
133
|
+
build(options: {
|
|
134
|
+
physicalCatalog: PhysicalCatalog;
|
|
135
|
+
metadata: GraphqlMetadataFile;
|
|
136
|
+
}): GraphqlCatalog;
|
|
137
|
+
private resolveIdentity;
|
|
138
|
+
private buildObject;
|
|
139
|
+
private buildField;
|
|
140
|
+
private buildRelations;
|
|
141
|
+
private resolvePagination;
|
|
142
|
+
private normalizeScalar;
|
|
143
|
+
private detectDuplicateFieldNames;
|
|
144
|
+
private detectDuplicateObjectNames;
|
|
145
|
+
private sortDiagnostics;
|
|
146
|
+
private computeSourceDigest;
|
|
147
|
+
private objectDigestMap;
|
|
148
|
+
private canonicalize;
|
|
149
|
+
}
|