@magda/registry-client 2.0.0-alpha.3 → 2.0.0-alpha.6
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 +98 -22
- package/dist/index.js +565 -298
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -93,19 +93,24 @@ export declare class AuthorizedRegistryClient extends RegistryClient {
|
|
|
93
93
|
protected jwt: string;
|
|
94
94
|
constructor(options: AuthorizedRegistryOptions);
|
|
95
95
|
getAspectDefinition(aspectId: string): Promise<AspectDefinition>;
|
|
96
|
-
putAspectDefinition(aspectDefinition: AspectDefinition, tenantId?: number): Promise<AspectDefinition |
|
|
97
|
-
postHook(hook: WebHook): Promise<WebHook |
|
|
98
|
-
putHook(hook: WebHook): Promise<WebHook |
|
|
99
|
-
getHook(hookId: string): Promise<Maybe<WebHook> |
|
|
100
|
-
getHooks(): Promise<WebHook[] |
|
|
101
|
-
resumeHook(webhookId: string, succeeded?: boolean, lastEventIdReceived?: string, active?: boolean): Promise<WebHookAcknowledgementResponse |
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
96
|
+
putAspectDefinition(aspectDefinition: AspectDefinition, tenantId?: number): Promise<AspectDefinition | ServerError>;
|
|
97
|
+
postHook(hook: WebHook): Promise<WebHook | ServerError>;
|
|
98
|
+
putHook(hook: WebHook): Promise<WebHook | ServerError>;
|
|
99
|
+
getHook(hookId: string): Promise<Maybe<WebHook> | ServerError>;
|
|
100
|
+
getHooks(): Promise<WebHook[] | ServerError>;
|
|
101
|
+
resumeHook(webhookId: string, succeeded?: boolean, lastEventIdReceived?: string, active?: boolean): Promise<WebHookAcknowledgementResponse | ServerError>;
|
|
102
|
+
creatRecord(record: Record_2, tenantId?: number): Promise<Record_2 | ServerError>;
|
|
103
|
+
putRecord(record: Record_2, tenantId?: number): Promise<Record_2 | ServerError>;
|
|
104
|
+
patchRecord(recordId: string, recordPatch: Operation[], tenantId?: number): Promise<Record_2 | ServerError>;
|
|
105
|
+
patchRecords(recordIds: string[], recordPatch: Operation[], tenantId?: number): Promise<string[] | ServerError>;
|
|
106
|
+
putRecordAspect(recordId: string, aspectId: string, aspect: any, merge?: boolean, tenantId?: number): Promise<any | ServerError>;
|
|
107
|
+
putRecordsAspect(recordIds: string[], aspectId: string, aspectData: any, merge?: boolean, tenantId?: number): Promise<string[] | ServerError>;
|
|
108
|
+
deleteRecordsAspectArrayItems(recordIds: string[], aspectId: string, jsonPath: string, items: (string | number)[], tenantId?: number): Promise<string[] | ServerError>;
|
|
109
|
+
deleteRecordAspect(recordId: string, aspectId: string, tenantId?: number): Promise<DeleteResult | ServerError>;
|
|
110
|
+
patchRecordAspect(recordId: string, aspectId: string, aspectPatch: Operation[], tenantId?: number): Promise<Record_2 | ServerError>;
|
|
111
|
+
deleteBySource(sourceTagToPreserve: string, sourceId: string, tenantId?: number): Promise<MultipleDeleteResult | "Processing" | ServerError>;
|
|
112
|
+
deleteRecord(id: string, tenantId?: number): Promise<DeleteResult | ServerError>;
|
|
113
|
+
getRecordHistory(id: string, pageToken?: string, start?: number, limit?: number): Promise<EventsPage | ServerError>;
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
export declare interface AuthorizedRegistryOptions extends RegistryOptions {
|
|
@@ -118,6 +123,12 @@ declare class CountResponse {
|
|
|
118
123
|
'count': number;
|
|
119
124
|
}
|
|
120
125
|
|
|
126
|
+
declare class DeleteRecordsAspectArrayItemsRequest {
|
|
127
|
+
'recordIds': Array<string>;
|
|
128
|
+
'jsonPath': string;
|
|
129
|
+
'items': Array<JsValue>;
|
|
130
|
+
}
|
|
131
|
+
|
|
121
132
|
declare class DeleteResult {
|
|
122
133
|
'deleted': boolean;
|
|
123
134
|
}
|
|
@@ -161,6 +172,10 @@ declare class JsObject {
|
|
|
161
172
|
};
|
|
162
173
|
}
|
|
163
174
|
|
|
175
|
+
declare class JsonPatch {
|
|
176
|
+
'ops': Array<Operation>;
|
|
177
|
+
}
|
|
178
|
+
|
|
164
179
|
declare class JsValue {
|
|
165
180
|
}
|
|
166
181
|
|
|
@@ -226,6 +241,16 @@ declare interface OptionalMaybePatterns<T, U> {
|
|
|
226
241
|
nothing?: () => U;
|
|
227
242
|
}
|
|
228
243
|
|
|
244
|
+
declare class PatchRecordsRequest {
|
|
245
|
+
'recordIds': Array<string>;
|
|
246
|
+
'jsonPath': JsonPatch;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare class PutRecordsAspectRequest {
|
|
250
|
+
'recordIds': Array<string>;
|
|
251
|
+
'data': JsObject;
|
|
252
|
+
}
|
|
253
|
+
|
|
229
254
|
/**
|
|
230
255
|
* A record in the registry, usually including data for one or more aspects, unique for a tenant.
|
|
231
256
|
*/
|
|
@@ -333,8 +358,9 @@ declare class RecordAspectsApi {
|
|
|
333
358
|
* @param aspect The record aspect to save.
|
|
334
359
|
* @param xMagdaSession Magda internal session id
|
|
335
360
|
* @param xMagdaTenantId 0
|
|
361
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
336
362
|
*/
|
|
337
|
-
putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number): Promise<{
|
|
363
|
+
putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number, merge?: boolean): Promise<{
|
|
338
364
|
response: http.IncomingMessage;
|
|
339
365
|
body: any;
|
|
340
366
|
}>;
|
|
@@ -362,8 +388,9 @@ declare class RecordHistoryApi {
|
|
|
362
388
|
* @param limit The maximum number of events to receive. The response will include a token that can be passed as the pageToken parameter to a future request to continue receiving results where this query leaves off.
|
|
363
389
|
* @param aspect The aspects for which to included in event history, specified as multiple occurrences of this query parameter.
|
|
364
390
|
* @param dereference true to automatically dereference links to other records; false to leave them as links. Dereferencing a link means including the record itself where the link would be. Dereferencing only happens one level deep, regardless of the value of this parameter.
|
|
391
|
+
* @param reversePageTokenOrder When pagination via pageToken, by default, records with smaller pageToken (i.e. older records) will be returned first. When this parameter is set to `true`, higher pageToken records (newer records) will be returned.
|
|
365
392
|
*/
|
|
366
|
-
history(xMagdaTenantId: number, recordId: string, xMagdaSession: string, pageToken?: string, start?: number, limit?: number, aspect?: Array<string>, dereference?: boolean): Promise<{
|
|
393
|
+
history(xMagdaTenantId: number, recordId: string, xMagdaSession: string, pageToken?: string, start?: number, limit?: number, aspect?: Array<string>, dereference?: boolean, reversePageTokenOrder?: boolean): Promise<{
|
|
367
394
|
response: http.IncomingMessage;
|
|
368
395
|
body: EventsPage;
|
|
369
396
|
}>;
|
|
@@ -413,6 +440,18 @@ declare class RecordsApi {
|
|
|
413
440
|
response: http.IncomingMessage;
|
|
414
441
|
body: DeleteResult;
|
|
415
442
|
}>;
|
|
443
|
+
/**
|
|
444
|
+
* Remove items from records' aspect data
|
|
445
|
+
* Remove items from records' aspect data
|
|
446
|
+
* @param xMagdaTenantId 0
|
|
447
|
+
* @param aspectId ID of the aspect to update.
|
|
448
|
+
* @param requestData An json object has key 'recordIds', 'jsonPath', 'items'
|
|
449
|
+
* @param xMagdaSession Magda internal session id
|
|
450
|
+
*/
|
|
451
|
+
deleteRecordsAspectArrayItems(xMagdaTenantId: number, aspectId: string, requestData: DeleteRecordsAspectArrayItemsRequest, xMagdaSession: string): Promise<{
|
|
452
|
+
response: http.IncomingMessage;
|
|
453
|
+
body: Array<any>;
|
|
454
|
+
}>;
|
|
416
455
|
/**
|
|
417
456
|
* Get a list of all records
|
|
418
457
|
*
|
|
@@ -428,9 +467,10 @@ declare class RecordsApi {
|
|
|
428
467
|
* @param orderBy Specify the field to sort the result. Aspect field can be supported in a format like aspectId.path.to.field
|
|
429
468
|
* @param orderByDir Specify the order by direction. Either `asc` or `desc`
|
|
430
469
|
* @param orderNullFirst Specify whether nulls appear before (`true`) or after (`false`) non-null values in the sort ordering.
|
|
470
|
+
* @param reversePageTokenOrder When pagination via pageToken, by default, records with smaller pageToken (i.e. older records) will be returned first. When this parameter is set to `true`, higher pageToken records (newer records) will be returned.
|
|
431
471
|
* @param xMagdaSession Magda internal session id
|
|
432
472
|
*/
|
|
433
|
-
getAll(xMagdaTenantId: number, aspect?: Array<string>, optionalAspect?: Array<string>, pageToken?: string, start?: number, limit?: number, dereference?: boolean, aspectQuery?: Array<string>, aspectOrQuery?: Array<string>, orderBy?: string, orderByDir?: string, orderNullFirst?: boolean, xMagdaSession?: string): Promise<{
|
|
473
|
+
getAll(xMagdaTenantId: number, aspect?: Array<string>, optionalAspect?: Array<string>, pageToken?: string, start?: number, limit?: number, dereference?: boolean, aspectQuery?: Array<string>, aspectOrQuery?: Array<string>, orderBy?: string, orderByDir?: string, orderNullFirst?: boolean, reversePageTokenOrder?: boolean, xMagdaSession?: string): Promise<{
|
|
434
474
|
response: http.IncomingMessage;
|
|
435
475
|
body: Array<Record_2>;
|
|
436
476
|
}>;
|
|
@@ -441,9 +481,10 @@ declare class RecordsApi {
|
|
|
441
481
|
* @param pageToken A token that identifies the start of a page of results. This token should not be interpreted as having any meaning, but it can be obtained from a previous page of results.
|
|
442
482
|
* @param start The index of the first record to retrieve. When possible, specify pageToken instead as it will result in better performance. If this parameter and pageToken are both specified, this parameter is interpreted as the index after the pageToken of the first record to retrieve.
|
|
443
483
|
* @param limit The maximum number of records to receive. The response will include a token that can be passed as the pageToken parameter to a future request to continue receiving results where this query leaves off.
|
|
484
|
+
* @param reversePageTokenOrder When pagination via pageToken, by default, records with smaller pageToken (i.e. older records) will be returned first. When this parameter is set to `true`, higher pageToken records (newer records) will be returned.
|
|
444
485
|
* @param xMagdaSession Magda internal session id
|
|
445
486
|
*/
|
|
446
|
-
getAllSummary(xMagdaTenantId: number, pageToken?: string, start?: number, limit?: number, xMagdaSession?: string): Promise<{
|
|
487
|
+
getAllSummary(xMagdaTenantId: number, pageToken?: string, start?: number, limit?: number, reversePageTokenOrder?: boolean, xMagdaSession?: string): Promise<{
|
|
447
488
|
response: http.IncomingMessage;
|
|
448
489
|
body: Array<RecordSummary>;
|
|
449
490
|
}>;
|
|
@@ -512,7 +553,7 @@ declare class RecordsApi {
|
|
|
512
553
|
* Modify a record by applying a JSON Patch
|
|
513
554
|
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
514
555
|
* @param xMagdaTenantId 0
|
|
515
|
-
* @param id ID of the
|
|
556
|
+
* @param id ID of the record to be pacthed.
|
|
516
557
|
* @param recordPatch The RFC 6902 patch to apply to the aspect.
|
|
517
558
|
* @param xMagdaSession Magda internal session id
|
|
518
559
|
*/
|
|
@@ -520,6 +561,17 @@ declare class RecordsApi {
|
|
|
520
561
|
response: http.IncomingMessage;
|
|
521
562
|
body: Record_2;
|
|
522
563
|
}>;
|
|
564
|
+
/**
|
|
565
|
+
* Modify a list of records by applying the same JSON Patch
|
|
566
|
+
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
567
|
+
* @param xMagdaTenantId 0
|
|
568
|
+
* @param requestData An json object has key 'recordIds' & 'jsonPath'
|
|
569
|
+
* @param xMagdaSession Magda internal session id
|
|
570
|
+
*/
|
|
571
|
+
patchRecords(xMagdaTenantId: number, requestData: PatchRecordsRequest, xMagdaSession: string): Promise<{
|
|
572
|
+
response: http.IncomingMessage;
|
|
573
|
+
body: Array<any>;
|
|
574
|
+
}>;
|
|
523
575
|
/**
|
|
524
576
|
* Modify a record by ID
|
|
525
577
|
* Modifies a record. Aspects included in the request are created or updated, but missing aspects are not removed.
|
|
@@ -532,6 +584,19 @@ declare class RecordsApi {
|
|
|
532
584
|
response: http.IncomingMessage;
|
|
533
585
|
body: Record_2;
|
|
534
586
|
}>;
|
|
587
|
+
/**
|
|
588
|
+
* Modify a list of records's aspect with same new data
|
|
589
|
+
* Modify a list of records's aspect with same new data
|
|
590
|
+
* @param xMagdaTenantId 0
|
|
591
|
+
* @param aspectId ID of the aspect to update.
|
|
592
|
+
* @param requestData An json object has key 'recordIds' & 'data'
|
|
593
|
+
* @param xMagdaSession Magda internal session id
|
|
594
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
595
|
+
*/
|
|
596
|
+
putRecordsAspect(xMagdaTenantId: number, aspectId: string, requestData: PutRecordsAspectRequest, xMagdaSession: string, merge?: boolean): Promise<{
|
|
597
|
+
response: http.IncomingMessage;
|
|
598
|
+
body: Array<any>;
|
|
599
|
+
}>;
|
|
535
600
|
/**
|
|
536
601
|
* Trim by source tag
|
|
537
602
|
* Trims records with the provided source that DON'T have the supplied source tag
|
|
@@ -591,12 +656,13 @@ export declare class RegistryClient {
|
|
|
591
656
|
protected jwt: string | undefined;
|
|
592
657
|
constructor({ baseUrl, maxRetries, secondsBetweenRetries, tenantId }: RegistryOptions);
|
|
593
658
|
getRecordUrl(id: string): string;
|
|
594
|
-
getAspectDefinitions(): Promise<AspectDefinition[] |
|
|
659
|
+
getAspectDefinitions(): Promise<AspectDefinition[] | ServerError>;
|
|
595
660
|
getAspectDefinition(aspectId: string, jwtToken?: string): Promise<AspectDefinition>;
|
|
596
|
-
getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 |
|
|
661
|
+
getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | ServerError>;
|
|
662
|
+
getRecordAspect(id: string, aspectId: string): Promise<any | ServerError>;
|
|
597
663
|
getRecordInFull(id: string): Promise<Record_2>;
|
|
598
|
-
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> |
|
|
599
|
-
getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] |
|
|
664
|
+
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, reversePageTokenOrder?: boolean): Promise<RecordsPage<I> | ServerError>;
|
|
665
|
+
getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | ServerError>;
|
|
600
666
|
}
|
|
601
667
|
|
|
602
668
|
export declare class RegistryEvent {
|
|
@@ -615,6 +681,16 @@ export declare interface RegistryOptions {
|
|
|
615
681
|
tenantId: number;
|
|
616
682
|
}
|
|
617
683
|
|
|
684
|
+
declare class ServerError extends Error {
|
|
685
|
+
statusCode: number;
|
|
686
|
+
constructor(message?: string, statusCode?: number);
|
|
687
|
+
toData(): {
|
|
688
|
+
isError: boolean;
|
|
689
|
+
errorCode: number;
|
|
690
|
+
errorMessage: string;
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
618
694
|
export declare const TenantConsts: any;
|
|
619
695
|
|
|
620
696
|
export declare class WebHook {
|