@mrtdown/core 2.0.0-alpha.5 → 2.0.0-alpha.6

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 (250) hide show
  1. package/dist/index.d.ts +0 -7
  2. package/dist/index.js +0 -7
  3. package/dist/index.js.map +1 -1
  4. package/dist/schema/Landmark.js.map +1 -1
  5. package/dist/schema/Line.js.map +1 -1
  6. package/dist/schema/Operator.js.map +1 -1
  7. package/dist/schema/Service.js.map +1 -1
  8. package/dist/schema/Station.js.map +1 -1
  9. package/dist/schema/Town.js.map +1 -1
  10. package/dist/schema/common.js.map +1 -1
  11. package/dist/schema/issue/bundle.js.map +1 -1
  12. package/dist/schema/issue/cause.js.map +1 -1
  13. package/dist/schema/issue/claim.js.map +1 -1
  14. package/dist/schema/issue/entity.js.map +1 -1
  15. package/dist/schema/issue/evidence.js.map +1 -1
  16. package/dist/schema/issue/facilityEffect.js.map +1 -1
  17. package/dist/schema/issue/id.js.map +1 -1
  18. package/dist/schema/issue/impactEvent.js.map +1 -1
  19. package/dist/schema/issue/issue.js.map +1 -1
  20. package/dist/schema/issue/issueType.js.map +1 -1
  21. package/dist/schema/issue/period.js.map +1 -1
  22. package/dist/schema/issue/serviceEffect.js.map +1 -1
  23. package/dist/schema/issue/serviceScope.js.map +1 -1
  24. package/package.json +19 -44
  25. package/README.md +0 -107
  26. package/dist/cli/commands/create.d.ts +0 -30
  27. package/dist/cli/commands/create.js +0 -189
  28. package/dist/cli/commands/create.js.map +0 -1
  29. package/dist/cli/commands/list.d.ts +0 -6
  30. package/dist/cli/commands/list.js +0 -106
  31. package/dist/cli/commands/list.js.map +0 -1
  32. package/dist/cli/commands/show.d.ts +0 -6
  33. package/dist/cli/commands/show.js +0 -156
  34. package/dist/cli/commands/show.js.map +0 -1
  35. package/dist/cli/commands/validate.d.ts +0 -6
  36. package/dist/cli/commands/validate.js +0 -19
  37. package/dist/cli/commands/validate.js.map +0 -1
  38. package/dist/cli/index.d.ts +0 -2
  39. package/dist/cli/index.js +0 -162
  40. package/dist/cli/index.js.map +0 -1
  41. package/dist/constants.d.ts +0 -10
  42. package/dist/constants.js +0 -11
  43. package/dist/constants.js.map +0 -1
  44. package/dist/helpers/calculateDurationWithinServiceHours.d.ts +0 -2
  45. package/dist/helpers/calculateDurationWithinServiceHours.js +0 -13
  46. package/dist/helpers/calculateDurationWithinServiceHours.js.map +0 -1
  47. package/dist/helpers/calculateDurationWithinServiceHours.test.d.ts +0 -1
  48. package/dist/helpers/calculateDurationWithinServiceHours.test.js +0 -83
  49. package/dist/helpers/calculateDurationWithinServiceHours.test.js.map +0 -1
  50. package/dist/helpers/computeImpactFromEvidenceClaims.d.ts +0 -21
  51. package/dist/helpers/computeImpactFromEvidenceClaims.js +0 -293
  52. package/dist/helpers/computeImpactFromEvidenceClaims.js.map +0 -1
  53. package/dist/helpers/computeImpactFromEvidenceClaims.test.d.ts +0 -1
  54. package/dist/helpers/computeImpactFromEvidenceClaims.test.js +0 -544
  55. package/dist/helpers/computeImpactFromEvidenceClaims.test.js.map +0 -1
  56. package/dist/helpers/computeStartOfDaysWithinInterval.d.ts +0 -2
  57. package/dist/helpers/computeStartOfDaysWithinInterval.js +0 -15
  58. package/dist/helpers/computeStartOfDaysWithinInterval.js.map +0 -1
  59. package/dist/helpers/computeStartOfDaysWithinInterval.test.d.ts +0 -1
  60. package/dist/helpers/computeStartOfDaysWithinInterval.test.js +0 -126
  61. package/dist/helpers/computeStartOfDaysWithinInterval.test.js.map +0 -1
  62. package/dist/helpers/estimateOpenAICost.d.ts +0 -40
  63. package/dist/helpers/estimateOpenAICost.js +0 -55
  64. package/dist/helpers/estimateOpenAICost.js.map +0 -1
  65. package/dist/helpers/keyForAffectedEntity.d.ts +0 -7
  66. package/dist/helpers/keyForAffectedEntity.js +0 -14
  67. package/dist/helpers/keyForAffectedEntity.js.map +0 -1
  68. package/dist/helpers/normalizeRecurringPeriod.d.ts +0 -7
  69. package/dist/helpers/normalizeRecurringPeriod.js +0 -118
  70. package/dist/helpers/normalizeRecurringPeriod.js.map +0 -1
  71. package/dist/helpers/normalizeRecurringPeriod.test.d.ts +0 -1
  72. package/dist/helpers/normalizeRecurringPeriod.test.js +0 -93
  73. package/dist/helpers/normalizeRecurringPeriod.test.js.map +0 -1
  74. package/dist/helpers/resolvePeriods.d.ts +0 -224
  75. package/dist/helpers/resolvePeriods.js +0 -207
  76. package/dist/helpers/resolvePeriods.js.map +0 -1
  77. package/dist/helpers/resolvePeriods.test.d.ts +0 -1
  78. package/dist/helpers/resolvePeriods.test.js +0 -239
  79. package/dist/helpers/resolvePeriods.test.js.map +0 -1
  80. package/dist/helpers/splitIntervalByServiceHours.d.ts +0 -2
  81. package/dist/helpers/splitIntervalByServiceHours.js +0 -30
  82. package/dist/helpers/splitIntervalByServiceHours.js.map +0 -1
  83. package/dist/helpers/splitIntervalByServiceHours.test.d.ts +0 -1
  84. package/dist/helpers/splitIntervalByServiceHours.test.js +0 -152
  85. package/dist/helpers/splitIntervalByServiceHours.test.js.map +0 -1
  86. package/dist/helpers/sumIntervalDuration.d.ts +0 -2
  87. package/dist/helpers/sumIntervalDuration.js +0 -9
  88. package/dist/helpers/sumIntervalDuration.js.map +0 -1
  89. package/dist/llm/client.d.ts +0 -2
  90. package/dist/llm/client.js +0 -5
  91. package/dist/llm/client.js.map +0 -1
  92. package/dist/llm/common/MemoryStore.d.ts +0 -21
  93. package/dist/llm/common/MemoryStore.js +0 -100
  94. package/dist/llm/common/MemoryStore.js.map +0 -1
  95. package/dist/llm/common/MemoryStore.test.d.ts +0 -1
  96. package/dist/llm/common/MemoryStore.test.js +0 -225
  97. package/dist/llm/common/MemoryStore.test.js.map +0 -1
  98. package/dist/llm/common/formatCurrentState.d.ts +0 -10
  99. package/dist/llm/common/formatCurrentState.js +0 -342
  100. package/dist/llm/common/formatCurrentState.js.map +0 -1
  101. package/dist/llm/common/tool.d.ts +0 -32
  102. package/dist/llm/common/tool.js +0 -6
  103. package/dist/llm/common/tool.js.map +0 -1
  104. package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.d.ts +0 -1
  105. package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.js +0 -433
  106. package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.js.map +0 -1
  107. package/dist/llm/functions/extractClaimsFromNewEvidence/index.d.ts +0 -18
  108. package/dist/llm/functions/extractClaimsFromNewEvidence/index.js +0 -153
  109. package/dist/llm/functions/extractClaimsFromNewEvidence/index.js.map +0 -1
  110. package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.d.ts +0 -1
  111. package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.js +0 -168
  112. package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.js.map +0 -1
  113. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.d.ts +0 -19
  114. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.js +0 -65
  115. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.js.map +0 -1
  116. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.d.ts +0 -21
  117. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.js +0 -115
  118. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.js.map +0 -1
  119. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.d.ts +0 -24
  120. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.js +0 -110
  121. package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.js.map +0 -1
  122. package/dist/llm/functions/generateIssueTitleAndSlug/index.d.ts +0 -14
  123. package/dist/llm/functions/generateIssueTitleAndSlug/index.js +0 -38
  124. package/dist/llm/functions/generateIssueTitleAndSlug/index.js.map +0 -1
  125. package/dist/llm/functions/generateIssueTitleAndSlug/prompt.d.ts +0 -1
  126. package/dist/llm/functions/generateIssueTitleAndSlug/prompt.js +0 -23
  127. package/dist/llm/functions/generateIssueTitleAndSlug/prompt.js.map +0 -1
  128. package/dist/llm/functions/translate/index.d.ts +0 -1
  129. package/dist/llm/functions/translate/index.js +0 -59
  130. package/dist/llm/functions/translate/index.js.map +0 -1
  131. package/dist/llm/functions/triageNewEvidence/eval.test.d.ts +0 -1
  132. package/dist/llm/functions/triageNewEvidence/eval.test.js +0 -139
  133. package/dist/llm/functions/triageNewEvidence/eval.test.js.map +0 -1
  134. package/dist/llm/functions/triageNewEvidence/index.d.ts +0 -37
  135. package/dist/llm/functions/triageNewEvidence/index.js +0 -121
  136. package/dist/llm/functions/triageNewEvidence/index.js.map +0 -1
  137. package/dist/llm/functions/triageNewEvidence/prompt.d.ts +0 -1
  138. package/dist/llm/functions/triageNewEvidence/prompt.js +0 -60
  139. package/dist/llm/functions/triageNewEvidence/prompt.js.map +0 -1
  140. package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.d.ts +0 -19
  141. package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.js +0 -65
  142. package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.js.map +0 -1
  143. package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.d.ts +0 -19
  144. package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.js +0 -37
  145. package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.js.map +0 -1
  146. package/dist/repo/MRTDownRepository.d.ts +0 -23
  147. package/dist/repo/MRTDownRepository.js +0 -28
  148. package/dist/repo/MRTDownRepository.js.map +0 -1
  149. package/dist/repo/common/FileStore.d.ts +0 -12
  150. package/dist/repo/common/FileStore.js +0 -27
  151. package/dist/repo/common/FileStore.js.map +0 -1
  152. package/dist/repo/common/StandardRepository.d.ts +0 -32
  153. package/dist/repo/common/StandardRepository.js +0 -58
  154. package/dist/repo/common/StandardRepository.js.map +0 -1
  155. package/dist/repo/common/store.d.ts +0 -29
  156. package/dist/repo/common/store.js +0 -2
  157. package/dist/repo/common/store.js.map +0 -1
  158. package/dist/repo/issue/IssueRepository.d.ts +0 -36
  159. package/dist/repo/issue/IssueRepository.js +0 -177
  160. package/dist/repo/issue/IssueRepository.js.map +0 -1
  161. package/dist/repo/issue/helpers/deriveCurrentState.d.ts +0 -51
  162. package/dist/repo/issue/helpers/deriveCurrentState.js +0 -113
  163. package/dist/repo/issue/helpers/deriveCurrentState.js.map +0 -1
  164. package/dist/repo/issue/helpers/deriveCurrentState.test.d.ts +0 -1
  165. package/dist/repo/issue/helpers/deriveCurrentState.test.js +0 -477
  166. package/dist/repo/issue/helpers/deriveCurrentState.test.js.map +0 -1
  167. package/dist/repo/landmark/LandmarkRepository.d.ts +0 -7
  168. package/dist/repo/landmark/LandmarkRepository.js +0 -12
  169. package/dist/repo/landmark/LandmarkRepository.js.map +0 -1
  170. package/dist/repo/line/LineRepository.d.ts +0 -13
  171. package/dist/repo/line/LineRepository.js +0 -32
  172. package/dist/repo/line/LineRepository.js.map +0 -1
  173. package/dist/repo/operator/OperatorRepository.d.ts +0 -7
  174. package/dist/repo/operator/OperatorRepository.js +0 -12
  175. package/dist/repo/operator/OperatorRepository.js.map +0 -1
  176. package/dist/repo/service/ServiceRepository.d.ts +0 -19
  177. package/dist/repo/service/ServiceRepository.js +0 -39
  178. package/dist/repo/service/ServiceRepository.js.map +0 -1
  179. package/dist/repo/station/StationRepository.d.ts +0 -13
  180. package/dist/repo/station/StationRepository.js +0 -30
  181. package/dist/repo/station/StationRepository.js.map +0 -1
  182. package/dist/repo/town/TownRepository.d.ts +0 -7
  183. package/dist/repo/town/TownRepository.js +0 -12
  184. package/dist/repo/town/TownRepository.js.map +0 -1
  185. package/dist/scripts/ingestViaWebhook.d.ts +0 -1
  186. package/dist/scripts/ingestViaWebhook.js +0 -9
  187. package/dist/scripts/ingestViaWebhook.js.map +0 -1
  188. package/dist/util/assert.d.ts +0 -1
  189. package/dist/util/assert.js +0 -6
  190. package/dist/util/assert.js.map +0 -1
  191. package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.d.ts +0 -7
  192. package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.js +0 -24
  193. package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.js.map +0 -1
  194. package/dist/util/ingestContent/index.d.ts +0 -12
  195. package/dist/util/ingestContent/index.js +0 -171
  196. package/dist/util/ingestContent/index.js.map +0 -1
  197. package/dist/util/ingestContent/types.d.ts +0 -32
  198. package/dist/util/ingestContent/types.js +0 -2
  199. package/dist/util/ingestContent/types.js.map +0 -1
  200. package/dist/validators/buildContext.d.ts +0 -7
  201. package/dist/validators/buildContext.js +0 -164
  202. package/dist/validators/buildContext.js.map +0 -1
  203. package/dist/validators/index.d.ts +0 -17
  204. package/dist/validators/index.js +0 -58
  205. package/dist/validators/index.js.map +0 -1
  206. package/dist/validators/issue.d.ts +0 -13
  207. package/dist/validators/issue.js +0 -220
  208. package/dist/validators/issue.js.map +0 -1
  209. package/dist/validators/landmark.d.ts +0 -7
  210. package/dist/validators/landmark.js +0 -43
  211. package/dist/validators/landmark.js.map +0 -1
  212. package/dist/validators/line.d.ts +0 -8
  213. package/dist/validators/line.js +0 -87
  214. package/dist/validators/line.js.map +0 -1
  215. package/dist/validators/operator.d.ts +0 -7
  216. package/dist/validators/operator.js +0 -43
  217. package/dist/validators/operator.js.map +0 -1
  218. package/dist/validators/service.d.ts +0 -8
  219. package/dist/validators/service.js +0 -87
  220. package/dist/validators/service.js.map +0 -1
  221. package/dist/validators/station.d.ts +0 -8
  222. package/dist/validators/station.js +0 -93
  223. package/dist/validators/station.js.map +0 -1
  224. package/dist/validators/town.d.ts +0 -7
  225. package/dist/validators/town.js +0 -43
  226. package/dist/validators/town.js.map +0 -1
  227. package/dist/validators/types.d.ts +0 -19
  228. package/dist/validators/types.js +0 -2
  229. package/dist/validators/types.js.map +0 -1
  230. package/dist/validators/utils.d.ts +0 -2
  231. package/dist/validators/utils.js +0 -9
  232. package/dist/validators/utils.js.map +0 -1
  233. package/dist/write/MRTDownWriter.d.ts +0 -27
  234. package/dist/write/MRTDownWriter.js +0 -27
  235. package/dist/write/MRTDownWriter.js.map +0 -1
  236. package/dist/write/common/FileWriteStore.d.ts +0 -13
  237. package/dist/write/common/FileWriteStore.js +0 -31
  238. package/dist/write/common/FileWriteStore.js.map +0 -1
  239. package/dist/write/common/StandardWriter.d.ts +0 -14
  240. package/dist/write/common/StandardWriter.js +0 -17
  241. package/dist/write/common/StandardWriter.js.map +0 -1
  242. package/dist/write/common/store.d.ts +0 -32
  243. package/dist/write/common/store.js +0 -2
  244. package/dist/write/common/store.js.map +0 -1
  245. package/dist/write/id/IdGenerator.d.ts +0 -18
  246. package/dist/write/id/IdGenerator.js +0 -23
  247. package/dist/write/id/IdGenerator.js.map +0 -1
  248. package/dist/write/issue/IssueWriter.d.ts +0 -12
  249. package/dist/write/issue/IssueWriter.js +0 -33
  250. package/dist/write/issue/IssueWriter.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildContext.js","sourceRoot":"/","sources":["validators/buildContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,QAAQ,EAAE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AC;4BACZ,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;4BACrC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;gCACzB,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gCAC7D,IAAI,QAAQ,CAAC,OAAO;oCAAE,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;oCAEtD,OAAO,CAAC,IAAI,CACV,mDAAmD,YAAY,GAAG,EAClE,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,QAAQ,CAAC,KAAK,CAC1C,CAAC;4BACN,CAAC;wBACH,CAAC;oBACH,CAAC;oBAAC,OAAO,GAAG,EAAE,CAAC;wBACb,OAAO,CAAC,IAAI,CACV,2CAA2C,YAAY,EAAE,EACzD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CACzC,CAAC;oBACJ,CAAC;oBACD,GAAG,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,gDAAgD,EAChD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CACzC,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { join } from 'node:path';\nimport { NdJson } from 'json-nd';\nimport z from 'zod';\nimport { LandmarkSchema } from '../schema/Landmark.js';\nimport { LineSchema } from '../schema/Line.js';\nimport { OperatorSchema } from '../schema/Operator.js';\nimport { ServiceSchema } from '../schema/Service.js';\nimport { StationSchema } from '../schema/Station.js';\nimport { TownSchema } from '../schema/Town.js';\nimport {\n DIR_ISSUE,\n DIR_LANDMARK,\n DIR_LINE,\n DIR_OPERATOR,\n DIR_SERVICE,\n DIR_STATION,\n DIR_TOWN,\n} from '../constants.js';\nimport type { IStore } from '../repo/common/store.js';\nimport type { ValidationContext } from './types.js';\nimport { loadJson } from './utils.js';\n\n/**\n * Loads all entity IDs from the store into a ValidationContext.\n * Use this to build context once, then pass it to validators for relationship checks.\n */\nexport function buildContext(store: IStore): ValidationContext {\n const ctx: ValidationContext = {\n townIds: new Set(),\n landmarkIds: new Set(),\n operatorIds: new Set(),\n lineIds: new Set(),\n serviceIds: new Set(),\n stationIds: new Set(),\n evidenceIdsByIssue: new Map(),\n };\n\n try {\n for (const file of store.listDir(DIR_TOWN)) {\n if (!file.endsWith('.json')) continue;\n const path = join(DIR_TOWN, file);\n const raw = loadJson<unknown>(store, path);\n const parsed = TownSchema.safeParse(raw);\n if (parsed.success) ctx.townIds.add(parsed.data.id);\n else\n console.warn(\n `[buildContext] Skipping invalid town: ${path}`,\n parsed.error?.message ?? parsed.error,\n );\n }\n } catch (err) {\n console.warn(\n '[buildContext] Failed to load towns:',\n err instanceof Error ? err.message : err,\n );\n }\n\n try {\n for (const file of store.listDir(DIR_LANDMARK)) {\n if (!file.endsWith('.json')) continue;\n const path = join(DIR_LANDMARK, file);\n const raw = loadJson<unknown>(store, path);\n const parsed = LandmarkSchema.safeParse(raw);\n if (parsed.success) ctx.landmarkIds.add(parsed.data.id);\n else\n console.warn(\n `[buildContext] Skipping invalid landmark: ${path}`,\n parsed.error?.message ?? parsed.error,\n );\n }\n } catch (err) {\n console.warn(\n '[buildContext] Failed to load landmarks:',\n err instanceof Error ? err.message : err,\n );\n }\n\n try {\n for (const file of store.listDir(DIR_OPERATOR)) {\n if (!file.endsWith('.json')) continue;\n const path = join(DIR_OPERATOR, file);\n const raw = loadJson<unknown>(store, path);\n const parsed = OperatorSchema.safeParse(raw);\n if (parsed.success) ctx.operatorIds.add(parsed.data.id);\n else\n console.warn(\n `[buildContext] Skipping invalid operator: ${path}`,\n parsed.error?.message ?? parsed.error,\n );\n }\n } catch (err) {\n console.warn(\n '[buildContext] Failed to load operators:',\n err instanceof Error ? err.message : err,\n );\n }\n\n try {\n for (const file of store.listDir(DIR_LINE)) {\n if (!file.endsWith('.json')) continue;\n const path = join(DIR_LINE, file);\n const raw = loadJson<unknown>(store, path);\n const parsed = LineSchema.safeParse(raw);\n if (parsed.success) ctx.lineIds.add(parsed.data.id);\n else\n console.warn(\n `[buildContext] Skipping invalid line: ${path}`,\n parsed.error?.message ?? parsed.error,\n );\n }\n } catch (err) {\n console.warn(\n '[buildContext] Failed to load lines:',\n err instanceof Error ? err.message : err,\n );\n }\n\n try {\n for (const file of store.listDir(DIR_STATION)) {\n if (!file.endsWith('.json')) continue;\n const path = join(DIR_STATION, file);\n const raw = loadJson<unknown>(store, path);\n const parsed = StationSchema.safeParse(raw);\n if (parsed.success) ctx.stationIds.add(parsed.data.id);\n else\n console.warn(\n `[buildContext] Skipping invalid station: ${path}`,\n parsed.error?.message ?? parsed.error,\n );\n }\n } catch (err) {\n console.warn(\n '[buildContext] Failed to load stations:',\n err instanceof Error ? err.message : err,\n );\n }\n\n try {\n for (const file of store.listDir(DIR_SERVICE)) {\n if (!file.endsWith('.json')) continue;\n const path = join(DIR_SERVICE, file);\n const raw = loadJson<unknown>(store, path);\n const parsed = ServiceSchema.safeParse(raw);\n if (parsed.success) ctx.serviceIds.add(parsed.data.id);\n else\n console.warn(\n `[buildContext] Skipping invalid service: ${path}`,\n parsed.error?.message ?? parsed.error,\n );\n }\n } catch (err) {\n console.warn(\n '[buildContext] Failed to load services:',\n err instanceof Error ? err.message : err,\n );\n }\n\n try {\n const years = store.listDir(DIR_ISSUE);\n for (const year of years) {\n if (!/^\\d{4}$/.test(year)) continue;\n const monthsPath = join(DIR_ISSUE, year);\n const months = store.listDir(monthsPath);\n for (const month of months) {\n if (!/^\\d{2}$/.test(month)) continue;\n const issuesPath = join(monthsPath, month);\n const issues = store.listDir(issuesPath);\n for (const issueId of issues) {\n const relBase = join(DIR_ISSUE, year, month, issueId);\n const evidencePath = join(relBase, 'evidence.ndjson');\n const evidenceIds = new Set<string>();\n try {\n const content = store.readText(evidencePath).trim();\n if (content) {\n const parsed = NdJson.parse(content);\n for (const row of parsed) {\n const idParsed = z.object({ id: z.string() }).safeParse(row);\n if (idParsed.success) evidenceIds.add(idParsed.data.id);\n else\n console.warn(\n `[buildContext] Skipping invalid evidence row in ${evidencePath}:`,\n idParsed.error?.message ?? idParsed.error,\n );\n }\n }\n } catch (err) {\n console.warn(\n `[buildContext] Failed to read evidence: ${evidencePath}`,\n err instanceof Error ? err.message : err,\n );\n }\n ctx.evidenceIdsByIssue.set(relBase, evidenceIds);\n }\n }\n }\n } catch (err) {\n console.warn(\n '[buildContext] Failed to load issues/evidence:',\n err instanceof Error ? err.message : err,\n );\n }\n\n return ctx;\n}\n"]}
