@edraj/tsdmart 4.1.1 → 5.0.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 +35 -36
  2. package/package.json +1 -1
package/dmart.service.ts CHANGED
@@ -105,14 +105,13 @@ export class Dmart {
105
105
  */
106
106
  public static async login(shortname: string, password: string) {
107
107
  const response = await Dmart.axiosDmartInstance.post<LoginResponse>(
108
- `user/login`,
108
+ 'user/login',
109
109
  {shortname, password},
110
110
  {headers}
111
111
  );
112
112
  const data: LoginResponse = response.data;
113
113
  if (data.status == Status.success && data.records.length > 0) {
114
- headers["Authorization"] =
115
- "Bearer " + data.records[0]?.attributes.access_token;
114
+ headers["Authorization"] = "Bearer " + data.records[0]?.attributes.access_token;
116
115
  }
117
116
  return data;
118
117
  }
@@ -127,7 +126,7 @@ export class Dmart {
127
126
  public static async loginBy(credentials: any, password: string) {
128
127
  try {
129
128
  const response = await Dmart.axiosDmartInstance.post<LoginResponse>(
130
- `user/login`,
129
+ 'user/login',
131
130
  {...credentials, password},
132
131
  {headers}
133
132
  );
@@ -150,7 +149,7 @@ export class Dmart {
150
149
  public static async logout() {
151
150
  try {
152
151
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
153
- `user/logout`,
152
+ 'user/logout',
154
153
  {},
155
154
  {headers}
156
155
  );
@@ -169,7 +168,7 @@ export class Dmart {
169
168
  public static async createUser(request: ActionRequestRecord) {
170
169
  try {
171
170
  const {data} = await Dmart.axiosDmartInstance.post<ActionResponse>(
172
- `user/create`,
171
+ 'user/create',
173
172
  request,
174
173
  {headers}
175
174
  );
@@ -188,7 +187,7 @@ export class Dmart {
188
187
  public static async updateUser(request: ActionRequestRecord) {
189
188
  try {
190
189
  const {data} = await Dmart.axiosDmartInstance.post<ActionResponse>(
191
- `user/profile`,
190
+ 'user/profile',
192
191
  request,
193
192
  {headers}
194
193
  );
@@ -224,7 +223,7 @@ export class Dmart {
224
223
  */
225
224
  public static async getProfile() {
226
225
  try {
227
- const {data} = await Dmart.axiosDmartInstance.get<ProfileResponse>(`user/profile`, {
226
+ const {data} = await Dmart.axiosDmartInstance.get<ProfileResponse>('user/profile', {
228
227
  headers,
229
228
  });
230
229
  if (typeof localStorage !== "undefined" && data.status === "success") {
@@ -283,7 +282,7 @@ export class Dmart {
283
282
  query.sort_by = "created_at";
284
283
  query.subpath = query.subpath.replace(/\/+/g, "/");
285
284
  const {data} = await Dmart.axiosDmartInstance.post<ApiQueryResponse>(
286
- `managed/csv`,
285
+ 'managed/csv',
287
286
  query,
288
287
  {headers}
289
288
  );
@@ -329,24 +328,24 @@ export class Dmart {
329
328
  }
330
329
  }
331
330
 
332
- /**
333
- * Performs space-level operations (create, update, delete spaces)
334
- * @param action - ActionRequest containing the operation details for space management
335
- * @returns Promise resolving to ActionResponse with operation result
336
- * @throws Error if space operation fails
337
- */
338
- public static async space(action: ActionRequest): Promise<ActionResponse> {
339
- try {
340
- const {data} = await Dmart.axiosDmartInstance.post<ActionResponse>(
341
- `managed/space`,
342
- action,
343
- {headers}
344
- );
345
- return data;
346
- } catch (error: any) {
347
- throw error;
348
- }
349
- }
331
+ // /** LEGACY, DEPRECATED CODE, DO NOT USE
332
+ // * Performs space-level operations (create, update, delete spaces)
333
+ // * @param action - ActionRequest containing the operation details for space management
334
+ // * @returns Promise resolving to ActionResponse with operation result
335
+ // * @throws Error if space operation fails
336
+ // */
337
+ // public static async space(action: ActionRequest): Promise<ActionResponse> {
338
+ // try {
339
+ // const {data} = await Dmart.axiosDmartInstance.post<ActionResponse>(
340
+ // 'managed/space',
341
+ // action,
342
+ // {headers}
343
+ // );
344
+ // return data;
345
+ // } catch (error: any) {
346
+ // throw error;
347
+ // }
348
+ // }
350
349
 
351
350
  /**
352
351
  * Executes a general request action against the Dmart API
@@ -354,7 +353,7 @@ export class Dmart {
354
353
  * @returns Promise resolving to ActionResponse with request result
355
354
  */
356
355
  public static async request(action: ActionRequest): Promise<ActionResponse> {
357
- const res = await Dmart.axiosDmartInstance.post<ActionResponse>(`managed/request`, action, {
356
+ const res = await Dmart.axiosDmartInstance.post<ActionResponse>('managed/request', action, {
358
357
  headers,
359
358
  });
360
359
  return res?.data;
@@ -637,7 +636,7 @@ export class Dmart {
637
636
  */
638
637
  public static async getManifest() {
639
638
  try {
640
- const {data} = await Dmart.axiosDmartInstance.get<any>(`info/manifest`, {
639
+ const {data} = await Dmart.axiosDmartInstance.get<any>('info/manifest', {
641
640
  headers,
642
641
  });
643
642
  return data;
@@ -653,7 +652,7 @@ export class Dmart {
653
652
  */
654
653
  public static async getSettings() {
655
654
  try {
656
- const {data} = await Dmart.axiosDmartInstance.get<any>(`info/settings`, {
655
+ const {data} = await Dmart.axiosDmartInstance.get<any>('info/settings', {
657
656
  headers,
658
657
  });
659
658
  return data;
@@ -680,7 +679,7 @@ export class Dmart {
680
679
  }
681
680
 
682
681
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
683
- `user/otp-request`,
682
+ 'user/otp-request',
684
683
  request,
685
684
  {headers: requestHeaders}
686
685
  );
@@ -708,7 +707,7 @@ export class Dmart {
708
707
  }
709
708
 
710
709
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
711
- `user/otp-request-login`,
710
+ 'user/otp-request-login',
712
711
  request,
713
712
  {headers: requestHeaders}
714
713
  );
@@ -727,7 +726,7 @@ export class Dmart {
727
726
  public static async passwordResetRequest(request: PasswordResetRequest) {
728
727
  try {
729
728
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
730
- `user/password-reset-request`,
729
+ 'user/password-reset-request',
731
730
  request,
732
731
  {headers}
733
732
  );
@@ -746,7 +745,7 @@ export class Dmart {
746
745
  public static async confirmOtp(request: ConfirmOTPRequest) {
747
746
  try {
748
747
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
749
- `user/otp-confirm`,
748
+ 'user/otp-confirm',
750
749
  request,
751
750
  {headers}
752
751
  );
@@ -765,7 +764,7 @@ export class Dmart {
765
764
  public static async userReset(shortname: string) {
766
765
  try {
767
766
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
768
- `user/reset`,
767
+ 'user/reset',
769
768
  {shortname},
770
769
  {headers}
771
770
  );
@@ -784,7 +783,7 @@ export class Dmart {
784
783
  public static async validatePassword(password: string) {
785
784
  try {
786
785
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
787
- `user/validate_password`,
786
+ 'user/validate_password',
788
787
  {password},
789
788
  {headers}
790
789
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edraj/tsdmart",
3
- "version": "4.1.1",
3
+ "version": "5.0.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",