@edraj/tsdmart 1.0.8 → 1.0.10

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/.idea/modules.xml CHANGED
File without changes
package/.idea/tsdmart.iml CHANGED
File without changes
package/.idea/vcs.xml CHANGED
File without changes
package/README.md CHANGED
@@ -4,7 +4,8 @@ A TypeScript implementation of the Dmart that depends on axios.
4
4
 
5
5
  ## APIs
6
6
 
7
- * `login(shortname: string, password: string) -> Promise<ApiResponse>` - Performs a login action.
7
+ * `login(shortname: string, password: string) -> Promise<ApiResponse>` - Performs a login action (shortname).
8
+ * `loginBy(credentials: dict, password: string) -> Promise<ApiResponse>` - Performs a login action but altering the default identifier that you can customise.
8
9
  * `logout() -> Promise<ApiResponse>` - Performs a logout action.
9
10
  * `create_user(request: any) -> Promise<ActionResponse>` - Creates a new user.
10
11
  * `update_user(request: any) -> Promise<ActionResponse>` - Updates an existing user.
package/index.ts CHANGED
@@ -8,7 +8,7 @@ export enum Status {
8
8
  failed = "failed",
9
9
  }
10
10
 
11
- type Error = {
11
+ export type Error = {
12
12
  type: string;
13
13
  code: number;
14
14
  message: string;
@@ -29,19 +29,19 @@ export type ApiResponse = {
29
29
  records: Array<ApiResponseRecord>;
30
30
  };
31
31
 
32
- type Translation = {
32
+ export type Translation = {
33
33
  ar: string;
34
34
  en: string;
35
35
  kd: string;
36
36
  };
37
37
 
38
- enum UserType {
38
+ export enum UserType {
39
39
  web = "web",
40
40
  mobile = "mobile",
41
41
  bot = "bot",
42
42
  }
43
43
 
44
- type LoginResponseRecord = ApiResponseRecord & {
44
+ export type LoginResponseRecord = ApiResponseRecord & {
45
45
  attributes: {
46
46
  access_token: string;
47
47
  type: UserType;
@@ -51,14 +51,14 @@ type LoginResponseRecord = ApiResponseRecord & {
51
51
 
52
52
  // type LoginResponse = ApiResponse & { records : Array<LoginResponseRecord> };
53
53
 
54
- type Permission = {
54
+ export type Permission = {
55
55
  allowed_actions: Array<ActionType>;
56
56
  conditions: Array<string>;
57
57
  restricted_fields: Array<any>;
58
58
  allowed_fields_values: Map<string, any>;
59
59
  };
60
60
 
61
- enum Language {
61
+ export enum Language {
62
62
  arabic = "arabic",
63
63
  english = "engligh",
64
64
  kurdish = "kurdish",
@@ -66,7 +66,7 @@ enum Language {
66
66
  turkish = "turkish",
67
67
  }
68
68
 
69
- type ProfileResponseRecord = ApiResponseRecord & {
69
+ export type ProfileResponseRecord = ApiResponseRecord & {
70
70
  attributes: {
71
71
  email: string;
72
72
  displayname: Translation;
@@ -121,6 +121,8 @@ export enum QueryType {
121
121
  spaces = "spaces",
122
122
  counters = "counters",
123
123
  reports = "reports",
124
+ attachments = "attachments",
125
+ attachments_aggregation = "attachments_aggregation"
124
126
  }
125
127
 
126
128
  export enum SortyType {
@@ -233,7 +235,7 @@ export enum ContentTypeMedia {
233
235
  video = "video",
234
236
  }
235
237
 
236
- type Payload = {
238
+ export type Payload = {
237
239
  content_type: ContentType;
238
240
  schema_shortname?: string;
239
241
  checksum: string;
@@ -242,7 +244,7 @@ type Payload = {
242
244
  validation_status: "valid" | "invalid";
243
245
  };
244
246
 
245
- type MetaExtended = {
247
+ export type MetaExtended = {
246
248
  email: string;
247
249
  msisdn: string;
248
250
  is_email_verified: boolean;
@@ -300,7 +302,7 @@ export type ActionResponse = ApiResponse & {
300
302
  >;
301
303
  };
302
304
 
303
- type ActionRequestRecord = {
305
+ export type ActionRequestRecord = {
304
306
  resource_type: ResourceType;
305
307
  uuid?: string;
306
308
  shortname: string;
@@ -316,7 +318,7 @@ export type ActionRequest = {
316
318
  };
317
319
 
318
320
 
319
- type ApiQueryResponse = ApiResponse & {
321
+ export type ApiQueryResponse = ApiResponse & {
320
322
  attributes: { total: number; returned: number };
321
323
  };
322
324
 
@@ -327,12 +329,13 @@ export default class Dmart {
327
329
  const {data} = await axios.post<
328
330
  ApiResponse & { records: Array<LoginResponseRecord> }
329
331
  >(this.baseURL + "/user/login", {shortname, password}, {headers});
330
- //console.log(JSON.stringify(data, null, 2));
331
- // FIXME settins Authorization is only needed when the code is running on the server
332
- /*headers.Authorization = "";
333
- if (data.status == Status.success && data.records.length > 0) {
334
- headers.Authorization = "Bearer " + data.records[0].attributes.access_token;
335
- }*/
332
+ return data;
333
+ }
334
+
335
+ public static async loginBy(credentials: any, password: string) {
336
+ const {data} = await axios.post<
337
+ ApiResponse & { records: Array<LoginResponseRecord> }
338
+ >(this.baseURL + "/user/login", {...credentials, password}, {headers});
336
339
  return data;
337
340
  }
338
341
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edraj/tsdmart",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
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",
@@ -21,6 +21,6 @@
21
21
  "typescript": "^5.4.2"
22
22
  },
23
23
  "dependencies": {
24
- "axios": "^1.6.8"
24
+ "axios": "^1.7.9"
25
25
  }
26
26
  }