@edraj/tsdmart 5.2.0 → 5.3.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.
- package/CHANGELOG.md +19 -0
- package/dist/dmart.model.d.ts +388 -0
- package/dist/dmart.model.d.ts.map +1 -0
- package/dist/dmart.model.js +140 -0
- package/dist/dmart.model.js.map +1 -0
- package/dist/dmart.service.d.ts +248 -0
- package/dist/dmart.service.d.ts.map +1 -0
- package/{dmart.service.ts → dist/dmart.service.js} +91 -296
- package/dist/dmart.service.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/{index.ts → dist/index.js} +1 -1
- package/dist/index.js.map +1 -0
- package/package.json +32 -4
- package/a +0 -2
- package/dmart.model.ts +0 -442
- package/test.ts +0 -70
- package/tsconfig.json +0 -44
|
@@ -1,293 +1,193 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
ActionRequest,
|
|
4
|
-
ActionRequestRecord,
|
|
5
|
-
ActionResponse,
|
|
6
|
-
ApiQueryResponse,
|
|
7
|
-
ApiResponse,
|
|
8
|
-
ConfirmOTPRequest,
|
|
9
|
-
DmartScope,
|
|
10
|
-
FetchDataAssetRequest,
|
|
11
|
-
GetAttachmentURLRequest,
|
|
12
|
-
GetChildrenRequest,
|
|
13
|
-
GetPayloadRequest,
|
|
14
|
-
headers,
|
|
15
|
-
LoginResponse,
|
|
16
|
-
PasswordResetRequest,
|
|
17
|
-
ProfileResponse,
|
|
18
|
-
ProgressTicketRequest,
|
|
19
|
-
QueryRequest,
|
|
20
|
-
QueryType,
|
|
21
|
-
ResourcesFromCSVRequest,
|
|
22
|
-
ResponseEntry,
|
|
23
|
-
RetrieveEntryRequest,
|
|
24
|
-
SendOTPRequest,
|
|
25
|
-
SortType,
|
|
26
|
-
Status,
|
|
27
|
-
SubmitRequest,
|
|
28
|
-
UploadWithPayloadRequest,
|
|
29
|
-
} from "./dmart.model";
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { DmartScope, headers, QueryType, SortType, Status, } from "./dmart.model";
|
|
32
2
|
export class Dmart {
|
|
33
|
-
static axiosDmartInstance
|
|
34
|
-
|
|
3
|
+
static axiosDmartInstance;
|
|
35
4
|
/**
|
|
36
5
|
* Sets the Axios instance to be used for all HTTP requests
|
|
37
6
|
* @param axiosInstance - The Axios instance to use for API calls
|
|
38
7
|
*/
|
|
39
|
-
static setAxiosInstance(axiosInstance
|
|
8
|
+
static setAxiosInstance(axiosInstance) {
|
|
40
9
|
Dmart.axiosDmartInstance = axiosInstance;
|
|
41
10
|
}
|
|
42
|
-
|
|
43
11
|
/**
|
|
44
12
|
* Gets the current Axios instance
|
|
45
13
|
* @returns The configured Axios instance
|
|
46
14
|
* @throws Error if no Axios instance has been set
|
|
47
15
|
*/
|
|
48
|
-
|
|
16
|
+
static getAxiosInstance() {
|
|
49
17
|
if (!Dmart.axiosDmartInstance) {
|
|
50
18
|
throw new Error("Axios instance is not set. Please set it using setAxiosInstance method.");
|
|
51
19
|
}
|
|
52
20
|
return Dmart.axiosDmartInstance;
|
|
53
21
|
}
|
|
54
|
-
|
|
55
22
|
/**
|
|
56
23
|
* Gets the current headers object used for API requests
|
|
57
24
|
* @returns The headers object containing request headers
|
|
58
25
|
*/
|
|
59
|
-
|
|
26
|
+
static getHeaders() {
|
|
60
27
|
return headers;
|
|
61
28
|
}
|
|
62
|
-
|
|
63
29
|
/**
|
|
64
30
|
* Updates the headers object with new headers
|
|
65
31
|
* @param newHeaders - Object containing headers to merge with existing headers
|
|
66
32
|
*/
|
|
67
|
-
|
|
33
|
+
static setHeaders(newHeaders) {
|
|
68
34
|
Object.assign(headers, newHeaders);
|
|
69
35
|
}
|
|
70
|
-
|
|
71
36
|
/**
|
|
72
37
|
* Gets the base URL from the Axios instance
|
|
73
38
|
* @returns The base URL string
|
|
74
39
|
* @throws Error if no Axios instance has been set
|
|
75
40
|
*/
|
|
76
|
-
|
|
41
|
+
static getBaseURL() {
|
|
77
42
|
return Dmart.getAxiosInstance().defaults.baseURL;
|
|
78
43
|
}
|
|
79
|
-
|
|
80
44
|
/**
|
|
81
45
|
* Sets the base URL for the Axios instance
|
|
82
46
|
* @param url - The base URL to set
|
|
83
47
|
*/
|
|
84
|
-
|
|
48
|
+
static setBaseURL(url) {
|
|
85
49
|
Dmart.getAxiosInstance().defaults.baseURL = url;
|
|
86
50
|
}
|
|
87
|
-
|
|
88
51
|
/**
|
|
89
52
|
* Gets the current authentication token
|
|
90
53
|
* @returns The token string without the "Bearer " prefix, or null if not set
|
|
91
54
|
*/
|
|
92
|
-
|
|
55
|
+
static getToken() {
|
|
93
56
|
return headers["Authorization"] ? headers["Authorization"].replace("Bearer ", "") : null;
|
|
94
57
|
}
|
|
95
|
-
|
|
96
58
|
/**
|
|
97
59
|
* Sets the authentication token in the headers
|
|
98
60
|
* @param token - The JWT token to use for authentication
|
|
99
61
|
*/
|
|
100
|
-
|
|
62
|
+
static setToken(token) {
|
|
101
63
|
headers["Authorization"] = `Bearer ${token}`;
|
|
102
64
|
}
|
|
103
|
-
|
|
104
65
|
/**
|
|
105
66
|
* Authenticates a user with shortname and password
|
|
106
67
|
* @param shortname - The user's shortname (username)
|
|
107
68
|
* @param password - The user's password
|
|
108
69
|
* @returns Promise resolving to LoginResponse containing authentication data and access token
|
|
109
70
|
*/
|
|
110
|
-
|
|
111
|
-
const response = await Dmart.axiosDmartInstance.post
|
|
112
|
-
|
|
113
|
-
{shortname, password},
|
|
114
|
-
{headers}
|
|
115
|
-
);
|
|
116
|
-
const data: LoginResponse = response.data;
|
|
71
|
+
static async login(shortname, password) {
|
|
72
|
+
const response = await Dmart.axiosDmartInstance.post('user/login', { shortname, password }, { headers });
|
|
73
|
+
const data = response.data;
|
|
117
74
|
if (data.status === Status.success && data.records.length > 0) {
|
|
118
75
|
headers["Authorization"] = "Bearer " + data.records[0]?.attributes.access_token;
|
|
119
76
|
}
|
|
120
77
|
return data;
|
|
121
78
|
}
|
|
122
|
-
|
|
123
79
|
/**
|
|
124
80
|
* Authenticates a user with custom credentials and password
|
|
125
81
|
* @param credentials - Object containing login credentials (e.g., email, phone, etc.)
|
|
126
82
|
* @param password - The user's password
|
|
127
83
|
* @returns Promise resolving to LoginResponse containing authentication data and access token
|
|
128
84
|
*/
|
|
129
|
-
|
|
130
|
-
const response = await Dmart.axiosDmartInstance.post
|
|
131
|
-
|
|
132
|
-
{...credentials, password},
|
|
133
|
-
{headers}
|
|
134
|
-
);
|
|
135
|
-
const data: LoginResponse = response.data;
|
|
85
|
+
static async loginBy(credentials, password) {
|
|
86
|
+
const response = await Dmart.axiosDmartInstance.post('user/login', { ...credentials, password }, { headers });
|
|
87
|
+
const data = response.data;
|
|
136
88
|
if (data.status === Status.success && data.records.length > 0) {
|
|
137
89
|
headers["Authorization"] =
|
|
138
90
|
"Bearer " + data.records[0]?.attributes.access_token;
|
|
139
91
|
}
|
|
140
92
|
return data;
|
|
141
93
|
}
|
|
142
|
-
|
|
143
94
|
/**
|
|
144
95
|
* Logs out the current user session
|
|
145
96
|
* @returns Promise resolving to ApiResponse indicating logout status
|
|
146
97
|
*/
|
|
147
|
-
|
|
148
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
149
|
-
'user/logout',
|
|
150
|
-
{},
|
|
151
|
-
{headers}
|
|
152
|
-
);
|
|
98
|
+
static async logout() {
|
|
99
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/logout', {}, { headers });
|
|
153
100
|
return data;
|
|
154
101
|
}
|
|
155
|
-
|
|
156
102
|
/**
|
|
157
103
|
* Creates a new user account
|
|
158
104
|
* @param request - ActionRequestRecord containing user creation data
|
|
159
105
|
* @returns Promise resolving to ActionResponse with creation result
|
|
160
106
|
*/
|
|
161
|
-
|
|
162
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
163
|
-
'user/create',
|
|
164
|
-
request,
|
|
165
|
-
{headers}
|
|
166
|
-
);
|
|
107
|
+
static async createUser(request) {
|
|
108
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/create', request, { headers });
|
|
167
109
|
return data;
|
|
168
110
|
}
|
|
169
|
-
|
|
170
111
|
/**
|
|
171
112
|
* Updates an existing user's profile information
|
|
172
113
|
* @param request - ActionRequestRecord containing user update data
|
|
173
114
|
* @returns Promise resolving to ActionResponse with update result
|
|
174
115
|
*/
|
|
175
|
-
|
|
176
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
177
|
-
'user/profile',
|
|
178
|
-
request,
|
|
179
|
-
{headers}
|
|
180
|
-
);
|
|
116
|
+
static async updateUser(request) {
|
|
117
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/profile', request, { headers });
|
|
181
118
|
return data;
|
|
182
119
|
}
|
|
183
|
-
|
|
184
120
|
/**
|
|
185
121
|
* Checks if a user property value already exists in the system
|
|
186
122
|
* @param prop - The property name to check (e.g., 'email', 'shortname')
|
|
187
123
|
* @param value - The value to check for existence
|
|
188
124
|
* @returns Promise resolving to ResponseEntry indicating if the value exists
|
|
189
125
|
*/
|
|
190
|
-
|
|
191
|
-
const {data} = await Dmart.axiosDmartInstance.get
|
|
192
|
-
`user/check-existing?${prop}=${value}`,
|
|
193
|
-
{headers}
|
|
194
|
-
);
|
|
126
|
+
static async checkExisting(prop, value) {
|
|
127
|
+
const { data } = await Dmart.axiosDmartInstance.get(`user/check-existing?${prop}=${value}`, { headers });
|
|
195
128
|
return data;
|
|
196
129
|
}
|
|
197
|
-
|
|
198
130
|
/**
|
|
199
131
|
* Retrieves the current user's profile information
|
|
200
132
|
* @returns Promise resolving to ProfileResponse containing user profile data, permissions, and roles
|
|
201
133
|
*/
|
|
202
|
-
|
|
203
|
-
const {data} = await Dmart.axiosDmartInstance.get
|
|
134
|
+
static async getProfile() {
|
|
135
|
+
const { data } = await Dmart.axiosDmartInstance.get('user/profile', {
|
|
204
136
|
headers,
|
|
205
137
|
});
|
|
206
138
|
if (typeof localStorage !== "undefined" && data.status === "success") {
|
|
207
|
-
localStorage.setItem(
|
|
208
|
-
|
|
209
|
-
JSON.stringify((data?.records ?? [{}])[0]?.attributes.permissions)
|
|
210
|
-
);
|
|
211
|
-
localStorage.setItem(
|
|
212
|
-
"roles",
|
|
213
|
-
JSON.stringify((data?.records ?? [{}])[0]?.attributes?.["roles"])
|
|
214
|
-
);
|
|
139
|
+
localStorage.setItem("permissions", JSON.stringify((data?.records ?? [{}])[0]?.attributes.permissions));
|
|
140
|
+
localStorage.setItem("roles", JSON.stringify((data?.records ?? [{}])[0]?.attributes?.["roles"]));
|
|
215
141
|
}
|
|
216
142
|
return data;
|
|
217
143
|
}
|
|
218
|
-
|
|
219
144
|
/**
|
|
220
145
|
* Executes a query against the Dmart API to retrieve data
|
|
221
146
|
* @param query - QueryRequest object containing query parameters, filters, and sorting options
|
|
222
147
|
* @param scope - The scope for the query (default: DmartScope.managed)
|
|
223
148
|
* @returns Promise resolving to ApiQueryResponse with query results or null
|
|
224
149
|
*/
|
|
225
|
-
|
|
226
|
-
query: QueryRequest,
|
|
227
|
-
scope: DmartScope = DmartScope.managed
|
|
228
|
-
): Promise<ApiQueryResponse | null> {
|
|
150
|
+
static async query(query, scope = DmartScope.managed) {
|
|
229
151
|
if (query.type !== QueryType.spaces) {
|
|
230
152
|
query.sort_type = query.sort_type || SortType.ascending;
|
|
231
153
|
query.sort_by = query.sort_by || "created_at";
|
|
232
154
|
}
|
|
233
155
|
query.subpath = query.subpath.replace(/\/+/g, "/");
|
|
234
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
235
|
-
`${scope}/query`,
|
|
236
|
-
query,
|
|
237
|
-
{headers}
|
|
238
|
-
);
|
|
156
|
+
const { data } = await Dmart.axiosDmartInstance.post(`${scope}/query`, query, { headers });
|
|
239
157
|
return data;
|
|
240
158
|
}
|
|
241
|
-
|
|
242
159
|
/**
|
|
243
160
|
* Exports query results as CSV format
|
|
244
161
|
* @param query - Query object with parameters for CSV export
|
|
245
162
|
* @returns Promise resolving to ApiQueryResponse containing CSV data
|
|
246
163
|
*/
|
|
247
|
-
|
|
164
|
+
static async csv(query) {
|
|
248
165
|
query.sort_type = query.sort_type || SortType.ascending;
|
|
249
166
|
query.sort_by = "created_at";
|
|
250
167
|
query.subpath = query.subpath.replace(/\/+/g, "/");
|
|
251
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
252
|
-
'managed/csv',
|
|
253
|
-
query,
|
|
254
|
-
{headers}
|
|
255
|
-
);
|
|
168
|
+
const { data } = await Dmart.axiosDmartInstance.post('managed/csv', query, { headers });
|
|
256
169
|
return data;
|
|
257
170
|
}
|
|
258
|
-
|
|
259
171
|
/**
|
|
260
172
|
* Creates resources from an uploaded CSV file
|
|
261
173
|
* @param request - ResourcesFromCSVRequest containing file data and resource configuration
|
|
262
174
|
* @returns Promise resolving to ApiResponse with creation results
|
|
263
175
|
*/
|
|
264
|
-
|
|
265
|
-
request: ResourcesFromCSVRequest
|
|
266
|
-
) {
|
|
176
|
+
static async resourcesFromCsv(request) {
|
|
267
177
|
let csvUrl = `/managed/resources_from_csv/${request.resourceType}/${request.space_name}/${request.subpath}`;
|
|
268
|
-
const params
|
|
178
|
+
const params = {};
|
|
269
179
|
if (request.schema) {
|
|
270
180
|
csvUrl += `/${request.schema}`;
|
|
271
181
|
}
|
|
272
|
-
|
|
273
182
|
const formdata = new FormData();
|
|
274
183
|
formdata.append("resources_file", request.payload);
|
|
275
|
-
|
|
276
184
|
if (request.isUpdate) {
|
|
277
185
|
params['is_update'] = request.isUpdate;
|
|
278
186
|
}
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
283
|
-
csvUrl,
|
|
284
|
-
formdata,
|
|
285
|
-
{headers: multipartHeaders, params}
|
|
286
|
-
);
|
|
287
|
-
|
|
187
|
+
const multipartHeaders = { ...headers, "Content-Type": "multipart/form-data" };
|
|
188
|
+
const { data } = await Dmart.axiosDmartInstance.post(csvUrl, formdata, { headers: multipartHeaders, params });
|
|
288
189
|
return data;
|
|
289
190
|
}
|
|
290
|
-
|
|
291
191
|
// /** LEGACY, DEPRECATED CODE, DO NOT USE
|
|
292
192
|
// * Performs space-level operations (create, update, delete spaces)
|
|
293
193
|
// * @param action - ActionRequest containing the operation details for space management
|
|
@@ -301,116 +201,87 @@ export class Dmart {
|
|
|
301
201
|
// );
|
|
302
202
|
// return data;
|
|
303
203
|
// }
|
|
304
|
-
|
|
305
204
|
/**
|
|
306
205
|
* Executes a general request action against the Dmart API
|
|
307
206
|
* @param action - ActionRequest containing the request details and parameters
|
|
308
207
|
* @returns Promise resolving to ActionResponse with request result
|
|
309
208
|
*/
|
|
310
|
-
|
|
311
|
-
const res = await Dmart.axiosDmartInstance.post
|
|
209
|
+
static async request(action) {
|
|
210
|
+
const res = await Dmart.axiosDmartInstance.post('managed/request', action, {
|
|
312
211
|
headers,
|
|
313
212
|
});
|
|
314
213
|
return res?.data;
|
|
315
214
|
}
|
|
316
|
-
|
|
317
215
|
/**
|
|
318
216
|
* Retrieves a specific entry from the Dmart system
|
|
319
217
|
* @param request - RetrieveEntryRequest containing entry identification and retrieval options
|
|
320
218
|
* @param scope - The scope for the retrieval (default: DmartScope.managed)
|
|
321
219
|
* @returns Promise resolving to ResponseEntry with entry data or null if not found
|
|
322
220
|
*/
|
|
323
|
-
|
|
324
|
-
request: RetrieveEntryRequest,
|
|
325
|
-
scope: DmartScope = DmartScope.managed
|
|
326
|
-
): Promise<ResponseEntry | null> {
|
|
221
|
+
static async retrieveEntry(request, scope = DmartScope.managed) {
|
|
327
222
|
if (request.validate_schema === null) {
|
|
328
223
|
request.validate_schema = true;
|
|
329
224
|
}
|
|
330
|
-
if (!request.subpath || request.subpath === "/")
|
|
225
|
+
if (!request.subpath || request.subpath === "/")
|
|
226
|
+
request.subpath = "__root__";
|
|
331
227
|
const url = `${scope}/entry/${request.resource_type}/${request.space_name}/${request.subpath}/${request.shortname}?retrieve_json_payload=${request.retrieve_json_payload}&retrieve_attachments=${request.retrieve_attachments}&validate_schema=${request.validate_schema}`;
|
|
332
|
-
const {data} = await Dmart.axiosDmartInstance.get
|
|
333
|
-
`${url.replace(/\/+/g, "/")}`,
|
|
334
|
-
{headers}
|
|
335
|
-
);
|
|
228
|
+
const { data } = await Dmart.axiosDmartInstance.get(`${url.replace(/\/+/g, "/")}`, { headers });
|
|
336
229
|
return data;
|
|
337
230
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
231
|
/**
|
|
341
232
|
* Uploads a resource with an attached payload file
|
|
342
233
|
* @param request - UploadWithPayloadRequest containing resource data and payload file
|
|
343
234
|
* @param scope - The scope for the upload operation (default: DmartScope.managed)
|
|
344
235
|
* @returns Promise resolving to ApiResponse with upload result
|
|
345
236
|
*/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
scope: DmartScope = DmartScope.managed
|
|
349
|
-
) {
|
|
350
|
-
const request_record_body: Record<string, any> = {
|
|
237
|
+
static async uploadWithPayload(request, scope = DmartScope.managed) {
|
|
238
|
+
const request_record_body = {
|
|
351
239
|
resource_type: request.resource_type,
|
|
352
240
|
subpath: request.subpath,
|
|
353
241
|
shortname: request.shortname,
|
|
354
242
|
attributes: request.attributes ?? {},
|
|
355
243
|
};
|
|
356
|
-
|
|
357
244
|
if (!request.attributes || Object.keys(request.attributes).length === 0) {
|
|
358
|
-
request_record_body['attributes'] = {is_active: true, payload: {body: {}}};
|
|
359
|
-
}
|
|
245
|
+
request_record_body['attributes'] = { is_active: true, payload: { body: {} } };
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
360
248
|
if (!Object.keys(request.attributes).includes('is_active')) {
|
|
361
249
|
request_record_body['attributes'].is_active = true;
|
|
362
250
|
}
|
|
363
251
|
}
|
|
364
|
-
|
|
365
252
|
const request_record = new Blob([JSON.stringify(request_record_body)], {
|
|
366
253
|
type: "application/json",
|
|
367
254
|
});
|
|
368
|
-
|
|
369
255
|
const form_data = new FormData();
|
|
370
256
|
form_data.append("space_name", request.space_name);
|
|
371
257
|
form_data.append("request_record", request_record);
|
|
372
258
|
form_data.append("payload_file", request.payload_file);
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
377
|
-
`${scope}/resource_with_payload`,
|
|
378
|
-
form_data,
|
|
379
|
-
{headers: _headers}
|
|
380
|
-
);
|
|
381
|
-
|
|
259
|
+
const _headers = { ...headers, "Content-Type": "multipart/form-data" };
|
|
260
|
+
const { data } = await Dmart.axiosDmartInstance.post(`${scope}/resource_with_payload`, form_data, { headers: _headers });
|
|
382
261
|
return data;
|
|
383
262
|
}
|
|
384
|
-
|
|
385
263
|
/**
|
|
386
264
|
* Fetches data assets from the Dmart system with optional SQL query filtering
|
|
387
265
|
* @param request - FetchDataAssetRequest containing asset identification and query parameters
|
|
388
266
|
* @returns Promise resolving to data asset response
|
|
389
267
|
*/
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
shortname: request.shortname,
|
|
401
|
-
query_string: request.query_string ?? "SELECT * FROM file",
|
|
402
|
-
filter_data_assets: request.filter_data_assets,
|
|
403
|
-
},
|
|
404
|
-
{headers}
|
|
405
|
-
);
|
|
268
|
+
static async fetchDataAsset(request) {
|
|
269
|
+
const { data } = await Dmart.axiosDmartInstance.post('managed/data-asset', {
|
|
270
|
+
space_name: request.spaceName,
|
|
271
|
+
resource_type: request.resourceType,
|
|
272
|
+
data_asset_type: request.dataAssetType,
|
|
273
|
+
subpath: request.subpath,
|
|
274
|
+
shortname: request.shortname,
|
|
275
|
+
query_string: request.query_string ?? "SELECT * FROM file",
|
|
276
|
+
filter_data_assets: request.filter_data_assets,
|
|
277
|
+
}, { headers });
|
|
406
278
|
return data;
|
|
407
279
|
}
|
|
408
|
-
|
|
409
280
|
/**
|
|
410
281
|
* Retrieves a list of all available spaces in the system
|
|
411
282
|
* @returns Promise resolving to ApiResponse containing spaces data or null
|
|
412
283
|
*/
|
|
413
|
-
|
|
284
|
+
static async getSpaces() {
|
|
414
285
|
return await this.query({
|
|
415
286
|
type: QueryType.spaces,
|
|
416
287
|
space_name: "management",
|
|
@@ -419,15 +290,12 @@ export class Dmart {
|
|
|
419
290
|
limit: 100,
|
|
420
291
|
});
|
|
421
292
|
}
|
|
422
|
-
|
|
423
293
|
/**
|
|
424
294
|
* Gets child resources within a specified space and subpath
|
|
425
295
|
* @param request - GetChildrenRequest containing search parameters and filters
|
|
426
296
|
* @returns Promise resolving to ApiResponse with child resources or null
|
|
427
297
|
*/
|
|
428
|
-
|
|
429
|
-
request: GetChildrenRequest
|
|
430
|
-
): Promise<ApiResponse | null> {
|
|
298
|
+
static async getChildren(request) {
|
|
431
299
|
if (request.limit === null) {
|
|
432
300
|
request.limit = 20;
|
|
433
301
|
}
|
|
@@ -448,92 +316,62 @@ export class Dmart {
|
|
|
448
316
|
offset: request.offset,
|
|
449
317
|
});
|
|
450
318
|
}
|
|
451
|
-
|
|
452
319
|
/**
|
|
453
320
|
* Generates a URL for accessing attachment resources
|
|
454
321
|
* @param request - GetAttachmentURLRequest containing attachment identification parameters
|
|
455
322
|
* @param scope - The scope for the attachment URL (default: DmartScope.managed)
|
|
456
323
|
* @returns String URL for accessing the attachment
|
|
457
324
|
*/
|
|
458
|
-
|
|
459
|
-
request
|
|
460
|
-
scope: DmartScope = DmartScope.managed
|
|
461
|
-
) {
|
|
462
|
-
const subpath = request.subpath.replace(
|
|
463
|
-
/\/+$/,
|
|
464
|
-
""
|
|
465
|
-
);
|
|
325
|
+
static getAttachmentUrl(request, scope = DmartScope.managed) {
|
|
326
|
+
const subpath = request.subpath.replace(/\/+$/, "");
|
|
466
327
|
return `${Dmart.getAxiosInstance().defaults.baseURL}` + `/${scope}/payload/${request.resource_type}/${request.space_name}/${subpath}/${request.parent_shortname}/${request.shortname}${request.ext === null ? "" : `.${request.ext}`}`.replaceAll('//', '/');
|
|
467
328
|
}
|
|
468
|
-
|
|
469
329
|
/**
|
|
470
330
|
* Retrieves health information and statistics for a specific space
|
|
471
331
|
* @param space_name - The name of the space to check health for
|
|
472
332
|
* @returns Promise resolving to ApiQueryResponse with health data and folders report
|
|
473
333
|
*/
|
|
474
|
-
|
|
475
|
-
const {data} = await Dmart.axiosDmartInstance.get
|
|
476
|
-
ApiQueryResponse & { attributes: { folders_report: Record<string, unknown> } }
|
|
477
|
-
>(`managed/health/${space_name}`, {headers});
|
|
334
|
+
static async getSpaceHealth(space_name) {
|
|
335
|
+
const { data } = await Dmart.axiosDmartInstance.get(`managed/health/${space_name}`, { headers });
|
|
478
336
|
return data;
|
|
479
337
|
}
|
|
480
|
-
|
|
481
338
|
/**
|
|
482
339
|
* Retrieves payload data for a specific resource
|
|
483
340
|
* @param request - GetPayloadRequest containing payload identification parameters
|
|
484
341
|
* @param scope - The scope for the payload retrieval (default: DmartScope.managed)
|
|
485
342
|
* @returns Promise resolving to payload data
|
|
486
343
|
*/
|
|
487
|
-
|
|
488
|
-
request: GetPayloadRequest,
|
|
489
|
-
scope: DmartScope = DmartScope.managed
|
|
490
|
-
) {
|
|
344
|
+
static async getPayload(request, scope = DmartScope.managed) {
|
|
491
345
|
let url = `${scope}/payload/${request.resource_type}/${request.space_name}/${request.subpath}/${request.shortname}`;
|
|
492
|
-
|
|
493
346
|
if (request.schemaShortname) {
|
|
494
347
|
url += `.${request.schemaShortname}`;
|
|
495
348
|
}
|
|
496
349
|
url += `.${request.ext}`;
|
|
497
|
-
const {data} = await Dmart.axiosDmartInstance.get
|
|
498
|
-
url,
|
|
499
|
-
{headers}
|
|
500
|
-
);
|
|
350
|
+
const { data } = await Dmart.axiosDmartInstance.get(url, { headers });
|
|
501
351
|
return data;
|
|
502
352
|
}
|
|
503
|
-
|
|
504
353
|
/**
|
|
505
354
|
* Updates the progress of a ticket with resolution and comments
|
|
506
355
|
* @param request - ProgressTicketRequest containing ticket identification and update data
|
|
507
356
|
* @returns Promise resolving to ApiQueryResponse with progress update result
|
|
508
357
|
*/
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
) {
|
|
512
|
-
const payload: Record<string, string> = {};
|
|
358
|
+
static async progressTicket(request) {
|
|
359
|
+
const payload = {};
|
|
513
360
|
if (request.resolution) {
|
|
514
361
|
payload['resolution'] = request.resolution;
|
|
515
362
|
}
|
|
516
363
|
if (request.comment) {
|
|
517
364
|
payload['comment'] = request.comment;
|
|
518
365
|
}
|
|
519
|
-
const {data} = await Dmart.axiosDmartInstance.put
|
|
520
|
-
ApiQueryResponse & { attributes: { folders_report: Record<string, unknown> } }
|
|
521
|
-
>(
|
|
522
|
-
`managed/progress-ticket/${request.space_name}/${request.subpath}/${request.shortname}/${request.action}`,
|
|
523
|
-
payload,
|
|
524
|
-
{headers}
|
|
525
|
-
);
|
|
366
|
+
const { data } = await Dmart.axiosDmartInstance.put(`managed/progress-ticket/${request.space_name}/${request.subpath}/${request.shortname}/${request.action}`, payload, { headers });
|
|
526
367
|
return data;
|
|
527
368
|
}
|
|
528
|
-
|
|
529
369
|
/**
|
|
530
370
|
* Submits data to a public endpoint with optional workflow processing
|
|
531
371
|
* @param request - SubmitRequest containing submission data and routing information
|
|
532
372
|
* @returns Promise resolving to submission response data
|
|
533
373
|
*/
|
|
534
|
-
|
|
535
|
-
request: SubmitRequest
|
|
536
|
-
) {
|
|
374
|
+
static async submit(request) {
|
|
537
375
|
let url = `public/submit/${request.spaceName}`;
|
|
538
376
|
if (request.resourceType) {
|
|
539
377
|
url += `/${request.resourceType}`;
|
|
@@ -542,135 +380,92 @@ export class Dmart {
|
|
|
542
380
|
url += `/${request.workflowShortname}`;
|
|
543
381
|
}
|
|
544
382
|
url += `/${request.schemaShortname}/${request.subpath}`;
|
|
545
|
-
const {data} = await Dmart.axiosDmartInstance.post(
|
|
546
|
-
url,
|
|
547
|
-
request.record,
|
|
548
|
-
{headers}
|
|
549
|
-
);
|
|
383
|
+
const { data } = await Dmart.axiosDmartInstance.post(url, request.record, { headers });
|
|
550
384
|
return data;
|
|
551
385
|
}
|
|
552
|
-
|
|
553
386
|
/**
|
|
554
387
|
* Retrieves the system manifest containing configuration and metadata
|
|
555
388
|
* @returns Promise resolving to manifest data
|
|
556
389
|
*/
|
|
557
|
-
|
|
558
|
-
const {data} = await Dmart.axiosDmartInstance.get
|
|
390
|
+
static async getManifest() {
|
|
391
|
+
const { data } = await Dmart.axiosDmartInstance.get('info/manifest', {
|
|
559
392
|
headers,
|
|
560
393
|
});
|
|
561
394
|
return data;
|
|
562
395
|
}
|
|
563
|
-
|
|
564
396
|
/**
|
|
565
397
|
* Retrieves the system settings and configuration
|
|
566
398
|
* @returns Promise resolving to settings data
|
|
567
399
|
*/
|
|
568
|
-
|
|
569
|
-
const {data} = await Dmart.axiosDmartInstance.get
|
|
400
|
+
static async getSettings() {
|
|
401
|
+
const { data } = await Dmart.axiosDmartInstance.get('info/settings', {
|
|
570
402
|
headers,
|
|
571
403
|
});
|
|
572
404
|
return data;
|
|
573
405
|
}
|
|
574
|
-
|
|
575
406
|
/**
|
|
576
407
|
* Sends an OTP (One-Time Password) request to a user
|
|
577
408
|
* @param request - SendOTPRequest containing recipient information
|
|
578
409
|
* @param acceptLanguage - Optional language preference for the OTP message (default: null)
|
|
579
410
|
* @returns Promise resolving to ApiResponse with OTP request result
|
|
580
411
|
*/
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
acceptLanguage: string | null = null
|
|
584
|
-
) {
|
|
585
|
-
const requestHeaders = {...headers};
|
|
412
|
+
static async otpRequest(request, acceptLanguage = null) {
|
|
413
|
+
const requestHeaders = { ...headers };
|
|
586
414
|
if (acceptLanguage) {
|
|
587
415
|
requestHeaders['Accept-Language'] = acceptLanguage;
|
|
588
416
|
}
|
|
589
|
-
|
|
590
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
591
|
-
'user/otp-request',
|
|
592
|
-
request,
|
|
593
|
-
{headers: requestHeaders}
|
|
594
|
-
);
|
|
417
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/otp-request', request, { headers: requestHeaders });
|
|
595
418
|
return data;
|
|
596
419
|
}
|
|
597
|
-
|
|
598
420
|
/**
|
|
599
421
|
* Sends an OTP (One-Time Password) request for login purposes
|
|
600
422
|
* @param request - SendOTPRequest containing recipient information for login OTP
|
|
601
423
|
* @param acceptLanguage - Optional language preference for the OTP message (default: null)
|
|
602
424
|
* @returns Promise resolving to ApiResponse with OTP login request result
|
|
603
425
|
*/
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
acceptLanguage: string | null = null
|
|
607
|
-
) {
|
|
608
|
-
const requestHeaders = {...headers};
|
|
426
|
+
static async otpRequestLogin(request, acceptLanguage = null) {
|
|
427
|
+
const requestHeaders = { ...headers };
|
|
609
428
|
if (acceptLanguage) {
|
|
610
429
|
requestHeaders['Accept-Language'] = acceptLanguage;
|
|
611
430
|
}
|
|
612
|
-
|
|
613
|
-
const {data} = await Dmart.axiosDmartInstance.post<ApiResponse>(
|
|
614
|
-
'user/otp-request-login',
|
|
615
|
-
request,
|
|
616
|
-
{headers: requestHeaders}
|
|
617
|
-
);
|
|
431
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/otp-request-login', request, { headers: requestHeaders });
|
|
618
432
|
return data;
|
|
619
433
|
}
|
|
620
|
-
|
|
621
434
|
/**
|
|
622
435
|
* Initiates a password reset request for a user
|
|
623
436
|
* @param request - PasswordResetRequest containing user identification for password reset
|
|
624
437
|
* @returns Promise resolving to ApiResponse with password reset request result
|
|
625
438
|
*/
|
|
626
|
-
|
|
627
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
628
|
-
'user/password-reset-request',
|
|
629
|
-
request,
|
|
630
|
-
{headers}
|
|
631
|
-
);
|
|
439
|
+
static async passwordResetRequest(request) {
|
|
440
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/password-reset-request', request, { headers });
|
|
632
441
|
return data;
|
|
633
442
|
}
|
|
634
|
-
|
|
635
443
|
/**
|
|
636
444
|
* Confirms an OTP (One-Time Password) code provided by the user
|
|
637
445
|
* @param request - ConfirmOTPRequest containing the OTP code and verification details
|
|
638
446
|
* @returns Promise resolving to ApiResponse with OTP confirmation result
|
|
639
447
|
*/
|
|
640
|
-
|
|
641
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
642
|
-
'user/otp-confirm',
|
|
643
|
-
request,
|
|
644
|
-
{headers}
|
|
645
|
-
);
|
|
448
|
+
static async confirmOtp(request) {
|
|
449
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/otp-confirm', request, { headers });
|
|
646
450
|
return data;
|
|
647
451
|
}
|
|
648
|
-
|
|
649
452
|
/**
|
|
650
453
|
* Resets a user's account or session state
|
|
651
454
|
* @param shortname - The shortname (username) of the user to reset
|
|
652
455
|
* @returns Promise resolving to ApiResponse with user reset result
|
|
653
456
|
*/
|
|
654
|
-
|
|
655
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
656
|
-
'user/reset',
|
|
657
|
-
{shortname},
|
|
658
|
-
{headers}
|
|
659
|
-
);
|
|
457
|
+
static async userReset(shortname) {
|
|
458
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/reset', { shortname }, { headers });
|
|
660
459
|
return data;
|
|
661
460
|
}
|
|
662
|
-
|
|
663
461
|
/**
|
|
664
462
|
* Validates a password against system password policies and requirements
|
|
665
463
|
* @param password - The password string to validate
|
|
666
464
|
* @returns Promise resolving to ApiResponse with validation result
|
|
667
465
|
*/
|
|
668
|
-
|
|
669
|
-
const {data} = await Dmart.axiosDmartInstance.post
|
|
670
|
-
'user/validate_password',
|
|
671
|
-
{password},
|
|
672
|
-
{headers}
|
|
673
|
-
);
|
|
466
|
+
static async validatePassword(password) {
|
|
467
|
+
const { data } = await Dmart.axiosDmartInstance.post('user/validate_password', { password }, { headers });
|
|
674
468
|
return data;
|
|
675
469
|
}
|
|
676
470
|
}
|
|
471
|
+
//# sourceMappingURL=dmart.service.js.map
|