@mrtdown/core 2.0.0-alpha.1 → 2.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/normalizeRecurringPeriod.d.ts +1 -1
- package/dist/helpers/normalizeRecurringPeriod.js +1 -1
- package/dist/helpers/normalizeRecurringPeriod.js.map +1 -1
- package/dist/helpers/normalizeRecurringPeriod.test.js.map +1 -1
- package/dist/helpers/resolvePeriods.d.ts +20 -5
- package/dist/helpers/resolvePeriods.js +15 -1
- package/dist/helpers/resolvePeriods.js.map +1 -1
- package/dist/helpers/resolvePeriods.test.js.map +1 -1
- package/dist/index.d.ts +22 -18
- package/dist/index.js +22 -18
- 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.d.ts +7 -0
- package/dist/schema/Station.js +7 -6
- package/dist/schema/Station.js.map +1 -1
- package/dist/schema/Town.js.map +1 -1
- package/dist/schema/common.d.ts +4 -0
- package/dist/schema/common.js +3 -0
- 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.d.ts +6 -0
- package/dist/schema/issue/entity.js +6 -1
- package/dist/schema/issue/entity.js.map +1 -1
- package/dist/schema/issue/evidence.d.ts +6 -0
- package/dist/schema/issue/evidence.js +9 -4
- package/dist/schema/issue/evidence.js.map +1 -1
- package/dist/schema/issue/facilityEffect.d.ts +5 -0
- package/dist/schema/issue/facilityEffect.js +6 -2
- 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 +2 -4
- 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.d.ts +7 -0
- package/dist/schema/issue/serviceEffect.js +10 -4
- package/dist/schema/issue/serviceEffect.js.map +1 -1
- package/dist/schema/issue/serviceScope.d.ts +6 -0
- package/dist/schema/issue/serviceScope.js +8 -3
- package/dist/schema/issue/serviceScope.js.map +1 -1
- package/dist/util/assert.js.map +1 -1
- package/package.json +21 -61
- package/README.md +0 -107
- 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/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/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/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/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,126 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { computeStartOfDaysWithinInterval } from './computeStartOfDaysWithinInterval.js';
|
|
3
|
-
import { DateTime } from 'luxon';
|
|
4
|
-
describe('computeStartOfDaysWithinInterval', () => {
|
|
5
|
-
test('interval that does not transcend days', () => {
|
|
6
|
-
expect(computeStartOfDaysWithinInterval(DateTime.fromObject({
|
|
7
|
-
day: 1,
|
|
8
|
-
month: 4,
|
|
9
|
-
year: 2025,
|
|
10
|
-
hour: 12,
|
|
11
|
-
minute: 30,
|
|
12
|
-
}), DateTime.fromObject({
|
|
13
|
-
day: 1,
|
|
14
|
-
month: 4,
|
|
15
|
-
year: 2025,
|
|
16
|
-
hour: 15,
|
|
17
|
-
minute: 30,
|
|
18
|
-
}))).toEqual([]);
|
|
19
|
-
});
|
|
20
|
-
test('interval that starts from midnight', () => {
|
|
21
|
-
expect(computeStartOfDaysWithinInterval(DateTime.fromObject({
|
|
22
|
-
day: 1,
|
|
23
|
-
month: 4,
|
|
24
|
-
year: 2025,
|
|
25
|
-
hour: 0,
|
|
26
|
-
minute: 0,
|
|
27
|
-
}), DateTime.fromObject({
|
|
28
|
-
day: 1,
|
|
29
|
-
month: 4,
|
|
30
|
-
year: 2025,
|
|
31
|
-
hour: 15,
|
|
32
|
-
minute: 30,
|
|
33
|
-
}))).toEqual([
|
|
34
|
-
DateTime.fromObject({
|
|
35
|
-
day: 1,
|
|
36
|
-
month: 4,
|
|
37
|
-
year: 2025,
|
|
38
|
-
hour: 0,
|
|
39
|
-
minute: 0,
|
|
40
|
-
}),
|
|
41
|
-
]);
|
|
42
|
-
});
|
|
43
|
-
test('interval that ends at midnight', () => {
|
|
44
|
-
expect(computeStartOfDaysWithinInterval(DateTime.fromObject({
|
|
45
|
-
day: 1,
|
|
46
|
-
month: 4,
|
|
47
|
-
year: 2025,
|
|
48
|
-
hour: 15,
|
|
49
|
-
minute: 30,
|
|
50
|
-
}), DateTime.fromObject({
|
|
51
|
-
day: 2,
|
|
52
|
-
month: 4,
|
|
53
|
-
year: 2025,
|
|
54
|
-
hour: 0,
|
|
55
|
-
minute: 0,
|
|
56
|
-
}))).toEqual([]);
|
|
57
|
-
});
|
|
58
|
-
test('interval that transcends 2 days', () => {
|
|
59
|
-
expect(computeStartOfDaysWithinInterval(DateTime.fromObject({
|
|
60
|
-
day: 1,
|
|
61
|
-
month: 4,
|
|
62
|
-
year: 2025,
|
|
63
|
-
hour: 18,
|
|
64
|
-
minute: 30,
|
|
65
|
-
}), DateTime.fromObject({
|
|
66
|
-
day: 2,
|
|
67
|
-
month: 4,
|
|
68
|
-
year: 2025,
|
|
69
|
-
hour: 18,
|
|
70
|
-
minute: 30,
|
|
71
|
-
}))).toEqual([
|
|
72
|
-
DateTime.fromObject({
|
|
73
|
-
day: 2,
|
|
74
|
-
month: 4,
|
|
75
|
-
year: 2025,
|
|
76
|
-
hour: 0,
|
|
77
|
-
minute: 0,
|
|
78
|
-
}),
|
|
79
|
-
]);
|
|
80
|
-
});
|
|
81
|
-
test('interval that transcends more than 2 days', () => {
|
|
82
|
-
expect(computeStartOfDaysWithinInterval(DateTime.fromObject({
|
|
83
|
-
day: 1,
|
|
84
|
-
month: 4,
|
|
85
|
-
year: 2025,
|
|
86
|
-
hour: 18,
|
|
87
|
-
minute: 30,
|
|
88
|
-
}), DateTime.fromObject({
|
|
89
|
-
day: 5,
|
|
90
|
-
month: 4,
|
|
91
|
-
year: 2025,
|
|
92
|
-
hour: 4,
|
|
93
|
-
minute: 30,
|
|
94
|
-
}))).toEqual([
|
|
95
|
-
DateTime.fromObject({
|
|
96
|
-
day: 2,
|
|
97
|
-
month: 4,
|
|
98
|
-
year: 2025,
|
|
99
|
-
hour: 0,
|
|
100
|
-
minute: 0,
|
|
101
|
-
}),
|
|
102
|
-
DateTime.fromObject({
|
|
103
|
-
day: 3,
|
|
104
|
-
month: 4,
|
|
105
|
-
year: 2025,
|
|
106
|
-
hour: 0,
|
|
107
|
-
minute: 0,
|
|
108
|
-
}),
|
|
109
|
-
DateTime.fromObject({
|
|
110
|
-
day: 4,
|
|
111
|
-
month: 4,
|
|
112
|
-
year: 2025,
|
|
113
|
-
hour: 0,
|
|
114
|
-
minute: 0,
|
|
115
|
-
}),
|
|
116
|
-
DateTime.fromObject({
|
|
117
|
-
day: 5,
|
|
118
|
-
month: 4,
|
|
119
|
-
year: 2025,
|
|
120
|
-
hour: 0,
|
|
121
|
-
minute: 0,
|
|
122
|
-
}),
|
|
123
|
-
]);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
//# sourceMappingURL=computeStartOfDaysWithinInterval.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"computeStartOfDaysWithinInterval.test.js","sourceRoot":"/","sources":["helpers/computeStartOfDaysWithinInterval.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;QACjD,MAAM,CACJ,gCAAgC,CAC9B,QAAQ,CAAC,UAAU,CAAC;YAClB,GAAG,EAAE,CAAC;YACN,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,EAAE;SACX,CAAC,EACF,QAAQ,CAAC,UAAU,CA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C;aACV,CAAC;YACF,QAAQ,CAAC,UAAU,CAAC;gBAClB,GAAG,EAAE,CAAC;gBACN,KAAK,EAAE,CAAC;gBACR,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,CAAC;gBACP,MAAM,EAAE,CAAC;aACV,CAAC;YACF,QAAQ,CAAC,UAAU,CAAC;gBAClB,GAAG,EAAE,CAAC;gBACN,KAAK,EAAE,CAAC;gBACR,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,CAAC;gBACP,MAAM,EAAE,CAAC;aACV,CAAC;YACF,QAAQ,CAAC,UAAU,CAAC;gBAClB,GAAG,EAAE,CAAC;gBACN,KAAK,EAAE,CAAC;gBACR,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,CAAC;gBACP,MAAM,EAAE,CAAC;aACV,CAAC;SACkB,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from 'vitest';\n\nimport { computeStartOfDaysWithinInterval } from './computeStartOfDaysWithinInterval.js';\nimport { DateTime } from 'luxon';\n\ndescribe('computeStartOfDaysWithinInterval', () => {\n test('interval that does not transcend days', () => {\n expect(\n computeStartOfDaysWithinInterval(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 12,\n minute: 30,\n }),\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 15,\n minute: 30,\n }),\n ),\n ).toEqual([] satisfies DateTime[]);\n });\n\n test('interval that starts from midnight', () => {\n expect(\n computeStartOfDaysWithinInterval(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 15,\n minute: 30,\n }),\n ),\n ).toEqual([\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n ] satisfies DateTime[]);\n });\n\n test('interval that ends at midnight', () => {\n expect(\n computeStartOfDaysWithinInterval(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 15,\n minute: 30,\n }),\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n ),\n ).toEqual([] satisfies DateTime[]);\n });\n\n test('interval that transcends 2 days', () => {\n expect(\n computeStartOfDaysWithinInterval(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 30,\n }),\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 30,\n }),\n ),\n ).toEqual([\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n ] satisfies DateTime[]);\n });\n\n test('interval that transcends more than 2 days', () => {\n expect(\n computeStartOfDaysWithinInterval(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 30,\n }),\n DateTime.fromObject({\n day: 5,\n month: 4,\n year: 2025,\n hour: 4,\n minute: 30,\n }),\n ),\n ).toEqual([\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 3,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 4,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 5,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n ] satisfies DateTime[]);\n });\n});\n"]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
type ResponsesUsageLike = {
|
|
2
|
-
input_tokens: number;
|
|
3
|
-
output_tokens: number;
|
|
4
|
-
total_tokens: number;
|
|
5
|
-
input_tokens_details?: {
|
|
6
|
-
cached_tokens?: number;
|
|
7
|
-
} | null;
|
|
8
|
-
} | null | undefined;
|
|
9
|
-
type ChatCompletionUsageLike = {
|
|
10
|
-
prompt_tokens: number;
|
|
11
|
-
completion_tokens: number;
|
|
12
|
-
total_tokens: number;
|
|
13
|
-
prompt_tokens_details?: {
|
|
14
|
-
cached_tokens?: number;
|
|
15
|
-
} | null;
|
|
16
|
-
} | null | undefined;
|
|
17
|
-
export type OpenAITokenUsage = {
|
|
18
|
-
inputTokens: number;
|
|
19
|
-
cachedInputTokens: number;
|
|
20
|
-
outputTokens: number;
|
|
21
|
-
totalTokens: number;
|
|
22
|
-
};
|
|
23
|
-
export type OpenAIModelPricing = {
|
|
24
|
-
inputUsdPer1MTokens: number;
|
|
25
|
-
cachedInputUsdPer1MTokens: number;
|
|
26
|
-
outputUsdPer1MTokens: number;
|
|
27
|
-
};
|
|
28
|
-
export declare const OPENAI_MODEL_PRICING: Record<string, OpenAIModelPricing>;
|
|
29
|
-
export declare function normalizeOpenAIResponsesUsage(usage: ResponsesUsageLike): OpenAITokenUsage | null;
|
|
30
|
-
export declare function normalizeOpenAIChatCompletionUsage(usage: ChatCompletionUsageLike): OpenAITokenUsage | null;
|
|
31
|
-
export declare function estimateOpenAICostFromUsage({ model, usage, pricingByModel, }: {
|
|
32
|
-
model: string;
|
|
33
|
-
usage: OpenAITokenUsage | null;
|
|
34
|
-
pricingByModel?: Record<string, OpenAIModelPricing>;
|
|
35
|
-
}): {
|
|
36
|
-
estimatedCostUsd: number;
|
|
37
|
-
usage: OpenAITokenUsage;
|
|
38
|
-
pricing: OpenAIModelPricing;
|
|
39
|
-
} | null;
|
|
40
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export const OPENAI_MODEL_PRICING = {
|
|
2
|
-
'gpt-5-mini': {
|
|
3
|
-
inputUsdPer1MTokens: 0.25,
|
|
4
|
-
cachedInputUsdPer1MTokens: 0.025,
|
|
5
|
-
outputUsdPer1MTokens: 2,
|
|
6
|
-
},
|
|
7
|
-
'gpt-5-nano': {
|
|
8
|
-
inputUsdPer1MTokens: 0.05,
|
|
9
|
-
cachedInputUsdPer1MTokens: 0.005,
|
|
10
|
-
outputUsdPer1MTokens: 0.4,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export function normalizeOpenAIResponsesUsage(usage) {
|
|
14
|
-
if (usage == null) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
inputTokens: usage.input_tokens,
|
|
19
|
-
cachedInputTokens: usage.input_tokens_details?.cached_tokens ?? 0,
|
|
20
|
-
outputTokens: usage.output_tokens,
|
|
21
|
-
totalTokens: usage.total_tokens,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function normalizeOpenAIChatCompletionUsage(usage) {
|
|
25
|
-
if (usage == null) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
inputTokens: usage.prompt_tokens,
|
|
30
|
-
cachedInputTokens: usage.prompt_tokens_details?.cached_tokens ?? 0,
|
|
31
|
-
outputTokens: usage.completion_tokens,
|
|
32
|
-
totalTokens: usage.total_tokens,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export function estimateOpenAICostFromUsage({ model, usage, pricingByModel = OPENAI_MODEL_PRICING, }) {
|
|
36
|
-
if (usage == null) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const pricing = pricingByModel[model];
|
|
40
|
-
if (pricing == null) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const cachedInputTokens = Math.max(usage.cachedInputTokens, 0);
|
|
44
|
-
const uncachedInputTokens = Math.max(usage.inputTokens - cachedInputTokens, 0);
|
|
45
|
-
const outputTokens = Math.max(usage.outputTokens, 0);
|
|
46
|
-
const estimatedCostUsd = (uncachedInputTokens / 1_000_000) * pricing.inputUsdPer1MTokens +
|
|
47
|
-
(cachedInputTokens / 1_000_000) * pricing.cachedInputUsdPer1MTokens +
|
|
48
|
-
(outputTokens / 1_000_000) * pricing.outputUsdPer1MTokens;
|
|
49
|
-
return {
|
|
50
|
-
estimatedCostUsd,
|
|
51
|
-
usage,
|
|
52
|
-
pricing,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=estimateOpenAICost.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estimateOpenAICost.js","sourceRoot":"/","sources":["helpers/estimateOpenAICost.ts"],"names":[],"mappings":"AA+BA,MAAM,CAAC,MAAM,oBAAoB,GAAuC;IACtE,YAAY,EAAE;QACZ,mBAAmB,EAAE,IAAI;QACzB,yBAAyB,EAAE,KAAK;QAChC,oBAAoB,EAAE,CAAC;KACxB;IACD,YAAY,EAAE;QACZ,mBAAmB,EAAE,IAAI;QACzB,yBAAyB,EAAE,KAAK;QAChC,oBAAoB,EAAE,GAAG;KAC1B;CACF,CAAC;AAEF,MAAM,UAAU,6BAA6B,CAC3C,KAAyB;IAEzB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,YAAY;QAC/B,iBAAiB,EAAE,KAAK,CAAC,oBAAoB,EAAE,aAAa,IAAI,CAAC;QACjE,YAAY,EAAE,KAAK,CAAC,aAAa;QACjC,WAAW,EAAE,KAAK,CAAC,YAAY;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,KAA8B;IAE9B,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,aAAa;QAChC,iBAAiB,EAAE,KAAK,CAAC,qBAAqB,EAAE,aAAa,IAAI,CAAC;QAClE,YAAY,EAAE,KAAK,CAAC,iBAAiB;QACrC,WAAW,EAAE,KAAK,CAAC,YAAY;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,EAC1C,KAAK,EACL,KAAK,EACL,cAAc,GAAG,oBAAoB,GAKtC;IACC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAC/D,MAAM,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAC/E,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAErD,MAAM,gBAAgB,GACpB,CAAC,mBAAmB,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,mBAAmB;QAC/D,CAAC,iBAAiB,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,yBAAyB;QACnE,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAE5D,OAAO;QACL,gBAAgB;QAChB,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["type ResponsesUsageLike = {\n input_tokens: number;\n output_tokens: number;\n total_tokens: number;\n input_tokens_details?: {\n cached_tokens?: number;\n } | null;\n} | null | undefined;\n\ntype ChatCompletionUsageLike = {\n prompt_tokens: number;\n completion_tokens: number;\n total_tokens: number;\n prompt_tokens_details?: {\n cached_tokens?: number;\n } | null;\n} | null | undefined;\n\nexport type OpenAITokenUsage = {\n inputTokens: number;\n cachedInputTokens: number;\n outputTokens: number;\n totalTokens: number;\n};\n\nexport type OpenAIModelPricing = {\n inputUsdPer1MTokens: number;\n cachedInputUsdPer1MTokens: number;\n outputUsdPer1MTokens: number;\n};\n\nexport const OPENAI_MODEL_PRICING: Record<string, OpenAIModelPricing> = {\n 'gpt-5-mini': {\n inputUsdPer1MTokens: 0.25,\n cachedInputUsdPer1MTokens: 0.025,\n outputUsdPer1MTokens: 2,\n },\n 'gpt-5-nano': {\n inputUsdPer1MTokens: 0.05,\n cachedInputUsdPer1MTokens: 0.005,\n outputUsdPer1MTokens: 0.4,\n },\n};\n\nexport function normalizeOpenAIResponsesUsage(\n usage: ResponsesUsageLike,\n): OpenAITokenUsage | null {\n if (usage == null) {\n return null;\n }\n\n return {\n inputTokens: usage.input_tokens,\n cachedInputTokens: usage.input_tokens_details?.cached_tokens ?? 0,\n outputTokens: usage.output_tokens,\n totalTokens: usage.total_tokens,\n };\n}\n\nexport function normalizeOpenAIChatCompletionUsage(\n usage: ChatCompletionUsageLike,\n): OpenAITokenUsage | null {\n if (usage == null) {\n return null;\n }\n\n return {\n inputTokens: usage.prompt_tokens,\n cachedInputTokens: usage.prompt_tokens_details?.cached_tokens ?? 0,\n outputTokens: usage.completion_tokens,\n totalTokens: usage.total_tokens,\n };\n}\n\nexport function estimateOpenAICostFromUsage({\n model,\n usage,\n pricingByModel = OPENAI_MODEL_PRICING,\n}: {\n model: string;\n usage: OpenAITokenUsage | null;\n pricingByModel?: Record<string, OpenAIModelPricing>;\n}) {\n if (usage == null) {\n return null;\n }\n\n const pricing = pricingByModel[model];\n if (pricing == null) {\n return null;\n }\n\n const cachedInputTokens = Math.max(usage.cachedInputTokens, 0);\n const uncachedInputTokens = Math.max(usage.inputTokens - cachedInputTokens, 0);\n const outputTokens = Math.max(usage.outputTokens, 0);\n\n const estimatedCostUsd =\n (uncachedInputTokens / 1_000_000) * pricing.inputUsdPer1MTokens +\n (cachedInputTokens / 1_000_000) * pricing.cachedInputUsdPer1MTokens +\n (outputTokens / 1_000_000) * pricing.outputUsdPer1MTokens;\n\n return {\n estimatedCostUsd,\n usage,\n pricing,\n };\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AffectedEntity } from '#schema/issue/entity.js';
|
|
2
|
-
/**
|
|
3
|
-
* Generate a stable key for an affected entity.
|
|
4
|
-
* @param target - The affected entity.
|
|
5
|
-
* @returns The key.
|
|
6
|
-
*/
|
|
7
|
-
export declare function keyForAffectedEntity(affectedEntity: AffectedEntity): string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate a stable key for an affected entity.
|
|
3
|
-
* @param target - The affected entity.
|
|
4
|
-
* @returns The key.
|
|
5
|
-
*/
|
|
6
|
-
export function keyForAffectedEntity(affectedEntity) {
|
|
7
|
-
switch (affectedEntity.type) {
|
|
8
|
-
case 'service':
|
|
9
|
-
return `service:${affectedEntity.serviceId}`;
|
|
10
|
-
case 'facility':
|
|
11
|
-
return `facility:${affectedEntity.stationId}:${affectedEntity.kind}`;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=keyForAffectedEntity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyForAffectedEntity.js","sourceRoot":"/","sources":["helpers/keyForAffectedEntity.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,cAA8B;IACjE,QAAQ,cAAc,CAAC,IAAI,EAAE,CAAC;QAC5B,KAAK,SAAS;YACZ,OAAO,WAAW,cAAc,CAAC,SAAS,EAAE,CAAC;QAC/C,KAAK,UAAU;YACb,OAAO,YAAY,cAAc,CAAC,SAAS,IAAI,cAAc,CAAC,IAAI,EAAE,CAAC;IACzE,CAAC;AACH,CAAC","sourcesContent":["import type { AffectedEntity } from '#schema/issue/entity.js';\n\n/**\n * Generate a stable key for an affected entity.\n * @param target - The affected entity.\n * @returns The key.\n */\nexport function keyForAffectedEntity(affectedEntity: AffectedEntity): string {\n switch (affectedEntity.type) {\n case 'service':\n return `service:${affectedEntity.serviceId}`;\n case 'facility':\n return `facility:${affectedEntity.stationId}:${affectedEntity.kind}`;\n }\n}\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
|
-
import { computeStartOfDaysWithinInterval } from './computeStartOfDaysWithinInterval.js';
|
|
3
|
-
import { assert } from '../util/assert.js';
|
|
4
|
-
export function splitIntervalByServiceHours(interval) {
|
|
5
|
-
assert(interval.start != null);
|
|
6
|
-
assert(interval.end != null);
|
|
7
|
-
const startOfDaysWithinRange = computeStartOfDaysWithinInterval(interval.start, interval.end);
|
|
8
|
-
const segments = [];
|
|
9
|
-
for (const segment of interval.splitAt(...startOfDaysWithinRange)) {
|
|
10
|
-
const { start, end } = segment;
|
|
11
|
-
assert(start != null);
|
|
12
|
-
assert(end != null);
|
|
13
|
-
const segmentStart = DateTime.max(start, start.set({ hour: 5, minute: 30, second: 0, millisecond: 0 }));
|
|
14
|
-
const segmentEnd = DateTime.max(end, segmentStart);
|
|
15
|
-
const segmentDuration = segmentEnd.diff(segmentStart);
|
|
16
|
-
if (segmentDuration.as('milliseconds') <= 0) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
const segmentUpdated = segment.set({
|
|
20
|
-
start: segmentStart,
|
|
21
|
-
end: segmentEnd,
|
|
22
|
-
});
|
|
23
|
-
if (!segmentUpdated.isValid) {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
segments.push(segmentUpdated);
|
|
27
|
-
}
|
|
28
|
-
return segments;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=splitIntervalByServiceHours.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"splitIntervalByServiceHours.js","sourceRoot":"/","sources":["helpers/splitIntervalByServiceHours.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,UAAU,2BAA2B,CAAC,QAAkB;IAC5D,MAAM,CAAC,QAAQ,CAAC,KAAK,IAA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port { computeStartOfDaysWithinInterval } from './computeStartOfDaysWithinInterval.js';\nimport { assert } from '../util/assert.js';\n\nexport function splitIntervalByServiceHours(interval: Interval): Interval[] {\n assert(interval.start != null);\n assert(interval.end != null);\n\n const startOfDaysWithinRange = computeStartOfDaysWithinInterval(\n interval.start,\n interval.end,\n );\n\n const segments: Interval[] = [];\n\n for (const segment of interval.splitAt(...startOfDaysWithinRange)) {\n const { start, end } = segment;\n assert(start != null);\n assert(end != null);\n\n const segmentStart = DateTime.max(\n start,\n start.set({ hour: 5, minute: 30, second: 0, millisecond: 0 }), // Limit to start of general service hours\n );\n const segmentEnd = DateTime.max(end, segmentStart);\n const segmentDuration = segmentEnd.diff(segmentStart);\n\n if (segmentDuration.as('milliseconds') <= 0) {\n continue;\n }\n\n const segmentUpdated = segment.set({\n start: segmentStart,\n end: segmentEnd,\n });\n\n if (!segmentUpdated.isValid) {\n continue;\n }\n\n segments.push(segmentUpdated);\n }\n\n return segments;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { DateTime, Interval } from 'luxon';
|
|
3
|
-
import { splitIntervalByServiceHours } from './splitIntervalByServiceHours.js';
|
|
4
|
-
describe('splitIntervalByServiceHours', () => {
|
|
5
|
-
test('single day, within service hours', () => {
|
|
6
|
-
expect(splitIntervalByServiceHours(Interval.fromDateTimes(DateTime.fromObject({
|
|
7
|
-
day: 1,
|
|
8
|
-
month: 4,
|
|
9
|
-
year: 2025,
|
|
10
|
-
hour: 8,
|
|
11
|
-
minute: 0,
|
|
12
|
-
}), DateTime.fromObject({
|
|
13
|
-
day: 1,
|
|
14
|
-
month: 4,
|
|
15
|
-
year: 2025,
|
|
16
|
-
hour: 12,
|
|
17
|
-
minute: 30,
|
|
18
|
-
})))).toEqual([
|
|
19
|
-
Interval.fromDateTimes(DateTime.fromObject({
|
|
20
|
-
day: 1,
|
|
21
|
-
month: 4,
|
|
22
|
-
year: 2025,
|
|
23
|
-
hour: 8,
|
|
24
|
-
minute: 0,
|
|
25
|
-
}), DateTime.fromObject({
|
|
26
|
-
day: 1,
|
|
27
|
-
month: 4,
|
|
28
|
-
year: 2025,
|
|
29
|
-
hour: 12,
|
|
30
|
-
minute: 30,
|
|
31
|
-
})),
|
|
32
|
-
]);
|
|
33
|
-
});
|
|
34
|
-
describe('transcends service hour boundaries', () => {
|
|
35
|
-
test('single day, starts before service hours', () => {
|
|
36
|
-
expect(splitIntervalByServiceHours(Interval.fromDateTimes(DateTime.fromObject({
|
|
37
|
-
day: 1,
|
|
38
|
-
month: 4,
|
|
39
|
-
year: 2025,
|
|
40
|
-
hour: 5,
|
|
41
|
-
minute: 0,
|
|
42
|
-
}), DateTime.fromObject({
|
|
43
|
-
day: 1,
|
|
44
|
-
month: 4,
|
|
45
|
-
year: 2025,
|
|
46
|
-
hour: 6,
|
|
47
|
-
minute: 0,
|
|
48
|
-
})))).toEqual([
|
|
49
|
-
Interval.fromDateTimes(DateTime.fromObject({
|
|
50
|
-
day: 1,
|
|
51
|
-
month: 4,
|
|
52
|
-
year: 2025,
|
|
53
|
-
hour: 5,
|
|
54
|
-
minute: 30,
|
|
55
|
-
}), DateTime.fromObject({
|
|
56
|
-
day: 1,
|
|
57
|
-
month: 4,
|
|
58
|
-
year: 2025,
|
|
59
|
-
hour: 6,
|
|
60
|
-
minute: 0,
|
|
61
|
-
})),
|
|
62
|
-
]);
|
|
63
|
-
});
|
|
64
|
-
test('single day, ends after service hours', () => {
|
|
65
|
-
expect(splitIntervalByServiceHours(Interval.fromDateTimes(DateTime.fromObject({
|
|
66
|
-
day: 1,
|
|
67
|
-
month: 4,
|
|
68
|
-
year: 2025,
|
|
69
|
-
hour: 18,
|
|
70
|
-
minute: 0,
|
|
71
|
-
}), DateTime.fromObject({
|
|
72
|
-
day: 2,
|
|
73
|
-
month: 4,
|
|
74
|
-
year: 2025,
|
|
75
|
-
hour: 1,
|
|
76
|
-
minute: 0,
|
|
77
|
-
})))).toEqual([
|
|
78
|
-
Interval.fromDateTimes(DateTime.fromObject({
|
|
79
|
-
day: 1,
|
|
80
|
-
month: 4,
|
|
81
|
-
year: 2025,
|
|
82
|
-
hour: 18,
|
|
83
|
-
minute: 0,
|
|
84
|
-
}), DateTime.fromObject({
|
|
85
|
-
day: 2,
|
|
86
|
-
month: 4,
|
|
87
|
-
year: 2025,
|
|
88
|
-
hour: 0,
|
|
89
|
-
minute: 0,
|
|
90
|
-
})),
|
|
91
|
-
]);
|
|
92
|
-
});
|
|
93
|
-
test('multiple days, transcends multiple service hours/non services hour ranges', () => {
|
|
94
|
-
expect(splitIntervalByServiceHours(Interval.fromDateTimes(DateTime.fromObject({
|
|
95
|
-
day: 1,
|
|
96
|
-
month: 4,
|
|
97
|
-
year: 2025,
|
|
98
|
-
hour: 18,
|
|
99
|
-
minute: 0,
|
|
100
|
-
}), DateTime.fromObject({
|
|
101
|
-
day: 2,
|
|
102
|
-
month: 4,
|
|
103
|
-
year: 2025,
|
|
104
|
-
hour: 18,
|
|
105
|
-
minute: 0,
|
|
106
|
-
})))).toEqual([
|
|
107
|
-
Interval.fromDateTimes(DateTime.fromObject({
|
|
108
|
-
day: 1,
|
|
109
|
-
month: 4,
|
|
110
|
-
year: 2025,
|
|
111
|
-
hour: 18,
|
|
112
|
-
minute: 0,
|
|
113
|
-
}), DateTime.fromObject({
|
|
114
|
-
day: 2,
|
|
115
|
-
month: 4,
|
|
116
|
-
year: 2025,
|
|
117
|
-
hour: 0,
|
|
118
|
-
minute: 0,
|
|
119
|
-
})),
|
|
120
|
-
Interval.fromDateTimes(DateTime.fromObject({
|
|
121
|
-
day: 2,
|
|
122
|
-
month: 4,
|
|
123
|
-
year: 2025,
|
|
124
|
-
hour: 5,
|
|
125
|
-
minute: 30,
|
|
126
|
-
}), DateTime.fromObject({
|
|
127
|
-
day: 2,
|
|
128
|
-
month: 4,
|
|
129
|
-
year: 2025,
|
|
130
|
-
hour: 18,
|
|
131
|
-
minute: 0,
|
|
132
|
-
})),
|
|
133
|
-
]);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
test('outside service hours', () => {
|
|
137
|
-
expect(splitIntervalByServiceHours(Interval.fromDateTimes(DateTime.fromObject({
|
|
138
|
-
day: 1,
|
|
139
|
-
month: 4,
|
|
140
|
-
year: 2025,
|
|
141
|
-
hour: 3,
|
|
142
|
-
minute: 0,
|
|
143
|
-
}), DateTime.fromObject({
|
|
144
|
-
day: 1,
|
|
145
|
-
month: 4,
|
|
146
|
-
year: 2025,
|
|
147
|
-
hour: 4,
|
|
148
|
-
minute: 30,
|
|
149
|
-
})))).toEqual([]);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
//# sourceMappingURL=splitIntervalByServiceHours.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"splitIntervalByServiceHours.test.js","sourceRoot":"/","sources":["helpers/splitIntervalByServiceHours.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC5C,MAAM,CACJ,2BAA2B,CACzB,QAAQ,CAAC,aAAa,CACpB,QAAQ,CAAC,UAAU,CAAC;YAClB,GAAG,EAAE,CAAC;YACN,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,CAAC;SACV,CAAC,EACF,QAAQ,CAAC,UAAU,CAAC;YAClB,GAAG,EAAE,CAAC;YACN,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,IAAI;YACV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YACP,MAAM,EAAE,CAAC;SACV,CAAC,EACF,QAAQ,CAAC,UAAU,CAAC;YAClB,GAAG,EAAE,CAAC;YACN,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,EAAE;SACX,CAAC,CACH,CACF,CACF,CAAC,OAAO,CAAC,EAAuB,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from 'vitest';\nimport { DateTime, Interval } from 'luxon';\nimport { splitIntervalByServiceHours } from './splitIntervalByServiceHours.js';\n\ndescribe('splitIntervalByServiceHours', () => {\n test('single day, within service hours', () => {\n expect(\n splitIntervalByServiceHours(\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 8,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 12,\n minute: 30,\n }),\n ),\n ),\n ).toEqual([\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 8,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 12,\n minute: 30,\n }),\n ),\n ] satisfies Interval[]);\n });\n describe('transcends service hour boundaries', () => {\n test('single day, starts before service hours', () => {\n expect(\n splitIntervalByServiceHours(\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 5,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 6,\n minute: 0,\n }),\n ),\n ),\n ).toEqual([\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 5,\n minute: 30,\n }),\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 6,\n minute: 0,\n }),\n ),\n ] satisfies Interval[]);\n });\n test('single day, ends after service hours', () => {\n expect(\n splitIntervalByServiceHours(\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 1,\n minute: 0,\n }),\n ),\n ),\n ).toEqual([\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n ),\n ] satisfies Interval[]);\n });\n test('multiple days, transcends multiple service hours/non services hour ranges', () => {\n expect(\n splitIntervalByServiceHours(\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 0,\n }),\n ),\n ),\n ).toEqual([\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 0,\n minute: 0,\n }),\n ),\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 5,\n minute: 30,\n }),\n DateTime.fromObject({\n day: 2,\n month: 4,\n year: 2025,\n hour: 18,\n minute: 0,\n }),\n ),\n ] satisfies Interval[]);\n });\n });\n test('outside service hours', () => {\n expect(\n splitIntervalByServiceHours(\n Interval.fromDateTimes(\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 3,\n minute: 0,\n }),\n DateTime.fromObject({\n day: 1,\n month: 4,\n year: 2025,\n hour: 4,\n minute: 30,\n }),\n ),\n ),\n ).toEqual([] satisfies Interval[]);\n });\n});\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Duration } from 'luxon';
|
|
2
|
-
export function sumIntervalDuration(intervals) {
|
|
3
|
-
let duration = Duration.fromObject({ milliseconds: 0 });
|
|
4
|
-
for (const segment of intervals) {
|
|
5
|
-
duration = duration.plus(segment.toDuration());
|
|
6
|
-
}
|
|
7
|
-
return duration;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=sumIntervalDuration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sumIntervalDuration.js","sourceRoot":"/","sources":["helpers/sumIntervalDuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,OAAO,CAAC;AAEhD,MAAM,UAAU,mBAAmB,CAAC,SAAqB;IACvD,IAAI,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;IACxD,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;QAChC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { Duration, type Interval } from 'luxon';\n\nexport function sumIntervalDuration(intervals: Interval[]) {\n let duration = Duration.fromObject({ milliseconds: 0 });\n for (const segment of intervals) {\n duration = duration.plus(segment.toDuration());\n }\n return duration;\n}\n"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { IStore } from './common/store.js';
|
|
2
|
-
import { IssueRepository } from './issue/IssueRepository.js';
|
|
3
|
-
import { LandmarkRepository } from './landmark/LandmarkRepository.js';
|
|
4
|
-
import { LineRepository } from './line/LineRepository.js';
|
|
5
|
-
import { OperatorRepository } from './operator/OperatorRepository.js';
|
|
6
|
-
import { ServiceRepository } from './service/ServiceRepository.js';
|
|
7
|
-
import { StationRepository } from './station/StationRepository.js';
|
|
8
|
-
import { TownRepository } from './town/TownRepository.js';
|
|
9
|
-
interface MRTDownRepositoryOptions {
|
|
10
|
-
store: IStore;
|
|
11
|
-
}
|
|
12
|
-
export declare class MRTDownRepository {
|
|
13
|
-
private readonly store;
|
|
14
|
-
readonly stations: StationRepository;
|
|
15
|
-
readonly towns: TownRepository;
|
|
16
|
-
readonly landmarks: LandmarkRepository;
|
|
17
|
-
readonly lines: LineRepository;
|
|
18
|
-
readonly operators: OperatorRepository;
|
|
19
|
-
readonly services: ServiceRepository;
|
|
20
|
-
readonly issues: IssueRepository;
|
|
21
|
-
constructor(options: MRTDownRepositoryOptions);
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { IssueRepository } from './issue/IssueRepository.js';
|
|
2
|
-
import { LandmarkRepository } from './landmark/LandmarkRepository.js';
|
|
3
|
-
import { LineRepository } from './line/LineRepository.js';
|
|
4
|
-
import { OperatorRepository } from './operator/OperatorRepository.js';
|
|
5
|
-
import { ServiceRepository } from './service/ServiceRepository.js';
|
|
6
|
-
import { StationRepository } from './station/StationRepository.js';
|
|
7
|
-
import { TownRepository } from './town/TownRepository.js';
|
|
8
|
-
export class MRTDownRepository {
|
|
9
|
-
store;
|
|
10
|
-
stations;
|
|
11
|
-
towns;
|
|
12
|
-
landmarks;
|
|
13
|
-
lines;
|
|
14
|
-
operators;
|
|
15
|
-
services;
|
|
16
|
-
issues;
|
|
17
|
-
constructor(options) {
|
|
18
|
-
this.store = options.store;
|
|
19
|
-
this.stations = new StationRepository(this.store);
|
|
20
|
-
this.towns = new TownRepository(this.store);
|
|
21
|
-
this.landmarks = new LandmarkRepository(this.store);
|
|
22
|
-
this.lines = new LineRepository(this.store);
|
|
23
|
-
this.operators = new OperatorRepository(this.store);
|
|
24
|
-
this.services = new ServiceRepository(this.store);
|
|
25
|
-
this.issues = new IssueRepository(this.store);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=MRTDownRepository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MRTDownRepository.js","sourceRoot":"/","sources":["repo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;CACF","sourcesContent":["import type { IStore } from './common/store.js';\nimport { IssueRepository } from './issue/IssueRepository.js';\nimport { LandmarkRepository } from './landmark/LandmarkRepository.js';\nimport { LineRepository } from './line/LineRepository.js';\nimport { OperatorRepository } from './operator/OperatorRepository.js';\nimport { ServiceRepository } from './service/ServiceRepository.js';\nimport { StationRepository } from './station/StationRepository.js';\nimport { TownRepository } from './town/TownRepository.js';\n\ninterface MRTDownRepositoryOptions {\n store: IStore;\n}\n\nexport class MRTDownRepository {\n private readonly store: IStore;\n\n readonly stations: StationRepository;\n readonly towns: TownRepository;\n readonly landmarks: LandmarkRepository;\n readonly lines: LineRepository;\n readonly operators: OperatorRepository;\n readonly services: ServiceRepository;\n readonly issues: IssueRepository;\n\n constructor(options: MRTDownRepositoryOptions) {\n this.store = options.store;\n this.stations = new StationRepository(this.store);\n this.towns = new TownRepository(this.store);\n this.landmarks = new LandmarkRepository(this.store);\n this.lines = new LineRepository(this.store);\n this.operators = new OperatorRepository(this.store);\n this.services = new ServiceRepository(this.store);\n this.issues = new IssueRepository(this.store);\n }\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IStore } from './store.js';
|
|
2
|
-
/**
|
|
3
|
-
* A store for reading and writing files.
|
|
4
|
-
*/
|
|
5
|
-
export declare class FileStore implements IStore {
|
|
6
|
-
private readonly rootDir;
|
|
7
|
-
constructor(rootDir: string);
|
|
8
|
-
readText(path: string): string;
|
|
9
|
-
readJson<T>(path: string): T;
|
|
10
|
-
listDir(path: string): string[];
|
|
11
|
-
exists(path: string): boolean;
|
|
12
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
/**
|
|
4
|
-
* A store for reading and writing files.
|
|
5
|
-
*/
|
|
6
|
-
export class FileStore {
|
|
7
|
-
rootDir;
|
|
8
|
-
constructor(rootDir) {
|
|
9
|
-
this.rootDir = rootDir;
|
|
10
|
-
}
|
|
11
|
-
readText(path) {
|
|
12
|
-
const fullPath = join(this.rootDir, path);
|
|
13
|
-
return readFileSync(fullPath, { encoding: 'utf-8' });
|
|
14
|
-
}
|
|
15
|
-
readJson(path) {
|
|
16
|
-
return JSON.parse(this.readText(path));
|
|
17
|
-
}
|
|
18
|
-
listDir(path) {
|
|
19
|
-
const fullPath = join(this.rootDir, path);
|
|
20
|
-
return readdirSync(fullPath);
|
|
21
|
-
}
|
|
22
|
-
exists(path) {
|
|
23
|
-
const fullPath = join(this.rootDir, path);
|
|
24
|
-
return existsSync(fullPath);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=FileStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileStore.js","sourceRoot":"/","sources":["repo/common/FileStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;GAEG;AACH,MAAM,OAAO,SAAS;IACS;IAA7B,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEhD,QAAQ,CAAC,IAAY;QACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,OAAO,YAAY,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,QAAQ,CAAI,IAAY;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { IStore } from './store.js';\n\n/**\n * A store for reading and writing files.\n */\nexport class FileStore implements IStore {\n constructor(private readonly rootDir: string) {}\n\n readText(path: string): string {\n const fullPath = join(this.rootDir, path);\n return readFileSync(fullPath, { encoding: 'utf-8' });\n }\n\n readJson<T>(path: string): T {\n return JSON.parse(this.readText(path));\n }\n\n listDir(path: string): string[] {\n const fullPath = join(this.rootDir, path);\n return readdirSync(fullPath);\n }\n\n exists(path: string): boolean {\n const fullPath = join(this.rootDir, path);\n return existsSync(fullPath);\n }\n}\n"]}
|