@edraj/tsdmart 2.6.2 → 2.7.1

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 (2) hide show
  1. package/dmart.service.ts +48 -16
  2. package/package.json +1 -1
package/dmart.service.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import {AxiosInstance} from "axios";
2
2
  import {
3
- ActionRequest,
4
- ActionResponse,
5
- ApiQueryResponse,
6
- ApiResponse,
7
- ContentType,
8
- headers,
9
- LoginResponse,
10
- ProfileResponse,
11
- QueryRequest,
12
- QueryType,
13
- ResourceType,
14
- ResponseEntry,
15
- SortyType,
16
- Status,
3
+ ActionRequest, ActionRequestRecord,
4
+ ActionResponse,
5
+ ApiQueryResponse,
6
+ ApiResponse,
7
+ ContentType,
8
+ headers,
9
+ LoginResponse,
10
+ ProfileResponse,
11
+ QueryRequest,
12
+ QueryType,
13
+ ResourceType,
14
+ ResponseEntry,
15
+ SortyType,
16
+ Status,
17
17
  } from "./dmart.model";
18
18
 
19
19
 
@@ -100,7 +100,7 @@ export class Dmart {
100
100
  }
101
101
  }
102
102
 
103
- public static async create_user(request: any) {
103
+ public static async create_user(request: ActionRequestRecord) {
104
104
  try {
105
105
  const { data } = await Dmart.axiosDmartInstance.post<ActionResponse>(
106
106
  `user/create`,
@@ -113,7 +113,7 @@ export class Dmart {
113
113
  }
114
114
  }
115
115
 
116
- public static async update_user(request: any) {
116
+ public static async update_user(request: ActionRequestRecord) {
117
117
  try {
118
118
  const { data } = await Dmart.axiosDmartInstance.post<ActionResponse>(
119
119
  `user/profile`,
@@ -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>(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edraj/tsdmart",
3
- "version": "2.6.2",
3
+ "version": "2.7.1",
4
4
  "description": "A TypeScript implementation of the Dmart that depends on axios.",
5
5
  "author": "Kefah T. Issa",
6
6
  "email": "kefah.issa@gmail.com",