@magda/connector-sdk 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 +816 -542
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -119,19 +119,24 @@ export declare class AuthorizedRegistryClient extends RegistryClient {
|
|
|
119
119
|
protected jwt: string;
|
|
120
120
|
constructor(options: AuthorizedRegistryOptions);
|
|
121
121
|
getAspectDefinition(aspectId: string): Promise<AspectDefinition>;
|
|
122
|
-
putAspectDefinition(aspectDefinition: AspectDefinition, tenantId?: number): Promise<AspectDefinition |
|
|
123
|
-
postHook(hook: WebHook): Promise<WebHook |
|
|
124
|
-
putHook(hook: WebHook): Promise<WebHook |
|
|
125
|
-
getHook(hookId: string): Promise<Maybe<WebHook> |
|
|
126
|
-
getHooks(): Promise<WebHook[] |
|
|
127
|
-
resumeHook(webhookId: string, succeeded?: boolean, lastEventIdReceived?: string, active?: boolean): Promise<WebHookAcknowledgementResponse |
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
putAspectDefinition(aspectDefinition: AspectDefinition, tenantId?: number): Promise<AspectDefinition | ServerError>;
|
|
123
|
+
postHook(hook: WebHook): Promise<WebHook | ServerError>;
|
|
124
|
+
putHook(hook: WebHook): Promise<WebHook | ServerError>;
|
|
125
|
+
getHook(hookId: string): Promise<Maybe<WebHook> | ServerError>;
|
|
126
|
+
getHooks(): Promise<WebHook[] | ServerError>;
|
|
127
|
+
resumeHook(webhookId: string, succeeded?: boolean, lastEventIdReceived?: string, active?: boolean): Promise<WebHookAcknowledgementResponse | ServerError>;
|
|
128
|
+
creatRecord(record: Record_2, tenantId?: number): Promise<Record_2 | ServerError>;
|
|
129
|
+
putRecord(record: Record_2, tenantId?: number): Promise<Record_2 | ServerError>;
|
|
130
|
+
patchRecord(recordId: string, recordPatch: Operation[], tenantId?: number): Promise<Record_2 | ServerError>;
|
|
131
|
+
patchRecords(recordIds: string[], recordPatch: Operation[], tenantId?: number): Promise<string[] | ServerError>;
|
|
132
|
+
putRecordAspect(recordId: string, aspectId: string, aspect: any, merge?: boolean, tenantId?: number): Promise<any | ServerError>;
|
|
133
|
+
putRecordsAspect(recordIds: string[], aspectId: string, aspectData: any, merge?: boolean, tenantId?: number): Promise<string[] | ServerError>;
|
|
134
|
+
deleteRecordsAspectArrayItems(recordIds: string[], aspectId: string, jsonPath: string, items: (string | number)[], tenantId?: number): Promise<string[] | ServerError>;
|
|
135
|
+
deleteRecordAspect(recordId: string, aspectId: string, tenantId?: number): Promise<DeleteResult | ServerError>;
|
|
136
|
+
patchRecordAspect(recordId: string, aspectId: string, aspectPatch: Operation[], tenantId?: number): Promise<Record_2 | ServerError>;
|
|
137
|
+
deleteBySource(sourceTagToPreserve: string, sourceId: string, tenantId?: number): Promise<MultipleDeleteResult | "Processing" | ServerError>;
|
|
138
|
+
deleteRecord(id: string, tenantId?: number): Promise<DeleteResult | ServerError>;
|
|
139
|
+
getRecordHistory(id: string, pageToken?: string, start?: number, limit?: number): Promise<EventsPage | ServerError>;
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
export declare interface AuthorizedRegistryOptions extends RegistryOptions {
|
|
@@ -334,6 +339,12 @@ declare interface CreateAsyncPage<T> {
|
|
|
334
339
|
(): Promise<AsyncPage<T>>;
|
|
335
340
|
}
|
|
336
341
|
|
|
342
|
+
declare class DeleteRecordsAspectArrayItemsRequest {
|
|
343
|
+
'recordIds': Array<string>;
|
|
344
|
+
'jsonPath': string;
|
|
345
|
+
'items': Array<JsValue>;
|
|
346
|
+
}
|
|
347
|
+
|
|
337
348
|
declare class DeleteResult {
|
|
338
349
|
'deleted': boolean;
|
|
339
350
|
}
|
|
@@ -477,6 +488,10 @@ export declare interface JsonConnectorRunInteractiveOptions {
|
|
|
477
488
|
transformerOptions: any;
|
|
478
489
|
}
|
|
479
490
|
|
|
491
|
+
declare class JsonPatch {
|
|
492
|
+
'ops': Array<Operation>;
|
|
493
|
+
}
|
|
494
|
+
|
|
480
495
|
/**
|
|
481
496
|
* A base class for transformers for most any JSON-based catalog source.
|
|
482
497
|
* A transformer takes source data and transforms it to registry records and aspects.
|
|
@@ -590,6 +605,16 @@ declare interface OptionalMaybePatterns<T, U> {
|
|
|
590
605
|
nothing?: () => U;
|
|
591
606
|
}
|
|
592
607
|
|
|
608
|
+
declare class PatchRecordsRequest {
|
|
609
|
+
'recordIds': Array<string>;
|
|
610
|
+
'jsonPath': JsonPatch;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
declare class PutRecordsAspectRequest {
|
|
614
|
+
'recordIds': Array<string>;
|
|
615
|
+
'data': JsObject;
|
|
616
|
+
}
|
|
617
|
+
|
|
593
618
|
/**
|
|
594
619
|
* A record in the registry, usually including data for one or more aspects, unique for a tenant.
|
|
595
620
|
*/
|
|
@@ -697,8 +722,9 @@ declare class RecordAspectsApi {
|
|
|
697
722
|
* @param aspect The record aspect to save.
|
|
698
723
|
* @param xMagdaSession Magda internal session id
|
|
699
724
|
* @param xMagdaTenantId 0
|
|
725
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
700
726
|
*/
|
|
701
|
-
putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number): Promise<{
|
|
727
|
+
putById(recordId: string, aspectId: string, aspect: any, xMagdaSession: string, xMagdaTenantId: number, merge?: boolean): Promise<{
|
|
702
728
|
response: http.IncomingMessage;
|
|
703
729
|
body: any;
|
|
704
730
|
}>;
|
|
@@ -733,8 +759,9 @@ declare class RecordHistoryApi {
|
|
|
733
759
|
* @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.
|
|
734
760
|
* @param aspect The aspects for which to included in event history, specified as multiple occurrences of this query parameter.
|
|
735
761
|
* @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.
|
|
762
|
+
* @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.
|
|
736
763
|
*/
|
|
737
|
-
history(xMagdaTenantId: number, recordId: string, xMagdaSession: string, pageToken?: string, start?: number, limit?: number, aspect?: Array<string>, dereference?: boolean): Promise<{
|
|
764
|
+
history(xMagdaTenantId: number, recordId: string, xMagdaSession: string, pageToken?: string, start?: number, limit?: number, aspect?: Array<string>, dereference?: boolean, reversePageTokenOrder?: boolean): Promise<{
|
|
738
765
|
response: http.IncomingMessage;
|
|
739
766
|
body: EventsPage;
|
|
740
767
|
}>;
|
|
@@ -784,6 +811,18 @@ declare class RecordsApi {
|
|
|
784
811
|
response: http.IncomingMessage;
|
|
785
812
|
body: DeleteResult;
|
|
786
813
|
}>;
|
|
814
|
+
/**
|
|
815
|
+
* Remove items from records' aspect data
|
|
816
|
+
* Remove items from records' aspect data
|
|
817
|
+
* @param xMagdaTenantId 0
|
|
818
|
+
* @param aspectId ID of the aspect to update.
|
|
819
|
+
* @param requestData An json object has key 'recordIds', 'jsonPath', 'items'
|
|
820
|
+
* @param xMagdaSession Magda internal session id
|
|
821
|
+
*/
|
|
822
|
+
deleteRecordsAspectArrayItems(xMagdaTenantId: number, aspectId: string, requestData: DeleteRecordsAspectArrayItemsRequest, xMagdaSession: string): Promise<{
|
|
823
|
+
response: http.IncomingMessage;
|
|
824
|
+
body: Array<any>;
|
|
825
|
+
}>;
|
|
787
826
|
/**
|
|
788
827
|
* Get a list of all records
|
|
789
828
|
*
|
|
@@ -799,9 +838,10 @@ declare class RecordsApi {
|
|
|
799
838
|
* @param orderBy Specify the field to sort the result. Aspect field can be supported in a format like aspectId.path.to.field
|
|
800
839
|
* @param orderByDir Specify the order by direction. Either `asc` or `desc`
|
|
801
840
|
* @param orderNullFirst Specify whether nulls appear before (`true`) or after (`false`) non-null values in the sort ordering.
|
|
841
|
+
* @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.
|
|
802
842
|
* @param xMagdaSession Magda internal session id
|
|
803
843
|
*/
|
|
804
|
-
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<{
|
|
844
|
+
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<{
|
|
805
845
|
response: http.IncomingMessage;
|
|
806
846
|
body: Array<Record_2>;
|
|
807
847
|
}>;
|
|
@@ -812,9 +852,10 @@ declare class RecordsApi {
|
|
|
812
852
|
* @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.
|
|
813
853
|
* @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.
|
|
814
854
|
* @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.
|
|
855
|
+
* @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.
|
|
815
856
|
* @param xMagdaSession Magda internal session id
|
|
816
857
|
*/
|
|
817
|
-
getAllSummary(xMagdaTenantId: number, pageToken?: string, start?: number, limit?: number, xMagdaSession?: string): Promise<{
|
|
858
|
+
getAllSummary(xMagdaTenantId: number, pageToken?: string, start?: number, limit?: number, reversePageTokenOrder?: boolean, xMagdaSession?: string): Promise<{
|
|
818
859
|
response: http.IncomingMessage;
|
|
819
860
|
body: Array<RecordSummary>;
|
|
820
861
|
}>;
|
|
@@ -883,7 +924,7 @@ declare class RecordsApi {
|
|
|
883
924
|
* Modify a record by applying a JSON Patch
|
|
884
925
|
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
885
926
|
* @param xMagdaTenantId 0
|
|
886
|
-
* @param id ID of the
|
|
927
|
+
* @param id ID of the record to be pacthed.
|
|
887
928
|
* @param recordPatch The RFC 6902 patch to apply to the aspect.
|
|
888
929
|
* @param xMagdaSession Magda internal session id
|
|
889
930
|
*/
|
|
@@ -891,6 +932,17 @@ declare class RecordsApi {
|
|
|
891
932
|
response: http.IncomingMessage;
|
|
892
933
|
body: Record_2;
|
|
893
934
|
}>;
|
|
935
|
+
/**
|
|
936
|
+
* Modify a list of records by applying the same JSON Patch
|
|
937
|
+
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
938
|
+
* @param xMagdaTenantId 0
|
|
939
|
+
* @param requestData An json object has key 'recordIds' & 'jsonPath'
|
|
940
|
+
* @param xMagdaSession Magda internal session id
|
|
941
|
+
*/
|
|
942
|
+
patchRecords(xMagdaTenantId: number, requestData: PatchRecordsRequest, xMagdaSession: string): Promise<{
|
|
943
|
+
response: http.IncomingMessage;
|
|
944
|
+
body: Array<any>;
|
|
945
|
+
}>;
|
|
894
946
|
/**
|
|
895
947
|
* Modify a record by ID
|
|
896
948
|
* Modifies a record. Aspects included in the request are created or updated, but missing aspects are not removed.
|
|
@@ -903,6 +955,19 @@ declare class RecordsApi {
|
|
|
903
955
|
response: http.IncomingMessage;
|
|
904
956
|
body: Record_2;
|
|
905
957
|
}>;
|
|
958
|
+
/**
|
|
959
|
+
* Modify a list of records's aspect with same new data
|
|
960
|
+
* Modify a list of records's aspect with same new data
|
|
961
|
+
* @param xMagdaTenantId 0
|
|
962
|
+
* @param aspectId ID of the aspect to update.
|
|
963
|
+
* @param requestData An json object has key 'recordIds' & 'data'
|
|
964
|
+
* @param xMagdaSession Magda internal session id
|
|
965
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
966
|
+
*/
|
|
967
|
+
putRecordsAspect(xMagdaTenantId: number, aspectId: string, requestData: PutRecordsAspectRequest, xMagdaSession: string, merge?: boolean): Promise<{
|
|
968
|
+
response: http.IncomingMessage;
|
|
969
|
+
body: Array<any>;
|
|
970
|
+
}>;
|
|
906
971
|
/**
|
|
907
972
|
* Trim by source tag
|
|
908
973
|
* Trims records with the provided source that DON'T have the supplied source tag
|
|
@@ -964,12 +1029,13 @@ declare class RegistryClient {
|
|
|
964
1029
|
protected jwt: string | undefined;
|
|
965
1030
|
constructor({ baseUrl, maxRetries, secondsBetweenRetries, tenantId }: RegistryOptions);
|
|
966
1031
|
getRecordUrl(id: string): string;
|
|
967
|
-
getAspectDefinitions(): Promise<AspectDefinition[] |
|
|
1032
|
+
getAspectDefinitions(): Promise<AspectDefinition[] | ServerError>;
|
|
968
1033
|
getAspectDefinition(aspectId: string, jwtToken?: string): Promise<AspectDefinition>;
|
|
969
|
-
getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 |
|
|
1034
|
+
getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | ServerError>;
|
|
1035
|
+
getRecordAspect(id: string, aspectId: string): Promise<any | ServerError>;
|
|
970
1036
|
getRecordInFull(id: string): Promise<Record_2>;
|
|
971
|
-
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> |
|
|
972
|
-
getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] |
|
|
1037
|
+
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>;
|
|
1038
|
+
getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | ServerError>;
|
|
973
1039
|
}
|
|
974
1040
|
|
|
975
1041
|
declare class RegistryEvent {
|
|
@@ -992,6 +1058,16 @@ declare interface ReportProblem {
|
|
|
992
1058
|
(title: string, message?: string, additionalInfo?: any): void;
|
|
993
1059
|
}
|
|
994
1060
|
|
|
1061
|
+
declare class ServerError extends Error {
|
|
1062
|
+
statusCode: number;
|
|
1063
|
+
constructor(message?: string, statusCode?: number);
|
|
1064
|
+
toData(): {
|
|
1065
|
+
isError: boolean;
|
|
1066
|
+
errorCode: number;
|
|
1067
|
+
errorMessage: string;
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
|
|
995
1071
|
export declare const TenantConsts: any;
|
|
996
1072
|
|
|
997
1073
|
declare class WebHook {
|