ts-mailcow-api 0.8.4 → 0.9.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/LICENSE +661 -661
- package/dist/Endpoints/alias-endpoints.d.ts +33 -33
- package/dist/Endpoints/alias-endpoints.js +25 -26
- package/dist/Endpoints/alias-endpoints.js.map +1 -1
- package/dist/Endpoints/antispam-endpoints.d.ts +28 -28
- package/dist/Endpoints/antispam-endpoints.js +21 -22
- package/dist/Endpoints/antispam-endpoints.js.map +1 -1
- package/dist/Endpoints/domain-endpoints.d.ts +33 -33
- package/dist/Endpoints/domain-endpoints.js +25 -26
- package/dist/Endpoints/domain-endpoints.js.map +1 -1
- package/dist/Endpoints/forwarding-endpoints.d.ts +27 -27
- package/dist/Endpoints/forwarding-endpoints.js +21 -22
- package/dist/Endpoints/forwarding-endpoints.js.map +1 -1
- package/dist/Endpoints/log-endpoints.d.ts +55 -55
- package/dist/Endpoints/log-endpoints.js +37 -38
- package/dist/Endpoints/log-endpoints.js.map +1 -1
- package/dist/Endpoints/mailbox-endpoint.d.ts +58 -58
- package/dist/Endpoints/mailbox-endpoint.js +40 -41
- package/dist/Endpoints/mailbox-endpoint.js.map +1 -1
- package/dist/Endpoints/syncjob-endpoints.d.ts +24 -24
- package/dist/Endpoints/syncjob-endpoints.js +19 -20
- package/dist/Endpoints/syncjob-endpoints.js.map +1 -1
- package/dist/index.d.ts +86 -86
- package/dist/index.js +82 -82
- package/dist/index.js.map +1 -1
- package/dist/request-factory.d.ts +27 -27
- package/dist/request-factory.js +87 -88
- package/dist/request-factory.js.map +1 -1
- package/dist/types.d.ts +1313 -1313
- package/dist/types.js +9 -9
- package/package.json +15 -16
- package/src/types.ts +1393 -1393
package/dist/index.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @module MailcowClient
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const domain_endpoints_1 = require("./Endpoints/domain-endpoints");
|
|
7
|
-
const antispam_endpoints_1 = require("./Endpoints/antispam-endpoints");
|
|
8
|
-
const mailbox_endpoint_1 = require("./Endpoints/mailbox-endpoint");
|
|
9
|
-
const request_factory_1 = require("./request-factory");
|
|
10
|
-
const alias_endpoints_1 = require("./Endpoints/alias-endpoints");
|
|
11
|
-
const syncjob_endpoints_1 = require("./Endpoints/syncjob-endpoints");
|
|
12
|
-
const forwarding_endpoints_1 = require("./Endpoints/forwarding-endpoints");
|
|
13
|
-
const log_endpoints_1 = require("./Endpoints/log-endpoints");
|
|
14
|
-
/**
|
|
15
|
-
* Class containing all the logic to interface with the Mailcow API in TypeScript.
|
|
16
|
-
* @external
|
|
17
|
-
*/
|
|
18
|
-
class MailcowClient {
|
|
19
|
-
/**
|
|
20
|
-
* Creates a MailcowClient using the given URL and API key.
|
|
21
|
-
* @param BASE_URL - The base URL of the Mailcow API.
|
|
22
|
-
* @param API_KEY - The API key of the Mailcow API.
|
|
23
|
-
* @param EXTRA_AXIOS_CONFIG - Allows for setting extra Axios request config such as keep alive.
|
|
24
|
-
*/
|
|
25
|
-
constructor(BASE_URL, API_KEY, EXTRA_AXIOS_CONFIG) {
|
|
26
|
-
/**
|
|
27
|
-
* Factory method pattern for creating HTTP requests.
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
this.requestFactory = new request_factory_1.default(this);
|
|
31
|
-
/**
|
|
32
|
-
* All endpoints related to Aliases.
|
|
33
|
-
* See {@link AliasEndpoints}
|
|
34
|
-
* @external
|
|
35
|
-
*/
|
|
36
|
-
this.aliases = alias_endpoints_1.aliasEndpoints(this);
|
|
37
|
-
/**
|
|
38
|
-
* All endpoints related to Domains.
|
|
39
|
-
* See {@link DomainEndpoints}
|
|
40
|
-
* @external
|
|
41
|
-
*/
|
|
42
|
-
this.domains = domain_endpoints_1.domainEndpoints(this);
|
|
43
|
-
/**
|
|
44
|
-
* All endpoints related to spam policies.
|
|
45
|
-
* See {@link AntiSpamEndpoints}
|
|
46
|
-
* @external
|
|
47
|
-
*/
|
|
48
|
-
this.spamPolicy = antispam_endpoints_1.antiSpamEndpoints(this);
|
|
49
|
-
/**
|
|
50
|
-
* All endpoints related to mailboxes.
|
|
51
|
-
* See {@link MailboxEndpoints}
|
|
52
|
-
* @external
|
|
53
|
-
*/
|
|
54
|
-
this.mailbox = mailbox_endpoint_1.mailboxEndpoints(this);
|
|
55
|
-
/**
|
|
56
|
-
* All endpoints related to sync jobs.
|
|
57
|
-
* See {@link SyncjobEndpoints}
|
|
58
|
-
* @external
|
|
59
|
-
*/
|
|
60
|
-
this.syncjobs = syncjob_endpoints_1.syncjobEndpoints(this);
|
|
61
|
-
/**
|
|
62
|
-
* All endpoints related to forwarding hosts.
|
|
63
|
-
* See {@link ForwardingEndpoints}
|
|
64
|
-
* @external
|
|
65
|
-
*/
|
|
66
|
-
this.forwardingHosts = forwarding_endpoints_1.forwardingEndpoints(this);
|
|
67
|
-
/**
|
|
68
|
-
* All endpoints related to logs.
|
|
69
|
-
* See {@link LogEndpoints}
|
|
70
|
-
* @external
|
|
71
|
-
*/
|
|
72
|
-
this.logs = log_endpoints_1.logEndpoints(this);
|
|
73
|
-
this.BASE_URL = BASE_URL.charAt(BASE_URL.length - 1) === '/' ? BASE_URL : BASE_URL.concat('/');
|
|
74
|
-
this.API_KEY = API_KEY;
|
|
75
|
-
// Set the correct Axios headers.
|
|
76
|
-
this.HEADERS = Object.assign({ headers: {
|
|
77
|
-
'Content-Type': 'application/json',
|
|
78
|
-
'X-API-Key': this.API_KEY
|
|
79
|
-
} }, EXTRA_AXIOS_CONFIG);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.default = MailcowClient;
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module MailcowClient
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const domain_endpoints_1 = require("./Endpoints/domain-endpoints");
|
|
7
|
+
const antispam_endpoints_1 = require("./Endpoints/antispam-endpoints");
|
|
8
|
+
const mailbox_endpoint_1 = require("./Endpoints/mailbox-endpoint");
|
|
9
|
+
const request_factory_1 = require("./request-factory");
|
|
10
|
+
const alias_endpoints_1 = require("./Endpoints/alias-endpoints");
|
|
11
|
+
const syncjob_endpoints_1 = require("./Endpoints/syncjob-endpoints");
|
|
12
|
+
const forwarding_endpoints_1 = require("./Endpoints/forwarding-endpoints");
|
|
13
|
+
const log_endpoints_1 = require("./Endpoints/log-endpoints");
|
|
14
|
+
/**
|
|
15
|
+
* Class containing all the logic to interface with the Mailcow API in TypeScript.
|
|
16
|
+
* @external
|
|
17
|
+
*/
|
|
18
|
+
class MailcowClient {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a MailcowClient using the given URL and API key.
|
|
21
|
+
* @param BASE_URL - The base URL of the Mailcow API.
|
|
22
|
+
* @param API_KEY - The API key of the Mailcow API.
|
|
23
|
+
* @param EXTRA_AXIOS_CONFIG - Allows for setting extra Axios request config such as keep alive.
|
|
24
|
+
*/
|
|
25
|
+
constructor(BASE_URL, API_KEY, EXTRA_AXIOS_CONFIG) {
|
|
26
|
+
/**
|
|
27
|
+
* Factory method pattern for creating HTTP requests.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
this.requestFactory = new request_factory_1.default(this);
|
|
31
|
+
/**
|
|
32
|
+
* All endpoints related to Aliases.
|
|
33
|
+
* See {@link AliasEndpoints}
|
|
34
|
+
* @external
|
|
35
|
+
*/
|
|
36
|
+
this.aliases = (0, alias_endpoints_1.aliasEndpoints)(this);
|
|
37
|
+
/**
|
|
38
|
+
* All endpoints related to Domains.
|
|
39
|
+
* See {@link DomainEndpoints}
|
|
40
|
+
* @external
|
|
41
|
+
*/
|
|
42
|
+
this.domains = (0, domain_endpoints_1.domainEndpoints)(this);
|
|
43
|
+
/**
|
|
44
|
+
* All endpoints related to spam policies.
|
|
45
|
+
* See {@link AntiSpamEndpoints}
|
|
46
|
+
* @external
|
|
47
|
+
*/
|
|
48
|
+
this.spamPolicy = (0, antispam_endpoints_1.antiSpamEndpoints)(this);
|
|
49
|
+
/**
|
|
50
|
+
* All endpoints related to mailboxes.
|
|
51
|
+
* See {@link MailboxEndpoints}
|
|
52
|
+
* @external
|
|
53
|
+
*/
|
|
54
|
+
this.mailbox = (0, mailbox_endpoint_1.mailboxEndpoints)(this);
|
|
55
|
+
/**
|
|
56
|
+
* All endpoints related to sync jobs.
|
|
57
|
+
* See {@link SyncjobEndpoints}
|
|
58
|
+
* @external
|
|
59
|
+
*/
|
|
60
|
+
this.syncjobs = (0, syncjob_endpoints_1.syncjobEndpoints)(this);
|
|
61
|
+
/**
|
|
62
|
+
* All endpoints related to forwarding hosts.
|
|
63
|
+
* See {@link ForwardingEndpoints}
|
|
64
|
+
* @external
|
|
65
|
+
*/
|
|
66
|
+
this.forwardingHosts = (0, forwarding_endpoints_1.forwardingEndpoints)(this);
|
|
67
|
+
/**
|
|
68
|
+
* All endpoints related to logs.
|
|
69
|
+
* See {@link LogEndpoints}
|
|
70
|
+
* @external
|
|
71
|
+
*/
|
|
72
|
+
this.logs = (0, log_endpoints_1.logEndpoints)(this);
|
|
73
|
+
this.BASE_URL = BASE_URL.charAt(BASE_URL.length - 1) === '/' ? BASE_URL : BASE_URL.concat('/');
|
|
74
|
+
this.API_KEY = API_KEY;
|
|
75
|
+
// Set the correct Axios headers.
|
|
76
|
+
this.HEADERS = Object.assign({ headers: {
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
'X-API-Key': this.API_KEY
|
|
79
|
+
} }, EXTRA_AXIOS_CONFIG);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = MailcowClient;
|
|
83
83
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"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A;QAlE5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/F,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,iCAAiC;QACjC,IAAI,CAAC,OAAO,mBACV,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,WAAW,EAAE,IAAI,CAAC,OAAO;aAC1B,IACE,kBAAkB,CACtB,CAAC;IACJ,CAAC;CAwDF;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Payload } from './types';
|
|
2
|
-
import MailcowClient from './index';
|
|
3
|
-
/**
|
|
4
|
-
* Function that wraps T | T[] to T[]
|
|
5
|
-
* @internal
|
|
6
|
-
* @param promise - The promise of which the output to wrap.
|
|
7
|
-
*/
|
|
8
|
-
export declare function wrapPromiseToArray<T>(promise: Promise<T | T[]>): Promise<T[]>;
|
|
9
|
-
/**
|
|
10
|
-
* Factory method patterns for creating Axios Requests.
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export default class RequestFactory {
|
|
14
|
-
private ctx;
|
|
15
|
-
constructor(ctx: MailcowClient);
|
|
16
|
-
/**
|
|
17
|
-
* POST Request Factory
|
|
18
|
-
* @param route - The route to which to send the request.
|
|
19
|
-
* @param payload - The payload to send with the request.
|
|
20
|
-
*/
|
|
21
|
-
post<T>(route: string, payload: Payload): Promise<T>;
|
|
22
|
-
/**
|
|
23
|
-
* GET Request Factory
|
|
24
|
-
* @param route - The route to which to send the request.
|
|
25
|
-
*/
|
|
26
|
-
get<T>(route: string): Promise<T>;
|
|
27
|
-
}
|
|
1
|
+
import { Payload } from './types';
|
|
2
|
+
import MailcowClient from './index';
|
|
3
|
+
/**
|
|
4
|
+
* Function that wraps T | T[] to T[]
|
|
5
|
+
* @internal
|
|
6
|
+
* @param promise - The promise of which the output to wrap.
|
|
7
|
+
*/
|
|
8
|
+
export declare function wrapPromiseToArray<T>(promise: Promise<T | T[]>): Promise<T[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Factory method patterns for creating Axios Requests.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export default class RequestFactory {
|
|
14
|
+
private ctx;
|
|
15
|
+
constructor(ctx: MailcowClient);
|
|
16
|
+
/**
|
|
17
|
+
* POST Request Factory
|
|
18
|
+
* @param route - The route to which to send the request.
|
|
19
|
+
* @param payload - The payload to send with the request.
|
|
20
|
+
*/
|
|
21
|
+
post<T>(route: string, payload: Payload): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* GET Request Factory
|
|
24
|
+
* @param route - The route to which to send the request.
|
|
25
|
+
*/
|
|
26
|
+
get<T>(route: string): Promise<T>;
|
|
27
|
+
}
|
package/dist/request-factory.js
CHANGED
|
@@ -1,89 +1,88 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.wrapPromiseToArray =
|
|
13
|
-
const axios_1 = require("axios");
|
|
14
|
-
const types_1 = require("./types");
|
|
15
|
-
/**
|
|
16
|
-
* Ensures output is an array.
|
|
17
|
-
* @param item
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
function wrapToArray(item) {
|
|
21
|
-
return Array.isArray(item) ? item : [item];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Function that wraps T | T[] to T[]
|
|
25
|
-
* @internal
|
|
26
|
-
* @param promise - The promise of which the output to wrap.
|
|
27
|
-
*/
|
|
28
|
-
function wrapPromiseToArray(promise) {
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
promise
|
|
31
|
-
.then((res) => resolve(wrapToArray(res)))
|
|
32
|
-
.catch((err) => reject(err));
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
* @param
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
exports.default = RequestFactory;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.wrapPromiseToArray = wrapPromiseToArray;
|
|
13
|
+
const axios_1 = require("axios");
|
|
14
|
+
const types_1 = require("./types");
|
|
15
|
+
/**
|
|
16
|
+
* Ensures output is an array.
|
|
17
|
+
* @param item
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
function wrapToArray(item) {
|
|
21
|
+
return Array.isArray(item) ? item : [item];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Function that wraps T | T[] to T[]
|
|
25
|
+
* @internal
|
|
26
|
+
* @param promise - The promise of which the output to wrap.
|
|
27
|
+
*/
|
|
28
|
+
function wrapPromiseToArray(promise) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
promise
|
|
31
|
+
.then((res) => resolve(wrapToArray(res)))
|
|
32
|
+
.catch((err) => reject(err));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Factory method patterns for creating Axios Requests.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
class RequestFactory {
|
|
40
|
+
constructor(ctx) {
|
|
41
|
+
this.ctx = ctx;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* POST Request Factory
|
|
45
|
+
* @param route - The route to which to send the request.
|
|
46
|
+
* @param payload - The payload to send with the request.
|
|
47
|
+
*/
|
|
48
|
+
post(route, payload) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
axios_1.default
|
|
52
|
+
.post(this.ctx.BASE_URL + route, payload, this.ctx.HEADERS)
|
|
53
|
+
// On succes
|
|
54
|
+
.then((res) => {
|
|
55
|
+
resolve(res.data);
|
|
56
|
+
})
|
|
57
|
+
// On error
|
|
58
|
+
.catch((e) => {
|
|
59
|
+
const { msg } = e.response.data;
|
|
60
|
+
reject(new types_1.MailcowException(msg));
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* GET Request Factory
|
|
67
|
+
* @param route - The route to which to send the request.
|
|
68
|
+
*/
|
|
69
|
+
get(route) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
axios_1.default
|
|
73
|
+
.get(this.ctx.BASE_URL + route, this.ctx.HEADERS)
|
|
74
|
+
// On succes
|
|
75
|
+
.then((res) => {
|
|
76
|
+
resolve(res.data);
|
|
77
|
+
})
|
|
78
|
+
// On error
|
|
79
|
+
.catch((e) => {
|
|
80
|
+
const { msg } = e.response.data;
|
|
81
|
+
reject(new types_1.MailcowException(msg));
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.default = RequestFactory;
|
|
89
88
|
//# sourceMappingURL=request-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-factory.js","sourceRoot":"","sources":["../src/request-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-factory.js","sourceRoot":"","sources":["../src/request-factory.ts"],"names":[],"mappings":";;;;;;;;;;;AAkBA,gDAMC;AAxBD,iCAAyD;AACzD,mCAA0E;AAG1E;;;;GAIG;AACH,SAAS,WAAW,CAAI,IAAa;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC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