@edraj/tsdmart 1.0.5 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +2 -1
  2. package/index.ts +28 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A TypeScript implementation of the Dmart that depends on axios.
4
4
 
5
- ## APIs
5
+ ## APIs
6
6
 
7
7
  * `login(shortname: string, password: string) -> Promise<ApiResponse>` - Performs a login action.
8
8
  * `logout() -> Promise<ApiResponse>` - Performs a logout action.
@@ -25,5 +25,6 @@ A TypeScript implementation of the Dmart that depends on axios.
25
25
  * `get_payload(resource_type: string, space_name: string, subpath: string, shortname: string, ext: string = ".json") -> Promise<any>` - Gets the payload of a resource.
26
26
  * `get_payload_content(resource_type: string, space_name: string, subpath: string, shortname: string, ext: string = ".json") -> Promise<any>` - Gets the content of a payload.
27
27
  * `progress_ticket(space_name: string, subpath: string, shortname: string, action: string, resolution?: string, comment?: string) -> Promise<ApiQueryResponse & { attributes: { folders_report: Object } }>` - Performs a progress ticket action.
28
+ * `submit(spaceName: string, schemaShortname: string, subpath: string, record: any) -> Promise<any>` - Submits a record (log/feedback) to Dmart.
28
29
  * `get_manifest() -> Promise<any>` - Gets the manifest of the current instance.
29
30
  * `get_settings() -> Promise<any>` - Gets the settings of the current instance.
package/index.ts CHANGED
@@ -163,6 +163,8 @@ export enum RequestType {
163
163
  replace = "replace",
164
164
  delete = "delete",
165
165
  move = "move",
166
+ updateACL = "update_acl",
167
+ assign = "assign",
166
168
  }
167
169
 
168
170
  export enum ResourceAttachmentType {
@@ -372,8 +374,7 @@ export default class Dmart {
372
374
  public static async check_existing(prop: string, value: string) {
373
375
  try {
374
376
  const { data } = await axios.get<ResponseEntry>(
375
- this.baseURL +
376
- `/user/check-existing?${prop}=${value}`,
377
+ `${this.baseURL}/user/check-existing?${prop}=${value}`,
377
378
  { headers }
378
379
  );
379
380
  return data;
@@ -478,8 +479,7 @@ export default class Dmart {
478
479
  try {
479
480
  if (!subpath || subpath == "/") subpath = "__root__";
480
481
  const { data } = await axios.get<ResponseEntry>(
481
- this.baseURL +
482
- `/managed/entry/${resource_type}/${space_name}/${subpath}/${shortname}?retrieve_json_payload=${retrieve_json_payload}&retrieve_attachments=${retrieve_attachments}&validate_schema=${validate_schema}`.replace(
482
+ `${this.baseURL}/managed/entry/${resource_type}/${space_name}/${subpath}/${shortname}?retrieve_json_payload=${retrieve_json_payload}&retrieve_attachments=${retrieve_attachments}&validate_schema=${validate_schema}`.replace(
483
483
  /\/+/g,
484
484
  "/"
485
485
  ),
@@ -548,8 +548,7 @@ export default class Dmart {
548
548
  branch_name?: string
549
549
  ) {
550
550
  try {
551
- const endpoint = "/managed/data-asset";
552
- const url = `${this.baseURL}${endpoint}`;
551
+ const url = `${this.baseURL}/managed/data-asset`;
553
552
  const { data } = await axios.post(
554
553
  url,
555
554
  {
@@ -564,7 +563,6 @@ export default class Dmart {
564
563
  },
565
564
  { headers }
566
565
  );
567
-
568
566
  return data;
569
567
  } catch (error: any) {
570
568
  return error;
@@ -609,8 +607,7 @@ export default class Dmart {
609
607
  ext: string
610
608
  ) {
611
609
  return (
612
- this.baseURL +
613
- `/managed/payload/${resource_type}/${space_name}/${subpath.replace(
610
+ `${this.baseURL}/managed/payload/${resource_type}/${space_name}/${subpath.replace(
614
611
  /\/+$/,
615
612
  ""
616
613
  )}/${parent_shortname}/${shortname}.${ext}`.replaceAll("..", ".")
@@ -631,8 +628,7 @@ export default class Dmart {
631
628
  shortname: string,
632
629
  ) {
633
630
  const { data } = await axios.get<any>(
634
- this.baseURL +
635
- `/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}`,
631
+ `${this.baseURL}/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}`,
636
632
  { headers }
637
633
  );
638
634
  return data;
@@ -645,8 +641,7 @@ export default class Dmart {
645
641
  ext: string = ".json"
646
642
  ) {
647
643
  const { data } = await axios.get<any>(
648
- this.baseURL +
649
- `/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
644
+ `${this.baseURL}/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
650
645
  { headers }
651
646
  );
652
647
  return data;
@@ -659,8 +654,7 @@ export default class Dmart {
659
654
  ext: string = ".json"
660
655
  ) {
661
656
  const { data } = await axios.get<any>(
662
- this.baseURL +
663
- `/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
657
+ `${this.baseURL}/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
664
658
  { headers }
665
659
  );
666
660
  return data;
@@ -685,8 +679,7 @@ export default class Dmart {
685
679
  const { data } = await axios.put<
686
680
  ApiQueryResponse & { attributes: { folders_report: Object } }
687
681
  >(
688
- this.baseURL +
689
- `/managed/progress-ticket/${space_name}/${subpath}/${shortname}/${action}`,
682
+ `${this.baseURL}/managed/progress-ticket/${space_name}/${subpath}/${shortname}/${action}`,
690
683
  payload,
691
684
  { headers }
692
685
  );
@@ -696,6 +689,24 @@ export default class Dmart {
696
689
  }
697
690
  }
698
691
 
692
+ public static async submit(
693
+ spaceName: string,
694
+ schemaShortname: string,
695
+ subpath: string,
696
+ record: any // More general than Map<String, dynamic>
697
+ ){
698
+ try {
699
+ const {data} = await axios.post(
700
+ `${this.baseURL}/public/submit/${spaceName}/${schemaShortname}/${subpath}`,
701
+ record,
702
+ {headers}
703
+ );
704
+ return data;
705
+ } catch (error: any) {
706
+ return error.response.data;
707
+ }
708
+ }
709
+
699
710
  public static async get_manifest() {
700
711
  const { data } = await axios.get<any>(this.baseURL + `/info/manifest`, {
701
712
  headers,
@@ -710,4 +721,3 @@ export default class Dmart {
710
721
  return data;
711
722
  }
712
723
  }
713
- // 23 funcs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edraj/tsdmart",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
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",