@econ-v1/domain 6.7.0 → 6.10.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/dist/errors/index.d.ts +96 -25
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/events/index.d.ts +127 -20
- package/dist/events/index.d.ts.map +1 -1
- package/dist/index.d.ts +250 -47
- package/dist/index.d.ts.map +1 -1
- package/dist/models/agent.d.ts +25 -4
- package/dist/models/agent.d.ts.map +1 -1
- package/dist/models/app-data.d.ts +84 -0
- package/dist/models/app-data.d.ts.map +1 -0
- package/dist/models/conversation.d.ts +12 -2
- package/dist/models/conversation.d.ts.map +1 -1
- package/dist/models/delegation.d.ts +12 -3
- package/dist/models/delegation.d.ts.map +1 -1
- package/dist/models/device-boot-state.d.ts +12 -0
- package/dist/models/device-boot-state.d.ts.map +1 -0
- package/dist/models/device-identity.d.ts +11 -3
- package/dist/models/device-identity.d.ts.map +1 -1
- package/dist/models/graph.d.ts +26 -3
- package/dist/models/graph.d.ts.map +1 -1
- package/dist/models/index.d.ts +82 -14
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/json.d.ts +5 -5
- package/dist/models/json.d.ts.map +1 -1
- package/dist/models/l402.d.ts +4 -5
- package/dist/models/l402.d.ts.map +1 -1
- package/dist/models/live-query-definition.d.ts +15 -16
- package/dist/models/live-query-definition.d.ts.map +1 -1
- package/dist/models/node-app-memory.d.ts +107 -0
- package/dist/models/node-app-memory.d.ts.map +1 -0
- package/dist/models/outbox-intent.d.ts +3 -3
- package/dist/models/outbox-intent.d.ts.map +1 -1
- package/dist/models/outbox.d.ts +67 -15
- package/dist/models/outbox.d.ts.map +1 -1
- package/dist/models/owner-views.d.ts +28 -28
- package/dist/models/owner-views.d.ts.map +1 -1
- package/dist/models/payment.d.ts +28 -9
- package/dist/models/payment.d.ts.map +1 -1
- package/dist/models/query-diff.d.ts +2 -2
- package/dist/models/query-diff.d.ts.map +1 -1
- package/dist/models/release-manifest.d.ts +32 -47
- package/dist/models/release-manifest.d.ts.map +1 -1
- package/dist/models/repository-write.d.ts +3 -3
- package/dist/models/repository-write.d.ts.map +1 -1
- package/dist/models/revisioned-commands.d.ts +66 -13
- package/dist/models/revisioned-commands.d.ts.map +1 -1
- package/dist/models/revisioned.d.ts +50 -10
- package/dist/models/revisioned.d.ts.map +1 -1
- package/dist/models/settings.d.ts +2 -2
- package/dist/models/settings.d.ts.map +1 -1
- package/dist/models/sync.d.ts +18 -18
- package/dist/models/sync.d.ts.map +1 -1
- package/dist/models/wallet.d.ts +16 -16
- package/dist/models/wallet.d.ts.map +1 -1
- package/dist/queries/certificate-trust.d.ts +13 -0
- package/dist/queries/certificate-trust.d.ts.map +1 -0
- package/dist/queries/conversations.d.ts +38 -7
- package/dist/queries/conversations.d.ts.map +1 -1
- package/dist/queries/discovery.d.ts +10 -10
- package/dist/queries/discovery.d.ts.map +1 -1
- package/dist/queries/notifications.d.ts +24 -4
- package/dist/queries/notifications.d.ts.map +1 -1
- package/dist/queries/onboarding-flow.d.ts +25 -0
- package/dist/queries/onboarding-flow.d.ts.map +1 -0
- package/dist/queries/onboarding-lcd-screen.d.ts +56 -0
- package/dist/queries/onboarding-lcd-screen.d.ts.map +1 -0
- package/dist/queries/onboarding-status.d.ts +10 -10
- package/dist/queries/onboarding-status.d.ts.map +1 -1
- package/dist/queries/revisioned.d.ts +47 -13
- package/dist/queries/revisioned.d.ts.map +1 -1
- package/dist/queries/wallet.d.ts +40 -10
- package/dist/queries/wallet.d.ts.map +1 -1
- package/dist/services/abort-signal.d.ts +54 -0
- package/dist/services/abort-signal.d.ts.map +1 -0
- package/dist/services/certificate-trust-service.d.ts +42 -0
- package/dist/services/certificate-trust-service.d.ts.map +1 -0
- package/dist/services/conversation-service.d.ts +103 -15
- package/dist/services/conversation-service.d.ts.map +1 -1
- package/dist/services/conversation-sync.d.ts +9 -5
- package/dist/services/conversation-sync.d.ts.map +1 -1
- package/dist/services/device-boot-state-service.d.ts +17 -0
- package/dist/services/device-boot-state-service.d.ts.map +1 -0
- package/dist/services/device-cleanup-service.d.ts +47 -0
- package/dist/services/device-cleanup-service.d.ts.map +1 -0
- package/dist/services/discovery-probe-service.d.ts +37 -46
- package/dist/services/discovery-probe-service.d.ts.map +1 -1
- package/dist/services/gossip-service.d.ts +28 -13
- package/dist/services/gossip-service.d.ts.map +1 -1
- package/dist/services/invite-redemption-service.d.ts +43 -0
- package/dist/services/invite-redemption-service.d.ts.map +1 -0
- package/dist/services/lan-candidate-refresh-service.d.ts +22 -7
- package/dist/services/lan-candidate-refresh-service.d.ts.map +1 -1
- package/dist/services/lcd-decision-service.d.ts +58 -0
- package/dist/services/lcd-decision-service.d.ts.map +1 -0
- package/dist/services/onboarding-checkpoint-store.d.ts +54 -0
- package/dist/services/onboarding-checkpoint-store.d.ts.map +1 -0
- package/dist/services/onboarding-flow-service.d.ts +180 -0
- package/dist/services/onboarding-flow-service.d.ts.map +1 -0
- package/dist/services/onboarding-status-service.d.ts +21 -38
- package/dist/services/onboarding-status-service.d.ts.map +1 -1
- package/dist/services/outbox-service.d.ts +105 -29
- package/dist/services/outbox-service.d.ts.map +1 -1
- package/dist/services/owner-claim-service.d.ts +187 -0
- package/dist/services/owner-claim-service.d.ts.map +1 -0
- package/dist/services/owner-view-refresh-service.d.ts +40 -0
- package/dist/services/owner-view-refresh-service.d.ts.map +1 -0
- package/dist/services/owner-view-service.d.ts +49 -4
- package/dist/services/owner-view-service.d.ts.map +1 -1
- package/dist/services/peer-directory-service.d.ts +53 -17
- package/dist/services/peer-directory-service.d.ts.map +1 -1
- package/dist/services/release-manifest-verifier.d.ts +18 -20
- package/dist/services/release-manifest-verifier.d.ts.map +1 -1
- package/dist/services/revisioned-domain-service.d.ts +50 -17
- package/dist/services/revisioned-domain-service.d.ts.map +1 -1
- package/dist/services/runtime-globals.d.ts +39 -0
- package/dist/services/runtime-globals.d.ts.map +1 -0
- package/dist/services/session-service.d.ts +23 -3
- package/dist/services/session-service.d.ts.map +1 -1
- package/dist/services/sync/authoritative-mirror.d.ts +88 -15
- package/dist/services/sync/authoritative-mirror.d.ts.map +1 -1
- package/dist/services/sync/index.d.ts +17 -5
- package/dist/services/sync/index.d.ts.map +1 -1
- package/dist/services/sync/log-sync.d.ts +42 -8
- package/dist/services/sync/log-sync.d.ts.map +1 -1
- package/dist/services/sync/revision-merge.d.ts +80 -13
- package/dist/services/sync/revision-merge.d.ts.map +1 -1
- package/dist/services/sync/strategy.d.ts +11 -1
- package/dist/services/sync/strategy.d.ts.map +1 -1
- package/dist/services/transport-manager.d.ts +84 -29
- package/dist/services/transport-manager.d.ts.map +1 -1
- package/dist/services/wallet-mirror-service.d.ts +81 -18
- package/dist/services/wallet-mirror-service.d.ts.map +1 -1
- package/dist/services/wifi-provisioning-service.d.ts +146 -0
- package/dist/services/wifi-provisioning-service.d.ts.map +1 -0
- package/package.json +18 -12
- package/src/errors/index.js +126 -0
- package/src/events/index.js +124 -0
- package/src/index.js +566 -0
- package/src/models/agent.js +43 -0
- package/src/models/app-data.js +122 -0
- package/src/models/conversation.js +36 -0
- package/{dist → src}/models/delegation.js +18 -1
- package/src/models/device-boot-state.js +3 -0
- package/{dist → src}/models/device-identity.js +18 -2
- package/{dist → src}/models/graph.js +30 -3
- package/src/models/index.js +175 -0
- package/src/models/json.js +18 -0
- package/src/models/l402.js +9 -0
- package/src/models/live-query-definition.js +30 -0
- package/src/models/node-app-memory.js +130 -0
- package/src/models/outbox-intent.js +12 -0
- package/{dist → src}/models/outbox.js +102 -3
- package/src/models/owner-views.js +59 -0
- package/src/models/payment.js +24 -0
- package/src/models/query-diff.js +7 -0
- package/src/models/release-manifest.js +160 -0
- package/src/models/repository-write.js +10 -0
- package/src/models/revisioned-commands.js +92 -0
- package/src/models/revisioned.js +41 -0
- package/src/models/settings.js +16 -0
- package/src/models/sync.js +44 -0
- package/src/models/wallet.js +40 -0
- package/src/queries/certificate-trust.js +31 -0
- package/{dist → src}/queries/conversations.js +54 -3
- package/src/queries/discovery.js +34 -0
- package/{dist → src}/queries/notifications.js +25 -2
- package/src/queries/onboarding-flow.js +48 -0
- package/src/queries/onboarding-lcd-screen.js +100 -0
- package/src/queries/onboarding-status.js +34 -0
- package/src/queries/revisioned.js +128 -0
- package/{dist → src}/queries/wallet.js +35 -1
- package/src/services/abort-signal.js +69 -0
- package/src/services/certificate-trust-service.js +119 -0
- package/{dist → src}/services/conversation-service.js +108 -1
- package/src/services/conversation-sync.js +28 -0
- package/src/services/device-boot-state-service.js +45 -0
- package/src/services/device-cleanup-service.js +112 -0
- package/src/services/discovery-probe-service.js +196 -0
- package/{dist → src}/services/gossip-service.js +54 -4
- package/src/services/invite-redemption-service.js +64 -0
- package/src/services/lan-candidate-refresh-service.js +164 -0
- package/src/services/lcd-decision-service.js +93 -0
- package/src/services/onboarding-checkpoint-store.js +155 -0
- package/src/services/onboarding-flow-service.js +1096 -0
- package/src/services/onboarding-status-service.js +64 -0
- package/{dist → src}/services/outbox-service.js +132 -1
- package/src/services/owner-claim-service.js +347 -0
- package/src/services/owner-view-refresh-service.js +208 -0
- package/src/services/owner-view-service.js +87 -0
- package/{dist → src}/services/peer-directory-service.js +72 -3
- package/src/services/release-manifest-verifier.js +108 -0
- package/{dist → src}/services/revisioned-domain-service.js +189 -9
- package/src/services/runtime-globals.js +174 -0
- package/src/services/session-service.js +50 -0
- package/{dist → src}/services/sync/authoritative-mirror.js +90 -1
- package/src/services/sync/index.js +67 -0
- package/src/services/sync/log-sync.js +60 -0
- package/src/services/sync/revision-merge.js +119 -0
- package/src/services/sync/strategy.js +44 -0
- package/src/services/transport-manager.js +478 -0
- package/{dist → src}/services/wallet-mirror-service.js +226 -6
- package/src/services/wifi-provisioning-service.js +278 -0
- package/dist/errors/index.js +0 -45
- package/dist/errors/index.js.map +0 -1
- package/dist/events/index.js +0 -17
- package/dist/events/index.js.map +0 -1
- package/dist/index.js +0 -31
- package/dist/index.js.map +0 -1
- package/dist/models/agent.js +0 -17
- package/dist/models/agent.js.map +0 -1
- package/dist/models/conversation.js +0 -2
- package/dist/models/conversation.js.map +0 -1
- package/dist/models/delegation.js.map +0 -1
- package/dist/models/device-identity.js.map +0 -1
- package/dist/models/graph.js.map +0 -1
- package/dist/models/index.js +0 -8
- package/dist/models/index.js.map +0 -1
- package/dist/models/json.js +0 -2
- package/dist/models/json.js.map +0 -1
- package/dist/models/l402.js +0 -2
- package/dist/models/l402.js.map +0 -1
- package/dist/models/live-query-definition.js +0 -2
- package/dist/models/live-query-definition.js.map +0 -1
- package/dist/models/outbox-intent.js +0 -2
- package/dist/models/outbox-intent.js.map +0 -1
- package/dist/models/outbox.js.map +0 -1
- package/dist/models/owner-views.js +0 -7
- package/dist/models/owner-views.js.map +0 -1
- package/dist/models/payment.js +0 -3
- package/dist/models/payment.js.map +0 -1
- package/dist/models/query-diff.js +0 -2
- package/dist/models/query-diff.js.map +0 -1
- package/dist/models/release-manifest.js +0 -147
- package/dist/models/release-manifest.js.map +0 -1
- package/dist/models/repository-write.js +0 -2
- package/dist/models/repository-write.js.map +0 -1
- package/dist/models/revisioned-commands.js +0 -35
- package/dist/models/revisioned-commands.js.map +0 -1
- package/dist/models/revisioned.js +0 -2
- package/dist/models/revisioned.js.map +0 -1
- package/dist/models/settings.js +0 -2
- package/dist/models/settings.js.map +0 -1
- package/dist/models/sync.js +0 -2
- package/dist/models/sync.js.map +0 -1
- package/dist/models/wallet.js +0 -2
- package/dist/models/wallet.js.map +0 -1
- package/dist/queries/conversations.js.map +0 -1
- package/dist/queries/discovery.js +0 -27
- package/dist/queries/discovery.js.map +0 -1
- package/dist/queries/notifications.js.map +0 -1
- package/dist/queries/onboarding-status.js +0 -27
- package/dist/queries/onboarding-status.js.map +0 -1
- package/dist/queries/revisioned.js +0 -58
- package/dist/queries/revisioned.js.map +0 -1
- package/dist/queries/wallet.js.map +0 -1
- package/dist/services/conversation-service.js.map +0 -1
- package/dist/services/conversation-sync.js +0 -9
- package/dist/services/conversation-sync.js.map +0 -1
- package/dist/services/discovery-probe-service.js +0 -129
- package/dist/services/discovery-probe-service.js.map +0 -1
- package/dist/services/gossip-service.js.map +0 -1
- package/dist/services/lan-candidate-refresh-service.js +0 -79
- package/dist/services/lan-candidate-refresh-service.js.map +0 -1
- package/dist/services/onboarding-status-service.js +0 -32
- package/dist/services/onboarding-status-service.js.map +0 -1
- package/dist/services/outbox-service.js.map +0 -1
- package/dist/services/owner-view-service.js +0 -21
- package/dist/services/owner-view-service.js.map +0 -1
- package/dist/services/peer-directory-service.js.map +0 -1
- package/dist/services/release-manifest-verifier.js +0 -84
- package/dist/services/release-manifest-verifier.js.map +0 -1
- package/dist/services/revisioned-domain-service.js.map +0 -1
- package/dist/services/session-service.js +0 -20
- package/dist/services/session-service.js.map +0 -1
- package/dist/services/sync/authoritative-mirror.js.map +0 -1
- package/dist/services/sync/index.js +0 -4
- package/dist/services/sync/index.js.map +0 -1
- package/dist/services/sync/log-sync.js +0 -20
- package/dist/services/sync/log-sync.js.map +0 -1
- package/dist/services/sync/revision-merge.js +0 -46
- package/dist/services/sync/revision-merge.js.map +0 -1
- package/dist/services/sync/strategy.js +0 -2
- package/dist/services/sync/strategy.js.map +0 -1
- package/dist/services/transport-manager.js +0 -234
- package/dist/services/transport-manager.js.map +0 -1
- package/dist/services/wallet-mirror-service.js.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/** @typedef {import('@econ-v1/ports').AppDataManifest} AppDataManifest */
|
|
4
|
+
/** @typedef {import('@econ-v1/ports').AppDataQueryDeclaration} AppDataQueryDeclaration */
|
|
5
|
+
/** @typedef {import('@econ-v1/ports').AppDataStreamDeclaration} AppDataStreamDeclaration */
|
|
6
|
+
/** @typedef {import('./json.js').JsonValue} JsonValue */
|
|
7
|
+
export const APP_DATA_MAX_PAYLOAD_BYTES = 256 * 1024;
|
|
8
|
+
/**
|
|
9
|
+
* @param {JsonValue} value
|
|
10
|
+
* @returns {void}
|
|
11
|
+
*/
|
|
12
|
+
export function assertAppDataPayload(value) {
|
|
13
|
+
const encoded = JSON.stringify(value);
|
|
14
|
+
if (
|
|
15
|
+
encoded === undefined ||
|
|
16
|
+
encoded.length * 2 > APP_DATA_MAX_PAYLOAD_BYTES
|
|
17
|
+
) {
|
|
18
|
+
throw new RangeError("App data payload exceeds the bounded payload limit");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} left
|
|
23
|
+
* @param {string} right
|
|
24
|
+
* @returns {number}
|
|
25
|
+
*/
|
|
26
|
+
export function compareAppDataRevision(left, right) {
|
|
27
|
+
if (/^\d+$/u.test(left) && /^\d+$/u.test(right)) {
|
|
28
|
+
const leftNumber = BigInt(left);
|
|
29
|
+
const rightNumber = BigInt(right);
|
|
30
|
+
return leftNumber < rightNumber ? -1 : leftNumber > rightNumber ? 1 : 0;
|
|
31
|
+
}
|
|
32
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @param {unknown} value
|
|
36
|
+
* @returns {value is AppDataSyncResponse}
|
|
37
|
+
*/
|
|
38
|
+
export function isAppDataSyncResponse(value) {
|
|
39
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
40
|
+
return false;
|
|
41
|
+
const candidate = /** @type {Record<string, unknown>} */ (value);
|
|
42
|
+
if (
|
|
43
|
+
typeof candidate.kind !== "string" ||
|
|
44
|
+
typeof candidate.cursor !== "string" ||
|
|
45
|
+
typeof candidate.revision !== "string"
|
|
46
|
+
)
|
|
47
|
+
return false;
|
|
48
|
+
if (candidate.kind === "cursor-expired") return true;
|
|
49
|
+
return (
|
|
50
|
+
(candidate.kind === "delta" || candidate.kind === "snapshot") &&
|
|
51
|
+
isJsonValue(candidate.value)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @param {unknown} value
|
|
56
|
+
* @returns {value is JsonValue}
|
|
57
|
+
*/
|
|
58
|
+
function isJsonValue(value) {
|
|
59
|
+
if (
|
|
60
|
+
value === null ||
|
|
61
|
+
typeof value === "boolean" ||
|
|
62
|
+
typeof value === "number" ||
|
|
63
|
+
typeof value === "string"
|
|
64
|
+
)
|
|
65
|
+
return true;
|
|
66
|
+
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
67
|
+
if (typeof value !== "object") return false;
|
|
68
|
+
return Object.values(value).every(isJsonValue);
|
|
69
|
+
}
|
|
70
|
+
/** @typedef {"fresh" | "stale" | "offline" | "unavailable"} AppDataFreshness */
|
|
71
|
+
/** @typedef {"online" | "offline"} AppDataTransport */
|
|
72
|
+
/**
|
|
73
|
+
* @typedef {| { readonly cursor: string; readonly kind: "cursor-expired"; readonly revision: string }
|
|
74
|
+
* | { readonly cursor: string; readonly kind: "delta"; readonly revision: string; readonly value: JsonValue }
|
|
75
|
+
* | { readonly cursor: string; readonly kind: "snapshot"; readonly revision: string; readonly value: JsonValue }} AppDataSyncResponse
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* @typedef {| {
|
|
79
|
+
* readonly appName: string;
|
|
80
|
+
* readonly cursor?: string;
|
|
81
|
+
* readonly recovered?: boolean;
|
|
82
|
+
* readonly status: "synced";
|
|
83
|
+
* readonly streams: readonly string[];
|
|
84
|
+
* }
|
|
85
|
+
* | {
|
|
86
|
+
* readonly appName: string;
|
|
87
|
+
* readonly cursor?: string;
|
|
88
|
+
* readonly error?: string;
|
|
89
|
+
* readonly status: "offline" | "stale";
|
|
90
|
+
* readonly streams: readonly string[];
|
|
91
|
+
* }} AppDataSyncResult
|
|
92
|
+
*/
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {object} CachedAppData
|
|
95
|
+
* @property {string} cachedAt
|
|
96
|
+
* @property {string} [cursor]
|
|
97
|
+
* @property {AppDataFreshness} freshness
|
|
98
|
+
* @property {string} key
|
|
99
|
+
* @property {string} namespace
|
|
100
|
+
* @property {string} revision
|
|
101
|
+
* @property {AppDataTransport} transport
|
|
102
|
+
* @property {JsonValue} value
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* @typedef {object} AppDataManifestRegistration
|
|
106
|
+
* @property {string} appName
|
|
107
|
+
* @property {AppDataManifest} data
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* @typedef {AppDataQueryDeclaration & { readonly appName: string, readonly namespace: string }} AppDataQueryDefinition
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* @typedef {AppDataStreamDeclaration & { readonly appName: string, readonly namespace: string }} AppDataStreamDefinition
|
|
114
|
+
*/
|
|
115
|
+
/**
|
|
116
|
+
* @typedef {object} AppDataChangedEvent
|
|
117
|
+
* @property {string} appName
|
|
118
|
+
* @property {string} cursor
|
|
119
|
+
* @property {string} revision
|
|
120
|
+
* @property {string} stream
|
|
121
|
+
*/
|
|
122
|
+
// @ts-check
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("@econ-v1/ports").Conversation} Conversation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import("@econ-v1/ports").ConversationListParams} ConversationListParams
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import("@econ-v1/ports").ConversationLogDelta} ConversationLogDelta
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import("@econ-v1/ports").ConversationMessage} ConversationMessage
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import("@econ-v1/ports").ConversationMessageState} ConversationMessageState
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {import("@econ-v1/ports").ConversationRepositoryEvent} ConversationRepositoryEvent
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import("@econ-v1/ports").MessageListParams} MessageListParams
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {import("@econ-v1/ports").Notification} Notification
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {import("@econ-v1/ports").NotificationListParams} NotificationListParams
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {import("@econ-v1/ports").NotificationRepositoryEvent} NotificationRepositoryEvent
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {import("@econ-v1/ports").RepositoryEvent} RepositoryEvent
|
|
35
|
+
*/
|
|
36
|
+
export { CONVERSATION_MESSAGE_STATES, } from "@econ-v1/ports";
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("@econ-v1/ports").DeviceDelegation} DeviceDelegation
|
|
5
|
+
*/
|
|
1
6
|
const CAPABILITY_SCOPE = /^[a-z][a-z0-9_-]*(?:\.[a-z0-9_*-]+)+$/u;
|
|
7
|
+
/**
|
|
8
|
+
* @param {DeviceDelegation} delegation
|
|
9
|
+
* @returns {DeviceDelegation}
|
|
10
|
+
*/
|
|
2
11
|
export function normalizeDelegation(delegation) {
|
|
3
12
|
const scopes = [...new Set(delegation.scopes)].sort();
|
|
4
13
|
if (delegation.credential.length === 0 ||
|
|
@@ -12,12 +21,20 @@ export function normalizeDelegation(delegation) {
|
|
|
12
21
|
}
|
|
13
22
|
return { ...delegation, scopes };
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* @param {DeviceDelegation} delegation
|
|
26
|
+
* @param {Date} now
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
*/
|
|
15
29
|
export function isDelegationActive(delegation, now) {
|
|
16
30
|
const current = now.getTime();
|
|
17
31
|
return Date.parse(delegation.issuedAt) <= current && Date.parse(delegation.expiresAt) > current;
|
|
18
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* @param {string} value
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
19
37
|
function isIsoTimestamp(value) {
|
|
20
38
|
const epoch = Date.parse(value);
|
|
21
39
|
return Number.isFinite(epoch) && new Date(epoch).toISOString() === value;
|
|
22
40
|
}
|
|
23
|
-
//# sourceMappingURL=delegation.js.map
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("@econ-v1/ports").DevicePublicIdentity} DevicePublicIdentity
|
|
5
|
+
*/
|
|
1
6
|
const BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
7
|
+
/**
|
|
8
|
+
* @param {unknown} value
|
|
9
|
+
* @returns {value is DevicePublicIdentity}
|
|
10
|
+
*/
|
|
2
11
|
export function isDevicePublicIdentity(value) {
|
|
3
12
|
if (typeof value !== "object" || value === null)
|
|
4
13
|
return false;
|
|
5
|
-
const candidate = value;
|
|
14
|
+
const candidate = /** @type {Record<string, unknown>} */ (value);
|
|
6
15
|
if (!((candidate.custodyMode === "non-extractable" || candidate.custodyMode === "wrapped") &&
|
|
7
16
|
typeof candidate.did === "string" && candidate.did.startsWith("did:key:z") &&
|
|
8
17
|
typeof candidate.nodeId === "string" && /^[0-9a-f]{64}$/u.test(candidate.nodeId) &&
|
|
@@ -18,6 +27,10 @@ export function isDevicePublicIdentity(value) {
|
|
|
18
27
|
const nodeId = [...publicKey].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
19
28
|
return nodeId === candidate.nodeId && publicKey.every((byte, index) => byte === didKey[index + 2]);
|
|
20
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* @param {DevicePublicIdentity} identity
|
|
32
|
+
* @returns {Readonly<Record<string, string>>}
|
|
33
|
+
*/
|
|
21
34
|
export function publicIdentityDiagnostic(identity) {
|
|
22
35
|
return {
|
|
23
36
|
custodyMode: identity.custodyMode,
|
|
@@ -26,6 +39,10 @@ export function publicIdentityDiagnostic(identity) {
|
|
|
26
39
|
publicKeyMultibase: identity.publicKeyMultibase,
|
|
27
40
|
};
|
|
28
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} encoded
|
|
44
|
+
* @returns {Uint8Array | undefined}
|
|
45
|
+
*/
|
|
29
46
|
function decodeBase58(encoded) {
|
|
30
47
|
if (encoded.length === 0)
|
|
31
48
|
return undefined;
|
|
@@ -50,4 +67,3 @@ function decodeBase58(encoded) {
|
|
|
50
67
|
const significantBytes = leadingZeros === encoded.length ? [] : bytes.reverse();
|
|
51
68
|
return Uint8Array.from([...new Uint8Array(leadingZeros), ...significantBytes]);
|
|
52
69
|
}
|
|
53
|
-
//# sourceMappingURL=device-identity.js.map
|
|
@@ -1,7 +1,32 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("./json.js").JsonObject} JsonObject
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @template TValue
|
|
8
|
+
* @typedef {import("./sync.js").RevisionEntity<TValue>} RevisionEntity
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {JsonObject & { readonly id: string; readonly label?: string; readonly type: string; }} GraphNode
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {JsonObject & { readonly from: string; readonly id?: string; readonly to: string; }} GraphEdge
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {JsonObject & { readonly edges: readonly GraphEdge[]; readonly name?: string; readonly nodes: readonly GraphNode[]; }} GraphValue
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {RevisionEntity<GraphValue>} Graph
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @param {unknown} value
|
|
24
|
+
* @returns {GraphValue}
|
|
25
|
+
*/
|
|
1
26
|
export function parseGraphValue(value) {
|
|
2
27
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
3
28
|
throw invalid();
|
|
4
|
-
const record = value;
|
|
29
|
+
const record = /** @type {Record<string, unknown>} */ (value);
|
|
5
30
|
if (!Array.isArray(record.nodes) || !Array.isArray(record.edges))
|
|
6
31
|
throw invalid();
|
|
7
32
|
const nodeIds = new Set();
|
|
@@ -22,9 +47,11 @@ export function parseGraphValue(value) {
|
|
|
22
47
|
!nodeIds.has(candidate.from) || !nodeIds.has(candidate.to))
|
|
23
48
|
throw invalid();
|
|
24
49
|
}
|
|
25
|
-
return value;
|
|
50
|
+
return /** @type {GraphValue} */ (value);
|
|
26
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @returns {TypeError}
|
|
54
|
+
*/
|
|
27
55
|
function invalid() {
|
|
28
56
|
return new TypeError("Invalid graph value");
|
|
29
57
|
}
|
|
30
|
-
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("./json.js").JsonObject} JsonObject
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import("./json.js").JsonPrimitive} JsonPrimitive
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import("./json.js").JsonValue} JsonValue
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @template TParams
|
|
14
|
+
* @template TRow
|
|
15
|
+
* @typedef {import("./live-query-definition.js").LiveQueryDefinition<TParams, TRow>} LiveQueryDefinition
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {import("./outbox.js").LegacyOutboxState} LegacyOutboxState
|
|
19
|
+
*/
|
|
20
|
+
/** @typedef {import("./app-data.js").AppDataChangedEvent} AppDataChangedEvent */
|
|
21
|
+
/** @typedef {import("./app-data.js").AppDataFreshness} AppDataFreshness */
|
|
22
|
+
/** @typedef {import("./app-data.js").AppDataManifestRegistration} AppDataManifestRegistration */
|
|
23
|
+
/** @typedef {import("./app-data.js").AppDataQueryDefinition} AppDataQueryDefinition */
|
|
24
|
+
/** @typedef {import("./app-data.js").AppDataStreamDefinition} AppDataStreamDefinition */
|
|
25
|
+
/** @typedef {import("./app-data.js").AppDataSyncResponse} AppDataSyncResponse */
|
|
26
|
+
/** @typedef {import("./app-data.js").AppDataSyncResult} AppDataSyncResult */
|
|
27
|
+
/** @typedef {import("./app-data.js").AppDataTransport} AppDataTransport */
|
|
28
|
+
/** @typedef {import("./app-data.js").CachedAppData} CachedAppData */
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {import("./outbox.js").OutboxAuthority} OutboxAuthority
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {import("./outbox.js").OutboxEntry} OutboxEntry
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {import("./outbox.js").OutboxIntent} OutboxIntent
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {import("./outbox.js").OutboxIntentInput} OutboxIntentInput
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {import("./outbox.js").OutboxIntentOptions} OutboxIntentOptions
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {import("./outbox.js").OutboxIntentState} OutboxIntentState
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {import("./outbox.js").OutboxLease} OutboxLease
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {import("./outbox.js").OutboxState} OutboxState
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* @template TRow
|
|
55
|
+
* @typedef {import("./query-diff.js").QueryDiff<TRow>} QueryDiff
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {import("../events/index.js").DomainEvent} DomainEvent
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* @template {DomainEvent} TEvent
|
|
62
|
+
* @typedef {import("./repository-write.js").RepositoryWrite<TEvent>} RepositoryWrite
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* @typedef {import("./agent.js").Agent} Agent
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* @typedef {import("./agent.js").AgentStatus} AgentStatus
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* @typedef {import("./agent.js").AgentValue} AgentValue
|
|
72
|
+
*/
|
|
73
|
+
/**
|
|
74
|
+
* @typedef {import("./graph.js").Graph} Graph
|
|
75
|
+
*/
|
|
76
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryApp} NodeAppMemoryApp */
|
|
77
|
+
/** @typedef {import("./node-app-memory.js").NodeAppBudgetState} NodeAppBudgetState */
|
|
78
|
+
/** @typedef {import("./node-app-memory.js").NodeAppBudgetVerdict} NodeAppBudgetVerdict */
|
|
79
|
+
/** @typedef {import("./node-app-memory.js").NodeAppDeviceMemory} NodeAppDeviceMemory */
|
|
80
|
+
/** @typedef {import("./node-app-memory.js").NodeAppGovernorRow} NodeAppGovernorRow */
|
|
81
|
+
/** @typedef {import("./node-app-memory.js").NodeAppHeapObjectTypeCount} NodeAppHeapObjectTypeCount */
|
|
82
|
+
/** @typedef {import("./node-app-memory.js").NodeAppHeapSnapshot} NodeAppHeapSnapshot */
|
|
83
|
+
/** @typedef {import("./node-app-memory.js").NodeAppHeapSnapshotState} NodeAppHeapSnapshotState */
|
|
84
|
+
/** @typedef {import("./node-app-memory.js").NodeAppHeapSnapshotSummary} NodeAppHeapSnapshotSummary */
|
|
85
|
+
/** @typedef {import("./node-app-memory.js").NodeAppLaneKind} NodeAppLaneKind */
|
|
86
|
+
/** @typedef {import("./node-app-memory.js").NodeAppLifecycleMemoryObservation} NodeAppLifecycleMemoryObservation */
|
|
87
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryActivityRollup} NodeAppMemoryActivityRollup */
|
|
88
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryAttribution} NodeAppMemoryAttribution */
|
|
89
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryAvailability} NodeAppMemoryAvailability */
|
|
90
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryBudgetBasis} NodeAppMemoryBudgetBasis */
|
|
91
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryCapabilityCallCount} NodeAppMemoryCapabilityCallCount */
|
|
92
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryDownload} NodeAppMemoryDownload */
|
|
93
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryOverview} NodeAppMemoryOverview */
|
|
94
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryOverviewApp} NodeAppMemoryOverviewApp */
|
|
95
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryReading} NodeAppMemoryReading */
|
|
96
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryRepository} NodeAppMemoryRepository */
|
|
97
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemorySnapshot} NodeAppMemorySnapshot */
|
|
98
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemorySource} NodeAppMemorySource */
|
|
99
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryTrend} NodeAppMemoryTrend */
|
|
100
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryTrendVerdict} NodeAppMemoryTrendVerdict */
|
|
101
|
+
/** @typedef {import("./node-app-memory.js").NodeAppMemoryUnavailableReason} NodeAppMemoryUnavailableReason */
|
|
102
|
+
/** @typedef {import("./node-app-memory.js").NodeAppPressureState} NodeAppPressureState */
|
|
103
|
+
/** @typedef {import("./node-app-memory.js").NodeAppRuntimeMode} NodeAppRuntimeMode */
|
|
104
|
+
/** @typedef {import("./node-app-memory.js").NodeAppTerminationReason} NodeAppTerminationReason */
|
|
105
|
+
/**
|
|
106
|
+
* @typedef {import("./graph.js").GraphEdge} GraphEdge
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* @typedef {import("./graph.js").GraphNode} GraphNode
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* @typedef {import("./graph.js").GraphValue} GraphValue
|
|
113
|
+
*/
|
|
114
|
+
/**
|
|
115
|
+
* @typedef {import("./settings.js").RevisionedSetting} RevisionedSetting
|
|
116
|
+
*/
|
|
117
|
+
/**
|
|
118
|
+
* @typedef {import("./settings.js").SettingValue} SettingValue
|
|
119
|
+
*/
|
|
120
|
+
/**
|
|
121
|
+
* @typedef {import("./revisioned-commands.js").ResolveRevisionConflictCommand} ResolveRevisionConflictCommand
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* @template {JsonValue} [TValue=import("./json.js").JsonValue]
|
|
125
|
+
* @typedef {import("./revisioned-commands.js").RevisionUpdateCommand<TValue>} RevisionUpdateCommand
|
|
126
|
+
*/
|
|
127
|
+
/**
|
|
128
|
+
* @typedef {import("./revisioned-commands.js").RevisionUpdateCommandName} RevisionUpdateCommandName
|
|
129
|
+
*/
|
|
130
|
+
/**
|
|
131
|
+
* @typedef {import("./revisioned-commands.js").RevisionedCommandName} RevisionedCommandName
|
|
132
|
+
*/
|
|
133
|
+
/**
|
|
134
|
+
* @template {JsonValue} TValue
|
|
135
|
+
* @typedef {import("./revisioned.js").RevisionCommand<TValue>} RevisionCommand
|
|
136
|
+
*/
|
|
137
|
+
/**
|
|
138
|
+
* @template TValue
|
|
139
|
+
* @typedef {import("./revisioned.js").RevisionCommandResult<TValue>} RevisionCommandResult
|
|
140
|
+
*/
|
|
141
|
+
/**
|
|
142
|
+
* @template TValue
|
|
143
|
+
* @typedef {import("./revisioned.js").RevisionConflict<TValue>} RevisionConflict
|
|
144
|
+
*/
|
|
145
|
+
/**
|
|
146
|
+
* @template {JsonValue} TValue
|
|
147
|
+
* @typedef {import("./revisioned.js").RevisionConflictPayload<TValue>} RevisionConflictPayload
|
|
148
|
+
*/
|
|
149
|
+
/**
|
|
150
|
+
* @template {JsonValue} TValue
|
|
151
|
+
* @typedef {import("./revisioned.js").RevisionConflictRecord<TValue>} RevisionConflictRecord
|
|
152
|
+
*/
|
|
153
|
+
/**
|
|
154
|
+
* @template TValue
|
|
155
|
+
* @typedef {import("./revisioned.js").RevisionEntity<TValue>} RevisionEntity
|
|
156
|
+
*/
|
|
157
|
+
/**
|
|
158
|
+
* @template TValue
|
|
159
|
+
* @typedef {import("./revisioned.js").RevisionIntent<TValue>} RevisionIntent
|
|
160
|
+
*/
|
|
161
|
+
/**
|
|
162
|
+
* @typedef {import("./revisioned.js").RevisionResolution} RevisionResolution
|
|
163
|
+
*/
|
|
164
|
+
/**
|
|
165
|
+
* @typedef {import("./revisioned.js").RevisionedDomain} RevisionedDomain
|
|
166
|
+
*/
|
|
167
|
+
export { isDevicePublicIdentity, publicIdentityDiagnostic } from "./device-identity.js";
|
|
168
|
+
export { isDelegationActive, normalizeDelegation } from "./delegation.js";
|
|
169
|
+
export { APP_DATA_MAX_PAYLOAD_BYTES, assertAppDataPayload, compareAppDataRevision, isAppDataSyncResponse } from "./app-data.js";
|
|
170
|
+
export { OUTBOX_STATES, canonicalOutboxPayload, createOutboxIntent, fromPublicOutboxState, toPublicOutboxState, validateOutboxIntent, } from "./outbox.js";
|
|
171
|
+
export { AGENT_STATUSES, parseAgentValue } from "./agent.js";
|
|
172
|
+
export { isNodeAppBudgetState, isNodeAppLaneKind, isNodeAppMemoryAttribution, isNodeAppMemoryAvailability, isNodeAppMemoryBudgetBasis, isNodeAppMemorySource, isNodeAppMemoryTrendVerdict, isNodeAppMemoryUnavailableReason, isNodeAppPressureState, isNodeAppRuntimeMode, isNodeAppTerminationReason, NODE_APP_BUDGET_STATES, NODE_APP_LANE_KINDS, NODE_APP_MEMORY_ATTRIBUTIONS, NODE_APP_MEMORY_AVAILABILITIES, NODE_APP_MEMORY_BUDGET_BASES, NODE_APP_MEMORY_SOURCES, NODE_APP_MEMORY_TREND_VERDICTS, NODE_APP_MEMORY_UNAVAILABLE_REASONS, NODE_APP_PRESSURE_STATES, NODE_APP_RUNTIME_MODES, NODE_APP_TERMINATION_REASONS } from "./node-app-memory.js";
|
|
173
|
+
export { parseGraphValue } from "./graph.js";
|
|
174
|
+
export { REVISIONED_COMMAND_NAMES, createAgentUpdateCommand, createGraphUpdateCommand, createResolveRevisionConflictCommand, createRevisionedUpdateCommand, } from "./revisioned-commands.js";
|
|
175
|
+
export { REVISIONED_DOMAINS, } from "./revisioned.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("@econ-v1/ports").RepositoryJsonPrimitive} RepositoryJsonPrimitive
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {RepositoryJsonPrimitive} JsonPrimitive
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {JsonPrimitive | JsonArray | JsonObject} JsonValue
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {JsonValue[]} JsonArray
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {{ readonly [key: string]: JsonValue; }} JsonObject
|
|
17
|
+
*/
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {{ readonly amountMsat: number; readonly paidAt: string; readonly paymentHash?: string; readonly resource: string; readonly receiptId: string; }} L402Receipt
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {{ readonly freshness: "fresh" | "stale" | "unavailable"; readonly items: readonly L402Receipt[]; readonly observedAt?: string; readonly staleAt?: string; }} L402HistoryView
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("../events/index.js").KernelEventType} KernelEventType
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import("../events/index.js").QueryName} QueryName
|
|
8
|
+
*/
|
|
9
|
+
/** @typedef {import("../events/index.js").DomainEvent} DomainEvent */
|
|
10
|
+
/**
|
|
11
|
+
* `requiresDurableStorage` records whether `run()` reads the durable,
|
|
12
|
+
* OPFS-backed local SQLite cache. It defaults to `true` (storage-backed) when
|
|
13
|
+
* omitted, so queries are gated behind local-storage readiness unless their
|
|
14
|
+
* author deliberately establishes otherwise. Set it to `false` only when
|
|
15
|
+
* `run()` is provably independent of the local SQLite cache, such as in-memory
|
|
16
|
+
* state or a home-node round trip; those queries remain available in degraded
|
|
17
|
+
* mode when a browser cannot provide OPFS.
|
|
18
|
+
*
|
|
19
|
+
* @template TParams
|
|
20
|
+
* @template TRow
|
|
21
|
+
* @typedef {{
|
|
22
|
+
* readonly invalidateOn: readonly KernelEventType[];
|
|
23
|
+
* readonly matchesInvalidation?: (event: DomainEvent) => boolean;
|
|
24
|
+
* readonly name: QueryName;
|
|
25
|
+
* readonly requiresDurableStorage?: boolean;
|
|
26
|
+
* key(row: TRow): string;
|
|
27
|
+
* run(params: TParams): Promise<readonly TRow[]>;
|
|
28
|
+
* }} LiveQueryDefinition
|
|
29
|
+
*/
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryApp} NodeAppMemoryApp */
|
|
3
|
+
/** @typedef {import('@econ-v1/ports').NodeAppBudgetState} NodeAppBudgetState */
|
|
4
|
+
/** @typedef {import('@econ-v1/ports').NodeAppBudgetVerdict} NodeAppBudgetVerdict */
|
|
5
|
+
/** @typedef {import('@econ-v1/ports').NodeAppDeviceMemory} NodeAppDeviceMemory */
|
|
6
|
+
/** @typedef {import('@econ-v1/ports').NodeAppGovernorRow} NodeAppGovernorRow */
|
|
7
|
+
/** @typedef {import('@econ-v1/ports').NodeAppHeapObjectTypeCount} NodeAppHeapObjectTypeCount */
|
|
8
|
+
/** @typedef {import('@econ-v1/ports').NodeAppHeapSnapshot} NodeAppHeapSnapshot */
|
|
9
|
+
/** @typedef {import('@econ-v1/ports').NodeAppHeapSnapshotState} NodeAppHeapSnapshotState */
|
|
10
|
+
/** @typedef {import('@econ-v1/ports').NodeAppHeapSnapshotSummary} NodeAppHeapSnapshotSummary */
|
|
11
|
+
/** @typedef {import('@econ-v1/ports').NodeAppLaneKind} NodeAppLaneKind */
|
|
12
|
+
/** @typedef {import('@econ-v1/ports').NodeAppLifecycleMemoryObservation} NodeAppLifecycleMemoryObservation */
|
|
13
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryActivityRollup} NodeAppMemoryActivityRollup */
|
|
14
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryAttribution} NodeAppMemoryAttribution */
|
|
15
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryAvailability} NodeAppMemoryAvailability */
|
|
16
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryBudgetBasis} NodeAppMemoryBudgetBasis */
|
|
17
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryCapabilityCallCount} NodeAppMemoryCapabilityCallCount */
|
|
18
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryDownload} NodeAppMemoryDownload */
|
|
19
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryOverview} NodeAppMemoryOverview */
|
|
20
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryOverviewApp} NodeAppMemoryOverviewApp */
|
|
21
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryReading} NodeAppMemoryReading */
|
|
22
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryRepository} NodeAppMemoryRepository */
|
|
23
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemorySnapshot} NodeAppMemorySnapshot */
|
|
24
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemorySource} NodeAppMemorySource */
|
|
25
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryTrend} NodeAppMemoryTrend */
|
|
26
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryTrendVerdict} NodeAppMemoryTrendVerdict */
|
|
27
|
+
/** @typedef {import('@econ-v1/ports').NodeAppMemoryUnavailableReason} NodeAppMemoryUnavailableReason */
|
|
28
|
+
/** @typedef {import('@econ-v1/ports').NodeAppPressureState} NodeAppPressureState */
|
|
29
|
+
/** @typedef {import('@econ-v1/ports').NodeAppRuntimeMode} NodeAppRuntimeMode */
|
|
30
|
+
/** @typedef {import('@econ-v1/ports').NodeAppTerminationReason} NodeAppTerminationReason */
|
|
31
|
+
export const NODE_APP_MEMORY_AVAILABILITIES = [
|
|
32
|
+
"measured",
|
|
33
|
+
"stale",
|
|
34
|
+
"unavailable",
|
|
35
|
+
];
|
|
36
|
+
export const NODE_APP_MEMORY_ATTRIBUTIONS = [
|
|
37
|
+
"aggregate_shared_host",
|
|
38
|
+
"exact_cgroup",
|
|
39
|
+
"exact_isolate",
|
|
40
|
+
"exact_process",
|
|
41
|
+
"mapped_partial",
|
|
42
|
+
"self_reported",
|
|
43
|
+
"unavailable",
|
|
44
|
+
];
|
|
45
|
+
export const NODE_APP_MEMORY_SOURCES = [
|
|
46
|
+
"bun_heap_self_report",
|
|
47
|
+
"cgroup_v2",
|
|
48
|
+
"main_pid_smaps_rollup",
|
|
49
|
+
"main_pid_status_vm_rss",
|
|
50
|
+
"proc_smaps_mappings",
|
|
51
|
+
"proc_smaps_rollup",
|
|
52
|
+
"shared_host_residual",
|
|
53
|
+
];
|
|
54
|
+
export const NODE_APP_MEMORY_UNAVAILABLE_REASONS = [
|
|
55
|
+
"cgroup_unavailable",
|
|
56
|
+
"non_linux",
|
|
57
|
+
"not_attributable",
|
|
58
|
+
"not_sampled",
|
|
59
|
+
"permission_denied",
|
|
60
|
+
"proc_unavailable",
|
|
61
|
+
"process_not_running",
|
|
62
|
+
"systemd_unavailable",
|
|
63
|
+
];
|
|
64
|
+
export const NODE_APP_RUNTIME_MODES = ["dedicated", "shared"];
|
|
65
|
+
export const NODE_APP_MEMORY_BUDGET_BASES = ["rss", "pss", "heap_used", "not_attributable"];
|
|
66
|
+
export const NODE_APP_MEMORY_TREND_VERDICTS = ["unknown", "flat", "sawtooth", "growing", "ratcheting"];
|
|
67
|
+
export const NODE_APP_BUDGET_STATES = ["ok", "over", "not_attributable"];
|
|
68
|
+
export const NODE_APP_LANE_KINDS = ["running", "warm", "idle_countdown", "sleeping", "evicted"];
|
|
69
|
+
export const NODE_APP_TERMINATION_REASONS = ["idle", "pressure"];
|
|
70
|
+
export const NODE_APP_PRESSURE_STATES = ["ok", "evicting", "unknown"];
|
|
71
|
+
/**
|
|
72
|
+
* @param {unknown} value
|
|
73
|
+
* @returns {value is NodeAppMemoryAvailability}
|
|
74
|
+
*/
|
|
75
|
+
export function isNodeAppMemoryAvailability(value) {
|
|
76
|
+
return typeof value === "string" && NODE_APP_MEMORY_AVAILABILITIES.includes(/** @type {NodeAppMemoryAvailability} */ (value));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @param {unknown} value
|
|
80
|
+
* @returns {value is NodeAppMemoryAttribution}
|
|
81
|
+
*/
|
|
82
|
+
export function isNodeAppMemoryAttribution(value) {
|
|
83
|
+
return typeof value === "string" && NODE_APP_MEMORY_ATTRIBUTIONS.includes(/** @type {NodeAppMemoryAttribution} */ (value));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @param {unknown} value
|
|
87
|
+
* @returns {value is NodeAppMemorySource}
|
|
88
|
+
*/
|
|
89
|
+
export function isNodeAppMemorySource(value) {
|
|
90
|
+
return typeof value === "string" && NODE_APP_MEMORY_SOURCES.includes(/** @type {NodeAppMemorySource} */ (value));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @param {unknown} value
|
|
94
|
+
* @returns {value is NodeAppMemoryUnavailableReason}
|
|
95
|
+
*/
|
|
96
|
+
export function isNodeAppMemoryUnavailableReason(value) {
|
|
97
|
+
return typeof value === "string" && NODE_APP_MEMORY_UNAVAILABLE_REASONS.includes(/** @type {NodeAppMemoryUnavailableReason} */ (value));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @param {unknown} value
|
|
101
|
+
* @returns {value is NodeAppRuntimeMode}
|
|
102
|
+
*/
|
|
103
|
+
export function isNodeAppRuntimeMode(value) {
|
|
104
|
+
return typeof value === "string" && NODE_APP_RUNTIME_MODES.includes(/** @type {NodeAppRuntimeMode} */ (value));
|
|
105
|
+
}
|
|
106
|
+
/** @param {unknown} value @returns {value is NodeAppMemoryBudgetBasis} */
|
|
107
|
+
export function isNodeAppMemoryBudgetBasis(value) {
|
|
108
|
+
return typeof value === "string" && NODE_APP_MEMORY_BUDGET_BASES.includes(/** @type {NodeAppMemoryBudgetBasis} */ (value));
|
|
109
|
+
}
|
|
110
|
+
/** @param {unknown} value @returns {value is NodeAppBudgetState} */
|
|
111
|
+
export function isNodeAppBudgetState(value) {
|
|
112
|
+
return typeof value === "string" && NODE_APP_BUDGET_STATES.includes(/** @type {NodeAppBudgetState} */ (value));
|
|
113
|
+
}
|
|
114
|
+
/** @param {unknown} value @returns {value is NodeAppMemoryTrendVerdict} */
|
|
115
|
+
export function isNodeAppMemoryTrendVerdict(value) {
|
|
116
|
+
return typeof value === "string" && NODE_APP_MEMORY_TREND_VERDICTS.includes(/** @type {NodeAppMemoryTrendVerdict} */ (value));
|
|
117
|
+
}
|
|
118
|
+
/** @param {unknown} value @returns {value is NodeAppLaneKind} */
|
|
119
|
+
export function isNodeAppLaneKind(value) {
|
|
120
|
+
return typeof value === "string" && NODE_APP_LANE_KINDS.includes(/** @type {NodeAppLaneKind} */ (value));
|
|
121
|
+
}
|
|
122
|
+
/** @param {unknown} value @returns {value is NodeAppTerminationReason} */
|
|
123
|
+
export function isNodeAppTerminationReason(value) {
|
|
124
|
+
return typeof value === "string" && NODE_APP_TERMINATION_REASONS.includes(/** @type {NodeAppTerminationReason} */ (value));
|
|
125
|
+
}
|
|
126
|
+
/** @param {unknown} value @returns {value is NodeAppPressureState} */
|
|
127
|
+
export function isNodeAppPressureState(value) {
|
|
128
|
+
return typeof value === "string" && NODE_APP_PRESSURE_STATES.includes(/** @type {NodeAppPressureState} */ (value));
|
|
129
|
+
}
|
|
130
|
+
// @ts-check
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("./json.js").JsonValue} JsonValue
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {"acknowledged" | "failed" | "pending" | "replaying"} OutboxIntentState
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {{ readonly domain: string; readonly id: string; readonly idempotencyKey: string; readonly payload: JsonValue; readonly state: OutboxIntentState; }} OutboxIntent
|
|
11
|
+
*/
|
|
12
|
+
export {};
|