@edraj/tsdmart 1.0.1 → 1.0.2

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/index.ts +23 -22
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
2
 
3
- let baseURL = "http://localhost:8282";
3
+
4
4
 
5
5
  axios.defaults.withCredentials = true;
6
6
 
@@ -319,10 +319,11 @@ type ApiQueryResponse = ApiResponse & {
319
319
  };
320
320
 
321
321
  export class Dmart {
322
+ baseURL = "http://localhost:8282";
322
323
  public async login(shortname: string, password: string) {
323
324
  const { data } = await axios.post<
324
325
  ApiResponse & { records: Array<LoginResponseRecord> }
325
- >(baseURL + "/user/login", { shortname, password }, { headers });
326
+ >(this.baseURL + "/user/login", { shortname, password }, { headers });
326
327
  //console.log(JSON.stringify(data, null, 2));
327
328
  // FIXME settins Authorization is only needed when the code is running on the server
328
329
  /*headers.Authorization = "";
@@ -334,7 +335,7 @@ export class Dmart {
334
335
 
335
336
  public async logout() {
336
337
  const { data } = await axios.post<ApiResponse>(
337
- baseURL + "/user/logout",
338
+ this.baseURL + "/user/logout",
338
339
  {},
339
340
  { headers }
340
341
  );
@@ -344,7 +345,7 @@ export class Dmart {
344
345
  public async create_user(request: any) {
345
346
  try {
346
347
  const { data } = await axios.post<ActionResponse>(
347
- baseURL + "/user/create",
348
+ this.baseURL + "/user/create",
348
349
  request,
349
350
  { headers }
350
351
  );
@@ -357,7 +358,7 @@ export class Dmart {
357
358
  public async update_user(request: any) {
358
359
  try {
359
360
  const { data } = await axios.post<ActionResponse>(
360
- baseURL + "/user/profile",
361
+ this.baseURL + "/user/profile",
361
362
  request,
362
363
  { headers }
363
364
  );
@@ -370,7 +371,7 @@ export class Dmart {
370
371
  public async check_existing(prop: string, value: string) {
371
372
  try {
372
373
  const { data } = await axios.get<ResponseEntry>(
373
- baseURL +
374
+ this.baseURL +
374
375
  `/user/check-existing?${prop}=${value}`,
375
376
  { headers }
376
377
  );
@@ -383,7 +384,7 @@ export class Dmart {
383
384
  public async get_profile() {
384
385
  try {
385
386
  const { data } = await axios.get<ProfileResponse>(
386
- baseURL + "/user/profile",
387
+ this.baseURL + "/user/profile",
387
388
  {
388
389
  headers,
389
390
  }
@@ -412,7 +413,7 @@ export class Dmart {
412
413
  }
413
414
  query.subpath = query.subpath.replace(/\/+/g, "/");
414
415
  const { data } = await axios.post<ApiQueryResponse>(
415
- baseURL + "/managed/query",
416
+ this.baseURL + "/managed/query",
416
417
  query,
417
418
  { headers , timeout: 3000 }
418
419
  );
@@ -428,7 +429,7 @@ export class Dmart {
428
429
  query.sort_by = "created_at";
429
430
  query.subpath = query.subpath.replace(/\/+/g, "/");
430
431
  const { data } = await axios.post<ApiQueryResponse>(
431
- baseURL + "/managed/csv",
432
+ this.baseURL + "/managed/csv",
432
433
  query,
433
434
  { headers }
434
435
  );
@@ -441,7 +442,7 @@ export class Dmart {
441
442
  public async space(action: ActionRequest): Promise<ActionResponse> {
442
443
  try {
443
444
  const { data } = await axios.post<ActionResponse>(
444
- baseURL + "/managed/space",
445
+ this.baseURL + "/managed/space",
445
446
  action,
446
447
  { headers }
447
448
  );
@@ -454,7 +455,7 @@ export class Dmart {
454
455
  public async request(action: ActionRequest): Promise<ActionResponse> {
455
456
  try {
456
457
  const { data } = await axios.post<ActionResponse>(
457
- baseURL + "/managed/request",
458
+ this.baseURL + "/managed/request",
458
459
  action,
459
460
  { headers }
460
461
  );
@@ -476,7 +477,7 @@ export class Dmart {
476
477
  try {
477
478
  if (!subpath || subpath == "/") subpath = "__root__";
478
479
  const { data } = await axios.get<ResponseEntry>(
479
- baseURL +
480
+ this.baseURL +
480
481
  `/managed/entry/${resource_type}/${space_name}/${subpath}/${shortname}?retrieve_json_payload=${retrieve_json_payload}&retrieve_attachments=${retrieve_attachments}&validate_schema=${validate_schema}`.replace(
481
482
  /\/+/g,
482
483
  "/"
@@ -526,7 +527,7 @@ export class Dmart {
526
527
  const headers = { "Content-Type": "multipart/form-data" };
527
528
 
528
529
  const { data } = await axios.post<ApiResponse>(
529
- baseURL + "/managed/resource_with_payload",
530
+ this.baseURL + "/managed/resource_with_payload",
530
531
  form_data,
531
532
  { headers }
532
533
  );
@@ -547,7 +548,7 @@ export class Dmart {
547
548
  ) {
548
549
  try {
549
550
  const endpoint = "/managed/data-asset";
550
- const url = `${baseURL}${endpoint}`;
551
+ const url = `${this.baseURL}${endpoint}`;
551
552
  const { data } = await axios.post(
552
553
  url,
553
554
  {
@@ -607,7 +608,7 @@ export class Dmart {
607
608
  ext: string
608
609
  ) {
609
610
  return (
610
- baseURL +
611
+ this.baseURL +
611
612
  `/managed/payload/${resource_type}/${space_name}/${subpath.replace(
612
613
  /\/+$/,
613
614
  ""
@@ -618,7 +619,7 @@ export class Dmart {
618
619
  public async get_space_health(space_name: string) {
619
620
  const { data } = await axios.get<
620
621
  ApiQueryResponse & { attributes: { folders_report: Object } }
621
- >(baseURL + `/managed/health/${space_name}`, { headers });
622
+ >(this.baseURL + `/managed/health/${space_name}`, { headers });
622
623
  return data;
623
624
  }
624
625
 
@@ -629,7 +630,7 @@ export class Dmart {
629
630
  shortname: string,
630
631
  ) {
631
632
  const { data } = await axios.get<any>(
632
- baseURL +
633
+ this.baseURL +
633
634
  `/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}`,
634
635
  { headers }
635
636
  );
@@ -643,7 +644,7 @@ export class Dmart {
643
644
  ext: string = ".json"
644
645
  ) {
645
646
  const { data } = await axios.get<any>(
646
- baseURL +
647
+ this.baseURL +
647
648
  `/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
648
649
  { headers }
649
650
  );
@@ -657,7 +658,7 @@ export class Dmart {
657
658
  ext: string = ".json"
658
659
  ) {
659
660
  const { data } = await axios.get<any>(
660
- baseURL +
661
+ this.baseURL +
661
662
  `/managed/payload/${resource_type}/${space_name}/${subpath}/${shortname}${ext}`,
662
663
  { headers }
663
664
  );
@@ -683,7 +684,7 @@ export class Dmart {
683
684
  const { data } = await axios.put<
684
685
  ApiQueryResponse & { attributes: { folders_report: Object } }
685
686
  >(
686
- baseURL +
687
+ this.baseURL +
687
688
  `/managed/progress-ticket/${space_name}/${subpath}/${shortname}/${action}`,
688
689
  payload,
689
690
  { headers }
@@ -695,14 +696,14 @@ export class Dmart {
695
696
  }
696
697
 
697
698
  public async get_manifest() {
698
- const { data } = await axios.get<any>(baseURL + `/info/manifest`, {
699
+ const { data } = await axios.get<any>(this.baseURL + `/info/manifest`, {
699
700
  headers,
700
701
  });
701
702
  return data;
702
703
  }
703
704
 
704
705
  public async get_settings() {
705
- const { data } = await axios.get<any>(baseURL + `/info/settings`, {
706
+ const { data } = await axios.get<any>(this.baseURL + `/info/settings`, {
706
707
  headers,
707
708
  });
708
709
  return data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edraj/tsdmart",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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",