@edraj/tsdmart 2.3.0 → 2.4.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/client.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import axios, { AxiosInstance, CreateAxiosDefaults } from "axios";
2
2
  import { Config } from "./config";
3
3
  import {
4
- ActionRequest,
5
- ClientError,
6
- ContentType,
7
- QueryRequest,
8
- ResourceType,
4
+ ActionRequest,
5
+ ClientError,
6
+ ContentType,
7
+ QueryRequest,
8
+ ResourceType,
9
9
  } from "./dmart.model";
10
10
  import { get_profile, login, logout } from "./services/auth";
11
11
  import { query, retrieve_entry } from "./services/query";
@@ -105,8 +105,10 @@ export class DmartClient {
105
105
  spaceName: string,
106
106
  schemaShortname: string,
107
107
  subpath: string,
108
- record: any
108
+ record: any,
109
+ resourceType?: string,
110
+ workflowShortname?: string
109
111
  ) {
110
- return submit(this.client, spaceName, schemaShortname, subpath, record);
112
+ return submit(this.client, spaceName, schemaShortname, subpath, record, resourceType, workflowShortname);
111
113
  }
112
114
  }
package/dmart.service.ts CHANGED
@@ -358,54 +358,18 @@ export class Dmart {
358
358
  }
359
359
 
360
360
  // TODO: update to enums
361
- public static async get_attachment_content(
362
- resource_type: string,
363
- space_name: string,
364
- subpath: string,
365
- shortname: string,
366
- scope: string = "managed"
367
- ) {
368
- try {
369
- const { data } = await axios.get<any>(
370
- `${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}`,
371
- { headers }
372
- );
373
- return data;
374
- } catch (error: any) {
375
- throw error;
376
- }
377
- }
378
-
379
361
  public static async get_payload(
380
362
  resource_type: string,
381
363
  space_name: string,
382
364
  subpath: string,
383
365
  shortname: string,
366
+ schemaShortname: string = "",
384
367
  ext: string = ".json",
385
368
  scope: string = "managed"
386
369
  ) {
387
370
  try {
388
371
  const { data } = await axios.get<any>(
389
- `${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
390
- { headers }
391
- );
392
- return data;
393
- } catch (error: any) {
394
- throw error;
395
- }
396
- }
397
-
398
- public static async get_payload_content(
399
- resource_type: string,
400
- space_name: string,
401
- subpath: string,
402
- shortname: string,
403
- ext: string = ".json",
404
- scope: string = "managed"
405
- ) {
406
- try {
407
- const { data } = await axios.get<any>(
408
- `${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
372
+ `${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}${schemaShortname}${ext}`,
409
373
  { headers }
410
374
  );
411
375
  return data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edraj/tsdmart",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
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",
@@ -12,18 +12,43 @@ export const request = async (
12
12
  return res?.data;
13
13
  };
14
14
 
15
- // this is useless
15
+ // export const submit = async (
16
+ // client: AxiosInstance,
17
+ // spaceName: string,
18
+ // schemaShortname: string,
19
+ // subpath: string,
20
+ // record: any
21
+ // ) => {
22
+ // const { data } = await client.post(
23
+ // `public/submit/${spaceName}/${schemaShortname}/${subpath}`,
24
+ // record,
25
+ // { headers: Config.headers }
26
+ // );
27
+ // return data;
28
+ // };
29
+
30
+
16
31
  export const submit = async (
17
32
  client: AxiosInstance,
18
33
  spaceName: string,
19
34
  schemaShortname: string,
20
35
  subpath: string,
21
- record: any
36
+ record: any,
37
+ resourceType?: string,
38
+ workflowShortname?: string,
22
39
  ) => {
40
+ let url = `public/submit/${spaceName}`;
41
+ if (resourceType) {
42
+ url += `/${resourceType}`;
43
+ }
44
+ if (workflowShortname) {
45
+ url += `/${workflowShortname}`;
46
+ }
47
+ url += `/${schemaShortname}/${subpath}`;
23
48
  const { data } = await client.post(
24
- `public/submit/${spaceName}/${schemaShortname}/${subpath}`,
49
+ url,
25
50
  record,
26
51
  { headers: Config.headers }
27
52
  );
28
53
  return data;
29
- };
54
+ };