@natlibfi/melinda-rest-api-commons 2.3.1-alpha.7 → 2.3.2-alpha.10
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/amqp.health.spec.js +69 -0
- package/dist/amqp.health.spec.js.map +1 -0
- package/dist/amqp.js +135 -92
- package/dist/amqp.js.map +1 -1
- package/dist/amqp.tests.spec.js +338 -0
- package/dist/amqp.tests.spec.js.map +1 -0
- package/dist/constants.js +5 -3
- package/dist/constants.js.map +1 -1
- package/dist/helpers/conversion.js +5 -25
- package/dist/helpers/conversion.js.map +1 -1
- package/dist/helpers/conversion.spec.js +1 -7
- package/dist/helpers/conversion.spec.js.map +1 -1
- package/dist/helpers/fix-constants.js +98 -0
- package/dist/helpers/fix-constants.js.map +1 -0
- package/dist/helpers/fix-handle-tempurns.js +153 -0
- package/dist/helpers/fix-handle-tempurns.js.map +1 -0
- package/dist/helpers/fix-strip-f884s.js +87 -0
- package/dist/helpers/fix-strip-f884s.js.map +1 -0
- package/dist/helpers/fix-utils.js +82 -0
- package/dist/helpers/fix-utils.js.map +1 -0
- package/dist/helpers/fix.js +178 -0
- package/dist/helpers/fix.js.map +1 -0
- package/dist/helpers/fix.spec.js +46 -0
- package/dist/helpers/fix.spec.js.map +1 -0
- package/dist/helpers/validation.js +0 -6
- package/dist/helpers/validation.js.map +1 -1
- package/dist/helpers/validation.spec.js +1 -7
- package/dist/helpers/validation.spec.js.map +1 -1
- package/dist/index.js +12 -18
- package/dist/index.js.map +1 -1
- package/dist/mongo.js +50 -89
- package/dist/mongo.js.map +1 -1
- package/dist/mongo.spec.js.draft +54 -0
- package/dist/mongoLog.js +16 -35
- package/dist/mongoLog.js.map +1 -1
- package/dist/utils.js +34 -36
- package/dist/utils.js.map +1 -1
- package/package.json +122 -115
- package/dist/helpers/format.js +0 -148
- package/dist/helpers/format.js.map +0 -1
- package/dist/helpers/format.spec.js +0 -123
- package/dist/helpers/format.spec.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","names":["formatRecord","record","settings","logger","createLogger","verbose","newRecord","MarcRecord","clone","subfieldValues","generateMissingSIDs","forEach","options","replacePrefixes","toObject","oldPrefix","newPrefix","prefixReplaceCodes","pattern","replacement","getDatafields","field","subfields","filter","code","includes","subfield","value","replace","f035Filters","fSIDFilters","f035s","f035ToSidInfo","get","fSIDs","sidsToSidInfo","sidsToBeAdded","genNewSids","length","f035SidInfo","some","fSIDInfo","SID","sidField","insertField","map","sidInfo","tag","ind1","ind2","SIDs","flatMap","sub","undefined","wantedSub","regexp","test","findIndex","slice","indexOf","BIB_FORMAT_SETTINGS"],"sources":["../../src/helpers/format.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {createLogger} from '@natlibfi/melinda-backend-commons';\n\nexport function formatRecord(record, settings = []) {\n const logger = createLogger();\n\n logger.verbose('Applying formating');\n const newRecord = MarcRecord.clone(record, {subfieldValues: false});\n\n generateMissingSIDs();\n\n settings.forEach(options => {\n replacePrefixes(options);\n });\n\n return newRecord.toObject();\n\n // Replace prefix in all specified subfields\n function replacePrefixes(options) {\n const {oldPrefix, newPrefix, prefixReplaceCodes} = options;\n const pattern = `(${oldPrefix})`;\n const replacement = `(${newPrefix})`;\n newRecord.getDatafields()\n .forEach(field => {\n field.subfields\n .filter(({code}) => prefixReplaceCodes.includes(code))\n .forEach(subfield => {\n subfield.value = subfield.value.replace(pattern, replacement); // eslint-disable-line functional/immutable-data\n });\n });\n }\n\n\n function generateMissingSIDs() {\n const f035Filters = [/^\\(FI-BTJ\\)/u, /^\\(FI-TATI\\)/u];\n const fSIDFilters = ['FI-BTJ', 'tati'];\n const f035s = f035ToSidInfo(newRecord.get(/^035$/u));\n const fSIDs = sidsToSidInfo(newRecord.get(/^SID$/u));\n\n const sidsToBeAdded = genNewSids(fSIDs.length === 0\n ? f035s\n // test that SIDs are not there yet\n : f035s.filter(f035SidInfo => fSIDs.some(fSIDInfo => f035SidInfo.SID !== fSIDInfo.SID && f035SidInfo.value !== fSIDInfo.value)));\n\n // Add new SIDs\n return sidsToBeAdded.forEach(sidField => newRecord.insertField(sidField));\n\n function genNewSids(sidsToBeAdded) {\n return sidsToBeAdded.map(sidInfo => ({tag: 'SID', ind1: ' ', ind2: ' ', subfields: [{code: 'c', value: sidInfo.value}, {code: 'b', value: sidInfo.SID}]}));\n }\n\n function sidsToSidInfo(SIDs) {\n return SIDs.flatMap(({subfields}) => {\n const [SID] = subfields.filter(sub => sub.code === 'b' && fSIDFilters.includes(sub.value)).map(sub => sub.value);\n const [value] = subfields.filter(sub => sub.code === 'c' && sub.value !== undefined).map(sub => sub.value);\n\n if (SID && value) {\n return {\n SID,\n value\n };\n }\n\n return undefined;\n }).filter(value => value !== undefined);\n }\n\n function f035ToSidInfo(f035s) {\n return f035s.flatMap(({subfields}) => {\n const [wantedSub] = subfields.filter(sub => sub.code === 'a' && f035Filters.some(regexp => regexp.test(sub.value)));\n\n if (wantedSub) {\n return {\n SID: fSIDFilters[f035Filters.findIndex(regexp => regexp.test(wantedSub.value))],\n value: wantedSub.value.slice(wantedSub.value.indexOf(')') + 1)\n };\n }\n\n return undefined;\n }).filter(value => value !== undefined);\n }\n }\n}\n\n// If placed in config.js testing needs envs\nexport const BIB_FORMAT_SETTINGS = [\n {\n oldPrefix: 'FI-MELINDA',\n newPrefix: 'FIN01',\n prefixReplaceCodes: ['w']\n },\n {\n oldPrefix: 'FI-ASTERI-S',\n newPrefix: 'FIN10',\n prefixReplaceCodes: ['0']\n },\n {\n oldPrefix: 'FI-ASTERI-N',\n newPrefix: 'FIN11',\n prefixReplaceCodes: ['0']\n }\n];\n"],"mappings":";;;;;;;;AA4BA;;AACA;;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKO,SAASA,YAAT,CAAsBC,MAAtB,EAA8BC,QAAQ,GAAG,EAAzC,EAA6C;EAClD,MAAMC,MAAM,GAAG,IAAAC,mCAAA,GAAf;EAEAD,MAAM,CAACE,OAAP,CAAe,oBAAf;;EACA,MAAMC,SAAS,GAAGC,sBAAA,CAAWC,KAAX,CAAiBP,MAAjB,EAAyB;IAACQ,cAAc,EAAE;EAAjB,CAAzB,CAAlB;;EAEAC,mBAAmB;EAEnBR,QAAQ,CAACS,OAAT,CAAiBC,OAAO,IAAI;IAC1BC,eAAe,CAACD,OAAD,CAAf;EACD,CAFD;EAIA,OAAON,SAAS,CAACQ,QAAV,EAAP,CAZkD,CAclD;;EACA,SAASD,eAAT,CAAyBD,OAAzB,EAAkC;IAChC,MAAM;MAACG,SAAD;MAAYC,SAAZ;MAAuBC;IAAvB,IAA6CL,OAAnD;IACA,MAAMM,OAAO,GAAI,IAAGH,SAAU,GAA9B;IACA,MAAMI,WAAW,GAAI,IAAGH,SAAU,GAAlC;IACAV,SAAS,CAACc,aAAV,GACGT,OADH,CACWU,KAAK,IAAI;MAChBA,KAAK,CAACC,SAAN,CACGC,MADH,CACU,CAAC;QAACC;MAAD,CAAD,KAA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B,SAAJ,EAAe;UACb,OAAO;YACLZ,GAAG,EAAEZ,WAAW,CAACD,WAAW,CAAC4B,SAAZ,CAAsBF,MAAM,IAAIA,MAAM,CAACC,IAAP,CAAYF,SAAS,CAAC3B,KAAtB,CAAhC,CAAD,CADX;YAELA,KAAK,EAAE2B,SAAS,CAAC3B,KAAV,CAAgB+B,KAAhB,CAAsBJ,SAAS,CAAC3B,KAAV,CAAgBgC,OAAhB,CAAwB,GAAxB,IAA+B,CAArD;UAFF,CAAP;QAID;;QAED,OAAON,SAAP;MACD,CAXM,EAWJ9B,MAXI,CAWGI,KAAK,IAAIA,KAAK,KAAK0B,SAXtB,CAAP;IAYD;EACF;AACF,C,CAED;;;AACO,MAAMO,mBAAmB,GAAG,CACjC;EACE7C,SAAS,EAAE,YADb;EAEEC,SAAS,EAAE,OAFb;EAGEC,kBAAkB,EAAE,CAAC,GAAD;AAHtB,CADiC,EAMjC;EACEF,SAAS,EAAE,aADb;EAEEC,SAAS,EAAE,OAFb;EAGEC,kBAAkB,EAAE,CAAC,GAAD;AAHtB,CANiC,EAWjC;EACEF,SAAS,EAAE,aADb;EAEEC,SAAS,EAAE,OAFb;EAGEC,kBAAkB,EAAE,CAAC,GAAD;AAHtB,CAXiC,CAA5B"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _chai = require("chai");
|
|
4
|
-
|
|
5
|
-
var _fixura = _interopRequireWildcard(require("@natlibfi/fixura"));
|
|
6
|
-
|
|
7
|
-
var _marcRecord = require("@natlibfi/marc-record");
|
|
8
|
-
|
|
9
|
-
var _format = require("./format");
|
|
10
|
-
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
|
|
13
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
18
|
-
*
|
|
19
|
-
* Shared modules for microservices of Melinda rest api batch import system
|
|
20
|
-
*
|
|
21
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
22
|
-
*
|
|
23
|
-
* This file is part of melinda-rest-api-commons
|
|
24
|
-
*
|
|
25
|
-
* melinda-rest-api-commons program is free software: you can redistribute it and/or modify
|
|
26
|
-
* it under the terms of the GNU Affero General Public License as
|
|
27
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
28
|
-
* License, or (at your option) any later version.
|
|
29
|
-
*
|
|
30
|
-
* melinda-rest-api-commons is distributed in the hope that it will be useful,
|
|
31
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
32
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
33
|
-
* GNU Affero General Public License for more details.
|
|
34
|
-
*
|
|
35
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
36
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
37
|
-
*
|
|
38
|
-
* @licend The above is the entire license notice
|
|
39
|
-
* for the JavaScript code in this file.
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
describe('services/format', () => {
|
|
43
|
-
const FIXTURES_PATH = [__dirname, '..', '..', 'test-fixtures', 'format'];
|
|
44
|
-
const {
|
|
45
|
-
getFixture
|
|
46
|
-
} = (0, _fixura.default)({
|
|
47
|
-
root: FIXTURES_PATH,
|
|
48
|
-
reader: _fixura.READERS.JSON
|
|
49
|
-
});
|
|
50
|
-
describe('fiAsteriN0Fin11', () => {
|
|
51
|
-
it('Should succeed', () => {
|
|
52
|
-
const record = new _marcRecord.MarcRecord(getFixture({
|
|
53
|
-
components: ['in', 'fiAsteriN0Fin11.json']
|
|
54
|
-
}));
|
|
55
|
-
const result = (0, _format.formatRecord)(record.toObject(), _format.BIB_FORMAT_SETTINGS);
|
|
56
|
-
const expected = getFixture({
|
|
57
|
-
components: ['out', 'fiAsteriN0Fin11.json']
|
|
58
|
-
});
|
|
59
|
-
(0, _chai.expect)(result).to.eql(expected);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
describe('fiAsteriS0Fin10', () => {
|
|
63
|
-
it('Should succeed', () => {
|
|
64
|
-
const record = new _marcRecord.MarcRecord(getFixture({
|
|
65
|
-
components: ['in', 'fiAsteriS0Fin10.json']
|
|
66
|
-
}));
|
|
67
|
-
const result = (0, _format.formatRecord)(record.toObject(), _format.BIB_FORMAT_SETTINGS);
|
|
68
|
-
const expected = getFixture({
|
|
69
|
-
components: ['out', 'fiAsteriS0Fin10.json']
|
|
70
|
-
});
|
|
71
|
-
(0, _chai.expect)(result).to.eql(expected);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('fiMelindaWFin01', () => {
|
|
75
|
-
it('Should succeed', () => {
|
|
76
|
-
const record = new _marcRecord.MarcRecord(getFixture({
|
|
77
|
-
components: ['in', 'fiMelindaWFin01.json']
|
|
78
|
-
}));
|
|
79
|
-
const result = (0, _format.formatRecord)(record.toObject(), _format.BIB_FORMAT_SETTINGS);
|
|
80
|
-
const expected = getFixture({
|
|
81
|
-
components: ['out', 'fiMelindaWFin01.json']
|
|
82
|
-
});
|
|
83
|
-
(0, _chai.expect)(result).to.eql(expected);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
describe('f035fibtj', () => {
|
|
87
|
-
it('Should add FI-BTJ SID', () => {
|
|
88
|
-
const record = new _marcRecord.MarcRecord(getFixture({
|
|
89
|
-
components: ['in', 'f035fibtj.json']
|
|
90
|
-
}));
|
|
91
|
-
const result = (0, _format.formatRecord)(record.toObject());
|
|
92
|
-
const expected = getFixture({
|
|
93
|
-
components: ['out', 'f035fibtj.json']
|
|
94
|
-
});
|
|
95
|
-
(0, _chai.expect)(result).to.eql(expected);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe('f035tati', () => {
|
|
99
|
-
it('Should add tati SID', () => {
|
|
100
|
-
const record = new _marcRecord.MarcRecord(getFixture({
|
|
101
|
-
components: ['in', 'f035tati.json']
|
|
102
|
-
}));
|
|
103
|
-
const result = (0, _format.formatRecord)(record.toObject());
|
|
104
|
-
const expected = getFixture({
|
|
105
|
-
components: ['out', 'f035tati.json']
|
|
106
|
-
});
|
|
107
|
-
(0, _chai.expect)(result).to.eql(expected);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe('f035fibtjAndTati', () => {
|
|
111
|
-
it('Should add tati SID and skip FI-BTJ SID', () => {
|
|
112
|
-
const record = new _marcRecord.MarcRecord(getFixture({
|
|
113
|
-
components: ['in', 'f035fibtjAndTati.json']
|
|
114
|
-
}));
|
|
115
|
-
const result = (0, _format.formatRecord)(record.toObject());
|
|
116
|
-
const expected = getFixture({
|
|
117
|
-
components: ['out', 'f035fibtjAndTati.json']
|
|
118
|
-
});
|
|
119
|
-
(0, _chai.expect)(result).to.eql(expected);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
//# sourceMappingURL=format.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format.spec.js","names":["describe","FIXTURES_PATH","__dirname","getFixture","fixtureFactory","root","reader","READERS","JSON","it","record","MarcRecord","components","result","formatRecord","toObject","BIB_FORMAT_SETTINGS","expected","expect","to","eql"],"sources":["../../src/helpers/format.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Shared modules for microservices of Melinda rest api batch import system\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-rest-api-commons\n*\n* melinda-rest-api-commons program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-rest-api-commons is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport {expect} from 'chai';\nimport fixtureFactory, {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {formatRecord, BIB_FORMAT_SETTINGS} from './format';\n\ndescribe('services/format', () => {\n const FIXTURES_PATH = [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'format'\n ];\n const {getFixture} = fixtureFactory({root: FIXTURES_PATH, reader: READERS.JSON});\n\n describe('fiAsteriN0Fin11', () => {\n it('Should succeed', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'fiAsteriN0Fin11.json'\n ]\n }));\n const result = formatRecord(record.toObject(), BIB_FORMAT_SETTINGS);\n const expected = getFixture({\n components: [\n 'out',\n 'fiAsteriN0Fin11.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('fiAsteriS0Fin10', () => {\n it('Should succeed', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'fiAsteriS0Fin10.json'\n ]\n }));\n const result = formatRecord(record.toObject(), BIB_FORMAT_SETTINGS);\n const expected = getFixture({\n components: [\n 'out',\n 'fiAsteriS0Fin10.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('fiMelindaWFin01', () => {\n it('Should succeed', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'fiMelindaWFin01.json'\n ]\n }));\n const result = formatRecord(record.toObject(), BIB_FORMAT_SETTINGS);\n const expected = getFixture({\n components: [\n 'out',\n 'fiMelindaWFin01.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('f035fibtj', () => {\n it('Should add FI-BTJ SID', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f035fibtj.json'\n ]\n }));\n const result = formatRecord(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f035fibtj.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('f035tati', () => {\n it('Should add tati SID', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f035tati.json'\n ]\n }));\n const result = formatRecord(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f035tati.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n\n describe('f035fibtjAndTati', () => {\n it('Should add tati SID and skip FI-BTJ SID', () => {\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f035fibtjAndTati.json'\n ]\n }));\n const result = formatRecord(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f035fibtjAndTati.json'\n ]\n });\n\n expect(result).to.eql(expected);\n });\n });\n});\n"],"mappings":";;AA4BA;;AACA;;AACA;;AACA;;;;;;AA/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOAA,QAAQ,CAAC,iBAAD,EAAoB,MAAM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