@toothfairyai/sdk 0.6.1 → 0.6.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/build/authorisations/AuthorisationManager.d.ts +30 -6
- package/build/authorisations/AuthorisationManager.d.ts.map +1 -1
- package/build/authorisations/AuthorisationManager.js +65 -12
- package/build/authorisations/AuthorisationManager.js.map +1 -1
- package/build/connections/ConnectionManager.d.ts +5 -3
- package/build/connections/ConnectionManager.d.ts.map +1 -1
- package/build/connections/ConnectionManager.js +27 -9
- package/build/connections/ConnectionManager.js.map +1 -1
- package/build/secrets/SecretManager.d.ts +5 -3
- package/build/secrets/SecretManager.d.ts.map +1 -1
- package/build/secrets/SecretManager.js +30 -3
- package/build/secrets/SecretManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
import { Authorisation,
|
|
1
|
+
import { Authorisation, ListResponse } from '../types';
|
|
2
2
|
import { IToothFairyClient } from '../client';
|
|
3
|
+
export type AuthorisationType = 'bearer' | 'apikey' | 'oauth' | 'password' | 'env' | 'generic' | 'none' | 'username_and_password' | 'basic';
|
|
3
4
|
export declare class AuthorisationManager {
|
|
4
5
|
private client;
|
|
5
6
|
constructor(client: IToothFairyClient);
|
|
6
|
-
create(
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
create(name: string, authType: AuthorisationType, options?: {
|
|
8
|
+
tokenSecret?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
scope?: string;
|
|
11
|
+
grantType?: string;
|
|
12
|
+
clientId?: string;
|
|
13
|
+
clientSecret?: string;
|
|
14
|
+
authorizationBaseUrl?: string;
|
|
15
|
+
staticArgs?: string;
|
|
16
|
+
tokenBaseUrl?: string;
|
|
17
|
+
}): Promise<Authorisation>;
|
|
18
|
+
get(authorisationId: string): Promise<Authorisation>;
|
|
19
|
+
update(authorisationId: string, options?: {
|
|
20
|
+
name?: string;
|
|
21
|
+
tokenSecret?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
scope?: string;
|
|
24
|
+
grantType?: string;
|
|
25
|
+
clientId?: string;
|
|
26
|
+
clientSecret?: string;
|
|
27
|
+
authorizationBaseUrl?: string;
|
|
28
|
+
staticArgs?: string;
|
|
29
|
+
tokenBaseUrl?: string;
|
|
30
|
+
}): Promise<Authorisation>;
|
|
31
|
+
delete(authorisationId: string): Promise<{
|
|
9
32
|
success: boolean;
|
|
10
33
|
}>;
|
|
11
|
-
|
|
12
|
-
|
|
34
|
+
list(limit?: number, offset?: number): Promise<ListResponse<Authorisation>>;
|
|
35
|
+
getByType(authType: AuthorisationType): Promise<Authorisation[]>;
|
|
36
|
+
search(searchTerm: string): Promise<Authorisation[]>;
|
|
13
37
|
}
|
|
14
38
|
//# sourceMappingURL=AuthorisationManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorisationManager.d.ts","sourceRoot":"","sources":["../../src/authorisations/AuthorisationManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"AuthorisationManager.d.ts","sourceRoot":"","sources":["../../src/authorisations/AuthorisationManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK9C,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,UAAU,GACV,KAAK,GACL,SAAS,GACT,MAAM,GACN,uBAAuB,GACvB,OAAO,CAAC;AA8BZ,qBAAa,oBAAoB;IACnB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,iBAAiB;IAUvC,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;Q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
5
5
|
constructor(client) {
|
|
6
6
|
this.client = client;
|
|
7
7
|
}
|
|
8
|
-
async create(
|
|
8
|
+
async create(name, authType, options = {}) {
|
|
9
|
+
const data = {
|
|
10
|
+
name,
|
|
11
|
+
type: authType,
|
|
12
|
+
};
|
|
13
|
+
if (options.tokenSecret !== undefined) {
|
|
14
|
+
data.tokenSecret = options.tokenSecret;
|
|
15
|
+
}
|
|
16
|
+
if (options.description !== undefined) {
|
|
17
|
+
data.description = options.description;
|
|
18
|
+
}
|
|
19
|
+
if (options.scope !== undefined) {
|
|
20
|
+
data.scope = options.scope;
|
|
21
|
+
}
|
|
22
|
+
if (options.grantType !== undefined) {
|
|
23
|
+
data.grantType = options.grantType;
|
|
24
|
+
}
|
|
25
|
+
if (options.clientId !== undefined) {
|
|
26
|
+
data.clientId = options.clientId;
|
|
27
|
+
}
|
|
28
|
+
if (options.clientSecret !== undefined) {
|
|
29
|
+
data.clientSecret = options.clientSecret;
|
|
30
|
+
}
|
|
31
|
+
if (options.authorizationBaseUrl !== undefined) {
|
|
32
|
+
data.authorizationBaseUrl = options.authorizationBaseUrl;
|
|
33
|
+
}
|
|
34
|
+
if (options.staticArgs !== undefined) {
|
|
35
|
+
data.staticArgs = options.staticArgs;
|
|
36
|
+
}
|
|
37
|
+
if (options.tokenBaseUrl !== undefined) {
|
|
38
|
+
data.tokenBaseUrl = options.tokenBaseUrl;
|
|
39
|
+
}
|
|
9
40
|
return this.client.request('POST', 'authorisation/create', data);
|
|
10
41
|
}
|
|
11
|
-
async
|
|
12
|
-
return this.client.request('
|
|
42
|
+
async get(authorisationId) {
|
|
43
|
+
return this.client.request('GET', `authorisation/get/${authorisationId}`);
|
|
13
44
|
}
|
|
14
|
-
async
|
|
15
|
-
|
|
45
|
+
async update(authorisationId, options = {}) {
|
|
46
|
+
const data = {
|
|
47
|
+
id: authorisationId,
|
|
48
|
+
...options
|
|
49
|
+
};
|
|
50
|
+
return this.client.request('POST', 'authorisation/update', data);
|
|
16
51
|
}
|
|
17
|
-
async
|
|
18
|
-
|
|
52
|
+
async delete(authorisationId) {
|
|
53
|
+
await this.client.request('DELETE', `authorisation/delete/${authorisationId}`);
|
|
54
|
+
return { success: true };
|
|
19
55
|
}
|
|
20
|
-
async list(limit) {
|
|
56
|
+
async list(limit, offset) {
|
|
21
57
|
const params = {};
|
|
22
|
-
if (limit)
|
|
58
|
+
if (limit !== undefined) {
|
|
23
59
|
params.limit = limit;
|
|
60
|
+
}
|
|
61
|
+
if (offset !== undefined) {
|
|
62
|
+
params.offset = offset;
|
|
63
|
+
}
|
|
24
64
|
const response = await this.client.request('GET', 'authorisation/list', null, { params });
|
|
65
|
+
const items = Array.isArray(response)
|
|
66
|
+
? response
|
|
67
|
+
: (response && 'items' in response ? response.items : []);
|
|
25
68
|
return {
|
|
26
|
-
items
|
|
27
|
-
total:
|
|
28
|
-
limit
|
|
69
|
+
items,
|
|
70
|
+
total: items.length,
|
|
71
|
+
limit,
|
|
72
|
+
offset
|
|
29
73
|
};
|
|
30
74
|
}
|
|
75
|
+
async getByType(authType) {
|
|
76
|
+
const result = await this.list();
|
|
77
|
+
return result.items.filter(auth => auth.type === authType);
|
|
78
|
+
}
|
|
79
|
+
async search(searchTerm) {
|
|
80
|
+
const result = await this.list();
|
|
81
|
+
const searchLower = searchTerm.toLowerCase();
|
|
82
|
+
return result.items.filter(auth => auth.name.toLowerCase().includes(searchLower));
|
|
83
|
+
}
|
|
31
84
|
}
|
|
32
85
|
exports.AuthorisationManager = AuthorisationManager;
|
|
33
86
|
//# sourceMappingURL=AuthorisationManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorisationManager.js","sourceRoot":"","sources":["../../src/authorisations/AuthorisationManager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AuthorisationManager.js","sourceRoot":"","sources":["../../src/authorisations/AuthorisationManager.ts"],"names":[],"mappings":";;;AA6CA,MAAa,oBAAoB;IAC/B,YAAoB,MAAyB;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ACL,KAAK;YACL,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,KAAK;YACL,MAAM;SACP,CAAC;IACJ,CAAC;IAQD,KAAK,CAAC,SAAS,CAAC,QAA2B;QACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAQD,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACjC,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAChC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC9C,CAAC;IACJ,CAAC;CACF;AA5KD,oDA4KC"}
|
|
@@ -3,10 +3,12 @@ import { IToothFairyClient } from '../client';
|
|
|
3
3
|
export declare class ConnectionManager {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: IToothFairyClient);
|
|
6
|
-
|
|
6
|
+
get(connectionId: string): Promise<Connection>;
|
|
7
|
+
delete(connectionId: string): Promise<{
|
|
7
8
|
success: boolean;
|
|
8
9
|
}>;
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
list(limit?: number, offset?: number): Promise<ListResponse<Connection>>;
|
|
11
|
+
getByType(connectionType: string): Promise<Connection[]>;
|
|
12
|
+
search(searchTerm: string): Promise<Connection[]>;
|
|
11
13
|
}
|
|
12
14
|
//# sourceMappingURL=ConnectionManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionManager.d.ts","sourceRoot":"","sources":["../../src/connections/ConnectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"ConnectionManager.d.ts","sourceRoot":"","sources":["../../src/connections/ConnectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAsB9C,qBAAa,iBAAiB;IAChB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,iBAAiB;IAQvC,GAAG,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAU9C,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAY3D,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAkCxE,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAWxD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAOxD"}
|
|
@@ -5,23 +5,41 @@ class ConnectionManager {
|
|
|
5
5
|
constructor(client) {
|
|
6
6
|
this.client = client;
|
|
7
7
|
}
|
|
8
|
-
async
|
|
9
|
-
return this.client.request('
|
|
8
|
+
async get(connectionId) {
|
|
9
|
+
return this.client.request('GET', `connection/get/${connectionId}`);
|
|
10
10
|
}
|
|
11
|
-
async
|
|
12
|
-
|
|
11
|
+
async delete(connectionId) {
|
|
12
|
+
await this.client.request('DELETE', `connection/delete/${connectionId}`);
|
|
13
|
+
return { success: true };
|
|
13
14
|
}
|
|
14
|
-
async list(limit) {
|
|
15
|
+
async list(limit, offset) {
|
|
15
16
|
const params = {};
|
|
16
|
-
if (limit)
|
|
17
|
+
if (limit !== undefined) {
|
|
17
18
|
params.limit = limit;
|
|
19
|
+
}
|
|
20
|
+
if (offset !== undefined) {
|
|
21
|
+
params.offset = offset;
|
|
22
|
+
}
|
|
18
23
|
const response = await this.client.request('GET', 'connection/list', null, { params });
|
|
24
|
+
const items = Array.isArray(response)
|
|
25
|
+
? response
|
|
26
|
+
: (response && 'items' in response ? response.items : []);
|
|
19
27
|
return {
|
|
20
|
-
items
|
|
21
|
-
total:
|
|
22
|
-
limit
|
|
28
|
+
items,
|
|
29
|
+
total: items.length,
|
|
30
|
+
limit,
|
|
31
|
+
offset
|
|
23
32
|
};
|
|
24
33
|
}
|
|
34
|
+
async getByType(connectionType) {
|
|
35
|
+
const result = await this.list();
|
|
36
|
+
return result.items.filter(conn => conn.type === connectionType);
|
|
37
|
+
}
|
|
38
|
+
async search(searchTerm) {
|
|
39
|
+
const result = await this.list();
|
|
40
|
+
const searchLower = searchTerm.toLowerCase();
|
|
41
|
+
return result.items.filter(conn => conn.name.toLowerCase().includes(searchLower));
|
|
42
|
+
}
|
|
25
43
|
}
|
|
26
44
|
exports.ConnectionManager = ConnectionManager;
|
|
27
45
|
//# sourceMappingURL=ConnectionManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../src/connections/ConnectionManager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../src/connections/ConnectionManager.ts"],"names":[],"mappings":";;;AAuBA,MAAa,iBAAiB;IAC5B,YAAoB,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;IAAG,CAAC;IAQjD,KAAK,CAAC,GAAG,CAAC,YAAoB;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAa,KAAK,EAAE,kBAAkB,YAAY,EAAE,CAAC,CAAC;IAClF,CAAC;IAQD,KAAK,CAAC,MAAM,CAAC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,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAChC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC9C,CAAC;IACJ,CAAC;CACF;AAnFD,8CAmFC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Secret,
|
|
1
|
+
import { Secret, ListResponse } from '../types';
|
|
2
2
|
import { IToothFairyClient } from '../client';
|
|
3
3
|
export declare class SecretManager {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: IToothFairyClient);
|
|
6
|
-
create(
|
|
7
|
-
delete(
|
|
6
|
+
create(authorisationId: string, passwordSecretValue: string): Promise<Secret>;
|
|
7
|
+
delete(secretId: string): Promise<{
|
|
8
8
|
success: boolean;
|
|
9
9
|
}>;
|
|
10
|
+
list(limit?: number, offset?: number): Promise<ListResponse<Secret>>;
|
|
11
|
+
get(secretId: string): Promise<Secret>;
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=SecretManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretManager.d.ts","sourceRoot":"","sources":["../../src/secrets/SecretManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"SecretManager.d.ts","sourceRoot":"","sources":["../../src/secrets/SecretManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAgB9C,qBAAa,aAAa;IACZ,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,iBAAiB;IASvC,MAAM,CACV,eAAe,EAAE,MAAM,EACvB,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,MAAM,CAAC;IAcZ,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAYvD,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAkCpE,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG7C"}
|
|
@@ -5,11 +5,38 @@ class SecretManager {
|
|
|
5
5
|
constructor(client) {
|
|
6
6
|
this.client = client;
|
|
7
7
|
}
|
|
8
|
-
async create(
|
|
8
|
+
async create(authorisationId, passwordSecretValue) {
|
|
9
|
+
const data = {
|
|
10
|
+
id: authorisationId,
|
|
11
|
+
passwordSecretValue,
|
|
12
|
+
};
|
|
9
13
|
return this.client.request('POST', 'secret/create', data);
|
|
10
14
|
}
|
|
11
|
-
async delete(
|
|
12
|
-
|
|
15
|
+
async delete(secretId) {
|
|
16
|
+
await this.client.request('DELETE', `secret/delete/${secretId}`);
|
|
17
|
+
return { success: true };
|
|
18
|
+
}
|
|
19
|
+
async list(limit, offset) {
|
|
20
|
+
const params = {};
|
|
21
|
+
if (limit !== undefined) {
|
|
22
|
+
params.limit = limit;
|
|
23
|
+
}
|
|
24
|
+
if (offset !== undefined) {
|
|
25
|
+
params.offset = offset;
|
|
26
|
+
}
|
|
27
|
+
const response = await this.client.request('GET', 'secret/list', null, { params });
|
|
28
|
+
const items = Array.isArray(response)
|
|
29
|
+
? response
|
|
30
|
+
: (response && 'items' in response ? response.items : []);
|
|
31
|
+
return {
|
|
32
|
+
items,
|
|
33
|
+
total: items.length,
|
|
34
|
+
limit,
|
|
35
|
+
offset
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async get(secretId) {
|
|
39
|
+
return this.client.request('GET', `secret/get/${secretId}`);
|
|
13
40
|
}
|
|
14
41
|
}
|
|
15
42
|
exports.SecretManager = SecretManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretManager.js","sourceRoot":"","sources":["../../src/secrets/SecretManager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SecretManager.js","sourceRoot":"","sources":["../../src/secrets/SecretManager.ts"],"names":[],"mappings":";;;AAiBA,MAAa,aAAa;IACxB,YAAoB,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;IAAG,CAAC;IASjD,KAAK,CAAC,MAAM,CACV,eAAuB,EACvB,mBAA2B;QAE3B,MAAM,IAAI,GAAG;YACX,EAAE,EAAE,eAAe;YACnB,mBAAmB;SACpB,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAS,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAQD,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,QAAQ,EAAE,CAAC,CAAC;QACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IASD,KAAK,CAAC,IAAI,CAAC,KAAc,EAAE,MAAe;QACxC,MAAM,MAAM,GAAwB,EAAE,CAAC;QACvC,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;SACtB;QACD,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;SACxB;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CACxC,KAAK,EACL,aAAa,EACb,IAAI,EACJ,EAAE,MAAM,EAAE,CACX,CAAC;QAEF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YACnC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,CAAC,QAAQ,IAAI,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CA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