@magda/registry-client 2.0.0-alpha.2 → 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.
Files changed (3) hide show
  1. package/dist/index.d.ts +92 -19
  2. package/dist/index.js +548 -293
  3. 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 | Error>;
97
- postHook(hook: WebHook): Promise<WebHook | Error>;
98
- putHook(hook: WebHook): Promise<WebHook | Error>;
99
- getHook(hookId: string): Promise<Maybe<WebHook> | Error>;
100
- getHooks(): Promise<WebHook[] | Error>;
101
- resumeHook(webhookId: string, succeeded?: boolean, lastEventIdReceived?: string, active?: boolean): Promise<WebHookAcknowledgementResponse | Error>;
102
- putRecord(record: Record_2, tenantId?: number): Promise<Record_2 | Error>;
103
- patchRecord(recordId: string, recordPatch: Operation[], tenantId?: number): Promise<Record_2 | Error>;
104
- putRecordAspect(recordId: string, aspectId: string, aspect: any, tenantId?: number): Promise<Record_2 | Error>;
105
- deleteRecordAspect(recordId: string, aspectId: string, tenantId?: number): Promise<DeleteResult | Error>;
106
- patchRecordAspect(recordId: string, aspectId: string, aspectPatch: Operation[], tenantId?: number): Promise<Record_2 | Error>;
107
- deleteBySource(sourceTagToPreserve: string, sourceId: string, tenantId?: number): Promise<MultipleDeleteResult | "Processing" | Error>;
108
- getRecordHistory(id: string, pageToken?: string, start?: number, limit?: number): Promise<EventsPage | Error>;
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
  }>;
@@ -413,6 +439,18 @@ declare class RecordsApi {
413
439
  response: http.IncomingMessage;
414
440
  body: DeleteResult;
415
441
  }>;
442
+ /**
443
+ * Remove items from records&#39; aspect data
444
+ * Remove items from records&#39; aspect data
445
+ * @param xMagdaTenantId 0
446
+ * @param aspectId ID of the aspect to update.
447
+ * @param requestData An json object has key &#39;recordIds&#39;, &#39;jsonPath&#39;, &#39;items&#39;
448
+ * @param xMagdaSession Magda internal session id
449
+ */
450
+ deleteRecordsAspectArrayItems(xMagdaTenantId: number, aspectId: string, requestData: DeleteRecordsAspectArrayItemsRequest, xMagdaSession: string): Promise<{
451
+ response: http.IncomingMessage;
452
+ body: Array<any>;
453
+ }>;
416
454
  /**
417
455
  * Get a list of all records
418
456
  *
@@ -512,7 +550,7 @@ declare class RecordsApi {
512
550
  * Modify a record by applying a JSON Patch
513
551
  * The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
514
552
  * @param xMagdaTenantId 0
515
- * @param id ID of the aspect to be saved.
553
+ * @param id ID of the record to be pacthed.
516
554
  * @param recordPatch The RFC 6902 patch to apply to the aspect.
517
555
  * @param xMagdaSession Magda internal session id
518
556
  */
@@ -520,6 +558,17 @@ declare class RecordsApi {
520
558
  response: http.IncomingMessage;
521
559
  body: Record_2;
522
560
  }>;
561
+ /**
562
+ * Modify a list of records by applying the same JSON Patch
563
+ * The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
564
+ * @param xMagdaTenantId 0
565
+ * @param requestData An json object has key &#39;recordIds&#39; &amp; &#39;jsonPath&#39;
566
+ * @param xMagdaSession Magda internal session id
567
+ */
568
+ patchRecords(xMagdaTenantId: number, requestData: PatchRecordsRequest, xMagdaSession: string): Promise<{
569
+ response: http.IncomingMessage;
570
+ body: Array<any>;
571
+ }>;
523
572
  /**
524
573
  * Modify a record by ID
525
574
  * Modifies a record. Aspects included in the request are created or updated, but missing aspects are not removed.
@@ -532,6 +581,19 @@ declare class RecordsApi {
532
581
  response: http.IncomingMessage;
533
582
  body: Record_2;
534
583
  }>;
584
+ /**
585
+ * Modify a list of records&#39;s aspect with same new data
586
+ * Modify a list of records&#39;s aspect with same new data
587
+ * @param xMagdaTenantId 0
588
+ * @param aspectId ID of the aspect to update.
589
+ * @param requestData An json object has key &#39;recordIds&#39; &amp; &#39;data&#39;
590
+ * @param xMagdaSession Magda internal session id
591
+ * @param merge Whether merge the supplied aspect data to existing aspect data or replace it
592
+ */
593
+ putRecordsAspect(xMagdaTenantId: number, aspectId: string, requestData: PutRecordsAspectRequest, xMagdaSession: string, merge?: boolean): Promise<{
594
+ response: http.IncomingMessage;
595
+ body: Array<any>;
596
+ }>;
535
597
  /**
536
598
  * Trim by source tag
537
599
  * Trims records with the provided source that DON&#39;T have the supplied source tag
@@ -591,12 +653,13 @@ export declare class RegistryClient {
591
653
  protected jwt: string | undefined;
592
654
  constructor({ baseUrl, maxRetries, secondsBetweenRetries, tenantId }: RegistryOptions);
593
655
  getRecordUrl(id: string): string;
594
- getAspectDefinitions(): Promise<AspectDefinition[] | Error>;
656
+ getAspectDefinitions(): Promise<AspectDefinition[] | ServerError>;
595
657
  getAspectDefinition(aspectId: string, jwtToken?: string): Promise<AspectDefinition>;
596
- getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | Error>;
658
+ getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | ServerError>;
659
+ getRecordAspect(id: string, aspectId: string): Promise<any | ServerError>;
597
660
  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> | Error>;
599
- getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | Error>;
661
+ 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> | ServerError>;
662
+ getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | ServerError>;
600
663
  }
601
664
 
602
665
  export declare class RegistryEvent {
@@ -615,6 +678,16 @@ export declare interface RegistryOptions {
615
678
  tenantId: number;
616
679
  }
617
680
 
681
+ declare class ServerError extends Error {
682
+ statusCode: number;
683
+ constructor(message?: string, statusCode?: number);
684
+ toData(): {
685
+ isError: boolean;
686
+ errorCode: number;
687
+ errorMessage: string;
688
+ };
689
+ }
690
+
618
691
  export declare const TenantConsts: any;
619
692
 
620
693
  export declare class WebHook {