@magda/registry-client 1.2.1 → 2.0.0-alpha.1

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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import http = require('http');
3
+ import { Response as Response_2 } from 'request';
3
4
  import { default as URI_2 } from 'urijs';
4
5
 
5
6
  /**
@@ -43,8 +44,9 @@ declare class AspectDefinitionsApi {
43
44
  * Get a list of all aspects
44
45
  *
45
46
  * @param xMagdaTenantId 0
47
+ * @param xMagdaSession Magda internal session id
46
48
  */
47
- getAll(xMagdaTenantId: number): Promise<{
49
+ getAll(xMagdaTenantId: number, xMagdaSession?: string): Promise<{
48
50
  response: http.IncomingMessage;
49
51
  body: Array<AspectDefinition>;
50
52
  }>;
@@ -53,8 +55,9 @@ declare class AspectDefinitionsApi {
53
55
  *
54
56
  * @param xMagdaTenantId 0
55
57
  * @param id ID of the aspect to be fetched.
58
+ * @param xMagdaSession Magda internal session id
56
59
  */
57
- getById(xMagdaTenantId: number, id: string): Promise<{
60
+ getById(xMagdaTenantId: number, id: string, xMagdaSession?: string): Promise<{
58
61
  response: http.IncomingMessage;
59
62
  body: AspectDefinition;
60
63
  }>;
@@ -90,6 +93,7 @@ declare enum AspectDefinitionsApiApiKeys {
90
93
  export declare class AuthorizedRegistryClient extends RegistryClient {
91
94
  protected jwt: string;
92
95
  constructor(options: AuthorizedRegistryOptions);
96
+ getAspectDefinition(aspectId: string): Promise<AspectDefinition>;
93
97
  putAspectDefinition(aspectDefinition: AspectDefinition, tenantId?: number): Promise<AspectDefinition | Error>;
94
98
  postHook(hook: WebHook): Promise<WebHook | Error>;
95
99
  putHook(hook: WebHook): Promise<WebHook | Error>;
@@ -280,6 +284,33 @@ declare class RecordAspectsApi {
280
284
  response: http.IncomingMessage;
281
285
  body: DeleteResult;
282
286
  }>;
287
+ /**
288
+ * Get a list of a record&#39;s aspects
289
+ *
290
+ * @param xMagdaTenantId 0
291
+ * @param recordId ID of the record for which to fetch aspects.
292
+ * @param keyword Specify the keyword to search in the all aspects&#39; aspectId &amp; data fields.
293
+ * @param aspectIdOnly When set to true, will respond only an array contains aspect id only.
294
+ * @param start The index of the first record to retrieve.
295
+ * @param limit The maximum number of records to receive.
296
+ * @param xMagdaSession Magda internal session id
297
+ */
298
+ getAspects(xMagdaTenantId: number, recordId: string, keyword?: string, aspectIdOnly?: boolean, start?: number, limit?: number, xMagdaSession?: string): Promise<{
299
+ response: http.IncomingMessage;
300
+ body: Array<any>;
301
+ }>;
302
+ /**
303
+ * Get the number of aspects that a record has
304
+ *
305
+ * @param xMagdaTenantId 0
306
+ * @param recordId ID of the record for which to fetch an aspect.
307
+ * @param keyword Specify the keyword to search in the all aspects&#39; aspectId &amp; data fields.
308
+ * @param xMagdaSession Magda internal session id
309
+ */
310
+ getAspectsCount(xMagdaTenantId: number, recordId: string, keyword?: string, xMagdaSession?: string): Promise<{
311
+ response: http.IncomingMessage;
312
+ body: CountResponse;
313
+ }>;
283
314
  /**
284
315
  * Get a record aspect by ID
285
316
  *
@@ -441,6 +472,17 @@ declare class RecordsApi {
441
472
  response: http.IncomingMessage;
442
473
  body: Record_2;
443
474
  }>;
475
+ /**
476
+ * Get a record in full by ID
477
+ * Get a record with all attached aspects data by the record ID.
478
+ * @param id ID of the record to be fetched.
479
+ * @param xMagdaTenantId 0
480
+ * @param xMagdaSession Magda internal session id
481
+ */
482
+ getByIdInFull(id: string, xMagdaTenantId: number, xMagdaSession?: string): Promise<{
483
+ response: http.IncomingMessage;
484
+ body: Record_2;
485
+ }>;
444
486
  /**
445
487
  * Get a summary record by ID
446
488
  * Gets a summary record, including all the aspect ids for which this record has data.
@@ -559,9 +601,18 @@ export declare class RegistryClient {
559
601
  protected tenantId: number;
560
602
  protected jwt: string | undefined;
561
603
  constructor({ baseUrl, maxRetries, secondsBetweenRetries, tenantId }: RegistryOptions);
604
+ toServerError(error: {
605
+ body: any;
606
+ response: Response_2;
607
+ }): ServerError | {
608
+ body: any;
609
+ response: Response_2;
610
+ };
562
611
  getRecordUrl(id: string): string;
563
612
  getAspectDefinitions(): Promise<AspectDefinition[] | Error>;
613
+ getAspectDefinition(aspectId: string, jwtToken?: string): Promise<AspectDefinition>;
564
614
  getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | Error>;
615
+ getRecordInFull(id: string): Promise<Record_2>;
565
616
  getRecords<I extends Record_2>(aspect?: Array<string>, optionalAspect?: Array<string>, pageToken?: string, dereference?: boolean, limit?: number, aspectQueries?: string[], aspectOrQuery?: string[], orderBy?: string, orderByDir?: string, orderNullFirst?: boolean): Promise<RecordsPage<I> | Error>;
566
617
  getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | Error>;
567
618
  }
@@ -582,6 +633,16 @@ export declare interface RegistryOptions {
582
633
  tenantId: number;
583
634
  }
584
635
 
636
+ declare class ServerError extends Error {
637
+ statusCode: number;
638
+ constructor(message?: string, statusCode?: number);
639
+ toData(): {
640
+ isError: boolean;
641
+ errorCode: number;
642
+ errorMessage: string;
643
+ };
644
+ }
645
+
585
646
  export declare const TenantConsts: any;
586
647
 
587
648
  export declare class WebHook {
@@ -598,6 +659,11 @@ export declare class WebHook {
598
659
  'retryCount': number;
599
660
  'isRunning': any;
600
661
  'isProcessing': any;
662
+ 'ownerId': string;
663
+ 'creatorId': string;
664
+ 'editorId': string;
665
+ 'createTime': Date;
666
+ 'editTime': Date;
601
667
  }
602
668
 
603
669
  /**
package/dist/index.js CHANGED
@@ -11250,8 +11250,8 @@ module.exports = v4;
11250
11250
  /***/ (function(module, exports, __webpack_require__) {
11251
11251
 
11252
11252
  /*global exports*/
11253
- var SignStream = __webpack_require__(219);
11254
- var VerifyStream = __webpack_require__(223);
11253
+ var SignStream = __webpack_require__(220);
11254
+ var VerifyStream = __webpack_require__(224);
11255
11255
 
11256
11256
  var ALGORITHMS = [
11257
11257
  'HS256', 'HS384', 'HS512',
@@ -11279,6 +11279,15 @@ exports.createVerify = function createVerify(opts) {
11279
11279
 
11280
11280
  "use strict";
11281
11281
 
11282
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
11283
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11284
+ return new (P || (P = Promise))(function (resolve, reject) {
11285
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11286
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11287
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11288
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11289
+ });
11290
+ };
11282
11291
  var __importDefault = (this && this.__importDefault) || function (mod) {
11283
11292
  return (mod && mod.__esModule) ? mod : { "default": mod };
11284
11293
  };
@@ -11288,6 +11297,7 @@ const urijs_1 = __importDefault(__webpack_require__(213));
11288
11297
  const retry_1 = __importDefault(__webpack_require__(88));
11289
11298
  const formatServiceError_1 = __importDefault(__webpack_require__(89));
11290
11299
  const createServiceError_1 = __importDefault(__webpack_require__(90));
11300
+ const ServerError_1 = __importDefault(__webpack_require__(216));
11291
11301
  class RegistryClient {
11292
11302
  constructor({ baseUrl, maxRetries = 10, secondsBetweenRetries = 10, tenantId }) {
11293
11303
  if (tenantId === undefined) {
@@ -11305,6 +11315,14 @@ class RegistryClient {
11305
11315
  this.webHooksApi = new api_1.WebHooksApi(registryApiUrl);
11306
11316
  this.recordHistoryApi = new api_1.RecordHistoryApi(registryApiUrl);
11307
11317
  }
11318
+ toServerError(error) {
11319
+ if (error === null || error === void 0 ? void 0 : error.response) {
11320
+ return new ServerError_1.default(error.body, error.response.statusCode);
11321
+ }
11322
+ else {
11323
+ return error;
11324
+ }
11325
+ }
11308
11326
  getRecordUrl(id) {
11309
11327
  return this.baseUri.clone().segment("records").segment(id).toString();
11310
11328
  }
@@ -11314,6 +11332,20 @@ class RegistryClient {
11314
11332
  .then((result) => result.body)
11315
11333
  .catch(createServiceError_1.default);
11316
11334
  }
11335
+ getAspectDefinition(aspectId, jwtToken) {
11336
+ return __awaiter(this, void 0, void 0, function* () {
11337
+ try {
11338
+ const res = yield this.aspectDefinitionsApi.getById(this.tenantId, aspectId, jwtToken);
11339
+ if (typeof res.body === "string") {
11340
+ throw new Error("Invalid non-json response: " + res.body);
11341
+ }
11342
+ return res.body;
11343
+ }
11344
+ catch (e) {
11345
+ throw this.toServerError(e);
11346
+ }
11347
+ });
11348
+ }
11317
11349
  getRecord(id, aspect, optionalAspect, dereference) {
11318
11350
  const operation = (id) => () => this.recordsApi.getById(encodeURIComponent(id), this.tenantId, aspect, optionalAspect, dereference, this.jwt);
11319
11351
  return retry_1.default(operation(id), this.secondsBetweenRetries, this.maxRetries, (e, retriesLeft) => console.log(formatServiceError_1.default("Failed to GET records.", e, retriesLeft)), (e) => {
@@ -11322,6 +11354,20 @@ class RegistryClient {
11322
11354
  .then((result) => result.body)
11323
11355
  .catch(createServiceError_1.default);
11324
11356
  }
11357
+ getRecordInFull(id) {
11358
+ return __awaiter(this, void 0, void 0, function* () {
11359
+ try {
11360
+ const res = yield this.recordsApi.getByIdInFull(encodeURIComponent(id), this.tenantId, this.jwt);
11361
+ if (typeof res.body === "string") {
11362
+ throw new Error("Invalid non-json response: " + res.body);
11363
+ }
11364
+ return res.body;
11365
+ }
11366
+ catch (e) {
11367
+ throw this.toServerError(e);
11368
+ }
11369
+ });
11370
+ }
11325
11371
  getRecords(aspect, optionalAspect, pageToken, dereference, limit, aspectQueries, aspectOrQuery, orderBy, orderByDir, orderNullFirst) {
11326
11372
  const operation = (pageToken) => () => this.recordsApi.getAll(this.tenantId, aspect, optionalAspect, pageToken, undefined, limit, dereference, aspectQueries, aspectOrQuery, orderBy, orderByDir, orderNullFirst, this.jwt);
11327
11373
  return retry_1.default(operation(pageToken), this.secondsBetweenRetries, this.maxRetries, (e, retriesLeft) => console.log(formatServiceError_1.default("Failed to GET records.", e, retriesLeft)))
@@ -11559,8 +11605,9 @@ class AspectDefinitionsApi {
11559
11605
  * Get a list of all aspects
11560
11606
  *
11561
11607
  * @param xMagdaTenantId 0
11608
+ * @param xMagdaSession Magda internal session id
11562
11609
  */
11563
- getAll(xMagdaTenantId) {
11610
+ getAll(xMagdaTenantId, xMagdaSession) {
11564
11611
  const localVarPath = this.basePath + '/aspects';
11565
11612
  let queryParameters = {};
11566
11613
  let headerParams = Object.assign({}, this.defaultHeaders);
@@ -11570,6 +11617,7 @@ class AspectDefinitionsApi {
11570
11617
  throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getAll.');
11571
11618
  }
11572
11619
  headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
11620
+ headerParams['X-Magda-Session'] = xMagdaSession;
11573
11621
  let useFormData = false;
11574
11622
  let requestOptions = {
11575
11623
  method: 'GET',
@@ -11609,8 +11657,9 @@ class AspectDefinitionsApi {
11609
11657
  *
11610
11658
  * @param xMagdaTenantId 0
11611
11659
  * @param id ID of the aspect to be fetched.
11660
+ * @param xMagdaSession Magda internal session id
11612
11661
  */
11613
- getById(xMagdaTenantId, id) {
11662
+ getById(xMagdaTenantId, id, xMagdaSession) {
11614
11663
  const localVarPath = this.basePath + '/aspects/{id}'
11615
11664
  .replace('{' + 'id' + '}', String(id));
11616
11665
  let queryParameters = {};
@@ -11625,6 +11674,7 @@ class AspectDefinitionsApi {
11625
11674
  throw new Error('Required parameter id was null or undefined when calling getById.');
11626
11675
  }
11627
11676
  headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
11677
+ headerParams['X-Magda-Session'] = xMagdaSession;
11628
11678
  let useFormData = false;
11629
11679
  let requestOptions = {
11630
11680
  method: 'GET',
@@ -11890,6 +11940,140 @@ class RecordAspectsApi {
11890
11940
  });
11891
11941
  });
11892
11942
  }
11943
+ /**
11944
+ * Get a list of a record&#39;s aspects
11945
+ *
11946
+ * @param xMagdaTenantId 0
11947
+ * @param recordId ID of the record for which to fetch aspects.
11948
+ * @param keyword Specify the keyword to search in the all aspects&#39; aspectId &amp; data fields.
11949
+ * @param aspectIdOnly When set to true, will respond only an array contains aspect id only.
11950
+ * @param start The index of the first record to retrieve.
11951
+ * @param limit The maximum number of records to receive.
11952
+ * @param xMagdaSession Magda internal session id
11953
+ */
11954
+ getAspects(xMagdaTenantId, recordId, keyword, aspectIdOnly, start, limit, xMagdaSession) {
11955
+ const localVarPath = this.basePath + '/records/{recordId}/aspects'
11956
+ .replace('{' + 'recordId' + '}', String(recordId));
11957
+ let queryParameters = {};
11958
+ let headerParams = Object.assign({}, this.defaultHeaders);
11959
+ let formParams = {};
11960
+ // verify required parameter 'xMagdaTenantId' is not null or undefined
11961
+ if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
11962
+ throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getAspects.');
11963
+ }
11964
+ // verify required parameter 'recordId' is not null or undefined
11965
+ if (recordId === null || recordId === undefined) {
11966
+ throw new Error('Required parameter recordId was null or undefined when calling getAspects.');
11967
+ }
11968
+ if (keyword !== undefined) {
11969
+ queryParameters['keyword'] = keyword;
11970
+ }
11971
+ if (aspectIdOnly !== undefined) {
11972
+ queryParameters['aspectIdOnly'] = aspectIdOnly;
11973
+ }
11974
+ if (start !== undefined) {
11975
+ queryParameters['start'] = start;
11976
+ }
11977
+ if (limit !== undefined) {
11978
+ queryParameters['limit'] = limit;
11979
+ }
11980
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
11981
+ headerParams['X-Magda-Session'] = xMagdaSession;
11982
+ let useFormData = false;
11983
+ let requestOptions = {
11984
+ method: 'GET',
11985
+ qs: queryParameters,
11986
+ headers: headerParams,
11987
+ uri: localVarPath,
11988
+ useQuerystring: this._useQuerystring,
11989
+ json: true,
11990
+ };
11991
+ this.authentications.default.applyToRequest(requestOptions);
11992
+ if (Object.keys(formParams).length) {
11993
+ if (useFormData) {
11994
+ requestOptions.formData = formParams;
11995
+ }
11996
+ else {
11997
+ requestOptions.form = formParams;
11998
+ }
11999
+ }
12000
+ return new Promise((resolve, reject) => {
12001
+ request(requestOptions, (error, response, body) => {
12002
+ if (error) {
12003
+ reject(error);
12004
+ }
12005
+ else {
12006
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
12007
+ resolve({ response: response, body: body });
12008
+ }
12009
+ else {
12010
+ reject({ response: response, body: body });
12011
+ }
12012
+ }
12013
+ });
12014
+ });
12015
+ }
12016
+ /**
12017
+ * Get the number of aspects that a record has
12018
+ *
12019
+ * @param xMagdaTenantId 0
12020
+ * @param recordId ID of the record for which to fetch an aspect.
12021
+ * @param keyword Specify the keyword to search in the all aspects&#39; aspectId &amp; data fields.
12022
+ * @param xMagdaSession Magda internal session id
12023
+ */
12024
+ getAspectsCount(xMagdaTenantId, recordId, keyword, xMagdaSession) {
12025
+ const localVarPath = this.basePath + '/records/{recordId}/aspects/count'
12026
+ .replace('{' + 'recordId' + '}', String(recordId));
12027
+ let queryParameters = {};
12028
+ let headerParams = Object.assign({}, this.defaultHeaders);
12029
+ let formParams = {};
12030
+ // verify required parameter 'xMagdaTenantId' is not null or undefined
12031
+ if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
12032
+ throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getAspectsCount.');
12033
+ }
12034
+ // verify required parameter 'recordId' is not null or undefined
12035
+ if (recordId === null || recordId === undefined) {
12036
+ throw new Error('Required parameter recordId was null or undefined when calling getAspectsCount.');
12037
+ }
12038
+ if (keyword !== undefined) {
12039
+ queryParameters['keyword'] = keyword;
12040
+ }
12041
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
12042
+ headerParams['X-Magda-Session'] = xMagdaSession;
12043
+ let useFormData = false;
12044
+ let requestOptions = {
12045
+ method: 'GET',
12046
+ qs: queryParameters,
12047
+ headers: headerParams,
12048
+ uri: localVarPath,
12049
+ useQuerystring: this._useQuerystring,
12050
+ json: true,
12051
+ };
12052
+ this.authentications.default.applyToRequest(requestOptions);
12053
+ if (Object.keys(formParams).length) {
12054
+ if (useFormData) {
12055
+ requestOptions.formData = formParams;
12056
+ }
12057
+ else {
12058
+ requestOptions.form = formParams;
12059
+ }
12060
+ }
12061
+ return new Promise((resolve, reject) => {
12062
+ request(requestOptions, (error, response, body) => {
12063
+ if (error) {
12064
+ reject(error);
12065
+ }
12066
+ else {
12067
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
12068
+ resolve({ response: response, body: body });
12069
+ }
12070
+ else {
12071
+ reject({ response: response, body: body });
12072
+ }
12073
+ }
12074
+ });
12075
+ });
12076
+ }
11893
12077
  /**
11894
12078
  * Get a record aspect by ID
11895
12079
  *
@@ -12650,6 +12834,63 @@ class RecordsApi {
12650
12834
  });
12651
12835
  });
12652
12836
  }
12837
+ /**
12838
+ * Get a record in full by ID
12839
+ * Get a record with all attached aspects data by the record ID.
12840
+ * @param id ID of the record to be fetched.
12841
+ * @param xMagdaTenantId 0
12842
+ * @param xMagdaSession Magda internal session id
12843
+ */
12844
+ getByIdInFull(id, xMagdaTenantId, xMagdaSession) {
12845
+ const localVarPath = this.basePath + '/records/inFull/{id}'
12846
+ .replace('{' + 'id' + '}', String(id));
12847
+ let queryParameters = {};
12848
+ let headerParams = Object.assign({}, this.defaultHeaders);
12849
+ let formParams = {};
12850
+ // verify required parameter 'id' is not null or undefined
12851
+ if (id === null || id === undefined) {
12852
+ throw new Error('Required parameter id was null or undefined when calling getByIdInFull.');
12853
+ }
12854
+ // verify required parameter 'xMagdaTenantId' is not null or undefined
12855
+ if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
12856
+ throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getByIdInFull.');
12857
+ }
12858
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
12859
+ headerParams['X-Magda-Session'] = xMagdaSession;
12860
+ let useFormData = false;
12861
+ let requestOptions = {
12862
+ method: 'GET',
12863
+ qs: queryParameters,
12864
+ headers: headerParams,
12865
+ uri: localVarPath,
12866
+ useQuerystring: this._useQuerystring,
12867
+ json: true,
12868
+ };
12869
+ this.authentications.default.applyToRequest(requestOptions);
12870
+ if (Object.keys(formParams).length) {
12871
+ if (useFormData) {
12872
+ requestOptions.formData = formParams;
12873
+ }
12874
+ else {
12875
+ requestOptions.form = formParams;
12876
+ }
12877
+ }
12878
+ return new Promise((resolve, reject) => {
12879
+ request(requestOptions, (error, response, body) => {
12880
+ if (error) {
12881
+ reject(error);
12882
+ }
12883
+ else {
12884
+ if (response.statusCode >= 200 && response.statusCode <= 299) {
12885
+ resolve({ response: response, body: body });
12886
+ }
12887
+ else {
12888
+ reject({ response: response, body: body });
12889
+ }
12890
+ }
12891
+ });
12892
+ });
12893
+ }
12653
12894
  /**
12654
12895
  * Get a summary record by ID
12655
12896
  * Gets a summary record, including all the aspect ids for which this record has data.
@@ -18714,10 +18955,10 @@ module.exports = DataStream;
18714
18955
  /* 93 */
18715
18956
  /***/ (function(module, exports, __webpack_require__) {
18716
18957
 
18717
- var bufferEqual = __webpack_require__(220);
18958
+ var bufferEqual = __webpack_require__(221);
18718
18959
  var Buffer = __webpack_require__(8).Buffer;
18719
18960
  var crypto = __webpack_require__(3);
18720
- var formatEcdsa = __webpack_require__(221);
18961
+ var formatEcdsa = __webpack_require__(222);
18721
18962
  var util = __webpack_require__(1);
18722
18963
 
18723
18964
  var MSG_INVALID_ALGORITHM = '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".'
@@ -19024,7 +19265,7 @@ module.exports = TokenExpiredError;
19024
19265
  /* 97 */
19025
19266
  /***/ (function(module, exports, __webpack_require__) {
19026
19267
 
19027
- var ms = __webpack_require__(225);
19268
+ var ms = __webpack_require__(226);
19028
19269
 
19029
19270
  module.exports = function (time, iat) {
19030
19271
  var timestamp = iat || Math.floor(Date.now() / 1000);
@@ -19047,7 +19288,7 @@ module.exports = function (time, iat) {
19047
19288
  /* 98 */
19048
19289
  /***/ (function(module, exports, __webpack_require__) {
19049
19290
 
19050
- var semver = __webpack_require__(226);
19291
+ var semver = __webpack_require__(227);
19051
19292
 
19052
19293
  module.exports = semver.satisfies(process.version, '^6.12.0 || >=8.0.0');
19053
19294
 
@@ -19062,9 +19303,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
19062
19303
  exports.TenantConsts = void 0;
19063
19304
  var RegistryClient_1 = __webpack_require__(48);
19064
19305
  Object.defineProperty(exports, "RegistryClient", { enumerable: true, get: function () { return RegistryClient_1.default; } });
19065
- var AuthorizedRegistryClient_1 = __webpack_require__(216);
19306
+ var AuthorizedRegistryClient_1 = __webpack_require__(217);
19066
19307
  Object.defineProperty(exports, "AuthorizedRegistryClient", { enumerable: true, get: function () { return AuthorizedRegistryClient_1.default; } });
19067
- exports.TenantConsts = __webpack_require__(236);
19308
+ exports.TenantConsts = __webpack_require__(237);
19068
19309
  var api_1 = __webpack_require__(49);
19069
19310
  Object.defineProperty(exports, "Record", { enumerable: true, get: function () { return api_1.Record; } });
19070
19311
  Object.defineProperty(exports, "AspectDefinition", { enumerable: true, get: function () { return api_1.AspectDefinition; } });
@@ -38940,6 +39181,38 @@ exports.default = runLater;
38940
39181
 
38941
39182
  "use strict";
38942
39183
 
39184
+ Object.defineProperty(exports, "__esModule", { value: true });
39185
+ class ServerError extends Error {
39186
+ constructor(message = "Unknown Error", statusCode = 500) {
39187
+ super(message);
39188
+ this.statusCode = statusCode;
39189
+ }
39190
+ toData() {
39191
+ return {
39192
+ isError: true,
39193
+ errorCode: this.statusCode,
39194
+ errorMessage: this.message
39195
+ };
39196
+ }
39197
+ }
39198
+ exports.default = ServerError;
39199
+ //# sourceMappingURL=ServerError.js.map
39200
+
39201
+ /***/ }),
39202
+ /* 217 */
39203
+ /***/ (function(module, exports, __webpack_require__) {
39204
+
39205
+ "use strict";
39206
+
39207
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39208
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
39209
+ return new (P || (P = Promise))(function (resolve, reject) {
39210
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39211
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39212
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39213
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
39214
+ });
39215
+ };
38943
39216
  var __importDefault = (this && this.__importDefault) || function (mod) {
38944
39217
  return (mod && mod.__esModule) ? mod : { "default": mod };
38945
39218
  };
@@ -38948,8 +39221,8 @@ const RegistryClient_1 = __importDefault(__webpack_require__(48));
38948
39221
  const retry_1 = __importDefault(__webpack_require__(88));
38949
39222
  const formatServiceError_1 = __importDefault(__webpack_require__(89));
38950
39223
  const createServiceError_1 = __importDefault(__webpack_require__(90));
38951
- const buildJwt_1 = __importDefault(__webpack_require__(217));
38952
- const tsmonad_1 = __webpack_require__(235);
39224
+ const buildJwt_1 = __importDefault(__webpack_require__(218));
39225
+ const tsmonad_1 = __webpack_require__(236);
38953
39226
  class AuthorizedRegistryClient extends RegistryClient_1.default {
38954
39227
  constructor(options) {
38955
39228
  if (options.tenantId === undefined || options.tenantId === null) {
@@ -38965,6 +39238,14 @@ class AuthorizedRegistryClient extends RegistryClient_1.default {
38965
39238
  ? options.jwt
38966
39239
  : buildJwt_1.default(options.jwtSecret, options.userId);
38967
39240
  }
39241
+ getAspectDefinition(aspectId) {
39242
+ const _super = Object.create(null, {
39243
+ getAspectDefinition: { get: () => super.getAspectDefinition }
39244
+ });
39245
+ return __awaiter(this, void 0, void 0, function* () {
39246
+ return yield _super.getAspectDefinition.call(this, aspectId, this.jwt);
39247
+ });
39248
+ }
38968
39249
  putAspectDefinition(aspectDefinition, tenantId = this.tenantId) {
38969
39250
  const operation = () => this.aspectDefinitionsApi.putById(tenantId, encodeURIComponent(aspectDefinition.id), aspectDefinition, this.jwt);
38970
39251
  return retry_1.default(operation, this.secondsBetweenRetries, this.maxRetries, (e, retriesLeft) => console.log(formatServiceError_1.default(`Failed to create aspect definition "${aspectDefinition.id}".`, e, retriesLeft)))
@@ -39056,13 +39337,13 @@ exports.default = AuthorizedRegistryClient;
39056
39337
  //# sourceMappingURL=AuthorizedRegistryClient.js.map
39057
39338
 
39058
39339
  /***/ }),
39059
- /* 217 */
39340
+ /* 218 */
39060
39341
  /***/ (function(module, exports, __webpack_require__) {
39061
39342
 
39062
39343
  "use strict";
39063
39344
 
39064
39345
  Object.defineProperty(exports, "__esModule", { value: true });
39065
- const jwt = __webpack_require__(218);
39346
+ const jwt = __webpack_require__(219);
39066
39347
  function buildJwt(jwtSecret, userId, session = {}) {
39067
39348
  return jwt.sign({ userId, session }, jwtSecret);
39068
39349
  }
@@ -39070,13 +39351,13 @@ exports.default = buildJwt;
39070
39351
  //# sourceMappingURL=buildJwt.js.map
39071
39352
 
39072
39353
  /***/ }),
39073
- /* 218 */
39354
+ /* 219 */
39074
39355
  /***/ (function(module, exports, __webpack_require__) {
39075
39356
 
39076
39357
  module.exports = {
39077
39358
  decode: __webpack_require__(91),
39078
- verify: __webpack_require__(224),
39079
- sign: __webpack_require__(227),
39359
+ verify: __webpack_require__(225),
39360
+ sign: __webpack_require__(228),
39080
39361
  JsonWebTokenError: __webpack_require__(31),
39081
39362
  NotBeforeError: __webpack_require__(95),
39082
39363
  TokenExpiredError: __webpack_require__(96),
@@ -39084,7 +39365,7 @@ module.exports = {
39084
39365
 
39085
39366
 
39086
39367
  /***/ }),
39087
- /* 219 */
39368
+ /* 220 */
39088
39369
  /***/ (function(module, exports, __webpack_require__) {
39089
39370
 
39090
39371
  /*global module*/
@@ -39168,7 +39449,7 @@ module.exports = SignStream;
39168
39449
 
39169
39450
 
39170
39451
  /***/ }),
39171
- /* 220 */
39452
+ /* 221 */
39172
39453
  /***/ (function(module, exports, __webpack_require__) {
39173
39454
 
39174
39455
  "use strict";
@@ -39216,7 +39497,7 @@ bufferEq.restore = function() {
39216
39497
 
39217
39498
 
39218
39499
  /***/ }),
39219
- /* 221 */
39500
+ /* 222 */
39220
39501
  /***/ (function(module, exports, __webpack_require__) {
39221
39502
 
39222
39503
  "use strict";
@@ -39224,7 +39505,7 @@ bufferEq.restore = function() {
39224
39505
 
39225
39506
  var Buffer = __webpack_require__(8).Buffer;
39226
39507
 
39227
- var getParamBytesForAlg = __webpack_require__(222);
39508
+ var getParamBytesForAlg = __webpack_require__(223);
39228
39509
 
39229
39510
  var MAX_OCTET = 0x80,
39230
39511
  CLASS_UNIVERSAL = 0,
@@ -39410,7 +39691,7 @@ module.exports = {
39410
39691
 
39411
39692
 
39412
39693
  /***/ }),
39413
- /* 222 */
39694
+ /* 223 */
39414
39695
  /***/ (function(module, exports, __webpack_require__) {
39415
39696
 
39416
39697
  "use strict";
@@ -39440,7 +39721,7 @@ module.exports = getParamBytesForAlg;
39440
39721
 
39441
39722
 
39442
39723
  /***/ }),
39443
- /* 223 */
39724
+ /* 224 */
39444
39725
  /***/ (function(module, exports, __webpack_require__) {
39445
39726
 
39446
39727
  /*global module*/
@@ -39566,7 +39847,7 @@ module.exports = VerifyStream;
39566
39847
 
39567
39848
 
39568
39849
  /***/ }),
39569
- /* 224 */
39850
+ /* 225 */
39570
39851
  /***/ (function(module, exports, __webpack_require__) {
39571
39852
 
39572
39853
  var JsonWebTokenError = __webpack_require__(31);
@@ -39797,7 +40078,7 @@ module.exports = function (jwtString, secretOrPublicKey, options, callback) {
39797
40078
 
39798
40079
 
39799
40080
  /***/ }),
39800
- /* 225 */
40081
+ /* 226 */
39801
40082
  /***/ (function(module, exports) {
39802
40083
 
39803
40084
  /**
@@ -39965,7 +40246,7 @@ function plural(ms, msAbs, n, name) {
39965
40246
 
39966
40247
 
39967
40248
  /***/ }),
39968
- /* 226 */
40249
+ /* 227 */
39969
40250
  /***/ (function(module, exports) {
39970
40251
 
39971
40252
  exports = module.exports = SemVer
@@ -41454,19 +41735,19 @@ function coerce (version) {
41454
41735
 
41455
41736
 
41456
41737
  /***/ }),
41457
- /* 227 */
41738
+ /* 228 */
41458
41739
  /***/ (function(module, exports, __webpack_require__) {
41459
41740
 
41460
41741
  var timespan = __webpack_require__(97);
41461
41742
  var PS_SUPPORTED = __webpack_require__(98);
41462
41743
  var jws = __webpack_require__(47);
41463
- var includes = __webpack_require__(228);
41464
- var isBoolean = __webpack_require__(229);
41465
- var isInteger = __webpack_require__(230);
41466
- var isNumber = __webpack_require__(231);
41467
- var isPlainObject = __webpack_require__(232);
41468
- var isString = __webpack_require__(233);
41469
- var once = __webpack_require__(234);
41744
+ var includes = __webpack_require__(229);
41745
+ var isBoolean = __webpack_require__(230);
41746
+ var isInteger = __webpack_require__(231);
41747
+ var isNumber = __webpack_require__(232);
41748
+ var isPlainObject = __webpack_require__(233);
41749
+ var isString = __webpack_require__(234);
41750
+ var once = __webpack_require__(235);
41470
41751
 
41471
41752
  var SUPPORTED_ALGS = ['RS256', 'RS384', 'RS512', 'ES256', 'ES384', 'ES512', 'HS256', 'HS384', 'HS512', 'none']
41472
41753
  if (PS_SUPPORTED) {
@@ -41666,7 +41947,7 @@ module.exports = function (payload, secretOrPrivateKey, options, callback) {
41666
41947
 
41667
41948
 
41668
41949
  /***/ }),
41669
- /* 228 */
41950
+ /* 229 */
41670
41951
  /***/ (function(module, exports) {
41671
41952
 
41672
41953
  /**
@@ -42417,7 +42698,7 @@ module.exports = includes;
42417
42698
 
42418
42699
 
42419
42700
  /***/ }),
42420
- /* 229 */
42701
+ /* 230 */
42421
42702
  /***/ (function(module, exports) {
42422
42703
 
42423
42704
  /**
@@ -42493,7 +42774,7 @@ module.exports = isBoolean;
42493
42774
 
42494
42775
 
42495
42776
  /***/ }),
42496
- /* 230 */
42777
+ /* 231 */
42497
42778
  /***/ (function(module, exports) {
42498
42779
 
42499
42780
  /**
@@ -42764,7 +43045,7 @@ module.exports = isInteger;
42764
43045
 
42765
43046
 
42766
43047
  /***/ }),
42767
- /* 231 */
43048
+ /* 232 */
42768
43049
  /***/ (function(module, exports) {
42769
43050
 
42770
43051
  /**
@@ -42849,7 +43130,7 @@ module.exports = isNumber;
42849
43130
 
42850
43131
 
42851
43132
  /***/ }),
42852
- /* 232 */
43133
+ /* 233 */
42853
43134
  /***/ (function(module, exports) {
42854
43135
 
42855
43136
  /**
@@ -42994,7 +43275,7 @@ module.exports = isPlainObject;
42994
43275
 
42995
43276
 
42996
43277
  /***/ }),
42997
- /* 233 */
43278
+ /* 234 */
42998
43279
  /***/ (function(module, exports) {
42999
43280
 
43000
43281
  /**
@@ -43095,7 +43376,7 @@ module.exports = isString;
43095
43376
 
43096
43377
 
43097
43378
  /***/ }),
43098
- /* 234 */
43379
+ /* 235 */
43099
43380
  /***/ (function(module, exports) {
43100
43381
 
43101
43382
  /**
@@ -43395,14 +43676,14 @@ module.exports = once;
43395
43676
 
43396
43677
 
43397
43678
  /***/ }),
43398
- /* 235 */
43679
+ /* 236 */
43399
43680
  /***/ (function(module, exports, __webpack_require__) {
43400
43681
 
43401
43682
  !function(t,n){if(true)module.exports=n();else { var i, e; }}(this,function(){return function(t){function n(i){if(e[i])return e[i].exports;var r=e[i]={exports:{},id:i,loaded:!1};return t[i].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){"use strict";function i(t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e])}Object.defineProperty(n,"__esModule",{value:!0}),i(e(2)),i(e(3)),i(e(1)),i(e(4))},function(t,n){"use strict";function e(t,n){var i=0;if(t===n)return!0;if("function"==typeof t.equals)return t.equals(n);if(t.length>0&&t.length===n.length){for(;i<t.length;i+=1)if(!e(t[i],n[i]))return!1;return!0}return!1}Object.defineProperty(n,"__esModule",{value:!0}),n.eq=e},function(t,n,e){"use strict";function i(t){return null!==t&&void 0!==t}function r(t,n){if(i(t)&&i(n))throw new TypeError("Cannot construct an Either with both a left and a right");if(!i(t)&&!i(n))throw new TypeError("Cannot construct an Either with neither a left nor a right");return i(t)&&!i(n)?s.left(t):!i(t)&&i(n)?s.right(n):void 0}Object.defineProperty(n,"__esModule",{value:!0});var o,u=e(1);!function(t){t[t.Left=0]="Left",t[t.Right=1]="Right"}(o=n.EitherType||(n.EitherType={})),n.either=r;var s=function(){function t(t,n,e){this.type=t,this.l=n,this.r=e,this.of=this.unit,this.chain=this.bind,this.lift=this.fmap,this.map=this.fmap}return t.left=function(n){return new t(o.Left,n)},t.right=function(n){return new t(o.Right,null,n)},t.prototype.unit=function(n){return t.right(n)},t.prototype.bind=function(n){return this.type===o.Right?n(this.r):t.left(this.l)},t.prototype.fmap=function(t){var n=this;return this.bind(function(e){return n.unit(t(e))})},t.prototype.caseOf=function(t){return this.type===o.Right?t.right(this.r):t.left(this.l)},t.prototype.equals=function(t){return t.type===this.type&&(this.type===o.Left&&u.eq(t.l,this.l)||this.type===o.Right&&u.eq(t.r,this.r))},t.prototype["do"]=function(t){void 0===t&&(t={});var n={left:function(t){},right:function(t){}},e=Object.assign(n,t);return this.caseOf(e),this},t}();n.Either=s},function(t,n,e){"use strict";function i(t){return u.maybe(t)}Object.defineProperty(n,"__esModule",{value:!0});var r,o=e(1);!function(t){t[t.Nothing=0]="Nothing",t[t.Just=1]="Just"}(r=n.MaybeType||(n.MaybeType={})),n.maybe=i;var u=function(){function t(t,n){this.type=t,this.value=n,this.of=this.unit,this.chain=this.bind,this.lift=this.fmap,this.map=this.fmap}return t.sequence=function(n){if(Object.keys(n).filter(function(t){return n[t].type===r.Nothing}).length)return t.nothing();var e={};for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i].value);return t.just(e)},t.maybe=function(n){return null===n||void 0===n?new t(r.Nothing):new t(r.Just,n)},t.just=function(n){if(null===n||void 0===n)throw new TypeError("Cannot Maybe.just(null)");return new t(r.Just,n)},t.nothing=function(){return new t(r.Nothing)},t.prototype.unit=function(n){return t.maybe(n)},t.prototype.bind=function(n){return this.type===r.Just?n(this.value):t.nothing()},t.prototype.fmap=function(t){var n=this;return this.bind(function(e){return n.unit(t(e))})},t.prototype.caseOf=function(t){return this.type===r.Just?t.just(this.value):t.nothing()},t.prototype.defaulting=function(n){return t.just(this.valueOr(n))},t.prototype.equals=function(t){return t.type===this.type&&(this.type===r.Nothing||o.eq(t.value,this.value))},t.prototype.valueOr=function(t){return this.valueOrCompute(function(){return t})},t.prototype.valueOrCompute=function(t){return this.type===r.Just?this.value:t()},t.prototype.valueOrThrow=function(t){if(this.type===r.Just)return this.value;throw t||new Error("No value is available.")},t.prototype["do"]=function(t){void 0===t&&(t={});var n={just:function(t){},nothing:function(){}},e=Object.assign(n,t);return this.caseOf(e),this},t}();u.all=function(t){return u.sequence(t)},n.Maybe=u},function(t,n){"use strict";function e(t,n){return i.writer(t,n)}Object.defineProperty(n,"__esModule",{value:!0}),n.writer=e;var i=function(){function t(t,n){this.story=t,this.value=n,this.of=this.unit,this.chain=this.bind,this.lift=this.fmap,this.map=this.fmap}return t.writer=function(n,e){return new t(n,e)},t.tell=function(n){return new t([n],0)},t.prototype.unit=function(n){return new t([],n)},t.prototype.bind=function(n){var e=n(this.value),i=this.story.concat(e.story);return new t(i,e.value)},t.prototype.fmap=function(t){var n=this;return this.bind(function(e){return n.unit(t(e))})},t.prototype.caseOf=function(t){return t.writer(this.story,this.value)},t.prototype.equals=function(t){var n,e=!0;for(n=0;n<this.story.length;n+=1)e=e&&this.story[n]===t.story[n];return e&&this.value===t.value},t}();n.Writer=i}])});
43402
43683
  //# sourceMappingURL=tsmonad.js.map
43403
43684
 
43404
43685
  /***/ }),
43405
- /* 236 */
43686
+ /* 237 */
43406
43687
  /***/ (function(module, exports, __webpack_require__) {
43407
43688
 
43408
43689
  "use strict";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@magda/registry-client",
3
3
  "description": "MAGDA Registry Client",
4
- "version": "1.2.1",
4
+ "version": "2.0.0-alpha.1",
5
5
  "scripts": {
6
6
  "prebuild": "rimraf dist tsconfig.tsbuildinfo",
7
7
  "build": "webpack && api-extractor run -l",
@@ -12,7 +12,7 @@
12
12
  "main": "dist/index.js",
13
13
  "types": "dist/index.d.ts",
14
14
  "devDependencies": {
15
- "@magda/typescript-common": "^1.2.1",
15
+ "@magda/typescript-common": "^2.0.0-alpha.1",
16
16
  "@microsoft/api-extractor": "^7.7.8",
17
17
  "ts-loader": "^6.2.1",
18
18
  "typescript": "^3.7.2",