@magda/typescript-common 1.3.0-rc.0 → 2.0.0-alpha.2

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.
Files changed (122) hide show
  1. package/dist/BaseApiClient.d.ts +41 -0
  2. package/dist/BaseApiClient.js +63 -0
  3. package/dist/BaseApiClient.js.map +1 -0
  4. package/dist/IndexerApiClient.d.ts +16 -0
  5. package/dist/IndexerApiClient.js +39 -0
  6. package/dist/IndexerApiClient.js.map +1 -0
  7. package/dist/JsonTransformer.js +1 -2
  8. package/dist/JsonTransformer.js.map +1 -1
  9. package/dist/OpaCompileResponseParser.d.ts +260 -36
  10. package/dist/OpaCompileResponseParser.js +697 -297
  11. package/dist/OpaCompileResponseParser.js.map +1 -1
  12. package/dist/SQLUtils.d.ts +70 -0
  13. package/dist/SQLUtils.js +263 -0
  14. package/dist/SQLUtils.js.map +1 -0
  15. package/dist/ServerError.d.ts +9 -0
  16. package/dist/ServerError.js +17 -0
  17. package/dist/ServerError.js.map +1 -0
  18. package/dist/Try.d.ts +17 -0
  19. package/dist/Try.js +68 -0
  20. package/dist/Try.js.map +1 -0
  21. package/dist/authorization-api/ApiClient.d.ts +9 -13
  22. package/dist/authorization-api/ApiClient.js +88 -31
  23. package/dist/authorization-api/ApiClient.js.map +1 -1
  24. package/dist/authorization-api/authMiddleware.d.ts +60 -2
  25. package/dist/authorization-api/authMiddleware.js +154 -9
  26. package/dist/authorization-api/authMiddleware.js.map +1 -1
  27. package/dist/authorization-api/constants.d.ts +6 -0
  28. package/dist/authorization-api/constants.js +14 -0
  29. package/dist/authorization-api/constants.js.map +1 -0
  30. package/dist/authorization-api/model.d.ts +57 -28
  31. package/dist/createNoCacheFetchOptions.d.ts +15 -0
  32. package/dist/createNoCacheFetchOptions.js +20 -0
  33. package/dist/createNoCacheFetchOptions.js.map +1 -0
  34. package/dist/express/getNoCacheHeaders.d.ts +6 -0
  35. package/dist/express/getNoCacheHeaders.js +9 -0
  36. package/dist/express/getNoCacheHeaders.js.map +1 -0
  37. package/dist/express/setResponseNoCache.d.ts +3 -0
  38. package/dist/express/setResponseNoCache.js +9 -0
  39. package/dist/express/setResponseNoCache.js.map +1 -0
  40. package/dist/fetchRequest.d.ts +11 -0
  41. package/dist/fetchRequest.js +62 -0
  42. package/dist/fetchRequest.js.map +1 -0
  43. package/dist/generated/registry/api.d.ts +48 -7
  44. package/dist/generated/registry/api.js +197 -2
  45. package/dist/generated/registry/api.js.map +1 -1
  46. package/dist/getRequest.d.ts +1 -0
  47. package/dist/getRequest.js +28 -0
  48. package/dist/getRequest.js.map +1 -0
  49. package/dist/getRequestNoCache.d.ts +1 -0
  50. package/dist/getRequestNoCache.js +23 -0
  51. package/dist/getRequestNoCache.js.map +1 -0
  52. package/dist/getStorageUrl.d.ts +34 -0
  53. package/dist/getStorageUrl.js +138 -0
  54. package/dist/getStorageUrl.js.map +1 -0
  55. package/dist/handleServerError.d.ts +2 -0
  56. package/dist/handleServerError.js +17 -0
  57. package/dist/handleServerError.js.map +1 -0
  58. package/dist/opa/AspectQuery.d.ts +71 -0
  59. package/dist/opa/AspectQuery.js +219 -0
  60. package/dist/opa/AspectQuery.js.map +1 -0
  61. package/dist/opa/AuthDecision.d.ts +51 -0
  62. package/dist/opa/AuthDecision.js +241 -0
  63. package/dist/opa/AuthDecision.js.map +1 -0
  64. package/dist/opa/AuthDecisionQueryClient.d.ts +23 -0
  65. package/dist/opa/AuthDecisionQueryClient.js +113 -0
  66. package/dist/opa/AuthDecisionQueryClient.js.map +1 -0
  67. package/dist/pgTypes.d.ts +1 -0
  68. package/dist/pgTypes.js +18 -0
  69. package/dist/pgTypes.js.map +1 -0
  70. package/dist/registry/AuthorizedRegistryClient.d.ts +8 -11
  71. package/dist/registry/AuthorizedRegistryClient.js +73 -21
  72. package/dist/registry/AuthorizedRegistryClient.js.map +1 -1
  73. package/dist/registry/RegistryClient.d.ts +8 -0
  74. package/dist/registry/RegistryClient.js +57 -6
  75. package/dist/registry/RegistryClient.js.map +1 -1
  76. package/dist/registry/model.d.ts +5 -0
  77. package/dist/registry/model.js +3 -0
  78. package/dist/registry/model.js.map +1 -0
  79. package/dist/test/arbitraries.js +2 -4
  80. package/dist/test/arbitraries.js.map +1 -1
  81. package/dist/test/buildApiClient.spec.js +2 -41
  82. package/dist/test/buildApiClient.spec.js.map +1 -1
  83. package/dist/test/db/getTestDBConfig.js +1 -1
  84. package/dist/test/db/getTestDBConfig.js.map +1 -1
  85. package/dist/test/getAuthDecision.spec.js +2 -2
  86. package/dist/test/getAuthDecision.spec.js.map +1 -1
  87. package/dist/test/getStorageUrl.spec.d.ts +1 -0
  88. package/dist/test/getStorageUrl.spec.js +95 -0
  89. package/dist/test/getStorageUrl.spec.js.map +1 -0
  90. package/dist/test/mockAuthApiHost.js +2 -26
  91. package/dist/test/mockAuthApiHost.js.map +1 -1
  92. package/dist/test/mockAuthorization.js +2 -2
  93. package/dist/test/mockAuthorization.js.map +1 -1
  94. package/dist/test/registry/buildAuthorizedClient.spec.js +9 -7
  95. package/dist/test/registry/buildAuthorizedClient.spec.js.map +1 -1
  96. package/dist/test/sampleAuthDecisions/content.json +29 -0
  97. package/dist/test/sampleAuthDecisions/datasetPermissionWithOrgUnitConstraint.json +79 -0
  98. package/dist/test/sampleAuthDecisions/extraLargeResponse.json +2519 -0
  99. package/dist/test/sampleAuthDecisions/simple.json +29 -0
  100. package/dist/test/sampleAuthDecisions/singleTermAspectRef.json +39 -0
  101. package/dist/test/sampleAuthDecisions/unconditionalFalseSimple.json +6 -0
  102. package/dist/test/sampleAuthDecisions/unconditionalNotMacthed.json +6 -0
  103. package/dist/test/sampleAuthDecisions/unconditionalNotMacthedWithExtraRefs.json +6 -0
  104. package/dist/test/sampleAuthDecisions/unconditionalTrue.json +6 -0
  105. package/dist/test/sampleAuthDecisions/unconditionalTrueSimple.json +6 -0
  106. package/dist/test/sampleAuthDecisions/unconditionalTrueWithDefaultRule.json +6 -0
  107. package/dist/test/sampleAuthDecisions/withDefaultRule.json +6 -0
  108. package/dist/test/{sampleOpaResponse.json → sampleOpaResponses/content.json} +0 -0
  109. package/dist/test/sampleOpaResponses/datasetPermissionWithOrgUnitConstraint.json +341 -0
  110. package/dist/test/sampleOpaResponses/extraLargeResponse.json +104869 -0
  111. package/dist/test/{sampleOpaResponseSimple.json → sampleOpaResponses/simple.json} +0 -0
  112. package/dist/test/sampleOpaResponses/singleTermAspectRef.json +233 -0
  113. package/dist/test/sampleOpaResponses/unconditionalFalseSimple.json +3 -0
  114. package/dist/test/sampleOpaResponses/unconditionalNotMacthed.json +73 -0
  115. package/dist/test/sampleOpaResponses/unconditionalNotMacthedWithExtraRefs.json +155 -0
  116. package/dist/test/{sampleOpaResponseUnconditionalTrue.json → sampleOpaResponses/unconditionalTrue.json} +0 -0
  117. package/dist/test/sampleOpaResponses/unconditionalTrueSimple.json +48 -0
  118. package/dist/test/{sampleOpaResponseUnconditionalTrueWithDefaultRule.json → sampleOpaResponses/unconditionalTrueWithDefaultRule.json} +0 -0
  119. package/dist/test/{sampleOpaResponseWithDefaultRule.json → sampleOpaResponses/withDefaultRule.json} +0 -0
  120. package/dist/test/testOpaCompileResponseParser.spec.js +212 -20
  121. package/dist/test/testOpaCompileResponseParser.spec.js.map +1 -1
  122. package/package.json +9 -6
