@magda/typescript-common 2.0.0-alpha.4 → 2.0.0-alpha.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/dist/SQLUtils.d.ts +5 -5
- package/dist/SQLUtils.js.map +1 -1
- package/dist/authorization-api/authMiddleware.d.ts +11 -5
- package/dist/authorization-api/authMiddleware.js +19 -6
- package/dist/authorization-api/authMiddleware.js.map +1 -1
- package/dist/authorization-api/model.d.ts +33 -0
- package/dist/generated/registry/api.d.ts +55 -2
- package/dist/generated/registry/api.js +218 -3
- package/dist/generated/registry/api.js.map +1 -1
- package/dist/registry/AuthorizedRegistryClient.d.ts +19 -13
- package/dist/registry/AuthorizedRegistryClient.js +36 -7
- package/dist/registry/AuthorizedRegistryClient.js.map +1 -1
- package/dist/registry/RegistryClient.d.ts +5 -4
- package/dist/registry/RegistryClient.js +13 -2
- package/dist/registry/RegistryClient.js.map +1 -1
- package/dist/registry/model.d.ts +5 -0
- package/dist/util/unionToThrowable.d.ts +2 -1
- package/dist/util/unionToThrowable.js +8 -1
- package/dist/util/unionToThrowable.js.map +1 -1
- package/package.json +3 -3
package/dist/SQLUtils.d.ts
CHANGED
|
@@ -43,16 +43,16 @@ export declare function getTableColumnName(columnName: String, tableRef?: String
|
|
|
43
43
|
* @param {{ [key: string]: Value }} data
|
|
44
44
|
* @return {*}
|
|
45
45
|
*/
|
|
46
|
-
export declare function createTableRecord(poolOrClient: pg.PoolClient | pg.Pool, table: string, data: {
|
|
46
|
+
export declare function createTableRecord(poolOrClient: pg.PoolClient | pg.Pool | pg.Client, table: string, data: {
|
|
47
47
|
[key: string]: RawValue;
|
|
48
48
|
}, allowFieldList?: string[], autoGenerateUuid?: boolean): Promise<any>;
|
|
49
49
|
export declare function updateTableRecord(poolOrClient: pg.PoolClient | pg.Pool, table: string, id: string, data: {
|
|
50
50
|
[key: string]: Value;
|
|
51
51
|
}, allowFieldList?: string[]): Promise<any>;
|
|
52
|
-
export declare function deleteTableRecord(poolOrClient: pg.Client | pg.Pool, table: string, id: string): Promise<void>;
|
|
52
|
+
export declare function deleteTableRecord(poolOrClient: pg.Client | pg.Pool | pg.PoolClient, table: string, id: string): Promise<void>;
|
|
53
53
|
export declare function parseIntParam(p: number | string | undefined): number;
|
|
54
54
|
export declare const MAX_PAGE_RECORD_NUMBER = 500;
|
|
55
|
-
export declare function searchTableRecord<T = any>(poolOrClient: pg.Client | pg.Pool, table: string, contiditions?: SQLSyntax[], queryConfig?: {
|
|
55
|
+
export declare function searchTableRecord<T = any>(poolOrClient: pg.Client | pg.Pool | pg.PoolClient, table: string, contiditions?: SQLSyntax[], queryConfig?: {
|
|
56
56
|
offset?: number | string;
|
|
57
57
|
limit?: number | string;
|
|
58
58
|
authDecision?: AuthDecision;
|
|
@@ -65,6 +65,6 @@ export declare function searchTableRecord<T = any>(poolOrClient: pg.Client | pg.
|
|
|
65
65
|
}[];
|
|
66
66
|
groupBy?: SQLSyntax | SQLSyntax[];
|
|
67
67
|
}): Promise<T[]>;
|
|
68
|
-
export declare function getTableRecord<T = any>(poolOrClient: pg.Client | pg.Pool, table: string, id: string, authDecision?: AuthDecision, objectKind?: PossibleObjectKind, toSqlConfig?: AspectQueryToSqlConfig): Promise<T | null>;
|
|
69
|
-
export declare function countTableRecord(poolOrClient: pg.Client | pg.Pool, table: string, contiditions?: SQLSyntax[], authDecision?: AuthDecision, objectKind?: PossibleObjectKind, toSqlConfig?: AspectQueryToSqlConfig): Promise<number>;
|
|
68
|
+
export declare function getTableRecord<T = any>(poolOrClient: pg.Client | pg.Pool | pg.PoolClient, table: string, id: string, authDecision?: AuthDecision, objectKind?: PossibleObjectKind, toSqlConfig?: AspectQueryToSqlConfig): Promise<T | null>;
|
|
69
|
+
export declare function countTableRecord(poolOrClient: pg.Client | pg.Pool | pg.PoolClient, table: string, contiditions?: SQLSyntax[], authDecision?: AuthDecision, objectKind?: PossibleObjectKind, toSqlConfig?: AspectQueryToSqlConfig): Promise<number>;
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C;SAC9B;IACL,CAAC;CAAA;AAxBD,4CAwBC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Request, Response } from "express";
|
|
1
|
+
import { Request, Response, NextFunction } from "express";
|
|
2
2
|
import AuthDecisionQueryClient, { AuthDecisionReqConfig } from "../opa/AuthDecisionQueryClient";
|
|
3
3
|
/**
|
|
4
4
|
* Find the user making the request. Assign it to req passport style.
|
|
@@ -6,6 +6,7 @@ import AuthDecisionQueryClient, { AuthDecisionReqConfig } from "../opa/AuthDecis
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const getUser: (baseAuthUrl: string, jwtSecret: string, actionUserId?: string) => (req: Request, res: Response, next: () => void) => void;
|
|
8
8
|
export declare const mustBeAdmin: (baseAuthUrl: string, jwtSecret: string) => (req: Request, res: Response, next: () => void) => void;
|
|
9
|
+
export declare type AuthDecisionReqConfigOrConfigFuncParam = AuthDecisionReqConfig | ((req: Request, res: Response, next: NextFunction) => AuthDecisionReqConfig | null | Promise<AuthDecisionReqConfig | null>);
|
|
9
10
|
/**
|
|
10
11
|
* Make auth decision based on auth decision request config.
|
|
11
12
|
* Depends on the config provided, either partial eval (conditional decision on a set of records/objects)
|
|
@@ -13,10 +14,15 @@ export declare const mustBeAdmin: (baseAuthUrl: string, jwtSecret: string) => (r
|
|
|
13
14
|
*
|
|
14
15
|
* @export
|
|
15
16
|
* @param {AuthDecisionQueryClient} authDecisionClient
|
|
16
|
-
* @param {
|
|
17
|
+
* @param {AuthDecisionReqConfigOrConfigFuncParam} configOrConfigFunc An auth decision config object or a function returns an auth decision config object.
|
|
18
|
+
* When a function is supplied, the function can opt to:
|
|
19
|
+
* - return an auth decision object based on incoming request.
|
|
20
|
+
* - throw an Error
|
|
21
|
+
* - send the response and return a `null` value to skip the rest of request processing.
|
|
22
|
+
* - call `next` function and return a `null` value to skip the rest of processing of current middleware
|
|
17
23
|
* @return {*}
|
|
18
24
|
*/
|
|
19
|
-
export declare function withAuthDecision(authDecisionClient: AuthDecisionQueryClient,
|
|
25
|
+
export declare function withAuthDecision(authDecisionClient: AuthDecisionQueryClient, configOrConfigFunc: AuthDecisionReqConfigOrConfigFuncParam): (req: Request, res: Response, next: () => void) => Promise<void>;
|
|
20
26
|
/**
|
|
21
27
|
* Require unconditional auth decision based on auth decision request config.
|
|
22
28
|
* When making decision on a group of records/objects, this method makes sure
|
|
@@ -24,11 +30,11 @@ export declare function withAuthDecision(authDecisionClient: AuthDecisionQueryCl
|
|
|
24
30
|
*
|
|
25
31
|
* @export
|
|
26
32
|
* @param {AuthDecisionQueryClient} authDecisionClient
|
|
27
|
-
* @param {
|
|
33
|
+
* @param {AuthDecisionReqConfigOrConfigFuncParam} configOrConfigFunc
|
|
28
34
|
* @param {boolean} [requiredDecision=true]
|
|
29
35
|
* @return {*}
|
|
30
36
|
*/
|
|
31
|
-
export declare function requireUnconditionalAuthDecision(authDecisionClient: AuthDecisionQueryClient,
|
|
37
|
+
export declare function requireUnconditionalAuthDecision(authDecisionClient: AuthDecisionQueryClient, configOrConfigFunc: AuthDecisionReqConfigOrConfigFuncParam, requiredDecision?: boolean): (req: Request, res: Response, next: () => void) => void;
|
|
32
38
|
declare type InputDataOrFuncType = ((req: Request, res: Response) => Record<string, any>) | Record<string, any>;
|
|
33
39
|
/**
|
|
34
40
|
* require permission based on input data provided.
|
|
@@ -93,15 +93,27 @@ exports.mustBeAdmin = (baseAuthUrl, jwtSecret) => {
|
|
|
93
93
|
*
|
|
94
94
|
* @export
|
|
95
95
|
* @param {AuthDecisionQueryClient} authDecisionClient
|
|
96
|
-
* @param {
|
|
96
|
+
* @param {AuthDecisionReqConfigOrConfigFuncParam} configOrConfigFunc An auth decision config object or a function returns an auth decision config object.
|
|
97
|
+
* When a function is supplied, the function can opt to:
|
|
98
|
+
* - return an auth decision object based on incoming request.
|
|
99
|
+
* - throw an Error
|
|
100
|
+
* - send the response and return a `null` value to skip the rest of request processing.
|
|
101
|
+
* - call `next` function and return a `null` value to skip the rest of processing of current middleware
|
|
97
102
|
* @return {*}
|
|
98
103
|
*/
|
|
99
|
-
function withAuthDecision(authDecisionClient,
|
|
104
|
+
function withAuthDecision(authDecisionClient, configOrConfigFunc) {
|
|
100
105
|
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
101
106
|
try {
|
|
107
|
+
const config = typeof configOrConfigFunc === "function"
|
|
108
|
+
? yield configOrConfigFunc(req, res, next)
|
|
109
|
+
: configOrConfigFunc;
|
|
110
|
+
if (!config) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
102
113
|
const jwtToken = req.get("X-Magda-Session");
|
|
103
114
|
const authDecision = yield authDecisionClient.getAuthDecision(config, jwtToken);
|
|
104
115
|
res.locals.authDecision = authDecision;
|
|
116
|
+
res.locals.authDecisionConfig = config;
|
|
105
117
|
next();
|
|
106
118
|
}
|
|
107
119
|
catch (e) {
|
|
@@ -123,20 +135,21 @@ exports.withAuthDecision = withAuthDecision;
|
|
|
123
135
|
*
|
|
124
136
|
* @export
|
|
125
137
|
* @param {AuthDecisionQueryClient} authDecisionClient
|
|
126
|
-
* @param {
|
|
138
|
+
* @param {AuthDecisionReqConfigOrConfigFuncParam} configOrConfigFunc
|
|
127
139
|
* @param {boolean} [requiredDecision=true]
|
|
128
140
|
* @return {*}
|
|
129
141
|
*/
|
|
130
|
-
function requireUnconditionalAuthDecision(authDecisionClient,
|
|
142
|
+
function requireUnconditionalAuthDecision(authDecisionClient, configOrConfigFunc, requiredDecision = true) {
|
|
131
143
|
return (req, res, next) => {
|
|
132
|
-
withAuthDecision(authDecisionClient,
|
|
144
|
+
withAuthDecision(authDecisionClient, configOrConfigFunc)(req, res, () => {
|
|
145
|
+
var _a, _b;
|
|
133
146
|
const authDecision = res.locals.authDecision;
|
|
134
147
|
if ((authDecision === null || authDecision === void 0 ? void 0 : authDecision.hasResidualRules) === false &&
|
|
135
148
|
AuthDecision_1.isTrueEquivalent(authDecision === null || authDecision === void 0 ? void 0 : authDecision.result) == requiredDecision) {
|
|
136
149
|
return next();
|
|
137
150
|
}
|
|
138
151
|
else {
|
|
139
|
-
res.status(403).send(`you are not permitted to perform \`${
|
|
152
|
+
res.status(403).send(`you are not permitted to perform \`${(_b = (_a = res === null || res === void 0 ? void 0 : res.locals) === null || _a === void 0 ? void 0 : _a.authDecisionConfig) === null || _b === void 0 ? void 0 : _b.operationUri}\` on required resources.`);
|
|
140
153
|
}
|
|
141
154
|
});
|
|
142
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authMiddleware.js","sourceRoot":"","sources":["../../src/authorization-api/authMiddleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAqE;AACrE,4DAAoC;AAIpC,sDAAqE;AACrE,2CAAyE;AACzE,iEAAyC;AAEzC;;;GAGG;AACU,QAAA,OAAO,GAAG,CACnB,WAAmB,EACnB,SAAiB,EACjB,YAAqB,EACvB,EAAE,CAAC,CAAC,GAAY,EAAE,GAAa,EAAE,IAAgB,EAAE,EAAE;IACnD,qBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC;QACpC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE;YACb,MAAM,SAAS,GAAG,IAAI,mBAAS,CAC3B,WAAW,EACX,SAAS,EACT,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iCAAqB,CACtD,CAAC;YACF,SAAS;iBACJ,OAAO,CAAC,MAAM,CAAC;iBACf,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBAChB,SAAS,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;wBACX,GAAG,CAAC,IAAI,mCAID,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAC1B,IAAI,CACV,CAAC;wBACF,IAAI,EAAE,CAAC;oBACX,CAAC;oBACD,OAAO,EAAE,IAAI;iBAChB,CAAC,CA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MAAM,EAAE,GAAG,CAAC,CAAC;qBACtC;iBACJ;qBAAM;oBACH,MAAM,IAAI,qBAAW,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;iBAChD;aACJ;YAAC,OAAO,CAAC,EAAE;gBACR,IAAI,CAAC,YAAY,qBAAW,EAAE;oBAC1B,OAAO,CAAC,IAAI,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC;oBAC/C,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;iBAC5C;qBAAM;oBACH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;iBAChC;aACJ;QACL,CAAC,CAAA,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"authMiddleware.js","sourceRoot":"","sources":["../../src/authorization-api/authMiddleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAqE;AACrE,4DAAoC;AAIpC,sDAAqE;AACrE,2CAAyE;AACzE,iEAAyC;AAEzC;;;GAGG;AACU,QAAA,OAAO,GAAG,CACnB,WAAmB,EACnB,SAAiB,EACjB,YAAqB,EACvB,EAAE,CAAC,CAAC,GAAY,EAAE,GAAa,EAAE,IAAgB,EAAE,EAAE;IACnD,qBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC;QACpC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE;YACb,MAAM,SAAS,GAAG,IAAI,mBAAS,CAC3B,WAAW,EACX,SAAS,EACT,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iCAAqB,CACtD,CAAC;YACF,SAAS;iBACJ,OAAO,CAAC,MAAM,CAAC;iBACf,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBAChB,SAAS,CAAC,MAAM,CAAC;oBACb,IAAI,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AAS,CAAC,CAAC,MAAM,CAAC;YACpC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE;gBACb,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;gBAC3B,IAAI,EAAE,CAAC;YACX,CAAC;YACD,OAAO,EAAE,GAAG,EAAE;gBACV,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;gBAC9B,IAAI,EAAE,CAAC;YACX,CAAC;SACJ,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAbD,8BAaC;AAED;;;;;;;;GAQG;AACU,QAAA,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,CAChD,GAAY,EACZ,GAAa,EACb,IAAgB,EAClB,EAAE,CACA,SAAS,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;QACpB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAChB,+DAA+D,CAClE,CAAC;KACL;SAAM;QACH,OAAO,IAAI,EAAE,CAAC;KACjB;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -130,3 +130,36 @@ export interface AccessControlMetaData {
|
|
|
130
130
|
preAuthorisedPermissionIds?: string[];
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
+
export interface CreateAccessGroupRequestBodyType {
|
|
134
|
+
name: string;
|
|
135
|
+
resourceUri: string;
|
|
136
|
+
description?: string;
|
|
137
|
+
keywords?: string[];
|
|
138
|
+
operationUris: string[];
|
|
139
|
+
ownerId?: string;
|
|
140
|
+
orgUnitId?: string;
|
|
141
|
+
}
|
|
142
|
+
export interface UpdateAccessGroupRequestBodyType {
|
|
143
|
+
name?: string;
|
|
144
|
+
description?: string;
|
|
145
|
+
keywords?: string[];
|
|
146
|
+
operationUris?: string[];
|
|
147
|
+
ownerId?: string;
|
|
148
|
+
orgUnitId?: string;
|
|
149
|
+
}
|
|
150
|
+
export interface AccessGroup {
|
|
151
|
+
id: string;
|
|
152
|
+
name: string;
|
|
153
|
+
resourceUri: string;
|
|
154
|
+
operationUris: string[];
|
|
155
|
+
description?: string;
|
|
156
|
+
keywords?: string[];
|
|
157
|
+
permissionId: string;
|
|
158
|
+
roleId: string;
|
|
159
|
+
ownerId?: string;
|
|
160
|
+
orgUnit?: string;
|
|
161
|
+
createTime?: Date;
|
|
162
|
+
createBy?: string;
|
|
163
|
+
editTime?: Date;
|
|
164
|
+
editBy?: string;
|
|
165
|
+
}
|
|
@@ -35,6 +35,11 @@ export declare class AspectDefinition {
|
|
|
35
35
|
export declare class CountResponse {
|
|
36
36
|
'count': number;
|
|
37
37
|
}
|
|
38
|
+
export declare class DeleteRecordsAspectArrayItemsRequest {
|
|
39
|
+
'recordIds': Array<string>;
|
|
40
|
+
'jsonPath': string;
|
|
41
|
+
'items': Array<JsValue>;
|
|
42
|
+
}
|
|
38
43
|
export declare class DeleteResult {
|
|
39
44
|
'deleted': boolean;
|
|
40
45
|
}
|
|
@@ -66,11 +71,22 @@ export declare class JsObject {
|
|
|
66
71
|
}
|
|
67
72
|
export declare class JsValue {
|
|
68
73
|
}
|
|
74
|
+
export declare class JsonPatch {
|
|
75
|
+
'ops': Array<Operation>;
|
|
76
|
+
}
|
|
69
77
|
export declare class MultipleDeleteResult {
|
|
70
78
|
'count': number;
|
|
71
79
|
}
|
|
72
80
|
export declare class Operation {
|
|
73
81
|
}
|
|
82
|
+
export declare class PatchRecordsRequest {
|
|
83
|
+
'recordIds': Array<string>;
|
|
84
|
+
'jsonPath': JsonPatch;
|
|
85
|
+
}
|
|
86
|
+
export declare class PutRecordsAspectRequest {
|
|
87
|
+
'recordIds': Array<string>;
|
|
88
|
+
'data': JsObject;
|
|
89
|
+
}
|
|
74
90
|
/**
|
|
75
91
|
* A record in the registry, usually including data for one or more aspects, unique for a tenant.
|
|
76
92
|
*/
|
|
@@ -355,8 +371,9 @@ export declare class RecordAspectsApi {
|
|
|
355
371
|
* @param aspect The record aspect to save.
|
|
356
372
|
* @param xMagdaSession Magda internal session id
|
|
357
373
|
* @param xMagdaTenantId 0
|
|
374
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
358
375
|
*/
|
|
359
|
-
putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number): Promise<{
|
|
376
|
+
putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number, merge?: boolean): Promise<{
|
|
360
377
|
response: http.IncomingMessage;
|
|
361
378
|
body: any;
|
|
362
379
|
}>;
|
|
@@ -431,6 +448,18 @@ export declare class RecordsApi {
|
|
|
431
448
|
response: http.IncomingMessage;
|
|
432
449
|
body: DeleteResult;
|
|
433
450
|
}>;
|
|
451
|
+
/**
|
|
452
|
+
* Remove items from records' aspect data
|
|
453
|
+
* Remove items from records' aspect data
|
|
454
|
+
* @param xMagdaTenantId 0
|
|
455
|
+
* @param aspectId ID of the aspect to update.
|
|
456
|
+
* @param requestData An json object has key 'recordIds', 'jsonPath', 'items'
|
|
457
|
+
* @param xMagdaSession Magda internal session id
|
|
458
|
+
*/
|
|
459
|
+
deleteRecordsAspectArrayItems(xMagdaTenantId: number, aspectId: string, requestData: DeleteRecordsAspectArrayItemsRequest, xMagdaSession: string): Promise<{
|
|
460
|
+
response: http.IncomingMessage;
|
|
461
|
+
body: Array<any>;
|
|
462
|
+
}>;
|
|
434
463
|
/**
|
|
435
464
|
* Get a list of all records
|
|
436
465
|
*
|
|
@@ -530,7 +559,7 @@ export declare class RecordsApi {
|
|
|
530
559
|
* Modify a record by applying a JSON Patch
|
|
531
560
|
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
532
561
|
* @param xMagdaTenantId 0
|
|
533
|
-
* @param id ID of the
|
|
562
|
+
* @param id ID of the record to be pacthed.
|
|
534
563
|
* @param recordPatch The RFC 6902 patch to apply to the aspect.
|
|
535
564
|
* @param xMagdaSession Magda internal session id
|
|
536
565
|
*/
|
|
@@ -538,6 +567,17 @@ export declare class RecordsApi {
|
|
|
538
567
|
response: http.IncomingMessage;
|
|
539
568
|
body: Record;
|
|
540
569
|
}>;
|
|
570
|
+
/**
|
|
571
|
+
* Modify a list of records by applying the same JSON Patch
|
|
572
|
+
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
573
|
+
* @param xMagdaTenantId 0
|
|
574
|
+
* @param requestData An json object has key 'recordIds' & 'jsonPath'
|
|
575
|
+
* @param xMagdaSession Magda internal session id
|
|
576
|
+
*/
|
|
577
|
+
patchRecords(xMagdaTenantId: number, requestData: PatchRecordsRequest, xMagdaSession: string): Promise<{
|
|
578
|
+
response: http.IncomingMessage;
|
|
579
|
+
body: Array<any>;
|
|
580
|
+
}>;
|
|
541
581
|
/**
|
|
542
582
|
* Modify a record by ID
|
|
543
583
|
* Modifies a record. Aspects included in the request are created or updated, but missing aspects are not removed.
|
|
@@ -550,6 +590,19 @@ export declare class RecordsApi {
|
|
|
550
590
|
response: http.IncomingMessage;
|
|
551
591
|
body: Record;
|
|
552
592
|
}>;
|
|
593
|
+
/**
|
|
594
|
+
* Modify a list of records's aspect with same new data
|
|
595
|
+
* Modify a list of records's aspect with same new data
|
|
596
|
+
* @param xMagdaTenantId 0
|
|
597
|
+
* @param aspectId ID of the aspect to update.
|
|
598
|
+
* @param requestData An json object has key 'recordIds' & 'data'
|
|
599
|
+
* @param xMagdaSession Magda internal session id
|
|
600
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
601
|
+
*/
|
|
602
|
+
putRecordsAspect(xMagdaTenantId: number, aspectId: string, requestData: PutRecordsAspectRequest, xMagdaSession: string, merge?: boolean): Promise<{
|
|
603
|
+
response: http.IncomingMessage;
|
|
604
|
+
body: Array<any>;
|
|
605
|
+
}>;
|
|
553
606
|
/**
|
|
554
607
|
* Trim by source tag
|
|
555
608
|
* Trims records with the provided source that DON'T have the supplied source tag
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Do not edit the class manually.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.WebHooksApi = exports.WebHooksApiApiKeys = exports.RecordsApi = exports.RecordsApiApiKeys = exports.RecordHistoryApi = exports.RecordHistoryApiApiKeys = exports.RecordAspectsApi = exports.RecordAspectsApiApiKeys = exports.AspectDefinitionsApi = exports.AspectDefinitionsApiApiKeys = exports.VoidAuth = exports.OAuth = exports.ApiKeyAuth = exports.HttpBasicAuth = exports.WebHookConfig = exports.WebHookAcknowledgementResponse = exports.WebHookAcknowledgement = exports.WebHook = exports.RegistryEvent = exports.RecordSummary = exports.Record = exports.Operation = exports.MultipleDeleteResult = exports.JsValue = exports.JsObject = exports.EventsPage = exports.DeleteResult = exports.CountResponse = exports.AspectDefinition = exports.ApiError = void 0;
|
|
14
|
+
exports.WebHooksApi = exports.WebHooksApiApiKeys = exports.RecordsApi = exports.RecordsApiApiKeys = exports.RecordHistoryApi = exports.RecordHistoryApiApiKeys = exports.RecordAspectsApi = exports.RecordAspectsApiApiKeys = exports.AspectDefinitionsApi = exports.AspectDefinitionsApiApiKeys = exports.VoidAuth = exports.OAuth = exports.ApiKeyAuth = exports.HttpBasicAuth = exports.WebHookConfig = exports.WebHookAcknowledgementResponse = exports.WebHookAcknowledgement = exports.WebHook = exports.RegistryEvent = exports.RecordSummary = exports.Record = exports.PutRecordsAspectRequest = exports.PatchRecordsRequest = exports.Operation = exports.MultipleDeleteResult = exports.JsonPatch = exports.JsValue = exports.JsObject = exports.EventsPage = exports.DeleteResult = exports.DeleteRecordsAspectArrayItemsRequest = exports.CountResponse = exports.AspectDefinition = exports.ApiError = void 0;
|
|
15
15
|
const request = require("request");
|
|
16
16
|
let defaultBasePath = 'http://localhost/api/v0/registry/';
|
|
17
17
|
// ===============================================
|
|
@@ -30,6 +30,9 @@ exports.AspectDefinition = AspectDefinition;
|
|
|
30
30
|
class CountResponse {
|
|
31
31
|
}
|
|
32
32
|
exports.CountResponse = CountResponse;
|
|
33
|
+
class DeleteRecordsAspectArrayItemsRequest {
|
|
34
|
+
}
|
|
35
|
+
exports.DeleteRecordsAspectArrayItemsRequest = DeleteRecordsAspectArrayItemsRequest;
|
|
33
36
|
class DeleteResult {
|
|
34
37
|
}
|
|
35
38
|
exports.DeleteResult = DeleteResult;
|
|
@@ -45,12 +48,21 @@ exports.JsObject = JsObject;
|
|
|
45
48
|
class JsValue {
|
|
46
49
|
}
|
|
47
50
|
exports.JsValue = JsValue;
|
|
51
|
+
class JsonPatch {
|
|
52
|
+
}
|
|
53
|
+
exports.JsonPatch = JsonPatch;
|
|
48
54
|
class MultipleDeleteResult {
|
|
49
55
|
}
|
|
50
56
|
exports.MultipleDeleteResult = MultipleDeleteResult;
|
|
51
57
|
class Operation {
|
|
52
58
|
}
|
|
53
59
|
exports.Operation = Operation;
|
|
60
|
+
class PatchRecordsRequest {
|
|
61
|
+
}
|
|
62
|
+
exports.PatchRecordsRequest = PatchRecordsRequest;
|
|
63
|
+
class PutRecordsAspectRequest {
|
|
64
|
+
}
|
|
65
|
+
exports.PutRecordsAspectRequest = PutRecordsAspectRequest;
|
|
54
66
|
/**
|
|
55
67
|
* A record in the registry, usually including data for one or more aspects, unique for a tenant.
|
|
56
68
|
*/
|
|
@@ -827,8 +839,9 @@ class RecordAspectsApi {
|
|
|
827
839
|
* @param aspect The record aspect to save.
|
|
828
840
|
* @param xMagdaSession Magda internal session id
|
|
829
841
|
* @param xMagdaTenantId 0
|
|
842
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
830
843
|
*/
|
|
831
|
-
putById(recordId, aspectId, aspect, xMagdaSession, xMagdaTenantId) {
|
|
844
|
+
putById(recordId, aspectId, aspect, xMagdaSession, xMagdaTenantId, merge) {
|
|
832
845
|
const localVarPath = this.basePath + '/records/{recordId}/aspects/{aspectId}'
|
|
833
846
|
.replace('{' + 'recordId' + '}', String(recordId))
|
|
834
847
|
.replace('{' + 'aspectId' + '}', String(aspectId));
|
|
@@ -855,6 +868,9 @@ class RecordAspectsApi {
|
|
|
855
868
|
if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
|
|
856
869
|
throw new Error('Required parameter xMagdaTenantId was null or undefined when calling putById.');
|
|
857
870
|
}
|
|
871
|
+
if (merge !== undefined) {
|
|
872
|
+
queryParameters['merge'] = merge;
|
|
873
|
+
}
|
|
858
874
|
headerParams['X-Magda-Session'] = xMagdaSession;
|
|
859
875
|
headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
|
|
860
876
|
let useFormData = false;
|
|
@@ -1216,6 +1232,73 @@ class RecordsApi {
|
|
|
1216
1232
|
});
|
|
1217
1233
|
});
|
|
1218
1234
|
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Remove items from records' aspect data
|
|
1237
|
+
* Remove items from records' aspect data
|
|
1238
|
+
* @param xMagdaTenantId 0
|
|
1239
|
+
* @param aspectId ID of the aspect to update.
|
|
1240
|
+
* @param requestData An json object has key 'recordIds', 'jsonPath', 'items'
|
|
1241
|
+
* @param xMagdaSession Magda internal session id
|
|
1242
|
+
*/
|
|
1243
|
+
deleteRecordsAspectArrayItems(xMagdaTenantId, aspectId, requestData, xMagdaSession) {
|
|
1244
|
+
const localVarPath = this.basePath + '/records/aspectArrayItems/{aspectId}'
|
|
1245
|
+
.replace('{' + 'aspectId' + '}', String(aspectId));
|
|
1246
|
+
let queryParameters = {};
|
|
1247
|
+
let headerParams = Object.assign({}, this.defaultHeaders);
|
|
1248
|
+
let formParams = {};
|
|
1249
|
+
// verify required parameter 'xMagdaTenantId' is not null or undefined
|
|
1250
|
+
if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
|
|
1251
|
+
throw new Error('Required parameter xMagdaTenantId was null or undefined when calling deleteRecordsAspectArrayItems.');
|
|
1252
|
+
}
|
|
1253
|
+
// verify required parameter 'aspectId' is not null or undefined
|
|
1254
|
+
if (aspectId === null || aspectId === undefined) {
|
|
1255
|
+
throw new Error('Required parameter aspectId was null or undefined when calling deleteRecordsAspectArrayItems.');
|
|
1256
|
+
}
|
|
1257
|
+
// verify required parameter 'requestData' is not null or undefined
|
|
1258
|
+
if (requestData === null || requestData === undefined) {
|
|
1259
|
+
throw new Error('Required parameter requestData was null or undefined when calling deleteRecordsAspectArrayItems.');
|
|
1260
|
+
}
|
|
1261
|
+
// verify required parameter 'xMagdaSession' is not null or undefined
|
|
1262
|
+
if (xMagdaSession === null || xMagdaSession === undefined) {
|
|
1263
|
+
throw new Error('Required parameter xMagdaSession was null or undefined when calling deleteRecordsAspectArrayItems.');
|
|
1264
|
+
}
|
|
1265
|
+
headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
|
|
1266
|
+
headerParams['X-Magda-Session'] = xMagdaSession;
|
|
1267
|
+
let useFormData = false;
|
|
1268
|
+
let requestOptions = {
|
|
1269
|
+
method: 'DELETE',
|
|
1270
|
+
qs: queryParameters,
|
|
1271
|
+
headers: headerParams,
|
|
1272
|
+
uri: localVarPath,
|
|
1273
|
+
useQuerystring: this._useQuerystring,
|
|
1274
|
+
json: true,
|
|
1275
|
+
body: requestData,
|
|
1276
|
+
};
|
|
1277
|
+
this.authentications.default.applyToRequest(requestOptions);
|
|
1278
|
+
if (Object.keys(formParams).length) {
|
|
1279
|
+
if (useFormData) {
|
|
1280
|
+
requestOptions.formData = formParams;
|
|
1281
|
+
}
|
|
1282
|
+
else {
|
|
1283
|
+
requestOptions.form = formParams;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
return new Promise((resolve, reject) => {
|
|
1287
|
+
request(requestOptions, (error, response, body) => {
|
|
1288
|
+
if (error) {
|
|
1289
|
+
reject(error);
|
|
1290
|
+
}
|
|
1291
|
+
else {
|
|
1292
|
+
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
|
1293
|
+
resolve({ response: response, body: body });
|
|
1294
|
+
}
|
|
1295
|
+
else {
|
|
1296
|
+
reject({ response: response, body: body });
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1219
1302
|
/**
|
|
1220
1303
|
* Get a list of all records
|
|
1221
1304
|
*
|
|
@@ -1683,7 +1766,7 @@ class RecordsApi {
|
|
|
1683
1766
|
* Modify a record by applying a JSON Patch
|
|
1684
1767
|
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
1685
1768
|
* @param xMagdaTenantId 0
|
|
1686
|
-
* @param id ID of the
|
|
1769
|
+
* @param id ID of the record to be pacthed.
|
|
1687
1770
|
* @param recordPatch The RFC 6902 patch to apply to the aspect.
|
|
1688
1771
|
* @param xMagdaSession Magda internal session id
|
|
1689
1772
|
*/
|
|
@@ -1746,6 +1829,67 @@ class RecordsApi {
|
|
|
1746
1829
|
});
|
|
1747
1830
|
});
|
|
1748
1831
|
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Modify a list of records by applying the same JSON Patch
|
|
1834
|
+
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
1835
|
+
* @param xMagdaTenantId 0
|
|
1836
|
+
* @param requestData An json object has key 'recordIds' & 'jsonPath'
|
|
1837
|
+
* @param xMagdaSession Magda internal session id
|
|
1838
|
+
*/
|
|
1839
|
+
patchRecords(xMagdaTenantId, requestData, xMagdaSession) {
|
|
1840
|
+
const localVarPath = this.basePath + '/records';
|
|
1841
|
+
let queryParameters = {};
|
|
1842
|
+
let headerParams = Object.assign({}, this.defaultHeaders);
|
|
1843
|
+
let formParams = {};
|
|
1844
|
+
// verify required parameter 'xMagdaTenantId' is not null or undefined
|
|
1845
|
+
if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
|
|
1846
|
+
throw new Error('Required parameter xMagdaTenantId was null or undefined when calling patchRecords.');
|
|
1847
|
+
}
|
|
1848
|
+
// verify required parameter 'requestData' is not null or undefined
|
|
1849
|
+
if (requestData === null || requestData === undefined) {
|
|
1850
|
+
throw new Error('Required parameter requestData was null or undefined when calling patchRecords.');
|
|
1851
|
+
}
|
|
1852
|
+
// verify required parameter 'xMagdaSession' is not null or undefined
|
|
1853
|
+
if (xMagdaSession === null || xMagdaSession === undefined) {
|
|
1854
|
+
throw new Error('Required parameter xMagdaSession was null or undefined when calling patchRecords.');
|
|
1855
|
+
}
|
|
1856
|
+
headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
|
|
1857
|
+
headerParams['X-Magda-Session'] = xMagdaSession;
|
|
1858
|
+
let useFormData = false;
|
|
1859
|
+
let requestOptions = {
|
|
1860
|
+
method: 'PATCH',
|
|
1861
|
+
qs: queryParameters,
|
|
1862
|
+
headers: headerParams,
|
|
1863
|
+
uri: localVarPath,
|
|
1864
|
+
useQuerystring: this._useQuerystring,
|
|
1865
|
+
json: true,
|
|
1866
|
+
body: requestData,
|
|
1867
|
+
};
|
|
1868
|
+
this.authentications.default.applyToRequest(requestOptions);
|
|
1869
|
+
if (Object.keys(formParams).length) {
|
|
1870
|
+
if (useFormData) {
|
|
1871
|
+
requestOptions.formData = formParams;
|
|
1872
|
+
}
|
|
1873
|
+
else {
|
|
1874
|
+
requestOptions.form = formParams;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
return new Promise((resolve, reject) => {
|
|
1878
|
+
request(requestOptions, (error, response, body) => {
|
|
1879
|
+
if (error) {
|
|
1880
|
+
reject(error);
|
|
1881
|
+
}
|
|
1882
|
+
else {
|
|
1883
|
+
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
|
1884
|
+
resolve({ response: response, body: body });
|
|
1885
|
+
}
|
|
1886
|
+
else {
|
|
1887
|
+
reject({ response: response, body: body });
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
});
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1749
1893
|
/**
|
|
1750
1894
|
* Modify a record by ID
|
|
1751
1895
|
* Modifies a record. Aspects included in the request are created or updated, but missing aspects are not removed.
|
|
@@ -1813,6 +1957,77 @@ class RecordsApi {
|
|
|
1813
1957
|
});
|
|
1814
1958
|
});
|
|
1815
1959
|
}
|
|
1960
|
+
/**
|
|
1961
|
+
* Modify a list of records's aspect with same new data
|
|
1962
|
+
* Modify a list of records's aspect with same new data
|
|
1963
|
+
* @param xMagdaTenantId 0
|
|
1964
|
+
* @param aspectId ID of the aspect to update.
|
|
1965
|
+
* @param requestData An json object has key 'recordIds' & 'data'
|
|
1966
|
+
* @param xMagdaSession Magda internal session id
|
|
1967
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
1968
|
+
*/
|
|
1969
|
+
putRecordsAspect(xMagdaTenantId, aspectId, requestData, xMagdaSession, merge) {
|
|
1970
|
+
const localVarPath = this.basePath + '/records/aspects/{aspectId}'
|
|
1971
|
+
.replace('{' + 'aspectId' + '}', String(aspectId));
|
|
1972
|
+
let queryParameters = {};
|
|
1973
|
+
let headerParams = Object.assign({}, this.defaultHeaders);
|
|
1974
|
+
let formParams = {};
|
|
1975
|
+
// verify required parameter 'xMagdaTenantId' is not null or undefined
|
|
1976
|
+
if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
|
|
1977
|
+
throw new Error('Required parameter xMagdaTenantId was null or undefined when calling putRecordsAspect.');
|
|
1978
|
+
}
|
|
1979
|
+
// verify required parameter 'aspectId' is not null or undefined
|
|
1980
|
+
if (aspectId === null || aspectId === undefined) {
|
|
1981
|
+
throw new Error('Required parameter aspectId was null or undefined when calling putRecordsAspect.');
|
|
1982
|
+
}
|
|
1983
|
+
// verify required parameter 'requestData' is not null or undefined
|
|
1984
|
+
if (requestData === null || requestData === undefined) {
|
|
1985
|
+
throw new Error('Required parameter requestData was null or undefined when calling putRecordsAspect.');
|
|
1986
|
+
}
|
|
1987
|
+
// verify required parameter 'xMagdaSession' is not null or undefined
|
|
1988
|
+
if (xMagdaSession === null || xMagdaSession === undefined) {
|
|
1989
|
+
throw new Error('Required parameter xMagdaSession was null or undefined when calling putRecordsAspect.');
|
|
1990
|
+
}
|
|
1991
|
+
if (merge !== undefined) {
|
|
1992
|
+
queryParameters['merge'] = merge;
|
|
1993
|
+
}
|
|
1994
|
+
headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
|
|
1995
|
+
headerParams['X-Magda-Session'] = xMagdaSession;
|
|
1996
|
+
let useFormData = false;
|
|
1997
|
+
let requestOptions = {
|
|
1998
|
+
method: 'PUT',
|
|
1999
|
+
qs: queryParameters,
|
|
2000
|
+
headers: headerParams,
|
|
2001
|
+
uri: localVarPath,
|
|
2002
|
+
useQuerystring: this._useQuerystring,
|
|
2003
|
+
json: true,
|
|
2004
|
+
body: requestData,
|
|
2005
|
+
};
|
|
2006
|
+
this.authentications.default.applyToRequest(requestOptions);
|
|
2007
|
+
if (Object.keys(formParams).length) {
|
|
2008
|
+
if (useFormData) {
|
|
2009
|
+
requestOptions.formData = formParams;
|
|
2010
|
+
}
|
|
2011
|
+
else {
|
|
2012
|
+
requestOptions.form = formParams;
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
return new Promise((resolve, reject) => {
|
|
2016
|
+
request(requestOptions, (error, response, body) => {
|
|
2017
|
+
if (error) {
|
|
2018
|
+
reject(error);
|
|
2019
|
+
}
|
|
2020
|
+
else {
|
|
2021
|
+
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
|
2022
|
+
resolve({ response: response, body: body });
|
|
2023
|
+
}
|
|
2024
|
+
else {
|
|
2025
|
+
reject({ response: response, body: body });
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
});
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
1816
2031
|
/**
|
|
1817
2032
|
* Trim by source tag
|
|
1818
2033
|
* Trims records with the provided source that DON'T have the supplied source tag
|