@adtrackify/at-service-common 3.7.0 → 3.7.1
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/dist/cjs/clients/generic/sqs-client.d.ts +8 -1
- package/dist/cjs/clients/generic/sqs-client.js +35 -0
- package/dist/cjs/clients/generic/sqs-client.js.map +1 -1
- package/dist/cjs/clients/internal-api/destinations-client.d.ts +6 -5
- package/dist/cjs/clients/internal-api/destinations-client.js +9 -2
- package/dist/cjs/clients/internal-api/destinations-client.js.map +1 -1
- package/dist/esm/clients/generic/sqs-client.d.ts +8 -1
- package/dist/esm/clients/generic/sqs-client.js +35 -0
- package/dist/esm/clients/generic/sqs-client.js.map +1 -1
- package/dist/esm/clients/internal-api/destinations-client.d.ts +6 -5
- package/dist/esm/clients/internal-api/destinations-client.js +9 -2
- package/dist/esm/clients/internal-api/destinations-client.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { SQS } from '@aws-sdk/client-sqs';
|
|
1
|
+
import { SQS, SendMessageBatchCommandOutput } from '@aws-sdk/client-sqs';
|
|
2
2
|
export interface InternalSQSMessage {
|
|
3
3
|
messageId: string;
|
|
4
4
|
messageType: string;
|
|
5
5
|
messageTime: string;
|
|
6
6
|
messageBody: any;
|
|
7
7
|
}
|
|
8
|
+
export interface InternalSQSBatchSendResult {
|
|
9
|
+
sentCount: number;
|
|
10
|
+
failedCount: number;
|
|
11
|
+
responses: SendMessageBatchCommandOutput[];
|
|
12
|
+
}
|
|
8
13
|
export declare class SQSClient {
|
|
9
14
|
sqs: SQS;
|
|
10
15
|
queueUrl: string;
|
|
11
16
|
constructor(region: string, accountId: string, queueName: string);
|
|
12
17
|
buildAndSendMessage: (messageType: string, messageBody: any, deplaySeconds?: number) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
|
|
18
|
+
buildAndSendMessages: (messageType: string, messageBodies: any[], delaySeconds?: number, maxBatchSize?: number) => Promise<InternalSQSBatchSendResult>;
|
|
13
19
|
buildMessage: (messageType: string, messageBody: any, messageId?: string, messageTime?: string) => {
|
|
14
20
|
messageId: string;
|
|
15
21
|
messageType: string;
|
|
@@ -17,4 +23,5 @@ export declare class SQSClient {
|
|
|
17
23
|
messageBody: any;
|
|
18
24
|
};
|
|
19
25
|
sendMessage: (messageBody: any, delaySeconds?: number) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
|
|
26
|
+
sendMessages: (messageBodies: any[], delaySeconds?: number, maxBatchSize?: number) => Promise<InternalSQSBatchSendResult>;
|
|
20
27
|
}
|
|
@@ -15,6 +15,10 @@ class SQSClient {
|
|
|
15
15
|
const message = this.buildMessage(messageType, messageBody);
|
|
16
16
|
return await this.sendMessage(message, deplaySeconds);
|
|
17
17
|
};
|
|
18
|
+
buildAndSendMessages = async (messageType, messageBodies, delaySeconds = 0, maxBatchSize = 10) => {
|
|
19
|
+
const messages = messageBodies.map((messageBody) => this.buildMessage(messageType, messageBody));
|
|
20
|
+
return await this.sendMessages(messages, delaySeconds, maxBatchSize);
|
|
21
|
+
};
|
|
18
22
|
buildMessage = (messageType, messageBody, messageId = (0, uuid_1.v4)(), messageTime = (0, dates_js_1.getCurrentTimestamp)()) => {
|
|
19
23
|
return {
|
|
20
24
|
messageId,
|
|
@@ -32,6 +36,37 @@ class SQSClient {
|
|
|
32
36
|
const response = await this.sqs.sendMessage(params);
|
|
33
37
|
return response;
|
|
34
38
|
};
|
|
39
|
+
sendMessages = async (messageBodies, delaySeconds = 0, maxBatchSize = 10) => {
|
|
40
|
+
const messages = messageBodies ?? [];
|
|
41
|
+
if (messages.length === 0) {
|
|
42
|
+
return { sentCount: 0, failedCount: 0, responses: [] };
|
|
43
|
+
}
|
|
44
|
+
const boundedBatchSize = Math.min(Math.max(maxBatchSize, 1), 10);
|
|
45
|
+
const responses = [];
|
|
46
|
+
let sentCount = 0;
|
|
47
|
+
let failedCount = 0;
|
|
48
|
+
for (let i = 0; i < messages.length; i += boundedBatchSize) {
|
|
49
|
+
const batch = messages.slice(i, i + boundedBatchSize);
|
|
50
|
+
const entries = batch.map((messageBody, index) => ({
|
|
51
|
+
Id: String(i + index),
|
|
52
|
+
MessageBody: JSON.stringify(messageBody),
|
|
53
|
+
DelaySeconds: delaySeconds
|
|
54
|
+
}));
|
|
55
|
+
const params = {
|
|
56
|
+
QueueUrl: this.queueUrl,
|
|
57
|
+
Entries: entries
|
|
58
|
+
};
|
|
59
|
+
const response = await this.sqs.sendMessageBatch(params);
|
|
60
|
+
responses.push(response);
|
|
61
|
+
sentCount += response.Successful?.length ?? 0;
|
|
62
|
+
failedCount += response.Failed?.length ?? 0;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
sentCount,
|
|
66
|
+
failedCount,
|
|
67
|
+
responses
|
|
68
|
+
};
|
|
69
|
+
};
|
|
35
70
|
}
|
|
36
71
|
exports.SQSClient = SQSClient;
|
|
37
72
|
//# sourceMappingURL=sqs-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqs-client.js","sourceRoot":"","sources":["../../../../src/clients/generic/sqs-client.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"sqs-client.js","sourceRoot":"","sources":["../../../../src/clients/generic/sqs-client.ts"],"names":[],"mappings":";;;AAAA,oDAM6B;AAC7B,+BAAoC;AACpC,kDAA0D;AAgB1D,MAAa,SAAS;IACb,GAAG,CAAM;IACT,QAAQ,CAAS;IAExB,YAAY,MAAc,EAAE,SAAiB,EAAE,SAAiB;QAC9D,IAAI,CAAC,GAAG,GAAG,IAAI,gBAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,eAAe,MAAM,kBAAkB,SAAS,IAAI,SAAS,EAAE,CAAC;IAClF,CAAC;IAEM,mBAAmB,GAAG,KAAK,EAAE,WAAmB,EAAE,WAAgB,EAAE,aAAa,GAAG,CAAC,EAAE,EA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SAC7C;QAED,OAAO;YACL,SAAS;YACT,WAAW;YACX,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;CACH;AA3FD,8BA2FC"}
|
|
@@ -9,6 +9,10 @@ export interface CreateDestinationResponseData {
|
|
|
9
9
|
destination: Destination;
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}
|
|
12
|
+
export interface DeleteDestinationResponseData {
|
|
13
|
+
destination: Destination;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
12
16
|
export declare class DestinationsClient {
|
|
13
17
|
BASE_API_URL: string;
|
|
14
18
|
DESTINATIONS_API_KEY: string;
|
|
@@ -24,10 +28,7 @@ export declare class DestinationsClient {
|
|
|
24
28
|
updateDestination: (destinationId: string, body: any) => Promise<ApiResponse<CreateDestinationResponseData>>;
|
|
25
29
|
getPixelDestinations: (pixelId: string) => Promise<ApiResponse<GetDestinationsResponseData>>;
|
|
26
30
|
getAllDestinationByDestinationType: (destinationType: DESTINATION_TYPE, start: string) => Promise<ApiResponse<GetDestinationsResponseData>>;
|
|
27
|
-
deleteDestination: (destinationId: string,
|
|
28
|
-
|
|
29
|
-
accountId: string;
|
|
30
|
-
pixelId: string;
|
|
31
|
-
}) => Promise<ApiResponse<CreateDestinationResponseData>>;
|
|
31
|
+
deleteDestination: (destinationId: string, accountId: string, pixelId: string) => Promise<ApiResponse<DeleteDestinationResponseData>>;
|
|
32
|
+
uninstallShopifyAppDestinationPrivate: (accountId: string, pixelId: string) => Promise<ApiResponse<DeleteDestinationResponseData>>;
|
|
32
33
|
getDestinationsByDestination: (destinationKey: DESTINATION) => Promise<ApiResponse<Destination[]>>;
|
|
33
34
|
}
|
|
@@ -53,14 +53,21 @@ class DestinationsClient {
|
|
|
53
53
|
index_js_1.Logger.debug('getAllDestinationByDestinationType', { response });
|
|
54
54
|
return response;
|
|
55
55
|
};
|
|
56
|
-
deleteDestination = async (destinationId,
|
|
56
|
+
deleteDestination = async (destinationId, accountId, pixelId) => {
|
|
57
57
|
const response = await client.delete(`${this.SERVICE_API_ROOT_URL}/${destinationId}/private`, {
|
|
58
58
|
headers: this.getHeaders(),
|
|
59
|
-
data:
|
|
59
|
+
data: { id: destinationId, accountId, pixelId },
|
|
60
60
|
});
|
|
61
61
|
index_js_1.Logger.debug('deleteDestinationResponse', { response });
|
|
62
62
|
return response;
|
|
63
63
|
};
|
|
64
|
+
uninstallShopifyAppDestinationPrivate = async (accountId, pixelId) => {
|
|
65
|
+
const response = await client.post(`${this.SERVICE_API_ROOT_URL}/shopify-app/uninstall/private`, { accountId, pixelId }, {
|
|
66
|
+
headers: this.getHeaders(),
|
|
67
|
+
});
|
|
68
|
+
index_js_1.Logger.debug('uninstallShopifyAppDestinationPrivateResponse', { response });
|
|
69
|
+
return response;
|
|
70
|
+
};
|
|
64
71
|
getDestinationsByDestination = async (destinationKey) => {
|
|
65
72
|
const response = await client.get(`${this.SERVICE_API_ROOT_URL}/by-destination?destination=${destinationKey}`, {
|
|
66
73
|
headers: this.getHeaders(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destinations-client.js","sourceRoot":"","sources":["../../../../src/clients/internal-api/destinations-client.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,8DAAgF;
|
|
1
|
+
{"version":3,"file":"destinations-client.js","sourceRoot":"","sources":["../../../../src/clients/internal-api/destinations-client.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,8DAAgF;AAgBhF,MAAM,MAAM,GAAG,IAAA,iCAAgB,EAAC;IAE9B,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;KACnC;CACF,CAAC,CAAC;AAEH,MAAa,kBAAkB;IACtB,YAAY,CAAS;IACrB,oBAAoB,CAAS;IAC7B,MAAM,CAAoB;IAC1B,oBAAoB,CAAS;IAEpC,YAAY,UAAkB,EAAE,kBAA0B;QACxD,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC;QAC/B,IAAI,CAAC,oBAAoB,GAAG,kBAAkB,CAAC;QAC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,EAAE,CAAC,CAAC;QAC5E,OAAO,QAAsD,CAAC;IAChE,CAAC,CAAC;IAQF,4BAA4B,GAAG,KAAK,EAAE,cAA2B,EAAuC,EAAE;QACxG,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,oBAAoB,+BAA+B,cAAc,EAAE,EAAE;YAC7G,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;SAC3B,CAAC,CAAC;QACH,iBAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAC;QAC3E,OAAO,QAAsC,CAAC;IAChD,CAAC,CAAC;CACH;AA/FD,gDA+FC"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { SQS } from '@aws-sdk/client-sqs';
|
|
1
|
+
import { SQS, SendMessageBatchCommandOutput } from '@aws-sdk/client-sqs';
|
|
2
2
|
export interface InternalSQSMessage {
|
|
3
3
|
messageId: string;
|
|
4
4
|
messageType: string;
|
|
5
5
|
messageTime: string;
|
|
6
6
|
messageBody: any;
|
|
7
7
|
}
|
|
8
|
+
export interface InternalSQSBatchSendResult {
|
|
9
|
+
sentCount: number;
|
|
10
|
+
failedCount: number;
|
|
11
|
+
responses: SendMessageBatchCommandOutput[];
|
|
12
|
+
}
|
|
8
13
|
export declare class SQSClient {
|
|
9
14
|
sqs: SQS;
|
|
10
15
|
queueUrl: string;
|
|
11
16
|
constructor(region: string, accountId: string, queueName: string);
|
|
12
17
|
buildAndSendMessage: (messageType: string, messageBody: any, deplaySeconds?: number) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
|
|
18
|
+
buildAndSendMessages: (messageType: string, messageBodies: any[], delaySeconds?: number, maxBatchSize?: number) => Promise<InternalSQSBatchSendResult>;
|
|
13
19
|
buildMessage: (messageType: string, messageBody: any, messageId?: string, messageTime?: string) => {
|
|
14
20
|
messageId: string;
|
|
15
21
|
messageType: string;
|
|
@@ -17,4 +23,5 @@ export declare class SQSClient {
|
|
|
17
23
|
messageBody: any;
|
|
18
24
|
};
|
|
19
25
|
sendMessage: (messageBody: any, delaySeconds?: number) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
|
|
26
|
+
sendMessages: (messageBodies: any[], delaySeconds?: number, maxBatchSize?: number) => Promise<InternalSQSBatchSendResult>;
|
|
20
27
|
}
|
|
@@ -12,6 +12,10 @@ export class SQSClient {
|
|
|
12
12
|
const message = this.buildMessage(messageType, messageBody);
|
|
13
13
|
return await this.sendMessage(message, deplaySeconds);
|
|
14
14
|
};
|
|
15
|
+
buildAndSendMessages = async (messageType, messageBodies, delaySeconds = 0, maxBatchSize = 10) => {
|
|
16
|
+
const messages = messageBodies.map((messageBody) => this.buildMessage(messageType, messageBody));
|
|
17
|
+
return await this.sendMessages(messages, delaySeconds, maxBatchSize);
|
|
18
|
+
};
|
|
15
19
|
buildMessage = (messageType, messageBody, messageId = uuidv4(), messageTime = getCurrentTimestamp()) => {
|
|
16
20
|
return {
|
|
17
21
|
messageId,
|
|
@@ -29,5 +33,36 @@ export class SQSClient {
|
|
|
29
33
|
const response = await this.sqs.sendMessage(params);
|
|
30
34
|
return response;
|
|
31
35
|
};
|
|
36
|
+
sendMessages = async (messageBodies, delaySeconds = 0, maxBatchSize = 10) => {
|
|
37
|
+
const messages = messageBodies ?? [];
|
|
38
|
+
if (messages.length === 0) {
|
|
39
|
+
return { sentCount: 0, failedCount: 0, responses: [] };
|
|
40
|
+
}
|
|
41
|
+
const boundedBatchSize = Math.min(Math.max(maxBatchSize, 1), 10);
|
|
42
|
+
const responses = [];
|
|
43
|
+
let sentCount = 0;
|
|
44
|
+
let failedCount = 0;
|
|
45
|
+
for (let i = 0; i < messages.length; i += boundedBatchSize) {
|
|
46
|
+
const batch = messages.slice(i, i + boundedBatchSize);
|
|
47
|
+
const entries = batch.map((messageBody, index) => ({
|
|
48
|
+
Id: String(i + index),
|
|
49
|
+
MessageBody: JSON.stringify(messageBody),
|
|
50
|
+
DelaySeconds: delaySeconds
|
|
51
|
+
}));
|
|
52
|
+
const params = {
|
|
53
|
+
QueueUrl: this.queueUrl,
|
|
54
|
+
Entries: entries
|
|
55
|
+
};
|
|
56
|
+
const response = await this.sqs.sendMessageBatch(params);
|
|
57
|
+
responses.push(response);
|
|
58
|
+
sentCount += response.Successful?.length ?? 0;
|
|
59
|
+
failedCount += response.Failed?.length ?? 0;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
sentCount,
|
|
63
|
+
failedCount,
|
|
64
|
+
responses
|
|
65
|
+
};
|
|
66
|
+
};
|
|
32
67
|
}
|
|
33
68
|
//# sourceMappingURL=sqs-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqs-client.js","sourceRoot":"","sources":["../../../../src/clients/generic/sqs-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sqs-client.js","sourceRoot":"","sources":["../../../../src/clients/generic/sqs-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAKJ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAgB1D,MAAM,OAAO,SAAS;IACb,GAAG,CAAM;IACT,QAAQ,CAAS;IAExB,YAAY,MAAc,EAAE,SAAiB,EAAE,SAAiB;QAC9D,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,eAAe,MAAM,kBAAkB,SAAS,IAAI,SAAS,EAAE,CAAC;IAClF,CAAC;IAEM,mBAAmB,GAAG,KAAK,EAAE,WAAmB,EAAE,WAAgB,EAAE,aAAa,GAAG,CAAC,EAAE,EAAE;QAC9F,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW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AC,CAAC;CACH"}
|
|
@@ -9,6 +9,10 @@ export interface CreateDestinationResponseData {
|
|
|
9
9
|
destination: Destination;
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}
|
|
12
|
+
export interface DeleteDestinationResponseData {
|
|
13
|
+
destination: Destination;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
12
16
|
export declare class DestinationsClient {
|
|
13
17
|
BASE_API_URL: string;
|
|
14
18
|
DESTINATIONS_API_KEY: string;
|
|
@@ -24,10 +28,7 @@ export declare class DestinationsClient {
|
|
|
24
28
|
updateDestination: (destinationId: string, body: any) => Promise<ApiResponse<CreateDestinationResponseData>>;
|
|
25
29
|
getPixelDestinations: (pixelId: string) => Promise<ApiResponse<GetDestinationsResponseData>>;
|
|
26
30
|
getAllDestinationByDestinationType: (destinationType: DESTINATION_TYPE, start: string) => Promise<ApiResponse<GetDestinationsResponseData>>;
|
|
27
|
-
deleteDestination: (destinationId: string,
|
|
28
|
-
|
|
29
|
-
accountId: string;
|
|
30
|
-
pixelId: string;
|
|
31
|
-
}) => Promise<ApiResponse<CreateDestinationResponseData>>;
|
|
31
|
+
deleteDestination: (destinationId: string, accountId: string, pixelId: string) => Promise<ApiResponse<DeleteDestinationResponseData>>;
|
|
32
|
+
uninstallShopifyAppDestinationPrivate: (accountId: string, pixelId: string) => Promise<ApiResponse<DeleteDestinationResponseData>>;
|
|
32
33
|
getDestinationsByDestination: (destinationKey: DESTINATION) => Promise<ApiResponse<Destination[]>>;
|
|
33
34
|
}
|
|
@@ -50,14 +50,21 @@ export class DestinationsClient {
|
|
|
50
50
|
Logger.debug('getAllDestinationByDestinationType', { response });
|
|
51
51
|
return response;
|
|
52
52
|
};
|
|
53
|
-
deleteDestination = async (destinationId,
|
|
53
|
+
deleteDestination = async (destinationId, accountId, pixelId) => {
|
|
54
54
|
const response = await client.delete(`${this.SERVICE_API_ROOT_URL}/${destinationId}/private`, {
|
|
55
55
|
headers: this.getHeaders(),
|
|
56
|
-
data:
|
|
56
|
+
data: { id: destinationId, accountId, pixelId },
|
|
57
57
|
});
|
|
58
58
|
Logger.debug('deleteDestinationResponse', { response });
|
|
59
59
|
return response;
|
|
60
60
|
};
|
|
61
|
+
uninstallShopifyAppDestinationPrivate = async (accountId, pixelId) => {
|
|
62
|
+
const response = await client.post(`${this.SERVICE_API_ROOT_URL}/shopify-app/uninstall/private`, { accountId, pixelId }, {
|
|
63
|
+
headers: this.getHeaders(),
|
|
64
|
+
});
|
|
65
|
+
Logger.debug('uninstallShopifyAppDestinationPrivateResponse', { response });
|
|
66
|
+
return response;
|
|
67
|
+
};
|
|
61
68
|
getDestinationsByDestination = async (destinationKey) => {
|
|
62
69
|
const response = await client.get(`${this.SERVICE_API_ROOT_URL}/by-destination?destination=${destinationKey}`, {
|
|
63
70
|
headers: this.getHeaders(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destinations-client.js","sourceRoot":"","sources":["../../../../src/clients/internal-api/destinations-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAqB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"destinations-client.js","sourceRoot":"","sources":["../../../../src/clients/internal-api/destinations-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAqB,MAAM,2BAA2B,CAAC;AAgBhF,MAAM,MAAM,GAAG,gBAAgB,CAAC;IAE9B,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;KACnC;CACF,CAAC,CAAC;AAEH,MAAM,OAAO,kBAAkB;IACtB,YAAY,CAAS;IACrB,oBAAoB,CAAS;IAC7B,MAAM,CAAoB;IAC1B,oBAAoB,CAAS;IAEpC,YAAY,UAAkB,EAAE,kBAA0B;QACxD,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC;QAC/B,IAA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