@magda/minion-sdk 2.0.0-alpha.4 → 2.0.0-alpha.7
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 +107 -30
- package/dist/index.js +965 -691
- 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 |
|
|
99
|
-
postHook(hook: WebHook): Promise<WebHook |
|
|
100
|
-
putHook(hook: WebHook): Promise<WebHook |
|
|
101
|
-
getHook(hookId: string): Promise<Maybe<WebHook> |
|
|
102
|
-
getHooks(): Promise<WebHook[] |
|
|
103
|
-
resumeHook(webhookId: string, succeeded?: boolean, lastEventIdReceived?: string, active?: boolean): Promise<WebHookAcknowledgementResponse |
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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 {
|
|
@@ -117,19 +122,25 @@ export declare interface AuthorizedRegistryOptions extends RegistryOptions {
|
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
* Builds an argv object that will accept command line arguments used by all common argv minions.
|
|
126
|
+
*
|
|
127
|
+
* @param id
|
|
128
|
+
* @param defaultPort
|
|
129
|
+
* @param defaultInternalUrl
|
|
130
|
+
* @param additions
|
|
131
|
+
*/
|
|
127
132
|
export declare function commonYargs<T extends MinionArguments = MinionArguments>(defaultPort: number, defaultInternalUrl: string, additions?: (a: yargs.Argv<MinionArguments>) => yargs.Argv<T>): T;
|
|
128
133
|
|
|
129
134
|
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
|
|
|
@@ -230,7 +245,8 @@ export declare type MinionArguments = {
|
|
|
230
245
|
registryUrl: string;
|
|
231
246
|
enableMultiTenant: boolean;
|
|
232
247
|
tenantUrl: string;
|
|
233
|
-
retries: string | number;
|
|
248
|
+
retries: string | number;
|
|
249
|
+
crawlerRecordFetchNumber?: string | number;};
|
|
234
250
|
|
|
235
251
|
export declare interface MinionOptions {
|
|
236
252
|
argv: MinionArguments;
|
|
@@ -266,6 +282,16 @@ declare interface OptionalMaybePatterns<T, U> {
|
|
|
266
282
|
nothing?: () => U;
|
|
267
283
|
}
|
|
268
284
|
|
|
285
|
+
declare class PatchRecordsRequest {
|
|
286
|
+
'recordIds': Array<string>;
|
|
287
|
+
'jsonPath': JsonPatch;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
declare class PutRecordsAspectRequest {
|
|
291
|
+
'recordIds': Array<string>;
|
|
292
|
+
'data': JsObject;
|
|
293
|
+
}
|
|
294
|
+
|
|
269
295
|
/**
|
|
270
296
|
* A record in the registry, usually including data for one or more aspects, unique for a tenant.
|
|
271
297
|
*/
|
|
@@ -373,8 +399,9 @@ declare class RecordAspectsApi {
|
|
|
373
399
|
* @param aspect The record aspect to save.
|
|
374
400
|
* @param xMagdaSession Magda internal session id
|
|
375
401
|
* @param xMagdaTenantId 0
|
|
402
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
376
403
|
*/
|
|
377
|
-
putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number): Promise<{
|
|
404
|
+
putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number, merge?: boolean): Promise<{
|
|
378
405
|
response: http.IncomingMessage;
|
|
379
406
|
body: any;
|
|
380
407
|
}>;
|
|
@@ -402,8 +429,9 @@ declare class RecordHistoryApi {
|
|
|
402
429
|
* @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.
|
|
403
430
|
* @param aspect The aspects for which to included in event history, specified as multiple occurrences of this query parameter.
|
|
404
431
|
* @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.
|
|
432
|
+
* @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.
|
|
405
433
|
*/
|
|
406
|
-
history(xMagdaTenantId: number, recordId: string, xMagdaSession: string, pageToken?: string, start?: number, limit?: number, aspect?: Array<string>, dereference?: boolean): Promise<{
|
|
434
|
+
history(xMagdaTenantId: number, recordId: string, xMagdaSession: string, pageToken?: string, start?: number, limit?: number, aspect?: Array<string>, dereference?: boolean, reversePageTokenOrder?: boolean): Promise<{
|
|
407
435
|
response: http.IncomingMessage;
|
|
408
436
|
body: EventsPage;
|
|
409
437
|
}>;
|
|
@@ -453,6 +481,18 @@ declare class RecordsApi {
|
|
|
453
481
|
response: http.IncomingMessage;
|
|
454
482
|
body: DeleteResult;
|
|
455
483
|
}>;
|
|
484
|
+
/**
|
|
485
|
+
* Remove items from records' aspect data
|
|
486
|
+
* Remove items from records' aspect data
|
|
487
|
+
* @param xMagdaTenantId 0
|
|
488
|
+
* @param aspectId ID of the aspect to update.
|
|
489
|
+
* @param requestData An json object has key 'recordIds', 'jsonPath', 'items'
|
|
490
|
+
* @param xMagdaSession Magda internal session id
|
|
491
|
+
*/
|
|
492
|
+
deleteRecordsAspectArrayItems(xMagdaTenantId: number, aspectId: string, requestData: DeleteRecordsAspectArrayItemsRequest, xMagdaSession: string): Promise<{
|
|
493
|
+
response: http.IncomingMessage;
|
|
494
|
+
body: Array<any>;
|
|
495
|
+
}>;
|
|
456
496
|
/**
|
|
457
497
|
* Get a list of all records
|
|
458
498
|
*
|
|
@@ -468,9 +508,10 @@ declare class RecordsApi {
|
|
|
468
508
|
* @param orderBy Specify the field to sort the result. Aspect field can be supported in a format like aspectId.path.to.field
|
|
469
509
|
* @param orderByDir Specify the order by direction. Either `asc` or `desc`
|
|
470
510
|
* @param orderNullFirst Specify whether nulls appear before (`true`) or after (`false`) non-null values in the sort ordering.
|
|
511
|
+
* @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.
|
|
471
512
|
* @param xMagdaSession Magda internal session id
|
|
472
513
|
*/
|
|
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, xMagdaSession?: string): Promise<{
|
|
514
|
+
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<{
|
|
474
515
|
response: http.IncomingMessage;
|
|
475
516
|
body: Array<Record_2>;
|
|
476
517
|
}>;
|
|
@@ -481,9 +522,10 @@ declare class RecordsApi {
|
|
|
481
522
|
* @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.
|
|
482
523
|
* @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.
|
|
483
524
|
* @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.
|
|
525
|
+
* @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.
|
|
484
526
|
* @param xMagdaSession Magda internal session id
|
|
485
527
|
*/
|
|
486
|
-
getAllSummary(xMagdaTenantId: number, pageToken?: string, start?: number, limit?: number, xMagdaSession?: string): Promise<{
|
|
528
|
+
getAllSummary(xMagdaTenantId: number, pageToken?: string, start?: number, limit?: number, reversePageTokenOrder?: boolean, xMagdaSession?: string): Promise<{
|
|
487
529
|
response: http.IncomingMessage;
|
|
488
530
|
body: Array<RecordSummary>;
|
|
489
531
|
}>;
|
|
@@ -552,7 +594,7 @@ declare class RecordsApi {
|
|
|
552
594
|
* Modify a record by applying a JSON Patch
|
|
553
595
|
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
554
596
|
* @param xMagdaTenantId 0
|
|
555
|
-
* @param id ID of the
|
|
597
|
+
* @param id ID of the record to be pacthed.
|
|
556
598
|
* @param recordPatch The RFC 6902 patch to apply to the aspect.
|
|
557
599
|
* @param xMagdaSession Magda internal session id
|
|
558
600
|
*/
|
|
@@ -560,6 +602,17 @@ declare class RecordsApi {
|
|
|
560
602
|
response: http.IncomingMessage;
|
|
561
603
|
body: Record_2;
|
|
562
604
|
}>;
|
|
605
|
+
/**
|
|
606
|
+
* Modify a list of records by applying the same JSON Patch
|
|
607
|
+
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
608
|
+
* @param xMagdaTenantId 0
|
|
609
|
+
* @param requestData An json object has key 'recordIds' & 'jsonPath'
|
|
610
|
+
* @param xMagdaSession Magda internal session id
|
|
611
|
+
*/
|
|
612
|
+
patchRecords(xMagdaTenantId: number, requestData: PatchRecordsRequest, xMagdaSession: string): Promise<{
|
|
613
|
+
response: http.IncomingMessage;
|
|
614
|
+
body: Array<any>;
|
|
615
|
+
}>;
|
|
563
616
|
/**
|
|
564
617
|
* Modify a record by ID
|
|
565
618
|
* Modifies a record. Aspects included in the request are created or updated, but missing aspects are not removed.
|
|
@@ -572,6 +625,19 @@ declare class RecordsApi {
|
|
|
572
625
|
response: http.IncomingMessage;
|
|
573
626
|
body: Record_2;
|
|
574
627
|
}>;
|
|
628
|
+
/**
|
|
629
|
+
* Modify a list of records's aspect with same new data
|
|
630
|
+
* Modify a list of records's aspect with same new data
|
|
631
|
+
* @param xMagdaTenantId 0
|
|
632
|
+
* @param aspectId ID of the aspect to update.
|
|
633
|
+
* @param requestData An json object has key 'recordIds' & 'data'
|
|
634
|
+
* @param xMagdaSession Magda internal session id
|
|
635
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
636
|
+
*/
|
|
637
|
+
putRecordsAspect(xMagdaTenantId: number, aspectId: string, requestData: PutRecordsAspectRequest, xMagdaSession: string, merge?: boolean): Promise<{
|
|
638
|
+
response: http.IncomingMessage;
|
|
639
|
+
body: Array<any>;
|
|
640
|
+
}>;
|
|
575
641
|
/**
|
|
576
642
|
* Trim by source tag
|
|
577
643
|
* Trims records with the provided source that DON'T have the supplied source tag
|
|
@@ -631,12 +697,13 @@ declare class RegistryClient {
|
|
|
631
697
|
protected jwt: string | undefined;
|
|
632
698
|
constructor({ baseUrl, maxRetries, secondsBetweenRetries, tenantId }: RegistryOptions);
|
|
633
699
|
getRecordUrl(id: string): string;
|
|
634
|
-
getAspectDefinitions(): Promise<AspectDefinition[] |
|
|
700
|
+
getAspectDefinitions(): Promise<AspectDefinition[] | ServerError>;
|
|
635
701
|
getAspectDefinition(aspectId: string, jwtToken?: string): Promise<AspectDefinition>;
|
|
636
|
-
getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 |
|
|
702
|
+
getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | ServerError>;
|
|
703
|
+
getRecordAspect(id: string, aspectId: string): Promise<any | ServerError>;
|
|
637
704
|
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> |
|
|
639
|
-
getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] |
|
|
705
|
+
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>;
|
|
706
|
+
getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | ServerError>;
|
|
640
707
|
}
|
|
641
708
|
|
|
642
709
|
declare class RegistryEvent {
|
|
@@ -655,6 +722,16 @@ declare interface RegistryOptions {
|
|
|
655
722
|
tenantId: number;
|
|
656
723
|
}
|
|
657
724
|
|
|
725
|
+
declare class ServerError extends Error {
|
|
726
|
+
statusCode: number;
|
|
727
|
+
constructor(message?: string, statusCode?: number);
|
|
728
|
+
toData(): {
|
|
729
|
+
isError: boolean;
|
|
730
|
+
errorCode: number;
|
|
731
|
+
errorMessage: string;
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
|
|
658
735
|
declare class WebHook {
|
|
659
736
|
'id': string;
|
|
660
737
|
'name': string;
|