@murphai/hosted-execution 0.1.15 → 0.1.17
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/LICENSE +201 -674
- package/README.md +15 -14
- package/dist/auth.d.ts +11 -25
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +32 -76
- package/dist/auth.js.map +1 -1
- package/dist/builders.d.ts +3 -4
- package/dist/builders.d.ts.map +1 -1
- package/dist/builders.js +24 -24
- package/dist/builders.js.map +1 -1
- package/dist/bundles.d.ts +3 -13
- package/dist/bundles.d.ts.map +1 -1
- package/dist/bundles.js +1 -16
- package/dist/bundles.js.map +1 -1
- package/dist/client.d.ts +2 -26
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +38 -212
- package/dist/client.js.map +1 -1
- package/dist/contracts.d.ts +49 -118
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +15 -58
- package/dist/contracts.js.map +1 -1
- package/dist/dispatch-ref.d.ts +1 -2
- package/dist/dispatch-ref.d.ts.map +1 -1
- package/dist/dispatch-ref.js +16 -30
- package/dist/dispatch-ref.js.map +1 -1
- package/dist/env.d.ts +0 -38
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +1 -87
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/observability.d.ts +3 -1
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +76 -53
- package/dist/observability.js.map +1 -1
- package/dist/outbox-payload.d.ts +7 -5
- package/dist/outbox-payload.d.ts.map +1 -1
- package/dist/outbox-payload.js +75 -38
- package/dist/outbox-payload.js.map +1 -1
- package/dist/parsers.d.ts +10 -10
- package/dist/parsers.d.ts.map +1 -1
- package/dist/parsers.js +192 -139
- package/dist/parsers.js.map +1 -1
- package/dist/routes.d.ts +4 -9
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +7 -18
- package/dist/routes.js.map +1 -1
- package/node_modules/@murphai/core/README.md +3 -0
- package/node_modules/@murphai/core/dist/assessment/index.d.ts +5 -0
- package/node_modules/@murphai/core/dist/assessment/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/index.js +4 -0
- package/node_modules/@murphai/core/dist/assessment/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/project.d.ts +9 -0
- package/node_modules/@murphai/core/dist/assessment/project.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/project.js +353 -0
- package/node_modules/@murphai/core/dist/assessment/project.js.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/storage.d.ts +13 -0
- package/node_modules/@murphai/core/dist/assessment/storage.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/storage.js +202 -0
- package/node_modules/@murphai/core/dist/assessment/storage.js.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/types.d.ts +112 -0
- package/node_modules/@murphai/core/dist/assessment/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/assessment/types.js +5 -0
- package/node_modules/@murphai/core/dist/assessment/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/atomic-write.d.ts +5 -0
- package/node_modules/@murphai/core/dist/atomic-write.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/atomic-write.js +120 -0
- package/node_modules/@murphai/core/dist/atomic-write.js.map +1 -0
- package/node_modules/@murphai/core/dist/audit.d.ts +27 -0
- package/node_modules/@murphai/core/dist/audit.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/audit.js +94 -0
- package/node_modules/@murphai/core/dist/audit.js.map +1 -0
- package/node_modules/@murphai/core/dist/automation.d.ts +55 -0
- package/node_modules/@murphai/core/dist/automation.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/automation.js +411 -0
- package/node_modules/@murphai/core/dist/automation.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/allergies.d.ts +5 -0
- package/node_modules/@murphai/core/dist/bank/allergies.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/allergies.js +209 -0
- package/node_modules/@murphai/core/dist/bank/allergies.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/conditions.d.ts +5 -0
- package/node_modules/@murphai/core/dist/bank/conditions.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/conditions.js +249 -0
- package/node_modules/@murphai/core/dist/bank/conditions.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/foods.d.ts +8 -0
- package/node_modules/@murphai/core/dist/bank/foods.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/foods.js +255 -0
- package/node_modules/@murphai/core/dist/bank/foods.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/goals.d.ts +5 -0
- package/node_modules/@murphai/core/dist/bank/goals.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/goals.js +289 -0
- package/node_modules/@murphai/core/dist/bank/goals.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/index.d.ts +10 -0
- package/node_modules/@murphai/core/dist/bank/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/index.js +10 -0
- package/node_modules/@murphai/core/dist/bank/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/protocols.d.ts +8 -0
- package/node_modules/@murphai/core/dist/bank/protocols.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/protocols.js +466 -0
- package/node_modules/@murphai/core/dist/bank/protocols.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/providers.d.ts +46 -0
- package/node_modules/@murphai/core/dist/bank/providers.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/providers.js +160 -0
- package/node_modules/@murphai/core/dist/bank/providers.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/recipes.d.ts +8 -0
- package/node_modules/@murphai/core/dist/bank/recipes.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/recipes.js +287 -0
- package/node_modules/@murphai/core/dist/bank/recipes.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/shared.d.ts +39 -0
- package/node_modules/@murphai/core/dist/bank/shared.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/shared.js +150 -0
- package/node_modules/@murphai/core/dist/bank/shared.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/types.d.ts +469 -0
- package/node_modules/@murphai/core/dist/bank/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/types.js +35 -0
- package/node_modules/@murphai/core/dist/bank/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/bank/workout-formats.d.ts +5 -0
- package/node_modules/@murphai/core/dist/bank/workout-formats.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/bank/workout-formats.js +204 -0
- package/node_modules/@murphai/core/dist/bank/workout-formats.js.map +1 -0
- package/node_modules/@murphai/core/dist/canonical-mutations.d.ts +54 -0
- package/node_modules/@murphai/core/dist/canonical-mutations.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/canonical-mutations.js +196 -0
- package/node_modules/@murphai/core/dist/canonical-mutations.js.map +1 -0
- package/node_modules/@murphai/core/dist/constants.d.ts +125 -0
- package/node_modules/@murphai/core/dist/constants.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/constants.js +132 -0
- package/node_modules/@murphai/core/dist/constants.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/events.d.ts +100 -0
- package/node_modules/@murphai/core/dist/domains/events.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/events.js +593 -0
- package/node_modules/@murphai/core/dist/domains/events.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/experiments.d.ts +71 -0
- package/node_modules/@murphai/core/dist/domains/experiments.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/experiments.js +275 -0
- package/node_modules/@murphai/core/dist/domains/experiments.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/journal.d.ts +52 -0
- package/node_modules/@murphai/core/dist/domains/journal.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/journal.js +173 -0
- package/node_modules/@murphai/core/dist/domains/journal.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/shared.d.ts +37 -0
- package/node_modules/@murphai/core/dist/domains/shared.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/shared.js +101 -0
- package/node_modules/@murphai/core/dist/domains/shared.js.map +1 -0
- package/node_modules/@murphai/core/dist/domains/vault-summary.d.ts +15 -0
- package/node_modules/@murphai/core/dist/domains/vault-summary.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/domains/vault-summary.js +58 -0
- package/node_modules/@murphai/core/dist/domains/vault-summary.js.map +1 -0
- package/node_modules/@murphai/core/dist/errors.d.ts +8 -0
- package/node_modules/@murphai/core/dist/errors.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/errors.js +14 -0
- package/node_modules/@murphai/core/dist/errors.js.map +1 -0
- package/node_modules/@murphai/core/dist/event-attachments.d.ts +69 -0
- package/node_modules/@murphai/core/dist/event-attachments.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/event-attachments.js +202 -0
- package/node_modules/@murphai/core/dist/event-attachments.js.map +1 -0
- package/node_modules/@murphai/core/dist/event-links.d.ts +15 -0
- package/node_modules/@murphai/core/dist/event-links.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/event-links.js +54 -0
- package/node_modules/@murphai/core/dist/event-links.js.map +1 -0
- package/node_modules/@murphai/core/dist/family/api.d.ts +5 -0
- package/node_modules/@murphai/core/dist/family/api.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/family/api.js +221 -0
- package/node_modules/@murphai/core/dist/family/api.js.map +1 -0
- package/node_modules/@murphai/core/dist/family/index.d.ts +3 -0
- package/node_modules/@murphai/core/dist/family/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/family/index.js +3 -0
- package/node_modules/@murphai/core/dist/family/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/family/types.d.ts +34 -0
- package/node_modules/@murphai/core/dist/family/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/family/types.js +2 -0
- package/node_modules/@murphai/core/dist/family/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/frontmatter.d.ts +4 -0
- package/node_modules/@murphai/core/dist/frontmatter.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/frontmatter.js +99 -0
- package/node_modules/@murphai/core/dist/frontmatter.js.map +1 -0
- package/node_modules/@murphai/core/dist/fs.d.ts +22 -0
- package/node_modules/@murphai/core/dist/fs.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/fs.js +172 -0
- package/node_modules/@murphai/core/dist/fs.js.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/api.d.ts +5 -0
- package/node_modules/@murphai/core/dist/genetics/api.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/api.js +226 -0
- package/node_modules/@murphai/core/dist/genetics/api.js.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/index.d.ts +3 -0
- package/node_modules/@murphai/core/dist/genetics/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/index.js +3 -0
- package/node_modules/@murphai/core/dist/genetics/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/types.d.ts +40 -0
- package/node_modules/@murphai/core/dist/genetics/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/genetics/types.js +4 -0
- package/node_modules/@murphai/core/dist/genetics/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/api.d.ts +7 -0
- package/node_modules/@murphai/core/dist/history/api.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/api.js +473 -0
- package/node_modules/@murphai/core/dist/history/api.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/event-spine.d.ts +41 -0
- package/node_modules/@murphai/core/dist/history/event-spine.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/event-spine.js +111 -0
- package/node_modules/@murphai/core/dist/history/event-spine.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/index.d.ts +3 -0
- package/node_modules/@murphai/core/dist/history/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/index.js +3 -0
- package/node_modules/@murphai/core/dist/history/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/shared.d.ts +25 -0
- package/node_modules/@murphai/core/dist/history/shared.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/shared.js +144 -0
- package/node_modules/@murphai/core/dist/history/shared.js.map +1 -0
- package/node_modules/@murphai/core/dist/history/types.d.ts +127 -0
- package/node_modules/@murphai/core/dist/history/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/history/types.js +8 -0
- package/node_modules/@murphai/core/dist/history/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/ids.d.ts +3 -0
- package/node_modules/@murphai/core/dist/ids.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/ids.js +20 -0
- package/node_modules/@murphai/core/dist/ids.js.map +1 -0
- package/node_modules/@murphai/core/dist/index.d.ts +30 -0
- package/node_modules/@murphai/core/dist/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/index.js +23 -0
- package/node_modules/@murphai/core/dist/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/jsonl.d.ts +12 -0
- package/node_modules/@murphai/core/dist/jsonl.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/jsonl.js +40 -0
- package/node_modules/@murphai/core/dist/jsonl.js.map +1 -0
- package/node_modules/@murphai/core/dist/memory.d.ts +17 -0
- package/node_modules/@murphai/core/dist/memory.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/memory.js +72 -0
- package/node_modules/@murphai/core/dist/memory.js.map +1 -0
- package/node_modules/@murphai/core/dist/mutations.d.ts +150 -0
- package/node_modules/@murphai/core/dist/mutations.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/mutations.js +1109 -0
- package/node_modules/@murphai/core/dist/mutations.js.map +1 -0
- package/node_modules/@murphai/core/dist/operations/canonical-write-lock.d.ts +29 -0
- package/node_modules/@murphai/core/dist/operations/canonical-write-lock.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/operations/canonical-write-lock.js +164 -0
- package/node_modules/@murphai/core/dist/operations/canonical-write-lock.js.map +1 -0
- package/node_modules/@murphai/core/dist/operations/index.d.ts +5 -0
- package/node_modules/@murphai/core/dist/operations/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/operations/index.js +3 -0
- package/node_modules/@murphai/core/dist/operations/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/operations/raw-manifests.d.ts +33 -0
- package/node_modules/@murphai/core/dist/operations/raw-manifests.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/operations/raw-manifests.js +105 -0
- package/node_modules/@murphai/core/dist/operations/raw-manifests.js.map +1 -0
- package/node_modules/@murphai/core/dist/operations/write-batch.d.ts +166 -0
- package/node_modules/@murphai/core/dist/operations/write-batch.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/operations/write-batch.js +886 -0
- package/node_modules/@murphai/core/dist/operations/write-batch.js.map +1 -0
- package/node_modules/@murphai/core/dist/path-safety.d.ts +19 -0
- package/node_modules/@murphai/core/dist/path-safety.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/path-safety.js +193 -0
- package/node_modules/@murphai/core/dist/path-safety.js.map +1 -0
- package/node_modules/@murphai/core/dist/profile/index.d.ts +4 -0
- package/node_modules/@murphai/core/dist/profile/index.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/profile/index.js +3 -0
- package/node_modules/@murphai/core/dist/profile/index.js.map +1 -0
- package/node_modules/@murphai/core/dist/profile/storage.d.ts +41 -0
- package/node_modules/@murphai/core/dist/profile/storage.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/profile/storage.js +225 -0
- package/node_modules/@murphai/core/dist/profile/storage.js.map +1 -0
- package/node_modules/@murphai/core/dist/profile/types.d.ts +29 -0
- package/node_modules/@murphai/core/dist/profile/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/profile/types.js +8 -0
- package/node_modules/@murphai/core/dist/profile/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/public-mutations.d.ts +120 -0
- package/node_modules/@murphai/core/dist/public-mutations.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/public-mutations.js +275 -0
- package/node_modules/@murphai/core/dist/public-mutations.js.map +1 -0
- package/node_modules/@murphai/core/dist/raw.d.ts +28 -0
- package/node_modules/@murphai/core/dist/raw.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/raw.js +107 -0
- package/node_modules/@murphai/core/dist/raw.js.map +1 -0
- package/node_modules/@murphai/core/dist/registry/api.d.ts +80 -0
- package/node_modules/@murphai/core/dist/registry/api.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/registry/api.js +113 -0
- package/node_modules/@murphai/core/dist/registry/api.js.map +1 -0
- package/node_modules/@murphai/core/dist/registry/id-or-slug.d.ts +15 -0
- package/node_modules/@murphai/core/dist/registry/id-or-slug.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/registry/id-or-slug.js +9 -0
- package/node_modules/@murphai/core/dist/registry/id-or-slug.js.map +1 -0
- package/node_modules/@murphai/core/dist/registry/markdown.d.ts +101 -0
- package/node_modules/@murphai/core/dist/registry/markdown.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/registry/markdown.js +136 -0
- package/node_modules/@murphai/core/dist/registry/markdown.js.map +1 -0
- package/node_modules/@murphai/core/dist/shares.d.ts +36 -0
- package/node_modules/@murphai/core/dist/shares.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/shares.js +333 -0
- package/node_modules/@murphai/core/dist/shares.js.map +1 -0
- package/node_modules/@murphai/core/dist/storage-spine.d.ts +3 -0
- package/node_modules/@murphai/core/dist/storage-spine.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/storage-spine.js +3 -0
- package/node_modules/@murphai/core/dist/storage-spine.js.map +1 -0
- package/node_modules/@murphai/core/dist/time.d.ts +11 -0
- package/node_modules/@murphai/core/dist/time.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/time.js +72 -0
- package/node_modules/@murphai/core/dist/time.js.map +1 -0
- package/node_modules/@murphai/core/dist/types.d.ts +18 -0
- package/node_modules/@murphai/core/dist/types.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/types.js +7 -0
- package/node_modules/@murphai/core/dist/types.js.map +1 -0
- package/node_modules/@murphai/core/dist/vault-core-document.d.ts +8 -0
- package/node_modules/@murphai/core/dist/vault-core-document.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/vault-core-document.js +16 -0
- package/node_modules/@murphai/core/dist/vault-core-document.js.map +1 -0
- package/node_modules/@murphai/core/dist/vault-metadata.d.ts +17 -0
- package/node_modules/@murphai/core/dist/vault-metadata.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/vault-metadata.js +44 -0
- package/node_modules/@murphai/core/dist/vault-metadata.js.map +1 -0
- package/node_modules/@murphai/core/dist/vault-upgrade.d.ts +24 -0
- package/node_modules/@murphai/core/dist/vault-upgrade.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/vault-upgrade.js +44 -0
- package/node_modules/@murphai/core/dist/vault-upgrade.js.map +1 -0
- package/node_modules/@murphai/core/dist/vault.d.ts +40 -0
- package/node_modules/@murphai/core/dist/vault.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/vault.js +649 -0
- package/node_modules/@murphai/core/dist/vault.js.map +1 -0
- package/node_modules/@murphai/core/dist/write-policy.d.ts +63 -0
- package/node_modules/@murphai/core/dist/write-policy.d.ts.map +1 -0
- package/node_modules/@murphai/core/dist/write-policy.js +146 -0
- package/node_modules/@murphai/core/dist/write-policy.js.map +1 -0
- package/node_modules/@murphai/core/package.json +27 -0
- package/node_modules/@murphai/device-syncd/README.md +123 -0
- package/node_modules/@murphai/device-syncd/dist/bin.d.ts +2 -0
- package/node_modules/@murphai/device-syncd/dist/bin.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/bin.js +29 -0
- package/node_modules/@murphai/device-syncd/dist/bin.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/client.d.ts +124 -0
- package/node_modules/@murphai/device-syncd/dist/client.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/client.js +199 -0
- package/node_modules/@murphai/device-syncd/dist/client.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/config.d.ts +18 -0
- package/node_modules/@murphai/device-syncd/dist/config.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/config.js +279 -0
- package/node_modules/@murphai/device-syncd/dist/config.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/crypto.d.ts +6 -0
- package/node_modules/@murphai/device-syncd/dist/crypto.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/crypto.js +27 -0
- package/node_modules/@murphai/device-syncd/dist/crypto.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/errors.d.ts +21 -0
- package/node_modules/@murphai/device-syncd/dist/errors.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/errors.js +32 -0
- package/node_modules/@murphai/device-syncd/dist/errors.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-hints.d.ts +3 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-hints.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-hints.js +110 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-hints.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.d.ts +139 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.js +336 -0
- package/node_modules/@murphai/device-syncd/dist/hosted-runtime.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/http.d.ts +34 -0
- package/node_modules/@murphai/device-syncd/dist/http.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/http.js +644 -0
- package/node_modules/@murphai/device-syncd/dist/http.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/index.d.ts +23 -0
- package/node_modules/@murphai/device-syncd/dist/index.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/index.js +15 -0
- package/node_modules/@murphai/device-syncd/dist/index.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/garmin.d.ts +15 -0
- package/node_modules/@murphai/device-syncd/dist/providers/garmin.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/garmin.js +485 -0
- package/node_modules/@murphai/device-syncd/dist/providers/garmin.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.d.ts +49 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.js +401 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura-webhooks.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura.d.ts +20 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura.js +804 -0
- package/node_modules/@murphai/device-syncd/dist/providers/oura.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.d.ts +104 -0
- package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.js +214 -0
- package/node_modules/@murphai/device-syncd/dist/providers/shared-oauth.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/whoop.d.ts +15 -0
- package/node_modules/@murphai/device-syncd/dist/providers/whoop.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/providers/whoop.js +551 -0
- package/node_modules/@murphai/device-syncd/dist/providers/whoop.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/public-account.d.ts +4 -0
- package/node_modules/@murphai/device-syncd/dist/public-account.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/public-account.js +13 -0
- package/node_modules/@murphai/device-syncd/dist/public-account.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/public-ingress.d.ts +43 -0
- package/node_modules/@murphai/device-syncd/dist/public-ingress.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/public-ingress.js +353 -0
- package/node_modules/@murphai/device-syncd/dist/public-ingress.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/registry.d.ts +3 -0
- package/node_modules/@murphai/device-syncd/dist/registry.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/registry.js +5 -0
- package/node_modules/@murphai/device-syncd/dist/registry.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/service.d.ts +61 -0
- package/node_modules/@murphai/device-syncd/dist/service.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/service.js +496 -0
- package/node_modules/@murphai/device-syncd/dist/service.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/shared.d.ts +26 -0
- package/node_modules/@murphai/device-syncd/dist/shared.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/shared.js +182 -0
- package/node_modules/@murphai/device-syncd/dist/shared.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/store.d.ts +105 -0
- package/node_modules/@murphai/device-syncd/dist/store.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/store.js +965 -0
- package/node_modules/@murphai/device-syncd/dist/store.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/types.d.ts +287 -0
- package/node_modules/@murphai/device-syncd/dist/types.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/types.js +2 -0
- package/node_modules/@murphai/device-syncd/dist/types.js.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/webhook-verification.d.ts +14 -0
- package/node_modules/@murphai/device-syncd/dist/webhook-verification.d.ts.map +1 -0
- package/node_modules/@murphai/device-syncd/dist/webhook-verification.js +16 -0
- package/node_modules/@murphai/device-syncd/dist/webhook-verification.js.map +1 -0
- package/node_modules/@murphai/device-syncd/package.json +85 -0
- package/node_modules/@murphai/importers/README.md +34 -0
- package/node_modules/@murphai/importers/dist/assessment/core-port.d.ts +13 -0
- package/node_modules/@murphai/importers/dist/assessment/core-port.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/core-port.js +13 -0
- package/node_modules/@murphai/importers/dist/assessment/core-port.js.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.d.ts +15 -0
- package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.js +32 -0
- package/node_modules/@murphai/importers/dist/assessment/import-assessment-response.js.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/index.d.ts +4 -0
- package/node_modules/@murphai/importers/dist/assessment/index.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/assessment/index.js +2 -0
- package/node_modules/@murphai/importers/dist/assessment/index.js.map +1 -0
- package/node_modules/@murphai/importers/dist/core-port.d.ts +119 -0
- package/node_modules/@murphai/importers/dist/core-port.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/core-port.js +22 -0
- package/node_modules/@murphai/importers/dist/core-port.js.map +1 -0
- package/node_modules/@murphai/importers/dist/create-importers.d.ts +17 -0
- package/node_modules/@murphai/importers/dist/create-importers.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/create-importers.js +68 -0
- package/node_modules/@murphai/importers/dist/create-importers.js.map +1 -0
- package/node_modules/@murphai/importers/dist/csv-sample-importer.d.ts +22 -0
- package/node_modules/@murphai/importers/dist/csv-sample-importer.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/csv-sample-importer.js +153 -0
- package/node_modules/@murphai/importers/dist/csv-sample-importer.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/defaults.d.ts +5 -0
- package/node_modules/@murphai/importers/dist/device-providers/defaults.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/defaults.js +11 -0
- package/node_modules/@murphai/importers/dist/device-providers/defaults.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.d.ts +9 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.js +172 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-activity-normalizers.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.d.ts +12 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.js +619 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-health-normalizers.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.d.ts +40 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.js +295 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin-helpers.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin.d.ts +19 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin.js +150 -0
- package/node_modules/@murphai/importers/dist/device-providers/garmin.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.d.ts +14 -0
- package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.js +37 -0
- package/node_modules/@murphai/importers/dist/device-providers/import-device-provider-snapshot.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/index.d.ts +10 -0
- package/node_modules/@murphai/importers/dist/device-providers/index.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/index.js +8 -0
- package/node_modules/@murphai/importers/dist/device-providers/index.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/oura.d.ts +20 -0
- package/node_modules/@murphai/importers/dist/device-providers/oura.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/oura.js +602 -0
- package/node_modules/@murphai/importers/dist/device-providers/oura.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.d.ts +491 -0
- package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.js +326 -0
- package/node_modules/@murphai/importers/dist/device-providers/provider-descriptors.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/registry.d.ts +9 -0
- package/node_modules/@murphai/importers/dist/device-providers/registry.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/registry.js +5 -0
- package/node_modules/@murphai/importers/dist/device-providers/registry.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.d.ts +81 -0
- package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.js +215 -0
- package/node_modules/@murphai/importers/dist/device-providers/shared-normalization.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/types.d.ts +12 -0
- package/node_modules/@murphai/importers/dist/device-providers/types.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/types.js +2 -0
- package/node_modules/@murphai/importers/dist/device-providers/types.js.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/whoop.d.ts +16 -0
- package/node_modules/@murphai/importers/dist/device-providers/whoop.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/device-providers/whoop.js +410 -0
- package/node_modules/@murphai/importers/dist/device-providers/whoop.js.map +1 -0
- package/node_modules/@murphai/importers/dist/document-importer.d.ts +15 -0
- package/node_modules/@murphai/importers/dist/document-importer.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/document-importer.js +31 -0
- package/node_modules/@murphai/importers/dist/document-importer.js.map +1 -0
- package/node_modules/@murphai/importers/dist/index.d.ts +10 -0
- package/node_modules/@murphai/importers/dist/index.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/index.js +9 -0
- package/node_modules/@murphai/importers/dist/index.js.map +1 -0
- package/node_modules/@murphai/importers/dist/meal-importer.d.ts +15 -0
- package/node_modules/@murphai/importers/dist/meal-importer.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/meal-importer.js +39 -0
- package/node_modules/@murphai/importers/dist/meal-importer.js.map +1 -0
- package/node_modules/@murphai/importers/dist/preset-registry.d.ts +31 -0
- package/node_modules/@murphai/importers/dist/preset-registry.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/preset-registry.js +96 -0
- package/node_modules/@murphai/importers/dist/preset-registry.js.map +1 -0
- package/node_modules/@murphai/importers/dist/shared.d.ts +31 -0
- package/node_modules/@murphai/importers/dist/shared.d.ts.map +1 -0
- package/node_modules/@murphai/importers/dist/shared.js +154 -0
- package/node_modules/@murphai/importers/dist/shared.js.map +1 -0
- package/node_modules/@murphai/importers/package.json +36 -0
- package/node_modules/@murphai/runtime-state/README.md +37 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.js +80 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state-security.d.ts +29 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state-security.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state-security.js +159 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state-security.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state.d.ts +33 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state.js +47 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-state.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-usage.d.ts +56 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-usage.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-usage.js +189 -0
- package/node_modules/@murphai/runtime-state/dist/assistant-usage.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/atomic-write.d.ts +7 -0
- package/node_modules/@murphai/runtime-state/dist/atomic-write.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/atomic-write.js +27 -0
- package/node_modules/@murphai/runtime-state/dist/atomic-write.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.js +12 -0
- package/node_modules/@murphai/runtime-state/dist/device-sync-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.js +13 -0
- package/node_modules/@murphai/runtime-state/dist/gateway-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.d.ts +43 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.js +203 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-node.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.d.ts +13 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.js +46 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle-ref.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle.d.ts +67 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle.js +261 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundle.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundles.d.ts +31 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundles.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundles.js +211 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-bundles.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-email.d.ts +50 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-email.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-email.js +191 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-email.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-env.d.ts +14 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-env.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-env.js +59 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-env.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.d.ts +83 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.js +308 -0
- package/node_modules/@murphai/runtime-state/dist/hosted-user-keys.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.js +18 -0
- package/node_modules/@murphai/runtime-state/dist/inbox-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/index.d.ts +7 -0
- package/node_modules/@murphai/runtime-state/dist/index.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/index.js +7 -0
- package/node_modules/@murphai/runtime-state/dist/index.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.d.ts +31 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.js +120 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-helpers.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.js +17 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-descriptor-manifests.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-files.d.ts +10 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-files.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-files.js +27 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-files.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.d.ts +29 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.js +82 -0
- package/node_modules/@murphai/runtime-state/dist/local-state-taxonomy.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/locks.d.ts +46 -0
- package/node_modules/@murphai/runtime-state/dist/locks.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/locks.js +187 -0
- package/node_modules/@murphai/runtime-state/dist/locks.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.d.ts +4 -0
- package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.js +35 -0
- package/node_modules/@murphai/runtime-state/dist/loopback-control-plane.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/node/index.d.ts +22 -0
- package/node_modules/@murphai/runtime-state/dist/node/index.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/node/index.js +22 -0
- package/node_modules/@murphai/runtime-state/dist/node/index.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.js +12 -0
- package/node_modules/@murphai/runtime-state/dist/parser-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/process-env.d.ts +4 -0
- package/node_modules/@murphai/runtime-state/dist/process-env.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/process-env.js +124 -0
- package/node_modules/@murphai/runtime-state/dist/process-env.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.js +13 -0
- package/node_modules/@murphai/runtime-state/dist/query-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/runtime-paths.d.ts +48 -0
- package/node_modules/@murphai/runtime-state/dist/runtime-paths.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/runtime-paths.js +93 -0
- package/node_modules/@murphai/runtime-state/dist/runtime-paths.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/shared.d.ts +14 -0
- package/node_modules/@murphai/runtime-state/dist/shared.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/shared.js +46 -0
- package/node_modules/@murphai/runtime-state/dist/shared.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/sqlite.d.ts +26 -0
- package/node_modules/@murphai/runtime-state/dist/sqlite.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/sqlite.js +110 -0
- package/node_modules/@murphai/runtime-state/dist/sqlite.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/ulid.d.ts +5 -0
- package/node_modules/@murphai/runtime-state/dist/ulid.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/ulid.js +31 -0
- package/node_modules/@murphai/runtime-state/dist/ulid.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-files.d.ts +24 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-files.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-files.js +30 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-files.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-state.d.ts +18 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-state.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-state.js +25 -0
- package/node_modules/@murphai/runtime-state/dist/versioned-json-state.js.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.d.ts +3 -0
- package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.d.ts.map +1 -0
- package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.js +12 -0
- package/node_modules/@murphai/runtime-state/dist/write-operation-local-state-descriptors.js.map +1 -0
- package/node_modules/@murphai/runtime-state/package.json +30 -0
- package/package.json +45 -11
- package/dist/.tsbuildinfo +0 -1
- package/dist/callback-hosts.d.ts +0 -19
- package/dist/callback-hosts.d.ts.map +0 -1
- package/dist/callback-hosts.js +0 -19
- package/dist/callback-hosts.js.map +0 -1
- package/dist/web-control-plane.d.ts +0 -105
- package/dist/web-control-plane.d.ts.map +0 -1
- package/dist/web-control-plane.js +0 -358
- package/dist/web-control-plane.js.map +0 -1
|
@@ -0,0 +1,1109 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { experimentFrontmatterSchema, journalDayFrontmatterSchema, eventRecordSchema, safeParseContract, sampleRecordSchema, } from "@murphai/contracts";
|
|
3
|
+
import { BASELINE_EVENT_KINDS, BASELINE_SAMPLE_STREAMS, EVENT_SCHEMA_VERSION, EVENT_SOURCES, FRONTMATTER_SCHEMA_VERSIONS, ID_PREFIXES, SAMPLE_QUALITIES, SAMPLE_SCHEMA_VERSION, SAMPLE_SOURCES, VAULT_LAYOUT, } from "./constants.js";
|
|
4
|
+
import { emitAuditRecord } from "./audit.js";
|
|
5
|
+
import { buildAttachmentCompatibilityProjections, buildAttachmentPathCompatibilityProjections, prepareEventAttachments, stagePreparedEventAttachmentsInBatch, } from "./event-attachments.js";
|
|
6
|
+
import { canonicalizeEventRelations } from "./event-links.js";
|
|
7
|
+
import { VaultError } from "./errors.js";
|
|
8
|
+
import { pathExists, readUtf8File, writeVaultTextFile } from "./fs.js";
|
|
9
|
+
import { parseFrontmatterDocument, stringifyFrontmatterDocument } from "./frontmatter.js";
|
|
10
|
+
import { generateRecordId } from "./ids.js";
|
|
11
|
+
import { readJsonlRecords, toMonthlyShardRelativePath } from "./jsonl.js";
|
|
12
|
+
import { stageRawImportManifest } from "./operations/raw-manifests.js";
|
|
13
|
+
import { runCanonicalWrite } from "./operations/write-batch.js";
|
|
14
|
+
import { resolveVaultPath } from "./path-safety.js";
|
|
15
|
+
import { sanitizePathSegment } from "./path-safety.js";
|
|
16
|
+
import { prepareInlineRawArtifact, prepareRawArtifact } from "./raw.js";
|
|
17
|
+
import { defaultTimeZone, normalizeTimeZone, toIsoTimestamp, toLocalDayKey, } from "./time.js";
|
|
18
|
+
import { loadVault } from "./vault.js";
|
|
19
|
+
const EVENT_KIND_SET = new Set(BASELINE_EVENT_KINDS);
|
|
20
|
+
const EVENT_SOURCE_SET = new Set(EVENT_SOURCES);
|
|
21
|
+
const SAMPLE_STREAM_SET = new Set(BASELINE_SAMPLE_STREAMS);
|
|
22
|
+
const SAMPLE_SOURCE_SET = new Set(SAMPLE_SOURCES);
|
|
23
|
+
const SAMPLE_QUALITY_SET = new Set(SAMPLE_QUALITIES);
|
|
24
|
+
function compactRecord(record) {
|
|
25
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => {
|
|
26
|
+
if (value === undefined || value === null) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value === "object") {
|
|
33
|
+
return Object.keys(value).length > 0;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
function stableSortValue(value) {
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return value.map((entry) => stableSortValue(entry));
|
|
41
|
+
}
|
|
42
|
+
if (value && typeof value === "object") {
|
|
43
|
+
const entries = Object.entries(value)
|
|
44
|
+
.filter(([, entry]) => entry !== undefined)
|
|
45
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
46
|
+
.map(([key, entry]) => [key, stableSortValue(entry)]);
|
|
47
|
+
return Object.fromEntries(entries);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
function stableStringify(value) {
|
|
52
|
+
return JSON.stringify(stableSortValue(value));
|
|
53
|
+
}
|
|
54
|
+
function normalizeExternalRef(value) {
|
|
55
|
+
if (value === undefined || value === null) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const candidate = assertPlainObject(value, "VAULT_INVALID_EXTERNAL_REF", "externalRef must be a plain object.");
|
|
59
|
+
return compactRecord({
|
|
60
|
+
system: typeof candidate.system === "string" ? candidate.system.trim() : undefined,
|
|
61
|
+
resourceType: typeof candidate.resourceType === "string" ? candidate.resourceType.trim() : undefined,
|
|
62
|
+
resourceId: typeof candidate.resourceId === "string" ? candidate.resourceId.trim() : undefined,
|
|
63
|
+
version: typeof candidate.version === "string" && candidate.version.trim()
|
|
64
|
+
? candidate.version.trim()
|
|
65
|
+
: undefined,
|
|
66
|
+
facet: typeof candidate.facet === "string" && candidate.facet.trim()
|
|
67
|
+
? candidate.facet.trim()
|
|
68
|
+
: undefined,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function normalizeLooseRecord(value, code, message) {
|
|
72
|
+
if (value === undefined || value === null) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
return assertPlainObject(value, code, message);
|
|
76
|
+
}
|
|
77
|
+
function normalizeDayKeyInput(value) {
|
|
78
|
+
return typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value.trim())
|
|
79
|
+
? value.trim()
|
|
80
|
+
: undefined;
|
|
81
|
+
}
|
|
82
|
+
function normalizeRequiredRole(value, label) {
|
|
83
|
+
const candidate = String(value ?? "").trim();
|
|
84
|
+
if (!candidate) {
|
|
85
|
+
throw new VaultError("VAULT_INVALID_RAW_ROLE", `${label} must be a non-empty string.`);
|
|
86
|
+
}
|
|
87
|
+
return candidate;
|
|
88
|
+
}
|
|
89
|
+
function normalizeInlineRawContent(content) {
|
|
90
|
+
if (typeof content === "string") {
|
|
91
|
+
return content;
|
|
92
|
+
}
|
|
93
|
+
if (content === undefined) {
|
|
94
|
+
throw new VaultError("VAULT_INVALID_RAW_CONTENT", "raw artifact content is required.");
|
|
95
|
+
}
|
|
96
|
+
return `${JSON.stringify(stableSortValue(content), null, 2)}\n`;
|
|
97
|
+
}
|
|
98
|
+
function earliestTimestamp(timestamps, fallback = new Date()) {
|
|
99
|
+
if (timestamps.length === 0) {
|
|
100
|
+
return toIsoTimestamp(fallback, "occurredAt");
|
|
101
|
+
}
|
|
102
|
+
return [...timestamps].sort()[0];
|
|
103
|
+
}
|
|
104
|
+
function assertPlainObject(value, code, message) {
|
|
105
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
106
|
+
throw new VaultError(code, message);
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
function assertContractShape(schema, value, code, message) {
|
|
111
|
+
const result = safeParseContract(schema, value);
|
|
112
|
+
if (!result.success) {
|
|
113
|
+
throw new VaultError(code, `${message} ${JSON.stringify(result.errors)}`, { errors: result.errors });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function normalizeSource(value, allowed, fallback) {
|
|
117
|
+
return typeof value === "string" && allowed.has(value) ? value : fallback;
|
|
118
|
+
}
|
|
119
|
+
function normalizeSampleInputRecord(value, code, message) {
|
|
120
|
+
return assertPlainObject(value, code, message);
|
|
121
|
+
}
|
|
122
|
+
function trimStringList(value) {
|
|
123
|
+
if (!Array.isArray(value)) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
const entries = value
|
|
127
|
+
.filter((entry) => typeof entry === "string")
|
|
128
|
+
.map((entry) => entry.trim())
|
|
129
|
+
.filter(Boolean);
|
|
130
|
+
return entries.length > 0 ? entries : undefined;
|
|
131
|
+
}
|
|
132
|
+
function uniqueTrimmedStringList(value) {
|
|
133
|
+
const entries = trimStringList(value);
|
|
134
|
+
return entries ? [...new Set(entries)] : undefined;
|
|
135
|
+
}
|
|
136
|
+
const NUMERIC_UNIT_ALIASES = {
|
|
137
|
+
glucose: {
|
|
138
|
+
"mg/dl": "mg_dL",
|
|
139
|
+
"mg_dl": "mg_dL",
|
|
140
|
+
mg_dL: "mg_dL",
|
|
141
|
+
},
|
|
142
|
+
heart_rate: {
|
|
143
|
+
bpm: "bpm",
|
|
144
|
+
},
|
|
145
|
+
hrv: {
|
|
146
|
+
ms: "ms",
|
|
147
|
+
},
|
|
148
|
+
steps: {
|
|
149
|
+
count: "count",
|
|
150
|
+
},
|
|
151
|
+
respiratory_rate: {
|
|
152
|
+
breaths_per_minute: "breaths_per_minute",
|
|
153
|
+
"breaths/minute": "breaths_per_minute",
|
|
154
|
+
},
|
|
155
|
+
temperature: {
|
|
156
|
+
celsius: "celsius",
|
|
157
|
+
c: "celsius",
|
|
158
|
+
},
|
|
159
|
+
sleep_stage: {
|
|
160
|
+
stage: "stage",
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
const CROCKFORD_BASE32_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
164
|
+
const EVENT_VALIDATION_PLACEHOLDER_ID = `${ID_PREFIXES.event}_00000000000000000000000000`;
|
|
165
|
+
const SAMPLE_VALIDATION_PLACEHOLDER_ID = `${ID_PREFIXES.sample}_00000000000000000000000000`;
|
|
166
|
+
function normalizeNumericUnit(stream, unit) {
|
|
167
|
+
const normalized = String(unit ?? "").trim();
|
|
168
|
+
const aliases = NUMERIC_UNIT_ALIASES[stream];
|
|
169
|
+
const candidate = aliases[normalized] ??
|
|
170
|
+
aliases[normalized.toLowerCase()];
|
|
171
|
+
if (!candidate) {
|
|
172
|
+
throw new VaultError("VAULT_INVALID_SAMPLE_UNIT", `Unsupported unit "${normalized}" for stream "${stream}".`, {
|
|
173
|
+
stream,
|
|
174
|
+
unit: normalized,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return candidate;
|
|
178
|
+
}
|
|
179
|
+
function encodeBase32(bytes, length) {
|
|
180
|
+
let output = "";
|
|
181
|
+
let buffer = 0;
|
|
182
|
+
let bits = 0;
|
|
183
|
+
for (const byte of bytes) {
|
|
184
|
+
buffer = (buffer << 8) | byte;
|
|
185
|
+
bits += 8;
|
|
186
|
+
while (bits >= 5 && output.length < length) {
|
|
187
|
+
bits -= 5;
|
|
188
|
+
output += CROCKFORD_BASE32_ALPHABET[(buffer >> bits) & 31];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (bits > 0 && output.length < length) {
|
|
192
|
+
output += CROCKFORD_BASE32_ALPHABET[(buffer << (5 - bits)) & 31];
|
|
193
|
+
}
|
|
194
|
+
return output.padEnd(length, "0").slice(0, length);
|
|
195
|
+
}
|
|
196
|
+
function deterministicContractId(prefix, seed) {
|
|
197
|
+
const hash = createHash("sha256").update(seed).digest();
|
|
198
|
+
return `${prefix}_${encodeBase32(hash, 26)}`;
|
|
199
|
+
}
|
|
200
|
+
function buildPreparedAttachmentState(preparedAttachments) {
|
|
201
|
+
const projections = buildAttachmentPathCompatibilityProjections(preparedAttachments.map((attachment) => ({
|
|
202
|
+
role: attachment.role,
|
|
203
|
+
kind: attachment.kind ?? "other",
|
|
204
|
+
relativePath: attachment.raw.relativePath,
|
|
205
|
+
})));
|
|
206
|
+
return {
|
|
207
|
+
projections: {
|
|
208
|
+
audioPaths: projections.audioPaths,
|
|
209
|
+
documentPath: projections.documentPath,
|
|
210
|
+
photoPaths: projections.photoPaths,
|
|
211
|
+
rawRefs: projections.rawRefs,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function buildNormalizedEventSeed({ kind, occurredAt, recordedAt = new Date(), dayKey, timeZone, defaultTimeZone: fallbackTimeZone, source, title, note, tags, links, relatedIds, rawRefs, externalRef, fields = {}, }) {
|
|
216
|
+
if (!EVENT_KIND_SET.has(kind)) {
|
|
217
|
+
throw new VaultError("VAULT_UNSUPPORTED_EVENT_KIND", `Unsupported baseline event kind "${kind}".`, {
|
|
218
|
+
kind,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const normalizedFields = assertPlainObject(fields, "VAULT_INVALID_EVENT_FIELDS", "Event fields must be a plain object.");
|
|
222
|
+
const occurredTimestamp = toIsoTimestamp(occurredAt, "occurredAt");
|
|
223
|
+
const recordedTimestamp = toIsoTimestamp(recordedAt, "recordedAt");
|
|
224
|
+
const resolvedTimeZone = normalizeTimeZone(timeZone ?? fallbackTimeZone);
|
|
225
|
+
const resolvedDayKey = normalizeDayKeyInput(dayKey) ??
|
|
226
|
+
toLocalDayKey(occurredTimestamp, resolvedTimeZone ?? defaultTimeZone(), "occurredAt");
|
|
227
|
+
const canonicalRelations = canonicalizeEventRelations({
|
|
228
|
+
links,
|
|
229
|
+
relatedIds,
|
|
230
|
+
normalizeStringList: uniqueTrimmedStringList,
|
|
231
|
+
errorCode: "VAULT_INVALID_INPUT",
|
|
232
|
+
errorMessage: "links entries must be objects with non-empty type and targetId fields.",
|
|
233
|
+
});
|
|
234
|
+
const seed = {
|
|
235
|
+
kind,
|
|
236
|
+
occurredAt: occurredTimestamp,
|
|
237
|
+
recordedAt: recordedTimestamp,
|
|
238
|
+
dayKey: resolvedDayKey,
|
|
239
|
+
timeZone: resolvedTimeZone,
|
|
240
|
+
source: normalizeSource(source, EVENT_SOURCE_SET, "manual"),
|
|
241
|
+
title: typeof title === "string" && title.trim() ? title.trim() : kind,
|
|
242
|
+
note: typeof note === "string" && note.trim() ? note.trim() : undefined,
|
|
243
|
+
tags: trimStringList(tags),
|
|
244
|
+
links: canonicalRelations.links,
|
|
245
|
+
relatedIds: canonicalRelations.relatedIds,
|
|
246
|
+
rawRefs: trimStringList(rawRefs),
|
|
247
|
+
externalRef: normalizeExternalRef(externalRef),
|
|
248
|
+
fields: normalizedFields,
|
|
249
|
+
};
|
|
250
|
+
validateEventSeed(seed);
|
|
251
|
+
return seed;
|
|
252
|
+
}
|
|
253
|
+
function buildEventContractInput(seed, recordId) {
|
|
254
|
+
return compactRecord({
|
|
255
|
+
schemaVersion: EVENT_SCHEMA_VERSION,
|
|
256
|
+
id: recordId,
|
|
257
|
+
kind: seed.kind,
|
|
258
|
+
occurredAt: seed.occurredAt,
|
|
259
|
+
recordedAt: seed.recordedAt,
|
|
260
|
+
dayKey: seed.dayKey,
|
|
261
|
+
timeZone: seed.timeZone,
|
|
262
|
+
source: seed.source,
|
|
263
|
+
title: seed.title,
|
|
264
|
+
note: seed.note,
|
|
265
|
+
tags: seed.tags,
|
|
266
|
+
links: seed.links?.length ? seed.links : undefined,
|
|
267
|
+
relatedIds: seed.relatedIds,
|
|
268
|
+
rawRefs: seed.rawRefs,
|
|
269
|
+
externalRef: seed.externalRef,
|
|
270
|
+
...seed.fields,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function validateEventSeed(seed) {
|
|
274
|
+
assertContractShape(eventRecordSchema, buildEventContractInput(seed, EVENT_VALIDATION_PLACEHOLDER_ID), "EVENT_INVALID", "Event record failed contract validation before write.");
|
|
275
|
+
}
|
|
276
|
+
function buildStoredEventRecord(seed, recordId) {
|
|
277
|
+
const record = buildEventContractInput(seed, recordId);
|
|
278
|
+
assertContractShape(eventRecordSchema, record, "EVENT_INVALID", "Event record failed contract validation before write.");
|
|
279
|
+
return record;
|
|
280
|
+
}
|
|
281
|
+
function prepareStoredEventLedgerEntry(seed, recordId) {
|
|
282
|
+
const record = buildStoredEventRecord(seed, recordId);
|
|
283
|
+
return {
|
|
284
|
+
relativePath: toMonthlyShardRelativePath(VAULT_LAYOUT.eventLedgerDirectory, record.occurredAt, "occurredAt"),
|
|
285
|
+
record,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function prepareEventLedgerEntry({ recordId, ...input }) {
|
|
289
|
+
return prepareStoredEventLedgerEntry(buildNormalizedEventSeed(input), recordId ?? generateRecordId(ID_PREFIXES.event));
|
|
290
|
+
}
|
|
291
|
+
async function stageJsonlRecord(batch, relativePath, record) {
|
|
292
|
+
return batch.stageJsonlAppend(relativePath, `${JSON.stringify(record)}\n`);
|
|
293
|
+
}
|
|
294
|
+
function buildNormalizedSampleSeed({ stream, recordedAt, dayKey, timeZone, defaultTimeZone: fallbackTimeZone, source, quality, sample, unit, externalRef, }) {
|
|
295
|
+
const recordedTimestamp = toIsoTimestamp(sample.recordedAt ?? recordedAt, "recordedAt");
|
|
296
|
+
const normalizedUnit = normalizeNumericUnit(stream, unit);
|
|
297
|
+
const resolvedTimeZone = normalizeTimeZone(timeZone ?? fallbackTimeZone);
|
|
298
|
+
const resolvedDayKey = normalizeDayKeyInput(dayKey) ??
|
|
299
|
+
toLocalDayKey(recordedTimestamp, resolvedTimeZone ?? defaultTimeZone(), "recordedAt");
|
|
300
|
+
const baseSeed = {
|
|
301
|
+
stream,
|
|
302
|
+
recordedAt: recordedTimestamp,
|
|
303
|
+
dayKey: resolvedDayKey,
|
|
304
|
+
timeZone: resolvedTimeZone,
|
|
305
|
+
source: normalizeSource(source, SAMPLE_SOURCE_SET, "import"),
|
|
306
|
+
quality: normalizeSource(quality, SAMPLE_QUALITY_SET, "raw"),
|
|
307
|
+
externalRef: normalizeExternalRef(externalRef),
|
|
308
|
+
};
|
|
309
|
+
const seed = stream === "sleep_stage"
|
|
310
|
+
? {
|
|
311
|
+
...baseSeed,
|
|
312
|
+
unit: normalizedUnit,
|
|
313
|
+
measurement: {
|
|
314
|
+
kind: "sleep_stage",
|
|
315
|
+
stage: String(sample.stage ?? "").trim(),
|
|
316
|
+
startAt: toIsoTimestamp(sample.startAt, "startAt"),
|
|
317
|
+
endAt: toIsoTimestamp(sample.endAt, "endAt"),
|
|
318
|
+
durationMinutes: Number(sample.durationMinutes),
|
|
319
|
+
},
|
|
320
|
+
}
|
|
321
|
+
: (() => {
|
|
322
|
+
if (typeof sample.value !== "number" || !Number.isFinite(sample.value)) {
|
|
323
|
+
throw new VaultError("VAULT_INVALID_SAMPLE", "Sample value must be a finite number.", {
|
|
324
|
+
stream,
|
|
325
|
+
sampleSummary: JSON.stringify(sample),
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
...baseSeed,
|
|
330
|
+
unit: normalizedUnit,
|
|
331
|
+
measurement: {
|
|
332
|
+
kind: "numeric",
|
|
333
|
+
value: sample.value,
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
})();
|
|
337
|
+
assertContractShape(sampleRecordSchema, materializeSampleRecord({ seed, recordId: SAMPLE_VALIDATION_PLACEHOLDER_ID }), "SAMPLE_INVALID", "Sample record failed contract validation before write.");
|
|
338
|
+
return seed;
|
|
339
|
+
}
|
|
340
|
+
function materializeSampleRecord({ seed, recordId, }) {
|
|
341
|
+
const measurementFields = seed.measurement.kind === "sleep_stage"
|
|
342
|
+
? {
|
|
343
|
+
stage: seed.measurement.stage,
|
|
344
|
+
startAt: seed.measurement.startAt,
|
|
345
|
+
endAt: seed.measurement.endAt,
|
|
346
|
+
durationMinutes: seed.measurement.durationMinutes,
|
|
347
|
+
unit: seed.unit,
|
|
348
|
+
}
|
|
349
|
+
: {
|
|
350
|
+
value: seed.measurement.value,
|
|
351
|
+
unit: seed.unit,
|
|
352
|
+
};
|
|
353
|
+
return compactRecord({
|
|
354
|
+
schemaVersion: SAMPLE_SCHEMA_VERSION,
|
|
355
|
+
id: recordId,
|
|
356
|
+
dayKey: seed.dayKey,
|
|
357
|
+
timeZone: seed.timeZone,
|
|
358
|
+
stream: seed.stream,
|
|
359
|
+
recordedAt: seed.recordedAt,
|
|
360
|
+
source: seed.source,
|
|
361
|
+
quality: seed.quality,
|
|
362
|
+
externalRef: seed.externalRef,
|
|
363
|
+
...measurementFields,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function finalizeSampleRecord({ seed, recordId, }) {
|
|
367
|
+
const record = materializeSampleRecord({ seed, recordId });
|
|
368
|
+
assertContractShape(sampleRecordSchema, record, "SAMPLE_INVALID", "Sample record failed contract validation before write.");
|
|
369
|
+
return record;
|
|
370
|
+
}
|
|
371
|
+
function buildSampleRecord({ recordId, ...input }) {
|
|
372
|
+
return finalizeSampleRecord({
|
|
373
|
+
seed: buildNormalizedSampleSeed(input),
|
|
374
|
+
recordId: recordId ?? generateRecordId(ID_PREFIXES.sample),
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
async function readExistingRecordIds(vaultRoot, relativePath) {
|
|
378
|
+
const resolved = resolveVaultPath(vaultRoot, relativePath);
|
|
379
|
+
if (!(await pathExists(resolved.absolutePath))) {
|
|
380
|
+
return new Set();
|
|
381
|
+
}
|
|
382
|
+
const records = await readJsonlRecords({
|
|
383
|
+
vaultRoot,
|
|
384
|
+
relativePath,
|
|
385
|
+
});
|
|
386
|
+
return new Set(records
|
|
387
|
+
.map((record) => (typeof record.id === "string" ? record.id : null))
|
|
388
|
+
.filter((id) => id !== null));
|
|
389
|
+
}
|
|
390
|
+
async function buildJsonlAppendPlan(vaultRoot, entries, options = {}) {
|
|
391
|
+
const payloads = new Map();
|
|
392
|
+
const existingIdsByShard = new Map();
|
|
393
|
+
const targetShardPaths = [...new Set(entries.map((entry) => entry.relativePath))].sort();
|
|
394
|
+
for (const entry of entries) {
|
|
395
|
+
const existingIds = existingIdsByShard.get(entry.relativePath) ??
|
|
396
|
+
(await readExistingRecordIds(vaultRoot, entry.relativePath));
|
|
397
|
+
existingIdsByShard.set(entry.relativePath, existingIds);
|
|
398
|
+
if (existingIds.has(entry.record.id)) {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
if (options.dedupeWithinPlan) {
|
|
402
|
+
existingIds.add(entry.record.id);
|
|
403
|
+
}
|
|
404
|
+
const existingPayload = payloads.get(entry.relativePath) ?? "";
|
|
405
|
+
payloads.set(entry.relativePath, `${existingPayload}${JSON.stringify(entry.record)}\n`);
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
targetShardPaths,
|
|
409
|
+
appendedShardPaths: [...payloads.keys()].sort(),
|
|
410
|
+
payloads,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
async function stageJsonlAppendPlan(batch, appendPlan) {
|
|
414
|
+
for (const relativePath of appendPlan.appendedShardPaths) {
|
|
415
|
+
const payload = appendPlan.payloads.get(relativePath);
|
|
416
|
+
if (!payload) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
await batch.stageJsonlAppend(relativePath, payload);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function normalizeDeviceEventInputs(eventInputs, context) {
|
|
423
|
+
return eventInputs.map((eventInput, index) => {
|
|
424
|
+
const kind = String(eventInput.kind ?? "").trim();
|
|
425
|
+
if (!EVENT_KIND_SET.has(kind)) {
|
|
426
|
+
throw new VaultError("VAULT_UNSUPPORTED_EVENT_KIND", `Unsupported baseline event kind "${String(eventInput.kind ?? "")}".`, { index });
|
|
427
|
+
}
|
|
428
|
+
const fields = normalizeLooseRecord(eventInput.fields, "VAULT_INVALID_EVENT_FIELDS", `Device event ${index + 1} fields must be a plain object.`) ?? {};
|
|
429
|
+
const rawArtifactRoles = trimStringList(eventInput.rawArtifactRoles) ?? [];
|
|
430
|
+
const seed = buildNormalizedEventSeed({
|
|
431
|
+
kind,
|
|
432
|
+
occurredAt: eventInput.occurredAt ?? eventInput.recordedAt ?? context.importedAt,
|
|
433
|
+
recordedAt: eventInput.recordedAt ?? eventInput.occurredAt,
|
|
434
|
+
dayKey: typeof eventInput.dayKey === "string" ? eventInput.dayKey : undefined,
|
|
435
|
+
timeZone: typeof eventInput.timeZone === "string" ? eventInput.timeZone : undefined,
|
|
436
|
+
defaultTimeZone: context.defaultTimeZone,
|
|
437
|
+
source: eventInput.source ?? context.source,
|
|
438
|
+
title: typeof eventInput.title === "string" ? eventInput.title : undefined,
|
|
439
|
+
note: eventInput.note,
|
|
440
|
+
tags: eventInput.tags,
|
|
441
|
+
relatedIds: eventInput.relatedIds,
|
|
442
|
+
externalRef: eventInput.externalRef,
|
|
443
|
+
fields,
|
|
444
|
+
});
|
|
445
|
+
const { rawRefs: _rawRefs, ...seedRecord } = buildEventContractInput(seed);
|
|
446
|
+
return {
|
|
447
|
+
seed,
|
|
448
|
+
rawArtifactRoles,
|
|
449
|
+
recordId: deterministicContractId(ID_PREFIXES.event, stableStringify({
|
|
450
|
+
provider: context.provider,
|
|
451
|
+
accountId: context.accountId ?? null,
|
|
452
|
+
rawArtifactRoles,
|
|
453
|
+
record: seedRecord,
|
|
454
|
+
})),
|
|
455
|
+
};
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function normalizeDeviceSampleInputs(sampleInputs, context) {
|
|
459
|
+
return sampleInputs.map((sampleInput, index) => {
|
|
460
|
+
const stream = String(sampleInput.stream ?? "").trim();
|
|
461
|
+
if (!SAMPLE_STREAM_SET.has(stream)) {
|
|
462
|
+
throw new VaultError("VAULT_UNSUPPORTED_SAMPLE_STREAM", `Unsupported baseline sample stream "${String(sampleInput.stream ?? "")}".`, { index });
|
|
463
|
+
}
|
|
464
|
+
const sample = normalizeSampleInputRecord(sampleInput.sample, "VAULT_INVALID_SAMPLE", `Device sample ${index + 1} must include a sample object.`);
|
|
465
|
+
const seed = buildNormalizedSampleSeed({
|
|
466
|
+
stream,
|
|
467
|
+
recordedAt: sampleInput.recordedAt ?? sample.recordedAt ?? sample.occurredAt,
|
|
468
|
+
dayKey: typeof sampleInput.dayKey === "string" ? sampleInput.dayKey : undefined,
|
|
469
|
+
timeZone: typeof sampleInput.timeZone === "string" ? sampleInput.timeZone : undefined,
|
|
470
|
+
defaultTimeZone: context.defaultTimeZone,
|
|
471
|
+
source: sampleInput.source ?? context.source,
|
|
472
|
+
quality: sampleInput.quality ?? "normalized",
|
|
473
|
+
sample,
|
|
474
|
+
unit: String(sampleInput.unit ?? ""),
|
|
475
|
+
externalRef: sampleInput.externalRef,
|
|
476
|
+
});
|
|
477
|
+
const record = materializeSampleRecord({ seed });
|
|
478
|
+
return {
|
|
479
|
+
seed,
|
|
480
|
+
recordId: deterministicContractId(ID_PREFIXES.sample, stableStringify({
|
|
481
|
+
provider: context.provider,
|
|
482
|
+
accountId: context.accountId ?? null,
|
|
483
|
+
record,
|
|
484
|
+
})),
|
|
485
|
+
};
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
function normalizeDeviceRawArtifactInputs(rawArtifactInputs, provider) {
|
|
489
|
+
const seenRawRoles = new Set();
|
|
490
|
+
return rawArtifactInputs.map((artifactInput, index) => {
|
|
491
|
+
const role = normalizeRequiredRole(artifactInput.role ?? `artifact-${index + 1}`, `raw artifact ${index + 1} role`);
|
|
492
|
+
if (seenRawRoles.has(role)) {
|
|
493
|
+
throw new VaultError("VAULT_DUPLICATE_RAW_ROLE", `Device raw artifact role "${role}" may only appear once per batch.`);
|
|
494
|
+
}
|
|
495
|
+
seenRawRoles.add(role);
|
|
496
|
+
const content = normalizeInlineRawContent(artifactInput.content);
|
|
497
|
+
return {
|
|
498
|
+
role,
|
|
499
|
+
fileName: typeof artifactInput.fileName === "string" && artifactInput.fileName.trim()
|
|
500
|
+
? artifactInput.fileName.trim()
|
|
501
|
+
: `${provider}-${String(index + 1).padStart(2, "0")}.json`,
|
|
502
|
+
mediaType: typeof artifactInput.mediaType === "string" && artifactInput.mediaType.trim()
|
|
503
|
+
? artifactInput.mediaType.trim()
|
|
504
|
+
: undefined,
|
|
505
|
+
content,
|
|
506
|
+
metadata: normalizeLooseRecord(artifactInput.metadata, "VAULT_INVALID_RAW_ARTIFACT", `Device raw artifact ${index + 1} metadata must be a plain object.`),
|
|
507
|
+
sha256: createHash("sha256").update(content).digest("hex"),
|
|
508
|
+
index,
|
|
509
|
+
};
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
function normalizeDeviceBatchInputs({ provider, accountId, importedAt = new Date(), defaultTimeZone: fallbackTimeZone, source = "device", events = [], samples = [], rawArtifacts = [], provenance, }) {
|
|
513
|
+
const normalizedProvider = sanitizePathSegment(provider, "provider");
|
|
514
|
+
const normalizedAccountId = typeof accountId === "string" && accountId.trim() ? accountId.trim() : undefined;
|
|
515
|
+
const normalizedImportedAt = toIsoTimestamp(importedAt, "importedAt");
|
|
516
|
+
const defaultTimeZone = normalizeTimeZone(fallbackTimeZone);
|
|
517
|
+
const normalizedProvenance = normalizeLooseRecord(provenance, "VAULT_INVALID_DEVICE_PROVENANCE", "Device import provenance must be a plain object.") ?? {};
|
|
518
|
+
const eventInputs = Array.isArray(events)
|
|
519
|
+
? events.map((event, index) => assertPlainObject(event, "VAULT_INVALID_EVENT", `Device event ${index + 1} must be a plain object.`))
|
|
520
|
+
: [];
|
|
521
|
+
const sampleInputs = Array.isArray(samples)
|
|
522
|
+
? samples.map((sample, index) => assertPlainObject(sample, "VAULT_INVALID_SAMPLE", `Device sample ${index + 1} must be a plain object.`))
|
|
523
|
+
: [];
|
|
524
|
+
const rawArtifactInputs = Array.isArray(rawArtifacts)
|
|
525
|
+
? rawArtifacts.map((artifact, index) => assertPlainObject(artifact, "VAULT_INVALID_RAW_ARTIFACT", `Device raw artifact ${index + 1} must be a plain object.`))
|
|
526
|
+
: [];
|
|
527
|
+
if (eventInputs.length === 0 && sampleInputs.length === 0 && rawArtifactInputs.length === 0) {
|
|
528
|
+
throw new VaultError("VAULT_INVALID_DEVICE_BATCH", "importDeviceBatch requires at least one event, sample, or raw artifact.");
|
|
529
|
+
}
|
|
530
|
+
return {
|
|
531
|
+
provider: normalizedProvider,
|
|
532
|
+
accountId: normalizedAccountId,
|
|
533
|
+
importedAt: normalizedImportedAt,
|
|
534
|
+
source,
|
|
535
|
+
defaultTimeZone,
|
|
536
|
+
provenance: normalizedProvenance,
|
|
537
|
+
events: normalizeDeviceEventInputs(eventInputs, {
|
|
538
|
+
provider: normalizedProvider,
|
|
539
|
+
accountId: normalizedAccountId,
|
|
540
|
+
importedAt: normalizedImportedAt,
|
|
541
|
+
source,
|
|
542
|
+
defaultTimeZone,
|
|
543
|
+
}),
|
|
544
|
+
samples: normalizeDeviceSampleInputs(sampleInputs, {
|
|
545
|
+
provider: normalizedProvider,
|
|
546
|
+
accountId: normalizedAccountId,
|
|
547
|
+
source,
|
|
548
|
+
defaultTimeZone,
|
|
549
|
+
}),
|
|
550
|
+
rawArtifacts: normalizeDeviceRawArtifactInputs(rawArtifactInputs, normalizedProvider),
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function prepareDeviceRawArtifacts(rawArtifacts, options) {
|
|
554
|
+
return rawArtifacts.map((artifact) => ({
|
|
555
|
+
role: artifact.role,
|
|
556
|
+
content: artifact.content,
|
|
557
|
+
raw: prepareInlineRawArtifact({
|
|
558
|
+
fileName: artifact.fileName,
|
|
559
|
+
targetName: `${String(artifact.index + 1).padStart(2, "0")}-${artifact.fileName}`,
|
|
560
|
+
mediaType: artifact.mediaType,
|
|
561
|
+
category: "integrations",
|
|
562
|
+
provider: options.provider,
|
|
563
|
+
occurredAt: options.effectiveOccurredAt,
|
|
564
|
+
recordId: options.importId,
|
|
565
|
+
}),
|
|
566
|
+
metadata: artifact.metadata,
|
|
567
|
+
sha256: artifact.sha256,
|
|
568
|
+
}));
|
|
569
|
+
}
|
|
570
|
+
function prepareDeviceEventEntries(events, preparedRawArtifacts) {
|
|
571
|
+
const rawArtifactPathByRole = new Map(preparedRawArtifacts.map((artifact) => [artifact.role, artifact.raw.relativePath]));
|
|
572
|
+
const soleRawArtifactPath = preparedRawArtifacts.length === 1 ? preparedRawArtifacts[0]?.raw.relativePath : undefined;
|
|
573
|
+
return events.map((event) => {
|
|
574
|
+
const rawRefs = event.rawArtifactRoles.length > 0
|
|
575
|
+
? event.rawArtifactRoles.map((role) => {
|
|
576
|
+
const rawPath = rawArtifactPathByRole.get(role);
|
|
577
|
+
if (!rawPath) {
|
|
578
|
+
throw new VaultError("VAULT_RAW_ROLE_MISSING", `No staged raw artifact matched role "${role}" for device event ${event.recordId}.`);
|
|
579
|
+
}
|
|
580
|
+
return rawPath;
|
|
581
|
+
})
|
|
582
|
+
: soleRawArtifactPath
|
|
583
|
+
? [soleRawArtifactPath]
|
|
584
|
+
: undefined;
|
|
585
|
+
return prepareStoredEventLedgerEntry({
|
|
586
|
+
...event.seed,
|
|
587
|
+
rawRefs,
|
|
588
|
+
}, event.recordId);
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
function prepareDeviceSampleEntries(samples) {
|
|
592
|
+
return samples.map((sample) => {
|
|
593
|
+
const record = finalizeSampleRecord({
|
|
594
|
+
seed: sample.seed,
|
|
595
|
+
recordId: sample.recordId,
|
|
596
|
+
});
|
|
597
|
+
return {
|
|
598
|
+
record,
|
|
599
|
+
relativePath: toMonthlyShardRelativePath(`${VAULT_LAYOUT.sampleLedgerDirectory}/${sample.seed.stream}`, record.recordedAt, "recordedAt"),
|
|
600
|
+
};
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
function prepareDeviceBatchPlan({ provider, accountId, importedAt = new Date(), defaultTimeZone: fallbackTimeZone, source = "device", events = [], samples = [], rawArtifacts = [], provenance, }) {
|
|
604
|
+
const normalizedInputs = normalizeDeviceBatchInputs({
|
|
605
|
+
provider,
|
|
606
|
+
accountId,
|
|
607
|
+
importedAt,
|
|
608
|
+
defaultTimeZone: fallbackTimeZone,
|
|
609
|
+
source,
|
|
610
|
+
events,
|
|
611
|
+
samples,
|
|
612
|
+
rawArtifacts,
|
|
613
|
+
provenance,
|
|
614
|
+
});
|
|
615
|
+
const effectiveOccurredAt = earliestTimestamp([
|
|
616
|
+
...normalizedInputs.events.map(({ seed }) => seed.occurredAt),
|
|
617
|
+
...normalizedInputs.samples.map(({ seed }) => seed.recordedAt),
|
|
618
|
+
], normalizedInputs.importedAt);
|
|
619
|
+
const importId = deterministicContractId(ID_PREFIXES.transform, stableStringify({
|
|
620
|
+
provider: normalizedInputs.provider,
|
|
621
|
+
accountId: normalizedInputs.accountId ?? null,
|
|
622
|
+
eventIds: normalizedInputs.events.map(({ recordId }) => recordId),
|
|
623
|
+
sampleIds: normalizedInputs.samples.map(({ recordId }) => recordId),
|
|
624
|
+
rawArtifacts: normalizedInputs.rawArtifacts.map((artifact) => ({
|
|
625
|
+
role: artifact.role,
|
|
626
|
+
fileName: artifact.fileName,
|
|
627
|
+
mediaType: artifact.mediaType ?? null,
|
|
628
|
+
sha256: artifact.sha256,
|
|
629
|
+
})),
|
|
630
|
+
}));
|
|
631
|
+
const preparedRawArtifacts = prepareDeviceRawArtifacts(normalizedInputs.rawArtifacts, {
|
|
632
|
+
importId,
|
|
633
|
+
provider: normalizedInputs.provider,
|
|
634
|
+
effectiveOccurredAt,
|
|
635
|
+
});
|
|
636
|
+
const preparedEvents = prepareDeviceEventEntries(normalizedInputs.events, preparedRawArtifacts);
|
|
637
|
+
const preparedSamples = prepareDeviceSampleEntries(normalizedInputs.samples);
|
|
638
|
+
return {
|
|
639
|
+
importId,
|
|
640
|
+
provider: normalizedInputs.provider,
|
|
641
|
+
accountId: normalizedInputs.accountId,
|
|
642
|
+
importedAt: normalizedInputs.importedAt,
|
|
643
|
+
source: normalizedInputs.source,
|
|
644
|
+
provenance: normalizedInputs.provenance,
|
|
645
|
+
effectiveOccurredAt,
|
|
646
|
+
preparedEvents,
|
|
647
|
+
preparedSamples,
|
|
648
|
+
preparedRawArtifacts,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
export async function importDocument({ vaultRoot, sourcePath, occurredAt = new Date(), title, note, source = "import", }) {
|
|
652
|
+
const vault = await loadVault({ vaultRoot });
|
|
653
|
+
const documentId = generateRecordId(ID_PREFIXES.document);
|
|
654
|
+
const eventId = generateRecordId(ID_PREFIXES.event);
|
|
655
|
+
const preparedAttachments = prepareEventAttachments({
|
|
656
|
+
ownerKind: "document",
|
|
657
|
+
ownerId: documentId,
|
|
658
|
+
occurredAt,
|
|
659
|
+
attachments: [
|
|
660
|
+
{
|
|
661
|
+
role: "source_document",
|
|
662
|
+
kind: "document",
|
|
663
|
+
sourcePath,
|
|
664
|
+
},
|
|
665
|
+
],
|
|
666
|
+
});
|
|
667
|
+
const raw = preparedAttachments[0].raw;
|
|
668
|
+
const pendingAttachmentState = buildPreparedAttachmentState(preparedAttachments);
|
|
669
|
+
const eventSeed = buildNormalizedEventSeed({
|
|
670
|
+
kind: "document",
|
|
671
|
+
occurredAt,
|
|
672
|
+
recordedAt: new Date(),
|
|
673
|
+
timeZone: vault.metadata.timezone,
|
|
674
|
+
source,
|
|
675
|
+
title: String(title ?? raw.originalFileName).trim(),
|
|
676
|
+
note,
|
|
677
|
+
relatedIds: [documentId],
|
|
678
|
+
rawRefs: pendingAttachmentState.projections.rawRefs,
|
|
679
|
+
fields: {
|
|
680
|
+
documentId,
|
|
681
|
+
documentPath: pendingAttachmentState.projections.documentPath,
|
|
682
|
+
mimeType: raw.mediaType,
|
|
683
|
+
},
|
|
684
|
+
});
|
|
685
|
+
return runCanonicalWrite({
|
|
686
|
+
vaultRoot,
|
|
687
|
+
operationType: "document_import",
|
|
688
|
+
summary: `Import document ${documentId}`,
|
|
689
|
+
occurredAt,
|
|
690
|
+
mutate: async ({ batch }) => {
|
|
691
|
+
const stagedAttachments = await stagePreparedEventAttachmentsInBatch({
|
|
692
|
+
batch,
|
|
693
|
+
importId: documentId,
|
|
694
|
+
importKind: "document",
|
|
695
|
+
importedAt: eventSeed.recordedAt,
|
|
696
|
+
source: eventSeed.source ?? source ?? null,
|
|
697
|
+
attachments: preparedAttachments,
|
|
698
|
+
provenance: {
|
|
699
|
+
eventId,
|
|
700
|
+
lookupId: documentId,
|
|
701
|
+
occurredAt: eventSeed.occurredAt,
|
|
702
|
+
title: eventSeed.title ?? null,
|
|
703
|
+
note: eventSeed.note ?? null,
|
|
704
|
+
},
|
|
705
|
+
});
|
|
706
|
+
if (!stagedAttachments) {
|
|
707
|
+
throw new VaultError("EVENT_ATTACHMENTS_MISSING", "Document import expected one staged attachment.");
|
|
708
|
+
}
|
|
709
|
+
const projections = buildAttachmentCompatibilityProjections(stagedAttachments.attachments);
|
|
710
|
+
const event = prepareStoredEventLedgerEntry({
|
|
711
|
+
...eventSeed,
|
|
712
|
+
rawRefs: stagedAttachments.rawRefs,
|
|
713
|
+
fields: {
|
|
714
|
+
...eventSeed.fields,
|
|
715
|
+
attachments: stagedAttachments.attachments,
|
|
716
|
+
documentPath: projections.documentPath ?? raw.relativePath,
|
|
717
|
+
},
|
|
718
|
+
}, eventId);
|
|
719
|
+
const manifestPath = stagedAttachments.manifestPath;
|
|
720
|
+
await stageJsonlRecord(batch, event.relativePath, event.record);
|
|
721
|
+
const audit = await emitAuditRecord({
|
|
722
|
+
vaultRoot,
|
|
723
|
+
batch,
|
|
724
|
+
action: "document_import",
|
|
725
|
+
commandName: "core.importDocument",
|
|
726
|
+
summary: `Imported document ${raw.originalFileName}.`,
|
|
727
|
+
occurredAt,
|
|
728
|
+
files: [raw.relativePath, manifestPath, event.relativePath],
|
|
729
|
+
targetIds: [documentId, event.record.id],
|
|
730
|
+
});
|
|
731
|
+
return {
|
|
732
|
+
documentId,
|
|
733
|
+
raw,
|
|
734
|
+
event: event.record,
|
|
735
|
+
eventPath: event.relativePath,
|
|
736
|
+
auditPath: audit.relativePath,
|
|
737
|
+
manifestPath,
|
|
738
|
+
};
|
|
739
|
+
},
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
export async function addMeal({ vaultRoot, occurredAt = new Date(), note, photoPath, audioPath, source = "manual", }) {
|
|
743
|
+
const vault = await loadVault({ vaultRoot });
|
|
744
|
+
if (!photoPath && !audioPath && !note) {
|
|
745
|
+
throw new VaultError("VAULT_MEAL_CONTENT_REQUIRED", "Meal imports require at least one of photoPath, audioPath, or note.");
|
|
746
|
+
}
|
|
747
|
+
const mealId = generateRecordId(ID_PREFIXES.meal);
|
|
748
|
+
const eventId = generateRecordId(ID_PREFIXES.event);
|
|
749
|
+
const preparedAttachments = prepareEventAttachments({
|
|
750
|
+
ownerKind: "meal",
|
|
751
|
+
ownerId: mealId,
|
|
752
|
+
occurredAt,
|
|
753
|
+
attachments: [
|
|
754
|
+
...(photoPath
|
|
755
|
+
? [
|
|
756
|
+
{
|
|
757
|
+
role: "photo",
|
|
758
|
+
kind: "photo",
|
|
759
|
+
sourcePath: photoPath,
|
|
760
|
+
},
|
|
761
|
+
]
|
|
762
|
+
: []),
|
|
763
|
+
...(audioPath
|
|
764
|
+
? [
|
|
765
|
+
{
|
|
766
|
+
role: "audio",
|
|
767
|
+
kind: "audio",
|
|
768
|
+
sourcePath: audioPath,
|
|
769
|
+
},
|
|
770
|
+
]
|
|
771
|
+
: []),
|
|
772
|
+
],
|
|
773
|
+
});
|
|
774
|
+
const photo = preparedAttachments.find((attachment) => attachment.role === "photo")?.raw ?? null;
|
|
775
|
+
const audio = preparedAttachments.find((attachment) => attachment.role === "audio")?.raw ?? null;
|
|
776
|
+
const rawDirectory = resolveRawMealDirectory(occurredAt, mealId);
|
|
777
|
+
const pendingAttachmentState = buildPreparedAttachmentState(preparedAttachments);
|
|
778
|
+
const eventSeed = buildNormalizedEventSeed({
|
|
779
|
+
kind: "meal",
|
|
780
|
+
occurredAt,
|
|
781
|
+
recordedAt: new Date(),
|
|
782
|
+
timeZone: vault.metadata.timezone,
|
|
783
|
+
source,
|
|
784
|
+
title: "Meal",
|
|
785
|
+
note,
|
|
786
|
+
relatedIds: [mealId],
|
|
787
|
+
rawRefs: pendingAttachmentState.projections.rawRefs,
|
|
788
|
+
fields: {
|
|
789
|
+
mealId,
|
|
790
|
+
photoPaths: pendingAttachmentState.projections.photoPaths,
|
|
791
|
+
audioPaths: pendingAttachmentState.projections.audioPaths,
|
|
792
|
+
},
|
|
793
|
+
});
|
|
794
|
+
return runCanonicalWrite({
|
|
795
|
+
vaultRoot,
|
|
796
|
+
operationType: "meal_import",
|
|
797
|
+
summary: `Import meal ${mealId}`,
|
|
798
|
+
occurredAt,
|
|
799
|
+
mutate: async ({ batch }) => {
|
|
800
|
+
const stagedAttachments = await stagePreparedEventAttachmentsInBatch({
|
|
801
|
+
batch,
|
|
802
|
+
importId: mealId,
|
|
803
|
+
importKind: "meal",
|
|
804
|
+
importedAt: eventSeed.recordedAt,
|
|
805
|
+
rawDirectory,
|
|
806
|
+
source: eventSeed.source ?? source ?? null,
|
|
807
|
+
attachments: preparedAttachments,
|
|
808
|
+
provenance: {
|
|
809
|
+
eventId,
|
|
810
|
+
lookupId: mealId,
|
|
811
|
+
occurredAt: eventSeed.occurredAt,
|
|
812
|
+
note: eventSeed.note ?? null,
|
|
813
|
+
},
|
|
814
|
+
});
|
|
815
|
+
let rawRefs = eventSeed.rawRefs;
|
|
816
|
+
let attachments;
|
|
817
|
+
let photoPaths = eventSeed.fields.photoPaths;
|
|
818
|
+
let audioPaths = eventSeed.fields.audioPaths;
|
|
819
|
+
if (stagedAttachments) {
|
|
820
|
+
const projections = buildAttachmentCompatibilityProjections(stagedAttachments.attachments);
|
|
821
|
+
rawRefs = projections.rawRefs;
|
|
822
|
+
attachments = stagedAttachments.attachments;
|
|
823
|
+
photoPaths = projections.photoPaths;
|
|
824
|
+
audioPaths = projections.audioPaths;
|
|
825
|
+
}
|
|
826
|
+
const manifestPath = stagedAttachments
|
|
827
|
+
? stagedAttachments.manifestPath
|
|
828
|
+
: await stageRawImportManifest({
|
|
829
|
+
batch,
|
|
830
|
+
importId: mealId,
|
|
831
|
+
importKind: "meal",
|
|
832
|
+
importedAt: eventSeed.recordedAt,
|
|
833
|
+
rawDirectory,
|
|
834
|
+
source: eventSeed.source ?? source ?? null,
|
|
835
|
+
artifacts: [],
|
|
836
|
+
canonicalProvenance: {
|
|
837
|
+
eventId,
|
|
838
|
+
lookupId: mealId,
|
|
839
|
+
occurredAt: eventSeed.occurredAt,
|
|
840
|
+
note: eventSeed.note ?? null,
|
|
841
|
+
},
|
|
842
|
+
});
|
|
843
|
+
if (!stagedAttachments) {
|
|
844
|
+
rawRefs = [manifestPath];
|
|
845
|
+
}
|
|
846
|
+
const event = prepareStoredEventLedgerEntry({
|
|
847
|
+
...eventSeed,
|
|
848
|
+
rawRefs,
|
|
849
|
+
fields: {
|
|
850
|
+
...eventSeed.fields,
|
|
851
|
+
attachments,
|
|
852
|
+
photoPaths,
|
|
853
|
+
audioPaths,
|
|
854
|
+
},
|
|
855
|
+
}, eventId);
|
|
856
|
+
await stageJsonlRecord(batch, event.relativePath, event.record);
|
|
857
|
+
const touchedFiles = [photo?.relativePath, audio?.relativePath, manifestPath, event.relativePath].filter((value) => typeof value === "string");
|
|
858
|
+
const audit = await emitAuditRecord({
|
|
859
|
+
vaultRoot,
|
|
860
|
+
batch,
|
|
861
|
+
action: "meal_add",
|
|
862
|
+
commandName: "core.addMeal",
|
|
863
|
+
summary: `Added meal ${mealId}.`,
|
|
864
|
+
occurredAt,
|
|
865
|
+
files: touchedFiles,
|
|
866
|
+
targetIds: [mealId, event.record.id],
|
|
867
|
+
});
|
|
868
|
+
return {
|
|
869
|
+
mealId,
|
|
870
|
+
event: event.record,
|
|
871
|
+
eventPath: event.relativePath,
|
|
872
|
+
photo,
|
|
873
|
+
audio,
|
|
874
|
+
auditPath: audit.relativePath,
|
|
875
|
+
manifestPath,
|
|
876
|
+
};
|
|
877
|
+
},
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
function resolveRawMealDirectory(occurredAt, mealId) {
|
|
881
|
+
const timestamp = toIsoTimestamp(occurredAt, "occurredAt");
|
|
882
|
+
return `${VAULT_LAYOUT.rawMealsDirectory}/${timestamp.slice(0, 4)}/${timestamp.slice(5, 7)}/${mealId}`;
|
|
883
|
+
}
|
|
884
|
+
export async function importSamples({ vaultRoot, stream, unit, samples, sourcePath, source = "import", quality = "raw", batchProvenance, }) {
|
|
885
|
+
const vault = await loadVault({ vaultRoot });
|
|
886
|
+
if (!SAMPLE_STREAM_SET.has(stream)) {
|
|
887
|
+
throw new VaultError("VAULT_UNSUPPORTED_SAMPLE_STREAM", `Unsupported baseline sample stream "${stream}".`, {
|
|
888
|
+
stream,
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
if (!Array.isArray(samples) || samples.length === 0) {
|
|
892
|
+
throw new VaultError("VAULT_INVALID_SAMPLES", "importSamples requires a non-empty samples array.");
|
|
893
|
+
}
|
|
894
|
+
const normalizedStream = stream;
|
|
895
|
+
const normalizedSamples = samples.map((sample) => normalizeSampleInputRecord(sample, "VAULT_INVALID_SAMPLE", "Each sample must be a plain object."));
|
|
896
|
+
const transformFingerprint = normalizedSamples.map((sample) => buildSampleRecord({
|
|
897
|
+
stream: normalizedStream,
|
|
898
|
+
recordedAt: sample.recordedAt ?? sample.occurredAt,
|
|
899
|
+
timeZone: vault.metadata.timezone,
|
|
900
|
+
source,
|
|
901
|
+
quality,
|
|
902
|
+
sample,
|
|
903
|
+
unit,
|
|
904
|
+
recordId: `${ID_PREFIXES.sample}_00000000000000000000000000`,
|
|
905
|
+
}));
|
|
906
|
+
const transformId = deterministicContractId(ID_PREFIXES.transform, JSON.stringify({
|
|
907
|
+
stream: normalizedStream,
|
|
908
|
+
unit,
|
|
909
|
+
source,
|
|
910
|
+
quality,
|
|
911
|
+
sourcePath: sourcePath ?? null,
|
|
912
|
+
rows: transformFingerprint.map(({ id, ...record }) => record),
|
|
913
|
+
}));
|
|
914
|
+
const preparedRecords = [];
|
|
915
|
+
for (const [index, normalizedSample] of normalizedSamples.entries()) {
|
|
916
|
+
const record = buildSampleRecord({
|
|
917
|
+
stream: normalizedStream,
|
|
918
|
+
recordedAt: normalizedSample.recordedAt ?? normalizedSample.occurredAt,
|
|
919
|
+
timeZone: vault.metadata.timezone,
|
|
920
|
+
source,
|
|
921
|
+
quality,
|
|
922
|
+
sample: normalizedSample,
|
|
923
|
+
unit,
|
|
924
|
+
recordId: deterministicContractId(ID_PREFIXES.sample, `${transformId}:${index}`),
|
|
925
|
+
});
|
|
926
|
+
const relativePath = toMonthlyShardRelativePath(`${VAULT_LAYOUT.sampleLedgerDirectory}/${normalizedStream}`, record.recordedAt, "recordedAt");
|
|
927
|
+
preparedRecords.push({ record, relativePath });
|
|
928
|
+
}
|
|
929
|
+
const raw = sourcePath
|
|
930
|
+
? prepareRawArtifact({
|
|
931
|
+
sourcePath,
|
|
932
|
+
category: "samples",
|
|
933
|
+
occurredAt: preparedRecords[0]?.record.recordedAt ?? new Date(),
|
|
934
|
+
recordId: transformId,
|
|
935
|
+
stream: normalizedStream,
|
|
936
|
+
allowExistingMatch: true,
|
|
937
|
+
})
|
|
938
|
+
: null;
|
|
939
|
+
const touchedFiles = raw ? [raw.relativePath] : [];
|
|
940
|
+
const records = preparedRecords.map((entry) => entry.record);
|
|
941
|
+
const appendPlan = await buildJsonlAppendPlan(vaultRoot, preparedRecords);
|
|
942
|
+
const rowProvenance = batchProvenance?.rows ?? [];
|
|
943
|
+
return runCanonicalWrite({
|
|
944
|
+
vaultRoot,
|
|
945
|
+
operationType: "sample_batch_import",
|
|
946
|
+
summary: `Import ${normalizedStream} sample batch ${transformId}`,
|
|
947
|
+
occurredAt: preparedRecords[0]?.record.recordedAt ?? new Date(),
|
|
948
|
+
mutate: async ({ batch }) => {
|
|
949
|
+
const stagedRaw = raw && sourcePath
|
|
950
|
+
? await batch.stageRawCopy({
|
|
951
|
+
sourcePath,
|
|
952
|
+
targetRelativePath: raw.relativePath,
|
|
953
|
+
originalFileName: raw.originalFileName,
|
|
954
|
+
mediaType: raw.mediaType,
|
|
955
|
+
allowExistingMatch: true,
|
|
956
|
+
})
|
|
957
|
+
: null;
|
|
958
|
+
const manifestPath = stagedRaw
|
|
959
|
+
? await stageRawImportManifest({
|
|
960
|
+
batch,
|
|
961
|
+
importId: transformId,
|
|
962
|
+
importKind: "sample_batch",
|
|
963
|
+
importedAt: records[0]?.recordedAt ?? new Date().toISOString(),
|
|
964
|
+
source: source ?? null,
|
|
965
|
+
artifacts: [
|
|
966
|
+
{
|
|
967
|
+
role: "source_csv",
|
|
968
|
+
raw: stagedRaw,
|
|
969
|
+
},
|
|
970
|
+
],
|
|
971
|
+
canonicalProvenance: {
|
|
972
|
+
stream: normalizedStream,
|
|
973
|
+
unit,
|
|
974
|
+
importedCount: records.length,
|
|
975
|
+
sampleIds: records.map((record) => record.id),
|
|
976
|
+
ledgerFiles: appendPlan.targetShardPaths,
|
|
977
|
+
sourceFileName: batchProvenance?.sourceFileName ?? raw?.originalFileName ?? null,
|
|
978
|
+
importConfig: batchProvenance?.importConfig ?? null,
|
|
979
|
+
rowCount: rowProvenance.length,
|
|
980
|
+
rows: rowProvenance,
|
|
981
|
+
},
|
|
982
|
+
})
|
|
983
|
+
: "";
|
|
984
|
+
await stageJsonlAppendPlan(batch, appendPlan);
|
|
985
|
+
const touchedPaths = [...touchedFiles];
|
|
986
|
+
touchedPaths.push(...(manifestPath ? [manifestPath] : []), ...appendPlan.appendedShardPaths);
|
|
987
|
+
const audit = await emitAuditRecord({
|
|
988
|
+
vaultRoot,
|
|
989
|
+
batch,
|
|
990
|
+
action: "samples_import_csv",
|
|
991
|
+
commandName: "core.importSamples",
|
|
992
|
+
summary: `Imported ${records.length} ${normalizedStream} sample record(s).`,
|
|
993
|
+
occurredAt: records[0]?.recordedAt ?? new Date(),
|
|
994
|
+
files: touchedPaths,
|
|
995
|
+
targetIds: records.map((record) => record.id),
|
|
996
|
+
});
|
|
997
|
+
return {
|
|
998
|
+
count: records.length,
|
|
999
|
+
records,
|
|
1000
|
+
shardPaths: appendPlan.targetShardPaths,
|
|
1001
|
+
raw,
|
|
1002
|
+
transformId,
|
|
1003
|
+
auditPath: audit.relativePath,
|
|
1004
|
+
manifestPath,
|
|
1005
|
+
};
|
|
1006
|
+
},
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
export async function importDeviceBatch({ vaultRoot, provider, accountId, importedAt = new Date(), source = "device", events = [], samples = [], rawArtifacts = [], provenance, }) {
|
|
1010
|
+
const vault = await loadVault({ vaultRoot });
|
|
1011
|
+
const deviceBatchPlan = prepareDeviceBatchPlan({
|
|
1012
|
+
provider,
|
|
1013
|
+
accountId,
|
|
1014
|
+
importedAt,
|
|
1015
|
+
defaultTimeZone: vault.metadata.timezone,
|
|
1016
|
+
source,
|
|
1017
|
+
events,
|
|
1018
|
+
samples,
|
|
1019
|
+
rawArtifacts,
|
|
1020
|
+
provenance,
|
|
1021
|
+
});
|
|
1022
|
+
const eventAppendPlan = await buildJsonlAppendPlan(vaultRoot, deviceBatchPlan.preparedEvents, {
|
|
1023
|
+
dedupeWithinPlan: true,
|
|
1024
|
+
});
|
|
1025
|
+
const sampleAppendPlan = await buildJsonlAppendPlan(vaultRoot, deviceBatchPlan.preparedSamples, {
|
|
1026
|
+
dedupeWithinPlan: true,
|
|
1027
|
+
});
|
|
1028
|
+
const eventRecords = deviceBatchPlan.preparedEvents.map((entry) => entry.record);
|
|
1029
|
+
const sampleRecords = deviceBatchPlan.preparedSamples.map((entry) => entry.record);
|
|
1030
|
+
return runCanonicalWrite({
|
|
1031
|
+
vaultRoot,
|
|
1032
|
+
operationType: "device_batch_import",
|
|
1033
|
+
summary: `Import ${deviceBatchPlan.provider} device batch ${deviceBatchPlan.importId}`,
|
|
1034
|
+
occurredAt: deviceBatchPlan.effectiveOccurredAt,
|
|
1035
|
+
mutate: async ({ batch }) => {
|
|
1036
|
+
const stagedRawArtifacts = [];
|
|
1037
|
+
for (const artifact of deviceBatchPlan.preparedRawArtifacts) {
|
|
1038
|
+
stagedRawArtifacts.push({
|
|
1039
|
+
role: artifact.role,
|
|
1040
|
+
raw: await batch.stageRawText({
|
|
1041
|
+
targetRelativePath: artifact.raw.relativePath,
|
|
1042
|
+
originalFileName: artifact.raw.originalFileName,
|
|
1043
|
+
mediaType: artifact.raw.mediaType,
|
|
1044
|
+
content: artifact.content,
|
|
1045
|
+
allowExistingMatch: true,
|
|
1046
|
+
}),
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
const manifestPath = stagedRawArtifacts.length > 0
|
|
1050
|
+
? await stageRawImportManifest({
|
|
1051
|
+
batch,
|
|
1052
|
+
importId: deviceBatchPlan.importId,
|
|
1053
|
+
importKind: "device_batch",
|
|
1054
|
+
importedAt: deviceBatchPlan.importedAt,
|
|
1055
|
+
source: deviceBatchPlan.source ?? null,
|
|
1056
|
+
artifacts: stagedRawArtifacts,
|
|
1057
|
+
canonicalProvenance: {
|
|
1058
|
+
provider: deviceBatchPlan.provider,
|
|
1059
|
+
accountId: deviceBatchPlan.accountId ?? null,
|
|
1060
|
+
importedAt: deviceBatchPlan.importedAt,
|
|
1061
|
+
eventCount: eventRecords.length,
|
|
1062
|
+
sampleCount: sampleRecords.length,
|
|
1063
|
+
eventIds: eventRecords.map((record) => record.id),
|
|
1064
|
+
sampleIds: sampleRecords.map((record) => record.id),
|
|
1065
|
+
rawArtifacts: deviceBatchPlan.preparedRawArtifacts.map((artifact) => ({
|
|
1066
|
+
role: artifact.role,
|
|
1067
|
+
relativePath: artifact.raw.relativePath,
|
|
1068
|
+
sha256: artifact.sha256,
|
|
1069
|
+
metadata: artifact.metadata ?? null,
|
|
1070
|
+
})),
|
|
1071
|
+
},
|
|
1072
|
+
operatorMetadata: deviceBatchPlan.provenance,
|
|
1073
|
+
})
|
|
1074
|
+
: "";
|
|
1075
|
+
await stageJsonlAppendPlan(batch, eventAppendPlan);
|
|
1076
|
+
await stageJsonlAppendPlan(batch, sampleAppendPlan);
|
|
1077
|
+
const touchedPaths = [
|
|
1078
|
+
...deviceBatchPlan.preparedRawArtifacts.map((artifact) => artifact.raw.relativePath),
|
|
1079
|
+
...(manifestPath ? [manifestPath] : []),
|
|
1080
|
+
...eventAppendPlan.appendedShardPaths,
|
|
1081
|
+
...sampleAppendPlan.appendedShardPaths,
|
|
1082
|
+
];
|
|
1083
|
+
const audit = await emitAuditRecord({
|
|
1084
|
+
vaultRoot,
|
|
1085
|
+
batch,
|
|
1086
|
+
action: "device_import",
|
|
1087
|
+
commandName: "core.importDeviceBatch",
|
|
1088
|
+
summary: `Imported ${deviceBatchPlan.provider} device batch with ${eventRecords.length} event(s) and ${sampleRecords.length} sample(s).`,
|
|
1089
|
+
occurredAt: deviceBatchPlan.importedAt,
|
|
1090
|
+
files: touchedPaths,
|
|
1091
|
+
targetIds: [...eventRecords.map((record) => record.id), ...sampleRecords.map((record) => record.id)],
|
|
1092
|
+
});
|
|
1093
|
+
return {
|
|
1094
|
+
importId: deviceBatchPlan.importId,
|
|
1095
|
+
provider: deviceBatchPlan.provider,
|
|
1096
|
+
accountId: deviceBatchPlan.accountId,
|
|
1097
|
+
importedAt: deviceBatchPlan.importedAt,
|
|
1098
|
+
events: eventRecords,
|
|
1099
|
+
samples: sampleRecords,
|
|
1100
|
+
eventShardPaths: eventAppendPlan.targetShardPaths,
|
|
1101
|
+
sampleShardPaths: sampleAppendPlan.targetShardPaths,
|
|
1102
|
+
rawArtifacts: deviceBatchPlan.preparedRawArtifacts.map((artifact) => artifact.raw),
|
|
1103
|
+
auditPath: audit.relativePath,
|
|
1104
|
+
manifestPath,
|
|
1105
|
+
};
|
|
1106
|
+
},
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
//# sourceMappingURL=mutations.js.map
|