@lycoristech/azurdata 0.0.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.
Files changed (274) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +123 -0
  3. package/data/.gitkeep +0 -0
  4. package/data/id-map.json +3530 -0
  5. package/data/ship-list.json +4478 -0
  6. package/data/ships.json +143282 -0
  7. package/data/version.json +5 -0
  8. package/dist/cjs/client/AzurData.js +69 -0
  9. package/dist/cjs/client/fetcher.js +121 -0
  10. package/dist/cjs/client/index.js +7 -0
  11. package/dist/cjs/client/ships.js +80 -0
  12. package/dist/cjs/config.js +14 -0
  13. package/dist/cjs/index.js +6 -0
  14. package/dist/cjs/ingest/files.js +134 -0
  15. package/dist/cjs/ingest/index.js +18 -0
  16. package/dist/cjs/ingest/upstream.js +12 -0
  17. package/dist/cjs/normalize/construction.js +186 -0
  18. package/dist/cjs/normalize/identity.js +131 -0
  19. package/dist/cjs/normalize/index.js +25 -0
  20. package/dist/cjs/normalize/misc.js +31 -0
  21. package/dist/cjs/normalize/retrofit.js +21 -0
  22. package/dist/cjs/normalize/ship.js +406 -0
  23. package/dist/cjs/normalize/skills.js +194 -0
  24. package/dist/cjs/normalize/skins.js +141 -0
  25. package/dist/cjs/normalize/slots.js +35 -0
  26. package/dist/cjs/normalize/stats.js +182 -0
  27. package/dist/cjs/output/index.js +20 -0
  28. package/dist/cjs/output/writeIdMap.js +52 -0
  29. package/dist/cjs/output/writeShipList.js +31 -0
  30. package/dist/cjs/output/writeShips.js +33 -0
  31. package/dist/cjs/output/writeVersion.js +23 -0
  32. package/dist/cjs/package.json +1 -0
  33. package/dist/cjs/schema/output/index.js +17 -0
  34. package/dist/cjs/schema/output/ship.js +169 -0
  35. package/dist/cjs/schema/raw/attributeInfoByType.js +11 -0
  36. package/dist/cjs/schema/raw/equipDataByType.js +12 -0
  37. package/dist/cjs/schema/raw/fleetTechGroup.js +10 -0
  38. package/dist/cjs/schema/raw/fleetTechShipClass.js +15 -0
  39. package/dist/cjs/schema/raw/fleetTechShipTemplate.js +20 -0
  40. package/dist/cjs/schema/raw/index.js +38 -0
  41. package/dist/cjs/schema/raw/shipDataBlueprint.js +11 -0
  42. package/dist/cjs/schema/raw/shipDataBreakout.js +17 -0
  43. package/dist/cjs/schema/raw/shipDataByStar.js +10 -0
  44. package/dist/cjs/schema/raw/shipDataByType.js +13 -0
  45. package/dist/cjs/schema/raw/shipDataCreateExchange.js +10 -0
  46. package/dist/cjs/schema/raw/shipDataGroup.js +22 -0
  47. package/dist/cjs/schema/raw/shipDataStatistics.js +24 -0
  48. package/dist/cjs/schema/raw/shipDataStrengthen.js +12 -0
  49. package/dist/cjs/schema/raw/shipDataTemplate.js +26 -0
  50. package/dist/cjs/schema/raw/shipDataTrans.js +13 -0
  51. package/dist/cjs/schema/raw/shipSkinTemplate.js +23 -0
  52. package/dist/cjs/schema/raw/shipSkinWords.js +11 -0
  53. package/dist/cjs/schema/raw/shopTemplate.js +14 -0
  54. package/dist/cjs/schema/raw/skillDataDisplay.js +11 -0
  55. package/dist/cjs/schema/raw/skillDataTemplate.js +17 -0
  56. package/dist/cjs/schema/raw/transformDataTemplate.js +18 -0
  57. package/dist/cjs/schema/raw/voiceActorCn.js +11 -0
  58. package/dist/cjs/translate/enums.js +131 -0
  59. package/dist/cjs/translate/index.js +19 -0
  60. package/dist/cjs/translate/lookups.js +63 -0
  61. package/dist/cjs/translate/strings.js +98 -0
  62. package/dist/client/AzurData.d.ts +25 -0
  63. package/dist/client/AzurData.d.ts.map +1 -0
  64. package/dist/client/AzurData.js +63 -0
  65. package/dist/client/AzurData.js.map +1 -0
  66. package/dist/client/fetcher.d.ts +25 -0
  67. package/dist/client/fetcher.d.ts.map +1 -0
  68. package/dist/client/fetcher.js +116 -0
  69. package/dist/client/fetcher.js.map +1 -0
  70. package/dist/client/index.d.ts +4 -0
  71. package/dist/client/index.d.ts.map +1 -0
  72. package/dist/client/index.js +3 -0
  73. package/dist/client/index.js.map +1 -0
  74. package/dist/client/ships.d.ts +20 -0
  75. package/dist/client/ships.d.ts.map +1 -0
  76. package/dist/client/ships.js +74 -0
  77. package/dist/client/ships.js.map +1 -0
  78. package/dist/config.d.ts +5 -0
  79. package/dist/config.d.ts.map +1 -0
  80. package/dist/config.js +12 -0
  81. package/dist/config.js.map +1 -0
  82. package/dist/index.d.ts +3 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +2 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/ingest/files.d.ts +25 -0
  87. package/dist/ingest/files.d.ts.map +1 -0
  88. package/dist/ingest/files.js +108 -0
  89. package/dist/ingest/files.js.map +1 -0
  90. package/dist/ingest/index.d.ts +3 -0
  91. package/dist/ingest/index.d.ts.map +1 -0
  92. package/dist/ingest/index.js +3 -0
  93. package/dist/ingest/index.js.map +1 -0
  94. package/dist/ingest/upstream.d.ts +4 -0
  95. package/dist/ingest/upstream.d.ts.map +1 -0
  96. package/dist/ingest/upstream.js +6 -0
  97. package/dist/ingest/upstream.js.map +1 -0
  98. package/dist/normalize/construction.d.ts +30 -0
  99. package/dist/normalize/construction.d.ts.map +1 -0
  100. package/dist/normalize/construction.js +184 -0
  101. package/dist/normalize/construction.js.map +1 -0
  102. package/dist/normalize/identity.d.ts +47 -0
  103. package/dist/normalize/identity.d.ts.map +1 -0
  104. package/dist/normalize/identity.js +129 -0
  105. package/dist/normalize/identity.js.map +1 -0
  106. package/dist/normalize/index.d.ts +10 -0
  107. package/dist/normalize/index.d.ts.map +1 -0
  108. package/dist/normalize/index.js +10 -0
  109. package/dist/normalize/index.js.map +1 -0
  110. package/dist/normalize/misc.d.ts +15 -0
  111. package/dist/normalize/misc.d.ts.map +1 -0
  112. package/dist/normalize/misc.js +29 -0
  113. package/dist/normalize/misc.js.map +1 -0
  114. package/dist/normalize/retrofit.d.ts +14 -0
  115. package/dist/normalize/retrofit.d.ts.map +1 -0
  116. package/dist/normalize/retrofit.js +19 -0
  117. package/dist/normalize/retrofit.js.map +1 -0
  118. package/dist/normalize/ship.d.ts +67 -0
  119. package/dist/normalize/ship.d.ts.map +1 -0
  120. package/dist/normalize/ship.js +369 -0
  121. package/dist/normalize/ship.js.map +1 -0
  122. package/dist/normalize/skills.d.ts +20 -0
  123. package/dist/normalize/skills.d.ts.map +1 -0
  124. package/dist/normalize/skills.js +192 -0
  125. package/dist/normalize/skills.js.map +1 -0
  126. package/dist/normalize/skins.d.ts +14 -0
  127. package/dist/normalize/skins.d.ts.map +1 -0
  128. package/dist/normalize/skins.js +139 -0
  129. package/dist/normalize/skins.js.map +1 -0
  130. package/dist/normalize/slots.d.ts +14 -0
  131. package/dist/normalize/slots.d.ts.map +1 -0
  132. package/dist/normalize/slots.js +33 -0
  133. package/dist/normalize/slots.js.map +1 -0
  134. package/dist/normalize/stats.d.ts +19 -0
  135. package/dist/normalize/stats.d.ts.map +1 -0
  136. package/dist/normalize/stats.js +180 -0
  137. package/dist/normalize/stats.js.map +1 -0
  138. package/dist/output/index.d.ts +5 -0
  139. package/dist/output/index.d.ts.map +1 -0
  140. package/dist/output/index.js +5 -0
  141. package/dist/output/index.js.map +1 -0
  142. package/dist/output/writeIdMap.d.ts +16 -0
  143. package/dist/output/writeIdMap.d.ts.map +1 -0
  144. package/dist/output/writeIdMap.js +47 -0
  145. package/dist/output/writeIdMap.js.map +1 -0
  146. package/dist/output/writeShipList.d.ts +9 -0
  147. package/dist/output/writeShipList.d.ts.map +1 -0
  148. package/dist/output/writeShipList.js +26 -0
  149. package/dist/output/writeShipList.js.map +1 -0
  150. package/dist/output/writeShips.d.ts +15 -0
  151. package/dist/output/writeShips.d.ts.map +1 -0
  152. package/dist/output/writeShips.js +28 -0
  153. package/dist/output/writeShips.js.map +1 -0
  154. package/dist/output/writeVersion.d.ts +11 -0
  155. package/dist/output/writeVersion.d.ts.map +1 -0
  156. package/dist/output/writeVersion.js +18 -0
  157. package/dist/output/writeVersion.js.map +1 -0
  158. package/dist/schema/output/index.d.ts +2 -0
  159. package/dist/schema/output/index.d.ts.map +1 -0
  160. package/dist/schema/output/index.js +2 -0
  161. package/dist/schema/output/index.js.map +1 -0
  162. package/dist/schema/output/ship.d.ts +977 -0
  163. package/dist/schema/output/ship.d.ts.map +1 -0
  164. package/dist/schema/output/ship.js +167 -0
  165. package/dist/schema/output/ship.js.map +1 -0
  166. package/dist/schema/raw/attributeInfoByType.d.ts +25 -0
  167. package/dist/schema/raw/attributeInfoByType.d.ts.map +1 -0
  168. package/dist/schema/raw/attributeInfoByType.js +9 -0
  169. package/dist/schema/raw/attributeInfoByType.js.map +1 -0
  170. package/dist/schema/raw/equipDataByType.d.ts +31 -0
  171. package/dist/schema/raw/equipDataByType.d.ts.map +1 -0
  172. package/dist/schema/raw/equipDataByType.js +10 -0
  173. package/dist/schema/raw/equipDataByType.js.map +1 -0
  174. package/dist/schema/raw/fleetTechGroup.d.ts +19 -0
  175. package/dist/schema/raw/fleetTechGroup.d.ts.map +1 -0
  176. package/dist/schema/raw/fleetTechGroup.js +8 -0
  177. package/dist/schema/raw/fleetTechGroup.js.map +1 -0
  178. package/dist/schema/raw/fleetTechShipClass.d.ts +49 -0
  179. package/dist/schema/raw/fleetTechShipClass.d.ts.map +1 -0
  180. package/dist/schema/raw/fleetTechShipClass.js +13 -0
  181. package/dist/schema/raw/fleetTechShipClass.js.map +1 -0
  182. package/dist/schema/raw/fleetTechShipTemplate.d.ts +79 -0
  183. package/dist/schema/raw/fleetTechShipTemplate.d.ts.map +1 -0
  184. package/dist/schema/raw/fleetTechShipTemplate.js +18 -0
  185. package/dist/schema/raw/fleetTechShipTemplate.js.map +1 -0
  186. package/dist/schema/raw/index.d.ts +23 -0
  187. package/dist/schema/raw/index.d.ts.map +1 -0
  188. package/dist/schema/raw/index.js +23 -0
  189. package/dist/schema/raw/index.js.map +1 -0
  190. package/dist/schema/raw/shipDataBlueprint.d.ts +25 -0
  191. package/dist/schema/raw/shipDataBlueprint.d.ts.map +1 -0
  192. package/dist/schema/raw/shipDataBlueprint.js +9 -0
  193. package/dist/schema/raw/shipDataBlueprint.js.map +1 -0
  194. package/dist/schema/raw/shipDataBreakout.d.ts +61 -0
  195. package/dist/schema/raw/shipDataBreakout.d.ts.map +1 -0
  196. package/dist/schema/raw/shipDataBreakout.js +15 -0
  197. package/dist/schema/raw/shipDataBreakout.js.map +1 -0
  198. package/dist/schema/raw/shipDataByStar.d.ts +19 -0
  199. package/dist/schema/raw/shipDataByStar.d.ts.map +1 -0
  200. package/dist/schema/raw/shipDataByStar.js +8 -0
  201. package/dist/schema/raw/shipDataByStar.js.map +1 -0
  202. package/dist/schema/raw/shipDataByType.d.ts +37 -0
  203. package/dist/schema/raw/shipDataByType.d.ts.map +1 -0
  204. package/dist/schema/raw/shipDataByType.js +11 -0
  205. package/dist/schema/raw/shipDataByType.js.map +1 -0
  206. package/dist/schema/raw/shipDataCreateExchange.d.ts +19 -0
  207. package/dist/schema/raw/shipDataCreateExchange.d.ts.map +1 -0
  208. package/dist/schema/raw/shipDataCreateExchange.js +8 -0
  209. package/dist/schema/raw/shipDataCreateExchange.js.map +1 -0
  210. package/dist/schema/raw/shipDataGroup.d.ts +79 -0
  211. package/dist/schema/raw/shipDataGroup.d.ts.map +1 -0
  212. package/dist/schema/raw/shipDataGroup.js +20 -0
  213. package/dist/schema/raw/shipDataGroup.js.map +1 -0
  214. package/dist/schema/raw/shipDataStatistics.d.ts +103 -0
  215. package/dist/schema/raw/shipDataStatistics.d.ts.map +1 -0
  216. package/dist/schema/raw/shipDataStatistics.js +22 -0
  217. package/dist/schema/raw/shipDataStatistics.js.map +1 -0
  218. package/dist/schema/raw/shipDataStrengthen.d.ts +31 -0
  219. package/dist/schema/raw/shipDataStrengthen.d.ts.map +1 -0
  220. package/dist/schema/raw/shipDataStrengthen.js +10 -0
  221. package/dist/schema/raw/shipDataStrengthen.js.map +1 -0
  222. package/dist/schema/raw/shipDataTemplate.d.ts +115 -0
  223. package/dist/schema/raw/shipDataTemplate.d.ts.map +1 -0
  224. package/dist/schema/raw/shipDataTemplate.js +24 -0
  225. package/dist/schema/raw/shipDataTemplate.js.map +1 -0
  226. package/dist/schema/raw/shipDataTrans.d.ts +37 -0
  227. package/dist/schema/raw/shipDataTrans.d.ts.map +1 -0
  228. package/dist/schema/raw/shipDataTrans.js +11 -0
  229. package/dist/schema/raw/shipDataTrans.js.map +1 -0
  230. package/dist/schema/raw/shipSkinTemplate.d.ts +97 -0
  231. package/dist/schema/raw/shipSkinTemplate.d.ts.map +1 -0
  232. package/dist/schema/raw/shipSkinTemplate.js +21 -0
  233. package/dist/schema/raw/shipSkinTemplate.js.map +1 -0
  234. package/dist/schema/raw/shipSkinWords.d.ts +25 -0
  235. package/dist/schema/raw/shipSkinWords.d.ts.map +1 -0
  236. package/dist/schema/raw/shipSkinWords.js +9 -0
  237. package/dist/schema/raw/shipSkinWords.js.map +1 -0
  238. package/dist/schema/raw/shopTemplate.d.ts +43 -0
  239. package/dist/schema/raw/shopTemplate.d.ts.map +1 -0
  240. package/dist/schema/raw/shopTemplate.js +12 -0
  241. package/dist/schema/raw/shopTemplate.js.map +1 -0
  242. package/dist/schema/raw/skillDataDisplay.d.ts +25 -0
  243. package/dist/schema/raw/skillDataDisplay.d.ts.map +1 -0
  244. package/dist/schema/raw/skillDataDisplay.js +9 -0
  245. package/dist/schema/raw/skillDataDisplay.js.map +1 -0
  246. package/dist/schema/raw/skillDataTemplate.d.ts +61 -0
  247. package/dist/schema/raw/skillDataTemplate.d.ts.map +1 -0
  248. package/dist/schema/raw/skillDataTemplate.js +15 -0
  249. package/dist/schema/raw/skillDataTemplate.js.map +1 -0
  250. package/dist/schema/raw/transformDataTemplate.d.ts +67 -0
  251. package/dist/schema/raw/transformDataTemplate.d.ts.map +1 -0
  252. package/dist/schema/raw/transformDataTemplate.js +16 -0
  253. package/dist/schema/raw/transformDataTemplate.js.map +1 -0
  254. package/dist/schema/raw/voiceActorCn.d.ts +25 -0
  255. package/dist/schema/raw/voiceActorCn.d.ts.map +1 -0
  256. package/dist/schema/raw/voiceActorCn.js +9 -0
  257. package/dist/schema/raw/voiceActorCn.js.map +1 -0
  258. package/dist/translate/enums.d.ts +34 -0
  259. package/dist/translate/enums.d.ts.map +1 -0
  260. package/dist/translate/enums.js +126 -0
  261. package/dist/translate/enums.js.map +1 -0
  262. package/dist/translate/index.d.ts +4 -0
  263. package/dist/translate/index.d.ts.map +1 -0
  264. package/dist/translate/index.js +4 -0
  265. package/dist/translate/index.js.map +1 -0
  266. package/dist/translate/lookups.d.ts +37 -0
  267. package/dist/translate/lookups.d.ts.map +1 -0
  268. package/dist/translate/lookups.js +61 -0
  269. package/dist/translate/lookups.js.map +1 -0
  270. package/dist/translate/strings.d.ts +40 -0
  271. package/dist/translate/strings.d.ts.map +1 -0
  272. package/dist/translate/strings.js +92 -0
  273. package/dist/translate/strings.js.map +1 -0
  274. package/package.json +37 -0
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeIdentity = normalizeIdentity;
4
+ const config_js_1 = require("../config.js");
5
+ const enums_js_1 = require("../translate/enums.js");
6
+ const strings_js_1 = require("../translate/strings.js");
7
+ // ---------------------------------------------------------------------------
8
+ // Helpers
9
+ // ---------------------------------------------------------------------------
10
+ /** Returns true if the string contains any CJK Unified Ideograph. */
11
+ function isLikelyChinese(s) {
12
+ return /[\u4e00-\u9fff]/.test(s);
13
+ }
14
+ // ---------------------------------------------------------------------------
15
+ // Main
16
+ // ---------------------------------------------------------------------------
17
+ function normalizeIdentity(inputs) {
18
+ const { groupType, rowIds, en, cn, jp, isEnReleased, isResearch, blueprintVersion, groupRow, lookups, } = inputs;
19
+ // ------------------------------------------------------------------
20
+ // Resolve the LB3 row ID — the row whose key ends with "4", or last entry.
21
+ // ------------------------------------------------------------------
22
+ const lb3RowId = rowIds.find((id) => id.endsWith("4")) ?? rowIds[rowIds.length - 1] ?? groupType;
23
+ const enStats = en.statistics[lb3RowId];
24
+ if (enStats === undefined) {
25
+ throw new Error(`normalizeIdentity: missing EN statistics row "${lb3RowId}" for group_type "${groupType}"`);
26
+ }
27
+ const enTemplate = en.template[lb3RowId];
28
+ if (enTemplate === undefined) {
29
+ throw new Error(`normalizeIdentity: missing EN template row "${lb3RowId}" for group_type "${groupType}"`);
30
+ }
31
+ // ------------------------------------------------------------------
32
+ // Names
33
+ // ------------------------------------------------------------------
34
+ // EN name: prefer statistics.name if not Chinese, else fall back to english_name
35
+ let nameEn;
36
+ const rawName = enStats.name;
37
+ const rawEnglishName = enStats.english_name;
38
+ if (!isLikelyChinese(rawName) && rawName.trim().length > 0) {
39
+ nameEn = rawName;
40
+ }
41
+ else if (rawEnglishName !== undefined && rawEnglishName.trim().length > 0 && !isLikelyChinese(rawEnglishName)) {
42
+ nameEn = rawEnglishName;
43
+ }
44
+ // else: both are Chinese/empty → nameEn stays undefined
45
+ // CN name: from cn.statistics matching row if it looks Chinese; else fall back
46
+ // to the EN name field if that was the Chinese value.
47
+ let nameCn;
48
+ if (cn !== undefined) {
49
+ const cnStats = cn.statistics[lb3RowId];
50
+ if (cnStats !== undefined && cnStats.name.trim().length > 0 && isLikelyChinese(cnStats.name)) {
51
+ nameCn = cnStats.name;
52
+ }
53
+ }
54
+ if (nameCn === undefined && isLikelyChinese(rawName)) {
55
+ nameCn = rawName;
56
+ }
57
+ // JP name: from jp.statistics matching row if provided
58
+ let nameJp;
59
+ if (jp !== undefined) {
60
+ const jpStats = jp.statistics[lb3RowId];
61
+ if (jpStats !== undefined && jpStats.name.trim().length > 0) {
62
+ nameJp = jpStats.name;
63
+ }
64
+ }
65
+ // Code: english_name from EN statistics
66
+ const nameCode = rawEnglishName !== undefined && rawEnglishName.trim().length > 0 ? rawEnglishName : undefined;
67
+ const names = {};
68
+ if (nameEn !== undefined)
69
+ names.en = nameEn;
70
+ if (nameCn !== undefined)
71
+ names.cn = nameCn;
72
+ if (nameJp !== undefined)
73
+ names.jp = nameJp;
74
+ if (nameCode !== undefined)
75
+ names.code = nameCode;
76
+ // ------------------------------------------------------------------
77
+ // Rarity
78
+ // ------------------------------------------------------------------
79
+ const rarityInt = enStats.rarity;
80
+ const rarity = (0, enums_js_1.rarityName)(rarityInt, isResearch, blueprintVersion);
81
+ // ------------------------------------------------------------------
82
+ // Stars
83
+ // ------------------------------------------------------------------
84
+ const starMax = enTemplate.star_max;
85
+ const stars = {
86
+ stars: (0, strings_js_1.starsString)(starMax),
87
+ value: starMax,
88
+ };
89
+ // ------------------------------------------------------------------
90
+ // Class
91
+ // ------------------------------------------------------------------
92
+ const tagListFallback = enStats.tag_list?.[0];
93
+ const shipClass = lookups.classNameFor(groupType, tagListFallback);
94
+ // ------------------------------------------------------------------
95
+ // Hull type
96
+ // ------------------------------------------------------------------
97
+ const hullType = lookups.hullTypeName(enTemplate.type);
98
+ // ------------------------------------------------------------------
99
+ // Nationality
100
+ // ------------------------------------------------------------------
101
+ const nationality = (0, enums_js_1.nationalityName)(groupRow.nationality);
102
+ // ------------------------------------------------------------------
103
+ // Wiki URL
104
+ // ------------------------------------------------------------------
105
+ const wikiUrl = nameEn !== undefined ? (0, strings_js_1.wikiUrlFor)(nameEn) : undefined;
106
+ // ------------------------------------------------------------------
107
+ // Thumbnail (shipyard icon from azurlane-images repo)
108
+ // ------------------------------------------------------------------
109
+ const thumbnail = `${config_js_1.THUMBNAILS_URL}/${groupType}.png`;
110
+ // ------------------------------------------------------------------
111
+ // Build output
112
+ // ------------------------------------------------------------------
113
+ const output = {
114
+ id: groupType,
115
+ names,
116
+ rarity,
117
+ stars,
118
+ class: shipClass,
119
+ hullType,
120
+ nationality,
121
+ thumbnail,
122
+ };
123
+ if (wikiUrl !== undefined) {
124
+ output.wikiUrl = wikiUrl;
125
+ }
126
+ // Only emit isEnReleased when false (saves space for the common case)
127
+ if (!isEnReleased) {
128
+ output.isEnReleased = false;
129
+ }
130
+ return output;
131
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./identity.js"), exports);
18
+ __exportStar(require("./stats.js"), exports);
19
+ __exportStar(require("./slots.js"), exports);
20
+ __exportStar(require("./skills.js"), exports);
21
+ __exportStar(require("./construction.js"), exports);
22
+ __exportStar(require("./retrofit.js"), exports);
23
+ __exportStar(require("./misc.js"), exports);
24
+ __exportStar(require("./skins.js"), exports);
25
+ __exportStar(require("./ship.js"), exports);
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeMisc = normalizeMisc;
4
+ // ---------------------------------------------------------------------------
5
+ // Main
6
+ // ---------------------------------------------------------------------------
7
+ function normalizeMisc(inputs) {
8
+ const { defaultSkinId, skinTemplate, lookups, artistOverride } = inputs;
9
+ let voiceName;
10
+ let artistName;
11
+ // voice: resolve via voice_actor field on the default skin row
12
+ const defaultSkinRow = skinTemplate[defaultSkinId];
13
+ if (defaultSkinRow !== undefined && defaultSkinRow.voice_actor !== undefined) {
14
+ const name = lookups.voiceActorName(defaultSkinRow.voice_actor);
15
+ if (name !== "Unknown") {
16
+ voiceName = name;
17
+ }
18
+ }
19
+ // artist: only from override — illustrator.json is empty in raw data
20
+ if (artistOverride !== undefined && artistOverride.trim().length > 0) {
21
+ artistName = artistOverride.trim();
22
+ }
23
+ if (voiceName === undefined && artistName === undefined) {
24
+ return { misc: undefined };
25
+ }
26
+ const misc = {
27
+ ...(artistName !== undefined ? { artist: { name: artistName } } : {}),
28
+ ...(voiceName !== undefined ? { voice: { name: voiceName } } : {}),
29
+ };
30
+ return { misc };
31
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeRetrofit = normalizeRetrofit;
4
+ // ---------------------------------------------------------------------------
5
+ // Main
6
+ // ---------------------------------------------------------------------------
7
+ function normalizeRetrofit(inputs) {
8
+ const { groupType, groupRow, trans, lookups } = inputs;
9
+ const retrofit = groupType in trans;
10
+ if (!retrofit) {
11
+ return { retrofit: false };
12
+ }
13
+ // Resolve the post-retrofit hull type from trans_type on the group row.
14
+ // If trans_type is 0 or missing, omit the field (no hull-type change detectable).
15
+ const transType = groupRow?.trans_type ?? 0;
16
+ if (transType === 0) {
17
+ return { retrofit: true };
18
+ }
19
+ const retrofitHullType = lookups.hullTypeName(transType);
20
+ return { retrofit: true, retrofitHullType };
21
+ }
@@ -0,0 +1,406 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.buildShip = buildShip;
37
+ exports.buildAllShips = buildAllShips;
38
+ exports.createBuildContext = createBuildContext;
39
+ const ship_js_1 = require("../schema/output/ship.js");
40
+ const identity_js_1 = require("./identity.js");
41
+ const stats_js_1 = require("./stats.js");
42
+ const slots_js_1 = require("./slots.js");
43
+ const skills_js_1 = require("./skills.js");
44
+ const construction_js_1 = require("./construction.js");
45
+ const retrofit_js_1 = require("./retrofit.js");
46
+ const misc_js_1 = require("./misc.js");
47
+ const skins_js_1 = require("./skins.js");
48
+ function buildIndexes(ctx) {
49
+ // Build groupByGroupType: scan ship_data_group and index by group_type
50
+ const groupByGroupType = new Map();
51
+ for (const row of Object.values(ctx.en.group)) {
52
+ if (row === undefined)
53
+ continue;
54
+ groupByGroupType.set(String(row.group_type), row);
55
+ }
56
+ // Build researchGroupTypes: blueprint keys are themselves group_types
57
+ // (confirmed: all 42 blueprint keys appear as group_type values in ship_data_template)
58
+ const researchGroupTypes = new Set();
59
+ const blueprintVersionMap = new Map();
60
+ for (const [key, bpRow] of Object.entries(ctx.en.blueprint)) {
61
+ researchGroupTypes.add(key);
62
+ if (bpRow?.blueprint_version !== undefined) {
63
+ blueprintVersionMap.set(key, bpRow.blueprint_version);
64
+ }
65
+ }
66
+ return { groupByGroupType, researchGroupTypes, blueprintVersionMap };
67
+ }
68
+ // ---------------------------------------------------------------------------
69
+ // buildShip
70
+ // ---------------------------------------------------------------------------
71
+ function buildShip(groupType, ctx, indexes) {
72
+ const idx = indexes ?? buildIndexes(ctx);
73
+ // -------------------------------------------------------------------------
74
+ // 1. Resolve LB rows for this group_type
75
+ // -------------------------------------------------------------------------
76
+ const rowIds = [];
77
+ for (const [key, row] of Object.entries(ctx.en.template)) {
78
+ if (row === undefined)
79
+ continue;
80
+ if (String(row.group_type) !== groupType)
81
+ continue;
82
+ // Skip 9-prefix rows (promo/alt forms)
83
+ if (key.startsWith("9"))
84
+ continue;
85
+ rowIds.push(key);
86
+ }
87
+ if (rowIds.length === 0) {
88
+ return null;
89
+ }
90
+ // Sort by last digit (LB stage suffix: 1/2/3/4)
91
+ rowIds.sort((a, b) => {
92
+ const lastA = a[a.length - 1] ?? "0";
93
+ const lastB = b[b.length - 1] ?? "0";
94
+ return lastA.localeCompare(lastB);
95
+ });
96
+ // lb0RowId = row ending in "1", lb3RowId = row ending in "4"
97
+ const lb0RowId = rowIds.find((id) => id.endsWith("1")) ?? rowIds[0];
98
+ const lb3RowId = rowIds.find((id) => id.endsWith("4")) ?? rowIds[rowIds.length - 1];
99
+ if (lb0RowId === undefined || lb3RowId === undefined) {
100
+ return null;
101
+ }
102
+ // -------------------------------------------------------------------------
103
+ // 2. Resolve the group row (pre-indexed)
104
+ // -------------------------------------------------------------------------
105
+ const groupRow = idx.groupByGroupType.get(groupType);
106
+ if (groupRow === undefined) {
107
+ return null;
108
+ }
109
+ // -------------------------------------------------------------------------
110
+ // 3. Determine isResearch and blueprintVersion
111
+ // -------------------------------------------------------------------------
112
+ const isResearch = idx.researchGroupTypes.has(groupType);
113
+ const blueprintVersion = idx.blueprintVersionMap.get(groupType);
114
+ // -------------------------------------------------------------------------
115
+ // 4. Determine isEnReleased
116
+ // True if the LB3 statistics row has a non-empty, non-Chinese name
117
+ // -------------------------------------------------------------------------
118
+ function isLikelyChinese(s) {
119
+ return /[\u4e00-\u9fff]/.test(s);
120
+ }
121
+ const lb3Stats = ctx.en.statistics[lb3RowId];
122
+ const lb3Name = lb3Stats?.name ?? "";
123
+ const isEnReleased = lb3Name.trim().length > 0 && !isLikelyChinese(lb3Name);
124
+ // -------------------------------------------------------------------------
125
+ // 5. Determine strengthen_id from lb0 template row
126
+ // -------------------------------------------------------------------------
127
+ const lb0Template = ctx.en.template[lb0RowId];
128
+ const strengthenId = lb0Template !== undefined
129
+ ? String(lb0Template.strengthen_id)
130
+ : groupType;
131
+ // ship type from lb3 template
132
+ const lb3Template = ctx.en.template[lb3RowId];
133
+ const shipType = lb3Template?.type ?? 0;
134
+ const starMax = lb3Template?.star_max ?? 6;
135
+ // initialStar: use rarity (from statistics) for the scrap medal lookup.
136
+ // AzurAPI historically mapped rarity → ship_data_by_star tier for medals:
137
+ // rarity 5 (Super Rare) → star 5 → 10 medals.
138
+ const initialStar = lb3Stats?.rarity ?? starMax;
139
+ // -------------------------------------------------------------------------
140
+ // 6. Call each normalizer
141
+ // -------------------------------------------------------------------------
142
+ // Identity
143
+ const identityOutput = (0, identity_js_1.normalizeIdentity)({
144
+ groupType,
145
+ rowIds,
146
+ en: {
147
+ template: ctx.en.template,
148
+ statistics: ctx.en.statistics,
149
+ group: ctx.en.group,
150
+ blueprint: ctx.en.blueprint,
151
+ fleetTechShipTemplate: ctx.en.fleetTechShipTemplate,
152
+ fleetTechShipClass: ctx.en.fleetTechShipClass,
153
+ shipDataByType: ctx.en.shipDataByType,
154
+ },
155
+ cn: ctx.cn !== undefined ? { statistics: ctx.cn.statistics } : undefined,
156
+ jp: ctx.jp !== undefined ? { statistics: ctx.jp.statistics } : undefined,
157
+ isEnReleased,
158
+ isResearch,
159
+ blueprintVersion,
160
+ groupRow,
161
+ lookups: ctx.lookups,
162
+ });
163
+ // Stats
164
+ const statsOutput = (0, stats_js_1.normalizeStats)({
165
+ lb3RowId,
166
+ groupType,
167
+ strengthenId,
168
+ en: {
169
+ statistics: ctx.en.statistics,
170
+ strengthen: ctx.en.strengthen,
171
+ trans: ctx.en.trans,
172
+ transformDataTemplate: ctx.en.transformDataTemplate,
173
+ },
174
+ });
175
+ // Slots
176
+ const slots = (0, slots_js_1.normalizeSlots)({
177
+ lb0RowId,
178
+ lb3RowId,
179
+ template: ctx.en.template,
180
+ statistics: ctx.en.statistics,
181
+ lookups: ctx.lookups,
182
+ });
183
+ // Skills
184
+ const skillsOutput = (0, skills_js_1.normalizeSkills)({
185
+ rowIds,
186
+ groupType,
187
+ en: {
188
+ template: ctx.en.template,
189
+ breakout: ctx.en.breakout,
190
+ skillDataTemplate: ctx.en.skillDataTemplate,
191
+ skillDataDisplay: ctx.en.skillDataDisplay,
192
+ trans: ctx.en.trans,
193
+ transformDataTemplate: ctx.en.transformDataTemplate,
194
+ },
195
+ });
196
+ // Construction
197
+ const constructionOutput = (0, construction_js_1.normalizeConstruction)({
198
+ groupType,
199
+ groupRow,
200
+ lb3RowId,
201
+ shipType,
202
+ starMax,
203
+ initialStar,
204
+ fleetTechShipTemplate: ctx.en.fleetTechShipTemplate,
205
+ shipDataCreateExchange: ctx.en.exchange,
206
+ shipDataByType: ctx.en.shipDataByType,
207
+ shipDataByStar: ctx.en.shipDataByStar,
208
+ lookups: ctx.lookups,
209
+ constructionTimeOverride: ctx.overrides?.constructionTimes?.[groupType],
210
+ });
211
+ // Retrofit
212
+ const retrofitOutput = (0, retrofit_js_1.normalizeRetrofit)({
213
+ groupType,
214
+ groupRow,
215
+ trans: ctx.en.trans,
216
+ lookups: ctx.lookups,
217
+ });
218
+ // Misc
219
+ const miscOutput = (0, misc_js_1.normalizeMisc)({
220
+ defaultSkinId: `${groupType}0`,
221
+ skinTemplate: ctx.en.skinTemplate,
222
+ lookups: ctx.lookups,
223
+ artistOverride: ctx.overrides?.artists?.[groupType],
224
+ });
225
+ // Skins
226
+ const skinsOutput = (0, skins_js_1.normalizeSkins)({
227
+ groupType,
228
+ skinTemplate: ctx.en.skinTemplate,
229
+ shopTemplate: ctx.en.shopTemplate,
230
+ thumbnailBaseUrl: ctx.thumbnailBaseUrl,
231
+ availablePaintings: ctx.availablePaintings,
232
+ });
233
+ // -------------------------------------------------------------------------
234
+ // 7. Merge all partials into a Ship object
235
+ // -------------------------------------------------------------------------
236
+ const shipCandidate = {
237
+ id: identityOutput.id,
238
+ names: identityOutput.names,
239
+ rarity: identityOutput.rarity,
240
+ stars: identityOutput.stars,
241
+ thumbnail: identityOutput.thumbnail,
242
+ class: identityOutput.class,
243
+ hullType: identityOutput.hullType,
244
+ nationality: identityOutput.nationality,
245
+ stats: statsOutput.stats,
246
+ enhanceValue: statsOutput.enhanceValue,
247
+ slots,
248
+ skills: skillsOutput.skills,
249
+ retrofit: retrofitOutput.retrofit,
250
+ skins: skinsOutput.skins,
251
+ };
252
+ if (identityOutput.wikiUrl !== undefined) {
253
+ shipCandidate.wikiUrl = identityOutput.wikiUrl;
254
+ }
255
+ if (identityOutput.isEnReleased === false) {
256
+ shipCandidate.isEnReleased = false;
257
+ }
258
+ if (skillsOutput.limitBreaks !== undefined) {
259
+ shipCandidate.limitBreaks = skillsOutput.limitBreaks;
260
+ }
261
+ if (constructionOutput.construction !== undefined) {
262
+ shipCandidate.construction = constructionOutput.construction;
263
+ }
264
+ if (constructionOutput.scrapValue !== undefined) {
265
+ shipCandidate.scrapValue = constructionOutput.scrapValue;
266
+ }
267
+ if (constructionOutput.fleetTech !== undefined) {
268
+ shipCandidate.fleetTech = constructionOutput.fleetTech;
269
+ }
270
+ if (constructionOutput.obtainedFrom !== undefined) {
271
+ shipCandidate.obtainedFrom = constructionOutput.obtainedFrom;
272
+ }
273
+ if (retrofitOutput.retrofitHullType !== undefined) {
274
+ shipCandidate.retrofitHullType = retrofitOutput.retrofitHullType;
275
+ }
276
+ if (miscOutput.misc !== undefined) {
277
+ shipCandidate.misc = miscOutput.misc;
278
+ }
279
+ // -------------------------------------------------------------------------
280
+ // 8. Validate with ShipSchema.parse
281
+ // -------------------------------------------------------------------------
282
+ const parseResult = ship_js_1.ShipSchema.safeParse(shipCandidate);
283
+ if (!parseResult.success) {
284
+ console.error(`[buildShip] ShipSchema.parse failed for group_type="${groupType}":`, parseResult.error.message);
285
+ return null;
286
+ }
287
+ return parseResult.data;
288
+ }
289
+ // ---------------------------------------------------------------------------
290
+ // buildAllShips
291
+ // ---------------------------------------------------------------------------
292
+ function buildAllShips(ctx) {
293
+ // Pre-build shared indexes once for O(n) total cost
294
+ const indexes = buildIndexes(ctx);
295
+ // Collect all unique group_types from EN template, excluding 9-prefix rows
296
+ const groupTypeSet = new Set();
297
+ for (const [key, row] of Object.entries(ctx.en.template)) {
298
+ if (row === undefined)
299
+ continue;
300
+ if (key.startsWith("9"))
301
+ continue;
302
+ groupTypeSet.add(String(row.group_type));
303
+ }
304
+ const ships = [];
305
+ let failCount = 0;
306
+ for (const groupType of groupTypeSet) {
307
+ try {
308
+ const ship = buildShip(groupType, ctx, indexes);
309
+ if (ship !== null) {
310
+ ships.push(ship);
311
+ }
312
+ }
313
+ catch (err) {
314
+ failCount++;
315
+ console.error(`[buildAllShips] Unexpected error for group_type="${groupType}":`, err instanceof Error ? err.message : String(err));
316
+ }
317
+ }
318
+ if (failCount > 0) {
319
+ console.warn(`[buildAllShips] ${failCount} ships threw unexpected errors and were skipped.`);
320
+ }
321
+ // Sort by id numerically
322
+ ships.sort((a, b) => Number(a.id) - Number(b.id));
323
+ return ships;
324
+ }
325
+ // ---------------------------------------------------------------------------
326
+ // createBuildContext
327
+ // ---------------------------------------------------------------------------
328
+ /**
329
+ * Create a BuildContext by loading all EN raw tables plus optional CN/JP overlays.
330
+ * This is a convenience function for scripts/build-data.ts.
331
+ */
332
+ async function createBuildContext(options) {
333
+ const { loadShipDataTemplate, loadShipDataStatistics, loadShipDataBreakout, loadShipDataStrengthen, loadShipDataBlueprint, loadShipDataTrans, loadShipDataGroup, loadShipSkinTemplate, loadShopTemplate, loadShipDataCreateExchange, loadShipDataByType, loadShipDataByStar, loadFleetTechShipTemplate, loadFleetTechShipClass, loadSkillDataTemplate, loadSkillDataDisplay, loadTransformDataTemplate, loadEquipDataByType, loadVoiceActorCn, loadAttributeInfoByType, } = await Promise.resolve().then(() => __importStar(require("../ingest/files.js")));
334
+ const { createLookups } = await Promise.resolve().then(() => __importStar(require("../translate/lookups.js")));
335
+ const enTemplate = loadShipDataTemplate("EN");
336
+ const enStatistics = loadShipDataStatistics("EN");
337
+ const enBreakout = loadShipDataBreakout("EN");
338
+ const enStrengthen = loadShipDataStrengthen("EN");
339
+ const enBlueprint = loadShipDataBlueprint("EN");
340
+ const enTrans = loadShipDataTrans("EN");
341
+ const enGroup = loadShipDataGroup("EN");
342
+ const enSkinTemplate = loadShipSkinTemplate("EN");
343
+ const enShopTemplate = loadShopTemplate("EN");
344
+ const enExchange = loadShipDataCreateExchange("EN");
345
+ const enShipDataByType = loadShipDataByType("EN");
346
+ const enShipDataByStar = loadShipDataByStar("EN");
347
+ const enFleetTechShipTemplate = loadFleetTechShipTemplate("EN");
348
+ const enFleetTechShipClass = loadFleetTechShipClass("EN");
349
+ const enSkillDataTemplate = loadSkillDataTemplate("EN");
350
+ const enSkillDataDisplay = loadSkillDataDisplay("EN");
351
+ const enTransformDataTemplate = loadTransformDataTemplate("EN");
352
+ const enEquipDataByType = loadEquipDataByType("EN");
353
+ const enVoiceActorCn = loadVoiceActorCn("EN");
354
+ const enAttributeInfoByType = loadAttributeInfoByType("EN");
355
+ const lookups = createLookups({
356
+ fleetTechShipTemplate: enFleetTechShipTemplate,
357
+ fleetTechShipClass: enFleetTechShipClass,
358
+ shipDataByType: enShipDataByType,
359
+ equipDataByType: enEquipDataByType,
360
+ skillDataTemplate: enSkillDataTemplate,
361
+ skillDataDisplay: enSkillDataDisplay,
362
+ voiceActorCn: enVoiceActorCn,
363
+ });
364
+ let cn;
365
+ if (options?.loadCn === true) {
366
+ const cnStats = loadShipDataStatistics("CN");
367
+ const cnGroup = loadShipDataGroup("CN");
368
+ const cnTemplate = loadShipDataTemplate("CN");
369
+ cn = { statistics: cnStats, group: cnGroup, template: cnTemplate };
370
+ }
371
+ let jp;
372
+ if (options?.loadJp === true) {
373
+ const jpStats = loadShipDataStatistics("JP");
374
+ jp = { statistics: jpStats };
375
+ }
376
+ return {
377
+ region: "EN",
378
+ en: {
379
+ template: enTemplate,
380
+ statistics: enStatistics,
381
+ breakout: enBreakout,
382
+ strengthen: enStrengthen,
383
+ blueprint: enBlueprint,
384
+ trans: enTrans,
385
+ group: enGroup,
386
+ skinTemplate: enSkinTemplate,
387
+ shopTemplate: enShopTemplate,
388
+ exchange: enExchange,
389
+ shipDataByType: enShipDataByType,
390
+ shipDataByStar: enShipDataByStar,
391
+ fleetTechShipTemplate: enFleetTechShipTemplate,
392
+ fleetTechShipClass: enFleetTechShipClass,
393
+ skillDataTemplate: enSkillDataTemplate,
394
+ skillDataDisplay: enSkillDataDisplay,
395
+ transformDataTemplate: enTransformDataTemplate,
396
+ equipDataByType: enEquipDataByType,
397
+ voiceActorCn: enVoiceActorCn,
398
+ attributeInfoByType: enAttributeInfoByType,
399
+ },
400
+ cn,
401
+ jp,
402
+ overrides: options?.overrides,
403
+ thumbnailBaseUrl: options?.thumbnailBaseUrl,
404
+ lookups,
405
+ };
406
+ }