@magda/minion-sdk 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 +1060 -798
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -95,19 +95,24 @@ export declare class AuthorizedRegistryClient extends RegistryClient {
95
95
  protected jwt: string;
96
96
  constructor(options: AuthorizedRegistryOptions);
97
97
  getAspectDefinition(aspectId: string): Promise<AspectDefinition>;
98
- putAspectDefinition(aspectDefinition: AspectDefinition, tenantId?: number): Promise<AspectDefinition | Error>;
99
- postHook(hook: WebHook): Promise<WebHook | Error>;
100
- putHook(hook: WebHook): Promise<WebHook | Error>;
101
- getHook(hookId: string): Promise<Maybe<WebHook> | Error>;
102
- getHooks(): Promise<WebHook[] | Error>;
103
- resumeHook(webhookId: string, succeeded?: boolean, lastEventIdReceived?: string, active?: boolean): Promise<WebHookAcknowledgementResponse | Error>;
104
- putRecord(record: Record_2, tenantId?: number): Promise<Record_2 | Error>;
105
- patchRecord(recordId: string, recordPatch: Operation[], tenantId?: number): Promise<Record_2 | Error>;
106
- putRecordAspect(recordId: string, aspectId: string, aspect: any, tenantId?: number): Promise<Record_2 | Error>;
107
- deleteRecordAspect(recordId: string, aspectId: string, tenantId?: number): Promise<DeleteResult | Error>;
108
- patchRecordAspect(recordId: string, aspectId: string, aspectPatch: Operation[], tenantId?: number): Promise<Record_2 | Error>;
109
- deleteBySource(sourceTagToPreserve: string, sourceId: string, tenantId?: number): Promise<MultipleDeleteResult | "Processing" | Error>;
110
- getRecordHistory(id: string, pageToken?: string, start?: number, limit?: number): Promise<EventsPage | Error>;
98
+ putAspectDefinition(aspectDefinition: AspectDefinition, tenantId?: number): Promise<AspectDefinition | ServerError>;
99
+ postHook(hook: WebHook): Promise<WebHook | ServerError>;
100
+ putHook(hook: WebHook): Promise<WebHook | ServerError>;
101
+ getHook(hookId: string): Promise<Maybe<WebHook> | ServerError>;
102
+ getHooks(): Promise<WebHook[] | ServerError>;
103
+ resumeHook(webhookId: string, succeeded?: boolean, lastEventIdReceived?: string, active?: boolean): Promise<WebHookAcknowledgementResponse | ServerError>;
104
+ creatRecord(record: Record_2, tenantId?: number): Promise<Record_2 | ServerError>;
105
+ putRecord(record: Record_2, tenantId?: number): Promise<Record_2 | ServerError>;
106
+ patchRecord(recordId: string, recordPatch: Operation[], tenantId?: number): Promise<Record_2 | ServerError>;
107
+ patchRecords(recordIds: string[], recordPatch: Operation[], tenantId?: number): Promise<string[] | ServerError>;
108
+ putRecordAspect(recordId: string, aspectId: string, aspect: any, merge?: boolean, tenantId?: number): Promise<any | ServerError>;
109
+ putRecordsAspect(recordIds: string[], aspectId: string, aspectData: any, merge?: boolean, tenantId?: number): Promise<string[] | ServerError>;
110
+ deleteRecordsAspectArrayItems(recordIds: string[], aspectId: string, jsonPath: string, items: (string | number)[], tenantId?: number): Promise<string[] | ServerError>;
111
+ deleteRecordAspect(recordId: string, aspectId: string, tenantId?: number): Promise<DeleteResult | ServerError>;
112
+ patchRecordAspect(recordId: string, aspectId: string, aspectPatch: Operation[], tenantId?: number): Promise<Record_2 | ServerError>;
113
+ deleteBySource(sourceTagToPreserve: string, sourceId: string, tenantId?: number): Promise<MultipleDeleteResult | "Processing" | ServerError>;
114
+ deleteRecord(id: string, tenantId?: number): Promise<DeleteResult | ServerError>;
115
+ getRecordHistory(id: string, pageToken?: string, start?: number, limit?: number): Promise<EventsPage | ServerError>;
111
116
  }
112
117
 
113
118
  export declare interface AuthorizedRegistryOptions extends RegistryOptions {
@@ -130,6 +135,12 @@ declare class CountResponse {
130
135
  'count': number;
131
136
  }
132
137
 
138
+ declare class DeleteRecordsAspectArrayItemsRequest {
139
+ 'recordIds': Array<string>;
140
+ 'jsonPath': string;
141
+ 'items': Array<JsValue>;
142
+ }
143
+
133
144
  declare class DeleteResult {
134
145
  'deleted': boolean;
135
146
  }
@@ -173,6 +184,10 @@ declare class JsObject {
173
184
  };
174
185
  }
175
186
 
187
+ declare class JsonPatch {
188
+ 'ops': Array<Operation>;
189
+ }
190
+
176
191
  declare class JsValue {
177
192
  }
178
193
 
@@ -266,6 +281,16 @@ declare interface OptionalMaybePatterns<T, U> {
266
281
  nothing?: () => U;
267
282
  }
268
283
 
284
+ declare class PatchRecordsRequest {
285
+ 'recordIds': Array<string>;
286
+ 'jsonPath': JsonPatch;
287
+ }
288
+
289
+ declare class PutRecordsAspectRequest {
290
+ 'recordIds': Array<string>;
291
+ 'data': JsObject;
292
+ }
293
+
269
294
  /**
270
295
  * A record in the registry, usually including data for one or more aspects, unique for a tenant.
271
296
  */
