@magda/connector-sdk 2.0.0-alpha.4 → 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.
- package/dist/index.d.ts +92 -19
- package/dist/index.js +799 -537
- 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
|
}>;
|
|
@@ -784,6 +810,18 @@ declare class RecordsApi {
|
|
|
784
810
|
response: http.IncomingMessage;
|
|
785
811
|
body: DeleteResult;
|
|
786
812
|
}>;
|
|
813
|
+
/**
|
|
814
|
+
* Remove items from records' aspect data
|
|
815
|
+
* Remove items from records' aspect data
|
|
816
|
+
* @param xMagdaTenantId 0
|
|
817
|
+
* @param aspectId ID of the aspect to update.
|
|
818
|
+
* @param requestData An json object has key 'recordIds', 'jsonPath', 'items'
|
|
819
|
+
* @param xMagdaSession Magda internal session id
|
|
820
|
+
*/
|
|
821
|
+
deleteRecordsAspectArrayItems(xMagdaTenantId: number, aspectId: string, requestData: DeleteRecordsAspectArrayItemsRequest, xMagdaSession: string): Promise<{
|
|
822
|
+
response: http.IncomingMessage;
|
|
823
|
+
body: Array<any>;
|
|
824
|
+
}>;
|
|
787
825
|
/**
|
|
788
826
|
* Get a list of all records
|
|
789
827
|
*
|
|
@@ -883,7 +921,7 @@ declare class RecordsApi {
|
|
|
883
921
|
* Modify a record by applying a JSON Patch
|
|
884
922
|
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
885
923
|
* @param xMagdaTenantId 0
|
|
886
|
-
* @param id ID of the
|
|
924
|
+
* @param id ID of the record to be pacthed.
|
|
887
925
|
* @param recordPatch The RFC 6902 patch to apply to the aspect.
|
|
888
926
|
* @param xMagdaSession Magda internal session id
|
|
889
927
|
*/
|
|
@@ -891,6 +929,17 @@ declare class RecordsApi {
|
|
|
891
929
|
response: http.IncomingMessage;
|
|
892
930
|
body: Record_2;
|
|
893
931
|
}>;
|
|
932
|
+
/**
|
|
933
|
+
* Modify a list of records by applying the same JSON Patch
|
|
934
|
+
* The patch should follow IETF RFC 6902 (https://tools.ietf.org/html/rfc6902).
|
|
935
|
+
* @param xMagdaTenantId 0
|
|
936
|
+
* @param requestData An json object has key 'recordIds' & 'jsonPath'
|
|
937
|
+
* @param xMagdaSession Magda internal session id
|
|
938
|
+
*/
|
|
939
|
+
patchRecords(xMagdaTenantId: number, requestData: PatchRecordsRequest, xMagdaSession: string): Promise<{
|
|
940
|
+
response: http.IncomingMessage;
|
|
941
|
+
body: Array<any>;
|
|
942
|
+
}>;
|
|
894
943
|
/**
|
|
895
944
|
* Modify a record by ID
|
|
896
945
|
* Modifies a record. Aspects included in the request are created or updated, but missing aspects are not removed.
|
|
@@ -903,6 +952,19 @@ declare class RecordsApi {
|
|
|
903
952
|
response: http.IncomingMessage;
|
|
904
953
|
body: Record_2;
|
|
905
954
|
}>;
|
|
955
|
+
/**
|
|
956
|
+
* Modify a list of records's aspect with same new data
|
|
957
|
+
* Modify a list of records's aspect with same new data
|
|
958
|
+
* @param xMagdaTenantId 0
|
|
959
|
+
* @param aspectId ID of the aspect to update.
|
|
960
|
+
* @param requestData An json object has key 'recordIds' & 'data'
|
|
961
|
+
* @param xMagdaSession Magda internal session id
|
|
962
|
+
* @param merge Whether merge the supplied aspect data to existing aspect data or replace it
|
|
963
|
+
*/
|
|
964
|
+
putRecordsAspect(xMagdaTenantId: number, aspectId: string, requestData: PutRecordsAspectRequest, xMagdaSession: string, merge?: boolean): Promise<{
|
|
965
|
+
response: http.IncomingMessage;
|
|
966
|
+
body: Array<any>;
|
|
967
|
+
}>;
|
|
906
968
|
/**
|
|
907
969
|
* Trim by source tag
|
|
908
970
|
* Trims records with the provided source that DON'T have the supplied source tag
|
|
@@ -964,12 +1026,13 @@ declare class RegistryClient {
|
|
|
964
1026
|
protected jwt: string | undefined;
|
|
965
1027
|
constructor({ baseUrl, maxRetries, secondsBetweenRetries, tenantId }: RegistryOptions);
|
|
966
1028
|
getRecordUrl(id: string): string;
|
|
967
|
-
getAspectDefinitions(): Promise<AspectDefinition[] |
|
|
1029
|
+
getAspectDefinitions(): Promise<AspectDefinition[] | ServerError>;
|
|
968
1030
|
getAspectDefinition(aspectId: string, jwtToken?: string): Promise<AspectDefinition>;
|
|
969
|
-
getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 |
|
|
1031
|
+
getRecord(id: string, aspect?: Array<string>, optionalAspect?: Array<string>, dereference?: boolean): Promise<Record_2 | ServerError>;
|
|
1032
|
+
getRecordAspect(id: string, aspectId: string): Promise<any | ServerError>;
|
|
970
1033
|
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[] |
|
|
1034
|
+
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>;
|
|
1035
|
+
getRecordsPageTokens(aspect?: Array<string>, limit?: number): Promise<string[] | ServerError>;
|
|
973
1036
|
}
|
|
974
1037
|
|
|
975
1038
|
declare class RegistryEvent {
|
|
@@ -992,6 +1055,16 @@ declare interface ReportProblem {
|
|
|
992
1055
|
(title: string, message?: string, additionalInfo?: any): void;
|
|
993
1056
|
}
|
|
994
1057
|
|
|
1058
|
+
declare class ServerError extends Error {
|
|
1059
|
+
statusCode: number;
|
|
1060
|
+
constructor(message?: string, statusCode?: number);
|
|
1061
|
+
toData(): {
|
|
1062
|
+
isError: boolean;
|
|
1063
|
+
errorCode: number;
|
|
1064
|
+
errorMessage: string;
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
|
|
995
1068
|
export declare const TenantConsts: any;
|
|
996
1069
|
|
|
997
1070
|
declare class WebHook {
|