corequery 0.29.0 → 0.30.0
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/package.json +1 -1
- package/server/dist/server/api/create-api-router.js +3 -1
- package/server/dist/server/api/create-api-router.js.map +1 -1
- package/server/dist/server/api/handlers/about-page/v1/index.d.ts +2 -2
- package/server/dist/server/api/handlers/about-page/v1/index.js.map +1 -1
- package/server/dist/server/api/handlers/departures/v0/index.d.ts +2 -2
- package/server/dist/server/api/handlers/departures/v0/index.js +16 -13
- package/server/dist/server/api/handlers/departures/v0/index.js.map +1 -1
- package/server/dist/server/api/handlers/foda-synced-handler.d.ts +5 -0
- package/server/dist/server/api/handlers/foda-synced-handler.js +6 -0
- package/server/dist/server/api/handlers/foda-synced-handler.js.map +1 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-foda.d.ts +11 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-foda.js +107 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-foda.js.map +1 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-diagram-entry-foda.d.ts +10 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-diagram-entry-foda.js +35 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-diagram-entry-foda.js.map +1 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-diagram-foda.d.ts +10 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-diagram-foda.js +23 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-diagram-foda.js.map +1 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-foda.d.ts +10 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-foda.js +30 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-foda.js.map +1 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-stop-foda.d.ts +10 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-stop-foda.js +33 -0
- package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-stop-foda.js.map +1 -0
- package/server/dist/server/api/handlers/foundational-data/v1/index.d.ts +2 -2
- package/server/dist/server/api/handlers/foundational-data/v1/index.js +6 -4
- package/server/dist/server/api/handlers/foundational-data/v1/index.js.map +1 -1
- package/server/dist/server/api/handlers/service/v0/index.d.ts +2 -2
- package/server/dist/server/api/handlers/service/v0/index.js +18 -15
- package/server/dist/server/api/handlers/service/v0/index.js.map +1 -1
- package/server/dist/server/api/handlers/version-check/v1/index.d.ts +2 -2
- package/server/dist/server/api/handlers/version-check/v1/index.js.map +1 -1
- package/server/dist/server/api/handlers/versions/v1/index.d.ts +2 -2
- package/server/dist/server/api/handlers/versions/v1/index.js +1 -3
- package/server/dist/server/api/handlers/versions/v1/index.js.map +1 -1
- package/server/dist/server/api/types.d.ts +8 -1
- package/server/dist/server/corequery.d.ts +2 -0
- package/server/dist/server/corequery.js +12 -0
- package/server/dist/server/corequery.js.map +1 -1
- package/server/dist/server/data/line-diagram-entry.d.ts +0 -3
- package/server/dist/server/data/line-diagram-entry.js +1 -18
- package/server/dist/server/data/line-diagram-entry.js.map +1 -1
- package/server/dist/server/data/line-diagram.d.ts +0 -3
- package/server/dist/server/data/line-diagram.js +0 -6
- package/server/dist/server/data/line-diagram.js.map +1 -1
- package/server/dist/server/data/line.d.ts +0 -3
- package/server/dist/server/data/line.js +1 -10
- package/server/dist/server/data/line.js.map +1 -1
- package/server/dist/server/data/location.d.ts +0 -3
- package/server/dist/server/data/location.js +0 -6
- package/server/dist/server/data/location.js.map +1 -1
- package/server/dist/server/data/stop.d.ts +0 -3
- package/server/dist/server/data/stop.js +0 -9
- package/server/dist/server/data/stop.js.map +1 -1
- package/server/dist/shared/apis/departures/v0/index.d.ts +20 -17
- package/server/dist/shared/apis/departures/v0/index.js +3 -47
- package/server/dist/shared/apis/departures/v0/index.js.map +1 -1
- package/server/dist/shared/apis/foda-synced-result.d.ts +5 -0
- package/server/dist/shared/apis/foda-synced-result.js +8 -0
- package/server/dist/shared/apis/foda-synced-result.js.map +1 -0
- package/server/dist/shared/apis/foundational-data/v1/foundational-data.d.ts +2 -5
- package/server/dist/shared/apis/foundational-data/v1/foundational-data.js +3 -7
- package/server/dist/shared/apis/foundational-data/v1/foundational-data.js.map +1 -1
- package/server/dist/shared/apis/foundational-data/v1/index.d.ts +1 -0
- package/server/dist/shared/apis/service/v0/index.d.ts +21 -18
- package/server/dist/shared/apis/service/v0/index.js +3 -4
- package/server/dist/shared/apis/service/v0/index.js.map +1 -1
- package/server/dist/shared/apis/types.d.ts +1 -3
- package/server/dist/shared/apis/types.js +1 -1
- package/server/dist/shared/apis/types.js.map +1 -1
- package/web/dist/assets/About-DpFLDTV_.js +1 -0
- package/web/dist/assets/{AdminControls-BRkz2H1D.js → AdminControls-BMTTV4kR.js} +1 -1
- package/web/dist/assets/Alert-k_U4L_j3.js +1 -0
- package/web/dist/assets/Debug-DGqHdl31.js +1 -0
- package/web/dist/assets/{Home-Bimr0Ebg.js → Home-LcK9TehM.js} +1 -1
- package/web/dist/assets/Line-ZicduquS.js +1 -0
- package/web/dist/assets/NotFound-zNBih-TR.js +1 -0
- package/web/dist/assets/NotFoundPage-DLkgQE3z.js +1 -0
- package/web/dist/assets/{Picker-B59cZ5e5.js → Picker-ByWHXE97.js} +1 -1
- package/web/dist/assets/Service-CqfnDpff.js +1 -0
- package/web/dist/assets/{Settings-CcUztzue.js → Settings-1Z6FXsgC.js} +1 -1
- package/web/dist/assets/{SimpleMobileHeaderContent-9gskaqRe.js → SimpleMobileHeaderContent-DnaUyjiU.js} +1 -1
- package/web/dist/assets/{Status-Brsavasr.js → Status-DIIRyqgr.js} +1 -1
- package/web/dist/assets/Stop-DKWaUN6o.js +1 -0
- package/web/dist/assets/{ZenMode-D8bVmCaS.js → ZenMode-qKwx-pZt.js} +1 -1
- package/web/dist/assets/index-CE8NAPhv.js +2 -0
- package/web/dist/assets/linear-CMwrWzQJ.js +1 -0
- package/web/dist/assets/use-api-BJomuYg6.js +55 -0
- package/web/dist/assets/use-foda-synced-query-BM-OPAql.js +1 -0
- package/web/dist/assets/{use-simple-headers-CovxFlVs.js → use-simple-headers-Bihzijd5.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/server/dist/server/api/handlers/foundational-data/v1/builder.d.ts +0 -11
- package/server/dist/server/api/handlers/foundational-data/v1/builder.js +0 -44
- package/server/dist/server/api/handlers/foundational-data/v1/builder.js.map +0 -1
- package/web/dist/assets/About-BFYcBory.js +0 -1
- package/web/dist/assets/Alert-D41vPACK.js +0 -1
- package/web/dist/assets/Debug-CdyB6z1N.js +0 -1
- package/web/dist/assets/Line-DG7fDqpF.js +0 -1
- package/web/dist/assets/NotFound-DS9pNgRR.js +0 -1
- package/web/dist/assets/NotFoundPage-rHyFGsin.js +0 -1
- package/web/dist/assets/Service-CscfW4h8.js +0 -1
- package/web/dist/assets/Stop-mET1TOC2.js +0 -1
- package/web/dist/assets/index-DapCozyq.js +0 -2
- package/web/dist/assets/linear-eK93gfBn.js +0 -1
- package/web/dist/assets/use-query-BRsiAaVY.js +0 -55
package/package.json
CHANGED
|
@@ -7,7 +7,9 @@ export function createApiRouter(app) {
|
|
|
7
7
|
// web app, so nothing is needed to make that work, and browsers already block
|
|
8
8
|
// cross-origin requests bydefault, unless the server explicitly opts-in to
|
|
9
9
|
// allowing JS from another domain accessing it.
|
|
10
|
-
function setup(api,
|
|
10
|
+
function setup(api,
|
|
11
|
+
// NoInfer ensures that the types are inferred purely from the `api` type.
|
|
12
|
+
handler) {
|
|
11
13
|
router.post(api.path, async (req, res) => {
|
|
12
14
|
try {
|
|
13
15
|
const args = api.argsSchema.safeParse(req.body);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-api-router.js","sourceRoot":"","sources":["../../../api/create-api-router.ts"],"names":[],"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tB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,sBAAsB;IACtB,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAClD,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAClD,KAAK,CAAC,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAChE,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5C,KAAK,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACxD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAE9C,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QAC/B,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ABOUT_PAGE_V1 } from "../../../../../shared/apis/index.js";
|
|
2
2
|
import type { ApiContext } from "../../../types.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function handle(ctx: ApiContext, _args:
|
|
3
|
+
import type { ServerArgsOf, ServerResultOf } from "../../../types.js";
|
|
4
|
+
export declare function handle(ctx: ApiContext, _args: ServerArgsOf<typeof ABOUT_PAGE_V1>): Promise<ServerResultOf<typeof ABOUT_PAGE_V1>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/about-page/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,MAAM,CACpB,GAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/about-page/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,MAAM,CACpB,GAAe,EACf,KAAyC;IAEzC,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,eAAe,EAAE,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,eAAe;KACzD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DEPARTURES_V0 } from "../../../../../shared/apis/index.js";
|
|
2
2
|
import type { ApiContext } from "../../../types.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function handle(ctx: ApiContext, args:
|
|
3
|
+
import type { ServerArgsOf, ServerResultOf } from "../../../types.js";
|
|
4
|
+
export declare function handle(ctx: ApiContext, args: ServerArgsOf<typeof DEPARTURES_V0>): Promise<ServerResultOf<typeof DEPARTURES_V0>>;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { applyFodaSyncedResult } from "../../foda-synced-handler.js";
|
|
1
2
|
export async function handle(ctx, args) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
return applyFodaSyncedResult(ctx, async () => {
|
|
4
|
+
// TODO: The v1 API should return some sort of error object.
|
|
5
|
+
if (args.count < 1 || args.count > 50)
|
|
6
|
+
return { departures: [] };
|
|
7
|
+
const now = getStartOfCurrentMinute();
|
|
8
|
+
const iterator = ctx.app.services.getDeparturesIterator(args.stopId, now, "forwards");
|
|
9
|
+
const results = [];
|
|
10
|
+
while ((await iterator.peek()) != null && results.length < args.count) {
|
|
11
|
+
const dep = await iterator.take();
|
|
12
|
+
results.push(dep);
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
departures: results.map((x) => toApiResult(ctx.app, x)),
|
|
16
|
+
};
|
|
17
|
+
});
|
|
15
18
|
}
|
|
16
19
|
function getStartOfCurrentMinute() {
|
|
17
20
|
return Temporal.Now.zonedDateTimeISO("UTC")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/departures/v0/index.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,GAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/departures/v0/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAMrF,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,GAAe,EACf,IAAwC;IAExC,OAAO,qBAAqB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;QAC3C,4DAA4D;QAC5D,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,EAAE;YAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QAEjE,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAC;QAEtC,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CACrD,IAAI,CAAC,MAAM,EACX,GAAG,EACH,UAAU,CACX,CAAC;QAEF,MAAM,OAAO,GAAgB,EAAE,CAAC;QAEhC,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YACtE,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QAED,OAAO;YACL,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC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,qBAAqB,CACzC,GAAe,EACf,IAA2B;IAE3B,MAAM,oBAAoB,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;IAC/C,MAAM,WAAW,GAAG,MAAM,IAAI,EAAE,CAAC;IAEjC,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,CAAC;AAC/C,CAAC"}
|
package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-foda.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Corequery } from "../../../../corequery.js";
|
|
2
|
+
import type { fodaSchema as fodaV1Schema } from "../../../../../shared/apis/foundational-data/v1/foundational-data.js";
|
|
3
|
+
import type z from "zod";
|
|
4
|
+
export declare class MultiversionalFoda {
|
|
5
|
+
readonly obj: ReturnType<typeof MultiversionalFoda._buildObj>;
|
|
6
|
+
readonly hash: string;
|
|
7
|
+
constructor(obj: ReturnType<typeof MultiversionalFoda._buildObj>);
|
|
8
|
+
static build(app: Corequery): MultiversionalFoda;
|
|
9
|
+
private static _buildObj;
|
|
10
|
+
toFodaV1(): z.input<typeof fodaV1Schema>;
|
|
11
|
+
}
|
package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-foda.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import { MultiversionalLineFoda } from "./multiversional-line-foda.js";
|
|
3
|
+
import { MultiversionalStopFoda } from "./multiversional-stop-foda.js";
|
|
4
|
+
// This class exists because the `hash` value returned for FODA must remain
|
|
5
|
+
// identical across different versions of the FODA API for the same FODA. This
|
|
6
|
+
// means we have to calculate the hash based on a shared, version-agnostic
|
|
7
|
+
// representation of the FODA (called obj in here), which contains the full
|
|
8
|
+
// range of data which could possibly affect the hash (i.e., the union of the
|
|
9
|
+
// fields used by all versions of the FODA API)
|
|
10
|
+
//
|
|
11
|
+
// It has to be this way, otherwise an outdated client will fetch the FODA from
|
|
12
|
+
// the v1 API, getting one hash calculated from the v1 data, and then later
|
|
13
|
+
// calling a FODA-synced API endpoint which (a) can't calculate a hash unless it
|
|
14
|
+
// chooses which version to calculate the hash from, and (b) if it just decides
|
|
15
|
+
// to use the hash from the latest version of the FODA API, it'll keep telling
|
|
16
|
+
// that client that it needs to update its FODA, but the client will never
|
|
17
|
+
// succeed as it only knows how to call the v1 API, so the hash will always
|
|
18
|
+
// differ.
|
|
19
|
+
export class MultiversionalFoda {
|
|
20
|
+
obj;
|
|
21
|
+
hash;
|
|
22
|
+
// The obj which will ultimately be used to calculate the hash is the ONLY
|
|
23
|
+
// allowable input for this class. Methods like `toFodaV1` cannot be allowed
|
|
24
|
+
// to use anything else as an input, otherwise values which should be
|
|
25
|
+
// considered during hash calculation will be missed.
|
|
26
|
+
constructor(obj) {
|
|
27
|
+
this.obj = obj;
|
|
28
|
+
// Notice how this is not versioned. Every version of the FODA API, and all
|
|
29
|
+
// FODA-synced APIs return the same hash. This means a client won't get
|
|
30
|
+
// conflicting results from whichever FODA API version it's configured to
|
|
31
|
+
// call vs when it gets the hash back from a FODA-synced API.
|
|
32
|
+
this.hash = crypto
|
|
33
|
+
.createHash("sha256")
|
|
34
|
+
.update(JSON.stringify(this.obj))
|
|
35
|
+
.digest("hex");
|
|
36
|
+
}
|
|
37
|
+
static build(app) {
|
|
38
|
+
return new MultiversionalFoda(MultiversionalFoda._buildObj(app));
|
|
39
|
+
}
|
|
40
|
+
// TODO: Do something to enforce that the return type of `_buildObj` is a
|
|
41
|
+
// plain object (i.e. doesn't contain any class instances or other
|
|
42
|
+
// non-serializable values). I remember doing something in ItIsBuses that did
|
|
43
|
+
// this (a `JsonSerializable` type or something).
|
|
44
|
+
static _buildObj(app) {
|
|
45
|
+
return {
|
|
46
|
+
// TODO: Can I remember the rationale behind having serverVersion in the
|
|
47
|
+
// hash calculation? Was it just so foda.metadata.serverVersion remains up
|
|
48
|
+
// to date on the frontend?
|
|
49
|
+
//
|
|
50
|
+
// If so, does it need to? I'm pretty sure server version is baked into
|
|
51
|
+
// the PWA too, and I intentionally let it drift if the PWA bundle doesn't
|
|
52
|
+
// actually change. It's kinda cool in that way, to see that the frontend
|
|
53
|
+
// didn't need to change just because the server was updated (is server
|
|
54
|
+
// version the trainquery-melbourne commit hash?).
|
|
55
|
+
//
|
|
56
|
+
// Any material changes to FODA should be reflected in this obj, and
|
|
57
|
+
// therefore the hash, without needing serverVersion to drive it.
|
|
58
|
+
//
|
|
59
|
+
// If I decide to remove it, make serverVersion an arg on toFodaV1
|
|
60
|
+
// instead.
|
|
61
|
+
serverVersion: app.serverVersion,
|
|
62
|
+
stops: app.stops.map((s) => MultiversionalStopFoda.build(s).obj),
|
|
63
|
+
lines: app.lines.map((l) => MultiversionalLineFoda.build(l).obj),
|
|
64
|
+
landingPage: {
|
|
65
|
+
primaryMarkdown: app.landingPageConfig.primaryMarkdown,
|
|
66
|
+
},
|
|
67
|
+
footer: {
|
|
68
|
+
primaryMarkdown: app.footerConfig.primaryMarkdown,
|
|
69
|
+
},
|
|
70
|
+
terminology: {
|
|
71
|
+
stop: app.terminologyConfig.stop,
|
|
72
|
+
line: app.terminologyConfig.line,
|
|
73
|
+
service: app.terminologyConfig.service,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Just like `hash`, this value can also be memoized in this class if we want.
|
|
78
|
+
// If the FODA changes, this whole class (the `obj`) needs to be recreated
|
|
79
|
+
// anyway. I can sort of imagine the number of possible versions of FODA
|
|
80
|
+
// blowing up in future though (i.e. there'll be a v1, v2, v3, etc.), so we
|
|
81
|
+
// probably don't want to memoize all of them. But memoizing the latest
|
|
82
|
+
// version (which is presumably the one that updated clients are fetching all
|
|
83
|
+
// the time) probably always makes sense.
|
|
84
|
+
toFodaV1() {
|
|
85
|
+
return {
|
|
86
|
+
metadata: {
|
|
87
|
+
hash: this.hash,
|
|
88
|
+
fodaApiVersion: "1",
|
|
89
|
+
serverVersion: this.obj.serverVersion,
|
|
90
|
+
},
|
|
91
|
+
stops: this.obj.stops.map((s) => new MultiversionalStopFoda(s).toFodaV1()),
|
|
92
|
+
lines: this.obj.lines.map((l) => new MultiversionalLineFoda(l).toFodaV1()),
|
|
93
|
+
landingPage: {
|
|
94
|
+
primaryMarkdown: this.obj.landingPage.primaryMarkdown,
|
|
95
|
+
},
|
|
96
|
+
footer: {
|
|
97
|
+
primaryMarkdown: this.obj.footer.primaryMarkdown,
|
|
98
|
+
},
|
|
99
|
+
terminology: {
|
|
100
|
+
stop: this.obj.terminology.stop,
|
|
101
|
+
line: this.obj.terminology.line,
|
|
102
|
+
service: this.obj.terminology.service,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=multiversional-foda.js.map
|
package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-foda.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversional-foda.js","sourceRoot":"","sources":["../../../../../../api/handlers/foundational-data/multiversional/multiversional-foda.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oFAAoF,CAAC;AAC5H,OAAO,EAAE,sBAAsB,EAAE,MAAM,oFAAoF,CAAC;AAI5H,2EAA2E;AAC3E,8EAA8E;AAC9E,0EAA0E;AAC1E,2EAA2E;AAC3E,6EAA6E;AAC7E,+CAA+C;AAC/C,EAAE;AACF,+EAA+E;AAC/E,2EAA2E;AAC3E,gFAAgF;AAChF,+EAA+E;AAC/E,8EAA8E;AAC9E,0EAA0E;AAC1E,2EAA2E;AAC3E,UAAU;AAEV,MAAM,OAAO,kBAAkB;IAOR;IANZ,IAAI,CAAS;IAEtB,0EAA0E;IAC1E,4EAA4E;IAC5E,qEAAqE;IACrE,qDAAqD;IACrD,YAAqB,GAAoD;QAApD,QAAG,GAAH,GAAG,CAAiD;QACvE,2EAA2E;QAC3E,uEAAuE;QACvE,yEAAyE;QACzE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O,EAAE,GAAG,CAAC,iBAAiB,CAAC,OAAO;aACvC;SACF,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,0EAA0E;IAC1E,wEAAwE;IACxE,2EAA2E;IAC3E,uEAAuE;IACvE,6EAA6E;IAC7E,yCAAyC;IACzC,QAAQ;QACN,OAAO;YACL,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,cAAc,EAAE,GAAG;gBACnB,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa;aACtC;YAED,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9B,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CACzC;YACD,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9B,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CACzC;YACD,WAAW,EAAE;gBACX,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,eAAe;aACtD;YACD,MAAM,EAAE;gBACN,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe;aACjD;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI;gBAC/B,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI;gBAC/B,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO;aACtC;SACF,CAAC;IACJ,CAAC;CAMF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LineDiagramEntry } from "../../../../data/line-diagram-entry.js";
|
|
2
|
+
import type { lineDiagramEntryFodaSchema as lineDiagramEntryFodaV1Schema } from "../../../../../shared/apis/foundational-data/v1/foundational-data.js";
|
|
3
|
+
import type z from "zod";
|
|
4
|
+
export declare class MultiversionalLineDiagramEntryFoda {
|
|
5
|
+
readonly obj: ReturnType<typeof MultiversionalLineDiagramEntryFoda._buildObj>;
|
|
6
|
+
constructor(obj: ReturnType<typeof MultiversionalLineDiagramEntryFoda._buildObj>);
|
|
7
|
+
static build(diagram: LineDiagramEntry): MultiversionalLineDiagramEntryFoda;
|
|
8
|
+
private static _buildObj;
|
|
9
|
+
toFodaV1(): z.input<typeof lineDiagramEntryFodaV1Schema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getHexCodesForColor } from "../../../../data/color.js";
|
|
2
|
+
export class MultiversionalLineDiagramEntryFoda {
|
|
3
|
+
obj;
|
|
4
|
+
constructor(obj) {
|
|
5
|
+
this.obj = obj;
|
|
6
|
+
}
|
|
7
|
+
static build(diagram) {
|
|
8
|
+
return new MultiversionalLineDiagramEntryFoda(MultiversionalLineDiagramEntryFoda._buildObj(diagram));
|
|
9
|
+
}
|
|
10
|
+
static _buildObj(diagram) {
|
|
11
|
+
return {
|
|
12
|
+
name: diagram.name,
|
|
13
|
+
color: diagram.color != null ? getHexCodesForColor(diagram.color) : null,
|
|
14
|
+
shape: diagram.shape,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
toFodaV1() {
|
|
18
|
+
// So there's a mismatch between how the config creates line diagrams, with
|
|
19
|
+
// its "shape" field, and how the FODA schema doesn't have a "shape" field,
|
|
20
|
+
// it's all just dumped at the top level. This wasn't intentional, I decided
|
|
21
|
+
// on the schema first, and then when I got around to implementing the
|
|
22
|
+
// config I preferred having a "shape" field, as name and color are common.
|
|
23
|
+
//
|
|
24
|
+
// But, to be fair, maybe it's a good thing? This means if we change other
|
|
25
|
+
// fields (not just the shape), it can be a new "type" in the FODA, and then
|
|
26
|
+
// the frontend gracefully falls back to the fallbackStopList, instead of
|
|
27
|
+
// requiring a breaking change to the FODA schema.
|
|
28
|
+
return {
|
|
29
|
+
name: this.obj.name,
|
|
30
|
+
color: this.obj.color,
|
|
31
|
+
...this.obj.shape,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=multiversional-line-diagram-entry-foda.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversional-line-diagram-entry-foda.js","sourceRoot":"","sources":["../../../../../../api/handlers/foundational-data/multiversional/multiversional-line-diagram-entry-foda.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,OAAO,kCAAkC;IAElC;IADX,YACW,GAER;QAFQ,QAAG,GAAH,GAAG,CAEX;IACA,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,OAAyB;QACpC,OAAO,IAAI,kCAAkC,CAC3C,kCAAkC,CAAC,SAAS,CAAC,OAAO,CAAC,CACtD,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,SAAS,CAAC,OAAyB;QAChD,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;YACxE,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5E,sEAAsE;QACtE,2EAA2E;QAC3E,EAAE;QACF,0EAA0E;QAC1E,4EAA4E;QAC5E,yEAAyE;QACzE,kDAAkD;QAClD,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;YACnB,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK;YACrB,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LineDiagram } from "../../../../data/line-diagram.js";
|
|
2
|
+
import type { lineDiagramFodaSchema as lineDiagramFodaV1Schema } from "../../../../../shared/apis/foundational-data/v1/foundational-data.js";
|
|
3
|
+
import type z from "zod";
|
|
4
|
+
export declare class MultiversionalLineDiagramFoda {
|
|
5
|
+
readonly obj: ReturnType<typeof MultiversionalLineDiagramFoda._buildObj>;
|
|
6
|
+
constructor(obj: ReturnType<typeof MultiversionalLineDiagramFoda._buildObj>);
|
|
7
|
+
static build(diagram: LineDiagram): MultiversionalLineDiagramFoda;
|
|
8
|
+
private static _buildObj;
|
|
9
|
+
toFodaV1(): z.input<typeof lineDiagramFodaV1Schema>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MultiversionalLineDiagramEntryFoda } from "./multiversional-line-diagram-entry-foda.js";
|
|
2
|
+
export class MultiversionalLineDiagramFoda {
|
|
3
|
+
obj;
|
|
4
|
+
constructor(obj) {
|
|
5
|
+
this.obj = obj;
|
|
6
|
+
}
|
|
7
|
+
static build(diagram) {
|
|
8
|
+
return new MultiversionalLineDiagramFoda(MultiversionalLineDiagramFoda._buildObj(diagram));
|
|
9
|
+
}
|
|
10
|
+
static _buildObj(diagram) {
|
|
11
|
+
return {
|
|
12
|
+
entries: diagram.entries.map((entry) => MultiversionalLineDiagramEntryFoda.build(entry).obj),
|
|
13
|
+
fallbackStopList: diagram.getFallbackStopList(),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
toFodaV1() {
|
|
17
|
+
return {
|
|
18
|
+
entries: this.obj.entries.map((entry) => new MultiversionalLineDiagramEntryFoda(entry).toFodaV1()),
|
|
19
|
+
fallbackStopList: this.obj.fallbackStopList,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=multiversional-line-diagram-foda.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversional-line-diagram-foda.js","sourceRoot":"","sources":["../../../../../../api/handlers/foundational-data/multiversional/multiversional-line-diagram-foda.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kCAAkC,EAAE,MAAM,kGAAkG,CAAC;AAEtJ,MAAM,OAAO,6BAA6B;IAE7B;IADX,YACW,GAA+D;QAA/D,QAAG,GAAH,GAAG,CAA4D;IACvE,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,OAAoB;QAC/B,OAAO,IAAI,6BAA6B,CACtC,6BAA6B,CAAC,SAAS,CAAC,OAAO,CAAC,CACjD,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,SAAS,CAAC,OAAoB;QAC3C,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAC1B,CAAC,KAAK,EAAE,EAAE,CAAC,kCAAkC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAC/D;YACD,gBAAgB,EAAE,OAAO,CAAC,mBAAmB,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACtC,IAAI,kCAAkC,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CACzD;YACD,gBAAgB,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;SAC5C,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Line } from "../../../../data/line.js";
|
|
2
|
+
import type { lineFodaSchema as lineFodaV1Schema } from "../../../../../shared/apis/foundational-data/v1/foundational-data.js";
|
|
3
|
+
import type z from "zod";
|
|
4
|
+
export declare class MultiversionalLineFoda {
|
|
5
|
+
readonly obj: ReturnType<typeof MultiversionalLineFoda._buildObj>;
|
|
6
|
+
constructor(obj: ReturnType<typeof MultiversionalLineFoda._buildObj>);
|
|
7
|
+
static build(line: Line): MultiversionalLineFoda;
|
|
8
|
+
private static _buildObj;
|
|
9
|
+
toFodaV1(): z.input<typeof lineFodaV1Schema>;
|
|
10
|
+
}
|
package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-line-foda.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getHexCodesForColor } from "../../../../data/color.js";
|
|
2
|
+
import { MultiversionalLineDiagramFoda } from "./multiversional-line-diagram-foda.js";
|
|
3
|
+
export class MultiversionalLineFoda {
|
|
4
|
+
obj;
|
|
5
|
+
constructor(obj) {
|
|
6
|
+
this.obj = obj;
|
|
7
|
+
}
|
|
8
|
+
static build(line) {
|
|
9
|
+
return new MultiversionalLineFoda(MultiversionalLineFoda._buildObj(line));
|
|
10
|
+
}
|
|
11
|
+
static _buildObj(line) {
|
|
12
|
+
return {
|
|
13
|
+
id: line.id,
|
|
14
|
+
name: line.name,
|
|
15
|
+
urlPath: line.urlPath,
|
|
16
|
+
color: line.color != null ? getHexCodesForColor(line.color) : null,
|
|
17
|
+
diagram: MultiversionalLineDiagramFoda.build(line.diagram).obj,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
toFodaV1() {
|
|
21
|
+
return {
|
|
22
|
+
id: this.obj.id,
|
|
23
|
+
name: this.obj.name,
|
|
24
|
+
urlPath: this.obj.urlPath,
|
|
25
|
+
color: this.obj.color,
|
|
26
|
+
diagram: new MultiversionalLineDiagramFoda(this.obj.diagram).toFodaV1(),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=multiversional-line-foda.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversional-line-foda.js","sourceRoot":"","sources":["../../../../../../api/handlers/foundational-data/multiversional/multiversional-line-foda.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,4FAA4F,CAAC;AAE3I,MAAM,OAAO,sBAAsB;IAEtB;IADX,YACW,GAAwD;QAAxD,QAAG,GAAH,GAAG,CAAqD;IAChE,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,IAAU;QACrB,OAAO,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5E,CAAC;IAEO,MAAM,CAAC,SAAS,CAAC,IAAU;QACjC,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;YAClE,OAAO,EAAE,6BAA6B,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG;SAC/D,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE;YACf,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;YACnB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;YACzB,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK;YACrB,OAAO,EAAE,IAAI,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE;SACxE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Stop } from "../../../../data/stop.js";
|
|
2
|
+
import type { stopFodaSchema as stopFodaV1Schema } from "../../../../../shared/apis/foundational-data/v1/foundational-data.js";
|
|
3
|
+
import type z from "zod";
|
|
4
|
+
export declare class MultiversionalStopFoda {
|
|
5
|
+
readonly obj: ReturnType<typeof MultiversionalStopFoda._buildObj>;
|
|
6
|
+
constructor(obj: ReturnType<typeof MultiversionalStopFoda._buildObj>);
|
|
7
|
+
static build(stop: Stop): MultiversionalStopFoda;
|
|
8
|
+
private static _buildObj;
|
|
9
|
+
toFodaV1(): z.input<typeof stopFodaV1Schema>;
|
|
10
|
+
}
|
package/server/dist/server/api/handlers/foundational-data/multiversional/multiversional-stop-foda.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class MultiversionalStopFoda {
|
|
2
|
+
obj;
|
|
3
|
+
constructor(obj) {
|
|
4
|
+
this.obj = obj;
|
|
5
|
+
}
|
|
6
|
+
static build(stop) {
|
|
7
|
+
return new MultiversionalStopFoda(MultiversionalStopFoda._buildObj(stop));
|
|
8
|
+
}
|
|
9
|
+
static _buildObj(stop) {
|
|
10
|
+
return {
|
|
11
|
+
id: stop.id,
|
|
12
|
+
name: stop.name,
|
|
13
|
+
urlPath: stop.urlPath,
|
|
14
|
+
canonicalLinesServingStop: stop.canonicalLinesServingStop,
|
|
15
|
+
location: stop.location != null
|
|
16
|
+
? {
|
|
17
|
+
latitude: stop.location.latitude,
|
|
18
|
+
longitude: stop.location.longitude,
|
|
19
|
+
}
|
|
20
|
+
: null,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
toFodaV1() {
|
|
24
|
+
return {
|
|
25
|
+
id: this.obj.id,
|
|
26
|
+
name: this.obj.name,
|
|
27
|
+
urlPath: this.obj.urlPath,
|
|
28
|
+
canonicalLinesServingStop: this.obj.canonicalLinesServingStop,
|
|
29
|
+
location: this.obj.location,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=multiversional-stop-foda.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversional-stop-foda.js","sourceRoot":"","sources":["../../../../../../api/handlers/foundational-data/multiversional/multiversional-stop-foda.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,sBAAsB;IAEtB;IADX,YACW,GAAwD;QAAxD,QAAG,GAAH,GAAG,CAAqD;IAChE,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,IAAU;QACrB,OAAO,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5E,CAAC;IAEO,MAAM,CAAC,SAAS,CAAC,IAAU;QACjC,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,yBAAyB,EAAE,IAAI,CAAC,yBAAyB;YACzD,QAAQ,EACN,IAAI,CAAC,QAAQ,IAAI,IAAI;gBACnB,CAAC,CAAC;oBACE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;oBAChC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS;iBACnC;gBACH,CAAC,CAAC,IAAI;SACX,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE;YACf,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;YACnB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;YACzB,yBAAyB,EAAE,IAAI,CAAC,GAAG,CAAC,yBAAyB;YAC7D,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ;SAC5B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { FOUNDATIONAL_DATA_V1 } from "../../../../../shared/apis/index.js";
|
|
2
2
|
import type { ApiContext } from "../../../types.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function handle(ctx: ApiContext, args:
|
|
3
|
+
import type { ServerArgsOf, ServerResultOf } from "../../../types.js";
|
|
4
|
+
export declare function handle(ctx: ApiContext, args: ServerArgsOf<typeof FOUNDATIONAL_DATA_V1>): Promise<ServerResultOf<typeof FOUNDATIONAL_DATA_V1>>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { FoundationalDataV1Builder } from "./builder.js";
|
|
2
1
|
export function handle(ctx, args) {
|
|
3
2
|
// await new Promise((resolve) => setTimeout(resolve, 500));
|
|
4
|
-
const
|
|
5
|
-
if (args.hash ===
|
|
3
|
+
const hash = ctx.app.foda.hash;
|
|
4
|
+
if (args.hash === hash) {
|
|
6
5
|
return Promise.resolve({ result: "up-to-date" });
|
|
7
6
|
}
|
|
8
|
-
return Promise.resolve({
|
|
7
|
+
return Promise.resolve({
|
|
8
|
+
result: "outdated",
|
|
9
|
+
foundationalData: ctx.app.foda.toFodaV1(),
|
|
10
|
+
});
|
|
9
11
|
}
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/foundational-data/v1/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/foundational-data/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,MAAM,CACpB,GAAe,EACf,IAA+C;IAE/C,4DAA4D;IAE5D,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;IAE/B,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,UAAU;QAClB,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE;KAC1C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SERVICE_V0 } from "../../../../../shared/apis/index.js";
|
|
2
2
|
import type { ApiContext } from "../../../types.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function handle(ctx: ApiContext, args:
|
|
3
|
+
import type { ServerArgsOf, ServerResultOf } from "../../../types.js";
|
|
4
|
+
export declare function handle(ctx: ApiContext, args: ServerArgsOf<typeof SERVICE_V0>): Promise<ServerResultOf<typeof SERVICE_V0>>;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { assertNever } from "@dan-schel/js-utils";
|
|
2
|
+
import { applyFodaSyncedResult } from "../../foda-synced-handler.js";
|
|
2
3
|
export async function handle(ctx, args) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
return applyFodaSyncedResult(ctx, async () => {
|
|
5
|
+
const service = await ctx.app.services.getService(args.sourceId, args.intrasourceId);
|
|
6
|
+
if (service == null)
|
|
7
|
+
return { service: null };
|
|
8
|
+
const lastStop = ctx.app.stops.require(service.termination.stopId).name;
|
|
9
|
+
return {
|
|
10
|
+
service: {
|
|
11
|
+
sourceId: service.sourceId,
|
|
12
|
+
intrasourceId: service.intrasourceId,
|
|
13
|
+
primaryDestinationText: lastStop,
|
|
14
|
+
lineIds: service.lineIds,
|
|
15
|
+
color: service.getColorHexCodes(),
|
|
16
|
+
isCancelled: service.isCancelled,
|
|
17
|
+
movements: service.movements.map((x) => toApiMovement(x)),
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
22
|
function toApiMovement(x) {
|
|
20
23
|
if (x.type === "originating") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/service/v0/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/service/v0/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,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../shared/apis/index.js";
|
|
2
2
|
import type { ApiContext } from "../../../types.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function handle(_ctx: ApiContext, _args:
|
|
3
|
+
import type { ServerArgsOf, ServerResultOf } from "../../../types.js";
|
|
4
|
+
export declare function handle(_ctx: ApiContext, _args: ServerArgsOf<typeof VERSION_CHECK_V1>): Promise<ServerResultOf<typeof VERSION_CHECK_V1>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/version-check/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,MAAM,CACpB,IAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/version-check/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,MAAM,CACpB,IAAgB,EAChB,KAA4C;IAE5C,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5E,2EAA2E;QAC3E,QAAQ;QACR,EAAE;QACF,wEAAwE;QACxE,0EAA0E;QAC1E,wEAAwE;QACxE,0EAA0E;QAC1E,qEAAqE;QACrE,sEAAsE;QACtE,yEAAyE;QACzE,sBAAsB;QACtB,oCAAoC,EAAE,KAAK;KAC5C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { VERSIONS_V1 } from "../../../../../shared/apis/index.js";
|
|
2
2
|
import type { ApiContext } from "../../../types.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function handle(ctx: ApiContext, _args:
|
|
3
|
+
import type { ServerArgsOf, ServerResultOf } from "../../../types.js";
|
|
4
|
+
export declare function handle(ctx: ApiContext, _args: ServerArgsOf<typeof VERSIONS_V1>): Promise<ServerResultOf<typeof VERSIONS_V1>>;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { FoundationalDataV1Builder } from "../../foundational-data/v1/builder.js";
|
|
2
1
|
export function handle(ctx, _args) {
|
|
3
|
-
const foda = new FoundationalDataV1Builder(ctx.app).build();
|
|
4
2
|
return Promise.resolve({
|
|
5
3
|
serverVersion: ctx.app.serverVersion,
|
|
6
4
|
frontendVersion: ctx.app.getFrontendVersion(),
|
|
7
5
|
corequeryPackageVersion: ctx.app.getCorequeryPackageVersion(),
|
|
8
|
-
foundationalDataHash: foda.
|
|
6
|
+
foundationalDataHash: ctx.app.foda.hash,
|
|
9
7
|
// Deprecated, but kept for backwards compatibility.
|
|
10
8
|
version: ctx.app.serverVersion,
|
|
11
9
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/versions/v1/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../api/handlers/versions/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,MAAM,CACpB,GAAe,EACf,KAAuC;IAEvC,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa;QACpC,eAAe,EAAE,GAAG,CAAC,GAAG,CAAC,kBAAkB,EAAE;QAC7C,uBAAuB,EAAE,GAAG,CAAC,GAAG,CAAC,0BAA0B,EAAE;QAC7D,oBAAoB,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI;QAEvC,oDAAoD;QACpD,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa;KAC/B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { Corequery } from "../corequery.js";
|
|
2
|
+
import type { Api } from "../../shared/apis/types.js";
|
|
2
3
|
import type { z, ZodType } from "zod";
|
|
4
|
+
export type ApiServer<Args, Result> = Api<z.ZodType<Args>, z.ZodType<unknown, Result>>;
|
|
5
|
+
export type ServerArgsOf<ApiType> = ApiType extends Api<ZodType<infer Args>, ZodType> ? Args : never;
|
|
6
|
+
export type ServerResultOf<ApiType> = ApiType extends Api<ZodType, ZodType<unknown, infer Result>> ? Result : never;
|
|
7
|
+
export type ServerFodaSyncedResultOf<ApiType> = ApiType extends Api<ZodType, ZodType<unknown, {
|
|
8
|
+
innerResult: infer Result;
|
|
9
|
+
}>> ? Result : never;
|
|
3
10
|
export type ApiContext = {
|
|
4
11
|
readonly app: Corequery;
|
|
5
12
|
};
|
|
6
|
-
export type ApiHandler<Args
|
|
13
|
+
export type ApiHandler<Args, Result> = (ctx: ApiContext, args: Args) => Promise<Result>;
|