@natlibfi/melinda-rest-api-commons 6.1.0-alpha.0 → 6.2.0-alpha.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/.github/workflows/melinda-node-tests-and-publish.yml +4 -2
- package/README.md +211 -14
- package/dist/amqp.d.ts +41 -0
- package/dist/amqp.d.ts.map +1 -0
- package/dist/amqp.js +251 -235
- package/dist/amqp.js.map +1 -7
- package/dist/constants.d.ts +49 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +38 -38
- package/dist/constants.js.map +1 -7
- package/dist/helpers/conversion.d.ts +8 -0
- package/dist/helpers/conversion.d.ts.map +1 -0
- package/dist/helpers/conversion.js +70 -64
- package/dist/helpers/conversion.js.map +1 -7
- package/dist/helpers/fix-constants.d.ts +76 -0
- package/dist/helpers/fix-constants.d.ts.map +1 -0
- package/dist/helpers/fix-constants.js +41 -41
- package/dist/helpers/fix-constants.js.map +1 -7
- package/dist/helpers/fix-handle-tempurns.d.ts +3 -0
- package/dist/helpers/fix-handle-tempurns.d.ts.map +1 -0
- package/dist/helpers/fix-handle-tempurns.js +73 -71
- package/dist/helpers/fix-handle-tempurns.js.map +1 -7
- package/dist/helpers/fix-strip-f884s.d.ts +10 -0
- package/dist/helpers/fix-strip-f884s.d.ts.map +1 -0
- package/dist/helpers/fix-strip-f884s.js +161 -163
- package/dist/helpers/fix-strip-f884s.js.map +1 -7
- package/dist/helpers/fix.d.ts +6 -0
- package/dist/helpers/fix.d.ts.map +1 -0
- package/dist/helpers/fix.js +133 -121
- package/dist/helpers/fix.js.map +1 -7
- package/dist/helpers/validation.d.ts +9 -0
- package/dist/helpers/validation.d.ts.map +1 -0
- package/dist/helpers/validation.js +14 -16
- package/dist/helpers/validation.js.map +1 -7
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -7
- package/dist/mongo.d.ts +165 -0
- package/dist/mongo.d.ts.map +1 -0
- package/dist/mongo.js +595 -547
- package/dist/mongo.js.map +1 -7
- package/dist/mongoError.d.ts +2 -0
- package/dist/mongoError.d.ts.map +1 -0
- package/dist/mongoError.js +19 -0
- package/dist/mongoError.js.map +1 -0
- package/dist/mongoLog.d.ts +50 -0
- package/dist/mongoLog.d.ts.map +1 -0
- package/dist/mongoLog.js +274 -242
- package/dist/mongoLog.js.map +1 -7
- package/dist/utils.d.ts +36 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +112 -110
- package/dist/utils.js.map +1 -7
- package/eslint.config.ts +66 -0
- package/package.json +17 -11
- package/{tests/amqp-error-branches.test.js → test/amqp-error-branches.test.ts} +135 -61
- package/{tests/amqp.healthtest.js → test/amqp.healthtest.ts} +19 -11
- package/{tests/amqp.tests.localtest.js → test/amqp.tests.localtest.ts} +54 -35
- package/{tests/helpers/conversion.test.js → test/helpers/conversion.test.ts} +26 -14
- package/{tests/helpers/fix-edge.test.js → test/helpers/fix-edge.test.ts} +16 -12
- package/{tests/helpers/fix.test.js → test/helpers/fix.test.ts} +14 -8
- package/{tests/helpers/validation.test.js → test/helpers/validation.test.ts} +7 -6
- package/{tests/mongo-add-blob-size.test.js → test/mongo-add-blob-size.test.ts} +14 -15
- package/{tests/mongo-check-and-check-state.test.js → test/mongo-check-and-check-state.test.ts} +6 -8
- package/{tests/mongo-check-and-set-import-job-state.test.js → test/mongo-check-and-set-import-job-state.test.ts} +6 -9
- package/{tests/mongo-check-timeout.test.js → test/mongo-check-timeout.test.ts} +6 -9
- package/{tests/mongo-create-bulk.test.js → test/mongo-create-bulk.test.ts} +6 -7
- package/{tests/mongo-create-prio.test.js → test/mongo-create-prio.test.ts} +6 -6
- package/{tests/mongo-error-branches.test.js → test/mongo-error-branches.test.ts} +166 -65
- package/{tests/mongo-get-one.test.js → test/mongo-get-one.test.ts} +6 -6
- package/{tests/mongo-get-stream.test.js → test/mongo-get-stream.test.ts} +6 -8
- package/{tests/mongo-push-ids.test.js → test/mongo-push-ids.test.ts} +6 -6
- package/{tests/mongo-push-messages.test.js → test/mongo-push-messages.test.ts} +6 -6
- package/{tests/mongo-query-by-id.test.js → test/mongo-query-by-id.test.ts} +6 -9
- package/{tests/mongo-query.test.js → test/mongo-query.test.ts} +6 -7
- package/{tests/mongo-read-content.test.js → test/mongo-read-content.test.ts} +6 -9
- package/{tests/mongo-remove.test.js → test/mongo-remove.test.ts} +6 -8
- package/{tests/mongo-set-blob-size.test.js → test/mongo-set-blob-size.test.ts} +6 -6
- package/{tests/mongo-set-import-job-state.test.js → test/mongo-set-import-job-state.test.ts} +6 -6
- package/{tests/mongo-set-operation.test.js → test/mongo-set-operation.test.ts} +6 -6
- package/{tests/mongo-set-operations.test.js → test/mongo-set-operations.test.ts} +6 -6
- package/{tests/mongo-set-state.test.js → test/mongo-set-state.test.ts} +6 -6
- package/{tests/mongoLog-protect.test.js → test/mongoLog-protect.test.ts} +18 -17
- package/{tests/mongoLog.test.js → test/mongoLog.test.ts} +8 -8
- package/{tests/testUtils.js → test/testUtils.ts} +49 -15
- package/{tests/utils.test.js → test/utils.test.ts} +5 -5
- package/tsconfig.json +62 -0
- package/tsconfig.test.json +17 -0
- package/dist/helpers/fix-utils.js +0 -39
- package/dist/helpers/fix-utils.js.map +0 -7
- package/eslint.config.js +0 -53
package/dist/amqp.js
CHANGED
|
@@ -1,257 +1,273 @@
|
|
|
1
|
-
import amqplib from
|
|
2
|
-
import createDebugLogger from
|
|
3
|
-
import { promisify, inspect } from
|
|
4
|
-
import httpStatus from
|
|
5
|
-
import { MarcRecord } from
|
|
6
|
-
import { createLogger, Error as ApiError } from
|
|
1
|
+
import amqplib from 'amqplib';
|
|
2
|
+
import createDebugLogger from 'debug';
|
|
3
|
+
import { promisify, inspect } from 'util';
|
|
4
|
+
import httpStatus from 'http-status';
|
|
5
|
+
import { MarcRecord } from '@natlibfi/marc-record';
|
|
6
|
+
import { createLogger, Error as ApiError } from '@natlibfi/melinda-commons';
|
|
7
7
|
import { CHUNK_SIZE } from "./constants.js";
|
|
8
8
|
import { logError } from "./utils.js";
|
|
9
|
-
export default async function(AMQP_URL, runHealthCheck = false, deps = {}) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
export default async function (AMQP_URL, runHealthCheck = false, deps = {}) {
|
|
10
|
+
const logger = createLogger();
|
|
11
|
+
const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp');
|
|
12
|
+
const debugHC = debug.extend('HC');
|
|
13
|
+
const debugData = debug.extend('data');
|
|
14
|
+
const setTimeoutPromise = promisify(setTimeout);
|
|
15
|
+
debug(`Creating an AMQP operator to ${AMQP_URL}`);
|
|
16
|
+
const connection = deps.connection ?? await amqplib.connect(AMQP_URL);
|
|
17
|
+
const channel = deps.channel ?? await connection.createChannel();
|
|
18
|
+
let healthCheckRunning = runHealthCheck;
|
|
19
|
+
connection.on('error', (error) => {
|
|
20
|
+
debug(`Connection error: ${error}`);
|
|
21
|
+
logError(error);
|
|
22
|
+
});
|
|
23
|
+
connection.on('close', () => {
|
|
24
|
+
healthCheckRunning = false;
|
|
25
|
+
});
|
|
26
|
+
channel.on('error', (error) => {
|
|
27
|
+
debug(`Channel error: ${error}`);
|
|
28
|
+
logError(error);
|
|
29
|
+
});
|
|
30
|
+
channel.on('close', () => {
|
|
31
|
+
healthCheckRunning = false;
|
|
32
|
+
});
|
|
33
|
+
const healthCheckLoop = runHealthCheck ? healthCheck() : false;
|
|
34
34
|
debug(`Connection: ${connection}`);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
debug(`Channel: ${channel}`);
|
|
36
|
+
debug(`HealthCheckLoop: ${healthCheckLoop ? 'Running health check' : 'Not running health check'}`);
|
|
37
|
+
return { checkQueue, consumeChunk, consumeOne, ackMessages, nackMessages, sendToQueue, removeQueue, messagesToRecords, closeChannel, closeConnection };
|
|
38
|
+
async function closeChannel() {
|
|
39
|
+
healthCheckRunning = false;
|
|
40
|
+
debug(`Closing channel`);
|
|
41
|
+
await channel.close();
|
|
42
|
+
debug(`Channel: ${channel}`);
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
async function closeConnection() {
|
|
45
|
+
healthCheckRunning = false;
|
|
46
|
+
debug(`Closing connection`);
|
|
47
|
+
await connection.close();
|
|
48
|
+
debug(`Connection: ${connection}`);
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
async function healthCheck(wait = false) {
|
|
51
|
+
if (!healthCheckRunning) {
|
|
52
|
+
debugHC(`HealthCheck cancelled, not running`);
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (wait) {
|
|
56
|
+
await setTimeoutPromise(wait);
|
|
57
|
+
return healthCheck(false);
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
debugHC(`Health checking amqp by asserting a queue`);
|
|
61
|
+
await channel.assertQueue('HEALTHCHECK', { durable: false });
|
|
62
|
+
debugHC(`Waiting 200ms before running healthCheck next`);
|
|
63
|
+
return healthCheck(200);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
debugHC(`HealthCheck error ${JSON.stringify(error)}`);
|
|
67
|
+
if (!healthCheckRunning) {
|
|
68
|
+
debugHC(`HealthCheck cancelled while erroring, not throwing`);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
handleAmqpErrors(error);
|
|
72
|
+
}
|
|
57
73
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
async function checkQueue({ queue, style = 'basic', toRecord = true, purge = false }) {
|
|
75
|
+
debug(`checkQueue: ${queue}, Style: ${style}, toRecord: ${toRecord}, Purge: ${purge}`);
|
|
76
|
+
try {
|
|
77
|
+
errorUndefinedQueue(queue);
|
|
78
|
+
const channelInfo = await channel.assertQueue(queue, { durable: true });
|
|
79
|
+
if (purge) {
|
|
80
|
+
await purgeQueue(purge);
|
|
81
|
+
logger.verbose(`Queue ${queue} has purged ${channelInfo.messageCount} messages`);
|
|
82
|
+
debug(`Queue ${queue} has purged ${channelInfo.messageCount} messages`);
|
|
83
|
+
return checkQueue({ queue, style });
|
|
84
|
+
}
|
|
85
|
+
if (style === 'messages') {
|
|
86
|
+
return channelInfo.messageCount;
|
|
87
|
+
}
|
|
88
|
+
if (style === 'one') {
|
|
89
|
+
if (checkMessageCount(channelInfo)) {
|
|
90
|
+
return consumeOne(queue, toRecord);
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
if (style === 'basic') {
|
|
95
|
+
if (checkMessageCount(channelInfo)) {
|
|
96
|
+
return consumeChunk(queue, toRecord);
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `CheckQueue does not recognize style ${style}`);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
handleAmqpErrors(error);
|
|
76
104
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
105
|
+
function checkMessageCount(channelInfo) {
|
|
106
|
+
if (channelInfo.messageCount < 1) {
|
|
107
|
+
debug(`checkQueue: ${channelInfo.messageCount} - ${queue} is empty`);
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
debug(`Queue ${queue} has ${channelInfo.messageCount} messages`);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
function purgeQueue(purge) {
|
|
114
|
+
debug(`Purging queue: ${queue}, purge: ${purge}`);
|
|
115
|
+
if (purge) {
|
|
116
|
+
return channel.purgeQueue(queue);
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
82
119
|
}
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `CheckQueue does not recognize style ${style}`);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
handleAmqpErrors(error);
|
|
88
120
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
121
|
+
async function consumeChunk(queue, toRecord) {
|
|
122
|
+
debug(`Prepared to consumeChunk from queue: ${queue}`);
|
|
123
|
+
try {
|
|
124
|
+
await channel.assertQueue(queue, { durable: true });
|
|
125
|
+
const messages = await getData(queue);
|
|
126
|
+
if (messages.length === 0) {
|
|
127
|
+
debug(`consumeChunk: queue ${queue} drained, returning false`);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
const headers = getHeaderInfo(messages[0]);
|
|
131
|
+
debug(`consumeChunk (${messages ? messages.length : '0'} from queue ${queue}) ${toRecord ? 'to records' : 'just messages'}`);
|
|
132
|
+
if (toRecord) {
|
|
133
|
+
const records = messagesToRecords(messages);
|
|
134
|
+
return { headers, records, messages };
|
|
135
|
+
}
|
|
136
|
+
return { headers, messages };
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
handleAmqpErrors(error);
|
|
140
|
+
}
|
|
96
141
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
142
|
+
async function consumeOne(queue, toRecord) {
|
|
143
|
+
debug(`Prepared to consumeOne from queue: ${queue}`);
|
|
144
|
+
try {
|
|
145
|
+
await channel.assertQueue(queue, { durable: true });
|
|
146
|
+
const message = await channel.get(queue);
|
|
147
|
+
debugData(`Message: ${inspect(message, { colors: true, maxArrayLength: 3, depth: 3 })}`);
|
|
148
|
+
debug(`consumeOne from queue: ${queue} ${toRecord ? 'to records' : 'just the message'}`);
|
|
149
|
+
if (message) {
|
|
150
|
+
if (toRecord) {
|
|
151
|
+
const headers = getHeaderInfo(message);
|
|
152
|
+
const records = messagesToRecords([message]);
|
|
153
|
+
return { headers, records, messages: [message] };
|
|
154
|
+
}
|
|
155
|
+
return message;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
handleAmqpErrors(error);
|
|
161
|
+
}
|
|
102
162
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const messages = await getData(queue);
|
|
109
|
-
if (messages.length === 0) {
|
|
110
|
-
debug(`consumeChunk: queue ${queue} drained, returning false`);
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const headers = getHeaderInfo(messages[0]);
|
|
114
|
-
debug(`consumeChunk (${messages ? messages.length : "0"} from queue ${queue}) ${toRecord ? "to records" : "just messages"}`);
|
|
115
|
-
if (toRecord) {
|
|
116
|
-
const records = messagesToRecords(messages);
|
|
117
|
-
return { headers, records, messages };
|
|
118
|
-
}
|
|
119
|
-
return { headers, messages };
|
|
120
|
-
} catch (error) {
|
|
121
|
-
handleAmqpErrors(error);
|
|
163
|
+
function ackMessages(messages) {
|
|
164
|
+
messages.forEach(message => {
|
|
165
|
+
debug(`Ack message ${message.properties.correlationId}`);
|
|
166
|
+
channel.ack(message);
|
|
167
|
+
});
|
|
122
168
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
169
|
+
function nackMessages(messages) {
|
|
170
|
+
messages.forEach(message => {
|
|
171
|
+
debug(`Nack message ${message.properties.correlationId}`);
|
|
172
|
+
channel.nack(message);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async function sendToQueue({ queue, correlationId, headers, data }) {
|
|
176
|
+
debug(`sendToQueue`);
|
|
177
|
+
try {
|
|
178
|
+
debug(`Queue ${queue}`);
|
|
179
|
+
debug(`CorrelationId ${correlationId}`);
|
|
180
|
+
debugData(`Data ${JSON.stringify(data)}`);
|
|
181
|
+
debug(`Headers ${JSON.stringify(headers)}`);
|
|
182
|
+
errorUndefinedQueue(queue);
|
|
183
|
+
debug(`Asserting queue: ${queue}`);
|
|
184
|
+
await channel.assertQueue(queue, { durable: true });
|
|
185
|
+
debug(`Actually sendToQueue: ${queue}`);
|
|
186
|
+
await channel.sendToQueue(queue, Buffer.from(JSON.stringify({ data })), {
|
|
187
|
+
correlationId,
|
|
188
|
+
persistent: true,
|
|
189
|
+
headers
|
|
190
|
+
});
|
|
191
|
+
debug(`Send message for ${correlationId} to queue: ${queue}`);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
const errorToThrow = error;
|
|
195
|
+
debug(`SendToQueue errored: ${JSON.stringify(error)}`);
|
|
196
|
+
handleAmqpErrors(errorToThrow);
|
|
136
197
|
}
|
|
137
|
-
return message;
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
} catch (error) {
|
|
141
|
-
handleAmqpErrors(error);
|
|
142
198
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
async function sendToQueue({ queue, correlationId, headers, data }) {
|
|
157
|
-
debug(`sendToQueue`);
|
|
158
|
-
try {
|
|
159
|
-
debug(`Queue ${queue}`);
|
|
160
|
-
debug(`CorrelationId ${correlationId}`);
|
|
161
|
-
debugData(`Data ${JSON.stringify(data)}`);
|
|
162
|
-
debug(`Headers ${JSON.stringify(headers)}`);
|
|
163
|
-
errorUndefinedQueue(queue);
|
|
164
|
-
debug(`Asserting queue: ${queue}`);
|
|
165
|
-
await channel.assertQueue(queue, { durable: true });
|
|
166
|
-
debug(`Actually sendToQueue: ${queue}`);
|
|
167
|
-
await channel.sendToQueue(
|
|
168
|
-
queue,
|
|
169
|
-
Buffer.from(JSON.stringify({ data })),
|
|
170
|
-
{
|
|
171
|
-
correlationId,
|
|
172
|
-
persistent: true,
|
|
173
|
-
headers
|
|
199
|
+
async function removeQueue(queue) {
|
|
200
|
+
let tempChannel;
|
|
201
|
+
try {
|
|
202
|
+
tempChannel = await connection.createChannel();
|
|
203
|
+
logger.verbose(`Removing queue ${queue}.`);
|
|
204
|
+
debug(`Removing queue ${queue}.`);
|
|
205
|
+
await tempChannel.deleteQueue(queue);
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
if (tempChannel) {
|
|
209
|
+
await tempChannel.close();
|
|
210
|
+
}
|
|
174
211
|
}
|
|
175
|
-
);
|
|
176
|
-
debug(`Send message for ${correlationId} to queue: ${queue}`);
|
|
177
|
-
} catch (error) {
|
|
178
|
-
const errorToThrow = error;
|
|
179
|
-
debug(`SendToQueue errored: ${JSON.stringify(error)}`);
|
|
180
|
-
handleAmqpErrors(errorToThrow);
|
|
181
212
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
debug(`Removing queue ${queue}.`);
|
|
189
|
-
await tempChannel.deleteQueue(queue);
|
|
190
|
-
} finally {
|
|
191
|
-
if (tempChannel) {
|
|
192
|
-
await tempChannel.close();
|
|
193
|
-
}
|
|
213
|
+
function messagesToRecords(messages) {
|
|
214
|
+
debug(`Parsing messages (${messages.length}) to records`);
|
|
215
|
+
return messages.map(message => {
|
|
216
|
+
const content = JSON.parse(message.content.toString());
|
|
217
|
+
return new MarcRecord(content.data, { subfieldValues: false });
|
|
218
|
+
});
|
|
194
219
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
220
|
+
async function getData(queue) {
|
|
221
|
+
debug(`Getting queue data from ${queue}`);
|
|
222
|
+
try {
|
|
223
|
+
const { messageCount } = await channel.checkQueue(queue);
|
|
224
|
+
debug(`There is ${messageCount} messages in queue ${queue}`);
|
|
225
|
+
const messagesToGet = messageCount >= CHUNK_SIZE ? CHUNK_SIZE : messageCount;
|
|
226
|
+
debug(`Getting ${messagesToGet} messages from queue ${queue}`);
|
|
227
|
+
const messages = await pump(messagesToGet);
|
|
228
|
+
debug(`Returning ${messages.length} unique messages`);
|
|
229
|
+
return messages;
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
handleAmqpErrors(error);
|
|
233
|
+
}
|
|
234
|
+
async function pump(count, results = [], identifiers = []) {
|
|
235
|
+
if (count === 0) {
|
|
236
|
+
return results;
|
|
237
|
+
}
|
|
238
|
+
const message = await channel.get(queue);
|
|
239
|
+
if (!message) {
|
|
240
|
+
return results;
|
|
241
|
+
}
|
|
242
|
+
const identifier = {
|
|
243
|
+
correlationId: message.properties.correlationId,
|
|
244
|
+
deliveryTag: message.fields.deliveryTag
|
|
245
|
+
};
|
|
246
|
+
const isDuplicate = identifiers.some(i => i.correlationId === identifier.correlationId && i.deliveryTag === identifier.deliveryTag);
|
|
247
|
+
if (isDuplicate) {
|
|
248
|
+
return pump(count - 1, results, identifiers);
|
|
249
|
+
}
|
|
250
|
+
return pump(count - 1, results.concat(message), identifiers.concat(identifier));
|
|
251
|
+
}
|
|
215
252
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return results;
|
|
219
|
-
}
|
|
220
|
-
const message = await channel.get(queue);
|
|
221
|
-
if (!message) {
|
|
222
|
-
return results;
|
|
223
|
-
}
|
|
224
|
-
const identifier = {
|
|
225
|
-
correlationId: message.properties.correlationId,
|
|
226
|
-
deliveryTag: message.fields.deliveryTag
|
|
227
|
-
};
|
|
228
|
-
const isDuplicate = identifiers.some(
|
|
229
|
-
(i) => i.correlationId === identifier.correlationId && i.deliveryTag === identifier.deliveryTag
|
|
230
|
-
);
|
|
231
|
-
if (isDuplicate) {
|
|
232
|
-
return pump(count - 1, results, identifiers);
|
|
233
|
-
}
|
|
234
|
-
return pump(count - 1, results.concat(message), identifiers.concat(identifier));
|
|
253
|
+
function getHeaderInfo(data) {
|
|
254
|
+
return data.properties.headers;
|
|
235
255
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
function errorUndefinedQueue(queue) {
|
|
241
|
-
if (queue === void 0 || queue === "" || queue === null) {
|
|
242
|
-
throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Undefined queue!`);
|
|
256
|
+
function errorUndefinedQueue(queue) {
|
|
257
|
+
if (queue === undefined || queue === '' || queue === null) {
|
|
258
|
+
throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Undefined queue!`);
|
|
259
|
+
}
|
|
243
260
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
261
|
+
function handleAmqpErrors(error) {
|
|
262
|
+
const newError = error;
|
|
263
|
+
debug(`HandleAmqpErrors got an error: ${JSON.stringify(error)}`);
|
|
264
|
+
if (error instanceof ApiError) {
|
|
265
|
+
debug(`We have an ApiError`);
|
|
266
|
+
throw new ApiError(error.status, error.payload);
|
|
267
|
+
}
|
|
268
|
+
debug(`We have a non-ApiError`);
|
|
269
|
+
logError(error);
|
|
270
|
+
throw newError;
|
|
251
271
|
}
|
|
252
|
-
debug(`We have a non-ApiError`);
|
|
253
|
-
logError(error);
|
|
254
|
-
throw newError;
|
|
255
|
-
}
|
|
256
272
|
}
|
|
257
|
-
//# sourceMappingURL=amqp.js.map
|
|
273
|
+
//# sourceMappingURL=amqp.js.map
|
package/dist/amqp.js.map
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/amqp.js"],
|
|
4
|
-
"sourcesContent": ["import amqplib from 'amqplib';\nimport createDebugLogger from 'debug';\nimport {promisify, inspect} from 'util';\nimport httpStatus from 'http-status';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {createLogger, Error as ApiError} from '@natlibfi/melinda-commons';\nimport {CHUNK_SIZE} from './constants.js';\nimport {logError} from './utils.js';\n\nexport default async function (AMQP_URL, runHealthCheck = false, deps = {}) {\n const logger = createLogger();\n const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp');\n const debugHC = debug.extend('HC');\n const debugData = debug.extend('data');\n const setTimeoutPromise = promisify(setTimeout);\n\n debug(`Creating an AMQP operator to ${AMQP_URL}`);\n // deps allows injecting stubbed connection/channel in unit tests\n const connection = deps.connection ?? await amqplib.connect(AMQP_URL);\n const channel = deps.channel ?? await connection.createChannel();\n\n // the recursive healthCheck loop is never awaited and kept firing\n // ~every 200 ms even after the connection was closed. This flag is cleared\n // by closeChannel/closeConnection so the loop short-circuits on graceful\n // shutdown instead of running until the closed channel throws.\n let healthCheckRunning = runHealthCheck;\n const healthCheckLoop = runHealthCheck ? healthCheck() : false;\n\n debug(`Connection: ${connection}`);\n debug(`Channel: ${channel}`);\n debug(`HealthCheckLoop: ${healthCheckLoop ? 'Running health check' : 'Not running health check'}`);\n\n return {checkQueue, consumeChunk, consumeOne, ackMessages, nackMessages, sendToQueue, removeQueue, messagesToRecords, closeChannel, closeConnection};\n\n async function closeChannel() {\n // stop the health check loop before closing so it does not keep\n // firing on a closed channel during graceful shutdown\n healthCheckRunning = false;\n debug(`Closing channel`);\n await channel.close();\n debug(`Channel: ${channel}`);\n }\n\n async function closeConnection() {\n // stop the health check loop before closing\n healthCheckRunning = false;\n debug(`Closing connection`);\n await connection.close();\n debug(`Connection: ${connection}`);\n }\n\n async function healthCheck(wait = false) {\n // cancellable - closeChannel/closeConnection set this to false\n if (!healthCheckRunning) {\n debugHC(`HealthCheck cancelled, not running`);\n return false;\n }\n if (wait) {\n await setTimeoutPromise(wait);\n return healthCheck(false);\n }\n\n try {\n debugHC(`Health checking amqp by asserting a queue`);\n await channel.assertQueue('HEALTHCHECK', {durable: false});\n debugHC(`Waiting 200ms before running healthCheck next`);\n return healthCheck(200);\n } catch (error) {\n debugHC(`HealthCheck error ${JSON.stringify(error)}`);\n // if we were asked to stop, do not rethrow - a closed channel\n // throwing during shutdown would keep the process alive / crash it\n if (!healthCheckRunning) {\n debugHC(`HealthCheck cancelled while erroring, not throwing`);\n return false;\n }\n handleAmqpErrors(error);\n }\n }\n\n async function checkQueue({queue, style = 'basic', toRecord = true, purge = false}) {\n debug(`checkQueue: ${queue}, Style: ${style}, toRecord: ${toRecord}, Purge: ${purge}`);\n\n try {\n\n errorUndefinedQueue(queue);\n const channelInfo = await channel.assertQueue(queue, {durable: true});\n\n if (purge) {\n await purgeQueue(purge);\n logger.verbose(`Queue ${queue} has purged ${channelInfo.messageCount} messages`);\n debug(`Queue ${queue} has purged ${channelInfo.messageCount} messages`);\n return checkQueue({queue, style});\n }\n\n if (style === 'messages') {\n return channelInfo.messageCount;\n }\n\n\n // Note: returns one message (+ record, of toRecord: true)\n // note: if toRecord is false returns just plain message / false\n // note: if toRecord is true returns {headers, records, messages} -object / false\n // should this be more consistent?\n if (style === 'one') {\n if (checkMessageCount(channelInfo)) {\n return consumeOne(queue, toRecord);\n }\n return false;\n }\n\n // Note: returns a chunk of (100) messages (+ records, if toRecord: true)\n // returns {headers, records, messages} object or {headers, messages} object depending on toRecord\n if (style === 'basic') {\n if (checkMessageCount(channelInfo)) {\n return consumeChunk(queue, toRecord);\n }\n return false;\n }\n\n // Defaults:\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `CheckQueue does not recognize style ${style}`);\n } catch (error) {\n handleAmqpErrors(error);\n }\n\n function checkMessageCount(channelInfo) {\n if (channelInfo.messageCount < 1) {\n debug(`checkQueue: ${channelInfo.messageCount} - ${queue} is empty`);\n return false;\n }\n debug(`Queue ${queue} has ${channelInfo.messageCount} messages`);\n return true;\n }\n\n function purgeQueue(purge) {\n debug(`Purging queue: ${queue}, purge: ${purge}`);\n if (purge) {\n return channel.purgeQueue(queue);\n }\n }\n }\n\n async function consumeChunk(queue, toRecord) {\n debug(`Prepared to consumeChunk from queue: ${queue}`);\n try {\n await channel.assertQueue(queue, {durable: true});\n\n // getData: next chunk (100) messages\n const messages = await getData(queue);\n\n // queue can drain before/during the pump -> nothing to return,\n // matches the `false` contract checkQueue uses for an empty queue\n if (messages.length === 0) {\n debug(`consumeChunk: queue ${queue} drained, returning false`);\n return false;\n }\n\n // Note: headers are from the first message of the chunk\n const headers = getHeaderInfo(messages[0]);\n debug(`consumeChunk (${messages ? messages.length : '0'} from queue ${queue}) ${toRecord ? 'to records' : 'just messages'}`);\n\n if (toRecord) {\n const records = messagesToRecords(messages);\n return {headers, records, messages};\n }\n\n return {headers, messages};\n } catch (error) {\n handleAmqpErrors(error);\n }\n }\n\n async function consumeOne(queue, toRecord) {\n debug(`Prepared to consumeOne from queue: ${queue}`);\n try {\n await channel.assertQueue(queue, {durable: true});\n\n // Returns false if 0 items in queue\n const message = await channel.get(queue);\n\n debugData(`Message: ${inspect(message, {colors: true, maxArrayLength: 3, depth: 3})}`);\n // Do not spam the logs\n debug(`consumeOne from queue: ${queue} ${toRecord ? 'to records' : 'just the message'}`);\n\n if (message) {\n if (toRecord) {\n const headers = getHeaderInfo(message);\n const records = messagesToRecords([message]);\n return {headers, records, messages: [message]};\n }\n\n return message;\n }\n\n return false;\n } catch (error) {\n handleAmqpErrors(error);\n }\n }\n\n function ackMessages(messages) {\n messages.forEach(message => {\n debug(`Ack message ${message.properties.correlationId}`);\n channel.ack(message);\n });\n }\n\n function nackMessages(messages) {\n messages.forEach(message => {\n debug(`Nack message ${message.properties.correlationId}`);\n channel.nack(message);\n });\n }\n\n async function sendToQueue({queue, correlationId, headers, data}) {\n debug(`sendToQueue`);\n try {\n debug(`Queue ${queue}`);\n debug(`CorrelationId ${correlationId}`);\n debugData(`Data ${JSON.stringify(data)}`);\n debug(`Headers ${JSON.stringify(headers)}`);\n\n errorUndefinedQueue(queue);\n\n debug(`Asserting queue: ${queue}`);\n await channel.assertQueue(queue, {durable: true});\n\n // `correlationId` is deliberately delivered ONLY via AMQP message\n // properties (headers) \u2014 it is NOT included in the message body\n // (which is just `JSON.stringify({data})`). Consumers MUST read it from\n // `message.properties.correlationId`, not from the body. Do not add it\n // to the body without changing the message contract.\n debug(`Actually sendToQueue: ${queue}`);\n await channel.sendToQueue(\n queue,\n Buffer.from(JSON.stringify({data})),\n {\n correlationId,\n persistent: true,\n headers\n }\n );\n debug(`Send message for ${correlationId} to queue: ${queue}`);\n\n\n } catch (error) {\n const errorToThrow = error;\n //if (error instanceof ApiError) {\n // throw error;\n //}\n debug(`SendToQueue errored: ${JSON.stringify(error)}`);\n handleAmqpErrors(errorToThrow);\n }\n }\n\n async function removeQueue(queue) {\n // deleteQueue borks the channel if the queue does not exist\n // -> use throwaway tempChannel to avoid killing actual channel in use\n // this might be doable also with assertQueue before deleteQueue\n let tempChannel;\n try {\n tempChannel = await connection.createChannel();\n logger.verbose(`Removing queue ${queue}.`);\n debug(`Removing queue ${queue}.`);\n await tempChannel.deleteQueue(queue);\n } finally {\n // if deleteQueue throws (e.g. the queue does not exist) the\n // throwaway channel used to leak -> always close it\n if (tempChannel) {\n await tempChannel.close();\n }\n }\n }\n\n // ----------------\n // Helper functions\n // ----------------\n\n function messagesToRecords(messages) {\n debug(`Parsing messages (${messages.length}) to records`);\n\n return messages.map(message => {\n const content = JSON.parse(message.content.toString());\n // Use subfieldValues: false validationOption here\n return new MarcRecord(content.data, {subfieldValues: false});\n });\n }\n\n async function getData(queue) {\n debug(`Getting queue data from ${queue}`);\n try {\n const {messageCount} = await channel.checkQueue(queue);\n debug(`There is ${messageCount} messages in queue ${queue}`);\n const messagesToGet = messageCount >= CHUNK_SIZE ? CHUNK_SIZE : messageCount;\n debug(`Getting ${messagesToGet} messages from queue ${queue}`);\n\n const messages = await pump(messagesToGet);\n\n debug(`Returning ${messages.length} unique messages`);\n\n return messages;\n } catch (error) {\n handleAmqpErrors(error);\n }\n\n async function pump(count, results = [], identifiers = []) {\n if (count === 0) {\n return results;\n }\n\n const message = await channel.get(queue);\n // queue can drain between the messageCount read and channel.get\n // (race, purge, other consumer) -> channel.get returns null\n if (!message) {\n return results;\n }\n\n const identifier = {\n correlationId: message.properties.correlationId,\n deliveryTag: message.fields.deliveryTag\n };\n // filter not unique messages (compare by key, not by object reference)\n const isDuplicate = identifiers.some(\n i => i.correlationId === identifier.correlationId && i.deliveryTag === identifier.deliveryTag\n );\n if (isDuplicate) {\n return pump(count - 1, results, identifiers);\n }\n\n return pump(count - 1, results.concat(message), identifiers.concat(identifier));\n }\n }\n\n function getHeaderInfo(data) {\n return data.properties.headers;\n }\n\n function errorUndefinedQueue(queue) {\n if (queue === undefined || queue === '' || queue === null) {\n throw new ApiError(httpStatus.INTERNAL_SERVER_ERROR, `Undefined queue!`);\n }\n }\n\n function handleAmqpErrors(error) {\n const newError = error;\n debug(`HandleAmqpErrors got an error: ${JSON.stringify(error)}`);\n if (error instanceof ApiError) {\n debug(`We have an ApiError`);\n throw new ApiError(newError.status, newError.payload);\n }\n debug(`We have a non-ApiError`);\n logError(error);\n throw newError;\n }\n}\n\n\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,aAAa;AACpB,OAAO,uBAAuB;AAC9B,SAAQ,WAAW,eAAc;AACjC,OAAO,gBAAgB;AACvB,SAAQ,kBAAiB;AACzB,SAAQ,cAAc,SAAS,gBAAe;AAC9C,SAAQ,kBAAiB;AACzB,SAAQ,gBAAe;AAEvB,8BAA+B,UAAU,iBAAiB,OAAO,OAAO,CAAC,GAAG;AAC1E,QAAM,SAAS,aAAa;AAC5B,QAAM,QAAQ,kBAAkB,yCAAyC;AACzE,QAAM,UAAU,MAAM,OAAO,IAAI;AACjC,QAAM,YAAY,MAAM,OAAO,MAAM;AACrC,QAAM,oBAAoB,UAAU,UAAU;AAE9C,QAAM,gCAAgC,QAAQ,EAAE;AAEhD,QAAM,aAAa,KAAK,cAAc,MAAM,QAAQ,QAAQ,QAAQ;AACpE,QAAM,UAAU,KAAK,WAAW,MAAM,WAAW,cAAc;AAM/D,MAAI,qBAAqB;AACzB,QAAM,kBAAkB,iBAAiB,YAAY,IAAI;AAEzD,QAAM,eAAe,UAAU,EAAE;AACjC,QAAM,YAAY,OAAO,EAAE;AAC3B,QAAM,oBAAoB,kBAAkB,yBAAyB,0BAA0B,EAAE;AAEjG,SAAO,EAAC,YAAY,cAAc,YAAY,aAAa,cAAc,aAAa,aAAa,mBAAmB,cAAc,gBAAe;AAEnJ,iBAAe,eAAe;AAG5B,yBAAqB;AACrB,UAAM,iBAAiB;AACvB,UAAM,QAAQ,MAAM;AACpB,UAAM,YAAY,OAAO,EAAE;AAAA,EAC7B;AAEA,iBAAe,kBAAkB;AAE/B,yBAAqB;AACrB,UAAM,oBAAoB;AAC1B,UAAM,WAAW,MAAM;AACvB,UAAM,eAAe,UAAU,EAAE;AAAA,EACnC;AAEA,iBAAe,YAAY,OAAO,OAAO;AAEvC,QAAI,CAAC,oBAAoB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,CAAC,KAAgC;QAC3D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1D,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAMD,SAAS,gBAAgB,CAAC,KAAc;QACtC,MAAM,QAAQ,GAAG,KAAK,CAAC;QACvB,KAAK,CAAC,kCAAkC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjE,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;YAC9B,KAAK,CAAC,qBAAqB,CAAC,CAAC;YAC7B,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;QACD,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAChC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAChB,MAAM,QAAQ,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const QUEUE_ITEM_STATE: {
|
|
2
|
+
readonly VALIDATOR: {
|
|
3
|
+
readonly PENDING_QUEUING: "PENDING_QUEUING";
|
|
4
|
+
readonly PENDING_VALIDATION: "PENDING_VALIDATION";
|
|
5
|
+
readonly QUEUING_IN_PROGRESS: "QUEUING_IN_PROGRESS";
|
|
6
|
+
readonly UPLOADING: "UPLOADING";
|
|
7
|
+
readonly VALIDATING: "VALIDATING";
|
|
8
|
+
readonly WAITING_FOR_RECORDS: "WAITING_FOR_RECORDS";
|
|
9
|
+
};
|
|
10
|
+
readonly IMPORTER: {
|
|
11
|
+
readonly IMPORTING: "IMPORTING";
|
|
12
|
+
readonly IN_PROCESS: "IN_PROCESS";
|
|
13
|
+
readonly IN_QUEUE: "IN_QUEUE";
|
|
14
|
+
};
|
|
15
|
+
readonly DONE: "DONE";
|
|
16
|
+
readonly ERROR: "ERROR";
|
|
17
|
+
readonly ABORT: "ABORT";
|
|
18
|
+
};
|
|
19
|
+
export declare const IMPORT_JOB_STATE: {
|
|
20
|
+
readonly EMPTY: "EMPTY";
|
|
21
|
+
readonly QUEUING: "QUEUING";
|
|
22
|
+
readonly IN_QUEUE: "IN_QUEUE";
|
|
23
|
+
readonly IMPORTING: "IMPORTING";
|
|
24
|
+
readonly PROCESSING: "PROCESSING";
|
|
25
|
+
readonly DONE: "DONE";
|
|
26
|
+
readonly ERROR: "ERROR";
|
|
27
|
+
readonly ABORT: "ABORT";
|
|
28
|
+
};
|
|
29
|
+
export declare const OPERATIONS: {
|
|
30
|
+
readonly CREATE: "CREATE";
|
|
31
|
+
readonly UPDATE: "UPDATE";
|
|
32
|
+
readonly FIX: "FIX";
|
|
33
|
+
};
|
|
34
|
+
export declare const CHUNK_SIZE = 100;
|
|
35
|
+
export declare const LOG_ITEM_TYPE: {
|
|
36
|
+
readonly INPUT_RECORD_LOG: "INPUT_RECORD_LOG";
|
|
37
|
+
readonly MERGE_LOG: "MERGE_LOG";
|
|
38
|
+
readonly MATCH_LOG: "MATCH_LOG";
|
|
39
|
+
readonly RESULT_RECORD_LOG: "RESULT_RECORD_LOG";
|
|
40
|
+
readonly SPLITTER_LOG: "SPLITTER_LOG";
|
|
41
|
+
readonly LOAD_PROCESS_LOG: "LOAD_PROCESS_LOG";
|
|
42
|
+
};
|
|
43
|
+
export declare const CONVERSION_FORMATS: {
|
|
44
|
+
readonly MARCXML: "MARCXML";
|
|
45
|
+
readonly ISO2709: "ISO2709";
|
|
46
|
+
readonly JSON: "JSON";
|
|
47
|
+
readonly ALEPHSEQ: "ALEPHSEQ";
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;CAiBnB,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;CASnB,CAAC;AAEX,eAAO,MAAM,UAAU;;;;CAIb,CAAC;AAEX,eAAO,MAAM,UAAU,MAAM,CAAC;AAI9B,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC"}
|