@mrtdown/core 2.0.0-alpha.5 → 2.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -7
- package/dist/index.js.map +1 -1
- package/dist/schema/Landmark.js.map +1 -1
- package/dist/schema/Line.d.ts +6 -0
- package/dist/schema/Line.js +2 -1
- package/dist/schema/Line.js.map +1 -1
- package/dist/schema/Operator.js.map +1 -1
- package/dist/schema/Service.js.map +1 -1
- package/dist/schema/Station.js.map +1 -1
- package/dist/schema/Town.js.map +1 -1
- package/dist/schema/common.js.map +1 -1
- package/dist/schema/issue/bundle.js.map +1 -1
- package/dist/schema/issue/cause.js.map +1 -1
- package/dist/schema/issue/claim.js.map +1 -1
- package/dist/schema/issue/entity.js.map +1 -1
- package/dist/schema/issue/evidence.js.map +1 -1
- package/dist/schema/issue/facilityEffect.js.map +1 -1
- package/dist/schema/issue/id.js.map +1 -1
- package/dist/schema/issue/impactEvent.js.map +1 -1
- package/dist/schema/issue/issue.js.map +1 -1
- package/dist/schema/issue/issueType.js.map +1 -1
- package/dist/schema/issue/period.js.map +1 -1
- package/dist/schema/issue/serviceEffect.js.map +1 -1
- package/dist/schema/issue/serviceScope.js.map +1 -1
- package/package.json +19 -44
- package/README.md +0 -107
- package/dist/cli/commands/create.d.ts +0 -30
- package/dist/cli/commands/create.js +0 -189
- package/dist/cli/commands/create.js.map +0 -1
- package/dist/cli/commands/list.d.ts +0 -6
- package/dist/cli/commands/list.js +0 -106
- package/dist/cli/commands/list.js.map +0 -1
- package/dist/cli/commands/show.d.ts +0 -6
- package/dist/cli/commands/show.js +0 -156
- package/dist/cli/commands/show.js.map +0 -1
- package/dist/cli/commands/validate.d.ts +0 -6
- package/dist/cli/commands/validate.js +0 -19
- package/dist/cli/commands/validate.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -162
- package/dist/cli/index.js.map +0 -1
- package/dist/constants.d.ts +0 -10
- package/dist/constants.js +0 -11
- package/dist/constants.js.map +0 -1
- package/dist/helpers/calculateDurationWithinServiceHours.d.ts +0 -2
- package/dist/helpers/calculateDurationWithinServiceHours.js +0 -13
- package/dist/helpers/calculateDurationWithinServiceHours.js.map +0 -1
- package/dist/helpers/calculateDurationWithinServiceHours.test.d.ts +0 -1
- package/dist/helpers/calculateDurationWithinServiceHours.test.js +0 -83
- package/dist/helpers/calculateDurationWithinServiceHours.test.js.map +0 -1
- package/dist/helpers/computeImpactFromEvidenceClaims.d.ts +0 -21
- package/dist/helpers/computeImpactFromEvidenceClaims.js +0 -293
- package/dist/helpers/computeImpactFromEvidenceClaims.js.map +0 -1
- package/dist/helpers/computeImpactFromEvidenceClaims.test.d.ts +0 -1
- package/dist/helpers/computeImpactFromEvidenceClaims.test.js +0 -544
- package/dist/helpers/computeImpactFromEvidenceClaims.test.js.map +0 -1
- package/dist/helpers/computeStartOfDaysWithinInterval.d.ts +0 -2
- package/dist/helpers/computeStartOfDaysWithinInterval.js +0 -15
- package/dist/helpers/computeStartOfDaysWithinInterval.js.map +0 -1
- package/dist/helpers/computeStartOfDaysWithinInterval.test.d.ts +0 -1
- package/dist/helpers/computeStartOfDaysWithinInterval.test.js +0 -126
- package/dist/helpers/computeStartOfDaysWithinInterval.test.js.map +0 -1
- package/dist/helpers/estimateOpenAICost.d.ts +0 -40
- package/dist/helpers/estimateOpenAICost.js +0 -55
- package/dist/helpers/estimateOpenAICost.js.map +0 -1
- package/dist/helpers/keyForAffectedEntity.d.ts +0 -7
- package/dist/helpers/keyForAffectedEntity.js +0 -14
- package/dist/helpers/keyForAffectedEntity.js.map +0 -1
- package/dist/helpers/normalizeRecurringPeriod.d.ts +0 -7
- package/dist/helpers/normalizeRecurringPeriod.js +0 -118
- package/dist/helpers/normalizeRecurringPeriod.js.map +0 -1
- package/dist/helpers/normalizeRecurringPeriod.test.d.ts +0 -1
- package/dist/helpers/normalizeRecurringPeriod.test.js +0 -93
- package/dist/helpers/normalizeRecurringPeriod.test.js.map +0 -1
- package/dist/helpers/resolvePeriods.d.ts +0 -224
- package/dist/helpers/resolvePeriods.js +0 -207
- package/dist/helpers/resolvePeriods.js.map +0 -1
- package/dist/helpers/resolvePeriods.test.d.ts +0 -1
- package/dist/helpers/resolvePeriods.test.js +0 -239
- package/dist/helpers/resolvePeriods.test.js.map +0 -1
- package/dist/helpers/splitIntervalByServiceHours.d.ts +0 -2
- package/dist/helpers/splitIntervalByServiceHours.js +0 -30
- package/dist/helpers/splitIntervalByServiceHours.js.map +0 -1
- package/dist/helpers/splitIntervalByServiceHours.test.d.ts +0 -1
- package/dist/helpers/splitIntervalByServiceHours.test.js +0 -152
- package/dist/helpers/splitIntervalByServiceHours.test.js.map +0 -1
- package/dist/helpers/sumIntervalDuration.d.ts +0 -2
- package/dist/helpers/sumIntervalDuration.js +0 -9
- package/dist/helpers/sumIntervalDuration.js.map +0 -1
- package/dist/llm/client.d.ts +0 -2
- package/dist/llm/client.js +0 -5
- package/dist/llm/client.js.map +0 -1
- package/dist/llm/common/MemoryStore.d.ts +0 -21
- package/dist/llm/common/MemoryStore.js +0 -100
- package/dist/llm/common/MemoryStore.js.map +0 -1
- package/dist/llm/common/MemoryStore.test.d.ts +0 -1
- package/dist/llm/common/MemoryStore.test.js +0 -225
- package/dist/llm/common/MemoryStore.test.js.map +0 -1
- package/dist/llm/common/formatCurrentState.d.ts +0 -10
- package/dist/llm/common/formatCurrentState.js +0 -342
- package/dist/llm/common/formatCurrentState.js.map +0 -1
- package/dist/llm/common/tool.d.ts +0 -32
- package/dist/llm/common/tool.js +0 -6
- package/dist/llm/common/tool.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.d.ts +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.js +0 -433
- package/dist/llm/functions/extractClaimsFromNewEvidence/eval.test.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/index.d.ts +0 -18
- package/dist/llm/functions/extractClaimsFromNewEvidence/index.js +0 -153
- package/dist/llm/functions/extractClaimsFromNewEvidence/index.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.d.ts +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.js +0 -168
- package/dist/llm/functions/extractClaimsFromNewEvidence/prompt.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.d.ts +0 -19
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.js +0 -65
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindLinesTool.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.d.ts +0 -21
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.js +0 -115
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindServicesTool.js.map +0 -1
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.d.ts +0 -24
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.js +0 -110
- package/dist/llm/functions/extractClaimsFromNewEvidence/tools/FindStationsTool.js.map +0 -1
- package/dist/llm/functions/generateIssueTitleAndSlug/index.d.ts +0 -14
- package/dist/llm/functions/generateIssueTitleAndSlug/index.js +0 -38
- package/dist/llm/functions/generateIssueTitleAndSlug/index.js.map +0 -1
- package/dist/llm/functions/generateIssueTitleAndSlug/prompt.d.ts +0 -1
- package/dist/llm/functions/generateIssueTitleAndSlug/prompt.js +0 -23
- package/dist/llm/functions/generateIssueTitleAndSlug/prompt.js.map +0 -1
- package/dist/llm/functions/translate/index.d.ts +0 -1
- package/dist/llm/functions/translate/index.js +0 -59
- package/dist/llm/functions/translate/index.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/eval.test.d.ts +0 -1
- package/dist/llm/functions/triageNewEvidence/eval.test.js +0 -139
- package/dist/llm/functions/triageNewEvidence/eval.test.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/index.d.ts +0 -37
- package/dist/llm/functions/triageNewEvidence/index.js +0 -121
- package/dist/llm/functions/triageNewEvidence/index.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/prompt.d.ts +0 -1
- package/dist/llm/functions/triageNewEvidence/prompt.js +0 -60
- package/dist/llm/functions/triageNewEvidence/prompt.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.d.ts +0 -19
- package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.js +0 -65
- package/dist/llm/functions/triageNewEvidence/tools/FindIssuesTool.js.map +0 -1
- package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.d.ts +0 -19
- package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.js +0 -37
- package/dist/llm/functions/triageNewEvidence/tools/GetIssueTool.js.map +0 -1
- package/dist/repo/MRTDownRepository.d.ts +0 -23
- package/dist/repo/MRTDownRepository.js +0 -28
- package/dist/repo/MRTDownRepository.js.map +0 -1
- package/dist/repo/common/FileStore.d.ts +0 -12
- package/dist/repo/common/FileStore.js +0 -27
- package/dist/repo/common/FileStore.js.map +0 -1
- package/dist/repo/common/StandardRepository.d.ts +0 -32
- package/dist/repo/common/StandardRepository.js +0 -58
- package/dist/repo/common/StandardRepository.js.map +0 -1
- package/dist/repo/common/store.d.ts +0 -29
- package/dist/repo/common/store.js +0 -2
- package/dist/repo/common/store.js.map +0 -1
- package/dist/repo/issue/IssueRepository.d.ts +0 -36
- package/dist/repo/issue/IssueRepository.js +0 -177
- package/dist/repo/issue/IssueRepository.js.map +0 -1
- package/dist/repo/issue/helpers/deriveCurrentState.d.ts +0 -51
- package/dist/repo/issue/helpers/deriveCurrentState.js +0 -113
- package/dist/repo/issue/helpers/deriveCurrentState.js.map +0 -1
- package/dist/repo/issue/helpers/deriveCurrentState.test.d.ts +0 -1
- package/dist/repo/issue/helpers/deriveCurrentState.test.js +0 -477
- package/dist/repo/issue/helpers/deriveCurrentState.test.js.map +0 -1
- package/dist/repo/landmark/LandmarkRepository.d.ts +0 -7
- package/dist/repo/landmark/LandmarkRepository.js +0 -12
- package/dist/repo/landmark/LandmarkRepository.js.map +0 -1
- package/dist/repo/line/LineRepository.d.ts +0 -13
- package/dist/repo/line/LineRepository.js +0 -32
- package/dist/repo/line/LineRepository.js.map +0 -1
- package/dist/repo/operator/OperatorRepository.d.ts +0 -7
- package/dist/repo/operator/OperatorRepository.js +0 -12
- package/dist/repo/operator/OperatorRepository.js.map +0 -1
- package/dist/repo/service/ServiceRepository.d.ts +0 -19
- package/dist/repo/service/ServiceRepository.js +0 -39
- package/dist/repo/service/ServiceRepository.js.map +0 -1
- package/dist/repo/station/StationRepository.d.ts +0 -13
- package/dist/repo/station/StationRepository.js +0 -30
- package/dist/repo/station/StationRepository.js.map +0 -1
- package/dist/repo/town/TownRepository.d.ts +0 -7
- package/dist/repo/town/TownRepository.js +0 -12
- package/dist/repo/town/TownRepository.js.map +0 -1
- package/dist/scripts/ingestViaWebhook.d.ts +0 -1
- package/dist/scripts/ingestViaWebhook.js +0 -9
- package/dist/scripts/ingestViaWebhook.js.map +0 -1
- package/dist/util/assert.d.ts +0 -1
- package/dist/util/assert.js +0 -6
- package/dist/util/assert.js.map +0 -1
- package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.d.ts +0 -7
- package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.js +0 -24
- package/dist/util/ingestContent/helpers/getSlugDateTimeFromClaims.js.map +0 -1
- package/dist/util/ingestContent/index.d.ts +0 -12
- package/dist/util/ingestContent/index.js +0 -171
- package/dist/util/ingestContent/index.js.map +0 -1
- package/dist/util/ingestContent/types.d.ts +0 -32
- package/dist/util/ingestContent/types.js +0 -2
- package/dist/util/ingestContent/types.js.map +0 -1
- package/dist/validators/buildContext.d.ts +0 -7
- package/dist/validators/buildContext.js +0 -164
- package/dist/validators/buildContext.js.map +0 -1
- package/dist/validators/index.d.ts +0 -17
- package/dist/validators/index.js +0 -58
- package/dist/validators/index.js.map +0 -1
- package/dist/validators/issue.d.ts +0 -13
- package/dist/validators/issue.js +0 -220
- package/dist/validators/issue.js.map +0 -1
- package/dist/validators/landmark.d.ts +0 -7
- package/dist/validators/landmark.js +0 -43
- package/dist/validators/landmark.js.map +0 -1
- package/dist/validators/line.d.ts +0 -8
- package/dist/validators/line.js +0 -87
- package/dist/validators/line.js.map +0 -1
- package/dist/validators/operator.d.ts +0 -7
- package/dist/validators/operator.js +0 -43
- package/dist/validators/operator.js.map +0 -1
- package/dist/validators/service.d.ts +0 -8
- package/dist/validators/service.js +0 -87
- package/dist/validators/service.js.map +0 -1
- package/dist/validators/station.d.ts +0 -8
- package/dist/validators/station.js +0 -93
- package/dist/validators/station.js.map +0 -1
- package/dist/validators/town.d.ts +0 -7
- package/dist/validators/town.js +0 -43
- package/dist/validators/town.js.map +0 -1
- package/dist/validators/types.d.ts +0 -19
- package/dist/validators/types.js +0 -2
- package/dist/validators/types.js.map +0 -1
- package/dist/validators/utils.d.ts +0 -2
- package/dist/validators/utils.js +0 -9
- package/dist/validators/utils.js.map +0 -1
- package/dist/write/MRTDownWriter.d.ts +0 -27
- package/dist/write/MRTDownWriter.js +0 -27
- package/dist/write/MRTDownWriter.js.map +0 -1
- package/dist/write/common/FileWriteStore.d.ts +0 -13
- package/dist/write/common/FileWriteStore.js +0 -31
- package/dist/write/common/FileWriteStore.js.map +0 -1
- package/dist/write/common/StandardWriter.d.ts +0 -14
- package/dist/write/common/StandardWriter.js +0 -17
- package/dist/write/common/StandardWriter.js.map +0 -1
- package/dist/write/common/store.d.ts +0 -32
- package/dist/write/common/store.js +0 -2
- package/dist/write/common/store.js.map +0 -1
- package/dist/write/id/IdGenerator.d.ts +0 -18
- package/dist/write/id/IdGenerator.js +0 -23
- package/dist/write/id/IdGenerator.js.map +0 -1
- package/dist/write/issue/IssueWriter.d.ts +0 -12
- package/dist/write/issue/IssueWriter.js +0 -33
- package/dist/write/issue/IssueWriter.js.map +0 -1
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { DIR_SERVICE } from '../constants.js';
|
|
3
|
-
import { ServiceSchema } from '../schema/Service.js';
|
|
4
|
-
import { loadJson } from './utils.js';
|
|
5
|
-
export function validateServiceSchema(data) {
|
|
6
|
-
const result = ServiceSchema.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 validateServiceRelationships(data, ctx, file) {
|
|
15
|
-
const errors = [];
|
|
16
|
-
if (!ctx.lineIds.has(data.lineId)) {
|
|
17
|
-
errors.push({
|
|
18
|
-
file,
|
|
19
|
-
message: `lineId "${data.lineId}" does not exist`,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
for (const rev of data.revisions) {
|
|
23
|
-
for (const st of rev.path.stations) {
|
|
24
|
-
if (!ctx.stationIds.has(st.stationId)) {
|
|
25
|
-
errors.push({
|
|
26
|
-
file,
|
|
27
|
-
message: `revisions[].path.stations[].stationId "${st.stationId}" does not exist`,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return errors;
|
|
33
|
-
}
|
|
34
|
-
export function validateServices(store) {
|
|
35
|
-
const errors = [];
|
|
36
|
-
try {
|
|
37
|
-
const files = store.listDir(DIR_SERVICE);
|
|
38
|
-
for (const file of files) {
|
|
39
|
-
if (!file.endsWith('.json'))
|
|
40
|
-
continue;
|
|
41
|
-
const relPath = join(DIR_SERVICE, 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 = validateServiceSchema(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_SERVICE,
|
|
57
|
-
message: err instanceof Error ? err.message : String(err),
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return errors;
|
|
62
|
-
}
|
|
63
|
-
export function validateServicesRelationships(store, ctx) {
|
|
64
|
-
if (!ctx)
|
|
65
|
-
return [];
|
|
66
|
-
const errors = [];
|
|
67
|
-
try {
|
|
68
|
-
const files = store.listDir(DIR_SERVICE);
|
|
69
|
-
for (const file of files) {
|
|
70
|
-
if (!file.endsWith('.json'))
|
|
71
|
-
continue;
|
|
72
|
-
const relPath = join(DIR_SERVICE, file);
|
|
73
|
-
const raw = loadJson(store, relPath);
|
|
74
|
-
if (raw === null)
|
|
75
|
-
continue;
|
|
76
|
-
const parsed = ServiceSchema.safeParse(raw);
|
|
77
|
-
if (parsed.success) {
|
|
78
|
-
errors.push(...validateServiceRelationships(parsed.data, ctx, relPath));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
// ignore
|
|
84
|
-
}
|
|
85
|
-
return errors;
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"/","sources":["validators/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,UAA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CAAC;IACpB,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACzC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,SAAS;YACtC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YACxC,MAAM,GAAG,GAAG,QAAQ,CAAU,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,GAAG,KAAK,IAAI;gBAAE,SAAS;YAC3B,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,CAAC,IAAI,CAAC,GAAG,4BAA4B,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1E,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 { DIR_SERVICE } from '../constants.js';\nimport type { IStore } from '../repo/common/store.js';\nimport { ServiceSchema } from '../schema/Service.js';\nimport type { ValidationContext, ValidationError } from './types.js';\nimport { loadJson } from './utils.js';\n\nexport function validateServiceSchema(data: unknown): ValidationError[] {\n const result = ServiceSchema.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 validateServiceRelationships(\n data: z.infer<typeof ServiceSchema>,\n ctx: ValidationContext,\n file: string,\n): ValidationError[] {\n const errors: ValidationError[] = [];\n\n if (!ctx.lineIds.has(data.lineId)) {\n errors.push({\n file,\n message: `lineId \"${data.lineId}\" does not exist`,\n });\n }\n\n for (const rev of data.revisions) {\n for (const st of rev.path.stations) {\n if (!ctx.stationIds.has(st.stationId)) {\n errors.push({\n file,\n message: `revisions[].path.stations[].stationId \"${st.stationId}\" does not exist`,\n });\n }\n }\n }\n\n return errors;\n}\n\nexport function validateServices(store: IStore): ValidationError[] {\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_SERVICE);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_SERVICE, 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 = validateServiceSchema(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_SERVICE,\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n return errors;\n}\n\nexport function validateServicesRelationships(\n store: IStore,\n ctx?: ValidationContext,\n): ValidationError[] {\n if (!ctx) return [];\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_SERVICE);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_SERVICE, file);\n const raw = loadJson<unknown>(store, relPath);\n if (raw === null) continue;\n const parsed = ServiceSchema.safeParse(raw);\n if (parsed.success) {\n errors.push(...validateServiceRelationships(parsed.data, ctx, relPath));\n }\n }\n } catch {\n // ignore\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 { StationSchema } from '../schema/Station.js';
|
|
4
|
-
import type { ValidationContext, ValidationError } from './types.js';
|
|
5
|
-
export declare function validateStationSchema(data: unknown): ValidationError[];
|
|
6
|
-
export declare function validateStationRelationships(data: z.infer<typeof StationSchema>, ctx: ValidationContext, file: string): ValidationError[];
|
|
7
|
-
export declare function validateStations(store: IStore): ValidationError[];
|
|
8
|
-
export declare function validateStationsRelationships(store: IStore, ctx?: ValidationContext): ValidationError[];
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { DIR_STATION } from '../constants.js';
|
|
3
|
-
import { StationSchema } from '../schema/Station.js';
|
|
4
|
-
import { loadJson } from './utils.js';
|
|
5
|
-
export function validateStationSchema(data) {
|
|
6
|
-
const result = StationSchema.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 validateStationRelationships(data, ctx, file) {
|
|
15
|
-
const errors = [];
|
|
16
|
-
if (!ctx.townIds.has(data.townId)) {
|
|
17
|
-
errors.push({
|
|
18
|
-
file,
|
|
19
|
-
message: `townId "${data.townId}" does not exist`,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
for (const landmarkId of data.landmarkIds) {
|
|
23
|
-
if (!ctx.landmarkIds.has(landmarkId)) {
|
|
24
|
-
errors.push({
|
|
25
|
-
file,
|
|
26
|
-
message: `landmarkIds: "${landmarkId}" does not exist`,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
for (const sc of data.stationCodes) {
|
|
31
|
-
if (!ctx.lineIds.has(sc.lineId)) {
|
|
32
|
-
errors.push({
|
|
33
|
-
file,
|
|
34
|
-
message: `stationCodes[].lineId "${sc.lineId}" does not exist`,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return errors;
|
|
39
|
-
}
|
|
40
|
-
export function validateStations(store) {
|
|
41
|
-
const errors = [];
|
|
42
|
-
try {
|
|
43
|
-
const files = store.listDir(DIR_STATION);
|
|
44
|
-
for (const file of files) {
|
|
45
|
-
if (!file.endsWith('.json'))
|
|
46
|
-
continue;
|
|
47
|
-
const relPath = join(DIR_STATION, file);
|
|
48
|
-
const raw = loadJson(store, relPath);
|
|
49
|
-
if (raw === null) {
|
|
50
|
-
errors.push({ file: relPath, message: 'Failed to parse JSON' });
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const schemaErrs = validateStationSchema(raw);
|
|
54
|
-
for (const e of schemaErrs) {
|
|
55
|
-
errors.push({ ...e, file: e.file || relPath });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
if (err.code !== 'ENOENT') {
|
|
61
|
-
errors.push({
|
|
62
|
-
file: DIR_STATION,
|
|
63
|
-
message: err instanceof Error ? err.message : String(err),
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return errors;
|
|
68
|
-
}
|
|
69
|
-
export function validateStationsRelationships(store, ctx) {
|
|
70
|
-
if (!ctx)
|
|
71
|
-
return [];
|
|
72
|
-
const errors = [];
|
|
73
|
-
try {
|
|
74
|
-
const files = store.listDir(DIR_STATION);
|
|
75
|
-
for (const file of files) {
|
|
76
|
-
if (!file.endsWith('.json'))
|
|
77
|
-
continue;
|
|
78
|
-
const relPath = join(DIR_STATION, file);
|
|
79
|
-
const raw = loadJson(store, relPath);
|
|
80
|
-
if (raw === null)
|
|
81
|
-
continue;
|
|
82
|
-
const parsed = StationSchema.safeParse(raw);
|
|
83
|
-
if (parsed.success) {
|
|
84
|
-
errors.push(...validateStationRelationships(parsed.data, ctx, relPath));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
// ignore
|
|
90
|
-
}
|
|
91
|
-
return errors;
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=station.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"station.js","sourceRoot":"/","sources":["validators/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nimport type { IStore } from '../repo/common/store.js';\nimport { StationSchema } from '../schema/Station.js';\nimport type { ValidationContext, ValidationError } from './types.js';\nimport { loadJson } from './utils.js';\n\nexport function validateStationSchema(data: unknown): ValidationError[] {\n const result = StationSchema.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 validateStationRelationships(\n data: z.infer<typeof StationSchema>,\n ctx: ValidationContext,\n file: string,\n): ValidationError[] {\n const errors: ValidationError[] = [];\n\n if (!ctx.townIds.has(data.townId)) {\n errors.push({\n file,\n message: `townId \"${data.townId}\" does not exist`,\n });\n }\n\n for (const landmarkId of data.landmarkIds) {\n if (!ctx.landmarkIds.has(landmarkId)) {\n errors.push({\n file,\n message: `landmarkIds: \"${landmarkId}\" does not exist`,\n });\n }\n }\n\n for (const sc of data.stationCodes) {\n if (!ctx.lineIds.has(sc.lineId)) {\n errors.push({\n file,\n message: `stationCodes[].lineId \"${sc.lineId}\" does not exist`,\n });\n }\n }\n\n return errors;\n}\n\nexport function validateStations(store: IStore): ValidationError[] {\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_STATION);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_STATION, 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 = validateStationSchema(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_STATION,\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n return errors;\n}\n\nexport function validateStationsRelationships(\n store: IStore,\n ctx?: ValidationContext,\n): ValidationError[] {\n if (!ctx) return [];\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_STATION);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_STATION, file);\n const raw = loadJson<unknown>(store, relPath);\n if (raw === null) continue;\n const parsed = StationSchema.safeParse(raw);\n if (parsed.success) {\n errors.push(...validateStationRelationships(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 validateTownSchema(data: unknown): {
|
|
4
|
-
file: string;
|
|
5
|
-
message: string;
|
|
6
|
-
}[];
|
|
7
|
-
export declare function validateTowns(store: IStore): ValidationError[];
|
package/dist/validators/town.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { TownSchema } from '../schema/Town.js';
|
|
3
|
-
import { DIR_TOWN } from '../constants.js';
|
|
4
|
-
import { loadJson } from './utils.js';
|
|
5
|
-
export function validateTownSchema(data) {
|
|
6
|
-
const result = TownSchema.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 validateTowns(store) {
|
|
15
|
-
const errors = [];
|
|
16
|
-
try {
|
|
17
|
-
const files = store.listDir(DIR_TOWN);
|
|
18
|
-
for (const file of files) {
|
|
19
|
-
if (!file.endsWith('.json'))
|
|
20
|
-
continue;
|
|
21
|
-
const relPath = join(DIR_TOWN, 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 = validateTownSchema(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_TOWN,
|
|
37
|
-
message: err instanceof Error ? err.message : String(err),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return errors;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=town.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"town.js","sourceRoot":"/","sources":["validators/town.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,UAAU,kBAAkB,CAChC,IAAa;IAEb,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1C,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,aAAa,CAAC,KAAa;IACzC,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,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,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAC3C,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,QAAQ;gBACd,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 type { IStore } from '../repo/common/store.js';\nimport { TownSchema } from '../schema/Town.js';\nimport { DIR_TOWN } from '../constants.js';\nimport type { ValidationError } from './types.js';\nimport { loadJson } from './utils.js';\n\nexport function validateTownSchema(\n data: unknown,\n): { file: string; message: string }[] {\n const result = TownSchema.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 validateTowns(store: IStore): ValidationError[] {\n const errors: ValidationError[] = [];\n try {\n const files = store.listDir(DIR_TOWN);\n for (const file of files) {\n if (!file.endsWith('.json')) continue;\n const relPath = join(DIR_TOWN, 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 = validateTownSchema(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_TOWN,\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n return errors;\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface ValidationError {
|
|
2
|
-
file: string;
|
|
3
|
-
line?: number;
|
|
4
|
-
message: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Set of entity IDs loaded from data. Used for relationship validation.
|
|
8
|
-
* When omitted, validators run schema validation only (no relationship checks).
|
|
9
|
-
*/
|
|
10
|
-
export interface ValidationContext {
|
|
11
|
-
townIds: Set<string>;
|
|
12
|
-
landmarkIds: Set<string>;
|
|
13
|
-
operatorIds: Set<string>;
|
|
14
|
-
lineIds: Set<string>;
|
|
15
|
-
serviceIds: Set<string>;
|
|
16
|
-
stationIds: Set<string>;
|
|
17
|
-
/** evidence IDs per issue path (e.g. "issue/2025/03/2025-03-11-x") */
|
|
18
|
-
evidenceIdsByIssue: Map<string, Set<string>>;
|
|
19
|
-
}
|
package/dist/validators/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["validators/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface ValidationError {\n file: string;\n line?: number;\n message: string;\n}\n\n/**\n * Set of entity IDs loaded from data. Used for relationship validation.\n * When omitted, validators run schema validation only (no relationship checks).\n */\nexport interface ValidationContext {\n townIds: Set<string>;\n landmarkIds: Set<string>;\n operatorIds: Set<string>;\n lineIds: Set<string>;\n serviceIds: Set<string>;\n stationIds: Set<string>;\n /** evidence IDs per issue path (e.g. \"issue/2025/03/2025-03-11-x\") */\n evidenceIdsByIssue: Map<string, Set<string>>;\n}\n"]}
|
package/dist/validators/utils.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"/","sources":["validators/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAI,KAAa,EAAE,IAAY;IACrD,IAAI,CAAC;QACH,OAAO,KAAK,CAAC,QAAQ,CAAI,IAAI,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { IStore } from '../repo/common/store.js';\n\nexport function loadJson<T>(store: IStore, path: string): T | null {\n try {\n return store.readJson<T>(path);\n } catch {\n return null;\n }\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Landmark } from '../schema/Landmark.js';
|
|
2
|
-
import type { Line } from '../schema/Line.js';
|
|
3
|
-
import type { Operator } from '../schema/Operator.js';
|
|
4
|
-
import type { Service } from '../schema/Service.js';
|
|
5
|
-
import type { Station } from '../schema/Station.js';
|
|
6
|
-
import type { Town } from '../schema/Town.js';
|
|
7
|
-
import { StandardWriter } from './common/StandardWriter.js';
|
|
8
|
-
import type { IWriteStore } from './common/store.js';
|
|
9
|
-
import { IssueWriter } from './issue/IssueWriter.js';
|
|
10
|
-
type MRTDownWriterParams = {
|
|
11
|
-
store: IWriteStore;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* A writer for the MRTDown data.
|
|
15
|
-
*/
|
|
16
|
-
export declare class MRTDownWriter {
|
|
17
|
-
private readonly store;
|
|
18
|
-
readonly issues: IssueWriter;
|
|
19
|
-
readonly stations: StandardWriter<Station>;
|
|
20
|
-
readonly lines: StandardWriter<Line>;
|
|
21
|
-
readonly operators: StandardWriter<Operator>;
|
|
22
|
-
readonly services: StandardWriter<Service>;
|
|
23
|
-
readonly landmarks: StandardWriter<Landmark>;
|
|
24
|
-
readonly towns: StandardWriter<Town>;
|
|
25
|
-
constructor(params: MRTDownWriterParams);
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DIR_LANDMARK, DIR_LINE, DIR_OPERATOR, DIR_SERVICE, DIR_STATION, DIR_TOWN, } from '../constants.js';
|
|
2
|
-
import { StandardWriter } from './common/StandardWriter.js';
|
|
3
|
-
import { IssueWriter } from './issue/IssueWriter.js';
|
|
4
|
-
/**
|
|
5
|
-
* A writer for the MRTDown data.
|
|
6
|
-
*/
|
|
7
|
-
export class MRTDownWriter {
|
|
8
|
-
store;
|
|
9
|
-
issues;
|
|
10
|
-
stations;
|
|
11
|
-
lines;
|
|
12
|
-
operators;
|
|
13
|
-
services;
|
|
14
|
-
landmarks;
|
|
15
|
-
towns;
|
|
16
|
-
constructor(params) {
|
|
17
|
-
this.store = params.store;
|
|
18
|
-
this.issues = new IssueWriter(this.store);
|
|
19
|
-
this.stations = new StandardWriter(this.store, DIR_STATION);
|
|
20
|
-
this.lines = new StandardWriter(this.store, DIR_LINE);
|
|
21
|
-
this.operators = new StandardWriter(this.store, DIR_OPERATOR);
|
|
22
|
-
this.services = new StandardWriter(this.store, DIR_SERVICE);
|
|
23
|
-
this.landmarks = new StandardWriter(this.store, DIR_LANDMARK);
|
|
24
|
-
this.towns = new StandardWriter(this.store, DIR_TOWN);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=MRTDownWriter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MRTDownWriter.js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DIR_SERVICE,\n DIR_STATION,\n DIR_TOWN,\n} from '../constants.js';\nimport type { Landmark } from '../schema/Landmark.js';\nimport type { Line } from '../schema/Line.js';\nimport type { Operator } from '../schema/Operator.js';\nimport type { Service } from '../schema/Service.js';\nimport type { Station } from '../schema/Station.js';\nimport type { Town } from '../schema/Town.js';\nimport { StandardWriter } from './common/StandardWriter.js';\nimport type { IWriteStore } from './common/store.js';\nimport { IssueWriter } from './issue/IssueWriter.js';\n\ntype MRTDownWriterParams = {\n store: IWriteStore;\n};\n\n/**\n * A writer for the MRTDown data.\n */\nexport class MRTDownWriter {\n private readonly store: IWriteStore;\n readonly issues: IssueWriter;\n readonly stations: StandardWriter<Station>;\n readonly lines: StandardWriter<Line>;\n readonly operators: StandardWriter<Operator>;\n readonly services: StandardWriter<Service>;\n readonly landmarks: StandardWriter<Landmark>;\n readonly towns: StandardWriter<Town>;\n\n constructor(params: MRTDownWriterParams) {\n this.store = params.store;\n this.issues = new IssueWriter(this.store);\n this.stations = new StandardWriter(this.store, DIR_STATION);\n this.lines = new StandardWriter(this.store, DIR_LINE);\n this.operators = new StandardWriter(this.store, DIR_OPERATOR);\n this.services = new StandardWriter(this.store, DIR_SERVICE);\n this.landmarks = new StandardWriter(this.store, DIR_LANDMARK);\n this.towns = new StandardWriter(this.store, DIR_TOWN);\n }\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { IWriteStore } from './store.js';
|
|
2
|
-
/**
|
|
3
|
-
* A write store that writes to the file system.
|
|
4
|
-
*/
|
|
5
|
-
export declare class FileWriteStore implements IWriteStore {
|
|
6
|
-
private readonly rootDir;
|
|
7
|
-
constructor(rootDir: string);
|
|
8
|
-
writeText(path: string, text: string): void;
|
|
9
|
-
writeJson(path: string, json: unknown): void;
|
|
10
|
-
appendText(path: string, text: string): void;
|
|
11
|
-
ensureDir(path: string): void;
|
|
12
|
-
delete(path: string): void;
|
|
13
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { appendFileSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
/**
|
|
4
|
-
* A write store that writes to the file system.
|
|
5
|
-
*/
|
|
6
|
-
export class FileWriteStore {
|
|
7
|
-
rootDir;
|
|
8
|
-
constructor(rootDir) {
|
|
9
|
-
this.rootDir = rootDir;
|
|
10
|
-
}
|
|
11
|
-
writeText(path, text) {
|
|
12
|
-
const fullPath = join(this.rootDir, path);
|
|
13
|
-
writeFileSync(fullPath, text);
|
|
14
|
-
}
|
|
15
|
-
writeJson(path, json) {
|
|
16
|
-
this.writeText(path, JSON.stringify(json, null, 2));
|
|
17
|
-
}
|
|
18
|
-
appendText(path, text) {
|
|
19
|
-
const fullPath = join(this.rootDir, path);
|
|
20
|
-
appendFileSync(fullPath, text);
|
|
21
|
-
}
|
|
22
|
-
ensureDir(path) {
|
|
23
|
-
const fullPath = join(this.rootDir, path);
|
|
24
|
-
mkdirSync(fullPath, { recursive: true });
|
|
25
|
-
}
|
|
26
|
-
delete(path) {
|
|
27
|
-
const fullPath = join(this.rootDir, path);
|
|
28
|
-
rmSync(fullPath);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=FileWriteStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileWriteStore.js","sourceRoot":"/","sources":["write/common/FileWriteStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;GAEG;AACH,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEhD,SAAS,CAAC,IAAY,EAAE,IAAY;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,IAAa;QACnC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,UAAU,CAAC,IAAY,EAAE,IAAY;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,SAAS,CAAC,IAAY;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { appendFileSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { IWriteStore } from './store.js';\n\n/**\n * A write store that writes to the file system.\n */\nexport class FileWriteStore implements IWriteStore {\n constructor(private readonly rootDir: string) {}\n\n writeText(path: string, text: string): void {\n const fullPath = join(this.rootDir, path);\n writeFileSync(fullPath, text);\n }\n\n writeJson(path: string, json: unknown): void {\n this.writeText(path, JSON.stringify(json, null, 2));\n }\n\n appendText(path: string, text: string): void {\n const fullPath = join(this.rootDir, path);\n appendFileSync(fullPath, text);\n }\n\n ensureDir(path: string): void {\n const fullPath = join(this.rootDir, path);\n mkdirSync(fullPath, { recursive: true });\n }\n\n delete(path: string): void {\n const fullPath = join(this.rootDir, path);\n rmSync(fullPath);\n }\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IWriteStore } from './store.js';
|
|
2
|
-
type Item = {
|
|
3
|
-
id: string;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* A standard writer for items represented by single JSON files that are stored in a directory.
|
|
7
|
-
*/
|
|
8
|
-
export declare class StandardWriter<T extends Item> {
|
|
9
|
-
private readonly store;
|
|
10
|
-
private readonly dirPath;
|
|
11
|
-
constructor(store: IWriteStore, dirPath: string);
|
|
12
|
-
create(item: T): void;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
/**
|
|
3
|
-
* A standard writer for items represented by single JSON files that are stored in a directory.
|
|
4
|
-
*/
|
|
5
|
-
export class StandardWriter {
|
|
6
|
-
store;
|
|
7
|
-
dirPath;
|
|
8
|
-
constructor(store, dirPath) {
|
|
9
|
-
this.store = store;
|
|
10
|
-
this.dirPath = dirPath;
|
|
11
|
-
}
|
|
12
|
-
create(item) {
|
|
13
|
-
this.store.ensureDir(this.dirPath);
|
|
14
|
-
this.store.writeJson(join(this.dirPath, `${item.id}.json`), item);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=StandardWriter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StandardWriter.js","sourceRoot":"/","sources":["write/common/StandardWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC;;GAEG;AACH,MAAM,OAAO,cAAc;IAEN;IACA;IAFnB,YACmB,KAAkB,EAClB,OAAe;QADf,UAAK,GAAL,KAAK,CAAa;QAClB,YAAO,GAAP,OAAO,CAAQ;IAC/B,CAAC;IAEJ,MAAM,CAAC,IAAO;QACZ,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;CACF","sourcesContent":["import { join } from 'node:path';\nimport type { IWriteStore } from './store.js';\n\ntype Item = {\n id: string;\n};\n\n/**\n * A standard writer for items represented by single JSON files that are stored in a directory.\n */\nexport class StandardWriter<T extends Item> {\n constructor(\n private readonly store: IWriteStore,\n private readonly dirPath: string,\n ) {}\n\n create(item: T): void {\n this.store.ensureDir(this.dirPath);\n this.store.writeJson(join(this.dirPath, `${item.id}.json`), item);\n }\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface IWriteStore {
|
|
2
|
-
/**
|
|
3
|
-
* Write a text file.
|
|
4
|
-
* @param path
|
|
5
|
-
* @param text
|
|
6
|
-
*/
|
|
7
|
-
writeText(path: string, text: string): void;
|
|
8
|
-
/**
|
|
9
|
-
* Write a JSON file.
|
|
10
|
-
* @param path
|
|
11
|
-
* @param json
|
|
12
|
-
*/
|
|
13
|
-
writeJson(path: string, json: unknown): void;
|
|
14
|
-
/**
|
|
15
|
-
* Append text to a file.
|
|
16
|
-
* @param path
|
|
17
|
-
* @param text
|
|
18
|
-
*/
|
|
19
|
-
appendText(path: string, text: string): void;
|
|
20
|
-
/**
|
|
21
|
-
* Ensure a directory exists.
|
|
22
|
-
* @param path
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
ensureDir(path: string): void;
|
|
26
|
-
/**
|
|
27
|
-
* Delete a file or directory.
|
|
28
|
-
* @param path
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
delete?(path: string): void;
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"/","sources":["write/common/store.ts"],"names":[],"mappings":"","sourcesContent":["export interface IWriteStore {\n /**\n * Write a text file.\n * @param path\n * @param text\n */\n writeText(path: string, text: string): void;\n /**\n * Write a JSON file.\n * @param path\n * @param json\n */\n writeJson(path: string, json: unknown): void;\n /**\n * Append text to a file.\n * @param path\n * @param text\n */\n appendText(path: string, text: string): void;\n /**\n * Ensure a directory exists.\n * @param path\n * @returns\n */\n ensureDir(path: string): void;\n /**\n * Delete a file or directory.\n * @param path\n * @returns\n */\n delete?(path: string): void;\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { DateTime } from 'luxon';
|
|
2
|
-
/**
|
|
3
|
-
* A utility for generating unique IDs.
|
|
4
|
-
*/
|
|
5
|
-
export declare const IdGenerator: {
|
|
6
|
-
/**
|
|
7
|
-
* Generate a unique ID for an evidence.
|
|
8
|
-
* @param ts - The timestamp of the evidence.
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
evidenceId(ts?: DateTime): string;
|
|
12
|
-
/**
|
|
13
|
-
* Generate a unique ID for an impact event.
|
|
14
|
-
* @param ts - The timestamp of the impact event.
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
impactEventId(ts?: DateTime): string;
|
|
18
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ulid } from 'ulid';
|
|
2
|
-
/**
|
|
3
|
-
* A utility for generating unique IDs.
|
|
4
|
-
*/
|
|
5
|
-
export const IdGenerator = {
|
|
6
|
-
/**
|
|
7
|
-
* Generate a unique ID for an evidence.
|
|
8
|
-
* @param ts - The timestamp of the evidence.
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
evidenceId(ts) {
|
|
12
|
-
return `ev_${ulid(ts?.toMillis?.() ?? undefined)}`;
|
|
13
|
-
},
|
|
14
|
-
/**
|
|
15
|
-
* Generate a unique ID for an impact event.
|
|
16
|
-
* @param ts - The timestamp of the impact event.
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
impactEventId(ts) {
|
|
20
|
-
return `ie_${ulid(ts?.toMillis?.() ?? undefined)}`;
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=IdGenerator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdGenerator.js","sourceRoot":"/","sources":["write/id/IdGenerator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAa;QACtB,OAAO,MAAM,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,SAAS,CAAC,EAAE,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,EAAa;QACzB,OAAO,MAAM,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,SAAS,CAAC,EAAE,CAAC;IACrD,CAAC;CACF,CAAC","sourcesContent":["import type { DateTime } from 'luxon';\nimport { ulid } from 'ulid';\n\n/**\n * A utility for generating unique IDs.\n */\nexport const IdGenerator = {\n /**\n * Generate a unique ID for an evidence.\n * @param ts - The timestamp of the evidence.\n * @returns\n */\n evidenceId(ts?: DateTime) {\n return `ev_${ulid(ts?.toMillis?.() ?? undefined)}`;\n },\n\n /**\n * Generate a unique ID for an impact event.\n * @param ts - The timestamp of the impact event.\n * @returns\n */\n impactEventId(ts?: DateTime) {\n return `ie_${ulid(ts?.toMillis?.() ?? undefined)}`;\n },\n};\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Evidence } from '../../schema/issue/evidence.js';
|
|
2
|
-
import type { ImpactEvent } from '../../schema/issue/impactEvent.js';
|
|
3
|
-
import type { Issue } from '../../schema/issue/issue.js';
|
|
4
|
-
import type { IWriteStore } from '../common/store.js';
|
|
5
|
-
export declare class IssueWriter {
|
|
6
|
-
private readonly store;
|
|
7
|
-
constructor(store: IWriteStore);
|
|
8
|
-
create(issue: Issue): void;
|
|
9
|
-
appendEvidence(issueId: string, evidence: Evidence): void;
|
|
10
|
-
appendImpact(issueId: string, impact: ImpactEvent): void;
|
|
11
|
-
private getIssueDir;
|
|
12
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { NdJson } from 'json-nd';
|
|
3
|
-
import { DIR_ISSUE, FILE_ISSUE, FILE_ISSUE_EVIDENCE, FILE_ISSUE_IMPACT, } from '../../constants.js';
|
|
4
|
-
export class IssueWriter {
|
|
5
|
-
store;
|
|
6
|
-
constructor(store) {
|
|
7
|
-
this.store = store;
|
|
8
|
-
}
|
|
9
|
-
create(issue) {
|
|
10
|
-
const issueDir = this.getIssueDir(issue.id);
|
|
11
|
-
this.store.ensureDir(issueDir);
|
|
12
|
-
this.store.writeJson(join(issueDir, FILE_ISSUE), issue);
|
|
13
|
-
this.store.writeText(join(issueDir, FILE_ISSUE_EVIDENCE), '');
|
|
14
|
-
this.store.writeText(join(issueDir, FILE_ISSUE_IMPACT), '');
|
|
15
|
-
}
|
|
16
|
-
appendEvidence(issueId, evidence) {
|
|
17
|
-
this.store.ensureDir(this.getIssueDir(issueId));
|
|
18
|
-
this.store.appendText(join(this.getIssueDir(issueId), FILE_ISSUE_EVIDENCE), `${NdJson.stringify([evidence])}\n`);
|
|
19
|
-
}
|
|
20
|
-
appendImpact(issueId, impact) {
|
|
21
|
-
this.store.ensureDir(this.getIssueDir(issueId));
|
|
22
|
-
this.store.appendText(join(this.getIssueDir(issueId), FILE_ISSUE_IMPACT), `${NdJson.stringify([impact])}\n`);
|
|
23
|
-
}
|
|
24
|
-
getIssueDir(issueId) {
|
|
25
|
-
const tsMatch = /^(\d{4})-(\d{2})-(\d{2})/.exec(issueId);
|
|
26
|
-
if (!tsMatch) {
|
|
27
|
-
throw new Error(`Invalid issue ID: ${issueId}`);
|
|
28
|
-
}
|
|
29
|
-
const [_, year, month] = tsMatch;
|
|
30
|
-
return join(DIR_ISSUE, year, month, issueId);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=IssueWriter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IssueWriter.js","sourceRoot":"/","sources":["write/issue/IssueWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIjC,OAAO,EACL,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,OAAO,WAAW;IACL,KAAK,CAAc;IAEpC,YAAY,KAAkB;QAC5B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,KAAY;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,cAAc,CAAC,OAAe,EAAE,QAAkB;QAChD,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,CAAC,UAAU,CACnB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC,EACpD,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CACpC,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,OAAe,EAAE,MAAmB;QAC/C,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,CAAC,UAAU,CACnB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,EAClD,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAClC,CAAC;IACJ,CAAC;IAEO,WAAW,CAAC,OAAe;QACjC,MAAM,OAAO,GAAG,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC;QACjC,OAAO,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import { join } from 'node:path';\nimport { NdJson } from 'json-nd';\nimport type { Evidence } from '../../schema/issue/evidence.js';\nimport type { ImpactEvent } from '../../schema/issue/impactEvent.js';\nimport type { Issue } from '../../schema/issue/issue.js';\nimport {\n DIR_ISSUE,\n FILE_ISSUE,\n FILE_ISSUE_EVIDENCE,\n FILE_ISSUE_IMPACT,\n} from '../../constants.js';\nimport type { IWriteStore } from '../common/store.js';\n\nexport class IssueWriter {\n private readonly store: IWriteStore;\n\n constructor(store: IWriteStore) {\n this.store = store;\n }\n\n create(issue: Issue): void {\n const issueDir = this.getIssueDir(issue.id);\n this.store.ensureDir(issueDir);\n this.store.writeJson(join(issueDir, FILE_ISSUE), issue);\n this.store.writeText(join(issueDir, FILE_ISSUE_EVIDENCE), '');\n this.store.writeText(join(issueDir, FILE_ISSUE_IMPACT), '');\n }\n\n appendEvidence(issueId: string, evidence: Evidence): void {\n this.store.ensureDir(this.getIssueDir(issueId));\n this.store.appendText(\n join(this.getIssueDir(issueId), FILE_ISSUE_EVIDENCE),\n `${NdJson.stringify([evidence])}\\n`,\n );\n }\n\n appendImpact(issueId: string, impact: ImpactEvent): void {\n this.store.ensureDir(this.getIssueDir(issueId));\n this.store.appendText(\n join(this.getIssueDir(issueId), FILE_ISSUE_IMPACT),\n `${NdJson.stringify([impact])}\\n`,\n );\n }\n\n private getIssueDir(issueId: string): string {\n const tsMatch = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(issueId);\n if (!tsMatch) {\n throw new Error(`Invalid issue ID: ${issueId}`);\n }\n const [_, year, month] = tsMatch;\n return join(DIR_ISSUE, year, month, issueId);\n }\n}\n"]}
|