@ankhorage/data-sources 0.0.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 +15 -0
- package/README.md +12 -0
- package/dist/graphql/index.d.ts +83 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +327 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.d.ts +89 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +330 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/rest/index.d.ts +44 -0
- package/dist/rest/index.d.ts.map +1 -0
- package/dist/rest/index.js +158 -0
- package/dist/rest/index.js.map +1 -0
- package/package.json +1 -1
- package/src/graphql/index.test.ts +202 -0
- package/src/graphql/index.ts +486 -0
- package/src/index.ts +4 -0
- package/src/openapi/index.test.ts +296 -0
- package/src/openapi/index.ts +576 -0
- package/src/rest/index.test.ts +237 -0
- package/src/rest/index.ts +243 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
const OPENAPI_HTTP_METHODS = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put'];
|
|
2
|
+
const DATA_SCHEMA_PRIMITIVES = [
|
|
3
|
+
'array',
|
|
4
|
+
'boolean',
|
|
5
|
+
'integer',
|
|
6
|
+
'null',
|
|
7
|
+
'number',
|
|
8
|
+
'object',
|
|
9
|
+
'string',
|
|
10
|
+
];
|
|
11
|
+
export function importOpenApiDocument(input) {
|
|
12
|
+
const diagnostics = [];
|
|
13
|
+
const baseUrl = resolveOpenApiBaseUrl(input, diagnostics);
|
|
14
|
+
const schemas = normalizeOpenApiSchemas(input.document.components?.schemas, input.id, diagnostics);
|
|
15
|
+
const endpoints = normalizeOpenApiEndpoints(input, baseUrl, diagnostics);
|
|
16
|
+
const hasErrors = diagnostics.some((diagnostic) => diagnostic.severity === 'error');
|
|
17
|
+
if (hasErrors) {
|
|
18
|
+
return { ok: false, diagnostics };
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
ok: true,
|
|
22
|
+
data: {
|
|
23
|
+
id: input.id,
|
|
24
|
+
kind: 'openapi',
|
|
25
|
+
name: input.name ?? input.document.info?.title,
|
|
26
|
+
description: input.description ?? input.document.info?.description,
|
|
27
|
+
baseUrl,
|
|
28
|
+
credential: input.credential,
|
|
29
|
+
endpoints,
|
|
30
|
+
schemas,
|
|
31
|
+
import: {
|
|
32
|
+
url: input.documentUrl,
|
|
33
|
+
documentId: input.documentId,
|
|
34
|
+
version: input.document.info?.version,
|
|
35
|
+
},
|
|
36
|
+
metadata: input.metadata,
|
|
37
|
+
},
|
|
38
|
+
diagnostics,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function normalizeOpenApiOperationId(method, path, operationId) {
|
|
42
|
+
const rawId = operationId ?? `${method}-${path}`;
|
|
43
|
+
const normalized = rawId
|
|
44
|
+
.replace(/\{([^}]+)\}/g, '$1')
|
|
45
|
+
.replace(/[^A-Za-z0-9]+/g, '-')
|
|
46
|
+
.replace(/^-+|-+$/g, '')
|
|
47
|
+
.toLowerCase();
|
|
48
|
+
return normalized.length > 0 ? normalized : `${method}-root`;
|
|
49
|
+
}
|
|
50
|
+
export function normalizeOpenApiEndpointId(path) {
|
|
51
|
+
const normalized = path
|
|
52
|
+
.replace(/\{([^}]+)\}/g, '$1')
|
|
53
|
+
.replace(/[^A-Za-z0-9]+/g, '-')
|
|
54
|
+
.replace(/^-+|-+$/g, '')
|
|
55
|
+
.toLowerCase();
|
|
56
|
+
return normalized.length > 0 ? normalized : 'root';
|
|
57
|
+
}
|
|
58
|
+
export function normalizeOpenApiSchema(schema) {
|
|
59
|
+
const additionalProperties = normalizeAdditionalProperties(schema.additionalProperties);
|
|
60
|
+
return {
|
|
61
|
+
ref: normalizeOpenApiSchemaRef(schema.$ref),
|
|
62
|
+
type: normalizeSchemaType(schema.type),
|
|
63
|
+
title: schema.title,
|
|
64
|
+
description: schema.description,
|
|
65
|
+
enum: schema.enum,
|
|
66
|
+
const: schema.const,
|
|
67
|
+
default: schema.default,
|
|
68
|
+
format: schema.format,
|
|
69
|
+
nullable: schema.nullable,
|
|
70
|
+
required: schema.required,
|
|
71
|
+
properties: normalizeSchemaRecord(schema.properties),
|
|
72
|
+
additionalProperties,
|
|
73
|
+
items: schema.items === undefined ? undefined : normalizeOpenApiSchema(schema.items),
|
|
74
|
+
allOf: normalizeSchemaList(schema.allOf),
|
|
75
|
+
anyOf: normalizeSchemaList(schema.anyOf),
|
|
76
|
+
oneOf: normalizeSchemaList(schema.oneOf),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function resolveOpenApiBaseUrl(input, diagnostics) {
|
|
80
|
+
if (input.baseUrl !== undefined)
|
|
81
|
+
return input.baseUrl;
|
|
82
|
+
const servers = input.document.servers ?? [];
|
|
83
|
+
if (servers.length === 0) {
|
|
84
|
+
diagnostics.push({
|
|
85
|
+
code: 'ambiguous-server',
|
|
86
|
+
dataSourceId: input.id,
|
|
87
|
+
message: 'OpenAPI document does not define a server URL and no baseUrl override was provided.',
|
|
88
|
+
path: 'servers',
|
|
89
|
+
severity: 'warning',
|
|
90
|
+
});
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
if (servers.length > 1) {
|
|
94
|
+
diagnostics.push({
|
|
95
|
+
code: 'ambiguous-server',
|
|
96
|
+
dataSourceId: input.id,
|
|
97
|
+
message: 'OpenAPI document defines multiple servers. The first server URL was selected.',
|
|
98
|
+
path: 'servers',
|
|
99
|
+
severity: 'warning',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return servers[0]?.url;
|
|
103
|
+
}
|
|
104
|
+
function normalizeOpenApiSchemas(schemas, dataSourceId, diagnostics) {
|
|
105
|
+
if (schemas === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
const registry = {};
|
|
108
|
+
for (const [schemaId, schema] of Object.entries(schemas)) {
|
|
109
|
+
registry[schemaId] = normalizeOpenApiSchema(schema);
|
|
110
|
+
collectUnsupportedSchemaDiagnostics(schema, dataSourceId, `components.schemas.${schemaId}`, diagnostics);
|
|
111
|
+
}
|
|
112
|
+
return registry;
|
|
113
|
+
}
|
|
114
|
+
function normalizeOpenApiEndpoints(input, baseUrl, diagnostics) {
|
|
115
|
+
const { paths } = input.document;
|
|
116
|
+
if (paths === undefined || Object.keys(paths).length === 0) {
|
|
117
|
+
diagnostics.push({
|
|
118
|
+
code: 'invalid-config',
|
|
119
|
+
dataSourceId: input.id,
|
|
120
|
+
message: 'OpenAPI document must define at least one path.',
|
|
121
|
+
path: 'paths',
|
|
122
|
+
severity: 'error',
|
|
123
|
+
});
|
|
124
|
+
return {};
|
|
125
|
+
}
|
|
126
|
+
const endpoints = {};
|
|
127
|
+
const operationIds = new Set();
|
|
128
|
+
for (const [path, pathItem] of Object.entries(paths)) {
|
|
129
|
+
const endpointId = normalizeOpenApiEndpointId(path);
|
|
130
|
+
const operations = {};
|
|
131
|
+
for (const method of OPENAPI_HTTP_METHODS) {
|
|
132
|
+
const operation = pathItem[method];
|
|
133
|
+
if (operation === undefined)
|
|
134
|
+
continue;
|
|
135
|
+
const operationId = resolveUniqueOperationId(input.id, endpointId, method, path, operation.operationId, operationIds, diagnostics);
|
|
136
|
+
const parameters = normalizeOpenApiParameters([...(pathItem.parameters ?? []), ...(operation.parameters ?? [])], input.id, endpointId, operationId, diagnostics);
|
|
137
|
+
const request = normalizeOpenApiRequest(operation.requestBody, parameters);
|
|
138
|
+
const response = normalizeOpenApiResponse(operation.responses);
|
|
139
|
+
operations[operationId] = {
|
|
140
|
+
id: operationId,
|
|
141
|
+
endpointId,
|
|
142
|
+
name: operation.summary,
|
|
143
|
+
description: operation.description,
|
|
144
|
+
protocol: 'http',
|
|
145
|
+
intent: mapOpenApiMethodToIntent(method),
|
|
146
|
+
method: method.toUpperCase(),
|
|
147
|
+
path,
|
|
148
|
+
request,
|
|
149
|
+
response,
|
|
150
|
+
metadata: {
|
|
151
|
+
deprecated: operation.deprecated ?? false,
|
|
152
|
+
source: 'openapi',
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
endpoints[endpointId] = {
|
|
157
|
+
id: endpointId,
|
|
158
|
+
kind: 'http',
|
|
159
|
+
baseUrl,
|
|
160
|
+
path,
|
|
161
|
+
credential: input.credential,
|
|
162
|
+
operations,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return endpoints;
|
|
166
|
+
}
|
|
167
|
+
function resolveUniqueOperationId(dataSourceId, endpointId, method, path, operationId, operationIds, diagnostics) {
|
|
168
|
+
const normalized = normalizeOpenApiOperationId(method, path, operationId);
|
|
169
|
+
if (!operationIds.has(normalized)) {
|
|
170
|
+
operationIds.add(normalized);
|
|
171
|
+
return normalized;
|
|
172
|
+
}
|
|
173
|
+
let suffix = 2;
|
|
174
|
+
let uniqueId = `${normalized}-${suffix}`;
|
|
175
|
+
while (operationIds.has(uniqueId)) {
|
|
176
|
+
suffix += 1;
|
|
177
|
+
uniqueId = `${normalized}-${suffix}`;
|
|
178
|
+
}
|
|
179
|
+
operationIds.add(uniqueId);
|
|
180
|
+
diagnostics.push({
|
|
181
|
+
code: 'duplicate-operation-id',
|
|
182
|
+
dataSourceId,
|
|
183
|
+
endpointId,
|
|
184
|
+
operationId: uniqueId,
|
|
185
|
+
message: `OpenAPI operation id '${normalized}' is duplicated. Normalized to '${uniqueId}'.`,
|
|
186
|
+
path: `paths.${path}.${method}.operationId`,
|
|
187
|
+
severity: 'warning',
|
|
188
|
+
});
|
|
189
|
+
return uniqueId;
|
|
190
|
+
}
|
|
191
|
+
function normalizeOpenApiParameters(parameters, dataSourceId, endpointId, operationId, diagnostics) {
|
|
192
|
+
if (parameters.length === 0)
|
|
193
|
+
return undefined;
|
|
194
|
+
const normalized = [];
|
|
195
|
+
for (const parameter of parameters) {
|
|
196
|
+
const location = normalizeParameterLocation(parameter.in);
|
|
197
|
+
if (location === undefined) {
|
|
198
|
+
diagnostics.push({
|
|
199
|
+
code: 'invalid-config',
|
|
200
|
+
dataSourceId,
|
|
201
|
+
endpointId,
|
|
202
|
+
operationId,
|
|
203
|
+
message: `OpenAPI parameter '${parameter.name}' uses unsupported location '${parameter.in}'.`,
|
|
204
|
+
path: `paths.${endpointId}.parameters.${parameter.name}`,
|
|
205
|
+
severity: 'warning',
|
|
206
|
+
});
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
normalized.push({
|
|
210
|
+
name: parameter.name,
|
|
211
|
+
location,
|
|
212
|
+
required: parameter.required,
|
|
213
|
+
description: parameter.description,
|
|
214
|
+
schema: parameter.schema === undefined ? undefined : normalizeOpenApiSchema(parameter.schema),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return normalized;
|
|
218
|
+
}
|
|
219
|
+
function normalizeParameterLocation(location) {
|
|
220
|
+
if (location === 'cookie' ||
|
|
221
|
+
location === 'header' ||
|
|
222
|
+
location === 'path' ||
|
|
223
|
+
location === 'query') {
|
|
224
|
+
return location;
|
|
225
|
+
}
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
function normalizeOpenApiRequest(requestBody, parameters) {
|
|
229
|
+
const content = firstContentEntry(requestBody?.content);
|
|
230
|
+
if (requestBody === undefined && parameters === undefined)
|
|
231
|
+
return undefined;
|
|
232
|
+
return {
|
|
233
|
+
contentType: content?.contentType,
|
|
234
|
+
parameters,
|
|
235
|
+
schema: content?.schema === undefined ? undefined : normalizeOpenApiSchema(content.schema),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function normalizeOpenApiResponse(responses) {
|
|
239
|
+
if (responses === undefined)
|
|
240
|
+
return undefined;
|
|
241
|
+
const status = chooseResponseStatus(Object.keys(responses));
|
|
242
|
+
if (status === undefined)
|
|
243
|
+
return undefined;
|
|
244
|
+
const response = responses[status];
|
|
245
|
+
const content = firstContentEntry(response?.content);
|
|
246
|
+
return {
|
|
247
|
+
status,
|
|
248
|
+
contentType: content?.contentType,
|
|
249
|
+
description: response?.description,
|
|
250
|
+
schema: content?.schema === undefined ? undefined : normalizeOpenApiSchema(content.schema),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function firstContentEntry(content) {
|
|
254
|
+
if (content === undefined)
|
|
255
|
+
return undefined;
|
|
256
|
+
const [entry] = Object.entries(content);
|
|
257
|
+
if (entry === undefined)
|
|
258
|
+
return undefined;
|
|
259
|
+
const [contentType, media] = entry;
|
|
260
|
+
return { contentType, schema: media.schema };
|
|
261
|
+
}
|
|
262
|
+
function chooseResponseStatus(statuses) {
|
|
263
|
+
return statuses.find((status) => status.startsWith('2')) ?? statuses[0];
|
|
264
|
+
}
|
|
265
|
+
function mapOpenApiMethodToIntent(method) {
|
|
266
|
+
if (method === 'get' || method === 'head')
|
|
267
|
+
return 'read';
|
|
268
|
+
if (method === 'post')
|
|
269
|
+
return 'create';
|
|
270
|
+
if (method === 'delete')
|
|
271
|
+
return 'delete';
|
|
272
|
+
if (method === 'patch' || method === 'put')
|
|
273
|
+
return 'update';
|
|
274
|
+
return 'action';
|
|
275
|
+
}
|
|
276
|
+
function normalizeOpenApiSchemaRef(ref) {
|
|
277
|
+
if (ref === undefined)
|
|
278
|
+
return undefined;
|
|
279
|
+
const prefix = '#/components/schemas/';
|
|
280
|
+
if (ref.startsWith(prefix))
|
|
281
|
+
return { id: ref.slice(prefix.length) };
|
|
282
|
+
return { id: ref };
|
|
283
|
+
}
|
|
284
|
+
function normalizeSchemaRecord(record) {
|
|
285
|
+
if (record === undefined)
|
|
286
|
+
return undefined;
|
|
287
|
+
const normalized = {};
|
|
288
|
+
for (const [key, schema] of Object.entries(record)) {
|
|
289
|
+
normalized[key] = normalizeOpenApiSchema(schema);
|
|
290
|
+
}
|
|
291
|
+
return normalized;
|
|
292
|
+
}
|
|
293
|
+
function normalizeSchemaList(list) {
|
|
294
|
+
return list?.map((schema) => normalizeOpenApiSchema(schema));
|
|
295
|
+
}
|
|
296
|
+
function normalizeAdditionalProperties(additionalProperties) {
|
|
297
|
+
if (additionalProperties === undefined || typeof additionalProperties === 'boolean') {
|
|
298
|
+
return additionalProperties;
|
|
299
|
+
}
|
|
300
|
+
return normalizeOpenApiSchema(additionalProperties);
|
|
301
|
+
}
|
|
302
|
+
function normalizeSchemaType(type) {
|
|
303
|
+
if (type === undefined)
|
|
304
|
+
return undefined;
|
|
305
|
+
if (typeof type === 'string') {
|
|
306
|
+
return isDataSchemaPrimitive(type) ? type : undefined;
|
|
307
|
+
}
|
|
308
|
+
return type.filter(isDataSchemaPrimitive);
|
|
309
|
+
}
|
|
310
|
+
function isDataSchemaPrimitive(type) {
|
|
311
|
+
return DATA_SCHEMA_PRIMITIVES.some((primitive) => primitive === type);
|
|
312
|
+
}
|
|
313
|
+
function collectUnsupportedSchemaDiagnostics(schema, dataSourceId, path, diagnostics) {
|
|
314
|
+
if (typeof schema.type === 'string' && !isDataSchemaPrimitive(schema.type)) {
|
|
315
|
+
diagnostics.push({
|
|
316
|
+
code: 'unsupported-schema',
|
|
317
|
+
dataSourceId,
|
|
318
|
+
message: `OpenAPI schema type '${schema.type}' is not supported by the normalized schema model.`,
|
|
319
|
+
path: `${path}.type`,
|
|
320
|
+
severity: 'warning',
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
for (const [propertyName, propertySchema] of Object.entries(schema.properties ?? {})) {
|
|
324
|
+
collectUnsupportedSchemaDiagnostics(propertySchema, dataSourceId, `${path}.properties.${propertyName}`, diagnostics);
|
|
325
|
+
}
|
|
326
|
+
if (schema.items !== undefined) {
|
|
327
|
+
collectUnsupportedSchemaDiagnostics(schema.items, dataSourceId, `${path}.items`, diagnostics);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","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wB,MAAM,CAAC,IAAI,oDAAoD;YAChG,IAAI,EAAE,GAAG,IAAI,OAAO;YACpB,QAAQ,EAAE,SAAS;SACpB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC;QACrF,mCAAmC,CACjC,cAAc,EACd,YAAY,EACZ,GAAG,IAAI,eAAe,YAAY,EAAE,EACpC,WAAW,CACZ,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,mCAAmC,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI,QAAQ,EAAE,WAAW,CAAC,CAAC;IAChG,CAAC;AACH,CAAC","sourcesContent":["import type {\n CredentialRef,\n DataContractValue,\n DataEndpointConfig,\n DataOperationConfig,\n DataOperationIntent,\n DataOperationParameter,\n DataOperationParameterLocation,\n DataOperationRequest,\n DataOperationResponse,\n DataSchema,\n DataSchemaPrimitiveType,\n DataSchemaRegistry,\n DataSourceDiagnostic,\n DataSourceDiagnosticResult,\n EndpointId,\n OpenApiDataSourceConfig,\n OperationId,\n} from '@ankhorage/contracts/data';\n\nconst OPENAPI_HTTP_METHODS = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put'] as const;\nconst DATA_SCHEMA_PRIMITIVES = [\n 'array',\n 'boolean',\n 'integer',\n 'null',\n 'number',\n 'object',\n 'string',\n] as const satisfies readonly DataSchemaPrimitiveType[];\n\nexport type OpenApiHttpMethod = (typeof OPENAPI_HTTP_METHODS)[number];\n\nexport interface OpenApiServerObject {\n readonly url: string;\n readonly description?: string;\n}\n\nexport interface OpenApiSchemaObject {\n readonly $ref?: string;\n readonly type?: string | readonly string[];\n readonly title?: string;\n readonly description?: string;\n readonly enum?: readonly DataContractValue[];\n readonly const?: DataContractValue;\n readonly default?: DataContractValue;\n readonly format?: string;\n readonly nullable?: boolean;\n readonly required?: readonly string[];\n readonly properties?: Readonly<Record<string, OpenApiSchemaObject>>;\n readonly additionalProperties?: boolean | OpenApiSchemaObject;\n readonly items?: OpenApiSchemaObject;\n readonly allOf?: readonly OpenApiSchemaObject[];\n readonly anyOf?: readonly OpenApiSchemaObject[];\n readonly oneOf?: readonly OpenApiSchemaObject[];\n}\n\nexport interface OpenApiMediaTypeObject {\n readonly schema?: OpenApiSchemaObject;\n}\n\nexport interface OpenApiRequestBodyObject {\n readonly description?: string;\n readonly required?: boolean;\n readonly content?: Readonly<Record<string, OpenApiMediaTypeObject>>;\n}\n\nexport interface OpenApiResponseObject {\n readonly description?: string;\n readonly content?: Readonly<Record<string, OpenApiMediaTypeObject>>;\n}\n\nexport interface OpenApiParameterObject {\n readonly name: string;\n readonly in: string;\n readonly required?: boolean;\n readonly description?: string;\n readonly schema?: OpenApiSchemaObject;\n}\n\nexport interface OpenApiOperationObject {\n readonly operationId?: string;\n readonly summary?: string;\n readonly description?: string;\n readonly deprecated?: boolean;\n readonly parameters?: readonly OpenApiParameterObject[];\n readonly requestBody?: OpenApiRequestBodyObject;\n readonly responses?: Readonly<Record<string, OpenApiResponseObject>>;\n}\n\nexport type OpenApiPathItemObject = Partial<Record<OpenApiHttpMethod, OpenApiOperationObject>> & {\n readonly parameters?: readonly OpenApiParameterObject[];\n};\n\nexport interface OpenApiComponentsObject {\n readonly schemas?: Readonly<Record<string, OpenApiSchemaObject>>;\n readonly securitySchemes?: Readonly<Record<string, DataContractValue>>;\n}\n\nexport interface OpenApiDocumentObject {\n readonly openapi?: string;\n readonly info?: {\n readonly title?: string;\n readonly version?: string;\n readonly description?: string;\n };\n readonly servers?: readonly OpenApiServerObject[];\n readonly paths?: Readonly<Record<string, OpenApiPathItemObject>>;\n readonly components?: OpenApiComponentsObject;\n}\n\nexport interface OpenApiImportInput {\n readonly id: string;\n readonly document: OpenApiDocumentObject;\n readonly baseUrl?: string;\n readonly credential?: CredentialRef;\n readonly documentId?: string;\n readonly documentUrl?: string;\n readonly name?: string;\n readonly description?: string;\n readonly metadata?: DataContractValue;\n}\n\nexport type OpenApiImportResult = DataSourceDiagnosticResult<OpenApiDataSourceConfig>;\n\nexport function importOpenApiDocument(input: OpenApiImportInput): OpenApiImportResult {\n const diagnostics: DataSourceDiagnostic[] = [];\n const baseUrl = resolveOpenApiBaseUrl(input, diagnostics);\n const schemas = normalizeOpenApiSchemas(\n input.document.components?.schemas,\n input.id,\n diagnostics,\n );\n const endpoints = normalizeOpenApiEndpoints(input, baseUrl, diagnostics);\n const hasErrors = diagnostics.some((diagnostic) => diagnostic.severity === 'error');\n\n if (hasErrors) {\n return { ok: false, diagnostics };\n }\n\n return {\n ok: true,\n data: {\n id: input.id,\n kind: 'openapi',\n name: input.name ?? input.document.info?.title,\n description: input.description ?? input.document.info?.description,\n baseUrl,\n credential: input.credential,\n endpoints,\n schemas,\n import: {\n url: input.documentUrl,\n documentId: input.documentId,\n version: input.document.info?.version,\n },\n metadata: input.metadata,\n },\n diagnostics,\n };\n}\n\nexport function normalizeOpenApiOperationId(\n method: OpenApiHttpMethod,\n path: string,\n operationId?: string,\n): OperationId {\n const rawId = operationId ?? `${method}-${path}`;\n const normalized = rawId\n .replace(/\\{([^}]+)\\}/g, '$1')\n .replace(/[^A-Za-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .toLowerCase();\n\n return normalized.length > 0 ? normalized : `${method}-root`;\n}\n\nexport function normalizeOpenApiEndpointId(path: string): EndpointId {\n const normalized = path\n .replace(/\\{([^}]+)\\}/g, '$1')\n .replace(/[^A-Za-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .toLowerCase();\n\n return normalized.length > 0 ? normalized : 'root';\n}\n\nexport function normalizeOpenApiSchema(schema: OpenApiSchemaObject): DataSchema {\n const additionalProperties = normalizeAdditionalProperties(schema.additionalProperties);\n\n return {\n ref: normalizeOpenApiSchemaRef(schema.$ref),\n type: normalizeSchemaType(schema.type),\n title: schema.title,\n description: schema.description,\n enum: schema.enum,\n const: schema.const,\n default: schema.default,\n format: schema.format,\n nullable: schema.nullable,\n required: schema.required,\n properties: normalizeSchemaRecord(schema.properties),\n additionalProperties,\n items: schema.items === undefined ? undefined : normalizeOpenApiSchema(schema.items),\n allOf: normalizeSchemaList(schema.allOf),\n anyOf: normalizeSchemaList(schema.anyOf),\n oneOf: normalizeSchemaList(schema.oneOf),\n };\n}\n\nfunction resolveOpenApiBaseUrl(\n input: OpenApiImportInput,\n diagnostics: DataSourceDiagnostic[],\n): string | undefined {\n if (input.baseUrl !== undefined) return input.baseUrl;\n\n const servers = input.document.servers ?? [];\n\n if (servers.length === 0) {\n diagnostics.push({\n code: 'ambiguous-server',\n dataSourceId: input.id,\n message:\n 'OpenAPI document does not define a server URL and no baseUrl override was provided.',\n path: 'servers',\n severity: 'warning',\n });\n return undefined;\n }\n\n if (servers.length > 1) {\n diagnostics.push({\n code: 'ambiguous-server',\n dataSourceId: input.id,\n message: 'OpenAPI document defines multiple servers. The first server URL was selected.',\n path: 'servers',\n severity: 'warning',\n });\n }\n\n return servers[0]?.url;\n}\n\nfunction normalizeOpenApiSchemas(\n schemas: Readonly<Record<string, OpenApiSchemaObject>> | undefined,\n dataSourceId: string,\n diagnostics: DataSourceDiagnostic[],\n): DataSchemaRegistry | undefined {\n if (schemas === undefined) return undefined;\n\n const registry: Record<string, DataSchema> = {};\n\n for (const [schemaId, schema] of Object.entries(schemas)) {\n registry[schemaId] = normalizeOpenApiSchema(schema);\n collectUnsupportedSchemaDiagnostics(\n schema,\n dataSourceId,\n `components.schemas.${schemaId}`,\n diagnostics,\n );\n }\n\n return registry;\n}\n\nfunction normalizeOpenApiEndpoints(\n input: OpenApiImportInput,\n baseUrl: string | undefined,\n diagnostics: DataSourceDiagnostic[],\n): Record<EndpointId, DataEndpointConfig> {\n const { paths } = input.document;\n\n if (paths === undefined || Object.keys(paths).length === 0) {\n diagnostics.push({\n code: 'invalid-config',\n dataSourceId: input.id,\n message: 'OpenAPI document must define at least one path.',\n path: 'paths',\n severity: 'error',\n });\n return {};\n }\n\n const endpoints: Record<EndpointId, DataEndpointConfig> = {};\n const operationIds = new Set<OperationId>();\n\n for (const [path, pathItem] of Object.entries(paths)) {\n const endpointId = normalizeOpenApiEndpointId(path);\n const operations: Record<OperationId, DataOperationConfig> = {};\n\n for (const method of OPENAPI_HTTP_METHODS) {\n const operation = pathItem[method];\n if (operation === undefined) continue;\n\n const operationId = resolveUniqueOperationId(\n input.id,\n endpointId,\n method,\n path,\n operation.operationId,\n operationIds,\n diagnostics,\n );\n const parameters = normalizeOpenApiParameters(\n [...(pathItem.parameters ?? []), ...(operation.parameters ?? [])],\n input.id,\n endpointId,\n operationId,\n diagnostics,\n );\n const request = normalizeOpenApiRequest(operation.requestBody, parameters);\n const response = normalizeOpenApiResponse(operation.responses);\n\n operations[operationId] = {\n id: operationId,\n endpointId,\n name: operation.summary,\n description: operation.description,\n protocol: 'http',\n intent: mapOpenApiMethodToIntent(method),\n method: method.toUpperCase(),\n path,\n request,\n response,\n metadata: {\n deprecated: operation.deprecated ?? false,\n source: 'openapi',\n },\n };\n }\n\n endpoints[endpointId] = {\n id: endpointId,\n kind: 'http',\n baseUrl,\n path,\n credential: input.credential,\n operations,\n };\n }\n\n return endpoints;\n}\n\nfunction resolveUniqueOperationId(\n dataSourceId: string,\n endpointId: EndpointId,\n method: OpenApiHttpMethod,\n path: string,\n operationId: string | undefined,\n operationIds: Set<OperationId>,\n diagnostics: DataSourceDiagnostic[],\n): OperationId {\n const normalized = normalizeOpenApiOperationId(method, path, operationId);\n\n if (!operationIds.has(normalized)) {\n operationIds.add(normalized);\n return normalized;\n }\n\n let suffix = 2;\n let uniqueId: OperationId = `${normalized}-${suffix}`;\n\n while (operationIds.has(uniqueId)) {\n suffix += 1;\n uniqueId = `${normalized}-${suffix}`;\n }\n\n operationIds.add(uniqueId);\n diagnostics.push({\n code: 'duplicate-operation-id',\n dataSourceId,\n endpointId,\n operationId: uniqueId,\n message: `OpenAPI operation id '${normalized}' is duplicated. Normalized to '${uniqueId}'.`,\n path: `paths.${path}.${method}.operationId`,\n severity: 'warning',\n });\n\n return uniqueId;\n}\n\nfunction normalizeOpenApiParameters(\n parameters: readonly OpenApiParameterObject[],\n dataSourceId: string,\n endpointId: EndpointId,\n operationId: OperationId,\n diagnostics: DataSourceDiagnostic[],\n): readonly DataOperationParameter[] | undefined {\n if (parameters.length === 0) return undefined;\n\n const normalized: DataOperationParameter[] = [];\n\n for (const parameter of parameters) {\n const location = normalizeParameterLocation(parameter.in);\n\n if (location === undefined) {\n diagnostics.push({\n code: 'invalid-config',\n dataSourceId,\n endpointId,\n operationId,\n message: `OpenAPI parameter '${parameter.name}' uses unsupported location '${parameter.in}'.`,\n path: `paths.${endpointId}.parameters.${parameter.name}`,\n severity: 'warning',\n });\n continue;\n }\n\n normalized.push({\n name: parameter.name,\n location,\n required: parameter.required,\n description: parameter.description,\n schema: parameter.schema === undefined ? undefined : normalizeOpenApiSchema(parameter.schema),\n });\n }\n\n return normalized;\n}\n\nfunction normalizeParameterLocation(location: string): DataOperationParameterLocation | undefined {\n if (\n location === 'cookie' ||\n location === 'header' ||\n location === 'path' ||\n location === 'query'\n ) {\n return location;\n }\n\n return undefined;\n}\n\nfunction normalizeOpenApiRequest(\n requestBody: OpenApiRequestBodyObject | undefined,\n parameters: readonly DataOperationParameter[] | undefined,\n): DataOperationRequest | undefined {\n const content = firstContentEntry(requestBody?.content);\n\n if (requestBody === undefined && parameters === undefined) return undefined;\n\n return {\n contentType: content?.contentType,\n parameters,\n schema: content?.schema === undefined ? undefined : normalizeOpenApiSchema(content.schema),\n };\n}\n\nfunction normalizeOpenApiResponse(\n responses: Readonly<Record<string, OpenApiResponseObject>> | undefined,\n): DataOperationResponse | undefined {\n if (responses === undefined) return undefined;\n\n const status = chooseResponseStatus(Object.keys(responses));\n if (status === undefined) return undefined;\n\n const response = responses[status];\n const content = firstContentEntry(response?.content);\n\n return {\n status,\n contentType: content?.contentType,\n description: response?.description,\n schema: content?.schema === undefined ? undefined : normalizeOpenApiSchema(content.schema),\n };\n}\n\nfunction firstContentEntry(\n content: Readonly<Record<string, OpenApiMediaTypeObject>> | undefined,\n): { readonly contentType: string; readonly schema?: OpenApiSchemaObject } | undefined {\n if (content === undefined) return undefined;\n\n const [entry] = Object.entries(content);\n if (entry === undefined) return undefined;\n\n const [contentType, media] = entry;\n return { contentType, schema: media.schema };\n}\n\nfunction chooseResponseStatus(statuses: readonly string[]): string | undefined {\n return statuses.find((status) => status.startsWith('2')) ?? statuses[0];\n}\n\nfunction mapOpenApiMethodToIntent(method: OpenApiHttpMethod): DataOperationIntent {\n if (method === 'get' || method === 'head') return 'read';\n if (method === 'post') return 'create';\n if (method === 'delete') return 'delete';\n if (method === 'patch' || method === 'put') return 'update';\n return 'action';\n}\n\nfunction normalizeOpenApiSchemaRef(ref: string | undefined): { readonly id: string } | undefined {\n if (ref === undefined) return undefined;\n\n const prefix = '#/components/schemas/';\n if (ref.startsWith(prefix)) return { id: ref.slice(prefix.length) };\n\n return { id: ref };\n}\n\nfunction normalizeSchemaRecord(\n record: Readonly<Record<string, OpenApiSchemaObject>> | undefined,\n): Readonly<Record<string, DataSchema>> | undefined {\n if (record === undefined) return undefined;\n\n const normalized: Record<string, DataSchema> = {};\n\n for (const [key, schema] of Object.entries(record)) {\n normalized[key] = normalizeOpenApiSchema(schema);\n }\n\n return normalized;\n}\n\nfunction normalizeSchemaList(\n list: readonly OpenApiSchemaObject[] | undefined,\n): readonly DataSchema[] | undefined {\n return list?.map((schema) => normalizeOpenApiSchema(schema));\n}\n\nfunction normalizeAdditionalProperties(\n additionalProperties: boolean | OpenApiSchemaObject | undefined,\n): boolean | DataSchema | undefined {\n if (additionalProperties === undefined || typeof additionalProperties === 'boolean') {\n return additionalProperties;\n }\n\n return normalizeOpenApiSchema(additionalProperties);\n}\n\nfunction normalizeSchemaType(\n type: string | readonly string[] | undefined,\n): DataSchemaPrimitiveType | readonly DataSchemaPrimitiveType[] | undefined {\n if (type === undefined) return undefined;\n\n if (typeof type === 'string') {\n return isDataSchemaPrimitive(type) ? type : undefined;\n }\n\n return type.filter(isDataSchemaPrimitive);\n}\n\nfunction isDataSchemaPrimitive(type: string): type is DataSchemaPrimitiveType {\n return DATA_SCHEMA_PRIMITIVES.some((primitive) => primitive === type);\n}\n\nfunction collectUnsupportedSchemaDiagnostics(\n schema: OpenApiSchemaObject,\n dataSourceId: string,\n path: string,\n diagnostics: DataSourceDiagnostic[],\n): void {\n if (typeof schema.type === 'string' && !isDataSchemaPrimitive(schema.type)) {\n diagnostics.push({\n code: 'unsupported-schema',\n dataSourceId,\n message: `OpenAPI schema type '${schema.type}' is not supported by the normalized schema model.`,\n path: `${path}.type`,\n severity: 'warning',\n });\n }\n\n for (const [propertyName, propertySchema] of Object.entries(schema.properties ?? {})) {\n collectUnsupportedSchemaDiagnostics(\n propertySchema,\n dataSourceId,\n `${path}.properties.${propertyName}`,\n diagnostics,\n );\n }\n\n if (schema.items !== undefined) {\n collectUnsupportedSchemaDiagnostics(schema.items, dataSourceId, `${path}.items`, diagnostics);\n }\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CredentialRef, DataContractValue, DataOperationIntent, DataOperationMethod, DataOperationPagination, DataOperationParameter, DataOperationRequest, DataOperationResponse, DataSchemaRegistry, DataSourceDiagnostic, DataSourceDiagnosticResult, EndpointId, OperationId, RestDataSourceConfig } from '@ankhorage/contracts/data';
|
|
2
|
+
declare const REST_METHODS: readonly ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"];
|
|
3
|
+
export type ManualRestMethod = (typeof REST_METHODS)[number];
|
|
4
|
+
export interface ManualRestOperationDefinition {
|
|
5
|
+
readonly id: OperationId;
|
|
6
|
+
readonly intent: DataOperationIntent;
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly name?: string;
|
|
9
|
+
readonly description?: string;
|
|
10
|
+
readonly path?: string;
|
|
11
|
+
readonly credential?: CredentialRef;
|
|
12
|
+
readonly parameters?: readonly DataOperationParameter[];
|
|
13
|
+
readonly request?: DataOperationRequest;
|
|
14
|
+
readonly response?: DataOperationResponse;
|
|
15
|
+
readonly pagination?: DataOperationPagination;
|
|
16
|
+
readonly metadata?: DataContractValue;
|
|
17
|
+
}
|
|
18
|
+
export interface ManualRestEndpointDefinition {
|
|
19
|
+
readonly id: EndpointId;
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly name?: string;
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
readonly credential?: CredentialRef;
|
|
24
|
+
readonly operations: readonly ManualRestOperationDefinition[];
|
|
25
|
+
readonly metadata?: DataContractValue;
|
|
26
|
+
}
|
|
27
|
+
export interface ManualRestDataSourceDefinition {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly baseUrl: string;
|
|
30
|
+
readonly name?: string;
|
|
31
|
+
readonly description?: string;
|
|
32
|
+
readonly credential?: CredentialRef;
|
|
33
|
+
readonly endpoints: readonly ManualRestEndpointDefinition[];
|
|
34
|
+
readonly schemas?: DataSchemaRegistry;
|
|
35
|
+
readonly metadata?: DataContractValue;
|
|
36
|
+
}
|
|
37
|
+
export declare function isManualRestMethod(method: string): method is ManualRestMethod;
|
|
38
|
+
export declare function normalizeManualRestMethod(method: string): DataOperationMethod;
|
|
39
|
+
export declare function extractRestPathParams(path: string): readonly string[];
|
|
40
|
+
export declare function validateManualRestDataSource(definition: ManualRestDataSourceDefinition): readonly DataSourceDiagnostic[];
|
|
41
|
+
export declare function createManualRestDataSource(definition: ManualRestDataSourceDefinition): DataSourceDiagnosticResult<RestDataSourceConfig>;
|
|
42
|
+
export declare function normalizeManualRestDataSource(definition: ManualRestDataSourceDefinition): RestDataSourceConfig;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rest/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.some((restMethod) => restMethod === method);
|
|
4
|
+
}
|
|
5
|
+
export function normalizeManualRestMethod(method) {
|
|
6
|
+
return method.toUpperCase();
|
|
7
|
+
}
|
|
8
|
+
export function extractRestPathParams(path) {
|
|
9
|
+
const params = new Set();
|
|
10
|
+
const bracedParamPattern = /\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
11
|
+
const colonParamPattern = /(^|\/):([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
12
|
+
for (const match of path.matchAll(bracedParamPattern)) {
|
|
13
|
+
const [, param] = match;
|
|
14
|
+
if (param !== undefined)
|
|
15
|
+
params.add(param);
|
|
16
|
+
}
|
|
17
|
+
for (const match of path.matchAll(colonParamPattern)) {
|
|
18
|
+
const [, , param] = match;
|
|
19
|
+
if (param !== undefined)
|
|
20
|
+
params.add(param);
|
|
21
|
+
}
|
|
22
|
+
return [...params];
|
|
23
|
+
}
|
|
24
|
+
export function validateManualRestDataSource(definition) {
|
|
25
|
+
const diagnostics = [];
|
|
26
|
+
if (definition.baseUrl.trim().length === 0) {
|
|
27
|
+
diagnostics.push({
|
|
28
|
+
code: 'invalid-config',
|
|
29
|
+
dataSourceId: definition.id,
|
|
30
|
+
message: 'Manual REST data source requires a non-empty baseUrl.',
|
|
31
|
+
path: 'baseUrl',
|
|
32
|
+
severity: 'error',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
for (const endpoint of definition.endpoints) {
|
|
36
|
+
if (!endpoint.path.startsWith('/')) {
|
|
37
|
+
diagnostics.push({
|
|
38
|
+
code: 'invalid-config',
|
|
39
|
+
dataSourceId: definition.id,
|
|
40
|
+
endpointId: endpoint.id,
|
|
41
|
+
message: 'Manual REST endpoint paths must start with `/`.',
|
|
42
|
+
path: `endpoints.${endpoint.id}.path`,
|
|
43
|
+
severity: 'error',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
for (const operation of endpoint.operations) {
|
|
47
|
+
const normalizedMethod = normalizeManualRestMethod(operation.method);
|
|
48
|
+
const operationPath = operation.path ?? endpoint.path;
|
|
49
|
+
const templateParams = extractRestPathParams(operationPath);
|
|
50
|
+
const pathParameters = operation.parameters?.filter((parameter) => parameter.location === 'path') ?? [];
|
|
51
|
+
const pathParameterNames = new Set(pathParameters.map((parameter) => parameter.name));
|
|
52
|
+
if (!isManualRestMethod(normalizedMethod)) {
|
|
53
|
+
diagnostics.push({
|
|
54
|
+
code: 'invalid-config',
|
|
55
|
+
dataSourceId: definition.id,
|
|
56
|
+
endpointId: endpoint.id,
|
|
57
|
+
operationId: operation.id,
|
|
58
|
+
message: `Manual REST operation method must be one of ${REST_METHODS.join(', ')}.`,
|
|
59
|
+
path: `endpoints.${endpoint.id}.operations.${operation.id}.method`,
|
|
60
|
+
severity: 'error',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
for (const templateParam of templateParams) {
|
|
64
|
+
if (!pathParameterNames.has(templateParam)) {
|
|
65
|
+
diagnostics.push({
|
|
66
|
+
code: 'invalid-config',
|
|
67
|
+
dataSourceId: definition.id,
|
|
68
|
+
endpointId: endpoint.id,
|
|
69
|
+
operationId: operation.id,
|
|
70
|
+
message: `Path template parameter '${templateParam}' must have a matching path parameter definition.`,
|
|
71
|
+
path: `endpoints.${endpoint.id}.operations.${operation.id}.parameters`,
|
|
72
|
+
severity: 'error',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const pathParameter of pathParameters) {
|
|
77
|
+
if (!templateParams.includes(pathParameter.name)) {
|
|
78
|
+
diagnostics.push({
|
|
79
|
+
code: 'invalid-config',
|
|
80
|
+
dataSourceId: definition.id,
|
|
81
|
+
endpointId: endpoint.id,
|
|
82
|
+
operationId: operation.id,
|
|
83
|
+
message: `Path parameter '${pathParameter.name}' is not referenced by the operation path template.`,
|
|
84
|
+
path: `endpoints.${endpoint.id}.operations.${operation.id}.parameters.${pathParameter.name}`,
|
|
85
|
+
severity: 'error',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return diagnostics;
|
|
92
|
+
}
|
|
93
|
+
export function createManualRestDataSource(definition) {
|
|
94
|
+
const diagnostics = validateManualRestDataSource(definition);
|
|
95
|
+
const hasErrors = diagnostics.some((diagnostic) => diagnostic.severity === 'error');
|
|
96
|
+
if (hasErrors) {
|
|
97
|
+
return { ok: false, diagnostics };
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
ok: true,
|
|
101
|
+
data: normalizeManualRestDataSource(definition),
|
|
102
|
+
diagnostics,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export function normalizeManualRestDataSource(definition) {
|
|
106
|
+
const endpoints = {};
|
|
107
|
+
for (const endpoint of definition.endpoints) {
|
|
108
|
+
const operations = {};
|
|
109
|
+
for (const operation of endpoint.operations) {
|
|
110
|
+
const operationPath = operation.path ?? endpoint.path;
|
|
111
|
+
const { parameters } = operation;
|
|
112
|
+
const request = operation.request === undefined && parameters === undefined
|
|
113
|
+
? undefined
|
|
114
|
+
: {
|
|
115
|
+
...operation.request,
|
|
116
|
+
parameters,
|
|
117
|
+
};
|
|
118
|
+
operations[operation.id] = {
|
|
119
|
+
id: operation.id,
|
|
120
|
+
endpointId: endpoint.id,
|
|
121
|
+
name: operation.name,
|
|
122
|
+
description: operation.description,
|
|
123
|
+
protocol: 'http',
|
|
124
|
+
intent: operation.intent,
|
|
125
|
+
method: normalizeManualRestMethod(operation.method),
|
|
126
|
+
path: operationPath,
|
|
127
|
+
request,
|
|
128
|
+
response: operation.response,
|
|
129
|
+
pagination: operation.pagination,
|
|
130
|
+
credential: operation.credential,
|
|
131
|
+
metadata: operation.metadata,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
endpoints[endpoint.id] = {
|
|
135
|
+
id: endpoint.id,
|
|
136
|
+
kind: 'http',
|
|
137
|
+
name: endpoint.name,
|
|
138
|
+
description: endpoint.description,
|
|
139
|
+
baseUrl: definition.baseUrl,
|
|
140
|
+
path: endpoint.path,
|
|
141
|
+
credential: endpoint.credential,
|
|
142
|
+
operations,
|
|
143
|
+
metadata: endpoint.metadata,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
id: definition.id,
|
|
148
|
+
kind: 'rest',
|
|
149
|
+
name: definition.name,
|
|
150
|
+
description: definition.description,
|
|
151
|
+
baseUrl: definition.baseUrl,
|
|
152
|
+
credential: definition.credential,
|
|
153
|
+
endpoints,
|
|
154
|
+
schemas: definition.schemas,
|
|
155
|
+
metadata: definition.metadata,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rest/index.ts"],"names":[],"mappings":"AAmBA,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAwC3F,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,KAAK,MAAM,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAc;IACtD,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,MAAM,kBAAkB,GAAG,+BAA+B,CAAC;IAC3D,MAAM,iBAAiB,GAAG,kCAAkC,CAAC;IAE7D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtD,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS;YAA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B,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,UAAU;YACV,QAAQ,EAAE,QAAQ,CAAC,QAAQ;SAC5B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,SAAS;QACT,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["import type {\n CredentialRef,\n DataContractValue,\n DataEndpointConfig,\n DataOperationConfig,\n DataOperationIntent,\n DataOperationMethod,\n DataOperationPagination,\n DataOperationParameter,\n DataOperationRequest,\n DataOperationResponse,\n DataSchemaRegistry,\n DataSourceDiagnostic,\n DataSourceDiagnosticResult,\n EndpointId,\n OperationId,\n RestDataSourceConfig,\n} from '@ankhorage/contracts/data';\n\nconst REST_METHODS = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT'] as const;\n\nexport type ManualRestMethod = (typeof REST_METHODS)[number];\n\nexport interface ManualRestOperationDefinition {\n readonly id: OperationId;\n readonly intent: DataOperationIntent;\n readonly method: string;\n readonly name?: string;\n readonly description?: string;\n readonly path?: string;\n readonly credential?: CredentialRef;\n readonly parameters?: readonly DataOperationParameter[];\n readonly request?: DataOperationRequest;\n readonly response?: DataOperationResponse;\n readonly pagination?: DataOperationPagination;\n readonly metadata?: DataContractValue;\n}\n\nexport interface ManualRestEndpointDefinition {\n readonly id: EndpointId;\n readonly path: string;\n readonly name?: string;\n readonly description?: string;\n readonly credential?: CredentialRef;\n readonly operations: readonly ManualRestOperationDefinition[];\n readonly metadata?: DataContractValue;\n}\n\nexport interface ManualRestDataSourceDefinition {\n readonly id: string;\n readonly baseUrl: string;\n readonly name?: string;\n readonly description?: string;\n readonly credential?: CredentialRef;\n readonly endpoints: readonly ManualRestEndpointDefinition[];\n readonly schemas?: DataSchemaRegistry;\n readonly metadata?: DataContractValue;\n}\n\nexport function isManualRestMethod(method: string): method is ManualRestMethod {\n return REST_METHODS.some((restMethod) => restMethod === method);\n}\n\nexport function normalizeManualRestMethod(method: string): DataOperationMethod {\n return method.toUpperCase();\n}\n\nexport function extractRestPathParams(path: string): readonly string[] {\n const params = new Set<string>();\n const bracedParamPattern = /\\{([A-Za-z_][A-Za-z0-9_]*)\\}/g;\n const colonParamPattern = /(^|\\/):([A-Za-z_][A-Za-z0-9_]*)/g;\n\n for (const match of path.matchAll(bracedParamPattern)) {\n const [, param] = match;\n if (param !== undefined) params.add(param);\n }\n\n for (const match of path.matchAll(colonParamPattern)) {\n const [, , param] = match;\n if (param !== undefined) params.add(param);\n }\n\n return [...params];\n}\n\nexport function validateManualRestDataSource(\n definition: ManualRestDataSourceDefinition,\n): readonly DataSourceDiagnostic[] {\n const diagnostics: DataSourceDiagnostic[] = [];\n\n if (definition.baseUrl.trim().length === 0) {\n diagnostics.push({\n code: 'invalid-config',\n dataSourceId: definition.id,\n message: 'Manual REST data source requires a non-empty baseUrl.',\n path: 'baseUrl',\n severity: 'error',\n });\n }\n\n for (const endpoint of definition.endpoints) {\n if (!endpoint.path.startsWith('/')) {\n diagnostics.push({\n code: 'invalid-config',\n dataSourceId: definition.id,\n endpointId: endpoint.id,\n message: 'Manual REST endpoint paths must start with `/`.',\n path: `endpoints.${endpoint.id}.path`,\n severity: 'error',\n });\n }\n\n for (const operation of endpoint.operations) {\n const normalizedMethod = normalizeManualRestMethod(operation.method);\n const operationPath = operation.path ?? endpoint.path;\n const templateParams = extractRestPathParams(operationPath);\n const pathParameters =\n operation.parameters?.filter((parameter) => parameter.location === 'path') ?? [];\n const pathParameterNames = new Set(pathParameters.map((parameter) => parameter.name));\n\n if (!isManualRestMethod(normalizedMethod)) {\n diagnostics.push({\n code: 'invalid-config',\n dataSourceId: definition.id,\n endpointId: endpoint.id,\n operationId: operation.id,\n message: `Manual REST operation method must be one of ${REST_METHODS.join(', ')}.`,\n path: `endpoints.${endpoint.id}.operations.${operation.id}.method`,\n severity: 'error',\n });\n }\n\n for (const templateParam of templateParams) {\n if (!pathParameterNames.has(templateParam)) {\n diagnostics.push({\n code: 'invalid-config',\n dataSourceId: definition.id,\n endpointId: endpoint.id,\n operationId: operation.id,\n message: `Path template parameter '${templateParam}' must have a matching path parameter definition.`,\n path: `endpoints.${endpoint.id}.operations.${operation.id}.parameters`,\n severity: 'error',\n });\n }\n }\n\n for (const pathParameter of pathParameters) {\n if (!templateParams.includes(pathParameter.name)) {\n diagnostics.push({\n code: 'invalid-config',\n dataSourceId: definition.id,\n endpointId: endpoint.id,\n operationId: operation.id,\n message: `Path parameter '${pathParameter.name}' is not referenced by the operation path template.`,\n path: `endpoints.${endpoint.id}.operations.${operation.id}.parameters.${pathParameter.name}`,\n severity: 'error',\n });\n }\n }\n }\n }\n\n return diagnostics;\n}\n\nexport function createManualRestDataSource(\n definition: ManualRestDataSourceDefinition,\n): DataSourceDiagnosticResult<RestDataSourceConfig> {\n const diagnostics = validateManualRestDataSource(definition);\n const hasErrors = diagnostics.some((diagnostic) => diagnostic.severity === 'error');\n\n if (hasErrors) {\n return { ok: false, diagnostics };\n }\n\n return {\n ok: true,\n data: normalizeManualRestDataSource(definition),\n diagnostics,\n };\n}\n\nexport function normalizeManualRestDataSource(\n definition: ManualRestDataSourceDefinition,\n): RestDataSourceConfig {\n const endpoints: Record<EndpointId, DataEndpointConfig> = {};\n\n for (const endpoint of definition.endpoints) {\n const operations: Record<OperationId, DataOperationConfig> = {};\n\n for (const operation of endpoint.operations) {\n const operationPath = operation.path ?? endpoint.path;\n const { parameters } = operation;\n const request: DataOperationRequest | undefined =\n operation.request === undefined && parameters === undefined\n ? undefined\n : {\n ...operation.request,\n parameters,\n };\n\n operations[operation.id] = {\n id: operation.id,\n endpointId: endpoint.id,\n name: operation.name,\n description: operation.description,\n protocol: 'http',\n intent: operation.intent,\n method: normalizeManualRestMethod(operation.method),\n path: operationPath,\n request,\n response: operation.response,\n pagination: operation.pagination,\n credential: operation.credential,\n metadata: operation.metadata,\n };\n }\n\n endpoints[endpoint.id] = {\n id: endpoint.id,\n kind: 'http',\n name: endpoint.name,\n description: endpoint.description,\n baseUrl: definition.baseUrl,\n path: endpoint.path,\n credential: endpoint.credential,\n operations,\n metadata: endpoint.metadata,\n };\n }\n\n return {\n id: definition.id,\n kind: 'rest',\n name: definition.name,\n description: definition.description,\n baseUrl: definition.baseUrl,\n credential: definition.credential,\n endpoints,\n schemas: definition.schemas,\n metadata: definition.metadata,\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/data-sources",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "Headless toolkit for importing, generating, normalizing, and testing Ankhorage data-source configs.",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/data-sources#readme",
|
|
7
7
|
"bugs": {
|