@theruntime/protocol 0.0.0 → 0.0.1

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +14 -4
  3. package/src/error.ts +54 -0
  4. package/src/events/index.ts +51 -0
  5. package/src/guidance/index.ts +3 -0
  6. package/src/index.ts +46 -0
  7. package/src/logs/index.ts +46 -0
  8. package/src/notifications/event.ts +62 -0
  9. package/src/notifications.ts +5 -0
  10. package/src/operations/add-component.ts +121 -0
  11. package/src/operations/add-package.ts +58 -0
  12. package/src/operations/app-record.ts +29 -0
  13. package/src/operations/archive-route.ts +48 -0
  14. package/src/operations/capture-snapshot.ts +46 -0
  15. package/src/operations/declaration.ts +115 -0
  16. package/src/operations/declare-route.ts +66 -0
  17. package/src/operations/delete-app.ts +47 -0
  18. package/src/operations/delete-record.ts +46 -0
  19. package/src/operations/describe-route.ts +122 -0
  20. package/src/operations/emit-event.ts +66 -0
  21. package/src/operations/get-record.ts +44 -0
  22. package/src/operations/get-snapshot.ts +64 -0
  23. package/src/operations/guidance.ts +91 -0
  24. package/src/operations/heartbeat.ts +27 -0
  25. package/src/operations/identify.ts +50 -0
  26. package/src/operations/list-packages.ts +72 -0
  27. package/src/operations/list-presence.ts +64 -0
  28. package/src/operations/list-quick-actions.ts +60 -0
  29. package/src/operations/list-records.ts +55 -0
  30. package/src/operations/list-route-logs.ts +98 -0
  31. package/src/operations/list-routes.ts +101 -0
  32. package/src/operations/list-subscribers.ts +75 -0
  33. package/src/operations/list-subscriptions.ts +98 -0
  34. package/src/operations/list-templates.ts +71 -0
  35. package/src/operations/log-line.ts +222 -0
  36. package/src/operations/parse-helpers.ts +136 -0
  37. package/src/operations/query-selection.ts +44 -0
  38. package/src/operations/read-daemon-log.ts +29 -0
  39. package/src/operations/read-route-log.ts +39 -0
  40. package/src/operations/reboot-route.ts +45 -0
  41. package/src/operations/record-status.ts +18 -0
  42. package/src/operations/register-route.ts +135 -0
  43. package/src/operations/save-record.ts +55 -0
  44. package/src/operations/set-record-status.ts +63 -0
  45. package/src/operations/set-route-visibility.ts +48 -0
  46. package/src/operations/set-selection.ts +53 -0
  47. package/src/operations/subscribe.ts +47 -0
  48. package/src/operations/unregister-route.ts +36 -0
  49. package/src/operations/unsubscribe.ts +44 -0
  50. package/src/operations/visibility.ts +9 -0
  51. package/src/operations.ts +39 -0
  52. package/src/payloads/app-ready.ts +24 -0
  53. package/src/payloads/refusal.ts +44 -0
  54. package/src/payloads.ts +11 -0
  55. package/src/quick-actions/index.ts +12 -0
  56. package/src/readiness.ts +52 -0
  57. package/src/records/index.ts +46 -0
  58. package/src/routes/index.ts +104 -0
  59. package/src/selection/index.ts +16 -0
  60. package/src/sessions/index.ts +24 -0
  61. package/src/snapshots/index.ts +20 -0
  62. package/src/templates/index.ts +14 -0
  63. package/src/toolchain/index.ts +36 -0
  64. package/src/version.ts +3 -0
  65. package/README.md +0 -3
