@edraj/tsdmart 2.3.1 → 2.5.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.
Files changed (2) hide show
  1. package/dmart.service.ts +12 -40
  2. package/package.json +1 -1
package/dmart.service.ts CHANGED
@@ -224,6 +224,8 @@ export class Dmart {
224
224
  }
225
225
  }
226
226
 
227
+
228
+
227
229
  public static async upload_with_payload(
228
230
  space_name: string,
229
231
  subpath: string,
@@ -343,7 +345,7 @@ export class Dmart {
343
345
  return `/${scope}/payload/${resource_type}/${space_name}/${subpath.replace(
344
346
  /\/+$/,
345
347
  ""
346
- )}/${parent_shortname}/${shortname}${ext === null ? "" : ext}`;
348
+ )}/${parent_shortname}/${shortname}${ext === null ? "" : `.${ext}`}`;
347
349
  }
348
350
 
349
351
  public static async get_space_health(space_name: string) {
@@ -358,55 +360,25 @@ export class Dmart {
358
360
  }
359
361
 
360
362
  // 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
363
  public static async get_payload(
380
364
  resource_type: string,
381
365
  space_name: string,
382
366
  subpath: string,
383
367
  shortname: string,
384
- ext: string = ".json",
368
+ schemaShortname: string|null = null,
369
+ ext: string = "json",
385
370
  scope: string = "managed"
386
371
  ) {
387
372
  try {
388
- 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
- }
373
+ let url = `${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}`;
397
374
 
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 {
375
+ if(schemaShortname){
376
+ url += `.${schemaShortname}`
377
+ }
378
+ url += `.${ext}`
407
379
  const { data } = await axios.get<any>(
408
- `${scope}/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
409
- { headers }
380
+ url,
381
+ { headers }
410
382
  );
411
383
  return data;
412
384
  } catch (error: any) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edraj/tsdmart",
3
- "version": "2.3.1",
3
+ "version": "2.5.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",