@kerusiweb/core 2.0.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.
Files changed (95) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/dist/kerusi/index.d.ts +19 -0
  4. package/dist/kerusi/index.d.ts.map +1 -0
  5. package/dist/kerusi/index.js +19 -0
  6. package/dist/kerusi/index.js.map +1 -0
  7. package/dist/kerusi/kerusi-layout-mode.d.ts +58 -0
  8. package/dist/kerusi/kerusi-layout-mode.d.ts.map +1 -0
  9. package/dist/kerusi/kerusi-layout-mode.js +117 -0
  10. package/dist/kerusi/kerusi-layout-mode.js.map +1 -0
  11. package/dist/kerusi/kerusi-locale.d.ts +43 -0
  12. package/dist/kerusi/kerusi-locale.d.ts.map +1 -0
  13. package/dist/kerusi/kerusi-locale.js +111 -0
  14. package/dist/kerusi/kerusi-locale.js.map +1 -0
  15. package/dist/kerusi/kerusi-map.model.d.ts +258 -0
  16. package/dist/kerusi/kerusi-map.model.d.ts.map +1 -0
  17. package/dist/kerusi/kerusi-map.model.js +11 -0
  18. package/dist/kerusi/kerusi-map.model.js.map +1 -0
  19. package/dist/kerusi/kerusi-price.d.ts +22 -0
  20. package/dist/kerusi/kerusi-price.d.ts.map +1 -0
  21. package/dist/kerusi/kerusi-price.js +48 -0
  22. package/dist/kerusi/kerusi-price.js.map +1 -0
  23. package/dist/kerusi/kerusi-rows.d.ts +25 -0
  24. package/dist/kerusi/kerusi-rows.d.ts.map +1 -0
  25. package/dist/kerusi/kerusi-rows.js +36 -0
  26. package/dist/kerusi/kerusi-rows.js.map +1 -0
  27. package/dist/kerusi/kerusi-state.d.ts +85 -0
  28. package/dist/kerusi/kerusi-state.d.ts.map +1 -0
  29. package/dist/kerusi/kerusi-state.js +117 -0
  30. package/dist/kerusi/kerusi-state.js.map +1 -0
  31. package/dist/kerusi/kerusi-state.model.d.ts +79 -0
  32. package/dist/kerusi/kerusi-state.model.d.ts.map +1 -0
  33. package/dist/kerusi/kerusi-state.model.js +7 -0
  34. package/dist/kerusi/kerusi-state.model.js.map +1 -0
  35. package/dist/kerusi/kerusi-validator.d.ts +96 -0
  36. package/dist/kerusi/kerusi-validator.d.ts.map +1 -0
  37. package/dist/kerusi/kerusi-validator.js +525 -0
  38. package/dist/kerusi/kerusi-validator.js.map +1 -0
  39. package/dist/kerusi/kerusi-violation.d.ts +36 -0
  40. package/dist/kerusi/kerusi-violation.d.ts.map +1 -0
  41. package/dist/kerusi/kerusi-violation.js +13 -0
  42. package/dist/kerusi/kerusi-violation.js.map +1 -0
  43. package/dist/public-api.d.ts +4 -0
  44. package/dist/public-api.d.ts.map +1 -0
  45. package/dist/public-api.js +13 -0
  46. package/dist/public-api.js.map +1 -0
  47. package/dist/render/build-render-model.d.ts +36 -0
  48. package/dist/render/build-render-model.d.ts.map +1 -0
  49. package/dist/render/build-render-model.js +258 -0
  50. package/dist/render/build-render-model.js.map +1 -0
  51. package/dist/render/element-shapes.d.ts +34 -0
  52. package/dist/render/element-shapes.d.ts.map +1 -0
  53. package/dist/render/element-shapes.js +41 -0
  54. package/dist/render/element-shapes.js.map +1 -0
  55. package/dist/render/index.d.ts +14 -0
  56. package/dist/render/index.d.ts.map +1 -0
  57. package/dist/render/index.js +14 -0
  58. package/dist/render/index.js.map +1 -0
  59. package/dist/render/navigation-order.d.ts +49 -0
  60. package/dist/render/navigation-order.d.ts.map +1 -0
  61. package/dist/render/navigation-order.js +109 -0
  62. package/dist/render/navigation-order.js.map +1 -0
  63. package/dist/render/render-model.d.ts +151 -0
  64. package/dist/render/render-model.d.ts.map +1 -0
  65. package/dist/render/render-model.js +2 -0
  66. package/dist/render/render-model.js.map +1 -0
  67. package/dist/render/seat-shapes.d.ts +72 -0
  68. package/dist/render/seat-shapes.d.ts.map +1 -0
  69. package/dist/render/seat-shapes.js +161 -0
  70. package/dist/render/seat-shapes.js.map +1 -0
  71. package/dist/render/section-layout.d.ts +66 -0
  72. package/dist/render/section-layout.d.ts.map +1 -0
  73. package/dist/render/section-layout.js +173 -0
  74. package/dist/render/section-layout.js.map +1 -0
  75. package/dist/view/index.d.ts +12 -0
  76. package/dist/view/index.d.ts.map +1 -0
  77. package/dist/view/index.js +12 -0
  78. package/dist/view/index.js.map +1 -0
  79. package/dist/view/kerusi-seatmap-colors.d.ts +176 -0
  80. package/dist/view/kerusi-seatmap-colors.d.ts.map +1 -0
  81. package/dist/view/kerusi-seatmap-colors.js +215 -0
  82. package/dist/view/kerusi-seatmap-colors.js.map +1 -0
  83. package/dist/view/rtl.d.ts +17 -0
  84. package/dist/view/rtl.d.ts.map +1 -0
  85. package/dist/view/rtl.js +29 -0
  86. package/dist/view/rtl.js.map +1 -0
  87. package/dist/view/seat-aria.d.ts +44 -0
  88. package/dist/view/seat-aria.d.ts.map +1 -0
  89. package/dist/view/seat-aria.js +103 -0
  90. package/dist/view/seat-aria.js.map +1 -0
  91. package/dist/view/selection.d.ts +84 -0
  92. package/dist/view/selection.d.ts.map +1 -0
  93. package/dist/view/selection.js +98 -0
  94. package/dist/view/selection.js.map +1 -0
  95. package/package.json +42 -0
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Kerusi availability document types, transcribed from the Kerusi Seat Map and
3
+ * Availability Format v1.0.0-draft, §5. These describe the dynamic, per-seat
4
+ * booking status that is merged onto a static {@link KerusiMap} by `Seat.id`.
5
+ */
6
+ /** Per-seat availability status (§5.1). */
7
+ export interface SeatStatus {
8
+ /** REQUIRED. */
9
+ status: 'available' | 'held' | 'booked' | 'blocked';
10
+ /** RFC 3339 date-time (§5.1.1). Meaningful only when `status === "held"`. */
11
+ holdExpires?: string;
12
+ metadata?: Record<string, unknown>;
13
+ }
14
+ /**
15
+ * A complete availability snapshot (§5.1). A seat absent from `seats` MUST be
16
+ * interpreted as `"available"` — this sparse convention keeps state documents
17
+ * small for large venues.
18
+ */
19
+ export interface KerusiState {
20
+ /** REQUIRED. */
21
+ kerusi: '1.0';
22
+ /**
23
+ * Matches `KerusiSession.id`. RECOMMENDED when the referenced map is reused
24
+ * across many events (§5.3).
25
+ */
26
+ sessionId?: string;
27
+ /**
28
+ * Matches `KerusiMap.id` directly, for documents with no separate session
29
+ * concept. Exactly one of `sessionId`/`mapId` MUST be present.
30
+ */
31
+ mapId?: string;
32
+ /** REQUIRED. RFC 3339 date-time (§5.1.1). */
33
+ updatedAt: string;
34
+ /** REQUIRED. Keyed by `Seat.id`. Only non-default entries need be included. */
35
+ seats: Record<string, SeatStatus>;
36
+ }
37
+ /**
38
+ * An incremental update over a push transport (§5.2). Unlike {@link KerusiState},
39
+ * EVERY entry in `changes` is an explicit change and omission means "unchanged"
40
+ * — the opposite of KerusiState's sparse rule.
41
+ */
42
+ export interface KerusiStateDelta {
43
+ /** REQUIRED. */
44
+ kerusi: '1.0';
45
+ /** Same either/or rule as {@link KerusiState}. */
46
+ sessionId?: string;
47
+ mapId?: string;
48
+ /**
49
+ * REQUIRED. RFC 3339 date-time (§5.1.1), strictly increasing per session/map
50
+ * so a consumer can detect and discard an out-of-order delta.
51
+ */
52
+ updatedAt: string;
53
+ /**
54
+ * REQUIRED. Keyed by `Seat.id`. Every entry IS a change; an explicit
55
+ * `{ "status": "available" }` signals a seat reverting. A seat's absence
56
+ * means "unchanged".
57
+ */
58
+ changes: Record<string, SeatStatus>;
59
+ }
60
+ /**
61
+ * The optional join between a specific event/showtime/flight and a reusable
62
+ * {@link KerusiMap} (§5.3). `KerusiState`/`KerusiStateDelta` reference the
63
+ * session via `sessionId` when a session exists.
64
+ */
65
+ export interface KerusiSession {
66
+ /** REQUIRED. */
67
+ kerusi: '1.0';
68
+ /** REQUIRED. Unique session id, e.g. "MH123-2026-08-17". */
69
+ id: string;
70
+ /** REQUIRED. References the reusable `KerusiMap.id`. */
71
+ mapId: string;
72
+ /** e.g. "Dune: Part Three — 7:30pm", "MH123, 17 Aug 2026". */
73
+ label?: string;
74
+ /** RFC 3339 date-time (§5.1.1) — showtime / departure / event start. */
75
+ startsAt?: string;
76
+ endsAt?: string;
77
+ metadata?: Record<string, unknown>;
78
+ }
79
+ //# sourceMappingURL=kerusi-state.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kerusi-state.model.d.ts","sourceRoot":"","sources":["../../src/kerusi/kerusi-state.model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACzB,gBAAgB;IAChB,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACpD,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB;IAChB,MAAM,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB;IAChB,MAAM,EAAE,KAAK,CAAC;IACd,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACrC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,gBAAgB;IAChB,MAAM,EAAE,KAAK,CAAC;IACd,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAC;IACX,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Kerusi availability document types, transcribed from the Kerusi Seat Map and
3
+ * Availability Format v1.0.0-draft, §5. These describe the dynamic, per-seat
4
+ * booking status that is merged onto a static {@link KerusiMap} by `Seat.id`.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=kerusi-state.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kerusi-state.model.js","sourceRoot":"","sources":["../../src/kerusi/kerusi-state.model.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,96 @@
1
+ import { KerusiMap } from './kerusi-map.model.js';
2
+ import { KerusiSession, KerusiState, KerusiStateDelta } from './kerusi-state.model.js';
3
+ import { KerusiViolation } from './kerusi-violation.js';
4
+ export { errorsOf } from './kerusi-violation.js';
5
+ export type { KerusiViolation, ViolationSeverity } from './kerusi-violation.js';
6
+ /**
7
+ * Thrown when a Kerusi document violates a MUST-level rule in the standard.
8
+ * The message names the failing rule and the id that triggered it, so a
9
+ * malformed document is diagnosable rather than surfacing as a generic parse
10
+ * error (spec §4.6, §7).
11
+ *
12
+ * `violations` carries every finding from the same pass, not just the one that
13
+ * was thrown — useful when reporting a document's problems all at once. Use the
14
+ * non-throwing `checkKerusi*` functions when that is the primary goal.
15
+ */
16
+ export declare class KerusiValidationError extends Error {
17
+ /** Short slug of the violated rule, e.g. "seat-type-reference". */
18
+ readonly rule: string;
19
+ /** The id (seat, section, tier, ...) that triggered the failure, if any. */
20
+ readonly id?: string | undefined;
21
+ /** Every violation found in the same pass, in document order. */
22
+ readonly violations: readonly KerusiViolation[];
23
+ constructor(message: string,
24
+ /** Short slug of the violated rule, e.g. "seat-type-reference". */
25
+ rule: string,
26
+ /** The id (seat, section, tier, ...) that triggered the failure, if any. */
27
+ id?: string | undefined,
28
+ /** Every violation found in the same pass, in document order. */
29
+ violations?: readonly KerusiViolation[]);
30
+ }
31
+ /**
32
+ * Collects every conformance violation in a {@link KerusiMap}, in document
33
+ * order, without throwing. An empty array means the map is valid.
34
+ *
35
+ * Accepts `unknown` so it can be pointed at freshly parsed JSON: a value that
36
+ * isn't a usable map yields a shape violation rather than a crash.
37
+ */
38
+ export declare function checkKerusiMap(map: unknown): readonly KerusiViolation[];
39
+ /** Collects every violation in a {@link KerusiState} without throwing. */
40
+ export declare function checkKerusiState(state: unknown): readonly KerusiViolation[];
41
+ /** Collects every violation in a {@link KerusiStateDelta} without throwing. */
42
+ export declare function checkKerusiStateDelta(delta: unknown): readonly KerusiViolation[];
43
+ /** Collects every violation in a {@link KerusiSession} without throwing (§5.3). */
44
+ export declare function checkKerusiSession(session: unknown): readonly KerusiViolation[];
45
+ /**
46
+ * Validates a map together with the session and/or state that reference it,
47
+ * checking the joins the individual validators cannot see (§5.1, §5.3): a
48
+ * state's `mapId` must be the map's id, its `sessionId` the session's, and the
49
+ * session's `mapId` the map's.
50
+ */
51
+ export declare function validateDocumentSet(docs: {
52
+ map: KerusiMap;
53
+ state?: KerusiState;
54
+ session?: KerusiSession;
55
+ }): readonly KerusiViolation[];
56
+ /**
57
+ * Validates a {@link KerusiMap} against the MUST-level rules of spec §4.
58
+ * Throws {@link KerusiValidationError} on the first violation; returns the map
59
+ * unchanged when valid, so it can be used inline.
60
+ *
61
+ * Enforced rules:
62
+ * - Required members present: `kerusi`, `id`, `legend`, `sections` (§4), and
63
+ * `kerusi` declares a supported major version.
64
+ * - Every seat has `col`, or `x`+`y`, or both — never neither (§4.3.1) — and
65
+ * conforms to its section's declared or inferred `layout` mode (§4.5).
66
+ * - Section, seat and element ids are unique (§4.1, §4.3, §4.4).
67
+ * - Every `Seat.type` resolves to a `SeatType.id` in `legend` (§4.6).
68
+ * - Every `Seat.priceTier` resolves to a `PriceTier.id` (§4.6).
69
+ * - Every `Seat.row` resolves to a `RowMeta.id` when the section declares
70
+ * `rows`; opaque free-text otherwise (§4.6).
71
+ * - Every `Seat.companions[]` entry resolves to another seat in the SAME
72
+ * section, and the relationship is symmetric (§4.6).
73
+ * - Every `Element` has the required `id` and `kind` (§4.4), is positioned in
74
+ * its section's own layout mode, and — in a grid section — carries integer
75
+ * column and row spans that stay inside the section's rows (§4.4.1, §4.6).
76
+ * - All resolved currencies across the map are identical (§4.9).
77
+ *
78
+ * Advisory findings never throw; use {@link checkKerusiMap} to see them.
79
+ */
80
+ export declare function validateKerusiMap(map: KerusiMap): KerusiMap;
81
+ /**
82
+ * Validates a {@link KerusiState} against the MUST-level rules of spec §5.1,
83
+ * including the RFC 3339 timestamp profile of §5.1.1:
84
+ * `kerusi` present and supported, `updatedAt` present, exactly one of
85
+ * `sessionId`/`mapId`, and a `seats` object.
86
+ */
87
+ export declare function validateKerusiState(state: KerusiState): KerusiState;
88
+ /**
89
+ * Validates a {@link KerusiStateDelta} against the MUST-level rules of §5.2:
90
+ * `kerusi` present and supported, `updatedAt` present, exactly one of
91
+ * `sessionId`/`mapId`, and a `changes` object.
92
+ */
93
+ export declare function validateKerusiStateDelta(delta: KerusiStateDelta): KerusiStateDelta;
94
+ /** Validates a {@link KerusiSession} against §5.3. */
95
+ export declare function validateKerusiSession(session: KerusiSession): KerusiSession;
96
+ //# sourceMappingURL=kerusi-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kerusi-validator.d.ts","sourceRoot":"","sources":["../../src/kerusi/kerusi-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,SAAS,EAAiB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAc,MAAM,yBAAyB,CAAC;AAUnG,OAAO,EAAmB,eAAe,EAAW,MAAM,uBAAuB,CAAC;AAElF,OAAO,EAAE,QA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