@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,965 @@
|
|
|
1
|
+
import { applySqliteRuntimeMigrations, openSqliteRuntimeDatabase, tableExists, withImmediateTransaction, } from "@murphai/runtime-state/node";
|
|
2
|
+
import { generatePrefixedId, maybeParseJsonObject, sanitizeStoredDeviceSyncMetadata, stringifyJson, toIsoTimestamp, } from "./shared.js";
|
|
3
|
+
const DEVICE_SYNC_STORE_SQLITE_SCHEMA_VERSION = 2;
|
|
4
|
+
const MINIMIZED_WEBHOOK_TRACE_PAYLOAD_JSON = stringifyJson({});
|
|
5
|
+
function mapAccountRow(row) {
|
|
6
|
+
if (!row) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
id: row.id,
|
|
11
|
+
provider: row.provider,
|
|
12
|
+
externalAccountId: row.external_account_id,
|
|
13
|
+
displayName: row.display_name,
|
|
14
|
+
status: row.status,
|
|
15
|
+
scopes: JSON.parse(row.scopes_json ?? "[]"),
|
|
16
|
+
disconnectGeneration: row.disconnect_generation,
|
|
17
|
+
accessTokenEncrypted: row.access_token_encrypted,
|
|
18
|
+
hostedObservedTokenVersion: row.hosted_observed_token_version,
|
|
19
|
+
hostedObservedUpdatedAt: row.hosted_observed_updated_at,
|
|
20
|
+
refreshTokenEncrypted: row.refresh_token_encrypted,
|
|
21
|
+
accessTokenExpiresAt: row.access_token_expires_at,
|
|
22
|
+
metadata: sanitizeStoredDeviceSyncMetadata(maybeParseJsonObject(row.metadata_json)),
|
|
23
|
+
connectedAt: row.connected_at,
|
|
24
|
+
lastWebhookAt: row.last_webhook_at,
|
|
25
|
+
lastSyncStartedAt: row.last_sync_started_at,
|
|
26
|
+
lastSyncCompletedAt: row.last_sync_completed_at,
|
|
27
|
+
lastSyncErrorAt: row.last_sync_error_at,
|
|
28
|
+
lastErrorCode: row.last_error_code,
|
|
29
|
+
lastErrorMessage: row.last_error_message,
|
|
30
|
+
nextReconcileAt: row.next_reconcile_at,
|
|
31
|
+
createdAt: row.created_at,
|
|
32
|
+
updatedAt: row.updated_at ?? row.created_at,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function mapJobRow(row) {
|
|
36
|
+
if (!row) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
id: row.id,
|
|
41
|
+
provider: row.provider,
|
|
42
|
+
accountId: row.account_id,
|
|
43
|
+
kind: row.kind,
|
|
44
|
+
payload: maybeParseJsonObject(row.payload_json),
|
|
45
|
+
priority: row.priority,
|
|
46
|
+
availableAt: row.available_at,
|
|
47
|
+
attempts: row.attempts,
|
|
48
|
+
maxAttempts: row.max_attempts,
|
|
49
|
+
dedupeKey: row.dedupe_key,
|
|
50
|
+
status: row.status,
|
|
51
|
+
leaseOwner: row.lease_owner,
|
|
52
|
+
leaseExpiresAt: row.lease_expires_at,
|
|
53
|
+
lastErrorCode: row.last_error_code,
|
|
54
|
+
lastErrorMessage: row.last_error_message,
|
|
55
|
+
createdAt: row.created_at,
|
|
56
|
+
updatedAt: row.updated_at,
|
|
57
|
+
startedAt: row.started_at,
|
|
58
|
+
finishedAt: row.finished_at,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function mapOAuthStateRow(row) {
|
|
62
|
+
if (!row) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
state: row.state,
|
|
67
|
+
provider: row.provider,
|
|
68
|
+
returnTo: row.return_to,
|
|
69
|
+
metadata: maybeParseJsonObject(row.metadata_json),
|
|
70
|
+
createdAt: row.created_at,
|
|
71
|
+
expiresAt: row.expires_at,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function resolveHydratedHostedAccountTokens(input) {
|
|
75
|
+
if (input.inputTokens) {
|
|
76
|
+
return {
|
|
77
|
+
accessTokenEncrypted: input.inputTokens.accessTokenEncrypted,
|
|
78
|
+
refreshTokenEncrypted: input.inputTokens.refreshTokenEncrypted ?? null,
|
|
79
|
+
accessTokenExpiresAt: input.inputTokens.accessTokenExpiresAt ?? null,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (input.shouldClearTokens) {
|
|
83
|
+
return {
|
|
84
|
+
accessTokenEncrypted: "",
|
|
85
|
+
refreshTokenEncrypted: null,
|
|
86
|
+
accessTokenExpiresAt: null,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
accessTokenEncrypted: input.existing?.accessTokenEncrypted ?? "",
|
|
91
|
+
refreshTokenEncrypted: input.existing?.refreshTokenEncrypted ?? null,
|
|
92
|
+
accessTokenExpiresAt: input.existing?.accessTokenExpiresAt ?? null,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function assertNoLegacyDeviceSyncStore(database) {
|
|
96
|
+
if (!tableExists(database, "device_account")) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
throw new Error("Unsupported legacy device-sync runtime schema detected. Remove the local device-sync database and reconnect devices.");
|
|
100
|
+
}
|
|
101
|
+
function ensureDeviceSyncStoreSchema(database) {
|
|
102
|
+
database.exec(`
|
|
103
|
+
create table if not exists oauth_state (
|
|
104
|
+
state text primary key,
|
|
105
|
+
provider text not null,
|
|
106
|
+
return_to text,
|
|
107
|
+
metadata_json text not null,
|
|
108
|
+
created_at text not null,
|
|
109
|
+
expires_at text not null
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
create index if not exists oauth_state_expires_idx
|
|
113
|
+
on oauth_state (expires_at);
|
|
114
|
+
|
|
115
|
+
create table if not exists device_connection (
|
|
116
|
+
id text primary key,
|
|
117
|
+
provider text not null,
|
|
118
|
+
external_account_id text not null,
|
|
119
|
+
display_name text,
|
|
120
|
+
status text not null,
|
|
121
|
+
scopes_json text not null,
|
|
122
|
+
disconnect_generation integer not null default 0,
|
|
123
|
+
metadata_json text not null,
|
|
124
|
+
connected_at text not null,
|
|
125
|
+
created_at text not null,
|
|
126
|
+
updated_at text not null,
|
|
127
|
+
unique (provider, external_account_id)
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
create index if not exists device_connection_provider_idx
|
|
131
|
+
on device_connection (provider, updated_at desc);
|
|
132
|
+
|
|
133
|
+
create table if not exists device_credential_state (
|
|
134
|
+
account_id text primary key references device_connection(id) on delete cascade,
|
|
135
|
+
access_token_encrypted text not null,
|
|
136
|
+
refresh_token_encrypted text,
|
|
137
|
+
access_token_expires_at text,
|
|
138
|
+
created_at text not null,
|
|
139
|
+
updated_at text not null
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
create table if not exists device_observation_state (
|
|
143
|
+
account_id text primary key references device_connection(id) on delete cascade,
|
|
144
|
+
hosted_observed_updated_at text,
|
|
145
|
+
hosted_observed_token_version integer,
|
|
146
|
+
last_webhook_at text,
|
|
147
|
+
last_sync_started_at text,
|
|
148
|
+
last_sync_completed_at text,
|
|
149
|
+
last_sync_error_at text,
|
|
150
|
+
last_error_code text,
|
|
151
|
+
last_error_message text,
|
|
152
|
+
next_reconcile_at text,
|
|
153
|
+
created_at text not null,
|
|
154
|
+
updated_at text not null
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
create table if not exists device_job (
|
|
158
|
+
id text primary key,
|
|
159
|
+
provider text not null,
|
|
160
|
+
account_id text not null references device_connection(id) on delete cascade,
|
|
161
|
+
kind text not null,
|
|
162
|
+
payload_json text not null,
|
|
163
|
+
priority integer not null default 0,
|
|
164
|
+
available_at text not null,
|
|
165
|
+
attempts integer not null default 0,
|
|
166
|
+
max_attempts integer not null default 5,
|
|
167
|
+
dedupe_key text,
|
|
168
|
+
status text not null,
|
|
169
|
+
lease_owner text,
|
|
170
|
+
lease_expires_at text,
|
|
171
|
+
last_error_code text,
|
|
172
|
+
last_error_message text,
|
|
173
|
+
created_at text not null,
|
|
174
|
+
updated_at text not null,
|
|
175
|
+
started_at text,
|
|
176
|
+
finished_at text
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
create index if not exists device_job_claim_idx
|
|
180
|
+
on device_job (status, available_at asc, priority desc, created_at asc);
|
|
181
|
+
|
|
182
|
+
create index if not exists device_job_account_idx
|
|
183
|
+
on device_job (account_id, status, created_at desc);
|
|
184
|
+
|
|
185
|
+
create index if not exists device_job_account_running_idx
|
|
186
|
+
on device_job (account_id, status, lease_expires_at);
|
|
187
|
+
|
|
188
|
+
create table if not exists webhook_trace (
|
|
189
|
+
provider text not null,
|
|
190
|
+
trace_id text not null,
|
|
191
|
+
external_account_id text not null,
|
|
192
|
+
event_type text not null,
|
|
193
|
+
received_at text not null,
|
|
194
|
+
payload_json text not null,
|
|
195
|
+
status text not null default 'processed',
|
|
196
|
+
processing_expires_at text,
|
|
197
|
+
primary key (provider, trace_id)
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
create index if not exists webhook_trace_received_idx
|
|
201
|
+
on webhook_trace (received_at desc);
|
|
202
|
+
`);
|
|
203
|
+
}
|
|
204
|
+
function latestIsoTimestamp(left, right) {
|
|
205
|
+
if (!left) {
|
|
206
|
+
return right;
|
|
207
|
+
}
|
|
208
|
+
if (!right) {
|
|
209
|
+
return left;
|
|
210
|
+
}
|
|
211
|
+
return Date.parse(left) >= Date.parse(right) ? left : right;
|
|
212
|
+
}
|
|
213
|
+
const ACCOUNT_ROW_SELECT = `
|
|
214
|
+
select
|
|
215
|
+
connection.id as id,
|
|
216
|
+
connection.provider as provider,
|
|
217
|
+
connection.external_account_id as external_account_id,
|
|
218
|
+
connection.display_name as display_name,
|
|
219
|
+
connection.status as status,
|
|
220
|
+
connection.scopes_json as scopes_json,
|
|
221
|
+
connection.disconnect_generation as disconnect_generation,
|
|
222
|
+
credential.access_token_encrypted as access_token_encrypted,
|
|
223
|
+
credential.refresh_token_encrypted as refresh_token_encrypted,
|
|
224
|
+
credential.access_token_expires_at as access_token_expires_at,
|
|
225
|
+
observation.hosted_observed_updated_at as hosted_observed_updated_at,
|
|
226
|
+
observation.hosted_observed_token_version as hosted_observed_token_version,
|
|
227
|
+
connection.metadata_json as metadata_json,
|
|
228
|
+
connection.connected_at as connected_at,
|
|
229
|
+
observation.last_webhook_at as last_webhook_at,
|
|
230
|
+
observation.last_sync_started_at as last_sync_started_at,
|
|
231
|
+
observation.last_sync_completed_at as last_sync_completed_at,
|
|
232
|
+
observation.last_sync_error_at as last_sync_error_at,
|
|
233
|
+
observation.last_error_code as last_error_code,
|
|
234
|
+
observation.last_error_message as last_error_message,
|
|
235
|
+
observation.next_reconcile_at as next_reconcile_at,
|
|
236
|
+
connection.created_at as created_at,
|
|
237
|
+
max(connection.updated_at, credential.updated_at, observation.updated_at) as updated_at
|
|
238
|
+
from device_connection as connection
|
|
239
|
+
join device_credential_state as credential
|
|
240
|
+
on credential.account_id = connection.id
|
|
241
|
+
join device_observation_state as observation
|
|
242
|
+
on observation.account_id = connection.id
|
|
243
|
+
`;
|
|
244
|
+
export class SqliteDeviceSyncStore {
|
|
245
|
+
databasePath;
|
|
246
|
+
database;
|
|
247
|
+
constructor(databasePath) {
|
|
248
|
+
this.databasePath = databasePath;
|
|
249
|
+
const database = openSqliteRuntimeDatabase(databasePath);
|
|
250
|
+
this.database = database;
|
|
251
|
+
try {
|
|
252
|
+
assertNoLegacyDeviceSyncStore(database);
|
|
253
|
+
applySqliteRuntimeMigrations(database, {
|
|
254
|
+
migrations: [
|
|
255
|
+
{
|
|
256
|
+
version: DEVICE_SYNC_STORE_SQLITE_SCHEMA_VERSION,
|
|
257
|
+
migrate(candidateDatabase) {
|
|
258
|
+
ensureDeviceSyncStoreSchema(candidateDatabase);
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
schemaVersion: DEVICE_SYNC_STORE_SQLITE_SCHEMA_VERSION,
|
|
263
|
+
storeName: "device sync runtime",
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
database.close();
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
close() {
|
|
272
|
+
this.database.close();
|
|
273
|
+
}
|
|
274
|
+
summarize() {
|
|
275
|
+
const row = this.database.prepare(`
|
|
276
|
+
select
|
|
277
|
+
(select count(*) from device_connection) as accounts_total,
|
|
278
|
+
(select count(*) from device_connection where status = 'active') as accounts_active,
|
|
279
|
+
(select count(*) from device_job where status = 'queued') as jobs_queued,
|
|
280
|
+
(select count(*) from device_job where status = 'running') as jobs_running,
|
|
281
|
+
(select count(*) from device_job where status = 'dead') as jobs_dead,
|
|
282
|
+
(select count(*) from oauth_state) as oauth_states,
|
|
283
|
+
(select count(*) from webhook_trace) as webhook_traces
|
|
284
|
+
`).get();
|
|
285
|
+
return {
|
|
286
|
+
accountsTotal: row.accounts_total,
|
|
287
|
+
accountsActive: row.accounts_active,
|
|
288
|
+
jobsQueued: row.jobs_queued,
|
|
289
|
+
jobsRunning: row.jobs_running,
|
|
290
|
+
jobsDead: row.jobs_dead,
|
|
291
|
+
oauthStates: row.oauth_states,
|
|
292
|
+
webhookTraces: row.webhook_traces,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
createOAuthState(input) {
|
|
296
|
+
this.database.prepare(`
|
|
297
|
+
insert into oauth_state (state, provider, return_to, metadata_json, created_at, expires_at)
|
|
298
|
+
values (?, ?, ?, ?, ?, ?)
|
|
299
|
+
`).run(input.state, input.provider, input.returnTo, stringifyJson(input.metadata ?? {}), input.createdAt, input.expiresAt);
|
|
300
|
+
return input;
|
|
301
|
+
}
|
|
302
|
+
deleteExpiredOAuthStates(now) {
|
|
303
|
+
const result = this.database.prepare("delete from oauth_state where expires_at <= ?").run(now);
|
|
304
|
+
return result.changes ?? 0;
|
|
305
|
+
}
|
|
306
|
+
consumeOAuthState(state, now) {
|
|
307
|
+
return withImmediateTransaction(this.database, () => {
|
|
308
|
+
const row = this.database.prepare(`
|
|
309
|
+
select state, provider, return_to, metadata_json, created_at, expires_at
|
|
310
|
+
from oauth_state
|
|
311
|
+
where state = ?
|
|
312
|
+
`).get(state);
|
|
313
|
+
if (!row || Date.parse(row.expires_at) <= Date.parse(now)) {
|
|
314
|
+
this.database.prepare("delete from oauth_state where state = ?").run(state);
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
this.database.prepare("delete from oauth_state where state = ?").run(state);
|
|
318
|
+
return mapOAuthStateRow(row);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
listAccounts(provider) {
|
|
322
|
+
const rows = (provider
|
|
323
|
+
? this.database.prepare(`
|
|
324
|
+
${ACCOUNT_ROW_SELECT}
|
|
325
|
+
where connection.provider = ?
|
|
326
|
+
order by updated_at desc, connection.id desc
|
|
327
|
+
`).all(provider)
|
|
328
|
+
: this.database.prepare(`
|
|
329
|
+
${ACCOUNT_ROW_SELECT}
|
|
330
|
+
order by updated_at desc, connection.id desc
|
|
331
|
+
`).all());
|
|
332
|
+
return rows.map((row) => mapAccountRow(row)).filter(Boolean);
|
|
333
|
+
}
|
|
334
|
+
getAccountById(accountId) {
|
|
335
|
+
const row = this.database.prepare(`
|
|
336
|
+
${ACCOUNT_ROW_SELECT}
|
|
337
|
+
where connection.id = ?
|
|
338
|
+
`).get(accountId);
|
|
339
|
+
return mapAccountRow(row);
|
|
340
|
+
}
|
|
341
|
+
getAccountByExternalAccount(provider, externalAccountId) {
|
|
342
|
+
const row = this.database.prepare(`
|
|
343
|
+
${ACCOUNT_ROW_SELECT}
|
|
344
|
+
where connection.provider = ? and connection.external_account_id = ?
|
|
345
|
+
`).get(provider, externalAccountId);
|
|
346
|
+
return mapAccountRow(row);
|
|
347
|
+
}
|
|
348
|
+
upsertAccount(input) {
|
|
349
|
+
return withImmediateTransaction(this.database, () => {
|
|
350
|
+
const existing = this.getAccountByExternalAccount(input.provider, input.externalAccountId);
|
|
351
|
+
const now = input.connectedAt;
|
|
352
|
+
const status = input.status ?? "active";
|
|
353
|
+
const scopesJson = stringifyJson(input.scopes ?? []);
|
|
354
|
+
const metadataJson = stringifyJson(sanitizeStoredDeviceSyncMetadata(input.metadata ?? {}));
|
|
355
|
+
if (existing) {
|
|
356
|
+
this.database.prepare(`
|
|
357
|
+
update device_connection
|
|
358
|
+
set display_name = ?,
|
|
359
|
+
status = ?,
|
|
360
|
+
scopes_json = ?,
|
|
361
|
+
metadata_json = ?,
|
|
362
|
+
connected_at = ?,
|
|
363
|
+
updated_at = ?
|
|
364
|
+
where id = ?
|
|
365
|
+
`).run(input.displayName ?? null, status, scopesJson, metadataJson, input.connectedAt, now, existing.id);
|
|
366
|
+
this.database.prepare(`
|
|
367
|
+
update device_credential_state
|
|
368
|
+
set access_token_encrypted = ?,
|
|
369
|
+
refresh_token_encrypted = ?,
|
|
370
|
+
access_token_expires_at = ?,
|
|
371
|
+
updated_at = ?
|
|
372
|
+
where account_id = ?
|
|
373
|
+
`).run(input.tokens.accessTokenEncrypted, input.tokens.refreshTokenEncrypted ?? null, input.tokens.accessTokenExpiresAt ?? null, now, existing.id);
|
|
374
|
+
this.database.prepare(`
|
|
375
|
+
update device_observation_state
|
|
376
|
+
set next_reconcile_at = ?,
|
|
377
|
+
last_sync_error_at = null,
|
|
378
|
+
last_error_code = null,
|
|
379
|
+
last_error_message = null,
|
|
380
|
+
updated_at = ?
|
|
381
|
+
where account_id = ?
|
|
382
|
+
`).run(input.nextReconcileAt ?? null, now, existing.id);
|
|
383
|
+
return this.getAccountById(existing.id);
|
|
384
|
+
}
|
|
385
|
+
const id = generatePrefixedId("dsa");
|
|
386
|
+
this.database.prepare(`
|
|
387
|
+
insert into device_connection (
|
|
388
|
+
id,
|
|
389
|
+
provider,
|
|
390
|
+
external_account_id,
|
|
391
|
+
display_name,
|
|
392
|
+
status,
|
|
393
|
+
scopes_json,
|
|
394
|
+
metadata_json,
|
|
395
|
+
connected_at,
|
|
396
|
+
created_at,
|
|
397
|
+
updated_at
|
|
398
|
+
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
399
|
+
`).run(id, input.provider, input.externalAccountId, input.displayName ?? null, status, scopesJson, metadataJson, input.connectedAt, now, now);
|
|
400
|
+
this.database.prepare(`
|
|
401
|
+
insert into device_credential_state (
|
|
402
|
+
account_id,
|
|
403
|
+
access_token_encrypted,
|
|
404
|
+
refresh_token_encrypted,
|
|
405
|
+
access_token_expires_at,
|
|
406
|
+
created_at,
|
|
407
|
+
updated_at
|
|
408
|
+
) values (?, ?, ?, ?, ?, ?)
|
|
409
|
+
`).run(id, input.tokens.accessTokenEncrypted, input.tokens.refreshTokenEncrypted ?? null, input.tokens.accessTokenExpiresAt ?? null, now, now);
|
|
410
|
+
this.database.prepare(`
|
|
411
|
+
insert into device_observation_state (
|
|
412
|
+
account_id,
|
|
413
|
+
hosted_observed_updated_at,
|
|
414
|
+
hosted_observed_token_version,
|
|
415
|
+
last_webhook_at,
|
|
416
|
+
last_sync_started_at,
|
|
417
|
+
last_sync_completed_at,
|
|
418
|
+
last_sync_error_at,
|
|
419
|
+
last_error_code,
|
|
420
|
+
last_error_message,
|
|
421
|
+
next_reconcile_at,
|
|
422
|
+
created_at,
|
|
423
|
+
updated_at
|
|
424
|
+
) values (?, null, null, null, null, null, null, null, null, ?, ?, ?)
|
|
425
|
+
`).run(id, input.nextReconcileAt ?? null, now, now);
|
|
426
|
+
return this.getAccountById(id);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
patchAccount(accountId, patch) {
|
|
430
|
+
return withImmediateTransaction(this.database, () => {
|
|
431
|
+
const existing = this.getAccountById(accountId);
|
|
432
|
+
if (!existing) {
|
|
433
|
+
throw new TypeError(`Unknown account ${accountId}`);
|
|
434
|
+
}
|
|
435
|
+
const now = toIsoTimestamp(new Date());
|
|
436
|
+
const metadata = sanitizeStoredDeviceSyncMetadata(patch.metadata ? { ...existing.metadata, ...patch.metadata } : existing.metadata);
|
|
437
|
+
const nextReconcileAt = Object.prototype.hasOwnProperty.call(patch, "nextReconcileAt")
|
|
438
|
+
? patch.nextReconcileAt ?? null
|
|
439
|
+
: existing.nextReconcileAt;
|
|
440
|
+
const displayName = Object.prototype.hasOwnProperty.call(patch, "displayName")
|
|
441
|
+
? patch.displayName ?? null
|
|
442
|
+
: existing.displayName;
|
|
443
|
+
const scopes = Object.prototype.hasOwnProperty.call(patch, "scopes")
|
|
444
|
+
? patch.scopes ?? []
|
|
445
|
+
: existing.scopes;
|
|
446
|
+
this.database.prepare(`
|
|
447
|
+
update device_connection
|
|
448
|
+
set display_name = ?,
|
|
449
|
+
status = ?,
|
|
450
|
+
scopes_json = ?,
|
|
451
|
+
metadata_json = ?,
|
|
452
|
+
updated_at = ?
|
|
453
|
+
where id = ?
|
|
454
|
+
`).run(displayName, patch.status ?? existing.status, stringifyJson(scopes), stringifyJson(metadata), now, existing.id);
|
|
455
|
+
this.database.prepare(`
|
|
456
|
+
update device_observation_state
|
|
457
|
+
set next_reconcile_at = ?,
|
|
458
|
+
last_sync_error_at = ?,
|
|
459
|
+
last_error_code = ?,
|
|
460
|
+
last_error_message = ?,
|
|
461
|
+
updated_at = ?
|
|
462
|
+
where account_id = ?
|
|
463
|
+
`).run(nextReconcileAt, patch.clearErrors ? null : existing.lastSyncErrorAt, patch.clearErrors ? null : existing.lastErrorCode, patch.clearErrors ? null : existing.lastErrorMessage, now, existing.id);
|
|
464
|
+
return this.getAccountById(existing.id);
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
updateAccountTokens(accountId, tokens, disconnectGeneration) {
|
|
468
|
+
const now = toIsoTimestamp(new Date());
|
|
469
|
+
const result = this.database.prepare(`
|
|
470
|
+
update device_credential_state
|
|
471
|
+
set access_token_encrypted = ?,
|
|
472
|
+
refresh_token_encrypted = ?,
|
|
473
|
+
access_token_expires_at = ?,
|
|
474
|
+
updated_at = ?
|
|
475
|
+
where account_id = ?
|
|
476
|
+
and (? is null or exists (
|
|
477
|
+
select 1
|
|
478
|
+
from device_connection
|
|
479
|
+
where device_connection.id = device_credential_state.account_id
|
|
480
|
+
and device_connection.disconnect_generation = ?
|
|
481
|
+
and device_connection.status = 'active'
|
|
482
|
+
))
|
|
483
|
+
`).run(tokens.accessTokenEncrypted, tokens.refreshTokenEncrypted ?? null, tokens.accessTokenExpiresAt ?? null, now, accountId, disconnectGeneration ?? null, disconnectGeneration ?? null);
|
|
484
|
+
if ((result.changes ?? 0) === 0) {
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
return this.getAccountById(accountId);
|
|
488
|
+
}
|
|
489
|
+
hydrateHostedAccount(input) {
|
|
490
|
+
return withImmediateTransaction(this.database, () => {
|
|
491
|
+
const existing = this.getAccountByExternalAccount(input.connection.provider, input.connection.externalAccountId);
|
|
492
|
+
if (!existing && input.tokens === undefined) {
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
const shouldClearTokens = input.clearTokens === true
|
|
496
|
+
|| (input.connection.status === "disconnected" && input.tokens === undefined);
|
|
497
|
+
const rowUpdatedAt = latestIsoTimestamp(existing?.updatedAt ?? null, input.connection.updatedAt)
|
|
498
|
+
?? input.connection.updatedAt;
|
|
499
|
+
const { accessTokenEncrypted, refreshTokenEncrypted, accessTokenExpiresAt } = resolveHydratedHostedAccountTokens({
|
|
500
|
+
existing,
|
|
501
|
+
inputTokens: input.tokens,
|
|
502
|
+
shouldClearTokens,
|
|
503
|
+
});
|
|
504
|
+
const hostedObservedUpdatedAt = input.hostedObservedUpdatedAt ?? existing?.hostedObservedUpdatedAt ?? null;
|
|
505
|
+
const hostedObservedTokenVersion = input.hostedObservedTokenVersion ?? existing?.hostedObservedTokenVersion ?? null;
|
|
506
|
+
const metadata = sanitizeStoredDeviceSyncMetadata(input.connection.metadata);
|
|
507
|
+
const disconnectGeneration = existing
|
|
508
|
+
? input.connection.status === "disconnected" && existing.status !== "disconnected"
|
|
509
|
+
? existing.disconnectGeneration + 1
|
|
510
|
+
: existing.disconnectGeneration
|
|
511
|
+
: input.connection.status === "disconnected"
|
|
512
|
+
? 1
|
|
513
|
+
: 0;
|
|
514
|
+
if (existing) {
|
|
515
|
+
this.database.prepare(`
|
|
516
|
+
update device_connection
|
|
517
|
+
set display_name = ?,
|
|
518
|
+
status = ?,
|
|
519
|
+
scopes_json = ?,
|
|
520
|
+
disconnect_generation = ?,
|
|
521
|
+
metadata_json = ?,
|
|
522
|
+
connected_at = ?,
|
|
523
|
+
updated_at = ?
|
|
524
|
+
where id = ?
|
|
525
|
+
`).run(input.connection.displayName, input.connection.status, stringifyJson(input.connection.scopes), disconnectGeneration, stringifyJson(metadata), input.connection.connectedAt, rowUpdatedAt, existing.id);
|
|
526
|
+
this.database.prepare(`
|
|
527
|
+
update device_credential_state
|
|
528
|
+
set access_token_encrypted = ?,
|
|
529
|
+
refresh_token_encrypted = ?,
|
|
530
|
+
access_token_expires_at = ?,
|
|
531
|
+
updated_at = ?
|
|
532
|
+
where account_id = ?
|
|
533
|
+
`).run(accessTokenEncrypted, refreshTokenEncrypted, accessTokenExpiresAt, rowUpdatedAt, existing.id);
|
|
534
|
+
this.database.prepare(`
|
|
535
|
+
update device_observation_state
|
|
536
|
+
set hosted_observed_updated_at = ?,
|
|
537
|
+
hosted_observed_token_version = ?,
|
|
538
|
+
last_webhook_at = ?,
|
|
539
|
+
last_sync_started_at = ?,
|
|
540
|
+
last_sync_completed_at = ?,
|
|
541
|
+
last_sync_error_at = ?,
|
|
542
|
+
last_error_code = ?,
|
|
543
|
+
last_error_message = ?,
|
|
544
|
+
next_reconcile_at = ?,
|
|
545
|
+
updated_at = ?
|
|
546
|
+
where account_id = ?
|
|
547
|
+
`).run(hostedObservedUpdatedAt, hostedObservedTokenVersion, input.localState.lastWebhookAt, input.localState.lastSyncStartedAt, input.localState.lastSyncCompletedAt, input.localState.lastSyncErrorAt, input.localState.lastErrorCode, input.localState.lastErrorMessage, input.localState.nextReconcileAt, rowUpdatedAt, existing.id);
|
|
548
|
+
return this.getAccountById(existing.id);
|
|
549
|
+
}
|
|
550
|
+
const id = generatePrefixedId("dsa");
|
|
551
|
+
this.database.prepare(`
|
|
552
|
+
insert into device_connection (
|
|
553
|
+
id,
|
|
554
|
+
provider,
|
|
555
|
+
external_account_id,
|
|
556
|
+
display_name,
|
|
557
|
+
status,
|
|
558
|
+
scopes_json,
|
|
559
|
+
disconnect_generation,
|
|
560
|
+
metadata_json,
|
|
561
|
+
connected_at,
|
|
562
|
+
created_at,
|
|
563
|
+
updated_at
|
|
564
|
+
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
565
|
+
`).run(id, input.connection.provider, input.connection.externalAccountId, input.connection.displayName, input.connection.status, stringifyJson(input.connection.scopes), disconnectGeneration, stringifyJson(metadata), input.connection.connectedAt, input.connection.updatedAt, rowUpdatedAt);
|
|
566
|
+
this.database.prepare(`
|
|
567
|
+
insert into device_credential_state (
|
|
568
|
+
account_id,
|
|
569
|
+
access_token_encrypted,
|
|
570
|
+
refresh_token_encrypted,
|
|
571
|
+
access_token_expires_at,
|
|
572
|
+
created_at,
|
|
573
|
+
updated_at
|
|
574
|
+
) values (?, ?, ?, ?, ?, ?)
|
|
575
|
+
`).run(id, accessTokenEncrypted, refreshTokenEncrypted, accessTokenExpiresAt, input.connection.updatedAt, rowUpdatedAt);
|
|
576
|
+
this.database.prepare(`
|
|
577
|
+
insert into device_observation_state (
|
|
578
|
+
account_id,
|
|
579
|
+
hosted_observed_updated_at,
|
|
580
|
+
hosted_observed_token_version,
|
|
581
|
+
last_webhook_at,
|
|
582
|
+
last_sync_started_at,
|
|
583
|
+
last_sync_completed_at,
|
|
584
|
+
last_sync_error_at,
|
|
585
|
+
last_error_code,
|
|
586
|
+
last_error_message,
|
|
587
|
+
next_reconcile_at,
|
|
588
|
+
created_at,
|
|
589
|
+
updated_at
|
|
590
|
+
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
591
|
+
`).run(id, hostedObservedUpdatedAt, hostedObservedTokenVersion, input.localState.lastWebhookAt, input.localState.lastSyncStartedAt, input.localState.lastSyncCompletedAt, input.localState.lastSyncErrorAt, input.localState.lastErrorCode, input.localState.lastErrorMessage, input.localState.nextReconcileAt, input.connection.updatedAt, rowUpdatedAt);
|
|
592
|
+
return this.getAccountById(id);
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
disconnectAccount(accountId, now) {
|
|
596
|
+
withImmediateTransaction(this.database, () => {
|
|
597
|
+
this.database.prepare(`
|
|
598
|
+
update device_connection
|
|
599
|
+
set status = 'disconnected',
|
|
600
|
+
disconnect_generation = disconnect_generation + 1,
|
|
601
|
+
updated_at = ?
|
|
602
|
+
where id = ?
|
|
603
|
+
`).run(now, accountId);
|
|
604
|
+
this.database.prepare(`
|
|
605
|
+
update device_credential_state
|
|
606
|
+
set access_token_encrypted = '',
|
|
607
|
+
refresh_token_encrypted = null,
|
|
608
|
+
access_token_expires_at = null,
|
|
609
|
+
updated_at = ?
|
|
610
|
+
where account_id = ?
|
|
611
|
+
`).run(now, accountId);
|
|
612
|
+
this.database.prepare(`
|
|
613
|
+
update device_observation_state
|
|
614
|
+
set last_sync_error_at = null,
|
|
615
|
+
last_error_code = null,
|
|
616
|
+
last_error_message = null,
|
|
617
|
+
next_reconcile_at = null,
|
|
618
|
+
updated_at = ?
|
|
619
|
+
where account_id = ?
|
|
620
|
+
`).run(now, accountId);
|
|
621
|
+
});
|
|
622
|
+
return this.getAccountById(accountId);
|
|
623
|
+
}
|
|
624
|
+
markWebhookReceived(accountId, now) {
|
|
625
|
+
this.database.prepare(`
|
|
626
|
+
update device_observation_state
|
|
627
|
+
set last_webhook_at = ?, updated_at = ?
|
|
628
|
+
where account_id = ?
|
|
629
|
+
`).run(now, now, accountId);
|
|
630
|
+
}
|
|
631
|
+
markSyncStarted(accountId, now) {
|
|
632
|
+
this.database.prepare(`
|
|
633
|
+
update device_observation_state
|
|
634
|
+
set last_sync_started_at = ?, updated_at = ?
|
|
635
|
+
where account_id = ?
|
|
636
|
+
`).run(now, now, accountId);
|
|
637
|
+
}
|
|
638
|
+
markSyncSucceeded(accountId, now, disconnectGeneration = null, options = {}) {
|
|
639
|
+
const existing = this.getAccountById(accountId);
|
|
640
|
+
if (!existing) {
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
643
|
+
const metadata = sanitizeStoredDeviceSyncMetadata(options.metadataPatch ? { ...existing.metadata, ...options.metadataPatch } : existing.metadata);
|
|
644
|
+
const nextReconcileAt = Object.prototype.hasOwnProperty.call(options, "nextReconcileAt")
|
|
645
|
+
? options.nextReconcileAt ?? null
|
|
646
|
+
: existing.nextReconcileAt;
|
|
647
|
+
return withImmediateTransaction(this.database, () => {
|
|
648
|
+
const connectionResult = this.database.prepare(`
|
|
649
|
+
update device_connection
|
|
650
|
+
set status = case when status = 'disconnected' then status else 'active' end,
|
|
651
|
+
metadata_json = ?,
|
|
652
|
+
updated_at = ?
|
|
653
|
+
where id = ?
|
|
654
|
+
and (? is null or (disconnect_generation = ? and status = 'active'))
|
|
655
|
+
`).run(stringifyJson(metadata), now, accountId, disconnectGeneration ?? null, disconnectGeneration ?? null);
|
|
656
|
+
if ((connectionResult.changes ?? 0) === 0) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
this.database.prepare(`
|
|
660
|
+
update device_observation_state
|
|
661
|
+
set next_reconcile_at = ?,
|
|
662
|
+
last_sync_completed_at = ?,
|
|
663
|
+
last_sync_error_at = null,
|
|
664
|
+
last_error_code = null,
|
|
665
|
+
last_error_message = null,
|
|
666
|
+
updated_at = ?
|
|
667
|
+
where account_id = ?
|
|
668
|
+
`).run(nextReconcileAt, now, now, accountId);
|
|
669
|
+
return true;
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
markSyncFailed(accountId, now, code, message, status) {
|
|
673
|
+
withImmediateTransaction(this.database, () => {
|
|
674
|
+
this.database.prepare(`
|
|
675
|
+
update device_connection
|
|
676
|
+
set status = ?,
|
|
677
|
+
updated_at = ?
|
|
678
|
+
where id = ?
|
|
679
|
+
`).run(status ?? this.getAccountById(accountId)?.status ?? "active", now, accountId);
|
|
680
|
+
this.database.prepare(`
|
|
681
|
+
update device_observation_state
|
|
682
|
+
set last_sync_error_at = ?,
|
|
683
|
+
last_error_code = ?,
|
|
684
|
+
last_error_message = ?,
|
|
685
|
+
updated_at = ?
|
|
686
|
+
where account_id = ?
|
|
687
|
+
`).run(now, code, message, now, accountId);
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
enqueueJob(input) {
|
|
691
|
+
return withImmediateTransaction(this.database, () => this.enqueueJobInTransaction(input));
|
|
692
|
+
}
|
|
693
|
+
enqueueJobsAndCompleteWebhookTrace(input) {
|
|
694
|
+
return withImmediateTransaction(this.database, () => {
|
|
695
|
+
const queuedJobs = input.jobs.map((job) => this.enqueueJobInTransaction({
|
|
696
|
+
provider: input.provider,
|
|
697
|
+
accountId: input.accountId,
|
|
698
|
+
kind: job.kind,
|
|
699
|
+
payload: job.payload ?? {},
|
|
700
|
+
priority: job.priority ?? 0,
|
|
701
|
+
availableAt: job.availableAt,
|
|
702
|
+
maxAttempts: job.maxAttempts,
|
|
703
|
+
dedupeKey: job.dedupeKey,
|
|
704
|
+
}));
|
|
705
|
+
this.completeWebhookTrace(input.provider, input.traceId);
|
|
706
|
+
return queuedJobs;
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
getJobById(jobId) {
|
|
710
|
+
const row = this.database.prepare(`select * from device_job where id = ?`).get(jobId);
|
|
711
|
+
return mapJobRow(row);
|
|
712
|
+
}
|
|
713
|
+
readNextActiveReconcileAt() {
|
|
714
|
+
const row = this.database.prepare(`
|
|
715
|
+
select observation.next_reconcile_at
|
|
716
|
+
from device_observation_state as observation
|
|
717
|
+
join device_connection as connection
|
|
718
|
+
on connection.id = observation.account_id
|
|
719
|
+
where connection.status = 'active'
|
|
720
|
+
and observation.next_reconcile_at is not null
|
|
721
|
+
order by observation.next_reconcile_at asc, observation.updated_at asc, connection.id asc
|
|
722
|
+
limit 1
|
|
723
|
+
`).get();
|
|
724
|
+
return row?.next_reconcile_at ?? null;
|
|
725
|
+
}
|
|
726
|
+
readNextJobWakeAt() {
|
|
727
|
+
const row = this.database.prepare(`
|
|
728
|
+
select wake_at
|
|
729
|
+
from (
|
|
730
|
+
select available_at as wake_at
|
|
731
|
+
from device_job
|
|
732
|
+
where status = 'queued'
|
|
733
|
+
union all
|
|
734
|
+
select lease_expires_at as wake_at
|
|
735
|
+
from device_job
|
|
736
|
+
where status = 'running'
|
|
737
|
+
and lease_expires_at is not null
|
|
738
|
+
and attempts < max_attempts
|
|
739
|
+
)
|
|
740
|
+
order by wake_at asc
|
|
741
|
+
limit 1
|
|
742
|
+
`).get();
|
|
743
|
+
return row?.wake_at ?? null;
|
|
744
|
+
}
|
|
745
|
+
claimDueJob(workerId, now, leaseMs) {
|
|
746
|
+
return withImmediateTransaction(this.database, () => {
|
|
747
|
+
const row = this.database.prepare(`
|
|
748
|
+
select *
|
|
749
|
+
from device_job as candidate
|
|
750
|
+
where (
|
|
751
|
+
(
|
|
752
|
+
candidate.status = 'queued' and candidate.available_at <= ?
|
|
753
|
+
) or (
|
|
754
|
+
candidate.status = 'running'
|
|
755
|
+
and candidate.lease_expires_at is not null
|
|
756
|
+
and candidate.lease_expires_at <= ?
|
|
757
|
+
and candidate.attempts < candidate.max_attempts
|
|
758
|
+
)
|
|
759
|
+
)
|
|
760
|
+
and not exists (
|
|
761
|
+
select 1
|
|
762
|
+
from device_job as blocking
|
|
763
|
+
where blocking.account_id = candidate.account_id
|
|
764
|
+
and blocking.id != candidate.id
|
|
765
|
+
and blocking.status = 'running'
|
|
766
|
+
and blocking.lease_expires_at is not null
|
|
767
|
+
and blocking.lease_expires_at > ?
|
|
768
|
+
)
|
|
769
|
+
order by candidate.priority desc, candidate.available_at asc, candidate.created_at asc, candidate.id asc
|
|
770
|
+
limit 1
|
|
771
|
+
`).get(now, now, now);
|
|
772
|
+
if (!row) {
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
const leaseExpiresAt = new Date(Date.parse(now) + leaseMs).toISOString();
|
|
776
|
+
this.database.prepare(`
|
|
777
|
+
update device_job
|
|
778
|
+
set status = 'running',
|
|
779
|
+
lease_owner = ?,
|
|
780
|
+
lease_expires_at = ?,
|
|
781
|
+
attempts = attempts + 1,
|
|
782
|
+
started_at = coalesce(started_at, ?),
|
|
783
|
+
updated_at = ?
|
|
784
|
+
where id = ?
|
|
785
|
+
`).run(workerId, leaseExpiresAt, now, now, row.id);
|
|
786
|
+
return this.getJobById(row.id);
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
completeJob(jobId, now) {
|
|
790
|
+
this.database.prepare(`
|
|
791
|
+
update device_job
|
|
792
|
+
set status = 'succeeded',
|
|
793
|
+
lease_owner = null,
|
|
794
|
+
lease_expires_at = null,
|
|
795
|
+
finished_at = ?,
|
|
796
|
+
updated_at = ?
|
|
797
|
+
where id = ?
|
|
798
|
+
`).run(now, now, jobId);
|
|
799
|
+
}
|
|
800
|
+
completeJobIfOwned(jobId, workerId, now) {
|
|
801
|
+
const result = this.database.prepare(`
|
|
802
|
+
update device_job
|
|
803
|
+
set status = 'succeeded',
|
|
804
|
+
lease_owner = null,
|
|
805
|
+
lease_expires_at = null,
|
|
806
|
+
finished_at = ?,
|
|
807
|
+
updated_at = ?
|
|
808
|
+
where id = ?
|
|
809
|
+
and status = 'running'
|
|
810
|
+
and lease_owner = ?
|
|
811
|
+
`).run(now, now, jobId, workerId);
|
|
812
|
+
return (result.changes ?? 0) > 0;
|
|
813
|
+
}
|
|
814
|
+
failJob(jobId, now, code, message, retryAt, retryable) {
|
|
815
|
+
const job = this.getJobById(jobId);
|
|
816
|
+
if (!job) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (job.status !== "queued" && job.status !== "running") {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (retryable && job.attempts < job.maxAttempts) {
|
|
823
|
+
this.database.prepare(`
|
|
824
|
+
update device_job
|
|
825
|
+
set status = 'queued',
|
|
826
|
+
available_at = ?,
|
|
827
|
+
lease_owner = null,
|
|
828
|
+
lease_expires_at = null,
|
|
829
|
+
last_error_code = ?,
|
|
830
|
+
last_error_message = ?,
|
|
831
|
+
updated_at = ?
|
|
832
|
+
where id = ?
|
|
833
|
+
`).run(retryAt ?? now, code, message, now, jobId);
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
this.database.prepare(`
|
|
837
|
+
update device_job
|
|
838
|
+
set status = 'dead',
|
|
839
|
+
lease_owner = null,
|
|
840
|
+
lease_expires_at = null,
|
|
841
|
+
last_error_code = ?,
|
|
842
|
+
last_error_message = ?,
|
|
843
|
+
finished_at = ?,
|
|
844
|
+
updated_at = ?
|
|
845
|
+
where id = ?
|
|
846
|
+
`).run(code, message, now, now, jobId);
|
|
847
|
+
}
|
|
848
|
+
markPendingJobsDeadForAccount(accountId, now, code, message) {
|
|
849
|
+
const result = this.database.prepare(`
|
|
850
|
+
update device_job
|
|
851
|
+
set status = 'dead',
|
|
852
|
+
lease_owner = null,
|
|
853
|
+
lease_expires_at = null,
|
|
854
|
+
last_error_code = ?,
|
|
855
|
+
last_error_message = ?,
|
|
856
|
+
finished_at = ?,
|
|
857
|
+
updated_at = ?
|
|
858
|
+
where account_id = ? and status in ('queued', 'running')
|
|
859
|
+
`).run(code, message, now, now, accountId);
|
|
860
|
+
return result.changes ?? 0;
|
|
861
|
+
}
|
|
862
|
+
claimWebhookTrace(input) {
|
|
863
|
+
return withImmediateTransaction(this.database, () => {
|
|
864
|
+
const existing = this.database.prepare(`
|
|
865
|
+
select provider, trace_id, status, processing_expires_at
|
|
866
|
+
from webhook_trace
|
|
867
|
+
where provider = ?
|
|
868
|
+
and trace_id = ?
|
|
869
|
+
`).get(input.provider, input.traceId);
|
|
870
|
+
if (!existing) {
|
|
871
|
+
this.database.prepare(`
|
|
872
|
+
insert into webhook_trace (
|
|
873
|
+
provider,
|
|
874
|
+
trace_id,
|
|
875
|
+
external_account_id,
|
|
876
|
+
event_type,
|
|
877
|
+
received_at,
|
|
878
|
+
payload_json,
|
|
879
|
+
status,
|
|
880
|
+
processing_expires_at
|
|
881
|
+
) values (?, ?, ?, ?, ?, ?, 'processing', ?)
|
|
882
|
+
`).run(input.provider, input.traceId, input.externalAccountId, input.eventType, input.receivedAt, MINIMIZED_WEBHOOK_TRACE_PAYLOAD_JSON, input.processingExpiresAt);
|
|
883
|
+
return "claimed";
|
|
884
|
+
}
|
|
885
|
+
if ((existing.status ?? "processed") === "processed") {
|
|
886
|
+
return "processed";
|
|
887
|
+
}
|
|
888
|
+
if (existing.processing_expires_at
|
|
889
|
+
&& Date.parse(existing.processing_expires_at) > Date.parse(input.receivedAt)) {
|
|
890
|
+
return "processing";
|
|
891
|
+
}
|
|
892
|
+
const result = this.database.prepare(`
|
|
893
|
+
update webhook_trace
|
|
894
|
+
set external_account_id = ?,
|
|
895
|
+
event_type = ?,
|
|
896
|
+
received_at = ?,
|
|
897
|
+
payload_json = ?,
|
|
898
|
+
status = 'processing',
|
|
899
|
+
processing_expires_at = ?
|
|
900
|
+
where provider = ?
|
|
901
|
+
and trace_id = ?
|
|
902
|
+
and coalesce(status, 'processed') = 'processing'
|
|
903
|
+
and (
|
|
904
|
+
processing_expires_at is null
|
|
905
|
+
or processing_expires_at <= ?
|
|
906
|
+
)
|
|
907
|
+
`).run(input.externalAccountId, input.eventType, input.receivedAt, MINIMIZED_WEBHOOK_TRACE_PAYLOAD_JSON, input.processingExpiresAt, input.provider, input.traceId, input.receivedAt);
|
|
908
|
+
return (result.changes ?? 0) > 0 ? "claimed" : "processing";
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
completeWebhookTrace(provider, traceId) {
|
|
912
|
+
this.database.prepare(`
|
|
913
|
+
update webhook_trace
|
|
914
|
+
set payload_json = ?,
|
|
915
|
+
status = 'processed',
|
|
916
|
+
processing_expires_at = null
|
|
917
|
+
where provider = ?
|
|
918
|
+
and trace_id = ?
|
|
919
|
+
and coalesce(status, 'processed') = 'processing'
|
|
920
|
+
`).run(MINIMIZED_WEBHOOK_TRACE_PAYLOAD_JSON, provider, traceId);
|
|
921
|
+
}
|
|
922
|
+
releaseWebhookTrace(provider, traceId) {
|
|
923
|
+
this.database.prepare(`
|
|
924
|
+
delete from webhook_trace
|
|
925
|
+
where provider = ?
|
|
926
|
+
and trace_id = ?
|
|
927
|
+
and coalesce(status, 'processed') = 'processing'
|
|
928
|
+
`).run(provider, traceId);
|
|
929
|
+
}
|
|
930
|
+
enqueueJobInTransaction(input) {
|
|
931
|
+
if (input.dedupeKey) {
|
|
932
|
+
const existing = this.database.prepare(`
|
|
933
|
+
select *
|
|
934
|
+
from device_job
|
|
935
|
+
where account_id = ? and provider = ? and dedupe_key = ? and status in ('queued', 'running')
|
|
936
|
+
order by created_at desc, id desc
|
|
937
|
+
limit 1
|
|
938
|
+
`).get(input.accountId, input.provider, input.dedupeKey);
|
|
939
|
+
if (existing) {
|
|
940
|
+
return mapJobRow(existing);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
const now = toIsoTimestamp(new Date());
|
|
944
|
+
const id = generatePrefixedId("dsj");
|
|
945
|
+
this.database.prepare(`
|
|
946
|
+
insert into device_job (
|
|
947
|
+
id,
|
|
948
|
+
provider,
|
|
949
|
+
account_id,
|
|
950
|
+
kind,
|
|
951
|
+
payload_json,
|
|
952
|
+
priority,
|
|
953
|
+
available_at,
|
|
954
|
+
attempts,
|
|
955
|
+
max_attempts,
|
|
956
|
+
dedupe_key,
|
|
957
|
+
status,
|
|
958
|
+
created_at,
|
|
959
|
+
updated_at
|
|
960
|
+
) values (?, ?, ?, ?, ?, ?, ?, 0, ?, ?, 'queued', ?, ?)
|
|
961
|
+
`).run(id, input.provider, input.accountId, input.kind, stringifyJson(input.payload ?? {}), input.priority ?? 0, input.availableAt ?? now, input.maxAttempts ?? 5, input.dedupeKey ?? null, now, now);
|
|
962
|
+
return this.getJobById(id);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
//# sourceMappingURL=store.js.map
|