@edraj/tsdmart 2.6.1 → 2.7.0
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/dmart.service.ts +35 -4
- package/package.json +1 -1
package/dmart.service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
2
|
import {
|
|
3
3
|
ActionRequest,
|
|
4
4
|
ActionResponse,
|
|
@@ -196,6 +196,38 @@ export class Dmart {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
public static async resources_from_csv(
|
|
200
|
+
space_name: string,
|
|
201
|
+
subpath: string,
|
|
202
|
+
resourceType: ResourceType,
|
|
203
|
+
schema: string,
|
|
204
|
+
payload: File,
|
|
205
|
+
){
|
|
206
|
+
try {
|
|
207
|
+
let csvUrl = `/managed/resources_from_csv/${resourceType}/${space_name}/${subpath}`;
|
|
208
|
+
|
|
209
|
+
if(schema){
|
|
210
|
+
csvUrl += `/${schema}`;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let formdata = new FormData();
|
|
214
|
+
formdata.append("resources_file", payload);
|
|
215
|
+
|
|
216
|
+
const headers = {"Content-Type": "multipart/form-data"};
|
|
217
|
+
|
|
218
|
+
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
219
|
+
csvUrl,
|
|
220
|
+
formdata,
|
|
221
|
+
{headers}
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
return data;
|
|
225
|
+
} catch (error) {
|
|
226
|
+
return error;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
199
231
|
public static async space(action: ActionRequest): Promise<ActionResponse> {
|
|
200
232
|
try {
|
|
201
233
|
const { data } = await Dmart.axiosDmartInstance.post<ActionResponse>(
|
|
@@ -299,9 +331,8 @@ export class Dmart {
|
|
|
299
331
|
filter_data_assets?: string[]
|
|
300
332
|
) {
|
|
301
333
|
try {
|
|
302
|
-
const url = `managed/data-asset`;
|
|
303
334
|
const { data } = await Dmart.axiosDmartInstance.post(
|
|
304
|
-
|
|
335
|
+
'managed/data-asset',
|
|
305
336
|
{
|
|
306
337
|
space_name: spaceName,
|
|
307
338
|
resource_type: resourceType,
|
|
@@ -357,7 +388,7 @@ export class Dmart {
|
|
|
357
388
|
ext: string | null = null,
|
|
358
389
|
scope: string = "managed"
|
|
359
390
|
) {
|
|
360
|
-
return `${
|
|
391
|
+
return `${Dmart.axiosDmartInstance.defaults.baseURL}/${scope}/payload/${resource_type}/${space_name}/${subpath.replace(
|
|
361
392
|
/\/+$/,
|
|
362
393
|
""
|
|
363
394
|
)}/${parent_shortname}/${shortname}${ext === null ? "" : `.${ext}`}`;
|