@ramme-io/shared 3.6.0 → 4.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.
- package/README.md +0 -2
- package/dist/index.cjs +827 -459
- package/dist/index.d.cts +31599 -1363
- package/dist/index.d.ts +31599 -1363
- package/dist/index.js +773 -426
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -166,8 +166,10 @@ var SIGNAL_DOMAINS = {
|
|
|
166
166
|
// Track C — latency, uptime, queue depth
|
|
167
167
|
USER_BEHAVIOR: "user_behavior",
|
|
168
168
|
// Track D — engagement, conversion, NPS
|
|
169
|
-
LOGIC: "logic"
|
|
169
|
+
LOGIC: "logic",
|
|
170
170
|
// Derived — Methodology Engine outputs
|
|
171
|
+
ENVIRONMENT: "environment"
|
|
172
|
+
// A device's surroundings — temperature, humidity, light
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
// src/signals/base.schema.ts
|
|
@@ -458,7 +460,30 @@ var AppSourceSchema = z6.discriminatedUnion("kind", [
|
|
|
458
460
|
z6.object({
|
|
459
461
|
kind: z6.literal("cycle"),
|
|
460
462
|
count: z6.number().int().min(2).max(12),
|
|
461
|
-
minutes: z6.number().int().min(1).max(1440).default(5)
|
|
463
|
+
minutes: z6.number().int().min(1).max(1440).default(5),
|
|
464
|
+
/**
|
|
465
|
+
* A turn shorter than a minute — a slideshow at 5, 15 or 30 seconds. Wins
|
|
466
|
+
* over `minutes` where it is given; `minutes` stays the nearest whole
|
|
467
|
+
* minute, so a board whose firmware predates this still takes turns,
|
|
468
|
+
* once a minute. Counted the same way: seconds since 1970, in turns.
|
|
469
|
+
*/
|
|
470
|
+
seconds: z6.number().int().min(5).max(86400).optional()
|
|
471
|
+
}),
|
|
472
|
+
/**
|
|
473
|
+
* The board's own parts: what a sensor plugged into the board it is drawn
|
|
474
|
+
* on is reading right now (docs/superpowers/specs/ramme-lab.md, "The
|
|
475
|
+
* differentiator"). Fields: `temperature`, from a temperature probe, a
|
|
476
|
+
* whole number in `units` like the weather's; and `connected`, whether a
|
|
477
|
+
* probe is plugged in at all. A board with nothing plugged in has no
|
|
478
|
+
* `temperature`, so a binding to it draws the placeholder.
|
|
479
|
+
*
|
|
480
|
+
* The board fills it from the probe (drawApp() in the sketch); a page
|
|
481
|
+
* previewing that board fills it from the readings the board reported
|
|
482
|
+
* (useAppData); the Studio, with no board, shows the placeholder.
|
|
483
|
+
*/
|
|
484
|
+
z6.object({
|
|
485
|
+
kind: z6.literal("board"),
|
|
486
|
+
units: z6.enum(["imperial", "metric"]).default("imperial")
|
|
462
487
|
})
|
|
463
488
|
]);
|
|
464
489
|
var AppOperandSchema = z6.union([
|
|
@@ -631,6 +656,11 @@ var AppGroupSchema = z6.object({
|
|
|
631
656
|
children: z6.array(AppLeafSchema).min(1).max(8)
|
|
632
657
|
});
|
|
633
658
|
var AppBlockSchema = z6.union([AppLeafSchema, AppGroupSchema]);
|
|
659
|
+
var PanelOrientationSchema = z6.enum(["landscape", "portrait"]);
|
|
660
|
+
var PANEL_SIZE = {
|
|
661
|
+
landscape: { width: 320, height: 240 },
|
|
662
|
+
portrait: { width: 240, height: 320 }
|
|
663
|
+
};
|
|
634
664
|
var AppScreenSizeSchema = z6.preprocess(
|
|
635
665
|
(value) => value === "240x320" ? "320x240" : value,
|
|
636
666
|
z6.enum(["320x240"])
|
|
@@ -651,6 +681,27 @@ var AppDocumentSchema = z6.object({
|
|
|
651
681
|
* block off the glass. Older firmware draws from the top.
|
|
652
682
|
*/
|
|
653
683
|
valign: z6.enum(["start", "center"]).optional(),
|
|
684
|
+
/**
|
|
685
|
+
* Where the blocks sit across the screen as a whole. `center` makes a column
|
|
686
|
+
* as wide as the widest block and centres that column, so left-aligned lines
|
|
687
|
+
* stay aligned with each other and the group sits in the middle — rather
|
|
688
|
+
* than every line hugging the left edge with the right half empty. Widths
|
|
689
|
+
* are the board's (see `pack`); a block with no width of its own, like an
|
|
690
|
+
* equal-celled row or a bar, fills the screen and leaves nothing to centre.
|
|
691
|
+
* Older firmware draws from the left.
|
|
692
|
+
*/
|
|
693
|
+
halign: z6.enum(["start", "center"]).optional(),
|
|
694
|
+
/**
|
|
695
|
+
* The lettering. `inter` (the default) is Inter, anti-aliased, drawn at
|
|
696
|
+
* each text size from its own font — SMOOTH_FONT_ADVANCES in
|
|
697
|
+
* ./deviceFonts.generated.ts are its widths. `pixel` is the board's
|
|
698
|
+
* built-in 5x7 bitmap font scaled up: the retro look, chunky on purpose.
|
|
699
|
+
* `tay` is TAY Dreamboat, the Ramme display face — capitals only, so
|
|
700
|
+
* lowercase is drawn as capitals; best for signs, times and numbers.
|
|
701
|
+
* Firmware older than 2026-10-18 draws everything in pixel, and older than
|
|
702
|
+
* 2026-10-20 draws `tay` as Inter.
|
|
703
|
+
*/
|
|
704
|
+
font: z6.enum(["inter", "pixel", "tay"]).optional(),
|
|
654
705
|
/** Named so bindings can refer to them. */
|
|
655
706
|
sources: z6.record(AppSourceSchema).default({}),
|
|
656
707
|
blocks: z6.array(AppBlockSchema).min(1).max(12)
|
|
@@ -740,82 +791,32 @@ var PhotoSummarySchema = z7.object({
|
|
|
740
791
|
});
|
|
741
792
|
|
|
742
793
|
// src/apps/delivery.ts
|
|
743
|
-
import { z as
|
|
744
|
-
var DeviceIdSchema = z8.string().regex(/^[0-9A-HJKMNP-TV-Z]{8}$/, "eight characters, no I L O or U");
|
|
745
|
-
var PairCodeSchema = z8.string().regex(/^\d{4}$/);
|
|
746
|
-
var DeviceRegistrationSchema = z8.object({
|
|
747
|
-
deviceId: DeviceIdSchema,
|
|
748
|
-
code: PairCodeSchema,
|
|
749
|
-
/** Firmware build, so a support question has an answer. */
|
|
750
|
-
version: z8.string().max(40).optional(),
|
|
751
|
-
/** Which board this is, from Boards.h — the two variants need different firmware. */
|
|
752
|
-
board: z8.string().max(40).optional(),
|
|
753
|
-
/** dBm, always negative. -50 is across the room; -85 is a complaint. */
|
|
754
|
-
rssi: z8.number().int().min(-127).max(0).optional(),
|
|
755
|
-
/** On the owner's own network. Long enough for IPv6, which this does not send yet. */
|
|
756
|
-
ip: z8.string().max(45).optional(),
|
|
757
|
-
/** Seconds since boot. Not growing between check-ins means it is restarting. */
|
|
758
|
-
uptime: z8.number().int().nonnegative().optional(),
|
|
759
|
-
/** Free heap in bytes. */
|
|
760
|
-
heap: z8.number().int().nonnegative().optional(),
|
|
761
|
-
/** The app revision the board has actually drawn. */
|
|
762
|
-
drew: z8.number().int().nonnegative().optional(),
|
|
763
|
-
/** Why it last restarted, already mapped to a word by the firmware. */
|
|
764
|
-
reset: z8.string().max(40).optional()
|
|
765
|
-
});
|
|
766
|
-
var SendRequestSchema = z8.object({
|
|
767
|
-
deviceId: DeviceIdSchema,
|
|
768
|
-
code: PairCodeSchema
|
|
769
|
-
});
|
|
770
|
-
var OwnedSendRequestSchema = z8.object({
|
|
771
|
-
deviceId: DeviceIdSchema
|
|
772
|
-
});
|
|
773
|
-
var DeliveredAppSchema = z8.object({
|
|
774
|
-
revision: z8.number().int().nonnegative(),
|
|
775
|
-
sentAt: z8.number().int().nonnegative()
|
|
776
|
-
});
|
|
777
|
-
var DeviceRecordSchema = z8.object({
|
|
778
|
-
deviceId: DeviceIdSchema,
|
|
779
|
-
code: PairCodeSchema,
|
|
780
|
-
ownerId: z8.string().nullable().default(null),
|
|
781
|
-
version: z8.string().max(40).optional(),
|
|
782
|
-
createdAt: z8.number().int().nonnegative(),
|
|
783
|
-
lastSeenAt: z8.number().int().nonnegative()
|
|
784
|
-
});
|
|
785
|
-
var DEVICE_LABEL_MAX = 48;
|
|
786
|
-
var DEVICE_TTL_SECONDS = 60 * 60 * 24 * 30;
|
|
787
|
-
var CLAIMED_DEVICE_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
788
|
-
var FirmwareUpdateSchema = z8.object({
|
|
789
|
-
version: z8.string().min(1).max(40),
|
|
790
|
-
url: z8.string().url().max(200),
|
|
791
|
-
sha256: z8.string().regex(/^[0-9a-f]{64}$/),
|
|
792
|
-
bytes: z8.number().int().positive(),
|
|
793
|
-
requestedAt: z8.number().int().nonnegative()
|
|
794
|
-
});
|
|
795
|
-
var FIRMWARE_UPDATE_PREFIX = "https://www.ramme.io/firmware/weather-display/";
|
|
796
|
-
var FIRMWARE_UPDATE_ATTEMPTS = 3;
|
|
794
|
+
import { z as z9 } from "zod";
|
|
797
795
|
|
|
798
796
|
// src/apps/vitals.ts
|
|
799
|
-
import { z as
|
|
800
|
-
var VitalSourceSchema =
|
|
801
|
-
var
|
|
797
|
+
import { z as z8 } from "zod";
|
|
798
|
+
var VitalSourceSchema = z8.enum(["register", "poll", "send"]);
|
|
799
|
+
var DeviceFeatureStateSchema = z8.enum(["working", "missing", "unsupported", "fault"]);
|
|
800
|
+
var DeviceFeatureKeySchema = z8.string().regex(/^[a-z][a-z0-9-]{0,23}$/);
|
|
801
|
+
var DeviceFeaturesSchema = z8.record(DeviceFeatureKeySchema, DeviceFeatureStateSchema).refine((f) => Object.keys(f).length <= 16, { message: "at most 16 features" });
|
|
802
|
+
var DeviceVitalsSchema = z8.object({
|
|
802
803
|
/** When the board last said any of this, by the server's clock. */
|
|
803
|
-
reportedAt:
|
|
804
|
+
reportedAt: z8.number().int().nonnegative().optional(),
|
|
804
805
|
/**
|
|
805
806
|
* The firmware build. Today every board sends the literal "doc-1", which is a
|
|
806
807
|
* protocol marker rather than a build id — so this is shown as reported and
|
|
807
808
|
* labelled as not yet a version. The real value lives in the published
|
|
808
809
|
* manifest until firmware carries it.
|
|
809
810
|
*/
|
|
810
|
-
firmwareVersion:
|
|
811
|
+
firmwareVersion: z8.string().max(40).optional(),
|
|
811
812
|
/** Which board this is. Nothing distinguishes a CYD from a Freenove S3 yet. */
|
|
812
|
-
board:
|
|
813
|
+
board: z8.string().max(40).optional(),
|
|
813
814
|
/** dBm, negative. -50 is across the room, -85 is a complaint. */
|
|
814
|
-
rssi:
|
|
815
|
+
rssi: z8.number().int().min(-127).max(0).optional(),
|
|
815
816
|
/** The board's address on its own network, as the board sees it. */
|
|
816
|
-
ip:
|
|
817
|
-
uptimeSeconds:
|
|
818
|
-
freeHeapBytes:
|
|
817
|
+
ip: z8.string().max(45).optional(),
|
|
818
|
+
uptimeSeconds: z8.number().int().nonnegative().optional(),
|
|
819
|
+
freeHeapBytes: z8.number().int().nonnegative().optional(),
|
|
819
820
|
/**
|
|
820
821
|
* The revision the board is actually showing.
|
|
821
822
|
*
|
|
@@ -823,30 +824,69 @@ var DeviceVitalsSchema = z9.object({
|
|
|
823
824
|
* value: a send that was never drawn looks identical to a successful one until
|
|
824
825
|
* these two numbers disagree.
|
|
825
826
|
*/
|
|
826
|
-
drewRevision:
|
|
827
|
+
drewRevision: z8.number().int().nonnegative().optional(),
|
|
827
828
|
/** Why it last restarted, if it says. A board power-cycling in a loop is a fault. */
|
|
828
|
-
resetReason:
|
|
829
|
+
resetReason: z8.string().max(40).optional(),
|
|
830
|
+
/** Its parts and whether each works — see `DeviceFeaturesSchema`. */
|
|
831
|
+
features: DeviceFeaturesSchema.optional(),
|
|
829
832
|
/** When it last polled — finer-grained than a registration, for liveness only. */
|
|
830
|
-
lastPollAt:
|
|
833
|
+
lastPollAt: z8.number().int().nonnegative().optional()
|
|
831
834
|
});
|
|
832
|
-
var DeviceSeenSchema =
|
|
835
|
+
var DeviceSeenSchema = z8.object({
|
|
833
836
|
/** When the board last asked for its app. The freshest signal this system has. */
|
|
834
|
-
lastPollAt:
|
|
837
|
+
lastPollAt: z8.number().int().nonnegative(),
|
|
835
838
|
/** The revision it reported drawing at that moment. */
|
|
836
|
-
drewRevision:
|
|
839
|
+
drewRevision: z8.number().int().nonnegative().optional(),
|
|
837
840
|
/**
|
|
838
841
|
* The firmware it is running, sent on every poll by builds that can update
|
|
839
842
|
* remotely — so its presence is also the answer to "can this board be
|
|
840
843
|
* updated from its page?". Registration reports the version too, but only
|
|
841
844
|
* every six hours; after a remote update this is what shows it took.
|
|
842
845
|
*/
|
|
843
|
-
firmware:
|
|
846
|
+
firmware: z8.string().max(40).optional(),
|
|
844
847
|
/** Photos its app names, and how many of those it holds in flash. */
|
|
845
|
-
photosWanted:
|
|
846
|
-
photosHeld:
|
|
848
|
+
photosWanted: z8.number().int().nonnegative().optional(),
|
|
849
|
+
photosHeld: z8.number().int().nonnegative().optional(),
|
|
847
850
|
/** What happened to the last firmware update it tried, in a few words. */
|
|
848
|
-
updateResult:
|
|
849
|
-
|
|
851
|
+
updateResult: z8.string().max(80).optional(),
|
|
852
|
+
/**
|
|
853
|
+
* What the battery line reads, in millivolts — S3 boards only, which have a
|
|
854
|
+
* divider on GPIO9; a CYD has no way to measure a battery. Shown raw on the
|
|
855
|
+
* board's page until it has been checked against a real battery, and only
|
|
856
|
+
* then turned into an icon and a percentage on the glass.
|
|
857
|
+
*/
|
|
858
|
+
batteryMv: z8.number().int().min(0).max(1e4).optional(),
|
|
859
|
+
/**
|
|
860
|
+
* The quarter turn its screen is set to (Settings → Turn), 0-3 as LovyanGFX
|
|
861
|
+
* counts them: even is upright, odd is sideways, the board's 240x320 panel
|
|
862
|
+
* turned. Its page previews apps the way the board stands (PANEL_SIZE).
|
|
863
|
+
* Absent from a board older than 2026-10-28, which only ever stood sideways.
|
|
864
|
+
*/
|
|
865
|
+
rotation: z8.number().int().min(0).max(3).optional()
|
|
866
|
+
});
|
|
867
|
+
var DeviceReadingSchema = z8.object({
|
|
868
|
+
key: DeviceFeatureKeySchema,
|
|
869
|
+
value: z8.union([z8.number().finite(), z8.string().max(64), z8.boolean()]),
|
|
870
|
+
unit: z8.string().max(16).optional(),
|
|
871
|
+
at: z8.number().int().nonnegative().optional()
|
|
872
|
+
});
|
|
873
|
+
var DeviceReportSchema = z8.object({
|
|
874
|
+
readings: z8.array(DeviceReadingSchema).min(1).max(16)
|
|
875
|
+
});
|
|
876
|
+
var DEVICE_FEATURES = [
|
|
877
|
+
{ key: "screen", label: "Screen" },
|
|
878
|
+
{ key: "touch", label: "Touch" },
|
|
879
|
+
{ key: "speaker", label: "Speaker" },
|
|
880
|
+
{ key: "microphone", label: "Microphone" },
|
|
881
|
+
{ key: "battery", label: "Battery" },
|
|
882
|
+
{ key: "temperature", label: "Temperature probe" }
|
|
883
|
+
];
|
|
884
|
+
var DEVICE_FEATURE_STATE_LABELS = {
|
|
885
|
+
working: "Working",
|
|
886
|
+
missing: "None on this board",
|
|
887
|
+
unsupported: "Not supported yet",
|
|
888
|
+
fault: "Not working"
|
|
889
|
+
};
|
|
850
890
|
var DEVICE_VITALS_FIELDS = [
|
|
851
891
|
{
|
|
852
892
|
key: "firmwareVersion",
|
|
@@ -867,11 +907,84 @@ var DEVICE_VITALS_FIELDS = [
|
|
|
867
907
|
source: "register",
|
|
868
908
|
reportedByFirmware: true
|
|
869
909
|
},
|
|
870
|
-
{ key: "resetReason", label: "Last restart", source: "register", reportedByFirmware: true }
|
|
910
|
+
{ key: "resetReason", label: "Last restart", source: "register", reportedByFirmware: true },
|
|
911
|
+
{
|
|
912
|
+
key: "batteryMv",
|
|
913
|
+
label: "Battery line",
|
|
914
|
+
unit: "mV",
|
|
915
|
+
source: "poll",
|
|
916
|
+
reportedByFirmware: true,
|
|
917
|
+
note: "Black (S3) boards only, raw and not yet calibrated. A yellow board cannot measure a battery."
|
|
918
|
+
}
|
|
871
919
|
];
|
|
872
920
|
var DEVICE_FRESH_MS = 7 * 60 * 60 * 1e3;
|
|
873
921
|
var DEVICE_STALE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
874
922
|
|
|
923
|
+
// src/apps/delivery.ts
|
|
924
|
+
var DeviceIdSchema = z9.string().regex(/^[0-9A-HJKMNP-TV-Z]{8}$/, "eight characters, no I L O or U");
|
|
925
|
+
var PairCodeSchema = z9.string().regex(/^\d{4}$/);
|
|
926
|
+
var DeviceRegistrationSchema = z9.object({
|
|
927
|
+
deviceId: DeviceIdSchema,
|
|
928
|
+
code: PairCodeSchema,
|
|
929
|
+
/** Firmware build, so a support question has an answer. */
|
|
930
|
+
version: z9.string().max(40).optional(),
|
|
931
|
+
/** Which board this is, from Boards.h — the two variants need different firmware. */
|
|
932
|
+
board: z9.string().max(40).optional(),
|
|
933
|
+
/** dBm, always negative. -50 is across the room; -85 is a complaint. */
|
|
934
|
+
rssi: z9.number().int().min(-127).max(0).optional(),
|
|
935
|
+
/** On the owner's own network. Long enough for IPv6, which this does not send yet. */
|
|
936
|
+
ip: z9.string().max(45).optional(),
|
|
937
|
+
/** Seconds since boot. Not growing between check-ins means it is restarting. */
|
|
938
|
+
uptime: z9.number().int().nonnegative().optional(),
|
|
939
|
+
/** Free heap in bytes. */
|
|
940
|
+
heap: z9.number().int().nonnegative().optional(),
|
|
941
|
+
/** The app revision the board has actually drawn. */
|
|
942
|
+
drew: z9.number().int().nonnegative().optional(),
|
|
943
|
+
/** Why it last restarted, already mapped to a word by the firmware. */
|
|
944
|
+
reset: z9.string().max(40).optional(),
|
|
945
|
+
/**
|
|
946
|
+
* What the board has and whether each part works: "speaker: working",
|
|
947
|
+
* "battery: missing". This describes the device — its own hardware, as its
|
|
948
|
+
* own check screen reports it — and never the room: a state, not a reading.
|
|
949
|
+
* What the microphone heard, a sensor's value, or anything a part could
|
|
950
|
+
* learn about its surroundings does not belong here and is not representable
|
|
951
|
+
* (DeviceFeatureStateSchema is four words). Readings, when they come, travel
|
|
952
|
+
* as Signals and are argued for on their own.
|
|
953
|
+
*/
|
|
954
|
+
features: DeviceFeaturesSchema.optional()
|
|
955
|
+
});
|
|
956
|
+
var SendRequestSchema = z9.object({
|
|
957
|
+
deviceId: DeviceIdSchema,
|
|
958
|
+
code: PairCodeSchema
|
|
959
|
+
});
|
|
960
|
+
var OwnedSendRequestSchema = z9.object({
|
|
961
|
+
deviceId: DeviceIdSchema
|
|
962
|
+
});
|
|
963
|
+
var DeliveredAppSchema = z9.object({
|
|
964
|
+
revision: z9.number().int().nonnegative(),
|
|
965
|
+
sentAt: z9.number().int().nonnegative()
|
|
966
|
+
});
|
|
967
|
+
var DeviceRecordSchema = z9.object({
|
|
968
|
+
deviceId: DeviceIdSchema,
|
|
969
|
+
code: PairCodeSchema,
|
|
970
|
+
ownerId: z9.string().nullable().default(null),
|
|
971
|
+
version: z9.string().max(40).optional(),
|
|
972
|
+
createdAt: z9.number().int().nonnegative(),
|
|
973
|
+
lastSeenAt: z9.number().int().nonnegative()
|
|
974
|
+
});
|
|
975
|
+
var DEVICE_LABEL_MAX = 48;
|
|
976
|
+
var DEVICE_TTL_SECONDS = 60 * 60 * 24 * 30;
|
|
977
|
+
var CLAIMED_DEVICE_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
978
|
+
var FirmwareUpdateSchema = z9.object({
|
|
979
|
+
version: z9.string().min(1).max(40),
|
|
980
|
+
url: z9.string().url().max(200),
|
|
981
|
+
sha256: z9.string().regex(/^[0-9a-f]{64}$/),
|
|
982
|
+
bytes: z9.number().int().positive(),
|
|
983
|
+
requestedAt: z9.number().int().nonnegative()
|
|
984
|
+
});
|
|
985
|
+
var FIRMWARE_UPDATE_PREFIX = "https://www.ramme.io/firmware/weather-display/";
|
|
986
|
+
var FIRMWARE_UPDATE_ATTEMPTS = 3;
|
|
987
|
+
|
|
875
988
|
// src/apps/glyphs.ts
|
|
876
989
|
var DEVICE_UNKNOWN_GLYPH = "?";
|
|
877
990
|
var DEVICE_GLYPHS = {
|
|
@@ -947,6 +1060,7 @@ var DEVICE_GLYPHS = {
|
|
|
947
1060
|
"\u2212": { byte: 45, shows: "-" },
|
|
948
1061
|
"\xA0": { byte: 32, shows: " " }
|
|
949
1062
|
};
|
|
1063
|
+
var DISPLAY_FACE_MIN_PX = 28;
|
|
950
1064
|
var DEVICE_PALETTE = {
|
|
951
1065
|
background: "17 17 17",
|
|
952
1066
|
foreground: "238 238 238",
|
|
@@ -1077,74 +1191,158 @@ var WEATHER_ICONS = {
|
|
|
1077
1191
|
]
|
|
1078
1192
|
};
|
|
1079
1193
|
|
|
1080
|
-
// src/
|
|
1194
|
+
// src/apps/shelf.ts
|
|
1081
1195
|
import { z as z10 } from "zod";
|
|
1082
|
-
var
|
|
1083
|
-
|
|
1084
|
-
|
|
1196
|
+
var SHELF_MAX_APPS = 8;
|
|
1197
|
+
var SHELF_MAX_BYTES = 24e3;
|
|
1198
|
+
var SHELF_ROTATE_MINUTES = [0, 1, 5, 15, 30, 60];
|
|
1199
|
+
var ShelfSchema = z10.object({
|
|
1200
|
+
apps: z10.array(AppDocumentSchema).min(1).max(SHELF_MAX_APPS),
|
|
1201
|
+
/** Which app to show — an index into `apps`. */
|
|
1202
|
+
show: z10.number().int().min(0).max(SHELF_MAX_APPS - 1),
|
|
1203
|
+
/** Move to the next app every this many minutes; 0 holds still. */
|
|
1204
|
+
rotateMinutes: z10.number().int().min(0).max(1440).default(0),
|
|
1205
|
+
/**
|
|
1206
|
+
* When each app was last sent, aligned with `apps`. The server's
|
|
1207
|
+
* bookkeeping, not the board's: a send to a full shelf takes off the app
|
|
1208
|
+
* sent longest ago, so sending always works. Missing reads as oldest.
|
|
1209
|
+
*/
|
|
1210
|
+
added: z10.array(z10.number().int().nonnegative()).max(SHELF_MAX_APPS).optional()
|
|
1211
|
+
});
|
|
1212
|
+
var ShelfEditSchema = z10.discriminatedUnion("op", [
|
|
1213
|
+
z10.object({ op: z10.literal("show"), deviceId: DeviceIdSchema, index: z10.number().int().min(0) }),
|
|
1214
|
+
z10.object({ op: z10.literal("remove"), deviceId: DeviceIdSchema, index: z10.number().int().min(0) }),
|
|
1215
|
+
z10.object({
|
|
1216
|
+
op: z10.literal("move"),
|
|
1217
|
+
deviceId: DeviceIdSchema,
|
|
1218
|
+
from: z10.number().int().min(0),
|
|
1219
|
+
to: z10.number().int().min(0)
|
|
1220
|
+
}),
|
|
1221
|
+
z10.object({ op: z10.literal("rotate"), deviceId: DeviceIdSchema, minutes: z10.number().int().min(0).max(1440) }),
|
|
1222
|
+
/**
|
|
1223
|
+
* Swap the panel's light and dark. Not about apps, but it rides the same
|
|
1224
|
+
* route and the same poll: some units of the same board carry a panel wired
|
|
1225
|
+
* the other way, so one shows white on black and its twin black on white
|
|
1226
|
+
* from identical firmware. It is a fact about one board's glass, so it is a
|
|
1227
|
+
* per-board setting rather than a build.
|
|
1228
|
+
*/
|
|
1229
|
+
z10.object({ op: z10.literal("screen"), deviceId: DeviceIdSchema, invert: z10.boolean() }),
|
|
1230
|
+
/**
|
|
1231
|
+
* Remove one entry from the list of apps sent to this board, by the revision
|
|
1232
|
+
* it was sent as. The record only: what the board holds is the shelf's
|
|
1233
|
+
* business, and `remove` above is how an app comes off it.
|
|
1234
|
+
*/
|
|
1235
|
+
z10.object({ op: z10.literal("forget"), deviceId: DeviceIdSchema, revision: z10.number().int().min(1) })
|
|
1236
|
+
]);
|
|
1237
|
+
|
|
1238
|
+
// src/apps/protocol.ts
|
|
1239
|
+
import { z as z12 } from "zod";
|
|
1240
|
+
|
|
1241
|
+
// src/theme/account.ts
|
|
1242
|
+
import { z as z11 } from "zod";
|
|
1243
|
+
var ThemeRgbSchema = z11.string().regex(/^\d{1,3} \d{1,3} \d{1,3}$/, 'Must be "R G B", e.g. "13 110 253"').refine((v) => v.split(" ").every((n) => Number(n) <= 255), "Each channel is 0\u2013255");
|
|
1244
|
+
var ThemePaletteSchema = z11.object({
|
|
1245
|
+
background: ThemeRgbSchema,
|
|
1246
|
+
/** Text. */
|
|
1247
|
+
foreground: ThemeRgbSchema,
|
|
1248
|
+
/** Quieter text: labels, captions, the second line. */
|
|
1249
|
+
muted: ThemeRgbSchema,
|
|
1250
|
+
/** The brand colour: buttons and links on the site, highlights on a board. */
|
|
1251
|
+
accent: ThemeRgbSchema,
|
|
1252
|
+
success: ThemeRgbSchema,
|
|
1253
|
+
warning: ThemeRgbSchema,
|
|
1254
|
+
danger: ThemeRgbSchema
|
|
1255
|
+
});
|
|
1256
|
+
var THEME_PALETTE_TOKENS = [
|
|
1257
|
+
"background",
|
|
1258
|
+
"foreground",
|
|
1259
|
+
"muted",
|
|
1260
|
+
"accent",
|
|
1261
|
+
"success",
|
|
1262
|
+
"warning",
|
|
1263
|
+
"danger"
|
|
1264
|
+
];
|
|
1265
|
+
var ThemeLetteringSchema = z11.enum(["inter", "tay", "pixel"]);
|
|
1266
|
+
var THEME_RADII = ["0rem", "0.25rem", "0.5rem", "0.75rem", "1rem"];
|
|
1267
|
+
var AccountThemeSchema = z11.object({
|
|
1268
|
+
name: z11.string().trim().min(1).max(40),
|
|
1269
|
+
/** The preset it started from, when it started from one. */
|
|
1270
|
+
base: z11.string().max(40).optional(),
|
|
1271
|
+
light: ThemePaletteSchema,
|
|
1272
|
+
dark: ThemePaletteSchema,
|
|
1273
|
+
lettering: ThemeLetteringSchema,
|
|
1274
|
+
radius: z11.enum(THEME_RADII)
|
|
1275
|
+
});
|
|
1276
|
+
|
|
1277
|
+
// src/apps/protocol.ts
|
|
1278
|
+
var DEVICE_PROTOCOL = {
|
|
1279
|
+
/** POST `DeviceRegistration` → 200. On boot and every six hours. */
|
|
1280
|
+
register: { method: "POST", path: "/api/device/register" },
|
|
1281
|
+
/**
|
|
1282
|
+
* GET `?id=&since=<revision>` plus what the board says about itself
|
|
1283
|
+
* (`DEVICE_POLL_QUERY`) → 200 `DevicePollReply`, 304 when nothing is newer
|
|
1284
|
+
* than `since`, 204 when nothing has ever been sent.
|
|
1285
|
+
*/
|
|
1286
|
+
poll: { method: "GET", path: "/api/device/app" },
|
|
1287
|
+
/** POST `DeviceReport` → 202. Only while the board has readings to give. */
|
|
1288
|
+
report: { method: "POST", path: "/api/device/report" },
|
|
1289
|
+
/**
|
|
1290
|
+
* GET `?id=&hash=<sha256>` → 200 raw bytes, 404 for anything it may not
|
|
1291
|
+
* have. Only a hash an app on the board names; the board keeps the file.
|
|
1292
|
+
*/
|
|
1293
|
+
photo: { method: "GET", path: "/api/device/photo" }
|
|
1294
|
+
};
|
|
1295
|
+
var DEVICE_POLL_QUERY = {
|
|
1296
|
+
id: "the board id (required)",
|
|
1297
|
+
since: "the revision on the glass now",
|
|
1298
|
+
v: "the firmware version it runs",
|
|
1299
|
+
ph: 'photos held / photos wanted, as "3/4"',
|
|
1300
|
+
sh: '"1" when it can hold a shelf of apps rather than one',
|
|
1301
|
+
inv: 'its light/dark panel setting, "0" or "1"',
|
|
1302
|
+
rot: "which way it stands, 0\u20133",
|
|
1303
|
+
pl: "the palette it draws in, as 42 hex digits",
|
|
1304
|
+
fn: "the lettering it draws in",
|
|
1305
|
+
bt: "battery millivolts",
|
|
1306
|
+
u: "what happened to the last update it was asked to install"
|
|
1307
|
+
};
|
|
1308
|
+
var BoardPaletteHexSchema = z12.string().regex(/^[0-9a-f]{42}$/);
|
|
1309
|
+
var BoardFontSchema = z12.union([z12.literal("auto"), ThemeLetteringSchema]);
|
|
1310
|
+
var DevicePollReplySchema = z12.object({
|
|
1311
|
+
revision: z12.number().int().nonnegative(),
|
|
1312
|
+
sentAt: z12.number().int().nonnegative().optional(),
|
|
1313
|
+
document: AppDocumentSchema.optional(),
|
|
1314
|
+
shelf: ShelfSchema.optional(),
|
|
1315
|
+
update: FirmwareUpdateSchema.optional(),
|
|
1316
|
+
screen: z12.object({ invert: z12.boolean() }).optional(),
|
|
1317
|
+
palette: BoardPaletteHexSchema.optional(),
|
|
1318
|
+
font: BoardFontSchema.optional()
|
|
1319
|
+
});
|
|
1320
|
+
|
|
1321
|
+
// src/apps/deviceFonts.generated.ts
|
|
1322
|
+
var SMOOTH_FACES = { "inter": { "family": "Inter", "weight": 500, "caps": false }, "tay": { "family": "TAY Dreamboat", "weight": 400, "caps": true } };
|
|
1323
|
+
var SMOOTH_FONT_ADVANCES = { "inter": { "10": { "0": 6, "1": 4, "2": 6, "3": 6, "4": 7, "5": 6, "6": 6, "7": 6, "8": 6, "9": 6, " ": 3, "!": 3, '"': 5, "#": 6, "$": 6, "%": 10, "&": 7, "'": 3, "(": 4, ")": 4, "*": 5, "+": 7, ",": 3, "-": 5, ".": 3, "/": 4, ":": 3, ";": 3, "<": 7, "=": 7, ">": 7, "?": 5, "@": 10, "A": 7, "B": 7, "C": 7, "D": 7, "E": 6, "F": 6, "G": 7, "H": 7, "I": 3, "J": 6, "K": 7, "L": 6, "M": 9, "N": 8, "O": 8, "P": 6, "Q": 8, "R": 6, "S": 6, "T": 7, "U": 7, "V": 7, "W": 10, "X": 7, "Y": 7, "Z": 6, "[": 4, "\\": 4, "]": 4, "^": 5, "_": 5, "`": 3, "a": 6, "b": 6, "c": 6, "d": 6, "e": 6, "f": 4, "g": 6, "h": 6, "i": 3, "j": 3, "k": 6, "l": 3, "m": 9, "n": 6, "o": 6, "p": 6, "q": 6, "r": 4, "s": 5, "t": 3, "u": 6, "v": 6, "w": 8, "x": 6, "y": 6, "z": 6, "{": 4, "|": 3, "}": 4, "~": 7, "\xA0": 3, "\xA1": 3, "\xA2": 6, "\xA3": 6, "\xA5": 6, "\xAA": 5, "\xAB": 6, "\xAC": 7, "\xB0": 5, "\xB1": 7, "\xB2": 4, "\xB5": 6, "\xB7": 3, "\xBA": 5, "\xBB": 6, "\xBC": 8, "\xBD": 9, "\xBF": 5, "\xC4": 7, "\xC5": 7, "\xC6": 10, "\xC7": 7, "\xC9": 6, "\xD1": 8, "\xD6": 8, "\xDC": 7, "\xDF": 6, "\xE0": 6, "\xE1": 6, "\xE2": 6, "\xE4": 6, "\xE5": 6, "\xE6": 9, "\xE7": 6, "\xE8": 6, "\xE9": 6, "\xEA": 6, "\xEB": 6, "\xEC": 3, "\xED": 3, "\xEE": 3, "\xEF": 3, "\xF1": 6, "\xF2": 6, "\xF3": 6, "\xF4": 6, "\xF6": 6, "\xF7": 7, "\xF9": 6, "\xFA": 6, "\xFB": 6, "\xFC": 6, "\xFF": 6, "\u0192": 5, "\u03A9": 8, "\u03C0": 5, "\u2013": 5, "\u2014": 10, "\u2018": 3, "\u2019": 3, "\u201C": 5, "\u201D": 5, "\u2212": 7, "\u221A": 5, "\u221E": 7, "\u2248": 5, "\u2264": 5, "\u2265": 5 }, "12": { "0": 8, "1": 5, "2": 7, "3": 8, "4": 8, "5": 7, "6": 8, "7": 7, "8": 8, "9": 8, " ": 3, "!": 4, '"': 6, "#": 8, "$": 8, "%": 12, "&": 8, "'": 4, "(": 4, ")": 4, "*": 6, "+": 8, ",": 4, "-": 6, ".": 4, "/": 4, ":": 4, ";": 4, "<": 8, "=": 8, ">": 8, "?": 6, "@": 12, "A": 9, "B": 8, "C": 9, "D": 9, "E": 7, "F": 7, "G": 9, "H": 9, "I": 3, "J": 7, "K": 8, "L": 7, "M": 11, "N": 9, "O": 9, "P": 8, "Q": 9, "R": 8, "S": 8, "T": 8, "U": 9, "V": 9, "W": 12, "X": 8, "Y": 8, "Z": 8, "[": 4, "\\": 4, "]": 4, "^": 6, "_": 6, "`": 4, "a": 7, "b": 7, "c": 7, "d": 7, "e": 7, "f": 5, "g": 7, "h": 7, "i": 3, "j": 3, "k": 7, "l": 3, "m": 11, "n": 7, "o": 7, "p": 7, "q": 7, "r": 5, "s": 6, "t": 4, "u": 7, "v": 7, "w": 10, "x": 7, "y": 7, "z": 7, "{": 5, "|": 4, "}": 5, "~": 8, "\xA0": 3, "\xA1": 4, "\xA2": 7, "\xA3": 7, "\xA5": 7, "\xAA": 5, "\xAB": 7, "\xAC": 8, "\xB0": 5, "\xB1": 8, "\xB2": 5, "\xB5": 7, "\xB7": 4, "\xBA": 6, "\xBB": 7, "\xBC": 10, "\xBD": 10, "\xBF": 6, "\xC4": 9, "\xC5": 9, "\xC6": 12, "\xC7": 9, "\xC9": 7, "\xD1": 9, "\xD6": 9, "\xDC": 9, "\xDF": 8, "\xE0": 7, "\xE1": 7, "\xE2": 7, "\xE4": 7, "\xE5": 7, "\xE6": 11, "\xE7": 7, "\xE8": 7, "\xE9": 7, "\xEA": 7, "\xEB": 7, "\xEC": 3, "\xED": 3, "\xEE": 3, "\xEF": 3, "\xF1": 7, "\xF2": 7, "\xF3": 7, "\xF4": 7, "\xF6": 7, "\xF7": 8, "\xF9": 7, "\xFA": 7, "\xFB": 7, "\xFC": 7, "\xFF": 7, "\u0192": 6, "\u03A9": 9, "\u03C0": 7, "\u2013": 6, "\u2014": 12, "\u2018": 3, "\u2019": 3, "\u201C": 6, "\u201D": 6, "\u2212": 8, "\u221A": 7, "\u221E": 9, "\u2248": 7, "\u2264": 7, "\u2265": 7 }, "16": { "0": 10, "1": 7, "2": 10, "3": 10, "4": 11, "5": 10, "6": 10, "7": 9, "8": 10, "9": 10, " ": 4, "!": 5, '"': 8, "#": 10, "$": 10, "%": 16, "&": 10, "'": 5, "(": 6, ")": 6, "*": 8, "+": 11, ",": 5, "-": 7, ".": 5, "/": 6, ":": 5, ";": 5, "<": 11, "=": 11, ">": 11, "?": 8, "@": 16, "A": 11, "B": 11, "C": 12, "D": 12, "E": 10, "F": 9, "G": 12, "H": 12, "I": 4, "J": 9, "K": 11, "L": 9, "M": 15, "N": 12, "O": 12, "P": 10, "Q": 12, "R": 10, "S": 10, "T": 10, "U": 12, "V": 11, "W": 16, "X": 11, "Y": 11, "Z": 10, "[": 6, "\\": 6, "]": 6, "^": 8, "_": 7, "`": 5, "a": 9, "b": 10, "c": 9, "d": 10, "e": 9, "f": 6, "g": 10, "h": 10, "i": 4, "j": 4, "k": 9, "l": 4, "m": 14, "n": 10, "o": 10, "p": 10, "q": 10, "r": 6, "s": 9, "t": 5, "u": 10, "v": 9, "w": 13, "x": 9, "y": 9, "z": 9, "{": 7, "|": 6, "}": 7, "~": 11, "\xA0": 4, "\xA1": 5, "\xA2": 9, "\xA3": 10, "\xA5": 9, "\xAA": 7, "\xAB": 10, "\xAC": 11, "\xB0": 7, "\xB1": 11, "\xB2": 7, "\xB5": 10, "\xB7": 5, "\xBA": 8, "\xBB": 10, "\xBC": 13, "\xBD": 14, "\xBF": 8, "\xC4": 11, "\xC5": 11, "\xC6": 16, "\xC7": 12, "\xC9": 10, "\xD1": 12, "\xD6": 12, "\xDC": 12, "\xDF": 10, "\xE0": 9, "\xE1": 9, "\xE2": 9, "\xE4": 9, "\xE5": 9, "\xE6": 15, "\xE7": 9, "\xE8": 9, "\xE9": 9, "\xEA": 9, "\xEB": 9, "\xEC": 4, "\xED": 4, "\xEE": 4, "\xEF": 4, "\xF1": 10, "\xF2": 10, "\xF3": 10, "\xF4": 10, "\xF6": 10, "\xF7": 11, "\xF9": 10, "\xFA": 10, "\xFB": 10, "\xFC": 10, "\xFF": 9, "\u0192": 8, "\u03A9": 12, "\u03C0": 9, "\u2013": 8, "\u2014": 16, "\u2018": 4, "\u2019": 4, "\u201C": 8, "\u201D": 8, "\u2212": 11, "\u221A": 9, "\u221E": 11, "\u2248": 9, "\u2264": 9, "\u2265": 9 }, "20": { "0": 13, "1": 8, "2": 12, "3": 13, "4": 13, "5": 12, "6": 13, "7": 11, "8": 13, "9": 13, " ": 5, "!": 6, '"': 10, "#": 13, "$": 13, "%": 20, "&": 13, "'": 6, "(": 7, ")": 7, "*": 10, "+": 13, ",": 6, "-": 9, ".": 6, "/": 7, ":": 6, ";": 6, "<": 13, "=": 13, ">": 13, "?": 11, "@": 20, "A": 14, "B": 13, "C": 15, "D": 14, "E": 12, "F": 12, "G": 15, "H": 15, "I": 5, "J": 12, "K": 14, "L": 11, "M": 18, "N": 15, "O": 15, "P": 13, "Q": 15, "R": 13, "S": 13, "T": 13, "U": 15, "V": 14, "W": 20, "X": 14, "Y": 14, "Z": 13, "[": 7, "\\": 7, "]": 7, "^": 10, "_": 9, "`": 7, "a": 11, "b": 12, "c": 12, "d": 12, "e": 12, "f": 8, "g": 12, "h": 12, "i": 5, "j": 5, "k": 11, "l": 5, "m": 18, "n": 12, "o": 12, "p": 12, "q": 12, "r": 8, "s": 11, "t": 7, "u": 12, "v": 11, "w": 17, "x": 11, "y": 12, "z": 11, "{": 9, "|": 7, "}": 9, "~": 13, "\xA0": 5, "\xA1": 6, "\xA2": 12, "\xA3": 12, "\xA5": 11, "\xAA": 9, "\xAB": 12, "\xAC": 13, "\xB0": 9, "\xB1": 13, "\xB2": 9, "\xB5": 12, "\xB7": 6, "\xBA": 10, "\xBB": 12, "\xBC": 16, "\xBD": 17, "\xBF": 11, "\xC4": 14, "\xC5": 14, "\xC6": 20, "\xC7": 15, "\xC9": 12, "\xD1": 15, "\xD6": 15, "\xDC": 15, "\xDF": 13, "\xE0": 11, "\xE1": 11, "\xE2": 11, "\xE4": 11, "\xE5": 11, "\xE6": 18, "\xE7": 12, "\xE8": 12, "\xE9": 12, "\xEA": 12, "\xEB": 12, "\xEC": 5, "\xED": 5, "\xEE": 5, "\xEF": 5, "\xF1": 12, "\xF2": 12, "\xF3": 12, "\xF4": 12, "\xF6": 12, "\xF7": 13, "\xF9": 12, "\xFA": 12, "\xFB": 12, "\xFC": 12, "\xFF": 12, "\u0192": 10, "\u03A9": 15, "\u03C0": 11, "\u2013": 10, "\u2014": 20, "\u2018": 6, "\u2019": 6, "\u201C": 9, "\u201D": 9, "\u2212": 13, "\u221A": 11, "\u221E": 14, "\u2248": 11, "\u2264": 11, "\u2265": 11 }, "28": { "0": 18, "1": 12, "2": 17, "3": 18, "4": 18, "5": 17, "6": 18, "7": 16, "8": 18, "9": 18, " ": 7, "!": 9, '"': 14, "#": 18, "$": 18, "%": 28, "&": 18, "'": 9, "(": 10, ")": 10, "*": 15, "+": 19, ",": 8, "-": 13, ".": 8, "/": 10, ":": 8, ";": 9, "<": 19, "=": 19, ">": 19, "?": 15, "@": 28, "A": 20, "B": 18, "C": 21, "D": 20, "E": 17, "F": 17, "G": 21, "H": 21, "I": 8, "J": 16, "K": 19, "L": 16, "M": 26, "N": 21, "O": 21, "P": 18, "Q": 22, "R": 18, "S": 18, "T": 18, "U": 21, "V": 20, "W": 28, "X": 20, "Y": 19, "Z": 18, "[": 10, "\\": 10, "]": 10, "^": 13, "_": 13, "`": 9, "a": 16, "b": 17, "c": 16, "d": 17, "e": 16, "f": 11, "g": 17, "h": 17, "i": 7, "j": 7, "k": 16, "l": 7, "m": 25, "n": 17, "o": 17, "p": 17, "q": 17, "r": 11, "s": 15, "t": 10, "u": 17, "v": 16, "w": 23, "x": 16, "y": 16, "z": 16, "{": 12, "|": 10, "}": 12, "~": 19, "\xA0": 7, "\xA1": 9, "\xA2": 16, "\xA3": 17, "\xA5": 16, "\xAA": 13, "\xAB": 17, "\xAC": 19, "\xB0": 13, "\xB1": 19, "\xB2": 13, "\xB5": 17, "\xB7": 8, "\xBA": 14, "\xBB": 17, "\xBC": 23, "\xBD": 24, "\xBF": 15, "\xC4": 20, "\xC5": 20, "\xC6": 28, "\xC7": 21, "\xC9": 17, "\xD1": 21, "\xD6": 21, "\xDC": 21, "\xDF": 18, "\xE0": 16, "\xE1": 16, "\xE2": 16, "\xE4": 16, "\xE5": 16, "\xE6": 26, "\xE7": 16, "\xE8": 16, "\xE9": 16, "\xEA": 16, "\xEB": 16, "\xEC": 7, "\xED": 7, "\xEE": 7, "\xEF": 7, "\xF1": 17, "\xF2": 17, "\xF3": 17, "\xF4": 17, "\xF6": 17, "\xF7": 19, "\xF9": 17, "\xFA": 17, "\xFB": 17, "\xFC": 17, "\xFF": 16, "\u0192": 14, "\u03A9": 22, "\u03C0": 15, "\u2013": 14, "\u2014": 28, "\u2018": 8, "\u2019": 8, "\u201C": 13, "\u201D": 13, "\u2212": 19, "\u221A": 15, "\u221E": 20, "\u2248": 15, "\u2264": 15, "\u2265": 15 }, "56": { "0": 36, "1": 23, "2": 35, "3": 35, "4": 37, "5": 34, "6": 35, "7": 32, "8": 35, "9": 35, " ": 15, "!": 17, '"': 28, "#": 36, "$": 36, "%": 56, "&": 37, "'": 18, "(": 21, ")": 21, "*": 29, "+": 37, ",": 17, "-": 26, ".": 17, "/": 21, ":": 17, ";": 18, "<": 37, "=": 37, ">": 37, "?": 30, "@": 55, "A": 40, "B": 37, "C": 41, "D": 40, "E": 34, "F": 33, "G": 42, "H": 42, "I": 15, "J": 32, "K": 39, "L": 32, "M": 51, "N": 42, "O": 43, "P": 36, "Q": 43, "R": 36, "S": 36, "T": 37, "U": 41, "V": 40, "W": 56, "X": 39, "Y": 39, "Z": 36, "[": 21, "\\": 21, "]": 21, "^": 27, "_": 26, "`": 19, "a": 32, "b": 35, "c": 32, "d": 35, "e": 33, "f": 21, "g": 35, "h": 34, "i": 14, "j": 14, "k": 31, "l": 14, "m": 50, "n": 34, "o": 34, "p": 35, "q": 35, "r": 22, "s": 30, "t": 19, "u": 34, "v": 32, "w": 46, "x": 31, "y": 32, "z": 31, "{": 25, "|": 19, "}": 25, "~": 37, "\xB0": 26 } }, "tay": { "28": { "0": 29, "1": 16, "2": 28, "3": 28, "4": 30, "5": 27, "6": 28, "7": 26, "8": 29, "9": 29, " ": 12, "!": 16, '"': 12, "#": 27, "$": 27, "%": 29, "&": 33, "'": 9, "(": 20, ")": 20, "*": 14, "+": 21, ",": 10, "-": 16, ".": 10, "/": 19, ":": 13, ";": 12, "<": 18, "=": 22, ">": 18, "?": 27, "@": 31, "A": 28, "B": 32, "C": 28, "D": 30, "E": 30, "F": 29, "G": 29, "H": 32, "I": 16, "J": 27, "K": 29, "L": 27, "M": 36, "N": 32, "O": 29, "P": 30, "Q": 30, "R": 30, "S": 29, "T": 31, "U": 29, "V": 28, "W": 40, "X": 29, "Y": 29, "Z": 30, "[": 17, "\\": 19, "]": 17, "^": 13, "_": 19, "`": 9, "{": 13, "|": 6, "}": 13, "~": 15, "\xA0": 8, "\xA1": 15, "\xA2": 14, "\xA3": 26, "\xA5": 31, "\xAA": 8, "\xAB": 14, "\xAC": 16, "\xB0": 14, "\xB1": 15, "\xB2": 8, "\xB7": 7, "\xBA": 9, "\xBB": 14, "\xBC": 21, "\xBD": 21, "\xBF": 26, "\xC4": 28, "\xC5": 28, "\xC6": 25, "\xC7": 28, "\xC9": 30, "\xD1": 32, "\xD6": 29, "\xDC": 29, "\xF7": 15, "\u03A9": 22, "\u2013": 14, "\u2014": 28, "\u2018": 9, "\u2019": 9, "\u201C": 12, "\u201D": 12, "\u2212": 16, "\u221A": 15, "\u221E": 20, "\u2248": 15, "\u2264": 15, "\u2265": 15 }, "56": { "0": 58, "1": 33, "2": 56, "3": 57, "4": 60, "5": 55, "6": 57, "7": 51, "8": 58, "9": 59, " ": 24, "!": 32, '"': 23, "#": 55, "$": 55, "%": 59, "&": 66, "'": 18, "(": 39, ")": 39, "*": 28, "+": 43, ",": 20, "-": 31, ".": 20, "/": 38, ":": 26, ";": 23, "<": 37, "=": 44, ">": 37, "?": 54, "@": 61, "A": 56, "B": 63, "C": 56, "D": 60, "E": 60, "F": 58, "G": 58, "H": 63, "I": 33, "J": 55, "K": 58, "L": 53, "M": 72, "N": 65, "O": 59, "P": 60, "Q": 59, "R": 61, "S": 58, "T": 62, "U": 58, "V": 56, "W": 79, "X": 58, "Y": 58, "Z": 59, "[": 34, "\\": 38, "]": 34, "^": 26, "_": 39, "`": 19, "{": 27, "|": 11, "}": 27, "~": 30, "\xB0": 27 } } };
|
|
1324
|
+
|
|
1325
|
+
// src/ai/tools.ts
|
|
1326
|
+
import { z as z13 } from "zod";
|
|
1327
|
+
var telemetryGraphParameters = z13.object({
|
|
1328
|
+
deviceId: z13.string().min(1, "Device ID is required"),
|
|
1329
|
+
timeRange: z13.enum(["1h", "24h", "7d"], {
|
|
1085
1330
|
errorMap: () => ({ message: "Time range must be 1h, 24h, or 7d" })
|
|
1086
1331
|
}),
|
|
1087
|
-
metrics:
|
|
1088
|
-
|
|
1332
|
+
metrics: z13.array(
|
|
1333
|
+
z13.enum(["temperature", "humidity", "vwc", "ec", "ph", "pressure", "co2"])
|
|
1089
1334
|
).min(1, "At least one metric is required").max(4, "Maximum 4 metrics per graph")
|
|
1090
1335
|
});
|
|
1091
|
-
var stockChartParameters = z10.object({
|
|
1092
|
-
ticker: z10.string().min(1).describe("The stock ticker symbol explicitly requested by the user. YOU MUST EXTRACT AND PROVIDE THIS (e.g., 'AAPL', 'MSFT')."),
|
|
1093
|
-
timeRange: z10.enum(["1D", "1W", "1M", "1Y"], {
|
|
1094
|
-
errorMap: () => ({ message: "Time range must be 1D, 1W, 1M, or 1Y" })
|
|
1095
|
-
}).describe("The time range for the chart. Choose based on user request or default to '1M'."),
|
|
1096
|
-
metrics: z10.array(z10.enum(["price", "volume", "moving_average"])).min(1, "At least one metric is required").describe("Array of metrics to display. Always include 'price' and 'volume' unless user specifies otherwise.")
|
|
1097
|
-
});
|
|
1098
|
-
var tickerParam = z10.string().min(1).describe("The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT').");
|
|
1099
|
-
var liveQuoteParameters = z10.object({ ticker: tickerParam });
|
|
1100
|
-
var companyNewsParameters = z10.object({ ticker: tickerParam });
|
|
1101
|
-
var companyProfileParameters = z10.object({ ticker: tickerParam });
|
|
1102
|
-
var counterpartyGraphParameters = z10.object({
|
|
1103
|
-
ticker: tickerParam,
|
|
1104
|
-
hops: z10.number().int().min(1).max(2).optional().describe("How many relationship hops to traverse (1 = direct counterparties only, 2 = counterparties-of-counterparties too). Defaults to 1 if omitted.")
|
|
1105
|
-
});
|
|
1106
|
-
var divergenceMetricsParameters = z10.object({ ticker: tickerParam });
|
|
1107
|
-
var architectureReferenceParameters = z10.object({});
|
|
1108
1336
|
var AI_TOOLS = {
|
|
1109
1337
|
get_telemetry_graph: {
|
|
1110
1338
|
name: "get_telemetry_graph",
|
|
1111
1339
|
description: "Displays an interactive line chart of historical sensor telemetry data. Use this when the user asks to visualize trends, compare metrics over time, or analyze device performance. Supports temperature, humidity, VWC (volumetric water content), EC (electrical conductivity), pH, pressure, and CO2.",
|
|
1112
|
-
parameters: telemetryGraphParameters
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
},
|
|
1119
|
-
get_live_quote: {
|
|
1120
|
-
name: "get_live_quote",
|
|
1121
|
-
description: "Fetches and displays the real-time stock price and daily change percentage for a given company ticker symbol.",
|
|
1122
|
-
parameters: liveQuoteParameters
|
|
1123
|
-
},
|
|
1124
|
-
get_company_news: {
|
|
1125
|
-
name: "get_company_news",
|
|
1126
|
-
description: "Fetches and displays the 5 most recent news headlines and sentiment impact scores for a given company ticker symbol.",
|
|
1127
|
-
parameters: companyNewsParameters
|
|
1128
|
-
},
|
|
1129
|
-
get_company_profile: {
|
|
1130
|
-
name: "get_company_profile",
|
|
1131
|
-
description: "Fetches fundamental company data including the business description, sector, industry, market cap, and P/E ratio.",
|
|
1132
|
-
parameters: companyProfileParameters
|
|
1133
|
-
},
|
|
1134
|
-
get_counterparty_graph: {
|
|
1135
|
-
name: "get_counterparty_graph",
|
|
1136
|
-
description: "Displays the inferred counterparty relationship graph for a company \u2014 suppliers, customers, partners, competitors, regulators, and investment/acquisition relationships that Fleet-Brain-Deep has extracted from alternative signals. Use this when the user asks about a company's business relationships, supply chain, competitors, or who it partners/invests with. Not for corporate ownership structure (parent/subsidiary) \u2014 use company profile data for that.",
|
|
1137
|
-
parameters: counterpartyGraphParameters
|
|
1138
|
-
},
|
|
1139
|
-
get_divergence_metrics: {
|
|
1140
|
-
name: "get_divergence_metrics",
|
|
1141
|
-
description: "Displays Fleet-Brain-Deep's operational and customer divergence scores for a company \u2014 a signed delta between expected (baseline) and observed performance, inferred from recent signals. Use this when the user asks whether something is going better or worse than expected operationally or from a customer-experience standpoint.",
|
|
1142
|
-
parameters: divergenceMetricsParameters
|
|
1143
|
-
},
|
|
1144
|
-
get_architecture_reference: {
|
|
1145
|
-
name: "get_architecture_reference",
|
|
1146
|
-
description: "Explains THIS PLATFORM'S OWN data architecture \u2014 its tech stack, database schema and data modeling, AI/LLM integration points, and background worker (sentinel) fleet. Use this for questions about how the system itself is built, not about a company or the market. Takes no parameters.",
|
|
1147
|
-
parameters: architectureReferenceParameters
|
|
1340
|
+
parameters: telemetryGraphParameters,
|
|
1341
|
+
promptParameters: `{
|
|
1342
|
+
"deviceId": "string (required)",
|
|
1343
|
+
"timeRange": "enum: '1h' | '24h' | '7d' (required)",
|
|
1344
|
+
"metrics": "array of enum: 'temperature' | 'humidity' | 'vwc' | 'ec' | 'ph' | 'pressure' | 'co2' (1-4 items required)"
|
|
1345
|
+
}`
|
|
1148
1346
|
}
|
|
1149
1347
|
};
|
|
1150
1348
|
|
|
@@ -1375,7 +1573,12 @@ BLOCKS \u2014 up to 12, drawn top to bottom. Each is one of:
|
|
|
1375
1573
|
A row splits the width into equal cells. Add "pack": true and each child takes
|
|
1376
1574
|
only its own width, "gap" apart \u2014 a number with its icon right beside it, or
|
|
1377
1575
|
"H 68\xB0 L 56\xB0" as one line. Put "valign": "center" at the top level of the
|
|
1378
|
-
document to centre the blocks on the screen rather than start at the top
|
|
1576
|
+
document to centre the blocks on the screen rather than start at the top, and
|
|
1577
|
+
"font": "pixel" for chunky retro lettering or "font": "tay" for the Ramme
|
|
1578
|
+
display face, all capitals, good for signs and big numbers (the default is a
|
|
1579
|
+
smooth plain face), and
|
|
1580
|
+
"halign": "center" to centre them across it \u2014 the lines keep their own
|
|
1581
|
+
alignment inside a column as wide as the widest, and the column is centred.
|
|
1379
1582
|
|
|
1380
1583
|
AN ICON is the sky drawn in outline: "sun", "partly", "cloud", "fog", "rain",
|
|
1381
1584
|
"snow" or "storm". Bind its value to a weather source's "icon" field so it
|
|
@@ -1475,6 +1678,14 @@ SOURCES \u2014 declare what the app reads, then bind to it by name:
|
|
|
1475
1678
|
For things that take turns: give each block "hideWhen": { "value":
|
|
1476
1679
|
{ "source": "turn", "field": "index" }, "op": "!=", "than": N } so only
|
|
1477
1680
|
block N shows on turn N. The board changes at most once a minute.
|
|
1681
|
+
"probe": { "kind": "board", "units": "imperial" }
|
|
1682
|
+
fields: temperature, connected
|
|
1683
|
+
What a sensor plugged into the board itself is reading: a temperature
|
|
1684
|
+
probe's temperature, a whole number in units, updated about once a
|
|
1685
|
+
second. connected is false when nothing is plugged in, and temperature
|
|
1686
|
+
is then missing (it draws "--"): use hideWhen on connected to show
|
|
1687
|
+
"Plug in the probe" instead. Use this, not weather, for "my sensor",
|
|
1688
|
+
"the probe", "water temperature" and the like.
|
|
1478
1689
|
|
|
1479
1690
|
RULES
|
|
1480
1691
|
|
|
@@ -1494,12 +1705,12 @@ RULES
|
|
|
1494
1705
|
var APP_DOCUMENT_EDIT_PREFIX = "Here is the current app. Change only what is asked:";
|
|
1495
1706
|
|
|
1496
1707
|
// src/theme/schema.ts
|
|
1497
|
-
import { z as
|
|
1498
|
-
var RGBString =
|
|
1708
|
+
import { z as z14 } from "zod";
|
|
1709
|
+
var RGBString = z14.string().regex(
|
|
1499
1710
|
/^\d{1,3}\s+\d{1,3}\s+\d{1,3}$/,
|
|
1500
1711
|
'Must be space-separated RGB integers (e.g. "13 110 253")'
|
|
1501
1712
|
);
|
|
1502
|
-
var ThemeOverridesSchema =
|
|
1713
|
+
var ThemeOverridesSchema = z14.object({
|
|
1503
1714
|
// ── Core Brand ───────────────────────────────────────────────────────────
|
|
1504
1715
|
"--app-primary-color": RGBString.optional(),
|
|
1505
1716
|
"--app-primary-foreground-color": RGBString.optional(),
|
|
@@ -1515,9 +1726,9 @@ var ThemeOverridesSchema = z11.object({
|
|
|
1515
1726
|
"--app-muted-bg": RGBString.optional(),
|
|
1516
1727
|
"--app-muted-text": RGBString.optional(),
|
|
1517
1728
|
// ── Shape ────────────────────────────────────────────────────────────────
|
|
1518
|
-
"--app-border-radius-sm":
|
|
1519
|
-
"--app-border-radius-md":
|
|
1520
|
-
"--app-border-radius-lg":
|
|
1729
|
+
"--app-border-radius-sm": z14.string().optional(),
|
|
1730
|
+
"--app-border-radius-md": z14.string().optional(),
|
|
1731
|
+
"--app-border-radius-lg": z14.string().optional(),
|
|
1521
1732
|
// ── Form Controls ────────────────────────────────────────────────────────
|
|
1522
1733
|
"--app-input-bg-color": RGBString.optional(),
|
|
1523
1734
|
"--app-input-text-color": RGBString.optional(),
|
|
@@ -1531,19 +1742,19 @@ var ThemeOverridesSchema = z11.object({
|
|
|
1531
1742
|
"--app-chart-4": RGBString.optional(),
|
|
1532
1743
|
"--app-chart-5": RGBString.optional()
|
|
1533
1744
|
}).strict();
|
|
1534
|
-
var ThemeFontsSchema =
|
|
1745
|
+
var ThemeFontsSchema = z14.object({
|
|
1535
1746
|
/** Google Font name for headings (h1–h4, .font-serif). Example: "Playfair Display" */
|
|
1536
|
-
heading:
|
|
1747
|
+
heading: z14.string(),
|
|
1537
1748
|
/** Google Font name for body text. Example: "Inter" */
|
|
1538
|
-
body:
|
|
1749
|
+
body: z14.string(),
|
|
1539
1750
|
/** Optional monospace font. Example: "Roboto Mono" */
|
|
1540
|
-
mono:
|
|
1751
|
+
mono: z14.string().optional()
|
|
1541
1752
|
});
|
|
1542
|
-
var AIThemeSchema =
|
|
1753
|
+
var AIThemeSchema = z14.object({
|
|
1543
1754
|
/** Short descriptive theme name. Example: "Midnight Garden" */
|
|
1544
|
-
name:
|
|
1755
|
+
name: z14.string(),
|
|
1545
1756
|
/** One-sentence vibe description. Example: "Dark indigo with golden accents." */
|
|
1546
|
-
description:
|
|
1757
|
+
description: z14.string(),
|
|
1547
1758
|
/** Google Font pairing for heading and body text. */
|
|
1548
1759
|
fonts: ThemeFontsSchema.optional(),
|
|
1549
1760
|
/**
|
|
@@ -1554,13 +1765,13 @@ var AIThemeSchema = z11.object({
|
|
|
1554
1765
|
cssVars: ThemeOverridesSchema
|
|
1555
1766
|
});
|
|
1556
1767
|
var THEME_PRESETS = ["light", "dark", "system", "corporate", "midnight", "blueprint"];
|
|
1557
|
-
var ThemeTokensSchema =
|
|
1768
|
+
var ThemeTokensSchema = z14.object({
|
|
1558
1769
|
primary: RGBString,
|
|
1559
1770
|
neutral: RGBString,
|
|
1560
1771
|
success: RGBString,
|
|
1561
1772
|
warning: RGBString,
|
|
1562
1773
|
destructive: RGBString,
|
|
1563
|
-
radius:
|
|
1774
|
+
radius: z14.enum(["none", "sm", "md", "lg", "full"])
|
|
1564
1775
|
});
|
|
1565
1776
|
var DEFAULT_THEME_TOKENS = {
|
|
1566
1777
|
primary: "13 110 253",
|
|
@@ -1571,82 +1782,355 @@ var DEFAULT_THEME_TOKENS = {
|
|
|
1571
1782
|
radius: "md"
|
|
1572
1783
|
};
|
|
1573
1784
|
|
|
1785
|
+
// src/theme/controls.ts
|
|
1786
|
+
var CONTROL_STATES = ["rest", "pressed", "busy", "disabled", "focused"];
|
|
1787
|
+
var CONTROL_STATE_MEANINGS = {
|
|
1788
|
+
rest: { means: "The control, in the theme\u2019s surface or accent.", web: "default" },
|
|
1789
|
+
pressed: { means: "Lit the moment a finger lands on it.", web: ":active" },
|
|
1790
|
+
busy: { means: "Stays lit while its action runs; nothing else on screen moves.", web: "loading" },
|
|
1791
|
+
disabled: { means: "Muted, and a tap does nothing.", web: "disabled" },
|
|
1792
|
+
focused: { means: "Highlighted by a knob or a key: the control choosing would press.", web: ":focus-visible" }
|
|
1793
|
+
};
|
|
1794
|
+
|
|
1795
|
+
// src/enclosures/schema.ts
|
|
1796
|
+
import { z as z15 } from "zod";
|
|
1797
|
+
var Mm = z15.number().finite();
|
|
1798
|
+
var PositiveMm = Mm.positive();
|
|
1799
|
+
var NonNegativeMm = Mm.nonnegative();
|
|
1800
|
+
var PrinterProfileSchema = z15.object({
|
|
1801
|
+
name: z15.string().min(1).default("Bambu Lab X1 Carbon"),
|
|
1802
|
+
/** Walls are whole multiples of this. */
|
|
1803
|
+
nozzle: PositiveMm.default(0.4),
|
|
1804
|
+
/** Gap for parts that slide together: the case's lip, a lid. */
|
|
1805
|
+
clearance_slip: NonNegativeMm.default(0.2),
|
|
1806
|
+
/** Gap for a friction fit. */
|
|
1807
|
+
clearance_press: NonNegativeMm.default(0.1)
|
|
1808
|
+
});
|
|
1809
|
+
var EdgeSchema = z15.enum(["east", "west", "north", "south", "top", "bottom"]);
|
|
1810
|
+
var FlexButtonSchema = z15.object({
|
|
1811
|
+
/** The tongue's length, from its free end to where it joins the floor. */
|
|
1812
|
+
length: PositiveMm.default(12),
|
|
1813
|
+
/** Its width. */
|
|
1814
|
+
width: PositiveMm.default(5),
|
|
1815
|
+
/** The way from the switch to where the tongue joins the floor. */
|
|
1816
|
+
hinge: z15.enum(["east", "west", "north", "south"])
|
|
1817
|
+
});
|
|
1818
|
+
var InterfaceSchema = z15.object({
|
|
1819
|
+
/** usb_c, screen, reset_button, status_led, sd_card… */
|
|
1820
|
+
name: z15.string().min(1),
|
|
1821
|
+
edge: EdgeSchema,
|
|
1822
|
+
/** From the centre of that face — see COORDINATES above. */
|
|
1823
|
+
offset_from_center: z15.tuple([Mm, Mm]).default([0, 0]),
|
|
1824
|
+
/**
|
|
1825
|
+
* A grille is a field of small round holes filling an ellipse of
|
|
1826
|
+
* `cutout_size` — a speaker's — on a top or bottom face only.
|
|
1827
|
+
*/
|
|
1828
|
+
cutout_shape: z15.enum(["rect", "rounded_rect", "circle", "grille"]),
|
|
1829
|
+
/** [width, height] of the opening, including room for a plug's boot. A circle uses the first as its diameter. */
|
|
1830
|
+
cutout_size: z15.tuple([PositiveMm, PositiveMm]),
|
|
1831
|
+
/** How far the part sticks out past the component's edge. */
|
|
1832
|
+
protrusion: NonNegativeMm.default(0),
|
|
1833
|
+
/** A wider recess on the outside face, [width, height, depth], for a thick cable boot. */
|
|
1834
|
+
outer_recess: z15.tuple([PositiveMm, PositiveMm, PositiveMm]).optional(),
|
|
1835
|
+
/** Press it through the floor instead of opening a hole — see FlexButtonSchema. */
|
|
1836
|
+
flex_button: FlexButtonSchema.optional(),
|
|
1837
|
+
/**
|
|
1838
|
+
* A 45° ramp this deep round the opening at the outside face, widening it
|
|
1839
|
+
* by this much a side there. For a screen set back behind a bezel: the
|
|
1840
|
+
* picture's edges stay in view and a fingertip reaches them. Top or bottom
|
|
1841
|
+
* openings only.
|
|
1842
|
+
*/
|
|
1843
|
+
chamfer: NonNegativeMm.optional()
|
|
1844
|
+
});
|
|
1845
|
+
var MountHolesSchema = z15.object({
|
|
1846
|
+
/** Four holes, this far in from each corner: [east-west, north-south]. */
|
|
1847
|
+
inset_from_corners: z15.tuple([PositiveMm, PositiveMm]).optional(),
|
|
1848
|
+
/** Or exactly where they are: [east, north] from the footprint centre. */
|
|
1849
|
+
positions: z15.array(z15.tuple([Mm, Mm])).min(1).optional(),
|
|
1850
|
+
thread: z15.enum(["M2", "M2.5", "M3"]),
|
|
1851
|
+
/** Heat-set insert outer diameter and depth. split_shell_lip only: tray_bezel's screws cut their own thread. */
|
|
1852
|
+
insert_od: PositiveMm.optional(),
|
|
1853
|
+
insert_depth: PositiveMm.optional()
|
|
1854
|
+
}).refine((m) => (m.inset_from_corners ? 1 : 0) + (m.positions ? 1 : 0) === 1, {
|
|
1855
|
+
message: "give either inset_from_corners or positions, not both or neither"
|
|
1856
|
+
});
|
|
1857
|
+
var PlacementSchema = z15.object({
|
|
1858
|
+
relative_to: z15.string().min(1),
|
|
1859
|
+
where: z15.enum(["below", "above", "east", "west", "north", "south"]),
|
|
1860
|
+
/** Space between the two keep-outs. */
|
|
1861
|
+
gap: NonNegativeMm.default(1),
|
|
1862
|
+
/** Moved this far [east, north] from centred on the other, once placed. */
|
|
1863
|
+
offset: z15.tuple([Mm, Mm]).default([0, 0])
|
|
1864
|
+
});
|
|
1865
|
+
var ComponentSchema = z15.object({
|
|
1866
|
+
id: z15.string().regex(/^[a-z][a-z0-9_]*$/, "lowercase letters, digits and underscores"),
|
|
1867
|
+
type: z15.enum(["pcb", "display", "battery", "speaker", "module"]),
|
|
1868
|
+
/** [east, north, up] — see COORDINATES. */
|
|
1869
|
+
dimensions: z15.tuple([PositiveMm, PositiveMm, PositiveMm]),
|
|
1870
|
+
/**
|
|
1871
|
+
* Radius of the footprint's corners: most boards are rounded. The case's
|
|
1872
|
+
* inside corners follow it, so a rounded board gets a rounded tray without
|
|
1873
|
+
* the tray growing wider. Leave it at 0 for a square one, or when unsure —
|
|
1874
|
+
* assuming sharper than the part is safe, rounder is not.
|
|
1875
|
+
*/
|
|
1876
|
+
corner_radius: NonNegativeMm.default(0),
|
|
1877
|
+
/** Height of the tallest part on top (headers, capacitors, a connector), kept clear. */
|
|
1878
|
+
clearance_z_top: NonNegativeMm.default(0),
|
|
1879
|
+
/** Height of what is underneath (solder joints, a microSD socket), kept clear. */
|
|
1880
|
+
clearance_z_bottom: NonNegativeMm.default(0),
|
|
1881
|
+
/** Quarter turns about Z, applied before placement. */
|
|
1882
|
+
rotation: z15.union([z15.literal(0), z15.literal(90), z15.literal(180), z15.literal(270)]).default(0),
|
|
1883
|
+
placement: PlacementSchema.optional(),
|
|
1884
|
+
mount_holes: MountHolesSchema.optional(),
|
|
1885
|
+
interfaces: z15.array(InterfaceSchema).default([]),
|
|
1886
|
+
/** How it is held if it has no screw holes. */
|
|
1887
|
+
retention: z15.enum(["none", "cradle_ribs"]).default("none")
|
|
1888
|
+
});
|
|
1889
|
+
var EmblemSchema = z15.object({
|
|
1890
|
+
/** The SVG file, relative to the manifest. Filled paths only; strokes are ignored. */
|
|
1891
|
+
svg: z15.string().min(1),
|
|
1892
|
+
face: z15.enum(["top", "bottom"]).default("bottom"),
|
|
1893
|
+
/** Height of the mark on the face, along north. Its width follows the SVG's proportions. */
|
|
1894
|
+
height: PositiveMm,
|
|
1895
|
+
/** How deep it is pressed in. */
|
|
1896
|
+
depth: PositiveMm.default(0.6),
|
|
1897
|
+
/** From the centre of the case's footprint, [east, north]. */
|
|
1898
|
+
offset: z15.tuple([Mm, Mm]).default([0, 0]),
|
|
1899
|
+
/**
|
|
1900
|
+
* Cut it right through the face instead, as a stencil — a speaker's grille
|
|
1901
|
+
* in the shape of the mark. Whatever its lines enclose would fall out, so
|
|
1902
|
+
* each enclosed piece is held by bridges across a line: give them here, in
|
|
1903
|
+
* millimetres from the mark's centre as it reads (y up), each turned
|
|
1904
|
+
* `angle` degrees from running east-west. Pieces too small to hold
|
|
1905
|
+
* (STENCIL_SPECK) are cut away; a larger one with no bridge fails the fit
|
|
1906
|
+
* check, by where it is.
|
|
1907
|
+
*/
|
|
1908
|
+
stencil: z15.object({
|
|
1909
|
+
bridges: z15.array(z15.object({ at: z15.tuple([Mm, Mm]), angle: z15.number().default(0), length: PositiveMm.default(3) })).default([])
|
|
1910
|
+
}).optional()
|
|
1911
|
+
});
|
|
1912
|
+
var HardwareManifestSchema = z15.object({
|
|
1913
|
+
project: z15.string().regex(/^[a-z0-9][a-z0-9_-]*$/, "lowercase, digits, - and _"),
|
|
1914
|
+
/** How the case goes together — see TWO STYLES above. */
|
|
1915
|
+
enclosure_style: z15.enum(["split_shell_lip", "tray_bezel"]).default("split_shell_lip"),
|
|
1916
|
+
wall_thickness: PositiveMm.default(2.4),
|
|
1917
|
+
/**
|
|
1918
|
+
* Thicker walls on chosen sides, in place of `wall_thickness` there. A
|
|
1919
|
+
* screen whose glass is as wide as its board otherwise gets 2.4mm of frame
|
|
1920
|
+
* along its sides and 11mm at its ends, which looks off balance (the
|
|
1921
|
+
* black ESP32-S3 board's flush case, 2026-10-25). Each is a whole number
|
|
1922
|
+
* of nozzle lines, and no thinner than `wall_thickness`.
|
|
1923
|
+
*/
|
|
1924
|
+
walls: z15.object({ east: PositiveMm, west: PositiveMm, north: PositiveMm, south: PositiveMm }).partial().default({}),
|
|
1925
|
+
/** Radius of the vertical outside corners. */
|
|
1926
|
+
corner_radius: NonNegativeMm.default(2),
|
|
1927
|
+
/**
|
|
1928
|
+
* The outside's front and back edges — where the face meets the sides.
|
|
1929
|
+
* `chamfer` bevels them flat at 45°, `round` rounds them; `soften` then
|
|
1930
|
+
* rounds every edge the bevel leaves, so nothing on the outside is sharp.
|
|
1931
|
+
* Without it they are square, and a case reads as a printed box.
|
|
1932
|
+
*/
|
|
1933
|
+
edges: z15.object({
|
|
1934
|
+
style: z15.enum(["chamfer", "round"]),
|
|
1935
|
+
size: PositiveMm,
|
|
1936
|
+
soften: NonNegativeMm.default(0)
|
|
1937
|
+
}).optional(),
|
|
1938
|
+
printer: PrinterProfileSchema.default({}),
|
|
1939
|
+
components: z15.array(ComponentSchema).min(1),
|
|
1940
|
+
emblem: EmblemSchema.optional()
|
|
1941
|
+
}).superRefine((m, ctx) => {
|
|
1942
|
+
const lines = m.wall_thickness / m.printer.nozzle;
|
|
1943
|
+
if (Math.abs(lines - Math.round(lines)) > 1e-6) {
|
|
1944
|
+
ctx.addIssue({
|
|
1945
|
+
code: z15.ZodIssueCode.custom,
|
|
1946
|
+
path: ["wall_thickness"],
|
|
1947
|
+
message: `${m.wall_thickness}mm is not a whole number of ${m.printer.nozzle}mm lines \u2014 try ${(Math.round(lines) * m.printer.nozzle).toFixed(2)}`
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
for (const [side, t] of Object.entries(m.walls)) {
|
|
1951
|
+
if (t === void 0) continue;
|
|
1952
|
+
const n = t / m.printer.nozzle;
|
|
1953
|
+
if (Math.abs(n - Math.round(n)) > 1e-6) {
|
|
1954
|
+
ctx.addIssue({
|
|
1955
|
+
code: z15.ZodIssueCode.custom,
|
|
1956
|
+
path: ["walls", side],
|
|
1957
|
+
message: `${t}mm is not a whole number of ${m.printer.nozzle}mm lines \u2014 try ${(Math.round(n) * m.printer.nozzle).toFixed(2)}`
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
if (t < m.wall_thickness) {
|
|
1961
|
+
ctx.addIssue({
|
|
1962
|
+
code: z15.ZodIssueCode.custom,
|
|
1963
|
+
path: ["walls", side],
|
|
1964
|
+
message: `${t}mm is thinner than wall_thickness (${m.wall_thickness}mm): walls only thicken on chosen sides`
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
const ids = m.components.map((c) => c.id);
|
|
1969
|
+
ids.forEach((id, i) => {
|
|
1970
|
+
if (ids.indexOf(id) !== i) {
|
|
1971
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "id"], message: `"${id}" is used twice` });
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
const roots = m.components.filter((c) => !c.placement);
|
|
1975
|
+
if (roots.length !== 1) {
|
|
1976
|
+
ctx.addIssue({
|
|
1977
|
+
code: z15.ZodIssueCode.custom,
|
|
1978
|
+
path: ["components"],
|
|
1979
|
+
message: `exactly one component must have no placement (the origin); found ${roots.length}: ${roots.map((r) => r.id).join(", ") || "none"}`
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
const byId = new Map(m.components.map((c) => [c.id, c]));
|
|
1983
|
+
m.components.forEach((c, i) => {
|
|
1984
|
+
if (!c.placement) return;
|
|
1985
|
+
const target = c.placement.relative_to;
|
|
1986
|
+
if (!byId.has(target)) {
|
|
1987
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "placement", "relative_to"], message: `no component "${target}"` });
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
const seen = /* @__PURE__ */ new Set([c.id]);
|
|
1991
|
+
for (let at = byId.get(target); at?.placement; at = byId.get(at.placement.relative_to)) {
|
|
1992
|
+
if (seen.has(at.id)) {
|
|
1993
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "placement"], message: `placement loops back to "${at.id}"` });
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
seen.add(at.id);
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1999
|
+
m.components.forEach((c, i) => {
|
|
2000
|
+
if (m.enclosure_style === "split_shell_lip" && c.mount_holes && (!c.mount_holes.insert_od || !c.mount_holes.insert_depth)) {
|
|
2001
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "mount_holes"], message: "a split_shell_lip case holds boards on heat-set inserts: give insert_od and insert_depth" });
|
|
2002
|
+
}
|
|
2003
|
+
c.interfaces.forEach((f, j) => {
|
|
2004
|
+
if (f.chamfer && f.edge !== "top" && f.edge !== "bottom") {
|
|
2005
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "interfaces", j, "chamfer"], message: `a chamfer ramps an opening in the bezel or the floor: its edge must be top or bottom, not ${f.edge}` });
|
|
2006
|
+
}
|
|
2007
|
+
if (f.cutout_shape === "grille" && f.edge !== "top" && f.edge !== "bottom") {
|
|
2008
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "interfaces", j, "cutout_shape"], message: `a grille is a field of holes in the bezel or the floor: its edge must be top or bottom, not ${f.edge}` });
|
|
2009
|
+
}
|
|
2010
|
+
if (f.flex_button && f.edge !== "bottom") {
|
|
2011
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "interfaces", j, "flex_button"], message: `a flex button is pressed through the floor: its edge must be bottom, not ${f.edge}` });
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2014
|
+
const [x, y] = c.dimensions;
|
|
2015
|
+
c.mount_holes?.positions?.forEach((p, j) => {
|
|
2016
|
+
if (Math.abs(p[0]) > x / 2 || Math.abs(p[1]) > y / 2) {
|
|
2017
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "mount_holes", "positions", j], message: `hole at [${p}] is outside the ${x}\xD7${y} footprint` });
|
|
2018
|
+
}
|
|
2019
|
+
});
|
|
2020
|
+
const inset = c.mount_holes?.inset_from_corners;
|
|
2021
|
+
if (inset && (inset[0] * 2 >= x || inset[1] * 2 >= y)) {
|
|
2022
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "mount_holes", "inset_from_corners"], message: `insets [${inset}] meet in the middle of a ${x}\xD7${y} footprint` });
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2025
|
+
});
|
|
2026
|
+
var FamilyChoiceSchema = z15.object({
|
|
2027
|
+
label: z15.string().min(1),
|
|
2028
|
+
/** One sentence: what it is for. */
|
|
2029
|
+
description: z15.string().optional(),
|
|
2030
|
+
/** Components added to the base manifest's. */
|
|
2031
|
+
components: z15.array(ComponentSchema).default([]),
|
|
2032
|
+
/** Top-level manifest fields this choice sets: wall_thickness, emblem… */
|
|
2033
|
+
set: z15.record(z15.unknown()).default({}),
|
|
2034
|
+
/**
|
|
2035
|
+
* Changes to the base's own components, by id: fields to set, null to
|
|
2036
|
+
* remove one, and `interfaces` by name the same way — a null interface is
|
|
2037
|
+
* removed, an unknown one added. How a flush top lowers the board's
|
|
2038
|
+
* clearance and widens its screen opening to the glass.
|
|
2039
|
+
*/
|
|
2040
|
+
patch: z15.record(z15.record(z15.unknown())).default({})
|
|
2041
|
+
});
|
|
2042
|
+
var FamilyOptionSchema = z15.object({
|
|
2043
|
+
label: z15.string().min(1),
|
|
2044
|
+
/** In order; the first is the default. Ids are lowercase words and dashes. */
|
|
2045
|
+
choices: z15.array(FamilyChoiceSchema.extend({ id: z15.string().regex(/^[a-z0-9][a-z0-9-]*$/) })).min(1)
|
|
2046
|
+
});
|
|
2047
|
+
var CaseFamilySchema = z15.object({
|
|
2048
|
+
/** The base manifest, relative to this file. */
|
|
2049
|
+
manifest: z15.string().min(1),
|
|
2050
|
+
/** Option groups, in the order they are offered: base, top… */
|
|
2051
|
+
options: z15.record(z15.string().regex(/^[a-z][a-z0-9-]*$/), FamilyOptionSchema)
|
|
2052
|
+
});
|
|
2053
|
+
|
|
1574
2054
|
// src/auth/schema.ts
|
|
1575
|
-
import { z as
|
|
1576
|
-
var UserSchema =
|
|
1577
|
-
id:
|
|
1578
|
-
name:
|
|
1579
|
-
email:
|
|
1580
|
-
password:
|
|
1581
|
-
role:
|
|
1582
|
-
status:
|
|
1583
|
-
joinedAt:
|
|
1584
|
-
lastActive:
|
|
1585
|
-
avatarUrl:
|
|
2055
|
+
import { z as z16 } from "zod";
|
|
2056
|
+
var UserSchema = z16.object({
|
|
2057
|
+
id: z16.string().default(""),
|
|
2058
|
+
name: z16.string(),
|
|
2059
|
+
email: z16.string().email(),
|
|
2060
|
+
password: z16.string().optional(),
|
|
2061
|
+
role: z16.string(),
|
|
2062
|
+
status: z16.string().optional(),
|
|
2063
|
+
joinedAt: z16.string().optional(),
|
|
2064
|
+
lastActive: z16.string().optional(),
|
|
2065
|
+
avatarUrl: z16.string().optional()
|
|
1586
2066
|
});
|
|
1587
2067
|
|
|
1588
2068
|
// src/auth/accounts.ts
|
|
1589
|
-
import { z as
|
|
1590
|
-
var AccountIdSchema =
|
|
1591
|
-
var AccountRoleSchema =
|
|
1592
|
-
var AccountStatusSchema =
|
|
1593
|
-
var ScryptHashSchema =
|
|
1594
|
-
algo:
|
|
1595
|
-
n:
|
|
1596
|
-
r:
|
|
1597
|
-
p:
|
|
1598
|
-
keylen:
|
|
1599
|
-
salt:
|
|
1600
|
-
hash:
|
|
1601
|
-
});
|
|
1602
|
-
var AccountRecordSchema =
|
|
2069
|
+
import { z as z17 } from "zod";
|
|
2070
|
+
var AccountIdSchema = z17.string().regex(/^acct_[0-9a-f]{12}$/, "acct_ and 12 hex digits");
|
|
2071
|
+
var AccountRoleSchema = z17.enum(["member", "admin"]);
|
|
2072
|
+
var AccountStatusSchema = z17.enum(["active", "suspended"]);
|
|
2073
|
+
var ScryptHashSchema = z17.object({
|
|
2074
|
+
algo: z17.literal("scrypt"),
|
|
2075
|
+
n: z17.number().int().positive(),
|
|
2076
|
+
r: z17.number().int().positive(),
|
|
2077
|
+
p: z17.number().int().positive(),
|
|
2078
|
+
keylen: z17.number().int().positive(),
|
|
2079
|
+
salt: z17.string().min(16),
|
|
2080
|
+
hash: z17.string().min(16)
|
|
2081
|
+
});
|
|
2082
|
+
var AccountRecordSchema = z17.object({
|
|
1603
2083
|
accountId: AccountIdSchema,
|
|
1604
2084
|
/** Lowercased on write, because a login must not depend on how it was typed. */
|
|
1605
|
-
email:
|
|
1606
|
-
name:
|
|
2085
|
+
email: z17.string().email().max(254),
|
|
2086
|
+
name: z17.string().min(1).max(64),
|
|
1607
2087
|
role: AccountRoleSchema,
|
|
1608
2088
|
status: AccountStatusSchema,
|
|
1609
2089
|
password: ScryptHashSchema,
|
|
1610
|
-
createdAt:
|
|
1611
|
-
lastLoginAt:
|
|
2090
|
+
createdAt: z17.number().int().nonnegative(),
|
|
2091
|
+
lastLoginAt: z17.number().int().nonnegative().nullable().default(null),
|
|
1612
2092
|
/** Which admin approved this, or null for the bootstrap account. */
|
|
1613
2093
|
invitedBy: AccountIdSchema.nullable().default(null)
|
|
1614
2094
|
});
|
|
1615
|
-
var
|
|
2095
|
+
var DISPLAY_NAME_MAX = 40;
|
|
2096
|
+
var DisplayNameSchema = z17.string().transform((s) => s.trim().replace(/\s+/g, " ")).pipe(
|
|
2097
|
+
z17.string().min(1, "Give a name.").max(DISPLAY_NAME_MAX, `At most ${DISPLAY_NAME_MAX} characters.`).refine((s) => !/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069]/.test(s), "Letters, numbers, spaces and punctuation only.")
|
|
2098
|
+
);
|
|
2099
|
+
var PublicAccountSchema = z17.object({
|
|
1616
2100
|
accountId: AccountIdSchema,
|
|
1617
|
-
email:
|
|
1618
|
-
name:
|
|
2101
|
+
email: z17.string().email(),
|
|
2102
|
+
name: z17.string(),
|
|
1619
2103
|
role: AccountRoleSchema,
|
|
1620
2104
|
status: AccountStatusSchema
|
|
1621
2105
|
});
|
|
1622
|
-
var SessionRecordSchema =
|
|
2106
|
+
var SessionRecordSchema = z17.object({
|
|
1623
2107
|
accountId: AccountIdSchema,
|
|
1624
|
-
createdAt:
|
|
1625
|
-
expiresAt:
|
|
1626
|
-
lastSeenAt:
|
|
2108
|
+
createdAt: z17.number().int().nonnegative(),
|
|
2109
|
+
expiresAt: z17.number().int().nonnegative(),
|
|
2110
|
+
lastSeenAt: z17.number().int().nonnegative()
|
|
1627
2111
|
});
|
|
1628
|
-
var InviteRecordSchema =
|
|
1629
|
-
email:
|
|
2112
|
+
var InviteRecordSchema = z17.object({
|
|
2113
|
+
email: z17.string().email().max(254),
|
|
1630
2114
|
role: AccountRoleSchema,
|
|
1631
|
-
createdAt:
|
|
1632
|
-
expiresAt:
|
|
2115
|
+
createdAt: z17.number().int().nonnegative(),
|
|
2116
|
+
expiresAt: z17.number().int().nonnegative(),
|
|
1633
2117
|
invitedBy: AccountIdSchema
|
|
1634
2118
|
});
|
|
1635
|
-
var AccessRequestSchema =
|
|
1636
|
-
email:
|
|
1637
|
-
name:
|
|
2119
|
+
var AccessRequestSchema = z17.object({
|
|
2120
|
+
email: z17.string().email().max(254),
|
|
2121
|
+
name: z17.string().min(1).max(64),
|
|
1638
2122
|
/** Optional, and never shown publicly. Long enough to be useful, short enough not to be an essay. */
|
|
1639
|
-
reason:
|
|
1640
|
-
});
|
|
1641
|
-
var AccessRequestStatusSchema =
|
|
1642
|
-
var AccessRequestRecordSchema =
|
|
1643
|
-
requestId:
|
|
1644
|
-
email:
|
|
1645
|
-
name:
|
|
1646
|
-
reason:
|
|
2123
|
+
reason: z17.string().max(500).optional()
|
|
2124
|
+
});
|
|
2125
|
+
var AccessRequestStatusSchema = z17.enum(["pending", "approved", "denied"]);
|
|
2126
|
+
var AccessRequestRecordSchema = z17.object({
|
|
2127
|
+
requestId: z17.string().regex(/^req_[0-9a-f]{12}$/, "req_ and 12 hex digits"),
|
|
2128
|
+
email: z17.string().email().max(254),
|
|
2129
|
+
name: z17.string().min(1).max(64),
|
|
2130
|
+
reason: z17.string().max(500).optional(),
|
|
1647
2131
|
status: AccessRequestStatusSchema,
|
|
1648
|
-
createdAt:
|
|
1649
|
-
decidedAt:
|
|
2132
|
+
createdAt: z17.number().int().nonnegative(),
|
|
2133
|
+
decidedAt: z17.number().int().nonnegative().nullable().default(null),
|
|
1650
2134
|
decidedBy: AccountIdSchema.nullable().default(null)
|
|
1651
2135
|
});
|
|
1652
2136
|
var SCRYPT_PARAMS = {
|
|
@@ -1664,196 +2148,44 @@ var ACCOUNT_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
|
1664
2148
|
var INVITE_TTL_SECONDS = 60 * 60 * 24 * 14;
|
|
1665
2149
|
var ACCESS_REQUEST_TTL_SECONDS = 60 * 60 * 24 * 90;
|
|
1666
2150
|
|
|
1667
|
-
// src/
|
|
1668
|
-
import { z as
|
|
1669
|
-
var
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
"
|
|
1673
|
-
"
|
|
1674
|
-
"regulator",
|
|
1675
|
-
"unknown"
|
|
1676
|
-
]);
|
|
1677
|
-
var CounterpartyResolutionSchema = z14.enum([
|
|
1678
|
-
"public",
|
|
1679
|
-
"public_uncovered",
|
|
1680
|
-
"private",
|
|
1681
|
-
"unresolved"
|
|
1682
|
-
]);
|
|
1683
|
-
var CounterpartyNodeSchema = z14.object({
|
|
1684
|
-
id: z14.string(),
|
|
1685
|
-
ticker: z14.string().nullable(),
|
|
1686
|
-
/** Name as it appeared in the source signal — e.g. "Nike". Not the registered name. */
|
|
1687
|
-
name: z14.string(),
|
|
1688
|
-
/** Registered legal name from `profiles` — e.g. "NIKE, Inc.". Null unless `public`. */
|
|
1689
|
-
publicName: z14.string().nullable(),
|
|
1690
|
-
lei: z14.string().nullable(),
|
|
1691
|
-
resolution: CounterpartyResolutionSchema,
|
|
1692
|
-
type: CounterpartyTypeSchema,
|
|
1693
|
-
confidence: z14.number().min(0).max(1),
|
|
1694
|
-
sourceSignalIds: z14.array(z14.number()),
|
|
1695
|
-
firstSeenAt: z14.string().datetime(),
|
|
1696
|
-
lastSeenAt: z14.string().datetime()
|
|
1697
|
-
});
|
|
1698
|
-
var RelationshipEdgeTypeSchema = z14.enum([
|
|
1699
|
-
"supplies_to",
|
|
1700
|
-
"purchases_from",
|
|
1701
|
-
"partners_with",
|
|
1702
|
-
"competes_with",
|
|
1703
|
-
"regulated_by",
|
|
1704
|
-
"invests_in",
|
|
1705
|
-
"acquires",
|
|
1706
|
-
/**
|
|
1707
|
-
* Identity equivalence, not a business relationship: source and target are
|
|
1708
|
-
* the same real-world entity under two different node ids (typically a
|
|
1709
|
-
* slug-keyed node that predates LEI resolution, pointing at the canonical
|
|
1710
|
-
* LEI-keyed node once resolution succeeds). Never delete/merge either
|
|
1711
|
-
* node — this edge exists so a consumer wanting a deduped view can follow
|
|
1712
|
-
* it to the canonical id, reversibly.
|
|
1713
|
-
*/
|
|
1714
|
-
"same_as"
|
|
1715
|
-
]);
|
|
1716
|
-
var RelationshipEdgeSchema = z14.object({
|
|
1717
|
-
id: z14.string(),
|
|
1718
|
-
sourceId: z14.string(),
|
|
1719
|
-
targetId: z14.string(),
|
|
1720
|
-
edgeType: RelationshipEdgeTypeSchema,
|
|
1721
|
-
weight: z14.number().min(0).max(1),
|
|
1722
|
-
evidenceSignalIds: z14.array(z14.number()),
|
|
1723
|
-
updatedAt: z14.string().datetime(),
|
|
1724
|
-
validFrom: z14.string().datetime(),
|
|
1725
|
-
/** null = currently valid. Set when a differently-typed edge supersedes this one. */
|
|
1726
|
-
validTo: z14.string().datetime().nullable()
|
|
1727
|
-
});
|
|
1728
|
-
var SignalWeightSchema = z14.object({
|
|
1729
|
-
signalId: z14.number(),
|
|
1730
|
-
weight: z14.number().min(0).max(1),
|
|
1731
|
-
reason: z14.string().max(280)
|
|
1732
|
-
});
|
|
1733
|
-
var DivergenceMetricSchema = z14.object({
|
|
1734
|
-
ticker: z14.string(),
|
|
1735
|
-
// 'operations'/'customer' are current; 'operational'/'ux' are pre-rename
|
|
1736
|
-
// values that still exist on rows written before the backend's rename —
|
|
1737
|
-
// kept here so reading old rows doesn't fail validation.
|
|
1738
|
-
metric: z14.enum(["operations", "customer", "operational", "ux"]),
|
|
1739
|
-
score: z14.number(),
|
|
1740
|
-
baseline: z14.number(),
|
|
1741
|
-
observed: z14.number(),
|
|
1742
|
-
computedAt: z14.string().datetime(),
|
|
1743
|
-
contributingSignals: z14.array(SignalWeightSchema)
|
|
1744
|
-
});
|
|
1745
|
-
|
|
1746
|
-
// src/non-public-entity/schema.ts
|
|
1747
|
-
import { z as z15 } from "zod";
|
|
1748
|
-
var NonPublicEntitySchema = z15.object({
|
|
1749
|
-
lei: z15.string().nullable(),
|
|
1750
|
-
entityName: z15.string(),
|
|
1751
|
-
jurisdiction: z15.string().nullable(),
|
|
1752
|
-
registrationStatus: z15.string(),
|
|
1753
|
-
parentEntityLei: z15.string().nullable(),
|
|
1754
|
-
materialMetadata: z15.record(z15.unknown()),
|
|
1755
|
-
discoveredAt: z15.string().datetime()
|
|
1756
|
-
});
|
|
1757
|
-
|
|
1758
|
-
// src/events/schema.ts
|
|
1759
|
-
import { z as z16 } from "zod";
|
|
1760
|
-
var EventSourceSchema = z16.enum(["db", "mock"]);
|
|
1761
|
-
var EntityEventKindSchema = z16.enum(["news", "filing", "report"]);
|
|
1762
|
-
var ImpactScaleSchema = z16.enum(["graded", "binary", "default", "none"]);
|
|
1763
|
-
var TimestampPrecisionSchema = z16.enum(["second", "day"]);
|
|
1764
|
-
var EntityEventSchema = z16.object({
|
|
1765
|
-
/** Namespaced so ids never collide across sources: `news:1234`, `filing:AAPL:2026-07-31`. */
|
|
1766
|
-
id: z16.string(),
|
|
1767
|
-
kind: EntityEventKindSchema,
|
|
1768
|
-
/**
|
|
1769
|
-
* The producer's own type string, unmodified — `NEWS_YAHOO FINANCE_YAHOO RSS`,
|
|
1770
|
-
* `ANNUAL`, `SNAPSHOT`. There are 31 distinct NEWS variants in the live table,
|
|
1771
|
-
* so this is for filtering and debugging: never render it raw to a user.
|
|
1772
|
-
*/
|
|
1773
|
-
subtype: z16.string().nullable(),
|
|
1774
|
-
ticker: z16.string(),
|
|
1775
|
-
/** Always `YYYY-MM-DDTHH:MM:SSZ`. Fixed-width, so lexical order == chronological order. */
|
|
1776
|
-
occurredAt: z16.string(),
|
|
1777
|
-
precision: TimestampPrecisionSchema,
|
|
1778
|
-
title: z16.string(),
|
|
1779
|
-
summary: z16.string().nullable(),
|
|
1780
|
-
url: z16.string().nullable(),
|
|
1781
|
-
impact: z16.number().nullable(),
|
|
1782
|
-
impactScale: ImpactScaleSchema,
|
|
1783
|
-
/** 0 bearish … 50 neutral … 100 bullish. */
|
|
1784
|
-
sentiment: z16.number().nullable(),
|
|
1785
|
-
/** False for filings, and for any event sitting at exactly neutral. */
|
|
1786
|
-
sentimentIsMeaningful: z16.boolean(),
|
|
1787
|
-
source: EventSourceSchema,
|
|
1788
|
-
meta: z16.record(z16.unknown()).nullable()
|
|
1789
|
-
});
|
|
1790
|
-
var PaginatedEntityEventsSchema = z16.object({
|
|
1791
|
-
total: z16.number(),
|
|
1792
|
-
page: z16.number(),
|
|
1793
|
-
page_size: z16.number(),
|
|
1794
|
-
data: z16.array(EntityEventSchema)
|
|
1795
|
-
});
|
|
1796
|
-
var EventBucketSizeSchema = z16.enum(["day", "week", "month"]);
|
|
1797
|
-
var EntityEventDensityBucketSchema = z16.object({
|
|
1798
|
-
bucketStart: z16.string(),
|
|
1799
|
-
kind: EntityEventKindSchema,
|
|
1800
|
-
count: z16.number(),
|
|
1801
|
-
/** Null when no event in the bucket had meaningful sentiment. */
|
|
1802
|
-
avgSentiment: z16.number().nullable(),
|
|
1803
|
-
maxImpact: z16.number().nullable()
|
|
1804
|
-
});
|
|
1805
|
-
var EntityEventDensitySchema = z16.object({
|
|
1806
|
-
ticker: z16.string(),
|
|
1807
|
-
bucket: EventBucketSizeSchema,
|
|
1808
|
-
buckets: z16.array(EntityEventDensityBucketSchema),
|
|
1809
|
-
/** So the client can set its time domain without a second request. */
|
|
1810
|
-
range: z16.object({ min: z16.string(), max: z16.string() }),
|
|
1811
|
-
source: EventSourceSchema
|
|
1812
|
-
});
|
|
1813
|
-
var EntityEventFacetSchema = z16.object({
|
|
1814
|
-
kind: EntityEventKindSchema,
|
|
1815
|
-
count: z16.number(),
|
|
1816
|
-
earliest: z16.string().nullable(),
|
|
1817
|
-
latest: z16.string().nullable(),
|
|
1818
|
-
impactScale: ImpactScaleSchema,
|
|
1819
|
-
sentimentUsable: z16.boolean()
|
|
1820
|
-
});
|
|
1821
|
-
var EntityEventFacetsSchema = z16.object({
|
|
1822
|
-
ticker: z16.string(),
|
|
1823
|
-
facets: z16.array(EntityEventFacetSchema),
|
|
1824
|
-
source: EventSourceSchema
|
|
1825
|
-
});
|
|
1826
|
-
var DailyPricePointSchema = z16.object({
|
|
1827
|
-
date: z16.string(),
|
|
1828
|
-
open: z16.number().nullable(),
|
|
1829
|
-
high: z16.number().nullable(),
|
|
1830
|
-
low: z16.number().nullable(),
|
|
1831
|
-
close: z16.number(),
|
|
1832
|
-
volume: z16.number().nullable()
|
|
1833
|
-
});
|
|
1834
|
-
var EntityPriceSeriesSchema = z16.object({
|
|
1835
|
-
ticker: z16.string(),
|
|
1836
|
-
series: z16.array(DailyPricePointSchema),
|
|
1837
|
-
source: EventSourceSchema
|
|
1838
|
-
});
|
|
1839
|
-
var EVENT_KIND_LABELS = {
|
|
1840
|
-
news: "News",
|
|
1841
|
-
filing: "Filing",
|
|
1842
|
-
report: "Analyst report"
|
|
1843
|
-
};
|
|
1844
|
-
var IMPACT_FLAG_THRESHOLD = 7;
|
|
1845
|
-
var SENTIMENT_NEUTRAL = 50;
|
|
1846
|
-
var DEFAULT_HORIZON_QUARTERS = 5;
|
|
1847
|
-
var EXCLUDED_SOURCES = {
|
|
1848
|
-
insights: "insights.ANALYSIS is a verbatim 1:1 mirror of signals \u2014 every AAPL ANALYSIS row contains a news description verbatim and lands within 2s of it. Including it doubles every event.",
|
|
1849
|
-
divergence_metrics: "A continuously recomputed annotation, not an event: 524 AAPL rows in 2 days.",
|
|
1850
|
-
counterparty_edges: "No history exists \u2014 all rows were created within a 2-day window, so nothing can be placed on a time axis without fabricating it.",
|
|
1851
|
-
raw_filings: "Stale since April, superseded by signals.",
|
|
1852
|
-
market_metrics: "Two rows total.",
|
|
1853
|
-
job_log: "24.5M rows with no ticker index \u2014 never touch it in a request path."
|
|
2151
|
+
// src/auth/accessTokens.ts
|
|
2152
|
+
import { z as z18 } from "zod";
|
|
2153
|
+
var ACCESS_TOKEN_SCOPES = ["boards:read", "boards:send"];
|
|
2154
|
+
var AccessTokenScopeSchema = z18.enum(ACCESS_TOKEN_SCOPES);
|
|
2155
|
+
var ACCESS_TOKEN_SCOPE_LABELS = {
|
|
2156
|
+
"boards:read": "See my boards",
|
|
2157
|
+
"boards:send": "Send apps to my boards"
|
|
1854
2158
|
};
|
|
2159
|
+
var ACCESS_TOKEN_PREFIX = "rmk_";
|
|
2160
|
+
var ACCESS_TOKEN_LIFETIMES_DAYS = [7, 30, 90, 365];
|
|
2161
|
+
var ACCESS_TOKEN_MAX_PER_ACCOUNT = 20;
|
|
2162
|
+
var ACCESS_TOKEN_RATE_PER_MINUTE = 60;
|
|
2163
|
+
var AccessTokenRecordSchema = z18.object({
|
|
2164
|
+
/** The first 12 hex digits of the hash: what the owner sees and revokes by. */
|
|
2165
|
+
tokenId: z18.string().regex(/^[0-9a-f]{12}$/),
|
|
2166
|
+
accountId: AccountIdSchema,
|
|
2167
|
+
/** What the owner called it: "laptop", "Claude Code". */
|
|
2168
|
+
name: z18.string().trim().min(1).max(60),
|
|
2169
|
+
scopes: z18.array(AccessTokenScopeSchema).min(1),
|
|
2170
|
+
createdAt: z18.number().int().nonnegative(),
|
|
2171
|
+
expiresAt: z18.number().int().nonnegative(),
|
|
2172
|
+
/** Moved forward at most once a day, so using a token is not a write per request. */
|
|
2173
|
+
lastUsedAt: z18.number().int().nonnegative().nullable().default(null)
|
|
2174
|
+
});
|
|
2175
|
+
var PublicAccessTokenSchema = AccessTokenRecordSchema.omit({ accountId: true });
|
|
2176
|
+
var NewAccessTokenSchema = z18.object({
|
|
2177
|
+
name: z18.string().trim().min(1, "Give it a name.").max(60),
|
|
2178
|
+
scopes: z18.array(AccessTokenScopeSchema).min(1, "Choose at least one thing it can do."),
|
|
2179
|
+
days: z18.union(ACCESS_TOKEN_LIFETIMES_DAYS.map((d) => z18.literal(d)))
|
|
2180
|
+
});
|
|
1855
2181
|
export {
|
|
1856
2182
|
ACCESS_REQUEST_TTL_SECONDS,
|
|
2183
|
+
ACCESS_TOKEN_LIFETIMES_DAYS,
|
|
2184
|
+
ACCESS_TOKEN_MAX_PER_ACCOUNT,
|
|
2185
|
+
ACCESS_TOKEN_PREFIX,
|
|
2186
|
+
ACCESS_TOKEN_RATE_PER_MINUTE,
|
|
2187
|
+
ACCESS_TOKEN_SCOPES,
|
|
2188
|
+
ACCESS_TOKEN_SCOPE_LABELS,
|
|
1857
2189
|
ACCOUNT_TTL_SECONDS,
|
|
1858
2190
|
AIKeyManifestSchema,
|
|
1859
2191
|
AIThemeSchema,
|
|
@@ -1866,10 +2198,13 @@ export {
|
|
|
1866
2198
|
AccessRequestRecordSchema,
|
|
1867
2199
|
AccessRequestSchema,
|
|
1868
2200
|
AccessRequestStatusSchema,
|
|
2201
|
+
AccessTokenRecordSchema,
|
|
2202
|
+
AccessTokenScopeSchema,
|
|
1869
2203
|
AccountIdSchema,
|
|
1870
2204
|
AccountRecordSchema,
|
|
1871
2205
|
AccountRoleSchema,
|
|
1872
2206
|
AccountStatusSchema,
|
|
2207
|
+
AccountThemeSchema,
|
|
1873
2208
|
ActionSchema,
|
|
1874
2209
|
AircraftAppConfigSchema,
|
|
1875
2210
|
AppAlignSchema,
|
|
@@ -1901,106 +2236,120 @@ export {
|
|
|
1901
2236
|
AssetHashSchema,
|
|
1902
2237
|
AuthStrategySchema,
|
|
1903
2238
|
BlockSchema,
|
|
2239
|
+
BoardFontSchema,
|
|
2240
|
+
BoardPaletteHexSchema,
|
|
1904
2241
|
schema_exports as Bodewell,
|
|
1905
2242
|
CLAIMED_DEVICE_TTL_SECONDS,
|
|
2243
|
+
CONTROL_STATES,
|
|
2244
|
+
CONTROL_STATE_MEANINGS,
|
|
2245
|
+
CaseFamilySchema,
|
|
1906
2246
|
ClockAppConfigSchema,
|
|
1907
|
-
|
|
1908
|
-
CounterpartyResolutionSchema,
|
|
1909
|
-
CounterpartyTypeSchema,
|
|
2247
|
+
ComponentSchema,
|
|
1910
2248
|
DEFAULT_CHAT_MODEL,
|
|
1911
2249
|
DEFAULT_DEVICE_CONFIG,
|
|
1912
|
-
DEFAULT_HORIZON_QUARTERS,
|
|
1913
2250
|
DEFAULT_PRO_MODEL,
|
|
1914
2251
|
DEFAULT_SCHEMA_MODEL,
|
|
1915
2252
|
DEFAULT_THEME_TOKENS,
|
|
1916
2253
|
DEVICE_AP_SSID_PREFIX,
|
|
1917
2254
|
DEVICE_ENDPOINTS,
|
|
2255
|
+
DEVICE_FEATURES,
|
|
2256
|
+
DEVICE_FEATURE_STATE_LABELS,
|
|
1918
2257
|
DEVICE_FRESH_MS,
|
|
1919
2258
|
DEVICE_GLYPHS,
|
|
1920
2259
|
DEVICE_LABEL_MAX,
|
|
1921
2260
|
DEVICE_PALETTE,
|
|
2261
|
+
DEVICE_POLL_QUERY,
|
|
2262
|
+
DEVICE_PROTOCOL,
|
|
1922
2263
|
DEVICE_STALE_MS,
|
|
1923
2264
|
DEVICE_TIMEZONES,
|
|
1924
2265
|
DEVICE_TIMEZONE_FALLBACK,
|
|
1925
2266
|
DEVICE_TTL_SECONDS,
|
|
1926
2267
|
DEVICE_UNKNOWN_GLYPH,
|
|
1927
2268
|
DEVICE_VITALS_FIELDS,
|
|
1928
|
-
|
|
2269
|
+
DISPLAY_FACE_MIN_PX,
|
|
2270
|
+
DISPLAY_NAME_MAX,
|
|
1929
2271
|
DeliveredAppSchema,
|
|
1930
2272
|
DeviceAppIdSchema,
|
|
1931
2273
|
DeviceAppsSchema,
|
|
1932
2274
|
DeviceConfigSchema,
|
|
1933
2275
|
DeviceDisplayConfigSchema,
|
|
2276
|
+
DeviceFeatureKeySchema,
|
|
2277
|
+
DeviceFeatureStateSchema,
|
|
2278
|
+
DeviceFeaturesSchema,
|
|
1934
2279
|
DeviceIdSchema,
|
|
1935
2280
|
DeviceKindSchema,
|
|
2281
|
+
DevicePollReplySchema,
|
|
2282
|
+
DeviceReadingSchema,
|
|
1936
2283
|
DeviceRecordSchema,
|
|
1937
2284
|
DeviceRegistrationSchema,
|
|
2285
|
+
DeviceReportSchema,
|
|
1938
2286
|
DeviceSeenSchema,
|
|
1939
2287
|
DeviceStatusSchema,
|
|
1940
2288
|
DeviceThemeSchema,
|
|
1941
2289
|
DeviceVitalsSchema,
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
EntityEventDensityBucketSchema,
|
|
1946
|
-
EntityEventDensitySchema,
|
|
1947
|
-
EntityEventFacetSchema,
|
|
1948
|
-
EntityEventFacetsSchema,
|
|
1949
|
-
EntityEventKindSchema,
|
|
1950
|
-
EntityEventSchema,
|
|
1951
|
-
EntityPriceSeriesSchema,
|
|
2290
|
+
DisplayNameSchema,
|
|
2291
|
+
EdgeSchema,
|
|
2292
|
+
EmblemSchema,
|
|
1952
2293
|
EntitySchema,
|
|
1953
|
-
EventBucketSizeSchema,
|
|
1954
|
-
EventSourceSchema,
|
|
1955
2294
|
FIRMWARE_UPDATE_ATTEMPTS,
|
|
1956
2295
|
FIRMWARE_UPDATE_PREFIX,
|
|
1957
2296
|
FULL_COLOUR_FRAME_MAX,
|
|
1958
2297
|
FULL_RENDITION,
|
|
2298
|
+
FamilyChoiceSchema,
|
|
2299
|
+
FamilyOptionSchema,
|
|
1959
2300
|
FieldSchema,
|
|
1960
2301
|
FirmwareUpdateSchema,
|
|
2302
|
+
FlexButtonSchema,
|
|
1961
2303
|
FloraTelemetrySchema,
|
|
1962
2304
|
GENESIS_LIBRARY_CONTEXT,
|
|
1963
2305
|
GENESIS_VALID_COMPONENTS,
|
|
2306
|
+
HardwareManifestSchema,
|
|
1964
2307
|
ICON_GRID,
|
|
1965
2308
|
ICON_SIZE_PX,
|
|
1966
2309
|
ICON_STROKE,
|
|
1967
2310
|
IMAGE_MAX_DRAWN,
|
|
1968
2311
|
IMAGE_MAX_SCALE,
|
|
1969
|
-
IMPACT_FLAG_THRESHOLD,
|
|
1970
2312
|
INVITE_TTL_SECONDS,
|
|
1971
|
-
|
|
2313
|
+
InterfaceSchema,
|
|
1972
2314
|
InviteRecordSchema,
|
|
1973
2315
|
MAX_PASSWORD_LENGTH,
|
|
1974
2316
|
MIN_PASSWORD_LENGTH,
|
|
1975
|
-
|
|
2317
|
+
MountHolesSchema,
|
|
2318
|
+
NewAccessTokenSchema,
|
|
1976
2319
|
ORIGINAL_MAX_BYTES,
|
|
1977
2320
|
ORIGINAL_MAX_SIDE,
|
|
1978
2321
|
OwnedSendRequestSchema,
|
|
2322
|
+
PANEL_SIZE,
|
|
1979
2323
|
PHOTOS_PER_ACCOUNT,
|
|
1980
2324
|
PHOTO_UPLOADS_PER_HOUR,
|
|
1981
2325
|
PROVIDER_DEFAULT_MODEL,
|
|
1982
2326
|
PageSchema,
|
|
1983
2327
|
PageSectionSchema,
|
|
1984
|
-
PaginatedEntityEventsSchema,
|
|
1985
2328
|
PairCodeSchema,
|
|
2329
|
+
PanelOrientationSchema,
|
|
1986
2330
|
PhotoCropSchema,
|
|
1987
2331
|
PhotoFullSchema,
|
|
1988
2332
|
PhotoSummarySchema,
|
|
1989
2333
|
PhotoUploadSchema,
|
|
2334
|
+
PlacementSchema,
|
|
2335
|
+
PrinterProfileSchema,
|
|
1990
2336
|
ProvisioningStateSchema,
|
|
2337
|
+
PublicAccessTokenSchema,
|
|
1991
2338
|
PublicAccountSchema,
|
|
1992
2339
|
RETRO_RENDITION,
|
|
1993
|
-
RelationshipEdgeSchema,
|
|
1994
|
-
RelationshipEdgeTypeSchema,
|
|
1995
2340
|
ResourceSchema,
|
|
1996
2341
|
SCRYPT_PARAMS,
|
|
1997
|
-
SENTIMENT_NEUTRAL,
|
|
1998
2342
|
SESSION_COOKIE_NAME,
|
|
1999
2343
|
SESSION_TTL_SECONDS,
|
|
2344
|
+
SHELF_MAX_APPS,
|
|
2345
|
+
SHELF_MAX_BYTES,
|
|
2346
|
+
SHELF_ROTATE_MINUTES,
|
|
2000
2347
|
SIGNAL_DOMAINS,
|
|
2001
2348
|
SIGNAL_KINDS,
|
|
2002
2349
|
SIGNAL_KIND_LABELS,
|
|
2003
2350
|
SIGNAL_SOURCES,
|
|
2351
|
+
SMOOTH_FACES,
|
|
2352
|
+
SMOOTH_FONT_ADVANCES,
|
|
2004
2353
|
SPRITE_MAX_BASE64,
|
|
2005
2354
|
SPRITE_MAX_ROW_BYTES,
|
|
2006
2355
|
SPRITE_MAX_SIDE,
|
|
@@ -2010,18 +2359,23 @@ export {
|
|
|
2010
2359
|
SendRequestSchema,
|
|
2011
2360
|
SensorAppConfigSchema,
|
|
2012
2361
|
SessionRecordSchema,
|
|
2362
|
+
ShelfEditSchema,
|
|
2363
|
+
ShelfSchema,
|
|
2013
2364
|
SignalArraySchema,
|
|
2014
2365
|
SignalKindSchema,
|
|
2015
2366
|
SignalPacketSchema,
|
|
2016
2367
|
SignalSchema,
|
|
2017
2368
|
SignalSourceSchema,
|
|
2018
|
-
|
|
2369
|
+
THEME_PALETTE_TOKENS,
|
|
2019
2370
|
THEME_PRESETS,
|
|
2371
|
+
THEME_RADII,
|
|
2020
2372
|
THEME_SYSTEM_PROMPT,
|
|
2021
2373
|
ThemeFontsSchema,
|
|
2374
|
+
ThemeLetteringSchema,
|
|
2022
2375
|
ThemeOverridesSchema,
|
|
2376
|
+
ThemePaletteSchema,
|
|
2377
|
+
ThemeRgbSchema,
|
|
2023
2378
|
ThemeTokensSchema,
|
|
2024
|
-
TimestampPrecisionSchema,
|
|
2025
2379
|
TriggerSchema,
|
|
2026
2380
|
UserSchema,
|
|
2027
2381
|
VitalSourceSchema,
|
|
@@ -2030,12 +2384,5 @@ export {
|
|
|
2030
2384
|
WEATHER_ICON_NAMES,
|
|
2031
2385
|
WeatherAppConfigSchema,
|
|
2032
2386
|
WorkflowSchema,
|
|
2033
|
-
architectureReferenceParameters,
|
|
2034
|
-
companyNewsParameters,
|
|
2035
|
-
companyProfileParameters,
|
|
2036
|
-
counterpartyGraphParameters,
|
|
2037
|
-
divergenceMetricsParameters,
|
|
2038
|
-
liveQuoteParameters,
|
|
2039
|
-
stockChartParameters,
|
|
2040
2387
|
telemetryGraphParameters
|
|
2041
2388
|
};
|