@vue-skuilder/common 0.1.0 → 0.1.3
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/bulkImport/cardParser.d.ts +45 -0
- package/dist/bulkImport/cardParser.d.ts.map +1 -0
- package/dist/bulkImport/cardParser.js +113 -0
- package/dist/bulkImport/cardParser.js.map +1 -0
- package/dist/bulkImport/cardParser.mjs +106 -0
- package/dist/bulkImport/types.d.ts +23 -0
- package/dist/bulkImport/types.d.ts.map +1 -0
- package/dist/bulkImport/types.js +6 -0
- package/dist/bulkImport/types.js.map +1 -0
- package/dist/bulkImport/types.mjs +5 -0
- package/dist/course-data.d.ts +17 -0
- package/dist/course-data.d.ts.map +1 -0
- package/dist/course-data.js +87 -0
- package/dist/course-data.js.map +1 -0
- package/dist/course-data.mjs +84 -0
- package/dist/db.d.ts +140 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +46 -0
- package/dist/db.js.map +1 -0
- package/dist/db.mjs +39 -0
- package/dist/elo.d.ts +44 -0
- package/dist/elo.d.ts.map +1 -0
- package/dist/elo.js +162 -0
- package/dist/elo.js.map +1 -0
- package/dist/elo.mjs +152 -0
- package/dist/enums/DataShapeNames.d.ts +27 -0
- package/dist/enums/DataShapeNames.d.ts.map +1 -0
- package/dist/enums/DataShapeNames.js +40 -0
- package/dist/enums/DataShapeNames.js.map +1 -0
- package/dist/enums/DataShapeNames.mjs +37 -0
- package/dist/enums/FieldType.d.ts +18 -0
- package/dist/enums/FieldType.d.ts.map +1 -0
- package/dist/enums/FieldType.js +22 -0
- package/dist/enums/FieldType.js.map +1 -0
- package/dist/enums/FieldType.mjs +19 -0
- package/dist/enums/index.d.ts +3 -0
- package/dist/enums/index.d.ts.map +1 -0
- package/dist/enums/index.js +19 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/index.mjs +3 -0
- package/dist/fieldConverters.d.ts +17 -0
- package/dist/fieldConverters.d.ts.map +1 -0
- package/dist/fieldConverters.js +63 -0
- package/dist/fieldConverters.js.map +1 -0
- package/dist/fieldConverters.mjs +60 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +15 -0
- package/dist/interfaces/AnswerInterfaces.d.ts +7 -0
- package/dist/interfaces/AnswerInterfaces.d.ts.map +1 -0
- package/dist/interfaces/AnswerInterfaces.js +3 -0
- package/dist/interfaces/AnswerInterfaces.js.map +1 -0
- package/dist/interfaces/AnswerInterfaces.mjs +2 -0
- package/dist/interfaces/DataShape.d.ts +7 -0
- package/dist/interfaces/DataShape.d.ts.map +1 -0
- package/dist/interfaces/DataShape.js +4 -0
- package/dist/interfaces/DataShape.js.map +1 -0
- package/dist/interfaces/DataShape.mjs +3 -0
- package/dist/interfaces/FieldDefinition.d.ts +12 -0
- package/dist/interfaces/FieldDefinition.d.ts.map +1 -0
- package/dist/interfaces/FieldDefinition.js +3 -0
- package/dist/interfaces/FieldDefinition.js.map +1 -0
- package/dist/interfaces/FieldDefinition.mjs +2 -0
- package/dist/interfaces/Tagger.d.ts +7 -0
- package/dist/interfaces/Tagger.d.ts.map +1 -0
- package/dist/interfaces/Tagger.js +3 -0
- package/dist/interfaces/Tagger.js.map +1 -0
- package/dist/interfaces/Tagger.mjs +2 -0
- package/dist/interfaces/Validator.d.ts +14 -0
- package/dist/interfaces/Validator.d.ts.map +1 -0
- package/dist/interfaces/Validator.js +16 -0
- package/dist/interfaces/Validator.js.map +1 -0
- package/dist/interfaces/Validator.mjs +13 -0
- package/dist/interfaces/ViewData.d.ts +6 -0
- package/dist/interfaces/ViewData.d.ts.map +1 -0
- package/dist/interfaces/ViewData.js +19 -0
- package/dist/interfaces/ViewData.js.map +1 -0
- package/dist/interfaces/ViewData.mjs +16 -0
- package/dist/interfaces/index.d.ts +7 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +23 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/index.mjs +7 -0
- package/dist/logshim.d.ts +2 -0
- package/dist/logshim.d.ts.map +1 -0
- package/dist/logshim.js +9 -0
- package/dist/logshim.js.map +1 -0
- package/dist/logshim.mjs +5 -0
- package/dist/namespacer.d.ts +22 -0
- package/dist/namespacer.d.ts.map +1 -0
- package/dist/namespacer.js +54 -0
- package/dist/namespacer.js.map +1 -0
- package/dist/namespacer.mjs +50 -0
- package/dist/validators.d.ts +7 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +24 -0
- package/dist/validators.js.map +1 -0
- package/dist/validators.mjs +21 -0
- package/dist/wire-format.d.ts +141 -0
- package/dist/wire-format.d.ts.map +1 -0
- package/dist/wire-format.js +21 -0
- package/dist/wire-format.js.map +1 -0
- package/dist/wire-format.mjs +18 -0
- package/package.json +30 -31
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ParsedCard } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the bulk card parser
|
|
4
|
+
*/
|
|
5
|
+
export interface CardParserConfig {
|
|
6
|
+
/** Custom tag identifier (defaults to 'tags:') */
|
|
7
|
+
tagIdentifier?: string;
|
|
8
|
+
/** Custom ELO identifier (defaults to 'elo:') */
|
|
9
|
+
eloIdentifier?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Card delimiter used to separate cards in bulk input
|
|
13
|
+
*/
|
|
14
|
+
export declare const CARD_DELIMITER = "\n---\n---\n";
|
|
15
|
+
/**
|
|
16
|
+
* Parses a single card string into a structured object
|
|
17
|
+
*
|
|
18
|
+
* @param cardString - Raw string containing card content
|
|
19
|
+
* @param config - Optional parser configuration
|
|
20
|
+
* @returns ParsedCard object or null if parsing fails
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseCard(cardString: string, config?: CardParserConfig): ParsedCard | null;
|
|
23
|
+
/**
|
|
24
|
+
* Splits a bulk text input into individual card strings
|
|
25
|
+
*
|
|
26
|
+
* @param bulkText - Raw string containing multiple cards
|
|
27
|
+
* @returns Array of card strings
|
|
28
|
+
*/
|
|
29
|
+
export declare function splitCardsText(bulkText: string): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Parses a bulk text input into an array of structured ParsedCard objects.
|
|
32
|
+
*
|
|
33
|
+
* @param bulkText - Raw string containing multiple cards.
|
|
34
|
+
* @param config - Optional parser configuration.
|
|
35
|
+
* @returns Array of ParsedCard objects. Filters out cards that fail to parse.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseBulkTextToCards(bulkText: string, config?: CardParserConfig): ParsedCard[];
|
|
38
|
+
/**
|
|
39
|
+
* Validates if a bulk text input has valid format
|
|
40
|
+
*
|
|
41
|
+
* @param bulkText - Raw string containing multiple cards
|
|
42
|
+
* @returns true if valid, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
export declare function isValidBulkFormat(bulkText: string): boolean;
|
|
45
|
+
//# sourceMappingURL=cardParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardParser.d.ts","sourceRoot":"","sources":["../../src/bulkImport/cardParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAUD;;GAEG;AACH,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAE7C;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,gBAAwC,GAC/C,UAAU,GAAG,IAAI,CAsDnB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAKzD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,gBAAwC,GAC/C,UAAU,EAAE,CAWd;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG3D"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CARD_DELIMITER = void 0;
|
|
4
|
+
exports.parseCard = parseCard;
|
|
5
|
+
exports.splitCardsText = splitCardsText;
|
|
6
|
+
exports.parseBulkTextToCards = parseBulkTextToCards;
|
|
7
|
+
exports.isValidBulkFormat = isValidBulkFormat;
|
|
8
|
+
/**
|
|
9
|
+
* Default configuration for the card parser
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_PARSER_CONFIG = {
|
|
12
|
+
tagIdentifier: 'tags:',
|
|
13
|
+
eloIdentifier: 'elo:',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Card delimiter used to separate cards in bulk input
|
|
17
|
+
*/
|
|
18
|
+
exports.CARD_DELIMITER = '\n---\n---\n';
|
|
19
|
+
/**
|
|
20
|
+
* Parses a single card string into a structured object
|
|
21
|
+
*
|
|
22
|
+
* @param cardString - Raw string containing card content
|
|
23
|
+
* @param config - Optional parser configuration
|
|
24
|
+
* @returns ParsedCard object or null if parsing fails
|
|
25
|
+
*/
|
|
26
|
+
function parseCard(cardString, config = DEFAULT_PARSER_CONFIG) {
|
|
27
|
+
const trimmedCardString = cardString.trim();
|
|
28
|
+
if (!trimmedCardString) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const lines = trimmedCardString.split('\n');
|
|
32
|
+
let tags = [];
|
|
33
|
+
let elo = undefined;
|
|
34
|
+
const markdownLines = [...lines];
|
|
35
|
+
// Process the lines from bottom to top to handle metadata
|
|
36
|
+
let metadataLines = 0;
|
|
37
|
+
// Get the configured identifiers
|
|
38
|
+
const tagId = config.tagIdentifier || DEFAULT_PARSER_CONFIG.tagIdentifier;
|
|
39
|
+
const eloId = config.eloIdentifier || DEFAULT_PARSER_CONFIG.eloIdentifier;
|
|
40
|
+
// Check the last few lines for metadata (tags and elo)
|
|
41
|
+
for (let i = lines.length - 1; i >= 0 && i >= lines.length - 2; i--) {
|
|
42
|
+
const line = lines[i].trim();
|
|
43
|
+
// Check for tags
|
|
44
|
+
if (line.toLowerCase().startsWith(tagId.toLowerCase())) {
|
|
45
|
+
tags = line
|
|
46
|
+
.substring(tagId.length)
|
|
47
|
+
.split(',')
|
|
48
|
+
.map((tag) => tag.trim())
|
|
49
|
+
.filter((tag) => tag);
|
|
50
|
+
metadataLines++;
|
|
51
|
+
}
|
|
52
|
+
// Check for ELO
|
|
53
|
+
else if (line.toLowerCase().startsWith(eloId.toLowerCase())) {
|
|
54
|
+
const eloValue = line.substring(eloId.length).trim();
|
|
55
|
+
const parsedElo = parseInt(eloValue, 10);
|
|
56
|
+
if (!isNaN(parsedElo)) {
|
|
57
|
+
elo = parsedElo;
|
|
58
|
+
}
|
|
59
|
+
metadataLines++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Remove metadata lines from the end of the content
|
|
63
|
+
if (metadataLines > 0) {
|
|
64
|
+
markdownLines.splice(markdownLines.length - metadataLines);
|
|
65
|
+
}
|
|
66
|
+
const markdown = markdownLines.join('\n').trim();
|
|
67
|
+
if (!markdown) {
|
|
68
|
+
// Card must have some markdown content
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return { markdown, tags, elo };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Splits a bulk text input into individual card strings
|
|
75
|
+
*
|
|
76
|
+
* @param bulkText - Raw string containing multiple cards
|
|
77
|
+
* @returns Array of card strings
|
|
78
|
+
*/
|
|
79
|
+
function splitCardsText(bulkText) {
|
|
80
|
+
return bulkText
|
|
81
|
+
.split(exports.CARD_DELIMITER)
|
|
82
|
+
.map((card) => card.trim())
|
|
83
|
+
.filter((card) => card); // Filter out empty strings
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parses a bulk text input into an array of structured ParsedCard objects.
|
|
87
|
+
*
|
|
88
|
+
* @param bulkText - Raw string containing multiple cards.
|
|
89
|
+
* @param config - Optional parser configuration.
|
|
90
|
+
* @returns Array of ParsedCard objects. Filters out cards that fail to parse.
|
|
91
|
+
*/
|
|
92
|
+
function parseBulkTextToCards(bulkText, config = DEFAULT_PARSER_CONFIG) {
|
|
93
|
+
const cardStrings = splitCardsText(bulkText);
|
|
94
|
+
const parsedCards = [];
|
|
95
|
+
for (const cardString of cardStrings) {
|
|
96
|
+
const parsedCard = parseCard(cardString, config);
|
|
97
|
+
if (parsedCard) {
|
|
98
|
+
parsedCards.push(parsedCard);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return parsedCards;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Validates if a bulk text input has valid format
|
|
105
|
+
*
|
|
106
|
+
* @param bulkText - Raw string containing multiple cards
|
|
107
|
+
* @returns true if valid, false otherwise
|
|
108
|
+
*/
|
|
109
|
+
function isValidBulkFormat(bulkText) {
|
|
110
|
+
const cardStrings = splitCardsText(bulkText);
|
|
111
|
+
return cardStrings.length > 0 && cardStrings.some((card) => !!card.trim());
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=cardParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardParser.js","sourceRoot":"","sources":["../../src/bulkImport/cardParser.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,qBAAqB,GAAqB;IAC9C,aAAa,EAAE,OAAO;IACtB,aAAa,EAAE,MAAM;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,UAAkB,EAClB,SAA2B,qBAAqB;IAEhD,MAAM,iBAAiB,GAAG,UAAU,CAAC,IAAI,EAAE,CA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C,UAAU,EAAE,MAAM,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE,CAAC;YACf,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration for the card parser
|
|
3
|
+
*/
|
|
4
|
+
const DEFAULT_PARSER_CONFIG = {
|
|
5
|
+
tagIdentifier: 'tags:',
|
|
6
|
+
eloIdentifier: 'elo:',
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Card delimiter used to separate cards in bulk input
|
|
10
|
+
*/
|
|
11
|
+
export const CARD_DELIMITER = '\n---\n---\n';
|
|
12
|
+
/**
|
|
13
|
+
* Parses a single card string into a structured object
|
|
14
|
+
*
|
|
15
|
+
* @param cardString - Raw string containing card content
|
|
16
|
+
* @param config - Optional parser configuration
|
|
17
|
+
* @returns ParsedCard object or null if parsing fails
|
|
18
|
+
*/
|
|
19
|
+
export function parseCard(cardString, config = DEFAULT_PARSER_CONFIG) {
|
|
20
|
+
const trimmedCardString = cardString.trim();
|
|
21
|
+
if (!trimmedCardString) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const lines = trimmedCardString.split('\n');
|
|
25
|
+
let tags = [];
|
|
26
|
+
let elo = undefined;
|
|
27
|
+
const markdownLines = [...lines];
|
|
28
|
+
// Process the lines from bottom to top to handle metadata
|
|
29
|
+
let metadataLines = 0;
|
|
30
|
+
// Get the configured identifiers
|
|
31
|
+
const tagId = config.tagIdentifier || DEFAULT_PARSER_CONFIG.tagIdentifier;
|
|
32
|
+
const eloId = config.eloIdentifier || DEFAULT_PARSER_CONFIG.eloIdentifier;
|
|
33
|
+
// Check the last few lines for metadata (tags and elo)
|
|
34
|
+
for (let i = lines.length - 1; i >= 0 && i >= lines.length - 2; i--) {
|
|
35
|
+
const line = lines[i].trim();
|
|
36
|
+
// Check for tags
|
|
37
|
+
if (line.toLowerCase().startsWith(tagId.toLowerCase())) {
|
|
38
|
+
tags = line
|
|
39
|
+
.substring(tagId.length)
|
|
40
|
+
.split(',')
|
|
41
|
+
.map((tag) => tag.trim())
|
|
42
|
+
.filter((tag) => tag);
|
|
43
|
+
metadataLines++;
|
|
44
|
+
}
|
|
45
|
+
// Check for ELO
|
|
46
|
+
else if (line.toLowerCase().startsWith(eloId.toLowerCase())) {
|
|
47
|
+
const eloValue = line.substring(eloId.length).trim();
|
|
48
|
+
const parsedElo = parseInt(eloValue, 10);
|
|
49
|
+
if (!isNaN(parsedElo)) {
|
|
50
|
+
elo = parsedElo;
|
|
51
|
+
}
|
|
52
|
+
metadataLines++;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Remove metadata lines from the end of the content
|
|
56
|
+
if (metadataLines > 0) {
|
|
57
|
+
markdownLines.splice(markdownLines.length - metadataLines);
|
|
58
|
+
}
|
|
59
|
+
const markdown = markdownLines.join('\n').trim();
|
|
60
|
+
if (!markdown) {
|
|
61
|
+
// Card must have some markdown content
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return { markdown, tags, elo };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Splits a bulk text input into individual card strings
|
|
68
|
+
*
|
|
69
|
+
* @param bulkText - Raw string containing multiple cards
|
|
70
|
+
* @returns Array of card strings
|
|
71
|
+
*/
|
|
72
|
+
export function splitCardsText(bulkText) {
|
|
73
|
+
return bulkText
|
|
74
|
+
.split(CARD_DELIMITER)
|
|
75
|
+
.map((card) => card.trim())
|
|
76
|
+
.filter((card) => card); // Filter out empty strings
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parses a bulk text input into an array of structured ParsedCard objects.
|
|
80
|
+
*
|
|
81
|
+
* @param bulkText - Raw string containing multiple cards.
|
|
82
|
+
* @param config - Optional parser configuration.
|
|
83
|
+
* @returns Array of ParsedCard objects. Filters out cards that fail to parse.
|
|
84
|
+
*/
|
|
85
|
+
export function parseBulkTextToCards(bulkText, config = DEFAULT_PARSER_CONFIG) {
|
|
86
|
+
const cardStrings = splitCardsText(bulkText);
|
|
87
|
+
const parsedCards = [];
|
|
88
|
+
for (const cardString of cardStrings) {
|
|
89
|
+
const parsedCard = parseCard(cardString, config);
|
|
90
|
+
if (parsedCard) {
|
|
91
|
+
parsedCards.push(parsedCard);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return parsedCards;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Validates if a bulk text input has valid format
|
|
98
|
+
*
|
|
99
|
+
* @param bulkText - Raw string containing multiple cards
|
|
100
|
+
* @returns true if valid, false otherwise
|
|
101
|
+
*/
|
|
102
|
+
export function isValidBulkFormat(bulkText) {
|
|
103
|
+
const cardStrings = splitCardsText(bulkText);
|
|
104
|
+
return cardStrings.length > 0 && cardStrings.some((card) => !!card.trim());
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=cardParser.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing a parsed card from bulk import
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedCard {
|
|
5
|
+
/** The markdown content of the card */
|
|
6
|
+
markdown: string;
|
|
7
|
+
/** Tags associated with the card */
|
|
8
|
+
tags: string[];
|
|
9
|
+
/** ELO rating for the card (optional) */
|
|
10
|
+
elo?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface for card data ready to be stored in the database
|
|
14
|
+
*/
|
|
15
|
+
export interface BulkImportCardData {
|
|
16
|
+
/** Card markdown content */
|
|
17
|
+
Input: string;
|
|
18
|
+
/** Card media uploads */
|
|
19
|
+
Uploads: unknown[];
|
|
20
|
+
/** Any additional fields can be added as needed */
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bulkImport/types.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,mDAAmD;IACnD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// We no longer need to import DataShape since we've moved the interfaces that used it
|
|
3
|
+
// import { DataShape } from '@vue-skuilder/common';
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
// ImportResult and BulkCardProcessorConfig have been moved to @vue-skuilder/db
|
|
6
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bulkImport/types.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,oDAAoD;;AA0BpD,+EAA+E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// We no longer need to import DataShape since we've moved the interfaces that used it
|
|
2
|
+
// import { DataShape } from '@vue-skuilder/common';
|
|
3
|
+
export {};
|
|
4
|
+
// ImportResult and BulkCardProcessorConfig have been moved to @vue-skuilder/db
|
|
5
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DisplayableData } from './db.js';
|
|
2
|
+
import { DataShape } from './interfaces/DataShape.js';
|
|
3
|
+
export declare function prepareNote55(courseID: string, codeCourse: string, shape: DataShape, data: any, author: string, _tags: string[], uploads?: {
|
|
4
|
+
[x: string]: PouchDB.Core.FullAttachment;
|
|
5
|
+
}): DisplayableData;
|
|
6
|
+
/**
|
|
7
|
+
* Question components
|
|
8
|
+
*/
|
|
9
|
+
export interface Evaluation {
|
|
10
|
+
isCorrect: boolean;
|
|
11
|
+
performance: Performance;
|
|
12
|
+
}
|
|
13
|
+
type Performance = number | {
|
|
14
|
+
[dimension: string]: Performance;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=course-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"course-data.d.ts","sourceRoot":"","sources":["../src/course-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAW,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKtD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAGhB,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAA;CAAE,GACrD,eAAe,CAsFjB;AAED;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,KAAK,WAAW,GACZ,MAAM,GACN;IACE,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;CAClC,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareNote55 = prepareNote55;
|
|
4
|
+
const db_js_1 = require("./db.js");
|
|
5
|
+
const namespacer_js_1 = require("./namespacer.js");
|
|
6
|
+
const FieldType_js_1 = require("./enums/FieldType.js");
|
|
7
|
+
function prepareNote55(courseID, codeCourse, shape,
|
|
8
|
+
// [ ] add typing
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
data, author, _tags, uploads) {
|
|
11
|
+
const dataShapeId = namespacer_js_1.NameSpacer.getDataShapeString({
|
|
12
|
+
course: codeCourse,
|
|
13
|
+
dataShape: shape.name,
|
|
14
|
+
});
|
|
15
|
+
const attachmentFields = shape.fields
|
|
16
|
+
.map((field) => {
|
|
17
|
+
// make a copy, in order NOT to append to the datashape
|
|
18
|
+
const copy = {
|
|
19
|
+
name: field.name,
|
|
20
|
+
type: field.type,
|
|
21
|
+
};
|
|
22
|
+
return copy;
|
|
23
|
+
})
|
|
24
|
+
.filter((field) => {
|
|
25
|
+
return field.type === FieldType_js_1.FieldType.IMAGE || field.type === FieldType_js_1.FieldType.AUDIO;
|
|
26
|
+
})
|
|
27
|
+
.concat([
|
|
28
|
+
{
|
|
29
|
+
name: 'autoplayAudio',
|
|
30
|
+
type: FieldType_js_1.FieldType.AUDIO,
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
for (let i = 1; i < 11; i++) {
|
|
34
|
+
if (data[`audio-${i}`]) {
|
|
35
|
+
attachmentFields.push({
|
|
36
|
+
name: `audio-${i}`,
|
|
37
|
+
type: FieldType_js_1.FieldType.AUDIO,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (data[`image-${i}`]) {
|
|
41
|
+
attachmentFields.push({
|
|
42
|
+
name: `image-${i}`,
|
|
43
|
+
type: FieldType_js_1.FieldType.IMAGE,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (data[`audio-11`]) {
|
|
48
|
+
throw new Error('Too many audio attachments');
|
|
49
|
+
}
|
|
50
|
+
if (data[`image-11`]) {
|
|
51
|
+
throw new Error('Too many image attachments');
|
|
52
|
+
}
|
|
53
|
+
const attachments = {};
|
|
54
|
+
const payload = {
|
|
55
|
+
course: courseID,
|
|
56
|
+
data: [],
|
|
57
|
+
docType: db_js_1.DocType.DISPLAYABLE_DATA,
|
|
58
|
+
id_datashape: dataShapeId,
|
|
59
|
+
};
|
|
60
|
+
if (author) {
|
|
61
|
+
payload.author = author;
|
|
62
|
+
}
|
|
63
|
+
attachmentFields.forEach((attField) => {
|
|
64
|
+
attachments[attField.name] = data[attField.name];
|
|
65
|
+
});
|
|
66
|
+
//
|
|
67
|
+
if (uploads) {
|
|
68
|
+
Object.keys(uploads).forEach((k) => {
|
|
69
|
+
attachments[k] = uploads[k];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (attachmentFields.length !== 0 || (uploads && Object.keys(uploads).length)) {
|
|
73
|
+
payload._attachments = attachments;
|
|
74
|
+
}
|
|
75
|
+
shape.fields
|
|
76
|
+
.filter((field) => {
|
|
77
|
+
return field.type !== FieldType_js_1.FieldType.IMAGE && field.type !== FieldType_js_1.FieldType.AUDIO;
|
|
78
|
+
})
|
|
79
|
+
.forEach((field) => {
|
|
80
|
+
payload.data.push({
|
|
81
|
+
name: field.name,
|
|
82
|
+
data: data[field.name],
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return payload;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=course-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"course-data.js","sourceRoot":"","sources":["../src/course-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,OAAO,EAA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,WAAW,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,MAAM;SACT,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,KAAK,CAAC;IAC1E,CAAC,CAAC;SACD,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DocType } from './db.mjs';
|
|
2
|
+
import { NameSpacer } from './namespacer.mjs';
|
|
3
|
+
import { FieldType } from './enums/FieldType.mjs';
|
|
4
|
+
export function prepareNote55(courseID, codeCourse, shape,
|
|
5
|
+
// [ ] add typing
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
data, author, _tags, uploads) {
|
|
8
|
+
const dataShapeId = NameSpacer.getDataShapeString({
|
|
9
|
+
course: codeCourse,
|
|
10
|
+
dataShape: shape.name,
|
|
11
|
+
});
|
|
12
|
+
const attachmentFields = shape.fields
|
|
13
|
+
.map((field) => {
|
|
14
|
+
// make a copy, in order NOT to append to the datashape
|
|
15
|
+
const copy = {
|
|
16
|
+
name: field.name,
|
|
17
|
+
type: field.type,
|
|
18
|
+
};
|
|
19
|
+
return copy;
|
|
20
|
+
})
|
|
21
|
+
.filter((field) => {
|
|
22
|
+
return field.type === FieldType.IMAGE || field.type === FieldType.AUDIO;
|
|
23
|
+
})
|
|
24
|
+
.concat([
|
|
25
|
+
{
|
|
26
|
+
name: 'autoplayAudio',
|
|
27
|
+
type: FieldType.AUDIO,
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
for (let i = 1; i < 11; i++) {
|
|
31
|
+
if (data[`audio-${i}`]) {
|
|
32
|
+
attachmentFields.push({
|
|
33
|
+
name: `audio-${i}`,
|
|
34
|
+
type: FieldType.AUDIO,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (data[`image-${i}`]) {
|
|
38
|
+
attachmentFields.push({
|
|
39
|
+
name: `image-${i}`,
|
|
40
|
+
type: FieldType.IMAGE,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (data[`audio-11`]) {
|
|
45
|
+
throw new Error('Too many audio attachments');
|
|
46
|
+
}
|
|
47
|
+
if (data[`image-11`]) {
|
|
48
|
+
throw new Error('Too many image attachments');
|
|
49
|
+
}
|
|
50
|
+
const attachments = {};
|
|
51
|
+
const payload = {
|
|
52
|
+
course: courseID,
|
|
53
|
+
data: [],
|
|
54
|
+
docType: DocType.DISPLAYABLE_DATA,
|
|
55
|
+
id_datashape: dataShapeId,
|
|
56
|
+
};
|
|
57
|
+
if (author) {
|
|
58
|
+
payload.author = author;
|
|
59
|
+
}
|
|
60
|
+
attachmentFields.forEach((attField) => {
|
|
61
|
+
attachments[attField.name] = data[attField.name];
|
|
62
|
+
});
|
|
63
|
+
//
|
|
64
|
+
if (uploads) {
|
|
65
|
+
Object.keys(uploads).forEach((k) => {
|
|
66
|
+
attachments[k] = uploads[k];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (attachmentFields.length !== 0 || (uploads && Object.keys(uploads).length)) {
|
|
70
|
+
payload._attachments = attachments;
|
|
71
|
+
}
|
|
72
|
+
shape.fields
|
|
73
|
+
.filter((field) => {
|
|
74
|
+
return field.type !== FieldType.IMAGE && field.type !== FieldType.AUDIO;
|
|
75
|
+
})
|
|
76
|
+
.forEach((field) => {
|
|
77
|
+
payload.data.push({
|
|
78
|
+
name: field.name,
|
|
79
|
+
data: data[field.name],
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
return payload;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=course-data.js.map
|
package/dist/db.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Evaluation } from './course-data.js';
|
|
2
|
+
import { Answer } from './interfaces/AnswerInterfaces.js';
|
|
3
|
+
import { CourseElo } from './elo.js';
|
|
4
|
+
import { Moment } from 'moment';
|
|
5
|
+
export declare enum DocType {
|
|
6
|
+
DISPLAYABLE_DATA = "DISPLAYABLE_DATA",
|
|
7
|
+
CARD = "CARD",
|
|
8
|
+
DATASHAPE = "DATASHAPE",
|
|
9
|
+
QUESTIONTYPE = "QUESTION",
|
|
10
|
+
VIEW = "VIEW",
|
|
11
|
+
PEDAGOGY = "PEDAGOGY",
|
|
12
|
+
CARDRECORD = "CARDRECORD",
|
|
13
|
+
SCHEDULED_CARD = "SCHEDULED_CARD",
|
|
14
|
+
TAG = "TAG"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Interface for all data on course content and pedagogy stored
|
|
18
|
+
* in the c/pouch database.
|
|
19
|
+
*/
|
|
20
|
+
export interface SkuilderCourseData {
|
|
21
|
+
course: string;
|
|
22
|
+
docType: DocType;
|
|
23
|
+
}
|
|
24
|
+
export interface Tag extends SkuilderCourseData {
|
|
25
|
+
docType: DocType.TAG;
|
|
26
|
+
name: string;
|
|
27
|
+
snippet: string;
|
|
28
|
+
wiki: string;
|
|
29
|
+
taggedCards: PouchDB.Core.DocumentId[];
|
|
30
|
+
}
|
|
31
|
+
export interface TagStub {
|
|
32
|
+
name: string;
|
|
33
|
+
snippet: string;
|
|
34
|
+
count: number;
|
|
35
|
+
}
|
|
36
|
+
export interface CardData extends SkuilderCourseData {
|
|
37
|
+
docType: DocType.CARD;
|
|
38
|
+
id_displayable_data: PouchDB.Core.DocumentId[];
|
|
39
|
+
id_view: PouchDB.Core.DocumentId;
|
|
40
|
+
elo: CourseElo;
|
|
41
|
+
}
|
|
42
|
+
/** A list of populated courses in the DB */
|
|
43
|
+
export interface CourseListData extends PouchDB.Core.Response {
|
|
44
|
+
courses: string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The data used to hydrate viewable components (questions, info, etc)
|
|
48
|
+
*/
|
|
49
|
+
export interface DisplayableData extends SkuilderCourseData {
|
|
50
|
+
docType: DocType.DISPLAYABLE_DATA;
|
|
51
|
+
author?: string;
|
|
52
|
+
id_datashape: PouchDB.Core.DocumentId;
|
|
53
|
+
data: Field[];
|
|
54
|
+
_attachments?: {
|
|
55
|
+
[index: string]: PouchDB.Core.FullAttachment;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface Field {
|
|
59
|
+
data: unknown;
|
|
60
|
+
name: string;
|
|
61
|
+
}
|
|
62
|
+
export interface DataShapeData extends SkuilderCourseData {
|
|
63
|
+
docType: DocType.DATASHAPE;
|
|
64
|
+
_id: PouchDB.Core.DocumentId;
|
|
65
|
+
questionTypes: PouchDB.Core.DocumentId[];
|
|
66
|
+
}
|
|
67
|
+
export interface QuestionData extends SkuilderCourseData {
|
|
68
|
+
docType: DocType.QUESTIONTYPE;
|
|
69
|
+
_id: PouchDB.Core.DocumentId;
|
|
70
|
+
viewList: string[];
|
|
71
|
+
dataShapeList: PouchDB.Core.DocumentId[];
|
|
72
|
+
}
|
|
73
|
+
export declare function getCardHistoryID(courseID: string, cardID: string): PouchDB.Core.DocumentId;
|
|
74
|
+
export declare function parseCardHistoryID(id: string): {
|
|
75
|
+
courseID: string;
|
|
76
|
+
cardID: string;
|
|
77
|
+
};
|
|
78
|
+
export interface CardHistory<T extends CardRecord> {
|
|
79
|
+
_id: PouchDB.Core.DocumentId;
|
|
80
|
+
/**
|
|
81
|
+
* The CouchDB id of the card
|
|
82
|
+
*/
|
|
83
|
+
cardID: PouchDB.Core.DocumentId;
|
|
84
|
+
/**
|
|
85
|
+
* The ID of the course
|
|
86
|
+
*/
|
|
87
|
+
courseID: string;
|
|
88
|
+
/**
|
|
89
|
+
* The to-date largest interval between successful
|
|
90
|
+
* card reviews. `0` indicates no successful reviews.
|
|
91
|
+
*/
|
|
92
|
+
bestInterval: number;
|
|
93
|
+
/**
|
|
94
|
+
* The number of times that a card has been
|
|
95
|
+
* failed in review
|
|
96
|
+
*/
|
|
97
|
+
lapses: number;
|
|
98
|
+
/**
|
|
99
|
+
* The number of consecutive successful impressions
|
|
100
|
+
* on this card
|
|
101
|
+
*/
|
|
102
|
+
streak: number;
|
|
103
|
+
records: T[];
|
|
104
|
+
}
|
|
105
|
+
export interface CardRecord {
|
|
106
|
+
/**
|
|
107
|
+
* The CouchDB id of the card
|
|
108
|
+
*/
|
|
109
|
+
cardID: string;
|
|
110
|
+
/**
|
|
111
|
+
* The ID of the course
|
|
112
|
+
*/
|
|
113
|
+
courseID: string;
|
|
114
|
+
/**
|
|
115
|
+
* Number of milliseconds that the user spent before dismissing
|
|
116
|
+
* the card (ie, "I've read this" or "here is my answer")
|
|
117
|
+
*
|
|
118
|
+
* //TODO: this (sometimes?) wants to be replaced with a rich
|
|
119
|
+
* recording of user activity in working the question
|
|
120
|
+
*/
|
|
121
|
+
timeSpent: number;
|
|
122
|
+
/**
|
|
123
|
+
* The date-time that the card was rendered. timeStamp + timeSpent will give the
|
|
124
|
+
* time of user submission.
|
|
125
|
+
*/
|
|
126
|
+
timeStamp: Moment;
|
|
127
|
+
}
|
|
128
|
+
export interface QuestionRecord extends CardRecord, Evaluation {
|
|
129
|
+
userAnswer: Answer;
|
|
130
|
+
/**
|
|
131
|
+
* The number of incorrect user submissions prededing this submisstion.
|
|
132
|
+
*
|
|
133
|
+
* eg, if a user is asked 7*6=__, submitting 46, 48, 42 will result in three
|
|
134
|
+
* records being created having 0, 1, and 2 as their recorded 'priorAttempts' values
|
|
135
|
+
*/
|
|
136
|
+
priorAttemps: number;
|
|
137
|
+
}
|
|
138
|
+
export declare function areQuestionRecords(h: CardHistory<CardRecord>): h is CardHistory<QuestionRecord>;
|
|
139
|
+
export declare function isQuestionRecord(c: CardRecord): c is QuestionRecord;
|
|
140
|
+
//# sourceMappingURL=db.d.ts.map
|
package/dist/db.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,oBAAY,OAAO;IACjB,gBAAgB,qBAAqB;IACrC,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,YAAY,aAAa;IACzB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,GAAG,QAAQ;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,GAAI,SAAQ,kBAAkB;IAC7C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;CACxC;AACD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,QAAS,SAAQ,kBAAkB;IAClD,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC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