@edraj/tsdmart 1.0.16 → 2.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## 1.0.10
2
2
 
3
- - Implementing DMART apis up to TBD
3
+ - Implementing DMART apis up to 1.3.x
4
4
 
5
5
  ## 1.0.8
6
6
 
package/README.md CHANGED
@@ -4,8 +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 (shortname).
8
- * `loginBy(credentials: dict, password: string) -> Promise<ApiResponse>` - Performs a login action but altering the default identifier that you can customise.
7
+ * `login(shortname: string, password: string) -> Promise<LoginResponse>` - Performs a login action (shortname).
8
+ * `loginBy(credentials: dict, password: string) -> Promise<LoginResponse>` - Performs a login action but altering the default identifier that you can customise.
9
9
  * `logout() -> Promise<ApiResponse>` - Performs a logout action.
10
10
  * `create_user(request: any) -> Promise<ActionResponse>` - Creates a new user.
11
11
  * `update_user(request: any) -> Promise<ActionResponse>` - Updates an existing user.
package/a ADDED
@@ -0,0 +1,2 @@
1
+ npm login
2
+ npm publish
package/dmart.model.ts ADDED
@@ -0,0 +1,320 @@
1
+ export enum Status {
2
+ success = "success",
3
+ failed = "failed",
4
+ }
5
+
6
+ export type Error = {
7
+ type: string;
8
+ code: number;
9
+ message: string;
10
+ info: any;
11
+ };
12
+
13
+ export type ApiResponseRecord = {
14
+ resource_type: string;
15
+ shortname: string;
16
+ branch_name?: string;
17
+ subpath: string;
18
+ attributes: Record<string, any>;
19
+ };
20
+
21
+ export type ApiResponse = {
22
+ status: Status;
23
+ error?: Error;
24
+ records: Array<ApiResponseRecord>;
25
+ };
26
+
27
+ export type Translation = {
28
+ ar: string;
29
+ en: string;
30
+ kd: string;
31
+ };
32
+
33
+ export enum UserType {
34
+ web = "web",
35
+ mobile = "mobile",
36
+ bot = "bot",
37
+ }
38
+
39
+ export type LoginResponseRecord = ApiResponseRecord & {
40
+ attributes: {
41
+ access_token: string;
42
+ type: UserType;
43
+ displayname: Translation;
44
+ };
45
+ };
46
+
47
+ export type LoginResponse = ApiResponse & {
48
+ records: Array<LoginResponseRecord>;
49
+ };
50
+
51
+ export type Permission = {
52
+ allowed_actions: Array<ActionType>;
53
+ conditions: Array<string>;
54
+ restricted_fields: Array<any>;
55
+ allowed_fields_values: Map<string, any>;
56
+ };
57
+
58
+ export enum Language {
59
+ arabic = "arabic",
60
+ english = "engligh",
61
+ kurdish = "kurdish",
62
+ french = "french",
63
+ turkish = "turkish",
64
+ }
65
+
66
+ export type ProfileResponseRecord = ApiResponseRecord & {
67
+ attributes: {
68
+ email: string;
69
+ displayname: Translation;
70
+ type: string;
71
+ language: Language;
72
+ is_email_verified: boolean;
73
+ is_msisdn_verified: boolean;
74
+ force_password_change: boolean;
75
+ permissions: Record<string, Permission>;
76
+ };
77
+ };
78
+
79
+ export enum ActionType {
80
+ query = "query",
81
+ view = "view",
82
+ update = "update",
83
+ create = "create",
84
+ delete = "delete",
85
+ attach = "attach",
86
+ move = "move",
87
+ progress_ticket = "progress_ticket",
88
+ }
89
+
90
+ export type ProfileResponse = ApiResponse & {
91
+ records: Array<ProfileResponseRecord>;
92
+ };
93
+
94
+ export let headers: { [key: string]: string } = {
95
+ "Content-type": "application/json",
96
+ Authorization: "",
97
+ };
98
+
99
+ export type AggregationReducer = {
100
+ name: string;
101
+ alias: string;
102
+ args: Array<string>;
103
+ };
104
+
105
+ export type AggregationType = {
106
+ load: Array<string>;
107
+ group_by: Array<string>;
108
+ reducers: Array<AggregationReducer> | Array<string>;
109
+ };
110
+
111
+ export enum QueryType {
112
+ aggregation = "aggregation",
113
+ search = "search",
114
+ subpath = "subpath",
115
+ events = "events",
116
+ history = "history",
117
+ tags = "tags",
118
+ spaces = "spaces",
119
+ counters = "counters",
120
+ reports = "reports",
121
+ attachments = "attachments",
122
+ attachments_aggregation = "attachments_aggregation",
123
+ }
124
+
125
+ export enum SortyType {
126
+ ascending = "ascending",
127
+ descending = "descending",
128
+ }
129
+
130
+ // enum NotificationPriority {
131
+ // high = "high",
132
+ // medium = "medium",
133
+ // low = "low"
134
+ // };
135
+
136
+ export type QueryRequest = {
137
+ type: QueryType;
138
+ space_name: string;
139
+ subpath: string;
140
+ filter_types?: Array<ResourceType>;
141
+ filter_schema_names?: Array<string>;
142
+ filter_shortnames?: Array<string>;
143
+ search: string;
144
+ from_date?: string;
145
+ to_date?: string;
146
+ sort_by?: string;
147
+ sort_type?: SortyType;
148
+ retrieve_json_payload?: boolean;
149
+ retrieve_attachments?: boolean;
150
+ validate_schema?: boolean;
151
+ jq_filter?: string;
152
+ exact_subpath?: boolean;
153
+ limit?: number;
154
+ offset?: number;
155
+ aggregation_data?: AggregationType;
156
+ };
157
+
158
+ export enum RequestType {
159
+ create = "create",
160
+ update = "update",
161
+ replace = "replace",
162
+ delete = "delete",
163
+ move = "move",
164
+ updateACL = "update_acl",
165
+ assign = "assign",
166
+ }
167
+
168
+ export enum ResourceAttachmentType {
169
+ json = "json",
170
+ comment = "comment",
171
+ media = "media",
172
+ relationship = "relationship",
173
+ alteration = "alteration",
174
+ csv = "csv",
175
+ parquet = "parquet",
176
+ jsonl = "jsonl",
177
+ sqlite = "sqlite",
178
+ }
179
+
180
+ export enum ResourceType {
181
+ user = "user",
182
+ group = "group",
183
+ folder = "folder",
184
+ schema = "schema",
185
+ content = "content",
186
+ acl = "acl",
187
+ comment = "comment",
188
+ reaction = "reaction",
189
+ media = "media",
190
+ locator = "locator",
191
+ relationship = "relationship",
192
+ alteration = "alteration",
193
+ history = "history",
194
+ space = "space",
195
+ branch = "branch",
196
+ permission = "permission",
197
+ role = "role",
198
+ ticket = "ticket",
199
+ json = "json",
200
+ post = "post",
201
+ plugin_wrapper = "plugin_wrapper",
202
+ notification = "notification",
203
+ jsonl = "jsonl",
204
+ csv = "csv",
205
+ sqlite = "sqlite",
206
+ parquet = "parquet",
207
+ }
208
+
209
+ export enum ContentType {
210
+ text = "text",
211
+ html = "html",
212
+ markdown = "markdown",
213
+ json = "json",
214
+ image = "image",
215
+ python = "python",
216
+ pdf = "pdf",
217
+ audio = "audio",
218
+ video = "video",
219
+ jsonl = "jsonl",
220
+ csv = "csv",
221
+ sqlite = "sqlite",
222
+ parquet = "parquet",
223
+ }
224
+
225
+ export enum ContentTypeMedia {
226
+ text = "text",
227
+ html = "html",
228
+ markdown = "markdown",
229
+ image = "image",
230
+ python = "python",
231
+ pdf = "pdf",
232
+ audio = "audio",
233
+ video = "video",
234
+ }
235
+
236
+ export type Payload = {
237
+ content_type: ContentType;
238
+ schema_shortname?: string;
239
+ checksum: string;
240
+ body: string | Record<string, any> | any;
241
+ last_validated: string;
242
+ validation_status: "valid" | "invalid";
243
+ };
244
+
245
+ export type MetaExtended = {
246
+ email: string;
247
+ msisdn: string;
248
+ is_email_verified: boolean;
249
+ is_msisdn_verified: boolean;
250
+ force_password_change: boolean;
251
+ password: string;
252
+ workflow_shortname: string;
253
+ state: string;
254
+ is_open: boolean;
255
+ };
256
+
257
+ export type ResponseEntry = MetaExtended & {
258
+ uuid: string;
259
+ shortname: string;
260
+ subpath: string;
261
+ is_active: boolean;
262
+ displayname: Translation;
263
+ description: Translation;
264
+ tags: Set<string>;
265
+ created_at: string;
266
+ updated_at: string;
267
+ owner_shortname: string;
268
+ payload?: Payload;
269
+ relationships?: any;
270
+ attachments?: Object;
271
+ workflow_shortname?: string;
272
+ state?: string;
273
+ };
274
+
275
+ export type ResponseRecord = {
276
+ resource_type: ResourceType;
277
+ uuid: string;
278
+ shortname: string;
279
+ subpath: string;
280
+ attributes: {
281
+ is_active: boolean;
282
+ displayname: Translation;
283
+ description: Translation;
284
+ tags: Set<string>;
285
+ created_at: string;
286
+ updated_at: string;
287
+ owner_shortname: string;
288
+ payload?: Payload;
289
+ };
290
+ };
291
+
292
+ export type ActionResponse = ApiResponse & {
293
+ records: Array<
294
+ ResponseRecord & {
295
+ attachments: {
296
+ media: Array<ResponseRecord>;
297
+ json: Array<ResponseRecord>;
298
+ };
299
+ }
300
+ >;
301
+ };
302
+
303
+ export type ActionRequestRecord = {
304
+ resource_type: ResourceType;
305
+ uuid?: string;
306
+ shortname: string;
307
+ subpath: string;
308
+ attributes: Record<string, any>;
309
+ attachments?: Record<ResourceType, Array<any>>;
310
+ };
311
+
312
+ export type ActionRequest = {
313
+ space_name: string;
314
+ request_type: RequestType;
315
+ records: Array<ActionRequestRecord>;
316
+ };
317
+
318
+ export type ApiQueryResponse = ApiResponse & {
319
+ attributes: { total: number; returned: number };
320
+ };