Skip to content

Commit c589975

Browse files
committed
progress after rebase
Signed-off-by: Harald Fischer <[email protected]>
1 parent 19c77f0 commit c589975

File tree

7 files changed

+45
-41
lines changed

7 files changed

+45
-41
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"json-schema-to-ts": "3.1.1",
6464
"lodash": "^4.17.21",
6565
"memoizee": "^0.4.17",
66+
"odata-openapi": "^0.28.2",
6667
"pinejs-client-core": "^8.1.1",
6768
"randomstring": "^1.3.0",
6869
"typed-error": "^3.2.2"

src/odata-metadata/open-api-sepcification-generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import _ = require('lodash');
55

66
export const generateODataMetadataAsOpenApi = (
77
odataCsdl: ReturnType<typeof generateODataMetadata>,
8-
versionBasePathUrl: string = '',
9-
hostname: string = '',
8+
versionBasePathUrl = '',
9+
hostname = '',
1010
) => {
1111
// console.log(`odataCsdl:${JSON.stringify(odataCsdl, null, 2)}`);
1212
const openAPIJson: any = odataMetadata.csdl2openapi(odataCsdl, {

src/sbvr-api/sbvr-utils.ts

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,18 @@ export interface ApiKey extends Actor {
149149
export interface Response {
150150
statusCode: number;
151151
headers?:
152-
| {
153-
[headerName: string]: any;
154-
}
155-
| undefined;
152+
| {
153+
[headerName: string]: any;
154+
}
155+
| undefined;
156156
body?: AnyObject | string;
157157
}
158158

159159
export type ModelExecutionResult =
160160
| undefined
161161
| {
162-
migrationExecutionResult?: MigrationExecutionResult;
163-
};
162+
migrationExecutionResult?: MigrationExecutionResult;
163+
};
164164

165165
const memoizedResolvedSynonym = memoizeWeak(
166166
(
@@ -252,9 +252,9 @@ const prettifyConstraintError = (
252252
let keyMatches: RegExpExecArray | null = null;
253253
let violatedConstraintInfo:
254254
| {
255-
table: AbstractSQLCompiler.AbstractSqlTable;
256-
name: string;
257-
}
255+
table: AbstractSQLCompiler.AbstractSqlTable;
256+
name: string;
257+
}
258258
| undefined;
259259
if (err instanceof db.UniqueConstraintError) {
260260
switch (db.engine) {
@@ -292,8 +292,8 @@ const prettifyConstraintError = (
292292
const columns = keyMatches[1].split('_');
293293
throw new db.UniqueConstraintError(
294294
'"' +
295-
columns.map(sqlNameToODataName).join('" and "') +
296-
'" must be unique.',
295+
columns.map(sqlNameToODataName).join('" and "') +
296+
'" must be unique.',
297297
);
298298
}
299299
if (violatedConstraintInfo != null) {
@@ -328,16 +328,16 @@ const prettifyConstraintError = (
328328
const tableName = abstractSqlModel.tables[resourceName].name;
329329
keyMatches = new RegExp(
330330
'"' +
331-
tableName +
332-
'" violates foreign key constraint ".*?" on table "(.*?)"',
331+
tableName +
332+
'" violates foreign key constraint ".*?" on table "(.*?)"',
333333
).exec(err.message);
334334
if (keyMatches == null) {
335335
keyMatches = new RegExp(
336336
'"' +
337-
tableName +
338-
'" violates foreign key constraint "' +
339-
tableName +
340-
'_(.*?)_fkey"',
337+
tableName +
338+
'" violates foreign key constraint "' +
339+
tableName +
340+
'_(.*?)_fkey"',
341341
).exec(err.message);
342342
}
343343
break;
@@ -364,8 +364,8 @@ const prettifyConstraintError = (
364364
case 'postgres':
365365
keyMatches = new RegExp(
366366
'new row for relation "' +
367-
table.name +
368-
'" violates check constraint "(.*?)"',
367+
table.name +
368+
'" violates check constraint "(.*?)"',
369369
).exec(err.message);
370370
break;
371371
}
@@ -982,11 +982,11 @@ export const runRule = (() => {
982982
const odataResult = (await runURI(
983983
'GET',
984984
'/' +
985-
vocab +
986-
'/' +
987-
sqlNameToODataName(table.resourceName) +
988-
'?$filter=' +
989-
filter,
985+
vocab +
986+
'/' +
987+
sqlNameToODataName(table.resourceName) +
988+
'?$filter=' +
989+
filter,
990990
undefined,
991991
undefined,
992992
permissions.rootRead,
@@ -1377,7 +1377,10 @@ const runODataRequest = (req: Express.Request, vocabulary: string) => {
13771377
-'#canAccess'.length,
13781378
);
13791379
}
1380-
if (abstractSqlModel.tables[resolvedResourceName] == null && !metadataEndpoints.includes(resolvedResourceName)) {
1380+
if (
1381+
abstractSqlModel.tables[resolvedResourceName] == null &&
1382+
!metadataEndpoints.includes(resolvedResourceName)
1383+
) {
13811384
throw new UnauthorizedError();
13821385
}
13831386

@@ -1697,19 +1700,19 @@ const runRequest = async (
16971700

16981701
const runChangeSet =
16991702
(req: Express.Request, tx: Db.Tx) =>
1700-
async (
1701-
changeSetResults: Map<number, Response>,
1702-
request: uriParser.ODataRequest,
1703-
): Promise<void> => {
1704-
request = updateBinds(changeSetResults, request);
1705-
const result = await runRequest(req, tx, request);
1706-
if (request.id == null) {
1707-
throw new Error('No request id');
1708-
}
1709-
result.headers ??= {};
1710-
result.headers['content-id'] = request.id;
1711-
changeSetResults.set(request.id, result);
1712-
};
1703+
async (
1704+
changeSetResults: Map<number, Response>,
1705+
request: uriParser.ODataRequest,
1706+
): Promise<void> => {
1707+
request = updateBinds(changeSetResults, request);
1708+
const result = await runRequest(req, tx, request);
1709+
if (request.id == null) {
1710+
throw new Error('No request id');
1711+
}
1712+
result.headers ??= {};
1713+
result.headers['content-id'] = request.id;
1714+
changeSetResults.set(request.id, result);
1715+
};
17131716

17141717
// Requests inside a changeset may refer to resources created inside the
17151718
// changeset, the generation of the sql query for those requests must be
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import OpenAPIParser from '@readme/openapi-parser';
88
describe('08 metadata / openAPI spec', function () {
99
describe('Full model access specification', async function () {
1010
const fixturePath =
11-
__dirname + '/fixtures/08-metadata/config-full-access.js';
11+
__dirname + '/fixtures/09-metadata/config-full-access.js';
1212
let pineServer: Awaited<ReturnType<typeof testInit>>;
1313
before(async () => {
1414
pineServer = await testInit({
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)