@@ -11,35 +11,39 @@ declare global {
11
11
  }
12
12
  }
13
13
  }
14
- export interface PublicUser {
15
- id?: string;
14
+ export interface UserRecord {
15
+ id: string;
16
16
  displayName: string;
17
- photoURL?: string;
17
+ photoURL: string;
18
18
  isAdmin: boolean;
19
+ orgUnitId: string;
20
+ email: string;
21
+ source: string;
22
+ sourceId: string;
23
+ }
24
+ export declare type PublicUser = Partial<Pick<UserRecord, "id" | "photoURL" | "orgUnitId">> & Omit<UserRecord, "id" | "photoURL" | "orgUnitId" | "email" | "source" | "sourceId"> & {
19
25
  roles?: Role[];
20
26
  permissions?: Permission[];
21
27
  managingOrgUnitIds?: string[];
22
- orgUnitId?: string;
23
28
  orgUnit?: OrgUnit;
24
- }
29
+ };
30
+ export declare type User = PublicUser & Pick<UserRecord, "email" | "source" | "sourceId">;
31
+ export declare type CreateUserData = Partial<Omit<UserRecord, "email" | "displayName" | "id">> & Pick<UserRecord, "displayName" | "email">;
25
32
  export declare type OrgUnitRelationshipType = "ancestor" | "descendant" | "equal" | "unrelated";
