@edraj/tsdmart 4.1.1 → 5.0.1

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/dmart.model.ts CHANGED
@@ -178,6 +178,7 @@ export type QueryRequest = {
178
178
  sort_type?: SortyType;
179
179
  retrieve_json_payload?: boolean;
180
180
  retrieve_attachments?: boolean;
181
+ retrieve_total?: boolean;
181
182
  validate_schema?: boolean;
182
183
  jq_filter?: string;
183
184
  exact_subpath?: boolean;
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;
@@ -520,10 +519,11 @@ export class Dmart {
520
519
  request: GetAttachmentURLRequest,
521
520
  scope: string = DmartScope.managed
522
521
  ) {
523
- return `${Dmart.axiosDmartInstance.defaults.baseURL}/${scope}/payload/${request.resource_type}/${request.space_name}/${request.subpath.replace(
522
+ const subpath = request.subpath.replace(
524
523
  /\/+$/,
525
524
  ""
526
- )}/${request.parent_shortname}/${request.shortname}${request.ext === null ? "" : `.${request.ext}`}`;
525
+ );
526
+ return `${Dmart.axiosDmartInstance.defaults.baseURL}/${scope}/payload/${request.resource_type}/${request.space_name}/${subpath}/${request.parent_shortname}/${request.shortname}${request.ext === null ? "" : `.${request.ext}`}`.replaceAll('//', '/');
527
527
  }
528
528
 
529
529
  /**
@@ -637,7 +637,7 @@ export class Dmart {
637
637
  */
638
638
  public static async getManifest() {
639
639
  try {
640
- const {data} = await Dmart.axiosDmartInstance.get<any>(`info/manifest`, {
640
+ const {data} = await Dmart.axiosDmartInstance.get<any>('info/manifest', {
641
641
  headers,
642
642
  });
643
643
  return data;
@@ -653,7 +653,7 @@ export class Dmart {
653
653
  */
654
654
  public static async getSettings() {
655
655
  try {
656
- const {data} = await Dmart.axiosDmartInstance.get<any>(`info/settings`, {
656
+ const {data} = await Dmart.axiosDmartInstance.get<any>('info/settings', {
657
657
  headers,
658
658
  });
659
659
  return data;
@@ -680,7 +680,7 @@ export class Dmart {
680
680
  }
681
681
 
682
682
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
683
- `user/otp-request`,
683
+ 'user/otp-request',
684
684
  request,
685
685
  {headers: requestHeaders}
686
686
  );
@@ -708,7 +708,7 @@ export class Dmart {
708
708
  }
709
709
 
710
710
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
711
- `user/otp-request-login`,
711
+ 'user/otp-request-login',
712
712
  request,
713
713
  {headers: requestHeaders}
714
714
  );
@@ -727,7 +727,7 @@ export class Dmart {
727
727
  public static async passwordResetRequest(request: PasswordResetRequest) {
728
728
  try {
729
729
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
730
- `user/password-reset-request`,
730
+ 'user/password-reset-request',
731
731
  request,
732
732
  {headers}
733
733
  );
@@ -746,7 +746,7 @@ export class Dmart {
746
746
  public static async confirmOtp(request: ConfirmOTPRequest) {
747
747
  try {
748
748
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
749
- `user/otp-confirm`,
749
+ 'user/otp-confirm',
750
750
  request,
751
751
  {headers}
752
752
  );
@@ -765,7 +765,7 @@ export class Dmart {
765
765
  public static async userReset(shortname: string) {
766
766
  try {
767
767
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
768
- `user/reset`,
768
+ 'user/reset',
769
769
  {shortname},
770
770
  {headers}
771
771
  );
@@ -784,7 +784,7 @@ export class Dmart {
784
784
  public static async validatePassword(password: string) {
785
785
  try {
786
786
  const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
787
- `user/validate_password`,
787
+ 'user/validate_password',
788
788
  {password},
789
789
  {headers}
790
790
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edraj/tsdmart",
3
- "version": "4.1.1",
3
+ "version": "5.0.1",
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",
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="AgentMigrationStateService">
4
- <option name="migrationStatus" value="COMPLETED" />
5
- </component>
6
- </project>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="AskMigrationStateService">
4
- <option name="migrationStatus" value="COMPLETED" />
5
- </component>
6
- </project>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="Ask2AgentMigrationStateService">
4
- <option name="migrationStatus" value="COMPLETED" />
5
- </component>
6
- </project>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="EditMigrationStateService">
4
- <option name="migrationStatus" value="COMPLETED" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/tsdmart.iml" filepath="$PROJECT_DIR$/.idea/tsdmart.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/tsdmart.iml DELETED
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
- <excludeFolder url="file://$MODULE_DIR$/temp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- <excludeFolder url="file://$MODULE_DIR$/b" />
9
- <excludeFolder url="file://$MODULE_DIR$/.idea/copilot/chatSessions" />
10
- </content>
11
- <orderEntry type="inheritedJdk" />
12
- <orderEntry type="sourceFolder" forTests="false" />
13
- </component>
14
- </module>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>