@@ -373,8 +398,9 @@ declare class RecordAspectsApi {
373
398
  * @param aspect The record aspect to save.
374
399
  * @param xMagdaSession Magda internal session id
375
400
  * @param xMagdaTenantId 0
401
+ * @param merge Whether merge the supplied aspect data to existing aspect data or replace it
376
402
  */
377
- putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number): Promise<{
403
+ putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number, merge?: boolean): Promise<{
378
404
  response: http.IncomingMessage;
379
405
  body: any;
380
406
  }>;
@@ -453,6 +479,18 @@ declare class RecordsApi {
453
479
  response: http.IncomingMessage;
454
480
  body: DeleteResult;
455
481
  }>;
482
+ /**
483
+ * Remove items from records&#39; aspect data
484
+ * Remove items from records&#39; aspect data
485
+ * @param xMagdaTenantId 0
486
+ * @param aspectId ID of the aspect to update.
487
+ * @param requestData An json object has key &#39;recordIds&#39;, &#39;jsonPath&#39;, &#39;items&#39;
488
+ * @param xMagdaSession Magda internal session id
489
+ */
490
+ deleteRecordsAspectArrayItems(xMagdaTenantId: number, aspectId: string, requestData: DeleteRecordsAspectArrayItemsRequest, xMagdaSession: string): Promise<{
491
+ response: http.IncomingMessage;
492
+ body: Array<any>;
493
+ }>;
456
494
  /**
457
495
  * Get a list of all records
458
496
  *
@@ -552,7 +590,7 @@ declare class RecordsApi {
552
590
  * Modify a record by applying a JSON Patch
553
591
  * The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
554
592
  * @param xMagdaTenantId 0
555
- * @param id ID of the aspect to be saved.
593
+ * @param id ID of the record to be pacthed.
556
594
  * @param recordPatch The RFC 6902 patch to apply to the aspect.
557
595
  * @param xMagdaSession Magda internal session id
558
596
  */
@@ -560,6 +598,17 @@ declare class RecordsApi {
560
598
  response: http.IncomingMessage;
561
599
  body: Record_2;
562
600
  }>;
601
+ /**
602
+ * Modify a list of records by applying the same JSON Patch
603
+ * The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
604
+ * @param xMagdaTenantId 0
605
+ * @param requestData An json object has key &#39;recordIds&#39; &amp; &#39;jsonPath&#39;
606
+ * @param xMagdaSession Magda internal session id
607
+ */
608
+ patchRecords(xMagdaTenantId: number, requestData: PatchRecordsRequest, xMagdaSession: string): Promise<{
609
+ response: http.IncomingMessage;
610
+ body: Array<any>;
611
+ }>;
563
612
  /**
564
613
  * Modify a record by ID
565
614
  * Modifies a record. Aspects included in the request are created or updated, but missing aspects are not removed.
@@ -572,6 +621,19 @@ declare class RecordsApi {
572
621
  response: http.IncomingMessage;
573
622
  body: Record_2;
574
623
  }>;
624
+ /**
625
+ * Modify a list of records&#39;s aspect with same new data
626
+ * Modify a list of records&#39;s aspect with same new data
627
+ * @param xMagdaTenantId 0
628
+ * @param aspectId ID of the aspect to update.
629
+ * @param requestData An json object has key &#39;recordIds&#39; &amp; &#39;data&#39;
630
+ * @param xMagdaSession Magda internal session id
631
+ * @param merge Whether merge the supplied aspect data to existing aspect data or replace it
632
+ */
633
+ putRecordsAspect(xMagdaTenantId: number, aspectId: string, requestData: PutRecordsAspectRequest, xMagdaSession: string, merge?: boolean): Promise<{
634
+ response: http.IncomingMessage;
635
+ body: Array<any>;
636
+ }>;
575
637
  /**
576
638
  * Trim by source tag
577
639
  * Trims records with the provided source that DON&#39;T have the supplied source tag
@@ -631,12 +693,13 @@ declare class RegistryClient {
631
693
  protected jwt: string | undefined;
632
694
  constructor({ baseUrl, maxRetries, secondsBetweenRetries, tenantId }: RegistryOptions);
633
695
  getRecordUrl(id: string): string;
634
- getAspectDefinitions(): Promise<AspectDefinition[] | Error>;
696
+ getAspectDefinitions(): Promise<AspectDefinition[] | ServerError>;
635
697
  getAspectDefinition(aspectId: string, jwtToken?: string): Promise<AspectDefinition>;
636
- getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | Error>;
698
+ getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | ServerError>;
699
+ getRecordAspect(id: string, aspectId: string): Promise<any | ServerError>;
637
700
  getRecordInFull(id: string): Promise<Record_2>;
638
- 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>;
639
- getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | Error>;
701
+ 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>;
702
+ getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | ServerError>;
640
703
  }
641
704
 
642
705
  declare class RegistryEvent {
@@ -655,6 +718,16 @@ declare interface RegistryOptions {
655
718
  tenantId: number;
656
719
  }
657
720
 
721
+ declare class ServerError extends Error {
722
+ statusCode: number;
723
+ constructor(message?: string, statusCode?: number);
724
+ toData(): {
725
+ isError: boolean;
726
+ errorCode: number;
727
+ errorMessage: string;
728
+ };
729
+ }
730
+
658
731
  declare class WebHook {
659
732
  'id': string;
660
733
  'name': string;