26
- export interface OrgUnit {
27
- id?: string;
28
- name?: string;
29
- description?: string;
30
- relationship?: OrgUnitRelationshipType;
31
- left?: number;
32
- right?: number;
33
- createBy?: string;
34
- createTime?: Date;
35
- editBy?: string;
36
- editTime?: Date;
37
- }
38
- export interface User extends PublicUser {
39
- email: string;
40
- source: string;
41
- sourceId: string;
33
+ export interface OrgUnitRecord {
34
+ id: string;
35
+ name: string;
36
+ description: string;
37
+ left: number;
38
+ right: number;
39
+ createBy: string;
40
+ createTime: Date;
41
+ editBy: string;
42
+ editTime: Date;
42
43
  }
44
+ export declare type OrgUnit = Partial<OrgUnitRecord> & {
45
+ relationship?: OrgUnitRelationshipType;
46
+ };
43
47
  export interface APIKeyRecord {
44
48
  id: string;
45
49
  user_id: string;
@@ -77,6 +81,36 @@ export interface Permission {
77
81
  editBy?: string;
78
82
  editTime?: Date;
79
83
  }
84
+ export interface PermissionRecord {
85
+ id: string;
86
+ name: string;
87
+ description: string;
88
+ resource_id: string;
89
+ user_ownership_constraint: boolean;
90
+ org_unit_ownership_constraint: boolean;
91
+ pre_authorised_constraint: boolean;
92
+ owner_id: string;
93
+ create_time: string;
94
+ create_by: string;
95
+ edit_time: string;
96
+ edit_by: string;
97
+ }
98
+ export interface CreateRolePermissionInputData extends Omit<PermissionRecord, "id" | "owner_id" | "create_by" | "create_time" | "edit_by" | "edit_time"> {
99
+ operationIds: string[];
100
+ }
101
+ export declare type OperationRecord = {
102
+ id: string;
103
+ uri: string;
104
+ name: string;
105
+ description: string;
106
+ resource_id: string;
107
+ };
108
+ export declare type ResourceRecord = {
109
+ id: string;
110
+ uri: string;
111
+ name: string;
112
+ description: string;
113
+ };
80
114
  export interface UserToken {
81
115
  id: string;
82
116
  }
@@ -85,15 +119,10 @@ export interface UserToken {
85
119
  * You only need this when you try to figure out user characteristic (unknown) via Known information of a dataset.
86
120
  * i.e. set `input.user` to unknown then calculate residual rules via partial evaluation.
87
121
  */
88
- export interface DatasetAccessControlMetaData {
89
- /**
90
- * We do allow "archived" as defined in `publishing.schema.json`
91
- * But we probably should avoid using it as there is no story behinds it.
92
- */
93
- publishingState: "draft" | "published" | "archived";
122
+ export interface AccessControlMetaData {
94
123
  accessControl?: {
95
124
  ownerId?: string;
96
- orgUnitOwnerId?: string;
125
+ orgUnitId?: string;
97
126
  preAuthorisedPermissionIds?: string[];
98
127
  };
99
128
  }
@@ -0,0 +1,15 @@
1
+ export default function createNoCacheFetchOptions(fetchOptions?: RequestInit): {
2
+ body?: BodyInit;
3
+ cache?: RequestCache;
4
+ credentials?: RequestCredentials;
5
+ headers?: HeadersInit;
6
+ integrity?: string;
7
+ keepalive?: boolean;
8
+ method?: string;
9
+ mode?: RequestMode;
10
+ redirect?: RequestRedirect;
11
+ referrer?: string;
12
+ referrerPolicy?: ReferrerPolicy;
13
+ signal?: AbortSignal;
14
+ window?: any;
15
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function createNoCacheFetchOptions(fetchOptions = {}) {
4
+ const noCacheHeaders = {
5
+ "Cache-Control": "no-cache, no-store, must-revalidate",
6
+ Pragma: "no-cache",
7
+ Expires: "0"
8
+ };
9
+ const options = Object.assign({}, fetchOptions);
10
+ if (!options.headers) {
11
+ options.headers = Object.assign({}, noCacheHeaders);
12
+ }
13
+ else {
14
+ options.headers = Object.assign(Object.assign({}, options.headers), noCacheHeaders);
15
+ }
16
+ options.cache = "reload";
17
+ return options;
18
+ }
19
+ exports.default = createNoCacheFetchOptions;
20
+ //# sourceMappingURL=createNoCacheFetchOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNoCacheFetchOptions.js","sourceRoot":"","sources":["../src/createNoCacheFetchOptions.ts"],"names":[],"mappings":";;AAAA,SAAwB,yBAAyB,CAC7C,eAA4B,EAAE;IAE9B,MAAM,cAAc,GAAG;QACnB,eAAe,EAAE,qCAAqC;QACtD,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,GAAG;KACf,CAAC;IACF,MAAM,OAAO,qBAAQ,YAAY,CAAE,CAAC;IACpC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QAClB,OAAO,CAAC,OAAO,qBAAQ,cAAc,CAAE,CAAC;KAC3C;SAAM;QACH,OAAO,CAAC,OAAO,mCAAQ,OAAO,CAAC,OAAO,GAAK,cAAc,CAAE,CAAC;KAC/D;IACD,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;IACzB,OAAO,OAAO,CAAC;AACnB,CAAC;AAhBD,4CAgBC"}
@@ -0,0 +1,6 @@
1
+ declare const getNoCacheHeaders: () => {
2
+ "Cache-Control": string;
3
+ Expires: string;
4
+ "Last-Modified": string;
5
+ };
6
+ export default getNoCacheHeaders;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const getNoCacheHeaders = () => ({
4
+ "Cache-Control": "max-age=0, no-cache, must-revalidate, proxy-revalidate",
5
+ Expires: "Thu, 01 Jan 1970 00:00:00 GMT",
6
+ "Last-Modified": new Date().toUTCString()
7
+ });
8
+ exports.default = getNoCacheHeaders;
9
+ //# sourceMappingURL=getNoCacheHeaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNoCacheHeaders.js","sourceRoot":"","sources":["../../src/express/getNoCacheHeaders.ts"],"names":[],"mappings":";;AAAA,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,CAAC;IAC7B,eAAe,EAAE,wDAAwD;IACzE,OAAO,EAAE,+BAA+B;IACxC,eAAe,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;CAC5C,CAAC,CAAC;AAEH,kBAAe,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Response } from "express";
2
+ declare const setResponseNoCache: (res: Response) => Response<any>;
3
+ export default setResponseNoCache;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const getNoCacheHeaders_1 = __importDefault(require("./getNoCacheHeaders"));
7
+ const setResponseNoCache = (res) => res.set(getNoCacheHeaders_1.default());
8
+ exports.default = setResponseNoCache;
9
+ //# sourceMappingURL=setResponseNoCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setResponseNoCache.js","sourceRoot":"","sources":["../../src/express/setResponseNoCache.ts"],"names":[],"mappings":";;;;;AACA,4EAAoD;AAEpD,MAAM,kBAAkB,GAAG,CAAC,GAAa,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,2BAAiB,EAAE,CAAC,CAAC;AAE3E,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,11 @@
1
+ declare type RequestContentTypeJson = "application/json";
2
+ declare type RequestContentTypePlainText = "text/plain";
3
+ declare type RequestContentTypeForm = "application/x-www-form-urlencoded";
4
+ declare type RequestContentTypeBinary = "application/octet-stream";
5
+ declare type RequestContentTypeMultipartForm = "multipart/form-data";
6
+ declare type RequestContentType = RequestContentTypeJson | RequestContentTypePlainText | RequestContentTypeForm | RequestContentTypeBinary | RequestContentTypeMultipartForm;
7
+ export declare function setDefaultRequestInitOptions(options: RequestInit): void;
8
+ export declare function getDefaultRequestInitOptions(): RequestInit;
9
+ export default function fetchRequest<T = any, CT = string>(method: string, url: string, body?: any, contentType?: CT | RequestContentType | undefined | null, returnHeaders?: false, extraRequestOptions?: RequestInit): Promise<T>;
10
+ export default function fetchRequest<T = any, CT = string>(method: string, url: string, body?: any, contentType?: CT | RequestContentType | undefined | null, returnHeaders?: true, extraRequestOptions?: RequestInit): Promise<[T, Headers]>;
11
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getDefaultRequestInitOptions = exports.setDefaultRequestInitOptions = void 0;
16
+ const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch"));
17
+ const merge_1 = __importDefault(require("lodash/merge"));
18
+ const ServerError_1 = __importDefault(require("./ServerError"));
19
+ let defaultRequestInitOptions = {};
20
+ function setDefaultRequestInitOptions(options) {
21
+ defaultRequestInitOptions = options;
22
+ }
23
+ exports.setDefaultRequestInitOptions = setDefaultRequestInitOptions;
24
+ function getDefaultRequestInitOptions() {
25
+ return defaultRequestInitOptions;
26
+ }
27
+ exports.getDefaultRequestInitOptions = getDefaultRequestInitOptions;
28
+ function fetchRequest(method, url, body = undefined, contentType = "application/json", returnHeaders = false, extraRequestOptions = {}) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const defaultOptions = Object.assign({}, (defaultRequestInitOptions ? defaultRequestInitOptions : {}));
31
+ const fetchOptions = merge_1.default(defaultOptions, Object.assign({ method }, extraRequestOptions));
32
+ if (body !== undefined) {
33
+ if (contentType === "application/json") {
34
+ fetchOptions.body = JSON.stringify(body);
35
+ fetchOptions.headers = {
36
+ "Content-type": "application/json"
37
+ };
38
+ }
39
+ else {
40
+ fetchOptions.body = body;
41
+ if (typeof contentType === "string") {
42
+ fetchOptions.headers = {
43
+ "Content-type": contentType
44
+ };
45
+ }
46
+ }
47
+ }
48
+ const response = yield isomorphic_fetch_1.default(url, fetchOptions);
49
+ if (response.status >= 200 && response.status < 300) {
50
+ // wrapping this in try/catch as the request succeeded
51
+ // this is just haggling over response content
52
+ return returnHeaders
53
+ ? [(yield response.json()), response.headers]
54
+ : (yield response.json());
55
+ }
56
+ // --- get responseText and remove any HTML tags
57
+ const responseText = (yield response.text()).replace(/<(.|\n)*?>/g, "");
58
+ throw new ServerError_1.default(responseText, response.status);
59
+ });
60
+ }
61
+ exports.default = fetchRequest;
62
+ //# sourceMappingURL=fetchRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchRequest.js","sourceRoot":"","sources":["../src/fetchRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wEAAqC;AACrC,yDAAiC;AACjC,gEAAwC;AAexC,IAAI,yBAAyB,GAAgB,EAAE,CAAC;AAEhD,SAAgB,4BAA4B,CAAC,OAAoB;IAC7D,yBAAyB,GAAG,OAAO,CAAC;AACxC,CAAC;AAFD,oEAEC;AAED,SAAgB,4BAA4B;IACxC,OAAO,yBAAyB,CAAC;AACrC,CAAC;AAFD,oEAEC;AAoBD,SAA8B,YAAY,CACtC,MAAc,EACd,GAAW,EACX,OAAY,SAAS,EACrB,cAIa,kBAAkB,EAC/B,gBAAyB,KAAK,EAC9B,sBAAmC,EAAE;;QAErC,MAAM,cAAc,qBACb,CAAC,yBAAyB,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,CAAC,CAClE,CAAC;QACF,MAAM,YAAY,GAAG,eAAK,CAAC,cAAc,kBACrC,MAAM,IACH,mBAAmB,EACxB,CAAC;QACH,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,IAAI,WAAW,KAAK,kBAAkB,EAAE;gBACpC,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACzC,YAAY,CAAC,OAAO,GAAG;oBACnB,cAAc,EAAE,kBAAkB;iBACrC,CAAC;aACL;iBAAM;gBACH,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC;gBACzB,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;oBACjC,YAAY,CAAC,OAAO,GAAG;wBACnB,cAAc,EAAE,WAAW;qBAC9B,CAAC;iBACL;aACJ;SACJ;QAED,MAAM,QAAQ,GAAG,MAAM,0BAAK,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAEhD,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;YACjD,sDAAsD;YACtD,8CAA8C;YAC9C,OAAO,aAAa;gBAChB,CAAC,CAAE,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,EAAE,QAAQ,CAAC,OAAO,CAAkB;gBACpE,CAAC,CAAE,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAO,CAAC;SACxC;QACD,gDAAgD;QAChD,MAAM,YAAY,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACxE,MAAM,IAAI,qBAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;CAAA;AA/CD,+BA+CC"}
@@ -88,10 +88,6 @@ export declare class Record {
88
88
  */
89
89
  'aspects': any;
90
90
  /**
91
- * The read authorization policy id of a record
92
- */
93
- 'authnReadPolicyId': string;
94
- /**
95
91
  * A tag representing the action by the source of this record (e.g. an id for a individual crawl of a data portal).
96
92
  */
97
93
  'sourceTag': string;
@@ -143,6 +139,11 @@ export declare class WebHook {
143
139
  'retryCount': number;
144
140
  'isRunning': any;
145
141
  'isProcessing': any;
142
+ 'ownerId': string;
143
+ 'creatorId': string;
144
+ 'editorId': string;
145
+ 'createTime': Date;
146
+ 'editTime': Date;
146
147
  }
147
148
  /**
148
149
  * Asynchronously acknowledges receipt of a web hook notification.
@@ -230,8 +231,9 @@ export declare class AspectDefinitionsApi {
230
231
  * Get a list of all aspects
231
232
  *
232
233
  * @param xMagdaTenantId 0
234
+ * @param xMagdaSession Magda internal session id
233
235
  */
234
- getAll(xMagdaTenantId: number): Promise<{
236
+ getAll(xMagdaTenantId: number, xMagdaSession?: string): Promise<{
235
237
  response: http.IncomingMessage;
236
238
  body: Array<AspectDefinition>;
237
239
  }>;
@@ -240,8 +242,9 @@ export declare class AspectDefinitionsApi {
240
242
  *
241
243
  * @param xMagdaTenantId 0
242
244
  * @param id ID of the aspect to be fetched.
245
+ * @param xMagdaSession Magda internal session id
243
246
  */
244
- getById(xMagdaTenantId: number, id: string): Promise<{
247
+ getById(xMagdaTenantId: number, id: string, xMagdaSession?: string): Promise<{
245
248
  response: http.IncomingMessage;
246
249
  body: AspectDefinition;
247
250
  }>;
@@ -292,6 +295,33 @@ export declare class RecordAspectsApi {
292
295
  response: http.IncomingMessage;
293
296
  body: DeleteResult;
294
297
  }>;
298
+ /**
299
+ * Get a list of a record&#39;s aspects
300
+ *
301
+ * @param xMagdaTenantId 0
302
+ * @param recordId ID of the record for which to fetch aspects.
303
+ * @param keyword Specify the keyword to search in the all aspects&#39; aspectId &amp; data fields.
304
+ * @param aspectIdOnly When set to true, will respond only an array contains aspect id only.
305
+ * @param start The index of the first record to retrieve.
306
+ * @param limit The maximum number of records to receive.
307
+ * @param xMagdaSession Magda internal session id
308
+ */
309
+ getAspects(xMagdaTenantId: number, recordId: string, keyword?: string, aspectIdOnly?: boolean, start?: number, limit?: number, xMagdaSession?: string): Promise<{
310
+ response: http.IncomingMessage;
311
+ body: Array<any>;
312
+ }>;
313
+ /**
314
+ * Get the number of aspects that a record has
315
+ *
316
+ * @param xMagdaTenantId 0
317
+ * @param recordId ID of the record for which to fetch an aspect.
318
+ * @param keyword Specify the keyword to search in the all aspects&#39; aspectId &amp; data fields.
319
+ * @param xMagdaSession Magda internal session id
320
+ */
321
+ getAspectsCount(xMagdaTenantId: number, recordId: string, keyword?: string, xMagdaSession?: string): Promise<{
322
+ response: http.IncomingMessage;
323
+ body: CountResponse;
324
+ }>;
295
325
  /**
296
326
  * Get a record aspect by ID
297
327
  *
@@ -449,6 +479,17 @@ export declare class RecordsApi {
449
479
  response: http.IncomingMessage;
450
480
  body: Record;
451
481
  }>;
482
+ /**
483
+ * Get a record in full by ID
484
+ * Get a record with all attached aspects data by the record ID.
485
+ * @param id ID of the record to be fetched.
486
+ * @param xMagdaTenantId 0
487
+ * @param xMagdaSession Magda internal session id
488
+ */
489
+ getByIdInFull(id: string, xMagdaTenantId: number, xMagdaSession?: string): Promise<{
490
+ response: http.IncomingMessage;
491
+ body: Record;
492
+ }>;
452
493
  /**
453
494
  * Get a summary record by ID
454
495
  * Gets a summary record, including all the aspect ids for which this record has data.
@@ -495,7 +536,7 @@ export declare class RecordsApi {
495
536
  */
496
537
  patchById(xMagdaTenantId: number, id: string, recordPatch: Array<Operation>, xMagdaSession: string): Promise<{
497
538
  response: http.IncomingMessage;
498
- body: AspectDefinition;
539
+ body: Record;
499
540
  }>;
500
541
  /**
501
542
  * Modify a record by ID
@@ -214,8 +214,9 @@ class AspectDefinitionsApi {
214
214
  * Get a list of all aspects
215
215
  *
216
216
  * @param xMagdaTenantId 0
217
+ * @param xMagdaSession Magda internal session id
217
218
  */
218
- getAll(xMagdaTenantId) {
219
+ getAll(xMagdaTenantId, xMagdaSession) {
219
220
  const localVarPath = this.basePath + '/aspects';
220
221
  let queryParameters = {};
221
222
  let headerParams = Object.assign({}, this.defaultHeaders);
@@ -225,6 +226,7 @@ class AspectDefinitionsApi {
225
226
  throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getAll.');
226
227
  }
227
228
  headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
229
+ headerParams['X-Magda-Session'] = xMagdaSession;
228
230
  let useFormData = false;
229
231
  let requestOptions = {
230
232
  method: 'GET',
@@ -264,8 +266,9 @@ class AspectDefinitionsApi {
264
266
  *
265
267
  * @param xMagdaTenantId 0
266
268
  * @param id ID of the aspect to be fetched.
269
+ * @param xMagdaSession Magda internal session id
267
270
  */
268
- getById(xMagdaTenantId, id) {
271
+ getById(xMagdaTenantId, id, xMagdaSession) {
269
272
  const localVarPath = this.basePath + '/aspects/{id}'
270
273
  .replace('{' + 'id' + '}', String(id));
271
274
  let queryParameters = {};
@@ -280,6 +283,7 @@ class AspectDefinitionsApi {
280
283
  throw new Error('Required parameter id was null or undefined when calling getById.');
281
284
  }
282
285
  headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
286
+ headerParams['X-Magda-Session'] = xMagdaSession;
283
287
  let useFormData = false;
284
288
  let requestOptions = {
285
289
  method: 'GET',
@@ -545,6 +549,140 @@ class RecordAspectsApi {
545
549
  });
546
550
  });
547
551
  }
552
+ /**
553
+ * Get a list of a record&#39;s aspects
554
+ *
555
+ * @param xMagdaTenantId 0
556
+ * @param recordId ID of the record for which to fetch aspects.
557
+ * @param keyword Specify the keyword to search in the all aspects&#39; aspectId &amp; data fields.
558
+ * @param aspectIdOnly When set to true, will respond only an array contains aspect id only.
559
+ * @param start The index of the first record to retrieve.
560
+ * @param limit The maximum number of records to receive.
561
+ * @param xMagdaSession Magda internal session id
562
+ */
563
+ getAspects(xMagdaTenantId, recordId, keyword, aspectIdOnly, start, limit, xMagdaSession) {
564
+ const localVarPath = this.basePath + '/records/{recordId}/aspects'
565
+ .replace('{' + 'recordId' + '}', String(recordId));
566
+ let queryParameters = {};
567
+ let headerParams = Object.assign({}, this.defaultHeaders);
568
+ let formParams = {};
569
+ // verify required parameter 'xMagdaTenantId' is not null or undefined
570
+ if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
571
+ throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getAspects.');
572
+ }
573
+ // verify required parameter 'recordId' is not null or undefined
574
+ if (recordId === null || recordId === undefined) {
575
+ throw new Error('Required parameter recordId was null or undefined when calling getAspects.');
576
+ }
577
+ if (keyword !== undefined) {
578
+ queryParameters['keyword'] = keyword;
579
+ }
580
+ if (aspectIdOnly !== undefined) {
581
+ queryParameters['aspectIdOnly'] = aspectIdOnly;
582
+ }
583
+ if (start !== undefined) {
584
+ queryParameters['start'] = start;
585
+ }
586
+ if (limit !== undefined) {
587
+ queryParameters['limit'] = limit;
588
+ }
589
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
590
+ headerParams['X-Magda-Session'] = xMagdaSession;
591
+ let useFormData = false;
592
+ let requestOptions = {
593
+ method: 'GET',
594
+ qs: queryParameters,
595
+ headers: headerParams,
596
+ uri: localVarPath,
597
+ useQuerystring: this._useQuerystring,
598
+ json: true,
599
+ };
600
+ this.authentications.default.applyToRequest(requestOptions);
601
+ if (Object.keys(formParams).length) {
602
+ if (useFormData) {
603
+ requestOptions.formData = formParams;
604
+ }
605
+ else {
606
+ requestOptions.form = formParams;
607
+ }
608
+ }
609
+ return new Promise((resolve, reject) => {
610
+ request(requestOptions, (error, response, body) => {
611
+ if (error) {
612
+ reject(error);
613
+ }
614
+ else {
615
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
616
+ resolve({ response: response, body: body });
617
+ }
618
+ else {
619
+ reject({ response: response, body: body });
620
+ }
621
+ }
622
+ });
623
+ });
624
+ }
625
+ /**
626
+ * Get the number of aspects that a record has
627
+ *
628
+ * @param xMagdaTenantId 0
629
+ * @param recordId ID of the record for which to fetch an aspect.
630
+ * @param keyword Specify the keyword to search in the all aspects&#39; aspectId &amp; data fields.
631
+ * @param xMagdaSession Magda internal session id
632
+ */
633
+ getAspectsCount(xMagdaTenantId, recordId, keyword, xMagdaSession) {
634
+ const localVarPath = this.basePath + '/records/{recordId}/aspects/count'
635
+ .replace('{' + 'recordId' + '}', String(recordId));
636
+ let queryParameters = {};
637
+ let headerParams = Object.assign({}, this.defaultHeaders);
638
+ let formParams = {};
639
+ // verify required parameter 'xMagdaTenantId' is not null or undefined
640
+ if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
641
+ throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getAspectsCount.');
642
+ }
643
+ // verify required parameter 'recordId' is not null or undefined
644
+ if (recordId === null || recordId === undefined) {
645
+ throw new Error('Required parameter recordId was null or undefined when calling getAspectsCount.');
646
+ }
647
+ if (keyword !== undefined) {
648
+ queryParameters['keyword'] = keyword;
649
+ }
650
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
651
+ headerParams['X-Magda-Session'] = xMagdaSession;
652
+ let useFormData = false;
653
+ let requestOptions = {
654
+ method: 'GET',
655
+ qs: queryParameters,
656
+ headers: headerParams,
657
+ uri: localVarPath,
658
+ useQuerystring: this._useQuerystring,
659
+ json: true,
660
+ };
661
+ this.authentications.default.applyToRequest(requestOptions);
662
+ if (Object.keys(formParams).length) {
663
+ if (useFormData) {
664
+ requestOptions.formData = formParams;
665
+ }
666
+ else {
667
+ requestOptions.form = formParams;
668
+ }
669
+ }
670
+ return new Promise((resolve, reject) => {
671
+ request(requestOptions, (error, response, body) => {
672
+ if (error) {
673
+ reject(error);
674
+ }
675
+ else {
676
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
677
+ resolve({ response: response, body: body });
678
+ }
679
+ else {
680
+ reject({ response: response, body: body });
681
+ }
682
+ }
683
+ });
684
+ });
685
+ }
548
686
  /**
549
687
  * Get a record aspect by ID
550
688
  *
@@ -1305,6 +1443,63 @@ class RecordsApi {
1305
1443
  });
1306
1444
  });
1307
1445
  }
1446
+ /**
1447
+ * Get a record in full by ID
1448
+ * Get a record with all attached aspects data by the record ID.
1449
+ * @param id ID of the record to be fetched.
1450
+ * @param xMagdaTenantId 0
1451
+ * @param xMagdaSession Magda internal session id
1452
+ */
1453
+ getByIdInFull(id, xMagdaTenantId, xMagdaSession) {
1454
+ const localVarPath = this.basePath + '/records/inFull/{id}'
1455
+ .replace('{' + 'id' + '}', String(id));
1456
+ let queryParameters = {};
1457
+ let headerParams = Object.assign({}, this.defaultHeaders);
1458
+ let formParams = {};
1459
+ // verify required parameter 'id' is not null or undefined
1460
+ if (id === null || id === undefined) {
1461
+ throw new Error('Required parameter id was null or undefined when calling getByIdInFull.');
1462
+ }
1463
+ // verify required parameter 'xMagdaTenantId' is not null or undefined
1464
+ if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
1465
+ throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getByIdInFull.');
1466
+ }
1467
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1468
+ headerParams['X-Magda-Session'] = xMagdaSession;
1469
+ let useFormData = false;
1470
+ let requestOptions = {
1471
+ method: 'GET',
1472
+ qs: queryParameters,
1473
+ headers: headerParams,
1474
+ uri: localVarPath,
1475
+ useQuerystring: this._useQuerystring,
1476
+ json: true,
1477
+ };
1478
+ this.authentications.default.applyToRequest(requestOptions);
1479
+ if (Object.keys(formParams).length) {
1480
+ if (useFormData) {
1481
+ requestOptions.formData = formParams;
1482
+ }
1483
+ else {
1484
+ requestOptions.form = formParams;
1485
+ }
1486
+ }
1487
+ return new Promise((resolve, reject) => {
1488
+ request(requestOptions, (error, response, body) => {
1489
+ if (error) {
1490
+ reject(error);
1491
+ }
1492
+ else {
1493
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
1494
+ resolve({ response: response, body: body });
1495
+ }
1496
+ else {
1497
+ reject({ response: response, body: body });
1498
+ }
1499
+ }
1500
+ });
1501
+ });
1502
+ }
1308
1503
  /**
1309
1504
  * Get a summary record by ID
1310
1505
  * Gets a summary record, including all the aspect ids for which this record has data.