@@ -1,17 +0,0 @@
1
- import type { IStore } from '../repo/common/store.js';
2
- import type { ValidationError } from './types.js';
3
- export type ValidationScope = 'town' | 'landmark' | 'operator' | 'station' | 'line' | 'service' | 'issue';
4
- export interface ValidateOptions {
5
- /** When set, only run validators for these entity types. */
6
- scope?: ValidationScope[];
7
- }
8
- export declare function validateAll(store: IStore, options?: ValidateOptions): ValidationError[];
9
- export { buildContext } from './buildContext.js';
10
- export { validateIssue, validateIssues } from './issue.js';
11
- export { validateLandmarks } from './landmark.js';
12
- export { validateLines, validateLinesRelationships, } from './line.js';
13
- export { validateOperators } from './operator.js';
14
- export { validateServices, validateServicesRelationships, } from './service.js';
15
- export { validateStations, validateStationsRelationships, } from './station.js';
16
- export { validateTowns } from './town.js';
17
- export type { ValidationContext, ValidationError } from './types.js';
@@ -1,58 +0,0 @@
1
- import { buildContext } from './buildContext.js';
2
- import { validateIssues } from './issue.js';
3
- import { validateLandmarks } from './landmark.js';
4
- import { validateLines, validateLinesRelationships } from './line.js';
5
- import { validateOperators } from './operator.js';
6
- import { validateServices, validateServicesRelationships } from './service.js';
7
- import { validateStations, validateStationsRelationships } from './station.js';
8
- import { validateTowns } from './town.js';
9
- const SCOPE_NEEDS_CONTEXT = [
10
- 'station',
11
- 'line',
12
- 'service',
13
- 'issue',
14
- ];
15
- function inScope(scope, type) {
16
- return !scope || scope.has(type);
17
- }
18
- export function validateAll(store, options) {
19
- const scope = options?.scope;
20
- const scopeSet = scope && scope.length > 0 ? new Set(scope) : null;
21
- const needsContext = !scopeSet || SCOPE_NEEDS_CONTEXT.some((t) => scopeSet.has(t));
22
- const ctx = needsContext ? buildContext(store) : null;
23
- const allErrors = [];
24
- if (inScope(scopeSet, 'town'))
25
- allErrors.push(...validateTowns(store));
26
- if (inScope(scopeSet, 'landmark'))
27
- allErrors.push(...validateLandmarks(store));
28
- if (inScope(scopeSet, 'operator'))
29
- allErrors.push(...validateOperators(store));
30
- if (inScope(scopeSet, 'line')) {
31
- allErrors.push(...validateLines(store));
32
- if (ctx)
33
- allErrors.push(...validateLinesRelationships(store, ctx));
34
- }
35
- if (inScope(scopeSet, 'station')) {
36
- allErrors.push(...validateStations(store));
37
- if (ctx)
38
- allErrors.push(...validateStationsRelationships(store, ctx));
39
- }
40
- if (inScope(scopeSet, 'service')) {
41
- allErrors.push(...validateServices(store));
42
- if (ctx)
43
- allErrors.push(...validateServicesRelationships(store, ctx));
44
- }
45
- if (inScope(scopeSet, 'issue') && ctx) {
46
- allErrors.push(...validateIssues(store, ctx));
47
- }
48
- return allErrors;
49
- }
50
- export { buildContext } from './buildContext.js';
51
- export { validateIssue, validateIssues } from './issue.js';
52
- export { validateLandmarks } from './landmark.js';
53
- export { validateLines, validateLinesRelationships, } from './line.js';
54
- export { validateOperators } from './operator.js';
55
- export { validateServices, validateServicesRelationships, } from './service.js';
56
- export { validateStations, validateStationsRelationships, } from './station.js';
57
- export { validateTowns } from './town.js';
58
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {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AC,IAAI,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,aAAa,EACb,0BAA0B,GAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC","sourcesContent":["import type { IStore } from '../repo/common/store.js';\nimport { buildContext } from './buildContext.js';\nimport { validateIssues } from './issue.js';\nimport { validateLandmarks } from './landmark.js';\nimport { validateLines, validateLinesRelationships } from './line.js';\nimport { validateOperators } from './operator.js';\nimport { validateServices, validateServicesRelationships } from './service.js';\nimport { validateStations, validateStationsRelationships } from './station.js';\nimport { validateTowns } from './town.js';\nimport type { ValidationError } from './types.js';\n\nexport type ValidationScope =\n | 'town'\n | 'landmark'\n | 'operator'\n | 'station'\n | 'line'\n | 'service'\n | 'issue';\n\nexport interface ValidateOptions {\n /** When set, only run validators for these entity types. */\n scope?: ValidationScope[];\n}\n\nconst SCOPE_NEEDS_CONTEXT: ValidationScope[] = [\n 'station',\n 'line',\n 'service',\n 'issue',\n];\n\nfunction inScope(\n scope: Set<ValidationScope> | null,\n type: ValidationScope,\n): boolean {\n return !scope || scope.has(type);\n}\n\nexport function validateAll(\n store: IStore,\n options?: ValidateOptions,\n): ValidationError[] {\n const scope = options?.scope;\n const scopeSet = scope && scope.length > 0 ? new Set(scope) : null;\n const needsContext =\n !scopeSet || SCOPE_NEEDS_CONTEXT.some((t) => scopeSet.has(t));\n const ctx = needsContext ? buildContext(store) : null;\n\n const allErrors: ValidationError[] = [];\n\n if (inScope(scopeSet, 'town')) allErrors.push(...validateTowns(store));\n if (inScope(scopeSet, 'landmark'))\n allErrors.push(...validateLandmarks(store));\n if (inScope(scopeSet, 'operator'))\n allErrors.push(...validateOperators(store));\n if (inScope(scopeSet, 'line')) {\n allErrors.push(...validateLines(store));\n if (ctx) allErrors.push(...validateLinesRelationships(store, ctx));\n }\n if (inScope(scopeSet, 'station')) {\n allErrors.push(...validateStations(store));\n if (ctx) allErrors.push(...validateStationsRelationships(store, ctx));\n }\n if (inScope(scopeSet, 'service')) {\n allErrors.push(...validateServices(store));\n if (ctx) allErrors.push(...validateServicesRelationships(store, ctx));\n }\n if (inScope(scopeSet, 'issue') && ctx) {\n allErrors.push(...validateIssues(store, ctx));\n }\n\n return allErrors;\n}\n\nexport { buildContext } from './buildContext.js';\nexport { validateIssue, validateIssues } from './issue.js';\nexport { validateLandmarks } from './landmark.js';\nexport {\n validateLines,\n validateLinesRelationships,\n} from './line.js';\nexport { validateOperators } from './operator.js';\nexport {\n validateServices,\n validateServicesRelationships,\n} from './service.js';\nexport {\n validateStations,\n validateStationsRelationships,\n} from './station.js';\nexport { validateTowns } from './town.js';\nexport type { ValidationContext, ValidationError } from './types.js';\n"]}
@@ -1,13 +0,0 @@
1
- import type { ImpactEvent } from '../schema/issue/impactEvent.js';
2
- import type { IStore } from '../repo/common/store.js';
3
- import type { ValidationContext, ValidationError } from './types.js';
4
- export declare function validateIssueSchema(data: unknown): ValidationError[];
5
- export declare function validateEvidenceSchema(data: unknown): ValidationError[];
6
- export declare function validateImpactEventSchema(data: unknown): ValidationError[];
7
- export declare function validateImpactEventRelationships(event: ImpactEvent, evidenceIds: Set<string>, file: string, lineNum: number, ctx?: ValidationContext): ValidationError[];
8
- /**
9
- * Validates a single issue at the given path (e.g. "issue/2025/03/2025-03-11-x").
10
- * Pass ctx for relationship validation (serviceIds, stationIds, evidenceIds).
11
- */
12
- export declare function validateIssue(store: IStore, relBase: string, ctx?: ValidationContext): ValidationError[];
13
- export declare function validateIssues(store: IStore, ctx?: ValidationContext): ValidationError[];
@@ -1,220 +0,0 @@
1
- import { join } from 'node:path';
2
- import { NdJson } from 'json-nd';
3
- import z from 'zod';
4
- import { EvidenceSchema } from '../schema/issue/evidence.js';
5
- import { ImpactEventSchema } from '../schema/issue/impactEvent.js';
6
- import { IssueSchema } from '../schema/issue/issue.js';
7
- import { DIR_ISSUE } from '../constants.js';
8
- import { loadJson } from './utils.js';
9
- export function validateIssueSchema(data) {
10
- const result = IssueSchema.safeParse(data);
11
- if (result.success)
12
- return [];
13
- return result.error.issues.map((i) => ({
14
- file: '',
15
- message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,
16
- }));
17
- }
18
- export function validateEvidenceSchema(data) {
19
- const result = EvidenceSchema.safeParse(data);
20
- if (result.success)
21
- return [];
22
- return result.error.issues.map((i) => ({
23
- file: '',
24
- message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,
25
- }));
26
- }
27
- export function validateImpactEventSchema(data) {
28
- const result = ImpactEventSchema.safeParse(data);
29
- if (result.success)
30
- return [];
31
- return result.error.issues.map((i) => ({
32
- file: '',
33
- message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,
34
- }));
35
- }
36
- export function validateImpactEventRelationships(event, evidenceIds, file, lineNum, ctx) {
37
- const errors = [];
38
- if (!evidenceIds.has(event.basis.evidenceId)) {
39
- errors.push({
40
- file,
41
- line: lineNum,
42
- message: `basis.evidenceId "${event.basis.evidenceId}" does not exist in evidence`,
43
- });
44
- }
45
- if (!ctx)
46
- return errors;
47
- if (event.entity.type === 'service') {
48
- if (!ctx.serviceIds.has(event.entity.serviceId)) {
49
- errors.push({
50
- file,
51
- line: lineNum,
52
- message: `entity.serviceId "${event.entity.serviceId}" does not exist`,
53
- });
54
- }
55
- }
56
- else {
57
- if (!ctx.stationIds.has(event.entity.stationId)) {
58
- errors.push({
59
- file,
60
- line: lineNum,
61
- message: `entity.stationId "${event.entity.stationId}" does not exist`,
62
- });
63
- }
64
- }
65
- if ('serviceScopes' in event && event.serviceScopes) {
66
- for (const scope of event.serviceScopes) {
67
- if (scope.type === 'service.segment') {
68
- if (!ctx.stationIds.has(scope.fromStationId)) {
69
- errors.push({
70
- file,
71
- line: lineNum,
72
- message: `serviceScopes[].fromStationId "${scope.fromStationId}" does not exist`,
73
- });
74
- }
75
- if (!ctx.stationIds.has(scope.toStationId)) {
76
- errors.push({
77
- file,
78
- line: lineNum,
79
- message: `serviceScopes[].toStationId "${scope.toStationId}" does not exist`,
80
- });
81
- }
82
- }
83
- else if (scope.type === 'service.point') {
84
- if (!ctx.stationIds.has(scope.stationId)) {
85
- errors.push({
86
- file,
87
- line: lineNum,
88
- message: `serviceScopes[].stationId "${scope.stationId}" does not exist`,
89
- });
90
- }
91
- }
92
- }
93
- }
94
- return errors;
95
- }
96
- function validateIssueAtPath(store, relBase, ctx) {
97
- const errors = [];
98
- const issueJsonPath = join(relBase, 'issue.json');
99
- if (!store.exists(issueJsonPath)) {
100
- errors.push({
101
- file: issueJsonPath,
102
- message: 'Issue not found',
103
- });
104
- return errors;
105
- }
106
- const issueRaw = loadJson(store, issueJsonPath);
107
- if (issueRaw) {
108
- const schemaErrs = validateIssueSchema(issueRaw);
109
- for (const e of schemaErrs) {
110
- errors.push({ ...e, file: e.file || issueJsonPath });
111
- }
112
- }
113
- else {
114
- errors.push({
115
- file: issueJsonPath,
116
- message: 'Failed to parse JSON',
117
- });
118
- }
119
- const evidenceIdsFromCtx = ctx?.evidenceIdsByIssue.get(relBase);
120
- const evidenceIds = evidenceIdsFromCtx !== undefined ? evidenceIdsFromCtx : new Set();
121
- const needToBuildEvidenceIds = evidenceIdsFromCtx === undefined;
122
- const evidencePath = join(relBase, 'evidence.ndjson');
123
- try {
124
- const content = store.readText(evidencePath).trim();
125
- if (content) {
126
- const parsed = NdJson.parse(content);
127
- for (let i = 0; i < parsed.length; i++) {
128
- const row = parsed[i];
129
- const schemaErrs = validateEvidenceSchema(row);
130
- for (const e of schemaErrs) {
131
- errors.push({
132
- ...e,
133
- file: evidencePath,
134
- line: i + 1,
135
- });
136
- }
137
- if (needToBuildEvidenceIds) {
138
- const idParsed = z.object({ id: z.string() }).safeParse(row);
139
- if (idParsed.success)
140
- evidenceIds.add(idParsed.data.id);
141
- }
142
- }
143
- }
144
- }
145
- catch {
146
- // ignore missing
147
- }
148
- const impactPath = join(relBase, 'impact.ndjson');
149
- try {
150
- const content = store.readText(impactPath).trim();
151
- if (content) {
152
- const parsed = NdJson.parse(content);
153
- for (let i = 0; i < parsed.length; i++) {
154
- const row = parsed[i];
155
- const schemaErrs = validateImpactEventSchema(row);
156
- for (const e of schemaErrs) {
157
- errors.push({
158
- ...e,
159
- file: impactPath,
160
- line: i + 1,
161
- });
162
- }
163
- const eventResult = z
164
- .object({
165
- entity: z.any(),
166
- basis: z.any(),
167
- serviceScopes: z.any().optional(),
168
- })
169
- .safeParse(row);
170
- if (eventResult.success) {
171
- const relErrs = validateImpactEventRelationships(row, evidenceIds, impactPath, i + 1, ctx);
172
- errors.push(...relErrs);
173
- }
174
- }
175
- }
176
- }
177
- catch {
178
- // ignore missing
179
- }
180
- return errors;
181
- }
182
- /**
183
- * Validates a single issue at the given path (e.g. "issue/2025/03/2025-03-11-x").
184
- * Pass ctx for relationship validation (serviceIds, stationIds, evidenceIds).
185
- */
186
- export function validateIssue(store, relBase, ctx) {
187
- return validateIssueAtPath(store, relBase, ctx);
188
- }
189
- export function validateIssues(store, ctx) {
190
- const errors = [];
191
- try {
192
- const years = store.listDir(DIR_ISSUE);
193
- for (const year of years) {
194
- if (!/^\d{4}$/.test(year))
195
- continue;
196
- const monthsPath = join(DIR_ISSUE, year);
197
- const months = store.listDir(monthsPath);
198
- for (const month of months) {
199
- if (!/^\d{2}$/.test(month))
200
- continue;
201
- const issuesPath = join(monthsPath, month);
202
- const issues = store.listDir(issuesPath);
203
- for (const issueId of issues) {
204
- const relBase = join(DIR_ISSUE, year, month, issueId);
205
- errors.push(...validateIssueAtPath(store, relBase, ctx));
206
- }
207
- }
208
- }
209
- }
210
- catch (err) {
211
- if (err.code !== 'ENOENT') {
212
- errors.push({
213
- file: DIR_ISSUE,
214
- message: err instanceof Error ? err.message : String(err),
215
- });
216
- }
217
- }
218
- return errors;
219
- }
220
- //# sourceMappingURL=issue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"issue.js","sourceRoot":"/","sources":["validators/issue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,UAAU,mBAAmB,CAAC,IAAa;IAC/C,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACrC,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,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IAAI,MAAM,EAAE,CAAC;oBAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;oBACtD,MAAM,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aAC1D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { join } from 'node:path';\nimport { NdJson } from 'json-nd';\nimport z from 'zod';\nimport { EvidenceSchema } from '../schema/issue/evidence.js';\nimport type { ImpactEvent } from '../schema/issue/impactEvent.js';\nimport { ImpactEventSchema } from '../schema/issue/impactEvent.js';\nimport { IssueSchema } from '../schema/issue/issue.js';\nimport { DIR_ISSUE } from '../constants.js';\nimport type { IStore } from '../repo/common/store.js';\nimport type { ValidationContext, ValidationError } from './types.js';\nimport { loadJson } from './utils.js';\n\nexport function validateIssueSchema(data: unknown): ValidationError[] {\n const result = IssueSchema.safeParse(data);\n if (result.success) return [];\n return result.error.issues.map((i) => ({\n file: '',\n message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,\n }));\n}\n\nexport function validateEvidenceSchema(data: unknown): ValidationError[] {\n const result = EvidenceSchema.safeParse(data);\n if (result.success) return [];\n return result.error.issues.map((i) => ({\n file: '',\n message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,\n }));\n}\n\nexport function validateImpactEventSchema(data: unknown): ValidationError[] {\n const result = ImpactEventSchema.safeParse(data);\n if (result.success) return [];\n return result.error.issues.map((i) => ({\n file: '',\n message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,\n }));\n}\n\nexport function validateImpactEventRelationships(\n event: ImpactEvent,\n evidenceIds: Set<string>,\n file: string,\n lineNum: number,\n ctx?: ValidationContext,\n): ValidationError[] {\n const errors: ValidationError[] = [];\n\n if (!evidenceIds.has(event.basis.evidenceId)) {\n errors.push({\n file,\n line: lineNum,\n message: `basis.evidenceId \"${event.basis.evidenceId}\" does not exist in evidence`,\n });\n }\n\n if (!ctx) return errors;\n\n if (event.entity.type === 'service') {\n if (!ctx.serviceIds.has(event.entity.serviceId)) {\n errors.push({\n file,\n line: lineNum,\n message: `entity.serviceId \"${event.entity.serviceId}\" does not exist`,\n });\n }\n } else {\n if (!ctx.stationIds.has(event.entity.stationId)) {\n errors.push({\n file,\n line: lineNum,\n message: `entity.stationId \"${event.entity.stationId}\" does not exist`,\n });\n }\n }\n\n if ('serviceScopes' in event && event.serviceScopes) {\n for (const scope of event.serviceScopes) {\n if (scope.type === 'service.segment') {\n if (!ctx.stationIds.has(scope.fromStationId)) {\n errors.push({\n file,\n line: lineNum,\n message: `serviceScopes[].fromStationId \"${scope.fromStationId}\" does not exist`,\n });\n }\n if (!ctx.stationIds.has(scope.toStationId)) {\n errors.push({\n file,\n line: lineNum,\n message: `serviceScopes[].toStationId \"${scope.toStationId}\" does not exist`,\n });\n }\n } else if (scope.type === 'service.point') {\n if (!ctx.stationIds.has(scope.stationId)) {\n errors.push({\n file,\n line: lineNum,\n message: `serviceScopes[].stationId \"${scope.stationId}\" does not exist`,\n });\n }\n }\n }\n }\n\n return errors;\n}\n\nfunction validateIssueAtPath(\n store: IStore,\n relBase: string,\n ctx?: ValidationContext,\n): ValidationError[] {\n const errors: ValidationError[] = [];\n const issueJsonPath = join(relBase, 'issue.json');\n\n if (!store.exists(issueJsonPath)) {\n errors.push({\n file: issueJsonPath,\n message: 'Issue not found',\n });\n return errors;\n }\n\n const issueRaw = loadJson<unknown>(store, issueJsonPath);\n if (issueRaw) {\n const schemaErrs = validateIssueSchema(issueRaw);\n for (const e of schemaErrs) {\n errors.push({ ...e, file: e.file || issueJsonPath });\n }\n } else {\n errors.push({\n file: issueJsonPath,\n message: 'Failed to parse JSON',\n });\n }\n\n const evidenceIdsFromCtx = ctx?.evidenceIdsByIssue.get(relBase);\n const evidenceIds =\n evidenceIdsFromCtx !== undefined ? evidenceIdsFromCtx : new Set<string>();\n const needToBuildEvidenceIds = evidenceIdsFromCtx === undefined;\n\n const evidencePath = join(relBase, 'evidence.ndjson');\n try {\n const content = store.readText(evidencePath).trim();\n if (content) {\n const parsed = NdJson.parse(content);\n for (let i = 0; i < parsed.length; i++) {\n const row = parsed[i];\n const schemaErrs = validateEvidenceSchema(row);\n for (const e of schemaErrs) {\n errors.push({\n ...e,\n file: evidencePath,\n line: i + 1,\n });\n }\n if (needToBuildEvidenceIds) {\n const idParsed = z.object({ id: z.string() }).safeParse(row);\n if (idParsed.success) evidenceIds.add(idParsed.data.id);\n }\n }\n }\n } catch {\n // ignore missing\n }\n\n const impactPath = join(relBase, 'impact.ndjson');\n try {\n const content = store.readText(impactPath).trim();\n if (content) {\n const parsed = NdJson.parse(content);\n for (let i = 0; i < parsed.length; i++) {\n const row = parsed[i];\n const schemaErrs = validateImpactEventSchema(row);\n for (const e of schemaErrs) {\n errors.push({\n ...e,\n file: impactPath,\n line: i + 1,\n });\n }\n const eventResult = z\n .object({\n entity: z.any(),\n basis: z.any(),\n serviceScopes: z.any().optional(),\n })\n .safeParse(row);\n if (eventResult.success) {\n const relErrs = validateImpactEventRelationships(\n row as ImpactEvent,\n evidenceIds,\n impactPath,\n i + 1,\n ctx,\n );\n errors.push(...relErrs);\n }\n }\n }\n } catch {\n // ignore missing\n }\n\n return errors;\n}\n\n/**\n * Validates a single issue at the given path (e.g. \"issue/2025/03/2025-03-11-x\").\n * Pass ctx for relationship validation (serviceIds, stationIds, evidenceIds).\n */\nexport function validateIssue(\n store: IStore,\n relBase: string,\n ctx?: ValidationContext,\n): ValidationError[] {\n return validateIssueAtPath(store, relBase, ctx);\n}\n\nexport function validateIssues(\n store: IStore,\n ctx?: ValidationContext,\n): ValidationError[] {\n const errors: ValidationError[] = [];\n try {\n const years = store.listDir(DIR_ISSUE);\n for (const year of years) {\n if (!/^\\d{4}$/.test(year)) continue;\n const monthsPath = join(DIR_ISSUE, year);\n const months = store.listDir(monthsPath);\n for (const month of months) {\n if (!/^\\d{2}$/.test(month)) continue;\n const issuesPath = join(monthsPath, month);\n const issues = store.listDir(issuesPath);\n for (const issueId of issues) {\n const relBase = join(DIR_ISSUE, year, month, issueId);\n errors.push(...validateIssueAtPath(store, relBase, ctx));\n }\n }\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {\n errors.push({\n file: DIR_ISSUE,\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n return errors;\n}\n"]}
@@ -1,7 +0,0 @@
1
- import type { IStore } from '../repo/common/store.js';
2
- import type { ValidationError } from './types.js';
3
- export declare function validateLandmarkSchema(data: unknown): {
4
- file: string;
5
- message: string;
6
- }[];
7
- export declare function validateLandmarks(store: IStore): ValidationError[];
@@ -1,43 +0,0 @@
1
- import { join } from 'node:path';
2
- import { DIR_LANDMARK } from '../constants.js';
3
- import { LandmarkSchema } from '../schema/Landmark.js';
4
- import { loadJson } from './utils.js';
5
- export function validateLandmarkSchema(data) {
6
- const result = LandmarkSchema.safeParse(data);
7
- if (result.success)
8
- return [];
9
- return result.error.issues.map((i) => ({
10
- file: '',
11
- message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,
12
- }));
13
- }
14
- export function validateLandmarks(store) {
15
- const errors = [];
16
- try {
17
- const files = store.listDir(DIR_LANDMARK);
18
- for (const file of files) {
19
- if (!file.endsWith('.json'))
20
- continue;
21
- const relPath = join(DIR_LANDMARK, file);
22
- const raw = loadJson(store, relPath);
23
- if (raw === null) {
24
- errors.push({ file: relPath, message: 'Failed to parse JSON' });
25
- continue;
26
- }
27
- const schemaErrs = validateLandmarkSchema(raw);
28
- for (const e of schemaErrs) {
29
- errors.push({ ...e, file: e.file || relPath });
30
- }
31
- }
32
- }
33
- catch (err) {
34
- if (err.code !== 'ENOENT') {
35
- errors.push({
36
- file: DIR_LANDMARK,
37
- message: err instanceof Error ? err.message : String(err),
38
- });
39
- }
40
- }
41
- return errors;
42
- }
43
- //# sourceMappingURL=landmark.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"landmark.js","sourceRoot":"/","sources":["validators/landmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,UAAU,sBAAsB,CACpC,IAAa;IAEb,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACrC,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,EAAE;KAC1E,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,SAAS;YACtC,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YACzC,MAAM,GAAG,GAAG,QAAQ,CAAU,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBACjB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC,CAAC;gBAChE,SAAS;YACX,CAAC;YACD,MAAM,UAAU,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;YAC/C,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;gBAC3B,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aAC1D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { join } from 'node:path';\nimport { DIR_LANDMARK } from '../constants.js';\nimport type { IStore } from '../repo/common/store.js';\nimport { LandmarkSchema } from '../schema/Landmark.js';\nimport type { ValidationError } from './types.js';\nimport { loadJson } from './utils.js';\n\nexport function validateLandmarkSchema(\n data: unknown,\n): { file: string; message: string }[] {\n const result = LandmarkSchema.safeParse(data);\n if (result.success) return [];\n return result.error.issues.map((i) => ({\n file: '',\n message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,\n }));\n}\n\nexport function validateLandmarks(store: IStore): ValidationError[] {\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_LANDMARK);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_LANDMARK, file);\n const raw = loadJson<unknown>(store, relPath);\n if (raw === null) {\n errors.push({ file: relPath, message: 'Failed to parse JSON' });\n continue;\n }\n const schemaErrs = validateLandmarkSchema(raw);\n for (const e of schemaErrs) {\n errors.push({ ...e, file: e.file || relPath });\n }\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {\n errors.push({\n file: DIR_LANDMARK,\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n return errors;\n}\n"]}
@@ -1,8 +0,0 @@
1
- import type z from 'zod';
2
- import { LineSchema } from '../schema/Line.js';
3
- import type { IStore } from '../repo/common/store.js';
4
- import type { ValidationContext, ValidationError } from './types.js';
5
- export declare function validateLineSchema(data: unknown): ValidationError[];
6
- export declare function validateLineRelationships(data: z.infer<typeof LineSchema>, ctx: ValidationContext, file: string): ValidationError[];
7
- export declare function validateLines(store: IStore): ValidationError[];
8
- export declare function validateLinesRelationships(store: IStore, ctx?: ValidationContext): ValidationError[];
@@ -1,87 +0,0 @@
1
- import { join } from 'node:path';
2
- import { LineSchema } from '../schema/Line.js';
3
- import { DIR_LINE } from '../constants.js';
4
- import { loadJson } from './utils.js';
5
- export function validateLineSchema(data) {
6
- const result = LineSchema.safeParse(data);
7
- if (result.success)
8
- return [];
9
- return result.error.issues.map((i) => ({
10
- file: '',
11
- message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,
12
- }));
13
- }
14
- export function validateLineRelationships(data, ctx, file) {
15
- const errors = [];
16
- for (const op of data.operators) {
17
- if (!ctx.operatorIds.has(op.operatorId)) {
18
- errors.push({
19
- file,
20
- message: `operators[].operatorId "${op.operatorId}" does not exist`,
21
- });
22
- }
23
- }
24
- for (const serviceId of data.serviceIds) {
25
- if (!ctx.serviceIds.has(serviceId)) {
26
- errors.push({
27
- file,
28
- message: `serviceIds: "${serviceId}" does not exist`,
29
- });
30
- }
31
- }
32
- return errors;
33
- }
34
- export function validateLines(store) {
35
- const errors = [];
36
- try {
37
- const files = store.listDir(DIR_LINE);
38
- for (const file of files) {
39
- if (!file.endsWith('.json'))
40
- continue;
41
- const relPath = join(DIR_LINE, file);
42
- const raw = loadJson(store, relPath);
43
- if (raw === null) {
44
- errors.push({ file: relPath, message: 'Failed to parse JSON' });
45
- continue;
46
- }
47
- const schemaErrs = validateLineSchema(raw);
48
- for (const e of schemaErrs) {
49
- errors.push({ ...e, file: e.file || relPath });
50
- }
51
- }
52
- }
53
- catch (err) {
54
- if (err.code !== 'ENOENT') {
55
- errors.push({
56
- file: DIR_LINE,
57
- message: err instanceof Error ? err.message : String(err),
58
- });
59
- }
60
- }
61
- return errors;
62
- }
63
- export function validateLinesRelationships(store, ctx) {
64
- if (!ctx)
65
- return [];
66
- const errors = [];
67
- try {
68
- const files = store.listDir(DIR_LINE);
69
- for (const file of files) {
70
- if (!file.endsWith('.json'))
71
- continue;
72
- const relPath = join(DIR_LINE, file);
73
- const raw = loadJson(store, relPath);
74
- if (raw === null)
75
- continue;
76
- const parsed = LineSchema.safeParse(raw);
77
- if (parsed.success) {
78
- errors.push(...validateLineRelationships(parsed.data, ctx, relPath));
79
- }
80
- }
81
- }
82
- catch {
83
- // ignore
84
- }
85
- return errors;
86
- }
87
- //# sourceMappingURL=line.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"line.js","sourceRoot":"/","sources":["validators/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CA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AAM,UAAU,0BAA0B,CACxC,KAAa,EACb,GAAuB;IAEvB,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,SAAS;YACtC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACrC,MAAM,GAAG,GAAG,QAAQ,CAAU,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,GAAG,KAAK,IAAI;gBAAE,SAAS;YAC3B,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACzC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { join } from 'node:path';\nimport type z from 'zod';\nimport { LineSchema } from '../schema/Line.js';\nimport { DIR_LINE } from '../constants.js';\nimport type { IStore } from '../repo/common/store.js';\nimport type { ValidationContext, ValidationError } from './types.js';\nimport { loadJson } from './utils.js';\n\nexport function validateLineSchema(data: unknown): ValidationError[] {\n const result = LineSchema.safeParse(data);\n if (result.success) return [];\n return result.error.issues.map((i) => ({\n file: '',\n message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,\n }));\n}\n\nexport function validateLineRelationships(\n data: z.infer<typeof LineSchema>,\n ctx: ValidationContext,\n file: string,\n): ValidationError[] {\n const errors: ValidationError[] = [];\n\n for (const op of data.operators) {\n if (!ctx.operatorIds.has(op.operatorId)) {\n errors.push({\n file,\n message: `operators[].operatorId \"${op.operatorId}\" does not exist`,\n });\n }\n }\n\n for (const serviceId of data.serviceIds) {\n if (!ctx.serviceIds.has(serviceId)) {\n errors.push({\n file,\n message: `serviceIds: \"${serviceId}\" does not exist`,\n });\n }\n }\n\n return errors;\n}\n\nexport function validateLines(store: IStore): ValidationError[] {\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_LINE);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_LINE, file);\n const raw = loadJson<unknown>(store, relPath);\n if (raw === null) {\n errors.push({ file: relPath, message: 'Failed to parse JSON' });\n continue;\n }\n const schemaErrs = validateLineSchema(raw);\n for (const e of schemaErrs) {\n errors.push({ ...e, file: e.file || relPath });\n }\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {\n errors.push({\n file: DIR_LINE,\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n return errors;\n}\n\nexport function validateLinesRelationships(\n store: IStore,\n ctx?: ValidationContext,\n): ValidationError[] {\n if (!ctx) return [];\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_LINE);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_LINE, file);\n const raw = loadJson<unknown>(store, relPath);\n if (raw === null) continue;\n const parsed = LineSchema.safeParse(raw);\n if (parsed.success) {\n errors.push(...validateLineRelationships(parsed.data, ctx, relPath));\n }\n }\n } catch {\n // ignore\n }\n return errors;\n}\n"]}
@@ -1,7 +0,0 @@
1
- import type { IStore } from '../repo/common/store.js';
2
- import type { ValidationError } from './types.js';
3
- export declare function validateOperatorSchema(data: unknown): {
4
- file: string;
5
- message: string;
6
- }[];
7
- export declare function validateOperators(store: IStore): ValidationError[];
@@ -1,43 +0,0 @@
1
- import { join } from 'node:path';
2
- import { OperatorSchema } from '../schema/Operator.js';
3
- import { DIR_OPERATOR } from '../constants.js';
4
- import { loadJson } from './utils.js';
5
- export function validateOperatorSchema(data) {
6
- const result = OperatorSchema.safeParse(data);
7
- if (result.success)
8
- return [];
9
- return result.error.issues.map((i) => ({
10
- file: '',
11
- message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,
12
- }));
13
- }
14
- export function validateOperators(store) {
15
- const errors = [];
16
- try {
17
- const files = store.listDir(DIR_OPERATOR);
18
- for (const file of files) {
19
- if (!file.endsWith('.json'))
20
- continue;
21
- const relPath = join(DIR_OPERATOR, file);
22
- const raw = loadJson(store, relPath);
23
- if (raw === null) {
24
- errors.push({ file: relPath, message: 'Failed to parse JSON' });
25
- continue;
26
- }
27
- const schemaErrs = validateOperatorSchema(raw);
28
- for (const e of schemaErrs) {
29
- errors.push({ ...e, file: e.file || relPath });
30
- }
31
- }
32
- }
33
- catch (err) {
34
- if (err.code !== 'ENOENT') {
35
- errors.push({
36
- file: DIR_OPERATOR,
37
- message: err instanceof Error ? err.message : String(err),
38
- });
39
- }
40
- }
41
- return errors;
42
- }
43
- //# sourceMappingURL=operator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operator.js","sourceRoot":"/","sources":["validators/operator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,UAAU,sBAAsB,CACpC,IAAa;IAEb,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EA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;gBAClB,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aAC1D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { join } from 'node:path';\nimport { OperatorSchema } from '../schema/Operator.js';\nimport { DIR_OPERATOR } from '../constants.js';\nimport type { IStore } from '../repo/common/store.js';\nimport type { ValidationError } from './types.js';\nimport { loadJson } from './utils.js';\n\nexport function validateOperatorSchema(\n data: unknown,\n): { file: string; message: string }[] {\n const result = OperatorSchema.safeParse(data);\n if (result.success) return [];\n return result.error.issues.map((i) => ({\n file: '',\n message: `${i.path.length > 0 ? i.path.join('.') : 'root'}: ${i.message}`,\n }));\n}\n\nexport function validateOperators(store: IStore): ValidationError[] {\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_OPERATOR);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_OPERATOR, file);\n const raw = loadJson<unknown>(store, relPath);\n if (raw === null) {\n errors.push({ file: relPath, message: 'Failed to parse JSON' });\n continue;\n }\n const schemaErrs = validateOperatorSchema(raw);\n for (const e of schemaErrs) {\n errors.push({ ...e, file: e.file || relPath });\n }\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {\n errors.push({\n file: DIR_OPERATOR,\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n return errors;\n}\n"]}
@@ -1,8 +0,0 @@
1
- import type z from 'zod';
2
- import type { IStore } from '../repo/common/store.js';
3
- import { ServiceSchema } from '../schema/Service.js';
4
- import type { ValidationContext, ValidationError } from './types.js';
5
- export declare function validateServiceSchema(data: unknown): ValidationError[];
6
- export declare function validateServiceRelationships(data: z.infer<typeof ServiceSchema>, ctx: ValidationContext, file: string): ValidationError[];
7
- export declare function validateServices(store: IStore): ValidationError[];
8
- export declare function validateServicesRelationships(store: IStore, ctx?: ValidationContext): ValidationError[];