@@ -0,0 +1,52 @@
1
+ import { asRecord, optionalNonNegativeInteger } from "./operations/parse-helpers";
2
+
3
+ const NOUN = "a route readiness";
4
+
5
+ /**
6
+ * What a route's page has reported about its own rendering. "unknown" is no document served yet.
7
+ * "pending" is a document served and no report yet, inside the window. "ready" is a first frame
8
+ * committed with children under the root. "empty" is a first frame committed with none.
9
+ * "silent" is a document served and nothing reported, past the window.
10
+ */
11
+ export const APP_READINESS_STATES = ["unknown", "pending", "ready", "empty", "silent"] as const;
12
+ export type AppReadinessState = (typeof APP_READINESS_STATES)[number];
13
+
14
+ /**
15
+ * How long a served document may report nothing before the reading calls it silent. Sized above
16
+ * the slowest cold boot the engine has been measured through, so silent never names a load that
17
+ * is merely slow. A caller with a tighter budget reads sinceMs and decides for itself.
18
+ */
19
+ export const APP_READY_WINDOW_MS = 120_000;
20
+
21
+ export function isAppReadinessState(value: unknown): value is AppReadinessState {
22
+ if (typeof value !== "string") return false;
23
+ const states: readonly string[] = APP_READINESS_STATES;
24
+ return states.includes(value);
25
+ }
26
+
27
+ export interface AppReadiness {
28
+ readonly state: AppReadinessState;
29
+ /** Milliseconds since the stamp the state is derived from. Absent for "unknown". */
30
+ readonly sinceMs?: number;
31
+ /** How many elements the root held when the first frame committed. Present once a report
32
+ * arrived, including the zero that names a page that mounted and drew nothing. */
33
+ readonly rootChildren?: number;
34
+ }
35
+
36
+ export function parseAppReadiness(value: unknown): AppReadiness {
37
+ const record = asRecord(value, NOUN);
38
+ if (!isAppReadinessState(record.state)) {
39
+ throw new Error(`${NOUN} names a state of: ${APP_READINESS_STATES.join(", ")}`);
40
+ }
41
+ const sinceMs = optionalNonNegativeInteger(record, "sinceMs", NOUN);
42
+ const rootChildren = optionalNonNegativeInteger(record, "rootChildren", NOUN);
43
+ return {
44
+ state: record.state,
45
+ ...(sinceMs !== undefined ? { sinceMs } : {}),
46
+ ...(rootChildren !== undefined ? { rootChildren } : {}),
47
+ };
48
+ }
49
+
50
+ export function serializeAppReadiness(readiness: AppReadiness): string {
51
+ return JSON.stringify(readiness);
52
+ }
@@ -0,0 +1,46 @@
1
+ /** The record surface, re-exported by the package barrel as one line. */
2
+ export { RECORD_STATUSES, isRecordStatus } from "../operations/record-status";
3
+ export type { RecordStatus } from "../operations/record-status";
4
+
5
+ export { parseAppRecord } from "../operations/app-record";
6
+ export type { AppRecord } from "../operations/app-record";
7
+
8
+ export {
9
+ parseListRecordsInput,
10
+ serializeListRecordsInput,
11
+ parseListRecordsResult,
12
+ serializeListRecordsResult,
13
+ } from "../operations/list-records";
14
+ export type { ListRecordsInput, ListRecordsResult } from "../operations/list-records";
15
+
16
+ export {
17
+ parseGetRecordInput,
18
+ serializeGetRecordInput,
19
+ parseGetRecordResult,
20
+ serializeGetRecordResult,
21
+ } from "../operations/get-record";
22
+ export type { GetRecordInput, GetRecordResult } from "../operations/get-record";
23
+
24
+ export {
25
+ parseSetRecordStatusInput,
26
+ serializeSetRecordStatusInput,
27
+ parseSetRecordStatusResult,
28
+ serializeSetRecordStatusResult,
29
+ } from "../operations/set-record-status";
30
+ export type { SetRecordStatusInput, SetRecordStatusResult } from "../operations/set-record-status";
31
+
32
+ export {
33
+ parseDeleteRecordInput,
34
+ serializeDeleteRecordInput,
35
+ parseDeleteRecordResult,
36
+ serializeDeleteRecordResult,
37
+ } from "../operations/delete-record";
38
+ export type { DeleteRecordInput, DeleteRecordResult } from "../operations/delete-record";
39
+
40
+ export {
41
+ parseSaveRecordInput,
42
+ serializeSaveRecordInput,
43
+ parseSaveRecordResult,
44
+ serializeSaveRecordResult,
45
+ } from "../operations/save-record";
46
+ export type { SaveRecordInput, SaveRecordResult } from "../operations/save-record";
@@ -0,0 +1,104 @@
1
+ /** The route surface, re-exported by the package barrel as one line. */
2
+ export {
3
+ parseRegisterRouteInput,
4
+ serializeRegisterRouteInput,
5
+ parseRegisterRouteResult,
6
+ serializeRegisterRouteResult,
7
+ } from "../operations/register-route";
8
+ export type { RegisterRouteInput, RegisterRouteResult } from "../operations/register-route";
9
+
10
+ export {
11
+ parseUnregisterRouteInput,
12
+ serializeUnregisterRouteInput,
13
+ parseUnregisterRouteResult,
14
+ serializeUnregisterRouteResult,
15
+ } from "../operations/unregister-route";
16
+ export type { UnregisterRouteInput, UnregisterRouteResult } from "../operations/unregister-route";
17
+
18
+ export {
19
+ parseListRoutesInput,
20
+ serializeListRoutesInput,
21
+ parseListRoutesResult,
22
+ serializeListRoutesResult,
23
+ } from "../operations/list-routes";
24
+ export type { ListRoutesInput, ListRoutesResult, RouteSummary } from "../operations/list-routes";
25
+
26
+ export {
27
+ parseDescribeRouteInput,
28
+ serializeDescribeRouteInput,
29
+ parseDescribeRouteResult,
30
+ serializeDescribeRouteResult,
31
+ } from "../operations/describe-route";
32
+ export type {
33
+ DescribeRouteInput,
34
+ DescribeRouteResult,
35
+ RouteCard,
36
+ } from "../operations/describe-route";
37
+
38
+ export {
39
+ parseDeclareRouteInput,
40
+ serializeDeclareRouteInput,
41
+ parseDeclareRouteResult,
42
+ serializeDeclareRouteResult,
43
+ } from "../operations/declare-route";
44
+ export type { DeclareRouteInput, DeclareRouteResult } from "../operations/declare-route";
45
+
46
+ export {
47
+ COMPONENT_DECLARATIONS,
48
+ DECLARATION_FIELDS,
49
+ HOST_DECLARATIONS,
50
+ REACT_DECLARATIONS,
51
+ isComponentDeclaration,
52
+ isEmptyDeclarationPatch,
53
+ isHostDeclaration,
54
+ isReactDeclaration,
55
+ optionalDeclarationPatch,
56
+ parseDeclaration,
57
+ parseDeclarationPatch,
58
+ } from "../operations/declaration";
59
+ export type {
60
+ ComponentDeclaration,
61
+ Declaration,
62
+ DeclarationField,
63
+ DeclarationPatch,
64
+ HostDeclaration,
65
+ ReactDeclaration,
66
+ } from "../operations/declaration";
67
+
68
+ export {
69
+ parseArchiveRouteInput,
70
+ serializeArchiveRouteInput,
71
+ parseArchiveRouteResult,
72
+ serializeArchiveRouteResult,
73
+ } from "../operations/archive-route";
74
+ export type { ArchiveRouteInput, ArchiveRouteResult } from "../operations/archive-route";
75
+
76
+ export {
77
+ parseDeleteAppInput,
78
+ serializeDeleteAppInput,
79
+ parseDeleteAppResult,
80
+ serializeDeleteAppResult,
81
+ } from "../operations/delete-app";
82
+ export type { DeleteAppInput, DeleteAppResult } from "../operations/delete-app";
83
+
84
+ export {
85
+ parseRebootRouteInput,
86
+ serializeRebootRouteInput,
87
+ parseRebootRouteResult,
88
+ serializeRebootRouteResult,
89
+ } from "../operations/reboot-route";
90
+ export type { RebootRouteInput, RebootRouteResult } from "../operations/reboot-route";
91
+
92
+ export { VISIBILITIES, isVisibility } from "../operations/visibility";
93
+ export type { Visibility } from "../operations/visibility";
94
+
95
+ export {
96
+ parseSetRouteVisibilityInput,
97
+ serializeSetRouteVisibilityInput,
98
+ parseSetRouteVisibilityResult,
99
+ serializeSetRouteVisibilityResult,
100
+ } from "../operations/set-route-visibility";
101
+ export type {
102
+ SetRouteVisibilityInput,
103
+ SetRouteVisibilityResult,
104
+ } from "../operations/set-route-visibility";
@@ -0,0 +1,16 @@
1
+ /** The selection surface, re-exported by the package barrel as one line. */
2
+ export {
3
+ parseSetSelectionInput,
4
+ serializeSetSelectionInput,
5
+ parseSetSelectionResult,
6
+ serializeSetSelectionResult,
7
+ } from "../operations/set-selection";
8
+ export type { SetSelectionInput, SetSelectionResult } from "../operations/set-selection";
9
+
10
+ export {
11
+ parseQuerySelectionInput,
12
+ serializeQuerySelectionInput,
13
+ parseQuerySelectionResult,
14
+ serializeQuerySelectionResult,
15
+ } from "../operations/query-selection";
16
+ export type { QuerySelectionInput, QuerySelectionResult } from "../operations/query-selection";
@@ -0,0 +1,24 @@
1
+ /** The session surface, re-exported by the package barrel as one line. */
2
+ export {
3
+ IDENTITY_VIAS,
4
+ parseIdentifyInput,
5
+ serializeIdentifyInput,
6
+ parseIdentifyResult,
7
+ serializeIdentifyResult,
8
+ } from "../operations/identify";
9
+ export type { IdentifyInput, IdentifyResult, IdentityVia } from "../operations/identify";
10
+
11
+ export { parseHeartbeat, serializeHeartbeat } from "../operations/heartbeat";
12
+ export type { Heartbeat } from "../operations/heartbeat";
13
+
14
+ export {
15
+ parseListPresenceInput,
16
+ serializeListPresenceInput,
17
+ parseListPresenceResult,
18
+ serializeListPresenceResult,
19
+ } from "../operations/list-presence";
20
+ export type {
21
+ ListPresenceInput,
22
+ ListPresenceResult,
23
+ PresenceBeatSummary,
24
+ } from "../operations/list-presence";
@@ -0,0 +1,20 @@
1
+ /** The snapshot surface, re-exported by the package barrel as one line. */
2
+ export {
3
+ parseCaptureSnapshotInput,
4
+ serializeCaptureSnapshotInput,
5
+ parseCaptureSnapshotResult,
6
+ serializeCaptureSnapshotResult,
7
+ } from "../operations/capture-snapshot";
8
+ export type { CaptureSnapshotInput, CaptureSnapshotResult } from "../operations/capture-snapshot";
9
+
10
+ export {
11
+ parseGetSnapshotInput,
12
+ serializeGetSnapshotInput,
13
+ parseGetSnapshotResult,
14
+ serializeGetSnapshotResult,
15
+ } from "../operations/get-snapshot";
16
+ export type {
17
+ GetSnapshotInput,
18
+ GetSnapshotResult,
19
+ SnapshotState,
20
+ } from "../operations/get-snapshot";
@@ -0,0 +1,14 @@
1
+ /** The template surface, re-exported by the package barrel as one line. */
2
+ export {
3
+ parseListTemplatesInput,
4
+ serializeListTemplatesInput,
5
+ parseListTemplatesResult,
6
+ serializeListTemplatesResult,
7
+ parseTemplateSummary,
8
+ serializeTemplateSummary,
9
+ } from "../operations/list-templates";
10
+ export type {
11
+ ListTemplatesInput,
12
+ ListTemplatesResult,
13
+ TemplateSummary,
14
+ } from "../operations/list-templates";
@@ -0,0 +1,36 @@
1
+ /** The toolchain surface, re-exported by the package barrel as one line. */
2
+ export {
3
+ parseAddPackageInput,
4
+ serializeAddPackageInput,
5
+ parseAddPackageResult,
6
+ serializeAddPackageResult,
7
+ } from "../operations/add-package";
8
+ export type { AddPackageInput, AddPackageResult } from "../operations/add-package";
9
+
10
+ export {
11
+ parseListPackagesInput,
12
+ serializeListPackagesInput,
13
+ parseListPackagesResult,
14
+ serializeListPackagesResult,
15
+ } from "../operations/list-packages";
16
+ export type {
17
+ ListPackagesInput,
18
+ ListPackagesResult,
19
+ PackageSource,
20
+ PackageSummary,
21
+ } from "../operations/list-packages";
22
+
23
+ export {
24
+ COMPONENT_SOURCES,
25
+ isComponentSource,
26
+ parseAddComponentInput,
27
+ serializeAddComponentInput,
28
+ parseAddComponentResult,
29
+ serializeAddComponentResult,
30
+ } from "../operations/add-component";
31
+ export type {
32
+ AddComponentInput,
33
+ AddComponentResult,
34
+ ComponentSource,
35
+ LeftImport,
36
+ } from "../operations/add-component";
package/src/version.ts ADDED
@@ -0,0 +1,3 @@
1
+ export const PROTOCOL_VERSION = 1;
2
+
3
+ export type ProtocolVersion = typeof PROTOCOL_VERSION;
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # @theruntime/protocol
2
-
3
- Placeholder. The first release replaces it.