@edraj/tsdmart 1.0.1 → 1.0.3
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/tsdmart.iml +1 -0
- package/index.ts +22 -22
- package/package.json +1 -1
- package/b/axios.js +0 -9
- package/b/axios.ts +0 -36
- package/b/http.ts +0 -76
package/.idea/tsdmart.iml
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
7
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
8
|
<excludeFolder url="file://$MODULE_DIR$/b" />
|
|
9
|
+
<excludeFolder url="file://$MODULE_DIR$/.idea/copilot/chatSessions" />
|
|
9
10
|
</content>
|
|
10
11
|
<orderEntry type="inheritedJdk" />
|
|
11
12
|
<orderEntry type="sourceFolder" forTests="false" />
|
package/index.ts
CHANGED
|
@@ -319,7 +319,7 @@ type ApiQueryResponse = ApiResponse & {
|
|
|
319
319
|
};
|
|
320
320
|
|
|
321
321
|
export class Dmart {
|
|
322
|
-
public async login(shortname: string, password: string) {
|
|
322
|
+
public static async login(shortname: string, password: string) {
|
|
323
323
|
const { data } = await axios.post<
|
|
324
324
|
ApiResponse & { records: Array<LoginResponseRecord> }
|
|
325
325
|
>(baseURL + "/user/login", { shortname, password }, { headers });
|
|
@@ -332,7 +332,7 @@ export class Dmart {
|
|
|
332
332
|
return data;
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
public async logout() {
|
|
335
|
+
public static async logout() {
|
|
336
336
|
const { data } = await axios.post<ApiResponse>(
|
|
337
337
|
baseURL + "/user/logout",
|
|
338
338
|
{},
|
|
@@ -341,7 +341,7 @@ export class Dmart {
|
|
|
341
341
|
return data;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
public async create_user(request: any) {
|
|
344
|
+
public static async create_user(request: any) {
|
|
345
345
|
try {
|
|
346
346
|
const { data } = await axios.post<ActionResponse>(
|
|
347
347
|
baseURL + "/user/create",
|
|
@@ -354,7 +354,7 @@ export class Dmart {
|
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
public async update_user(request: any) {
|
|
357
|
+
public static async update_user(request: any) {
|
|
358
358
|
try {
|
|
359
359
|
const { data } = await axios.post<ActionResponse>(
|
|
360
360
|
baseURL + "/user/profile",
|
|
@@ -367,7 +367,7 @@ export class Dmart {
|
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
public async check_existing(prop: string, value: string) {
|
|
370
|
+
public static async check_existing(prop: string, value: string) {
|
|
371
371
|
try {
|
|
372
372
|
const { data } = await axios.get<ResponseEntry>(
|
|
373
373
|
baseURL +
|
|
@@ -380,7 +380,7 @@ export class Dmart {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
public async get_profile() {
|
|
383
|
+
public static async get_profile() {
|
|
384
384
|
try {
|
|
385
385
|
const { data } = await axios.get<ProfileResponse>(
|
|
386
386
|
baseURL + "/user/profile",
|
|
@@ -404,7 +404,7 @@ export class Dmart {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
public async query(query: QueryRequest): Promise<ApiQueryResponse|null> {
|
|
407
|
+
public static async query(query: QueryRequest): Promise<ApiQueryResponse|null> {
|
|
408
408
|
try {
|
|
409
409
|
if (query.type != QueryType.spaces) {
|
|
410
410
|
query.sort_type = query.sort_type || SortyType.ascending;
|
|
@@ -422,7 +422,7 @@ export class Dmart {
|
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
public async csv(query: any): Promise<ApiQueryResponse> {
|
|
425
|
+
public static async csv(query: any): Promise<ApiQueryResponse> {
|
|
426
426
|
try {
|
|
427
427
|
query.sort_type = query.sort_type || SortyType.ascending;
|
|
428
428
|
query.sort_by = "created_at";
|
|
@@ -438,7 +438,7 @@ export class Dmart {
|
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
public async space(action: ActionRequest): Promise<ActionResponse> {
|
|
441
|
+
public static async space(action: ActionRequest): Promise<ActionResponse> {
|
|
442
442
|
try {
|
|
443
443
|
const { data } = await axios.post<ActionResponse>(
|
|
444
444
|
baseURL + "/managed/space",
|
|
@@ -451,7 +451,7 @@ export class Dmart {
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
-
public async request(action: ActionRequest): Promise<ActionResponse> {
|
|
454
|
+
public static async request(action: ActionRequest): Promise<ActionResponse> {
|
|
455
455
|
try {
|
|
456
456
|
const { data } = await axios.post<ActionResponse>(
|
|
457
457
|
baseURL + "/managed/request",
|
|
@@ -464,7 +464,7 @@ export class Dmart {
|
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
|
|
467
|
-
public async retrieve_entry(
|
|
467
|
+
public static async retrieve_entry(
|
|
468
468
|
resource_type: ResourceType,
|
|
469
469
|
space_name: string,
|
|
470
470
|
subpath: string,
|
|
@@ -489,7 +489,7 @@ export class Dmart {
|
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
public async upload_with_payload(
|
|
492
|
+
public static async upload_with_payload(
|
|
493
493
|
space_name: string,
|
|
494
494
|
subpath: string,
|
|
495
495
|
shortname: string,
|
|
@@ -535,7 +535,7 @@ export class Dmart {
|
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
|
|
538
|
-
public async fetchDataAsset(
|
|
538
|
+
public static async fetchDataAsset(
|
|
539
539
|
resourceType: string, // Replace with actual type if needed
|
|
540
540
|
dataAssetType: string, // Replace with actual type if needed
|
|
541
541
|
spaceName: string,
|
|
@@ -569,7 +569,7 @@ export class Dmart {
|
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
-
public async get_spaces(): Promise<ApiResponse | null> {
|
|
572
|
+
public static async get_spaces(): Promise<ApiResponse | null> {
|
|
573
573
|
return await this.query({
|
|
574
574
|
type: QueryType.spaces,
|
|
575
575
|
space_name: "management",
|
|
@@ -579,7 +579,7 @@ export class Dmart {
|
|
|
579
579
|
});
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
-
public async get_children(
|
|
582
|
+
public static async get_children(
|
|
583
583
|
space_name: string,
|
|
584
584
|
subpath: string,
|
|
585
585
|
limit: number = 20,
|
|
@@ -615,14 +615,14 @@ export class Dmart {
|
|
|
615
615
|
);
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
-
public async get_space_health(space_name: string) {
|
|
618
|
+
public static async get_space_health(space_name: string) {
|
|
619
619
|
const { data } = await axios.get<
|
|
620
620
|
ApiQueryResponse & { attributes: { folders_report: Object } }
|
|
621
621
|
>(baseURL + `/managed/health/${space_name}`, { headers });
|
|
622
622
|
return data;
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
-
public async get_attachment_content(
|
|
625
|
+
public static async get_attachment_content(
|
|
626
626
|
resource_type: string,
|
|
627
627
|
space_name: string,
|
|
628
628
|
subpath: string,
|
|
@@ -635,7 +635,7 @@ export class Dmart {
|
|
|
635
635
|
);
|
|
636
636
|
return data;
|
|
637
637
|
}
|
|
638
|
-
public async get_payload(
|
|
638
|
+
public static async get_payload(
|
|
639
639
|
resource_type: string,
|
|
640
640
|
space_name: string,
|
|
641
641
|
subpath: string,
|
|
@@ -649,7 +649,7 @@ export class Dmart {
|
|
|
649
649
|
);
|
|
650
650
|
return data;
|
|
651
651
|
}
|
|
652
|
-
public async get_payload_content(
|
|
652
|
+
public static async get_payload_content(
|
|
653
653
|
resource_type: string,
|
|
654
654
|
space_name: string,
|
|
655
655
|
subpath: string,
|
|
@@ -664,7 +664,7 @@ export class Dmart {
|
|
|
664
664
|
return data;
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
-
public async progress_ticket(
|
|
667
|
+
public static async progress_ticket(
|
|
668
668
|
space_name: string,
|
|
669
669
|
subpath: string,
|
|
670
670
|
shortname: string,
|
|
@@ -694,14 +694,14 @@ export class Dmart {
|
|
|
694
694
|
}
|
|
695
695
|
}
|
|
696
696
|
|
|
697
|
-
public async get_manifest() {
|
|
697
|
+
public static async get_manifest() {
|
|
698
698
|
const { data } = await axios.get<any>(baseURL + `/info/manifest`, {
|
|
699
699
|
headers,
|
|
700
700
|
});
|
|
701
701
|
return data;
|
|
702
702
|
}
|
|
703
703
|
|
|
704
|
-
public async get_settings() {
|
|
704
|
+
public static async get_settings() {
|
|
705
705
|
const { data } = await axios.get<any>(baseURL + `/info/settings`, {
|
|
706
706
|
headers,
|
|
707
707
|
});
|
package/package.json
CHANGED
package/b/axios.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
// import axios from 'axios';
|
|
3
|
-
var postData = {
|
|
4
|
-
password: 'Password1234',
|
|
5
|
-
shortname: 'dmart'
|
|
6
|
-
};
|
|
7
|
-
var url = 'https://dmart.cc/dmart/user/login'; // Example endpoint
|
|
8
|
-
var response = await axios.post(url, postData);
|
|
9
|
-
console.log(response.data);
|
package/b/axios.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
|
|
4
|
-
let response = await axios.post('https://dmart.cc/dmart/user/login', {
|
|
5
|
-
password: 'Password1234',
|
|
6
|
-
shortname: 'dmart'
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
let config = {
|
|
10
|
-
method: 'post',
|
|
11
|
-
maxBodyLength: Infinity,
|
|
12
|
-
url: 'https://dmart.cc/dmart/managed/query',
|
|
13
|
-
headers: {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVzZXJuYW1lIjoiamltbXkifSwiZXhwaXJlcyI6MTcxMzI2ODQ3Ni43NDEzMjR9.pEmHFJFv1x43WGIhKNfSL5PVr2zI06yeOQv7QGojtQk'
|
|
16
|
-
},
|
|
17
|
-
data: JSON.stringify({
|
|
18
|
-
"type": "subpath",
|
|
19
|
-
"space_name": "management",
|
|
20
|
-
"subpath": "users",
|
|
21
|
-
"sort_by": "created_at",
|
|
22
|
-
"sort_type": "ascending",
|
|
23
|
-
"retrieve_json_payload": true
|
|
24
|
-
})
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// for (let i = 0; i < 100; i++) {
|
|
29
|
-
// await axios.request(config);
|
|
30
|
-
// }
|
|
31
|
-
|
|
32
|
-
const requests = [];
|
|
33
|
-
for (let i = 0; i < 1000; i++) {
|
|
34
|
-
requests.push(axios.request(config));
|
|
35
|
-
}
|
|
36
|
-
await Promise.all(requests);
|
package/b/http.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import https from 'https';
|
|
2
|
-
|
|
3
|
-
// Function to make a POST request
|
|
4
|
-
function makePostRequest(url: any, data: any, headers: any) {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
const options = {
|
|
7
|
-
method: 'POST',
|
|
8
|
-
headers: {
|
|
9
|
-
...headers,
|
|
10
|
-
'Content-Type': 'application/json'
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const req = https.request(url, options, (res) => {
|
|
15
|
-
let responseData = '';
|
|
16
|
-
res.on('data', (chunk) => {
|
|
17
|
-
responseData += chunk;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
res.on('end', () => {
|
|
21
|
-
resolve(responseData);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
req.on('error', (error) => {
|
|
26
|
-
reject(error);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
req.write(JSON.stringify(data));
|
|
30
|
-
req.end();
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Main logic
|
|
35
|
-
async function main() {
|
|
36
|
-
// Login request
|
|
37
|
-
let loginResponse: any = await makePostRequest('https://dmart.cc/dmart/user/login', {
|
|
38
|
-
password: 'Password1234',
|
|
39
|
-
shortname: 'dmart'
|
|
40
|
-
}, {});
|
|
41
|
-
const token = JSON.parse(loginResponse).records[0].attributes.access_token;
|
|
42
|
-
// Use the login response to generate the authorization header
|
|
43
|
-
let authHeader = `Bearer ${token}`;
|
|
44
|
-
|
|
45
|
-
// Request config
|
|
46
|
-
let config = {
|
|
47
|
-
method: 'post',
|
|
48
|
-
maxBodyLength: Infinity,
|
|
49
|
-
url: 'https://dmart.cc/dmart/managed/query',
|
|
50
|
-
headers: {
|
|
51
|
-
'Authorization': authHeader,
|
|
52
|
-
'Content-Type': 'application/json'
|
|
53
|
-
},
|
|
54
|
-
data: {
|
|
55
|
-
"type": "subpath",
|
|
56
|
-
"space_name": "management",
|
|
57
|
-
"subpath": "users",
|
|
58
|
-
"sort_by": "created_at",
|
|
59
|
-
"sort_type": "ascending",
|
|
60
|
-
"retrieve_json_payload": true
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// Making 100 requests
|
|
65
|
-
// for (let i = 0; i < 100; i++) {
|
|
66
|
-
// await makePostRequest(config.url, config.data, config.headers);
|
|
67
|
-
// }
|
|
68
|
-
const requests = [];
|
|
69
|
-
for (let i = 0; i < 500; i++) {
|
|
70
|
-
requests.push(makePostRequest(config.url, config.data, config.headers));
|
|
71
|
-
}
|
|
72
|
-
await Promise.all(requests);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Call main function
|
|
76
|
-
main();
|