@opendatalabs/personal-server-ts-core 0.0.1-canary.052d47e → 0.0.1-canary.0620a9a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/additions/budget.d.ts +34 -0
- package/dist/additions/budget.d.ts.map +1 -0
- package/dist/additions/budget.js +144 -0
- package/dist/additions/budget.js.map +1 -0
- package/dist/additions/durable.d.ts +94 -0
- package/dist/additions/durable.d.ts.map +1 -0
- package/dist/additions/durable.js +823 -0
- package/dist/additions/durable.js.map +1 -0
- package/dist/additions/first-added.d.ts +204 -0
- package/dist/additions/first-added.d.ts.map +1 -0
- package/dist/additions/first-added.js +598 -0
- package/dist/additions/first-added.js.map +1 -0
- package/dist/additions/index.d.ts +9 -0
- package/dist/additions/index.d.ts.map +1 -0
- package/dist/additions/index.js +9 -0
- package/dist/additions/index.js.map +1 -0
- package/dist/additions/ledger-store.d.ts +69 -0
- package/dist/additions/ledger-store.d.ts.map +1 -0
- package/dist/additions/ledger-store.js +407 -0
- package/dist/additions/ledger-store.js.map +1 -0
- package/dist/additions/record-rules.d.ts +54 -0
- package/dist/additions/record-rules.d.ts.map +1 -0
- package/dist/additions/record-rules.js +198 -0
- package/dist/additions/record-rules.js.map +1 -0
- package/dist/additions/scope-lock.d.ts +14 -0
- package/dist/additions/scope-lock.d.ts.map +1 -0
- package/dist/additions/scope-lock.js +32 -0
- package/dist/additions/scope-lock.js.map +1 -0
- package/dist/additions/summary.d.ts +143 -0
- package/dist/additions/summary.d.ts.map +1 -0
- package/dist/additions/summary.js +279 -0
- package/dist/additions/summary.js.map +1 -0
- package/dist/additions/version-inventory.d.ts +86 -0
- package/dist/additions/version-inventory.d.ts.map +1 -0
- package/dist/additions/version-inventory.js +244 -0
- package/dist/additions/version-inventory.js.map +1 -0
- package/dist/api/index.d.ts +192 -8
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1227 -153
- package/dist/api/index.js.map +1 -1
- package/dist/api/oura-collection-requirements.d.ts +16 -0
- package/dist/api/oura-collection-requirements.d.ts.map +1 -0
- package/dist/api/oura-collection-requirements.js +70 -0
- package/dist/api/oura-collection-requirements.js.map +1 -0
- package/dist/api/raw-envelope.d.ts +3 -0
- package/dist/api/raw-envelope.d.ts.map +1 -0
- package/dist/api/raw-envelope.js +215 -0
- package/dist/api/raw-envelope.js.map +1 -0
- package/dist/api/scope-upload-batches.d.ts +18 -0
- package/dist/api/scope-upload-batches.d.ts.map +1 -0
- package/dist/api/scope-upload-batches.js +71 -0
- package/dist/api/scope-upload-batches.js.map +1 -0
- package/dist/api/scope-uploads.d.ts +112 -0
- package/dist/api/scope-uploads.d.ts.map +1 -0
- package/dist/api/scope-uploads.js +369 -0
- package/dist/api/scope-uploads.js.map +1 -0
- package/dist/auth/index.d.ts +3 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/proof-id.d.ts +8 -0
- package/dist/auth/proof-id.d.ts.map +1 -0
- package/dist/auth/proof-id.js +29 -0
- package/dist/auth/proof-id.js.map +1 -0
- package/dist/auth/request.d.ts +24 -0
- package/dist/auth/request.d.ts.map +1 -1
- package/dist/auth/request.js +99 -4
- package/dist/auth/request.js.map +1 -1
- package/dist/client.d.ts +70 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/contracts/auth-device.d.ts +10 -0
- package/dist/contracts/auth-device.d.ts.map +1 -1
- package/dist/contracts/auth-device.js +2 -0
- package/dist/contracts/auth-device.js.map +1 -1
- package/dist/contracts/data.d.ts +102 -8
- package/dist/contracts/data.d.ts.map +1 -1
- package/dist/contracts/data.js +320 -47
- package/dist/contracts/data.js.map +1 -1
- package/dist/contracts/grants.d.ts.map +1 -1
- package/dist/contracts/grants.js +7 -0
- package/dist/contracts/grants.js.map +1 -1
- package/dist/contracts/index.d.ts +4 -2
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +3 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/oura-collection-requirements.d.ts +17 -0
- package/dist/contracts/oura-collection-requirements.d.ts.map +1 -0
- package/dist/contracts/oura-collection-requirements.js +49 -0
- package/dist/contracts/oura-collection-requirements.js.map +1 -0
- package/dist/contracts/sync.d.ts.map +1 -1
- package/dist/contracts/sync.js +1 -0
- package/dist/contracts/sync.js.map +1 -1
- package/dist/derivatives/answer-shape.d.ts +83 -0
- package/dist/derivatives/answer-shape.d.ts.map +1 -0
- package/dist/derivatives/answer-shape.js +320 -0
- package/dist/derivatives/answer-shape.js.map +1 -0
- package/dist/derivatives/api.d.ts +1 -1
- package/dist/derivatives/api.d.ts.map +1 -1
- package/dist/derivatives/api.js +8 -0
- package/dist/derivatives/api.js.map +1 -1
- package/dist/derivatives/compute.d.ts +9 -3
- package/dist/derivatives/compute.d.ts.map +1 -1
- package/dist/derivatives/compute.js +68 -6
- package/dist/derivatives/compute.js.map +1 -1
- package/dist/derivatives/index.d.ts +2 -1
- package/dist/derivatives/index.d.ts.map +1 -1
- package/dist/derivatives/index.js +2 -1
- package/dist/derivatives/index.js.map +1 -1
- package/dist/derivatives/prompt.d.ts +35 -0
- package/dist/derivatives/prompt.d.ts.map +1 -1
- package/dist/derivatives/prompt.js +96 -8
- package/dist/derivatives/prompt.js.map +1 -1
- package/dist/derivatives/registration.d.ts +6 -9
- package/dist/derivatives/registration.d.ts.map +1 -1
- package/dist/derivatives/registration.js +14 -6
- package/dist/derivatives/registration.js.map +1 -1
- package/dist/derivatives/scheduler.d.ts +39 -9
- package/dist/derivatives/scheduler.d.ts.map +1 -1
- package/dist/derivatives/scheduler.js +99 -8
- package/dist/derivatives/scheduler.js.map +1 -1
- package/dist/derivatives/store.d.ts.map +1 -1
- package/dist/derivatives/store.js +2 -0
- package/dist/derivatives/store.js.map +1 -1
- package/dist/derivatives/types.d.ts +13 -3
- package/dist/derivatives/types.d.ts.map +1 -1
- package/dist/derivatives/types.js +2 -0
- package/dist/derivatives/types.js.map +1 -1
- package/dist/errors/pdpp-catalog.d.ts +36 -0
- package/dist/errors/pdpp-catalog.d.ts.map +1 -0
- package/dist/errors/pdpp-catalog.js +86 -0
- package/dist/errors/pdpp-catalog.js.map +1 -0
- package/dist/grants/index.d.ts +2 -0
- package/dist/grants/index.d.ts.map +1 -1
- package/dist/grants/index.js +4 -0
- package/dist/grants/index.js.map +1 -1
- package/dist/grants/pdpp-binding-store.d.ts +89 -0
- package/dist/grants/pdpp-binding-store.d.ts.map +1 -0
- package/dist/grants/pdpp-binding-store.js +112 -0
- package/dist/grants/pdpp-binding-store.js.map +1 -0
- package/dist/grants/pdpp-binding.d.ts +169 -0
- package/dist/grants/pdpp-binding.d.ts.map +1 -0
- package/dist/grants/pdpp-binding.js +236 -0
- package/dist/grants/pdpp-binding.js.map +1 -0
- package/dist/legacy-projection/bindings.d.ts +31 -0
- package/dist/legacy-projection/bindings.d.ts.map +1 -0
- package/dist/legacy-projection/bindings.js +4512 -0
- package/dist/legacy-projection/bindings.js.map +1 -0
- package/dist/legacy-projection/claude-source-record.d.ts +22 -0
- package/dist/legacy-projection/claude-source-record.d.ts.map +1 -0
- package/dist/legacy-projection/claude-source-record.js +360 -0
- package/dist/legacy-projection/claude-source-record.js.map +1 -0
- package/dist/legacy-projection/declared-text.d.ts +41 -0
- package/dist/legacy-projection/declared-text.d.ts.map +1 -0
- package/dist/legacy-projection/declared-text.js +199 -0
- package/dist/legacy-projection/declared-text.js.map +1 -0
- package/dist/legacy-projection/github-browser-bindings.d.ts +3 -0
- package/dist/legacy-projection/github-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/github-browser-bindings.js +212 -0
- package/dist/legacy-projection/github-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/github-legacy-fields.d.ts +6 -0
- package/dist/legacy-projection/github-legacy-fields.d.ts.map +1 -0
- package/dist/legacy-projection/github-legacy-fields.js +202 -0
- package/dist/legacy-projection/github-legacy-fields.js.map +1 -0
- package/dist/legacy-projection/index.d.ts +38 -0
- package/dist/legacy-projection/index.d.ts.map +1 -0
- package/dist/legacy-projection/index.js +231 -0
- package/dist/legacy-projection/index.js.map +1 -0
- package/dist/legacy-projection/meta-040-bindings.d.ts +3 -0
- package/dist/legacy-projection/meta-040-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/meta-040-bindings.js +112 -0
- package/dist/legacy-projection/meta-040-bindings.js.map +1 -0
- package/dist/legacy-projection/oura-browser-bindings.d.ts +5 -0
- package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/oura-browser-bindings.js +141 -0
- package/dist/legacy-projection/oura-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/provenance.d.ts +57 -0
- package/dist/legacy-projection/provenance.d.ts.map +1 -0
- package/dist/legacy-projection/provenance.js +2 -0
- package/dist/legacy-projection/provenance.js.map +1 -0
- package/dist/legacy-projection/strava-browser-bindings.d.ts +3 -0
- package/dist/legacy-projection/strava-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/strava-browser-bindings.js +32 -0
- package/dist/legacy-projection/strava-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/test-debris.d.ts +2 -0
- package/dist/legacy-projection/test-debris.d.ts.map +1 -0
- package/dist/legacy-projection/test-debris.js +49 -0
- package/dist/legacy-projection/test-debris.js.map +1 -0
- package/dist/legacy-projection/types.d.ts +235 -0
- package/dist/legacy-projection/types.d.ts.map +1 -0
- package/dist/legacy-projection/types.js +2 -0
- package/dist/legacy-projection/types.js.map +1 -0
- package/dist/mcp/approval-url.d.ts +68 -0
- package/dist/mcp/approval-url.d.ts.map +1 -0
- package/dist/mcp/approval-url.js +95 -0
- package/dist/mcp/approval-url.js.map +1 -0
- package/dist/mcp/connection-api.d.ts +187 -3
- package/dist/mcp/connection-api.d.ts.map +1 -1
- package/dist/mcp/connection-api.js +600 -26
- package/dist/mcp/connection-api.js.map +1 -1
- package/dist/mcp/grantee.d.ts +1 -1
- package/dist/mcp/grantee.d.ts.map +1 -1
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/oauth-redirect.d.ts +14 -0
- package/dist/mcp/oauth-redirect.d.ts.map +1 -0
- package/dist/mcp/oauth-redirect.js +51 -0
- package/dist/mcp/oauth-redirect.js.map +1 -0
- package/dist/mcp/read-client.d.ts +5 -1
- package/dist/mcp/read-client.d.ts.map +1 -1
- package/dist/mcp/read-client.js +18 -4
- package/dist/mcp/read-client.js.map +1 -1
- package/dist/mcp/resources.d.ts.map +1 -1
- package/dist/mcp/resources.js +3 -0
- package/dist/mcp/resources.js.map +1 -1
- package/dist/mcp/server.d.ts +30 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +172 -17
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session.d.ts +1 -1
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +17 -3
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/store.d.ts +10 -1
- package/dist/mcp/store.d.ts.map +1 -1
- package/dist/mcp/store.js +72 -0
- package/dist/mcp/store.js.map +1 -1
- package/dist/mcp/token-expiry.d.ts +48 -0
- package/dist/mcp/token-expiry.d.ts.map +1 -0
- package/dist/mcp/token-expiry.js +69 -0
- package/dist/mcp/token-expiry.js.map +1 -0
- package/dist/mcp/tools.d.ts +92 -3
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +513 -28
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts +103 -4
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js +13 -1
- package/dist/mcp/types.js.map +1 -1
- package/dist/mcp/write-client.d.ts +81 -0
- package/dist/mcp/write-client.d.ts.map +1 -0
- package/dist/mcp/write-client.js +140 -0
- package/dist/mcp/write-client.js.map +1 -0
- package/dist/oura/history-policy.d.ts +12 -0
- package/dist/oura/history-policy.d.ts.map +1 -0
- package/dist/oura/history-policy.js +54 -0
- package/dist/oura/history-policy.js.map +1 -0
- package/dist/oura/index.d.ts +51 -0
- package/dist/oura/index.d.ts.map +1 -0
- package/dist/oura/index.js +315 -0
- package/dist/oura/index.js.map +1 -0
- package/dist/payment/own-app.d.ts +8 -0
- package/dist/payment/own-app.d.ts.map +1 -0
- package/dist/payment/own-app.js +47 -0
- package/dist/payment/own-app.js.map +1 -0
- package/dist/pdpp/approval.d.ts +271 -0
- package/dist/pdpp/approval.d.ts.map +1 -0
- package/dist/pdpp/approval.js +486 -0
- package/dist/pdpp/approval.js.map +1 -0
- package/dist/pdpp/client-identity.d.ts +88 -0
- package/dist/pdpp/client-identity.d.ts.map +1 -0
- package/dist/pdpp/client-identity.js +196 -0
- package/dist/pdpp/client-identity.js.map +1 -0
- package/dist/pdpp/client-metadata.d.ts +95 -0
- package/dist/pdpp/client-metadata.d.ts.map +1 -0
- package/dist/pdpp/client-metadata.js +96 -0
- package/dist/pdpp/client-metadata.js.map +1 -0
- package/dist/pdpp/commitments.d.ts +75 -0
- package/dist/pdpp/commitments.d.ts.map +1 -0
- package/dist/pdpp/commitments.js +113 -0
- package/dist/pdpp/commitments.js.map +1 -0
- package/dist/pdpp/declaration-limits.d.ts +7 -0
- package/dist/pdpp/declaration-limits.d.ts.map +1 -0
- package/dist/pdpp/declaration-limits.js +7 -0
- package/dist/pdpp/declaration-limits.js.map +1 -0
- package/dist/pdpp/declaration.d.ts +119 -0
- package/dist/pdpp/declaration.d.ts.map +1 -0
- package/dist/pdpp/declaration.js +837 -0
- package/dist/pdpp/declaration.js.map +1 -0
- package/dist/pdpp/index.d.ts +38 -0
- package/dist/pdpp/index.d.ts.map +1 -0
- package/dist/pdpp/index.js +24 -0
- package/dist/pdpp/index.js.map +1 -0
- package/dist/pdpp/issuance.d.ts +126 -0
- package/dist/pdpp/issuance.d.ts.map +1 -0
- package/dist/pdpp/issuance.js +184 -0
- package/dist/pdpp/issuance.js.map +1 -0
- package/dist/pdpp/pkce.d.ts +53 -0
- package/dist/pdpp/pkce.d.ts.map +1 -0
- package/dist/pdpp/pkce.js +109 -0
- package/dist/pdpp/pkce.js.map +1 -0
- package/dist/pdpp/redirect.d.ts +60 -0
- package/dist/pdpp/redirect.d.ts.map +1 -0
- package/dist/pdpp/redirect.js +125 -0
- package/dist/pdpp/redirect.js.map +1 -0
- package/dist/pdpp/resolve.d.ts +120 -0
- package/dist/pdpp/resolve.d.ts.map +1 -0
- package/dist/pdpp/resolve.js +491 -0
- package/dist/pdpp/resolve.js.map +1 -0
- package/dist/pdpp/review.d.ts +280 -0
- package/dist/pdpp/review.d.ts.map +1 -0
- package/dist/pdpp/review.js +205 -0
- package/dist/pdpp/review.js.map +1 -0
- package/dist/pdpp/selection.d.ts +79 -0
- package/dist/pdpp/selection.d.ts.map +1 -0
- package/dist/pdpp/selection.js +493 -0
- package/dist/pdpp/selection.js.map +1 -0
- package/dist/pdpp/store.d.ts +228 -0
- package/dist/pdpp/store.d.ts.map +1 -0
- package/dist/pdpp/store.js +542 -0
- package/dist/pdpp/store.js.map +1 -0
- package/dist/pdpp/time.d.ts +39 -0
- package/dist/pdpp/time.d.ts.map +1 -0
- package/dist/pdpp/time.js +173 -0
- package/dist/pdpp/time.js.map +1 -0
- package/dist/pdpp/tokens.d.ts +181 -0
- package/dist/pdpp/tokens.d.ts.map +1 -0
- package/dist/pdpp/tokens.js +421 -0
- package/dist/pdpp/tokens.js.map +1 -0
- package/dist/pdpp/types.d.ts +457 -0
- package/dist/pdpp/types.d.ts.map +1 -0
- package/dist/pdpp/types.js +68 -0
- package/dist/pdpp/types.js.map +1 -0
- package/dist/pdpp-version.d.ts +28 -0
- package/dist/pdpp-version.d.ts.map +1 -0
- package/dist/pdpp-version.js +28 -0
- package/dist/pdpp-version.js.map +1 -0
- package/dist/policy/data-read.d.ts +52 -1
- package/dist/policy/data-read.d.ts.map +1 -1
- package/dist/policy/data-read.js +157 -3
- package/dist/policy/data-read.js.map +1 -1
- package/dist/policy/data-write.d.ts.map +1 -1
- package/dist/policy/data-write.js +18 -1
- package/dist/policy/data-write.js.map +1 -1
- package/dist/policy/index.d.ts +2 -1
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +2 -1
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/reserved-scopes.d.ts +10 -0
- package/dist/policy/reserved-scopes.d.ts.map +1 -0
- package/dist/policy/reserved-scopes.js +16 -0
- package/dist/policy/reserved-scopes.js.map +1 -0
- package/dist/ports/index.d.ts +266 -5
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/pdpp-auth.d.ts +119 -0
- package/dist/ports/pdpp-auth.d.ts.map +1 -0
- package/dist/ports/pdpp-auth.js +46 -0
- package/dist/ports/pdpp-auth.js.map +1 -0
- package/dist/ports/pdpp-auth.test-utils.d.ts +9 -0
- package/dist/ports/pdpp-auth.test-utils.d.ts.map +1 -0
- package/dist/ports/pdpp-auth.test-utils.js +18 -0
- package/dist/ports/pdpp-auth.test-utils.js.map +1 -0
- package/dist/publication/publish.d.ts +109 -0
- package/dist/publication/publish.d.ts.map +1 -0
- package/dist/publication/publish.js +263 -0
- package/dist/publication/publish.js.map +1 -0
- package/dist/replication/completion.d.ts +20 -0
- package/dist/replication/completion.d.ts.map +1 -0
- package/dist/replication/completion.js +73 -0
- package/dist/replication/completion.js.map +1 -0
- package/dist/replication/coordinator-state.d.ts +29 -0
- package/dist/replication/coordinator-state.d.ts.map +1 -0
- package/dist/replication/coordinator-state.js +88 -0
- package/dist/replication/coordinator-state.js.map +1 -0
- package/dist/replication/coordinator-state.test-utils.d.ts +32 -0
- package/dist/replication/coordinator-state.test-utils.d.ts.map +1 -0
- package/dist/replication/coordinator-state.test-utils.js +113 -0
- package/dist/replication/coordinator-state.test-utils.js.map +1 -0
- package/dist/replication/coordinator.d.ts +264 -0
- package/dist/replication/coordinator.d.ts.map +1 -0
- package/dist/replication/coordinator.js +499 -0
- package/dist/replication/coordinator.js.map +1 -0
- package/dist/replication/copies.d.ts +126 -0
- package/dist/replication/copies.d.ts.map +1 -0
- package/dist/replication/copies.js +437 -0
- package/dist/replication/copies.js.map +1 -0
- package/dist/replication/copy-promotion.d.ts +132 -0
- package/dist/replication/copy-promotion.d.ts.map +1 -0
- package/dist/replication/copy-promotion.js +126 -0
- package/dist/replication/copy-promotion.js.map +1 -0
- package/dist/replication/door.d.ts +33 -0
- package/dist/replication/door.d.ts.map +1 -0
- package/dist/replication/door.js +10 -0
- package/dist/replication/door.js.map +1 -0
- package/dist/replication/dpv2.d.ts +141 -0
- package/dist/replication/dpv2.d.ts.map +1 -0
- package/dist/replication/dpv2.js +320 -0
- package/dist/replication/dpv2.js.map +1 -0
- package/dist/replication/effects.d.ts +68 -0
- package/dist/replication/effects.d.ts.map +1 -0
- package/dist/replication/effects.js +89 -0
- package/dist/replication/effects.js.map +1 -0
- package/dist/replication/engine.d.ts +378 -0
- package/dist/replication/engine.d.ts.map +1 -0
- package/dist/replication/engine.js +3197 -0
- package/dist/replication/engine.js.map +1 -0
- package/dist/replication/envelope.d.ts +481 -0
- package/dist/replication/envelope.d.ts.map +1 -0
- package/dist/replication/envelope.js +192 -0
- package/dist/replication/envelope.js.map +1 -0
- package/dist/replication/evidence.d.ts +118 -0
- package/dist/replication/evidence.d.ts.map +1 -0
- package/dist/replication/evidence.js +198 -0
- package/dist/replication/evidence.js.map +1 -0
- package/dist/replication/finality.d.ts +16 -0
- package/dist/replication/finality.d.ts.map +1 -0
- package/dist/replication/finality.js +11 -0
- package/dist/replication/finality.js.map +1 -0
- package/dist/replication/fixtures.d.ts +16 -0
- package/dist/replication/fixtures.d.ts.map +1 -0
- package/dist/replication/fixtures.js +47 -0
- package/dist/replication/fixtures.js.map +1 -0
- package/dist/replication/host-config.d.ts +52 -0
- package/dist/replication/host-config.d.ts.map +1 -0
- package/dist/replication/host-config.js +111 -0
- package/dist/replication/host-config.js.map +1 -0
- package/dist/replication/host-driver.d.ts +95 -0
- package/dist/replication/host-driver.d.ts.map +1 -0
- package/dist/replication/host-driver.js +202 -0
- package/dist/replication/host-driver.js.map +1 -0
- package/dist/replication/host-ports.d.ts +48 -0
- package/dist/replication/host-ports.d.ts.map +1 -0
- package/dist/replication/host-ports.js +69 -0
- package/dist/replication/host-ports.js.map +1 -0
- package/dist/replication/identity.d.ts +13 -0
- package/dist/replication/identity.d.ts.map +1 -0
- package/dist/replication/identity.js +22 -0
- package/dist/replication/identity.js.map +1 -0
- package/dist/replication/limits.d.ts +124 -0
- package/dist/replication/limits.d.ts.map +1 -0
- package/dist/replication/limits.js +182 -0
- package/dist/replication/limits.js.map +1 -0
- package/dist/replication/merge-plan.d.ts +92 -0
- package/dist/replication/merge-plan.d.ts.map +1 -0
- package/dist/replication/merge-plan.js +229 -0
- package/dist/replication/merge-plan.js.map +1 -0
- package/dist/replication/namespace.d.ts +4 -0
- package/dist/replication/namespace.d.ts.map +1 -0
- package/dist/replication/namespace.js +7 -0
- package/dist/replication/namespace.js.map +1 -0
- package/dist/replication/outcome.d.ts +178 -0
- package/dist/replication/outcome.d.ts.map +1 -0
- package/dist/replication/outcome.js +83 -0
- package/dist/replication/outcome.js.map +1 -0
- package/dist/replication/payload.d.ts +39 -0
- package/dist/replication/payload.d.ts.map +1 -0
- package/dist/replication/payload.js +137 -0
- package/dist/replication/payload.js.map +1 -0
- package/dist/replication/preparation.d.ts +42 -0
- package/dist/replication/preparation.d.ts.map +1 -0
- package/dist/replication/preparation.js +118 -0
- package/dist/replication/preparation.js.map +1 -0
- package/dist/replication/rebaseline.d.ts +33 -0
- package/dist/replication/rebaseline.d.ts.map +1 -0
- package/dist/replication/rebaseline.js +40 -0
- package/dist/replication/rebaseline.js.map +1 -0
- package/dist/replication/rebinding.d.ts +43 -0
- package/dist/replication/rebinding.d.ts.map +1 -0
- package/dist/replication/rebinding.js +52 -0
- package/dist/replication/rebinding.js.map +1 -0
- package/dist/replication/receive.d.ts +57 -0
- package/dist/replication/receive.d.ts.map +1 -0
- package/dist/replication/receive.js +114 -0
- package/dist/replication/receive.js.map +1 -0
- package/dist/replication/record-reducer.d.ts +16 -0
- package/dist/replication/record-reducer.d.ts.map +1 -0
- package/dist/replication/record-reducer.js +52 -0
- package/dist/replication/record-reducer.js.map +1 -0
- package/dist/replication/revision.d.ts +24 -0
- package/dist/replication/revision.d.ts.map +1 -0
- package/dist/replication/revision.js +35 -0
- package/dist/replication/revision.js.map +1 -0
- package/dist/replication/roster.d.ts +53 -0
- package/dist/replication/roster.d.ts.map +1 -0
- package/dist/replication/roster.js +115 -0
- package/dist/replication/roster.js.map +1 -0
- package/dist/replication/schedule.d.ts +73 -0
- package/dist/replication/schedule.d.ts.map +1 -0
- package/dist/replication/schedule.js +182 -0
- package/dist/replication/schedule.js.map +1 -0
- package/dist/replication/stream.d.ts +73 -0
- package/dist/replication/stream.d.ts.map +1 -0
- package/dist/replication/stream.js +542 -0
- package/dist/replication/stream.js.map +1 -0
- package/dist/replication/transport.d.ts +236 -0
- package/dist/replication/transport.d.ts.map +1 -0
- package/dist/replication/transport.js +440 -0
- package/dist/replication/transport.js.map +1 -0
- package/dist/replication/visibility-engine.d.ts +337 -0
- package/dist/replication/visibility-engine.d.ts.map +1 -0
- package/dist/replication/visibility-engine.js +602 -0
- package/dist/replication/visibility-engine.js.map +1 -0
- package/dist/replication/visibility-policy.d.ts +26 -0
- package/dist/replication/visibility-policy.d.ts.map +1 -0
- package/dist/replication/visibility-policy.js +33 -0
- package/dist/replication/visibility-policy.js.map +1 -0
- package/dist/replication/writer-identity-store.d.ts +100 -0
- package/dist/replication/writer-identity-store.d.ts.map +1 -0
- package/dist/replication/writer-identity-store.js +218 -0
- package/dist/replication/writer-identity-store.js.map +1 -0
- package/dist/replication/writer-identity.d.ts +252 -0
- package/dist/replication/writer-identity.d.ts.map +1 -0
- package/dist/replication/writer-identity.js +281 -0
- package/dist/replication/writer-identity.js.map +1 -0
- package/dist/replication/writer-identity.test-utils.d.ts +24 -0
- package/dist/replication/writer-identity.test-utils.d.ts.map +1 -0
- package/dist/replication/writer-identity.test-utils.js +86 -0
- package/dist/replication/writer-identity.test-utils.js.map +1 -0
- package/dist/schemas/server-config.d.ts +71 -0
- package/dist/schemas/server-config.d.ts.map +1 -1
- package/dist/schemas/server-config.js +151 -0
- package/dist/schemas/server-config.js.map +1 -1
- package/dist/signing/request-signer.d.ts +2 -0
- package/dist/signing/request-signer.d.ts.map +1 -1
- package/dist/signing/request-signer.js +1 -0
- package/dist/signing/request-signer.js.map +1 -1
- package/dist/storage/adapters/index.d.ts +3 -1
- package/dist/storage/adapters/index.d.ts.map +1 -1
- package/dist/storage/adapters/index.js +2 -0
- package/dist/storage/adapters/index.js.map +1 -1
- package/dist/storage/adapters/interface.d.ts +21 -1
- package/dist/storage/adapters/interface.d.ts.map +1 -1
- package/dist/storage/adapters/interface.js +13 -1
- package/dist/storage/adapters/interface.js.map +1 -1
- package/dist/storage/adapters/sdk.d.ts +2 -1
- package/dist/storage/adapters/sdk.d.ts.map +1 -1
- package/dist/storage/adapters/sdk.js +21 -3
- package/dist/storage/adapters/sdk.js.map +1 -1
- package/dist/storage/adapters/vana-audience.d.ts +24 -0
- package/dist/storage/adapters/vana-audience.d.ts.map +1 -0
- package/dist/storage/adapters/vana-audience.js +87 -0
- package/dist/storage/adapters/vana-audience.js.map +1 -0
- package/dist/storage/adapters/vana.d.ts +5 -3
- package/dist/storage/adapters/vana.d.ts.map +1 -1
- package/dist/storage/adapters/vana.js +69 -23
- package/dist/storage/adapters/vana.js.map +1 -1
- package/dist/storage/blocks/cursor.d.ts +5 -1
- package/dist/storage/blocks/cursor.d.ts.map +1 -1
- package/dist/storage/blocks/cursor.js +13 -1
- package/dist/storage/blocks/cursor.js.map +1 -1
- package/dist/storage/blocks/page.d.ts +18 -0
- package/dist/storage/blocks/page.d.ts.map +1 -0
- package/dist/storage/blocks/page.js +113 -0
- package/dist/storage/blocks/page.js.map +1 -0
- package/dist/storage/canonical-legacy-projection.d.ts +262 -0
- package/dist/storage/canonical-legacy-projection.d.ts.map +1 -0
- package/dist/storage/canonical-legacy-projection.js +759 -0
- package/dist/storage/canonical-legacy-projection.js.map +1 -0
- package/dist/storage/hierarchy/paths.d.ts.map +1 -1
- package/dist/storage/hierarchy/paths.js +9 -2
- package/dist/storage/hierarchy/paths.js.map +1 -1
- package/dist/storage/index/manager.d.ts +30 -3
- package/dist/storage/index/manager.d.ts.map +1 -1
- package/dist/storage/index/schema.d.ts +1 -1
- package/dist/storage/index/schema.js +1 -1
- package/dist/storage/index/types.d.ts +7 -1
- package/dist/storage/index/types.d.ts.map +1 -1
- package/dist/storage/legacy-projection.d.ts +88 -0
- package/dist/storage/legacy-projection.d.ts.map +1 -0
- package/dist/storage/legacy-projection.js +755 -0
- package/dist/storage/legacy-projection.js.map +1 -0
- package/dist/storage/legacy-scope-coverage-exceptions.d.ts +13 -0
- package/dist/storage/legacy-scope-coverage-exceptions.d.ts.map +1 -0
- package/dist/storage/legacy-scope-coverage-exceptions.js +14 -0
- package/dist/storage/legacy-scope-coverage-exceptions.js.map +1 -0
- package/dist/storage/legacy-scope-coverage.d.ts +53 -0
- package/dist/storage/legacy-scope-coverage.d.ts.map +1 -0
- package/dist/storage/legacy-scope-coverage.js +416 -0
- package/dist/storage/legacy-scope-coverage.js.map +1 -0
- package/dist/storage/legacy-scope-entity-keys.d.ts +17 -0
- package/dist/storage/legacy-scope-entity-keys.d.ts.map +1 -0
- package/dist/storage/legacy-scope-entity-keys.js +109 -0
- package/dist/storage/legacy-scope-entity-keys.js.map +1 -0
- package/dist/storage/legacy-scope-view.d.ts +206 -0
- package/dist/storage/legacy-scope-view.d.ts.map +1 -0
- package/dist/storage/legacy-scope-view.js +1061 -0
- package/dist/storage/legacy-scope-view.js.map +1 -0
- package/dist/storage/pdpp-records/completion.d.ts +91 -0
- package/dist/storage/pdpp-records/completion.d.ts.map +1 -0
- package/dist/storage/pdpp-records/completion.js +170 -0
- package/dist/storage/pdpp-records/completion.js.map +1 -0
- package/dist/storage/pdpp-records/cursor.d.ts +86 -0
- package/dist/storage/pdpp-records/cursor.d.ts.map +1 -0
- package/dist/storage/pdpp-records/cursor.js +56 -0
- package/dist/storage/pdpp-records/cursor.js.map +1 -0
- package/dist/storage/pdpp-records/declaration-witness.d.ts +58 -0
- package/dist/storage/pdpp-records/declaration-witness.d.ts.map +1 -0
- package/dist/storage/pdpp-records/declaration-witness.js +230 -0
- package/dist/storage/pdpp-records/declaration-witness.js.map +1 -0
- package/dist/storage/pdpp-records/enforcement.d.ts +39 -0
- package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -0
- package/dist/storage/pdpp-records/enforcement.js +143 -0
- package/dist/storage/pdpp-records/enforcement.js.map +1 -0
- package/dist/storage/pdpp-records/index.d.ts +7 -0
- package/dist/storage/pdpp-records/index.d.ts.map +1 -0
- package/dist/storage/pdpp-records/index.js +6 -0
- package/dist/storage/pdpp-records/index.js.map +1 -0
- package/dist/storage/pdpp-records/ingest-plan.d.ts +39 -0
- package/dist/storage/pdpp-records/ingest-plan.d.ts.map +1 -0
- package/dist/storage/pdpp-records/ingest-plan.js +103 -0
- package/dist/storage/pdpp-records/ingest-plan.js.map +1 -0
- package/dist/storage/pdpp-records/interface.d.ts +111 -0
- package/dist/storage/pdpp-records/interface.d.ts.map +1 -0
- package/dist/storage/pdpp-records/interface.js +2 -0
- package/dist/storage/pdpp-records/interface.js.map +1 -0
- package/dist/storage/pdpp-records/list-page.d.ts +35 -0
- package/dist/storage/pdpp-records/list-page.d.ts.map +1 -0
- package/dist/storage/pdpp-records/list-page.js +106 -0
- package/dist/storage/pdpp-records/list-page.js.map +1 -0
- package/dist/storage/pdpp-records/memory-store.d.ts +9 -0
- package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -0
- package/dist/storage/pdpp-records/memory-store.js +462 -0
- package/dist/storage/pdpp-records/memory-store.js.map +1 -0
- package/dist/storage/pdpp-records/portable.d.ts +12 -0
- package/dist/storage/pdpp-records/portable.d.ts.map +1 -0
- package/dist/storage/pdpp-records/portable.js +11 -0
- package/dist/storage/pdpp-records/portable.js.map +1 -0
- package/dist/storage/pdpp-records/read-port.d.ts +44 -0
- package/dist/storage/pdpp-records/read-port.d.ts.map +1 -0
- package/dist/storage/pdpp-records/read-port.js +22 -0
- package/dist/storage/pdpp-records/read-port.js.map +1 -0
- package/dist/storage/pdpp-records/record-key.d.ts +52 -0
- package/dist/storage/pdpp-records/record-key.d.ts.map +1 -0
- package/dist/storage/pdpp-records/record-key.js +97 -0
- package/dist/storage/pdpp-records/record-key.js.map +1 -0
- package/dist/storage/pdpp-records/replication-journal.d.ts +20 -0
- package/dist/storage/pdpp-records/replication-journal.d.ts.map +1 -0
- package/dist/storage/pdpp-records/replication-journal.js +2 -0
- package/dist/storage/pdpp-records/replication-journal.js.map +1 -0
- package/dist/storage/pdpp-records/schema.d.ts +41 -0
- package/dist/storage/pdpp-records/schema.d.ts.map +1 -0
- package/dist/storage/pdpp-records/schema.js +153 -0
- package/dist/storage/pdpp-records/schema.js.map +1 -0
- package/dist/storage/pdpp-records/stream-declaration.d.ts +86 -0
- package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -0
- package/dist/storage/pdpp-records/stream-declaration.js +48 -0
- package/dist/storage/pdpp-records/stream-declaration.js.map +1 -0
- package/dist/storage/pdpp-records/sync-selection.d.ts +4 -0
- package/dist/storage/pdpp-records/sync-selection.d.ts.map +1 -0
- package/dist/storage/pdpp-records/sync-selection.js +37 -0
- package/dist/storage/pdpp-records/sync-selection.js.map +1 -0
- package/dist/storage/pdpp-records/types.d.ts +202 -0
- package/dist/storage/pdpp-records/types.d.ts.map +1 -0
- package/dist/storage/pdpp-records/types.js +38 -0
- package/dist/storage/pdpp-records/types.js.map +1 -0
- package/dist/stream-sync/artifacts.d.ts +31 -0
- package/dist/stream-sync/artifacts.d.ts.map +1 -0
- package/dist/stream-sync/artifacts.js +106 -0
- package/dist/stream-sync/artifacts.js.map +1 -0
- package/dist/stream-sync/blobs.d.ts +11 -0
- package/dist/stream-sync/blobs.d.ts.map +1 -0
- package/dist/stream-sync/blobs.js +34 -0
- package/dist/stream-sync/blobs.js.map +1 -0
- package/dist/stream-sync/crypto.d.ts +21 -0
- package/dist/stream-sync/crypto.d.ts.map +1 -0
- package/dist/stream-sync/crypto.js +45 -0
- package/dist/stream-sync/crypto.js.map +1 -0
- package/dist/stream-sync/home.d.ts +46 -0
- package/dist/stream-sync/home.d.ts.map +1 -0
- package/dist/stream-sync/home.js +37 -0
- package/dist/stream-sync/home.js.map +1 -0
- package/dist/stream-sync/index.d.ts +14 -0
- package/dist/stream-sync/index.d.ts.map +1 -0
- package/dist/stream-sync/index.js +14 -0
- package/dist/stream-sync/index.js.map +1 -0
- package/dist/stream-sync/intake.d.ts +165 -0
- package/dist/stream-sync/intake.d.ts.map +1 -0
- package/dist/stream-sync/intake.js +467 -0
- package/dist/stream-sync/intake.js.map +1 -0
- package/dist/stream-sync/io-barrier.d.ts +39 -0
- package/dist/stream-sync/io-barrier.d.ts.map +1 -0
- package/dist/stream-sync/io-barrier.js +130 -0
- package/dist/stream-sync/io-barrier.js.map +1 -0
- package/dist/stream-sync/memory-files.d.ts +6 -0
- package/dist/stream-sync/memory-files.d.ts.map +1 -0
- package/dist/stream-sync/memory-files.js +50 -0
- package/dist/stream-sync/memory-files.js.map +1 -0
- package/dist/stream-sync/ports.d.ts +134 -0
- package/dist/stream-sync/ports.d.ts.map +1 -0
- package/dist/stream-sync/ports.js +26 -0
- package/dist/stream-sync/ports.js.map +1 -0
- package/dist/stream-sync/publish-plan.d.ts +157 -0
- package/dist/stream-sync/publish-plan.d.ts.map +1 -0
- package/dist/stream-sync/publish-plan.js +212 -0
- package/dist/stream-sync/publish-plan.js.map +1 -0
- package/dist/stream-sync/registry.d.ts +19 -0
- package/dist/stream-sync/registry.d.ts.map +1 -0
- package/dist/stream-sync/registry.js +125 -0
- package/dist/stream-sync/registry.js.map +1 -0
- package/dist/stream-sync/scope-routing.d.ts +17 -0
- package/dist/stream-sync/scope-routing.d.ts.map +1 -0
- package/dist/stream-sync/scope-routing.js +24 -0
- package/dist/stream-sync/scope-routing.js.map +1 -0
- package/dist/stream-sync/spool.d.ts +69 -0
- package/dist/stream-sync/spool.d.ts.map +1 -0
- package/dist/stream-sync/spool.js +197 -0
- package/dist/stream-sync/spool.js.map +1 -0
- package/dist/stream-sync/writer-overlay.d.ts +19 -0
- package/dist/stream-sync/writer-overlay.d.ts.map +1 -0
- package/dist/stream-sync/writer-overlay.js +55 -0
- package/dist/stream-sync/writer-overlay.js.map +1 -0
- package/dist/stream-sync/writer.d.ts +404 -0
- package/dist/stream-sync/writer.d.ts.map +1 -0
- package/dist/stream-sync/writer.js +1994 -0
- package/dist/stream-sync/writer.js.map +1 -0
- package/dist/stream-sync-read/fold.d.ts +69 -0
- package/dist/stream-sync-read/fold.d.ts.map +1 -0
- package/dist/stream-sync-read/fold.js +83 -0
- package/dist/stream-sync-read/fold.js.map +1 -0
- package/dist/stream-sync-read/importer.d.ts +81 -0
- package/dist/stream-sync-read/importer.d.ts.map +1 -0
- package/dist/stream-sync-read/importer.js +226 -0
- package/dist/stream-sync-read/importer.js.map +1 -0
- package/dist/stream-sync-read/index.d.ts +8 -0
- package/dist/stream-sync-read/index.d.ts.map +1 -0
- package/dist/stream-sync-read/index.js +5 -0
- package/dist/stream-sync-read/index.js.map +1 -0
- package/dist/stream-sync-read/keys.d.ts +16 -0
- package/dist/stream-sync-read/keys.d.ts.map +1 -0
- package/dist/stream-sync-read/keys.js +48 -0
- package/dist/stream-sync-read/keys.js.map +1 -0
- package/dist/stream-sync-read/lines.d.ts +37 -0
- package/dist/stream-sync-read/lines.d.ts.map +1 -0
- package/dist/stream-sync-read/lines.js +98 -0
- package/dist/stream-sync-read/lines.js.map +1 -0
- package/dist/stream-sync-read/memory-files.d.ts +6 -0
- package/dist/stream-sync-read/memory-files.d.ts.map +1 -0
- package/dist/stream-sync-read/memory-files.js +34 -0
- package/dist/stream-sync-read/memory-files.js.map +1 -0
- package/dist/stream-sync-read/mirror.d.ts +80 -0
- package/dist/stream-sync-read/mirror.d.ts.map +1 -0
- package/dist/stream-sync-read/mirror.js +189 -0
- package/dist/stream-sync-read/mirror.js.map +1 -0
- package/dist/stream-sync-read/ports.d.ts +155 -0
- package/dist/stream-sync-read/ports.d.ts.map +1 -0
- package/dist/stream-sync-read/ports.js +9 -0
- package/dist/stream-sync-read/ports.js.map +1 -0
- package/dist/stream-sync-read/projection.d.ts +47 -0
- package/dist/stream-sync-read/projection.d.ts.map +1 -0
- package/dist/stream-sync-read/projection.js +338 -0
- package/dist/stream-sync-read/projection.js.map +1 -0
- package/dist/stream-sync-read/routing.d.ts +27 -0
- package/dist/stream-sync-read/routing.d.ts.map +1 -0
- package/dist/stream-sync-read/routing.js +49 -0
- package/dist/stream-sync-read/routing.js.map +1 -0
- package/dist/stream-sync-read/service-fixture.d.ts +94 -0
- package/dist/stream-sync-read/service-fixture.d.ts.map +1 -0
- package/dist/stream-sync-read/service-fixture.js +227 -0
- package/dist/stream-sync-read/service-fixture.js.map +1 -0
- package/dist/stream-sync-read/service.d.ts +260 -0
- package/dist/stream-sync-read/service.d.ts.map +1 -0
- package/dist/stream-sync-read/service.js +975 -0
- package/dist/stream-sync-read/service.js.map +1 -0
- package/dist/stream-sync-read/testing.d.ts +54 -0
- package/dist/stream-sync-read/testing.d.ts.map +1 -0
- package/dist/stream-sync-read/testing.js +80 -0
- package/dist/stream-sync-read/testing.js.map +1 -0
- package/dist/stream-sync-read/view-store.d.ts +98 -0
- package/dist/stream-sync-read/view-store.d.ts.map +1 -0
- package/dist/stream-sync-read/view-store.js +278 -0
- package/dist/stream-sync-read/view-store.js.map +1 -0
- package/dist/stream-sync-read/writer-rig.d.ts +122 -0
- package/dist/stream-sync-read/writer-rig.d.ts.map +1 -0
- package/dist/stream-sync-read/writer-rig.js +301 -0
- package/dist/stream-sync-read/writer-rig.js.map +1 -0
- package/dist/sync/data-point-feed.d.ts +3 -0
- package/dist/sync/data-point-feed.d.ts.map +1 -1
- package/dist/sync/data-point-feed.js +20 -1
- package/dist/sync/data-point-feed.js.map +1 -1
- package/dist/sync/delete-data-port.d.ts +19 -0
- package/dist/sync/delete-data-port.d.ts.map +1 -1
- package/dist/sync/delete-data-port.js +42 -9
- package/dist/sync/delete-data-port.js.map +1 -1
- package/dist/sync/engine/sync-manager.d.ts +21 -1
- package/dist/sync/engine/sync-manager.d.ts.map +1 -1
- package/dist/sync/engine/sync-manager.js +140 -11
- package/dist/sync/engine/sync-manager.js.map +1 -1
- package/dist/sync/index.d.ts +6 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +7 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/pdpp-import.d.ts +192 -0
- package/dist/sync/pdpp-import.d.ts.map +1 -0
- package/dist/sync/pdpp-import.js +441 -0
- package/dist/sync/pdpp-import.js.map +1 -0
- package/dist/sync/pending-blob-deletions.d.ts +18 -2
- package/dist/sync/pending-blob-deletions.d.ts.map +1 -1
- package/dist/sync/pending-blob-deletions.js +97 -23
- package/dist/sync/pending-blob-deletions.js.map +1 -1
- package/dist/sync/scope-deletions.d.ts +12 -0
- package/dist/sync/scope-deletions.d.ts.map +1 -1
- package/dist/sync/scope-deletions.js +99 -25
- package/dist/sync/scope-deletions.js.map +1 -1
- package/dist/sync/tombstone-finality.d.ts +36 -0
- package/dist/sync/tombstone-finality.d.ts.map +1 -0
- package/dist/sync/tombstone-finality.js +142 -0
- package/dist/sync/tombstone-finality.js.map +1 -0
- package/dist/sync/tombstone-resubmits.d.ts +61 -0
- package/dist/sync/tombstone-resubmits.d.ts.map +1 -0
- package/dist/sync/tombstone-resubmits.js +85 -0
- package/dist/sync/tombstone-resubmits.js.map +1 -0
- package/dist/sync/types.d.ts +10 -0
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/workers/delete.d.ts +54 -5
- package/dist/sync/workers/delete.d.ts.map +1 -1
- package/dist/sync/workers/delete.js +594 -170
- package/dist/sync/workers/delete.js.map +1 -1
- package/dist/sync/workers/download.d.ts +42 -1
- package/dist/sync/workers/download.d.ts.map +1 -1
- package/dist/sync/workers/download.js +344 -24
- package/dist/sync/workers/download.js.map +1 -1
- package/dist/sync/workers/lost-data-points.d.ts +38 -0
- package/dist/sync/workers/lost-data-points.d.ts.map +1 -0
- package/dist/sync/workers/lost-data-points.js +72 -0
- package/dist/sync/workers/lost-data-points.js.map +1 -0
- package/dist/sync/workers/upload.d.ts +27 -6
- package/dist/sync/workers/upload.d.ts.map +1 -1
- package/dist/sync/workers/upload.js +169 -274
- package/dist/sync/workers/upload.js.map +1 -1
- package/dist/test-utils/memory-storage.d.ts +1 -1
- package/dist/test-utils/memory-storage.d.ts.map +1 -1
- package/dist/test-utils/memory-storage.js +83 -17
- package/dist/test-utils/memory-storage.js.map +1 -1
- package/dist/write/attribution.d.ts.map +1 -1
- package/dist/write/attribution.js +8 -4
- package/dist/write/attribution.js.map +1 -1
- package/dist/write/route.d.ts.map +1 -1
- package/dist/write/route.js +9 -10
- package/dist/write/route.js.map +1 -1
- package/dist/write/session.d.ts.map +1 -1
- package/dist/write/session.js +13 -0
- package/dist/write/session.js.map +1 -1
- package/package.json +103 -3
|
@@ -0,0 +1,4512 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every entry cites source evidence in ./declarations. Published OCI profiles
|
|
3
|
+
* carry immutable artifact digests; where the OCI manifest pin is unavailable,
|
|
4
|
+
* the generated collection-profile output digest is recorded explicitly. No
|
|
5
|
+
* entry here uses a fabricated field. Every legacy field
|
|
6
|
+
* this phase cannot reconstruct is a documented gap (either the whole scope
|
|
7
|
+
* is absent from
|
|
8
|
+
* LEGACY_SCOPE_BINDINGS and appears in the report's gap table, or the field
|
|
9
|
+
* is listed in the binding's `lossy` array and called out in this file's
|
|
10
|
+
* comments plus the report).
|
|
11
|
+
*
|
|
12
|
+
* `pdppSource` is each declaration's own `connector_id`
|
|
13
|
+
* (`https://registry.pdpp.dev/connectors/<key>`), verified byte-identical
|
|
14
|
+
* per source below — never the short `connector_key` a Personal Server does
|
|
15
|
+
* not key sources by.
|
|
16
|
+
*
|
|
17
|
+
* `fieldsRead` and `primaryKey` name exactly the declared fields each
|
|
18
|
+
* binding depends on, per bound stream. The self-check
|
|
19
|
+
* (bindings-self-check.test.ts) compares both against the vendored
|
|
20
|
+
* declaration's own `schema.properties` / `primary_key` — deleting or
|
|
21
|
+
* renaming a field this binding reads, or pointing `primaryKey` at the
|
|
22
|
+
* wrong (but still declared) field, must fail that check (S1).
|
|
23
|
+
*/
|
|
24
|
+
function byStream(records, stream) {
|
|
25
|
+
return records.filter((r) => r.stream === stream).map((r) => r.data);
|
|
26
|
+
}
|
|
27
|
+
function isObjectRow(value) {
|
|
28
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
29
|
+
}
|
|
30
|
+
function ifDefined(record, sourceField, targetField) {
|
|
31
|
+
return record[sourceField] === undefined
|
|
32
|
+
? {}
|
|
33
|
+
: { [targetField]: record[sourceField] };
|
|
34
|
+
}
|
|
35
|
+
export function ouraInteger(value) {
|
|
36
|
+
return typeof value === "number" && Number.isFinite(value)
|
|
37
|
+
? Math.round(value)
|
|
38
|
+
: value;
|
|
39
|
+
}
|
|
40
|
+
function ifDefinedOuraInteger(record, sourceField, targetField) {
|
|
41
|
+
return record[sourceField] === undefined
|
|
42
|
+
? {}
|
|
43
|
+
: { [targetField]: ouraInteger(record[sourceField]) };
|
|
44
|
+
}
|
|
45
|
+
export function ouraContributors(value, integerFields) {
|
|
46
|
+
if (!isObjectRow(value))
|
|
47
|
+
return undefined;
|
|
48
|
+
const contributors = { ...value };
|
|
49
|
+
for (const field of integerFields) {
|
|
50
|
+
if (Object.hasOwn(contributors, field)) {
|
|
51
|
+
contributors[field] = ouraInteger(contributors[field]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return contributors;
|
|
55
|
+
}
|
|
56
|
+
export function withOuraContributors(value, integerFields) {
|
|
57
|
+
const contributors = ouraContributors(value, integerFields);
|
|
58
|
+
return contributors ? { contributors } : {};
|
|
59
|
+
}
|
|
60
|
+
const OURA_ACTIVITY_CONTRIBUTOR_INTEGERS = [
|
|
61
|
+
"meet_daily_targets",
|
|
62
|
+
"move_every_hour",
|
|
63
|
+
"recovery_time",
|
|
64
|
+
"stay_active",
|
|
65
|
+
"training_frequency",
|
|
66
|
+
"training_volume",
|
|
67
|
+
];
|
|
68
|
+
const OURA_READINESS_CONTRIBUTOR_INTEGERS = [
|
|
69
|
+
"activity_balance",
|
|
70
|
+
"body_temperature",
|
|
71
|
+
"hrv_balance",
|
|
72
|
+
"previous_day_activity",
|
|
73
|
+
"previous_night",
|
|
74
|
+
"recovery_index",
|
|
75
|
+
"resting_heart_rate",
|
|
76
|
+
"sleep_balance",
|
|
77
|
+
];
|
|
78
|
+
export const OURA_SLEEP_CONTRIBUTOR_INTEGERS = [
|
|
79
|
+
"deep_sleep",
|
|
80
|
+
"efficiency",
|
|
81
|
+
"latency",
|
|
82
|
+
"rem_sleep",
|
|
83
|
+
"restfulness",
|
|
84
|
+
"timing",
|
|
85
|
+
"total_sleep",
|
|
86
|
+
];
|
|
87
|
+
function missingStream(scope, expectedStream) {
|
|
88
|
+
return {
|
|
89
|
+
ok: false,
|
|
90
|
+
error: { kind: "missing_stream", scope, expectedStream },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A stream the caller never fetched must be a `missing_stream` error, not
|
|
95
|
+
* silently indistinguishable from "fetched, zero rows" (a valid state for a
|
|
96
|
+
* list-shaped stream). "Fetched" is expressed explicitly via
|
|
97
|
+
* `options.fetchedStreams` — the set of streams the caller actually asked
|
|
98
|
+
* the Personal Server for — independent of how many records came back. A
|
|
99
|
+
* stream in `fetchedStreams` with zero matching `records` is a real, empty
|
|
100
|
+
* result (N-B1), not an error.
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* The timestamp a binding stamps on generated fields (`fetched_at`,
|
|
104
|
+
* `fetchedAt`, a null memory `created_at`). A caller that needs the same
|
|
105
|
+
* stored records to project to the same bytes passes `options.now`; without
|
|
106
|
+
* it the wall clock is used, as the legacy connectors did per run.
|
|
107
|
+
*/
|
|
108
|
+
function projectionTime(options) {
|
|
109
|
+
return options.now ?? new Date().toISOString();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Counts source rows a binding leaves out and turns them into one
|
|
113
|
+
* `records_dropped` diagnostic per (stream, reason). Each row is counted
|
|
114
|
+
* once, under the first reason it failed, so counts sum to distinct rows.
|
|
115
|
+
*/
|
|
116
|
+
class DroppedRows {
|
|
117
|
+
scope;
|
|
118
|
+
counts = new Map();
|
|
119
|
+
constructor(scope) {
|
|
120
|
+
this.scope = scope;
|
|
121
|
+
}
|
|
122
|
+
add(stream, reason, count = 1) {
|
|
123
|
+
if (count <= 0)
|
|
124
|
+
return;
|
|
125
|
+
const key = JSON.stringify([stream, reason]);
|
|
126
|
+
this.counts.set(key, (this.counts.get(key) ?? 0) + count);
|
|
127
|
+
}
|
|
128
|
+
diagnostics() {
|
|
129
|
+
return [...this.counts].map(([key, count]) => {
|
|
130
|
+
const [stream, reason] = JSON.parse(key);
|
|
131
|
+
return {
|
|
132
|
+
kind: "records_dropped",
|
|
133
|
+
scope: this.scope,
|
|
134
|
+
stream,
|
|
135
|
+
count,
|
|
136
|
+
reasons: [reason],
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** `{ diagnostics }` when there are any, else nothing, for spreading into a result. */
|
|
142
|
+
function withDiagnostics(diagnostics) {
|
|
143
|
+
return diagnostics.length > 0 ? { diagnostics } : {};
|
|
144
|
+
}
|
|
145
|
+
export const OURA_BAD_DAY = "Oura day is missing or not a YYYY-MM-DD date";
|
|
146
|
+
export const OURA_BAD_SCORE = "Oura score is absent or does not round to an integer from 0 to 100";
|
|
147
|
+
/** A real calendar date in the legacy `format: date` shape. */
|
|
148
|
+
export function isCalendarDay(value) {
|
|
149
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const parsed = new Date(`${value}T00:00:00.000Z`);
|
|
153
|
+
return (!Number.isNaN(parsed.getTime()) && parsed.toISOString().startsWith(value));
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The legacy Oura daily schemas require `score`, typed integer 0-100 or null.
|
|
157
|
+
* OpenPet decodes it as `*int`, so null is valid while fractional numbers are
|
|
158
|
+
* not. Rounding happens at the projection boundary.
|
|
159
|
+
*/
|
|
160
|
+
function isOuraScore(value) {
|
|
161
|
+
if (value === null)
|
|
162
|
+
return true;
|
|
163
|
+
return (typeof value === "number" &&
|
|
164
|
+
Number.isFinite(value) &&
|
|
165
|
+
Math.round(value) >= 0 &&
|
|
166
|
+
Math.round(value) <= 100);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Oura rows the legacy schema cannot hold are left out and counted, never
|
|
170
|
+
* emitted with an impossible day or without the required score. A null score
|
|
171
|
+
* is valid under the frozen legacy schema.
|
|
172
|
+
* `scoreField` names the source field that becomes the legacy `score`
|
|
173
|
+
* (per row, or undefined for a row that produces no daily score). The
|
|
174
|
+
* caller decides what an all-dropped stream means.
|
|
175
|
+
*/
|
|
176
|
+
export function partitionOuraRows(scope, stream, rows, scoreField) {
|
|
177
|
+
const dropped = new DroppedRows(scope);
|
|
178
|
+
const valid = rows.filter((row) => {
|
|
179
|
+
const field = scoreField(row);
|
|
180
|
+
if (!isCalendarDay(row.day))
|
|
181
|
+
dropped.add(stream, OURA_BAD_DAY);
|
|
182
|
+
else if (field !== undefined && !isOuraScore(row[field]))
|
|
183
|
+
dropped.add(stream, OURA_BAD_SCORE);
|
|
184
|
+
else
|
|
185
|
+
return true;
|
|
186
|
+
return false;
|
|
187
|
+
});
|
|
188
|
+
return { rows: valid, diagnostics: dropped.diagnostics() };
|
|
189
|
+
}
|
|
190
|
+
function requireStreams(scope, options, expectedStreams) {
|
|
191
|
+
for (const stream of expectedStreams) {
|
|
192
|
+
if (!options.fetchedStreams.includes(stream)) {
|
|
193
|
+
return missingStream(scope, stream);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Legacy connectors that hit a missing/null value at the pin emit `''`
|
|
200
|
+
* (verified per call site: linkedin-playwright.js `pos.title || ''`,
|
|
201
|
+
* `edu.grade || ''`; amazon-playwright.js `price: ''`; shop-playwright.js
|
|
202
|
+
* DOM-fallback `orderNumber: ''`). A legacy-typed string field therefore
|
|
203
|
+
* defaults to `''`, matching the pinned connector's own behavior, so the
|
|
204
|
+
* projected payload never fails the legacy schema on a null/undefined PDPP
|
|
205
|
+
* field. This is real, cited legacy behavior, not an invented default.
|
|
206
|
+
*/
|
|
207
|
+
function orEmptyString(value) {
|
|
208
|
+
return typeof value === "string" ? value : "";
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Legacy connectors that hit a missing/null count emit `0`
|
|
212
|
+
* (linkedin-playwright.js `sk.endorsementCount || sk.endorsements || 0`).
|
|
213
|
+
*/
|
|
214
|
+
function orZero(value) {
|
|
215
|
+
return typeof value === "number" ? value : 0;
|
|
216
|
+
}
|
|
217
|
+
function youtubeStringOrNull(value) {
|
|
218
|
+
return typeof value === "string" ? value : null;
|
|
219
|
+
}
|
|
220
|
+
function youtubeRequiredString(value) {
|
|
221
|
+
return typeof value === "string" && value.trim() ? value : undefined;
|
|
222
|
+
}
|
|
223
|
+
function youtubeLegacyProjection(scope, skipped, fields, payload) {
|
|
224
|
+
return {
|
|
225
|
+
ok: true,
|
|
226
|
+
payload,
|
|
227
|
+
...(skipped > 0
|
|
228
|
+
? {
|
|
229
|
+
diagnostics: [
|
|
230
|
+
{
|
|
231
|
+
kind: "records_skipped",
|
|
232
|
+
scope,
|
|
233
|
+
count: skipped,
|
|
234
|
+
missingFields: fields,
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
}
|
|
238
|
+
: {}),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const youtubeProvenance = [
|
|
242
|
+
{
|
|
243
|
+
kind: "collection-profile",
|
|
244
|
+
ref: "https://github.com/PDP-Connect/data-connectors/tree/fe871c128acd801849551e1d75db0b570b5279df/connectors/youtube",
|
|
245
|
+
digest: "sha256:bc6bcb2704bd52d9c002eb0c1810bceb15c4a07469f07a326ff08553b3b5e41f",
|
|
246
|
+
path: "declarations/youtube.collection-profile.json#streams[name=profile,subscriptions,playlists,playlist_items,likes,watch_later,watch_history]",
|
|
247
|
+
},
|
|
248
|
+
];
|
|
249
|
+
const youtubeProfile = {
|
|
250
|
+
scope: "youtube.profile",
|
|
251
|
+
pdppSource: "https://registry.pdpp.dev/connectors/youtube",
|
|
252
|
+
pdppStreams: ["profile"],
|
|
253
|
+
legacySchemaPath: "youtube.profile.json",
|
|
254
|
+
fieldsRead: {
|
|
255
|
+
profile: [
|
|
256
|
+
"id",
|
|
257
|
+
"channel_url",
|
|
258
|
+
"title",
|
|
259
|
+
"handle",
|
|
260
|
+
"email",
|
|
261
|
+
"joined_at",
|
|
262
|
+
"avatar_url",
|
|
263
|
+
"description",
|
|
264
|
+
"country",
|
|
265
|
+
"subscriber_count",
|
|
266
|
+
"view_count",
|
|
267
|
+
"video_count",
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
primaryKey: { profile: ["id"] },
|
|
271
|
+
lossy: [
|
|
272
|
+
"Browser-visible profile values map to the retained legacy fields; values absent from the signed-in page remain null.",
|
|
273
|
+
],
|
|
274
|
+
provenance: youtubeProvenance,
|
|
275
|
+
project(records, options) {
|
|
276
|
+
const guard = requireStreams("youtube.profile", options, ["profile"]);
|
|
277
|
+
if (guard)
|
|
278
|
+
return guard;
|
|
279
|
+
const profile = byStream(records, "profile")[0];
|
|
280
|
+
if (!profile)
|
|
281
|
+
return { ok: true, payload: {} };
|
|
282
|
+
const channelId = youtubeRequiredString(profile.id);
|
|
283
|
+
if (!channelId)
|
|
284
|
+
return {
|
|
285
|
+
ok: false,
|
|
286
|
+
error: {
|
|
287
|
+
kind: "invalid_value",
|
|
288
|
+
scope: "youtube.profile",
|
|
289
|
+
reason: "YouTube profile is missing its declared id",
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
return youtubeLegacyProjection("youtube.profile", 0, [], {
|
|
293
|
+
email: youtubeStringOrNull(profile.email),
|
|
294
|
+
channelUrl: youtubeStringOrNull(profile.channel_url),
|
|
295
|
+
handle: youtubeStringOrNull(profile.handle),
|
|
296
|
+
joinedDate: youtubeStringOrNull(profile.joined_at),
|
|
297
|
+
channelTitle: youtubeStringOrNull(profile.title),
|
|
298
|
+
channelId,
|
|
299
|
+
avatarUrl: youtubeStringOrNull(profile.avatar_url),
|
|
300
|
+
description: youtubeStringOrNull(profile.description),
|
|
301
|
+
country: youtubeStringOrNull(profile.country),
|
|
302
|
+
subscriberCount: typeof profile.subscriber_count === "number"
|
|
303
|
+
? profile.subscriber_count
|
|
304
|
+
: null,
|
|
305
|
+
viewCount: typeof profile.view_count === "number" ? profile.view_count : null,
|
|
306
|
+
videoCount: typeof profile.video_count === "number" ? profile.video_count : null,
|
|
307
|
+
});
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
const youtubeSubscriptions = {
|
|
311
|
+
scope: "youtube.subscriptions",
|
|
312
|
+
pdppSource: youtubeProfile.pdppSource,
|
|
313
|
+
pdppStreams: ["subscriptions"],
|
|
314
|
+
legacySchemaPath: "youtube.subscriptions.json",
|
|
315
|
+
fieldsRead: {
|
|
316
|
+
subscriptions: [
|
|
317
|
+
"channel_id",
|
|
318
|
+
"channel_title",
|
|
319
|
+
"channel_url",
|
|
320
|
+
"handle",
|
|
321
|
+
"avatar_url",
|
|
322
|
+
"subscriber_count",
|
|
323
|
+
"subscriber_count_text",
|
|
324
|
+
"description",
|
|
325
|
+
"is_verified",
|
|
326
|
+
"notifications",
|
|
327
|
+
],
|
|
328
|
+
},
|
|
329
|
+
primaryKey: { subscriptions: ["id"] },
|
|
330
|
+
lossy: [
|
|
331
|
+
"Rows without legacy-required channelTitle/channelUrl or required notification booleans are skipped and reported.",
|
|
332
|
+
"subscriberCountText is null when the page rendered no count text; the connector omits subscriber_count_text then, and legacy's own default is null.",
|
|
333
|
+
],
|
|
334
|
+
provenance: youtubeProvenance,
|
|
335
|
+
project(records, options) {
|
|
336
|
+
const guard = requireStreams("youtube.subscriptions", options, [
|
|
337
|
+
"subscriptions",
|
|
338
|
+
]);
|
|
339
|
+
if (guard)
|
|
340
|
+
return guard;
|
|
341
|
+
let skipped = 0;
|
|
342
|
+
const missing = new Set();
|
|
343
|
+
const subscriptions = byStream(records, "subscriptions").flatMap((row) => {
|
|
344
|
+
const channelTitle = youtubeRequiredString(row.channel_title);
|
|
345
|
+
const channelUrl = youtubeRequiredString(row.channel_url);
|
|
346
|
+
if (!channelTitle ||
|
|
347
|
+
!channelUrl ||
|
|
348
|
+
typeof row.is_verified !== "boolean" ||
|
|
349
|
+
typeof row.notifications !== "boolean") {
|
|
350
|
+
skipped++;
|
|
351
|
+
if (!channelTitle)
|
|
352
|
+
missing.add("subscriptions.channel_title");
|
|
353
|
+
if (!channelUrl)
|
|
354
|
+
missing.add("subscriptions.channel_url");
|
|
355
|
+
if (typeof row.is_verified !== "boolean")
|
|
356
|
+
missing.add("subscriptions.is_verified");
|
|
357
|
+
if (typeof row.notifications !== "boolean")
|
|
358
|
+
missing.add("subscriptions.notifications");
|
|
359
|
+
return [];
|
|
360
|
+
}
|
|
361
|
+
return [
|
|
362
|
+
{
|
|
363
|
+
channelTitle,
|
|
364
|
+
channelUrl,
|
|
365
|
+
handle: youtubeStringOrNull(row.handle),
|
|
366
|
+
channelId: youtubeStringOrNull(row.channel_id),
|
|
367
|
+
avatarUrl: youtubeStringOrNull(row.avatar_url),
|
|
368
|
+
subscriberCountText: youtubeRequiredString(row.subscriber_count_text) ?? null,
|
|
369
|
+
subscriberCount: typeof row.subscriber_count === "number"
|
|
370
|
+
? row.subscriber_count
|
|
371
|
+
: null,
|
|
372
|
+
description: youtubeStringOrNull(row.description),
|
|
373
|
+
isVerified: row.is_verified,
|
|
374
|
+
isBellNotification: row.notifications,
|
|
375
|
+
},
|
|
376
|
+
];
|
|
377
|
+
});
|
|
378
|
+
return youtubeLegacyProjection("youtube.subscriptions", skipped, [...missing], { subscriptions });
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
const youtubePlaylists = {
|
|
382
|
+
scope: "youtube.playlists",
|
|
383
|
+
pdppSource: youtubeProfile.pdppSource,
|
|
384
|
+
pdppStreams: ["playlists"],
|
|
385
|
+
legacySchemaPath: "youtube.playlists.json",
|
|
386
|
+
fieldsRead: {
|
|
387
|
+
playlists: [
|
|
388
|
+
"id",
|
|
389
|
+
"url",
|
|
390
|
+
"title",
|
|
391
|
+
"owner",
|
|
392
|
+
"owner_url",
|
|
393
|
+
"visibility",
|
|
394
|
+
"video_count",
|
|
395
|
+
"view_count",
|
|
396
|
+
],
|
|
397
|
+
},
|
|
398
|
+
primaryKey: { playlists: ["id"] },
|
|
399
|
+
lossy: [
|
|
400
|
+
"Rows without a legacy-required URL are skipped and reported. Browser collection is a bounded snapshot.",
|
|
401
|
+
],
|
|
402
|
+
provenance: youtubeProvenance,
|
|
403
|
+
project(records, options) {
|
|
404
|
+
const guard = requireStreams("youtube.playlists", options, ["playlists"]);
|
|
405
|
+
if (guard)
|
|
406
|
+
return guard;
|
|
407
|
+
let skipped = 0;
|
|
408
|
+
const playlists = byStream(records, "playlists").flatMap((row) => {
|
|
409
|
+
const playlistId = youtubeRequiredString(row.id);
|
|
410
|
+
const url = youtubeRequiredString(row.url);
|
|
411
|
+
if (!playlistId || !url) {
|
|
412
|
+
skipped++;
|
|
413
|
+
return [];
|
|
414
|
+
}
|
|
415
|
+
const privacy = typeof row.visibility === "string" &&
|
|
416
|
+
["Public", "Private", "Unlisted"].includes(row.visibility)
|
|
417
|
+
? row.visibility
|
|
418
|
+
: null;
|
|
419
|
+
return [
|
|
420
|
+
{
|
|
421
|
+
playlistId,
|
|
422
|
+
url,
|
|
423
|
+
title: youtubeStringOrNull(row.title),
|
|
424
|
+
owner: youtubeStringOrNull(row.owner),
|
|
425
|
+
ownerUrl: youtubeStringOrNull(row.owner_url),
|
|
426
|
+
privacy,
|
|
427
|
+
videoCount: typeof row.video_count === "number" ? row.video_count : null,
|
|
428
|
+
views: typeof row.view_count === "number" ? row.view_count : null,
|
|
429
|
+
},
|
|
430
|
+
];
|
|
431
|
+
});
|
|
432
|
+
return youtubeLegacyProjection("youtube.playlists", skipped, skipped ? ["playlists.id", "playlists.url"] : [], { playlists });
|
|
433
|
+
},
|
|
434
|
+
};
|
|
435
|
+
function youtubeVideo(row) {
|
|
436
|
+
const videoUrl = youtubeRequiredString(row.video_url);
|
|
437
|
+
const videoTitle = youtubeRequiredString(row.video_title);
|
|
438
|
+
if (!videoUrl || !videoTitle)
|
|
439
|
+
return undefined;
|
|
440
|
+
const duration = typeof row.duration_seconds === "number" ? row.duration_seconds : null;
|
|
441
|
+
const durationText = duration === null
|
|
442
|
+
? null
|
|
443
|
+
: duration >= 3600
|
|
444
|
+
? `${Math.floor(duration / 3600)}:${String(Math.floor((duration % 3600) / 60)).padStart(2, "0")}:${String(duration % 60).padStart(2, "0")}`
|
|
445
|
+
: `${Math.floor(duration / 60)}:${String(duration % 60).padStart(2, "0")}`;
|
|
446
|
+
return {
|
|
447
|
+
videoId: youtubeStringOrNull(row.video_id),
|
|
448
|
+
videoUrl,
|
|
449
|
+
videoTitle,
|
|
450
|
+
channelTitle: youtubeStringOrNull(row.channel_title),
|
|
451
|
+
channelUrl: youtubeStringOrNull(row.channel_url),
|
|
452
|
+
durationText,
|
|
453
|
+
thumbnailUrl: youtubeStringOrNull(row.thumbnail_url),
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
const youtubePlaylistItems = {
|
|
457
|
+
scope: "youtube.playlistItems",
|
|
458
|
+
pdppSource: youtubeProfile.pdppSource,
|
|
459
|
+
pdppStreams: ["playlist_items"],
|
|
460
|
+
legacySchemaPath: "youtube.playlistItems.json",
|
|
461
|
+
fieldsRead: {
|
|
462
|
+
playlist_items: [
|
|
463
|
+
"playlist_id",
|
|
464
|
+
"video_id",
|
|
465
|
+
"video_url",
|
|
466
|
+
"video_title",
|
|
467
|
+
"channel_title",
|
|
468
|
+
"channel_url",
|
|
469
|
+
"duration_seconds",
|
|
470
|
+
"thumbnail_url",
|
|
471
|
+
],
|
|
472
|
+
},
|
|
473
|
+
primaryKey: { playlist_items: ["id"] },
|
|
474
|
+
lossy: [
|
|
475
|
+
"Playlist headers are unavailable on item rows. Records missing required videoTitle/videoUrl or playlist_id are skipped and reported. duration_seconds is formatted as m:ss.",
|
|
476
|
+
],
|
|
477
|
+
provenance: youtubeProvenance,
|
|
478
|
+
project(records, options) {
|
|
479
|
+
const guard = requireStreams("youtube.playlistItems", options, [
|
|
480
|
+
"playlist_items",
|
|
481
|
+
]);
|
|
482
|
+
if (guard)
|
|
483
|
+
return guard;
|
|
484
|
+
const grouped = new Map();
|
|
485
|
+
let skipped = 0;
|
|
486
|
+
for (const row of byStream(records, "playlist_items")) {
|
|
487
|
+
const playlistId = youtubeRequiredString(row.playlist_id);
|
|
488
|
+
const video = youtubeVideo(row);
|
|
489
|
+
if (!playlistId || !video) {
|
|
490
|
+
skipped++;
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
const group = grouped.get(playlistId) ?? { playlistId, items: [] };
|
|
494
|
+
group.items.push(video);
|
|
495
|
+
grouped.set(playlistId, group);
|
|
496
|
+
}
|
|
497
|
+
return youtubeLegacyProjection("youtube.playlistItems", skipped, skipped
|
|
498
|
+
? [
|
|
499
|
+
"playlist_items.playlist_id",
|
|
500
|
+
"playlist_items.video_url",
|
|
501
|
+
"playlist_items.video_title",
|
|
502
|
+
]
|
|
503
|
+
: [], {
|
|
504
|
+
playlists: [...grouped.values()].map((group) => ({
|
|
505
|
+
...group,
|
|
506
|
+
playlistTitle: null,
|
|
507
|
+
playlistUrl: null,
|
|
508
|
+
})),
|
|
509
|
+
});
|
|
510
|
+
},
|
|
511
|
+
};
|
|
512
|
+
function youtubeNamedVideos(scope, stream, key) {
|
|
513
|
+
return {
|
|
514
|
+
scope,
|
|
515
|
+
pdppSource: youtubeProfile.pdppSource,
|
|
516
|
+
pdppStreams: [stream],
|
|
517
|
+
legacySchemaPath: `${scope}.json`,
|
|
518
|
+
fieldsRead: {
|
|
519
|
+
[stream]: [
|
|
520
|
+
"video_id",
|
|
521
|
+
"video_url",
|
|
522
|
+
"video_title",
|
|
523
|
+
"channel_title",
|
|
524
|
+
"channel_url",
|
|
525
|
+
"duration_seconds",
|
|
526
|
+
"thumbnail_url",
|
|
527
|
+
],
|
|
528
|
+
},
|
|
529
|
+
primaryKey: { [stream]: ["id"] },
|
|
530
|
+
lossy: [
|
|
531
|
+
"Legacy requires videoTitle and videoUrl; incomplete browser rows are skipped and reported.",
|
|
532
|
+
],
|
|
533
|
+
provenance: youtubeProvenance,
|
|
534
|
+
project(records, options) {
|
|
535
|
+
const guard = requireStreams(scope, options, [stream]);
|
|
536
|
+
if (guard)
|
|
537
|
+
return guard;
|
|
538
|
+
let skipped = 0;
|
|
539
|
+
const videos = byStream(records, stream).flatMap((row) => {
|
|
540
|
+
const video = youtubeVideo(row);
|
|
541
|
+
if (!video) {
|
|
542
|
+
skipped++;
|
|
543
|
+
return [];
|
|
544
|
+
}
|
|
545
|
+
return [video];
|
|
546
|
+
});
|
|
547
|
+
return youtubeLegacyProjection(scope, skipped, skipped ? [`${stream}.video_url`, `${stream}.video_title`] : [], { [key]: videos });
|
|
548
|
+
},
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
const youtubeLikes = youtubeNamedVideos("youtube.likes", "likes", "likedVideos");
|
|
552
|
+
const youtubeWatchLater = youtubeNamedVideos("youtube.watchLater", "watch_later", "watchLater");
|
|
553
|
+
const youtubeHistory = {
|
|
554
|
+
scope: "youtube.history",
|
|
555
|
+
pdppSource: youtubeProfile.pdppSource,
|
|
556
|
+
pdppStreams: ["watch_history"],
|
|
557
|
+
legacySchemaPath: "youtube.history.json",
|
|
558
|
+
fieldsRead: {
|
|
559
|
+
watch_history: [
|
|
560
|
+
"position",
|
|
561
|
+
"watched_date",
|
|
562
|
+
"watched_date_label",
|
|
563
|
+
"video_id",
|
|
564
|
+
"video_url",
|
|
565
|
+
"video_title",
|
|
566
|
+
"channel_title",
|
|
567
|
+
"channel_url",
|
|
568
|
+
"view_count",
|
|
569
|
+
"views_text",
|
|
570
|
+
"description",
|
|
571
|
+
],
|
|
572
|
+
},
|
|
573
|
+
primaryKey: { watch_history: ["id"] },
|
|
574
|
+
lossy: [
|
|
575
|
+
"Preserves page order by position and caps output at 50 entries. watchedAt carries watched_date (YYYY-MM-DD, null unchanged) at day precision only; no timestamp is inferred. watchedAtText carries watched_date_label (the browser section header as shown, as legacy emitted it); it falls back to watched_date only when the label is absent or empty. views_text is preserved when present; otherwise integer view_count is rendered as '<count> views'. Rows without required videoUrl are skipped and reported. Missing positions fail because page order cannot be preserved.",
|
|
576
|
+
],
|
|
577
|
+
provenance: youtubeProvenance,
|
|
578
|
+
project(records, options) {
|
|
579
|
+
const guard = requireStreams("youtube.history", options, ["watch_history"]);
|
|
580
|
+
if (guard)
|
|
581
|
+
return guard;
|
|
582
|
+
let skipped = 0;
|
|
583
|
+
const sourceRows = byStream(records, "watch_history");
|
|
584
|
+
if (sourceRows.some((row) => typeof row.position !== "number" || !Number.isInteger(row.position))) {
|
|
585
|
+
return {
|
|
586
|
+
ok: false,
|
|
587
|
+
error: {
|
|
588
|
+
kind: "invalid_value",
|
|
589
|
+
scope: "youtube.history",
|
|
590
|
+
reason: "YouTube browser history is missing an integer position; page order cannot be preserved",
|
|
591
|
+
},
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
const rows = sourceRows
|
|
595
|
+
.flatMap((row) => {
|
|
596
|
+
const videoUrl = youtubeRequiredString(row.video_url);
|
|
597
|
+
if (!videoUrl) {
|
|
598
|
+
skipped++;
|
|
599
|
+
return [];
|
|
600
|
+
}
|
|
601
|
+
const viewCount = typeof row.view_count === "number" ? row.view_count : null;
|
|
602
|
+
const viewsText = youtubeRequiredString(row.views_text);
|
|
603
|
+
return [
|
|
604
|
+
{
|
|
605
|
+
watchedAt: youtubeStringOrNull(row.watched_date),
|
|
606
|
+
watchedAtText: youtubeRequiredString(row.watched_date_label) ??
|
|
607
|
+
youtubeStringOrNull(row.watched_date),
|
|
608
|
+
videoId: youtubeStringOrNull(row.video_id),
|
|
609
|
+
videoUrl,
|
|
610
|
+
videoTitle: youtubeStringOrNull(row.video_title),
|
|
611
|
+
channelTitle: youtubeStringOrNull(row.channel_title),
|
|
612
|
+
views: viewsText ?? (viewCount === null ? null : `${viewCount} views`),
|
|
613
|
+
description: youtubeStringOrNull(row.description),
|
|
614
|
+
_position: row.position,
|
|
615
|
+
},
|
|
616
|
+
];
|
|
617
|
+
})
|
|
618
|
+
.sort((a, b) => a._position - b._position);
|
|
619
|
+
const history = rows
|
|
620
|
+
.slice(0, 50)
|
|
621
|
+
.map(({ _position: _ignored, ...row }) => row);
|
|
622
|
+
return youtubeLegacyProjection("youtube.history", skipped, skipped ? ["watch_history.video_url"] : [], { timeWindow: "top 50 most recent items", history });
|
|
623
|
+
},
|
|
624
|
+
};
|
|
625
|
+
function isNonEmptyString(value) {
|
|
626
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
627
|
+
}
|
|
628
|
+
function isOptionalString(value) {
|
|
629
|
+
return value === undefined || value === null || typeof value === "string";
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Validates that a string is a valid ISO 8601 date-time. Rejects invalid
|
|
633
|
+
* formats so only valid date-times pass through to the payload (F5).
|
|
634
|
+
*/
|
|
635
|
+
function isValidIso8601DateTime(value) {
|
|
636
|
+
if (typeof value !== "string")
|
|
637
|
+
return false;
|
|
638
|
+
const date = new Date(value);
|
|
639
|
+
// The string is valid if it parses to a valid date (not NaN).
|
|
640
|
+
return !isNaN(date.getTime());
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Reformats an ISO-8601 date/date-time string to amazon-playwright.js's
|
|
644
|
+
* captured legacy shape, `"March 5, 2024"` (verified: the connector's own
|
|
645
|
+
* regex only ever matches `MonthName D, YYYY`,
|
|
646
|
+
* connectors/amazon/amazon-playwright.js:184-187 at the pin). Returns `''`
|
|
647
|
+
* (the connector's own no-match fallback) for anything that does not parse
|
|
648
|
+
* as a date, rather than passing through a shape the legacy schema does not
|
|
649
|
+
* expect.
|
|
650
|
+
*/
|
|
651
|
+
const MONTH_NAMES = [
|
|
652
|
+
"January",
|
|
653
|
+
"February",
|
|
654
|
+
"March",
|
|
655
|
+
"April",
|
|
656
|
+
"May",
|
|
657
|
+
"June",
|
|
658
|
+
"July",
|
|
659
|
+
"August",
|
|
660
|
+
"September",
|
|
661
|
+
"October",
|
|
662
|
+
"November",
|
|
663
|
+
"December",
|
|
664
|
+
];
|
|
665
|
+
function toLegacyLongDate(value) {
|
|
666
|
+
if (typeof value !== "string") {
|
|
667
|
+
return "";
|
|
668
|
+
}
|
|
669
|
+
const d = new Date(value);
|
|
670
|
+
if (Number.isNaN(d.getTime())) {
|
|
671
|
+
return "";
|
|
672
|
+
}
|
|
673
|
+
return `${MONTH_NAMES[d.getUTCMonth()]} ${d.getUTCDate()}, ${d.getUTCFullYear()}`;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Reformats start/end date strings to linkedin-playwright.js's captured
|
|
677
|
+
* legacy `dates` shape for experience and education, e.g.
|
|
678
|
+
* `"1/2024 - Present"` (verified: `extractTimePeriod`,
|
|
679
|
+
* connectors/linkedin/linkedin-playwright.js:129-145 — `(month + '/' ) +
|
|
680
|
+
* year` per side, joined by `' - '`, `'Present'` for a missing end, then
|
|
681
|
+
* `.trim()`-ed so a missing start reads `"- Present"` / `"- 3/2020"`). The
|
|
682
|
+
* signed LinkedIn 0.3.1 declaration uses partial dates (`YYYY` or `YYYY-MM`),
|
|
683
|
+
* so year-only values keep their source precision. Full ISO values keep the
|
|
684
|
+
* earlier month/year behavior.
|
|
685
|
+
*/
|
|
686
|
+
function toLegacyTimePeriod(start, end) {
|
|
687
|
+
const part = (value) => {
|
|
688
|
+
if (typeof value !== "string") {
|
|
689
|
+
return "";
|
|
690
|
+
}
|
|
691
|
+
const yearOnly = value.match(/^(\d{4})$/);
|
|
692
|
+
if (yearOnly) {
|
|
693
|
+
return yearOnly[1];
|
|
694
|
+
}
|
|
695
|
+
const yearMonth = value.match(/^(\d{4})-(\d{2})$/);
|
|
696
|
+
if (yearMonth) {
|
|
697
|
+
return `${Number(yearMonth[2])}/${yearMonth[1]}`;
|
|
698
|
+
}
|
|
699
|
+
const d = new Date(value);
|
|
700
|
+
if (Number.isNaN(d.getTime())) {
|
|
701
|
+
return "";
|
|
702
|
+
}
|
|
703
|
+
return `${d.getUTCMonth() + 1}/${d.getUTCFullYear()}`;
|
|
704
|
+
};
|
|
705
|
+
const startPart = part(start);
|
|
706
|
+
const endPart = typeof end === "string" ? part(end) : "";
|
|
707
|
+
return `${startPart} - ${endPart || "Present"}`.trim();
|
|
708
|
+
}
|
|
709
|
+
// ---------------------------------------------------------------------------
|
|
710
|
+
// meta (instagram)
|
|
711
|
+
// declarations/meta.collection-profile.json, streams "profile" and "posts".
|
|
712
|
+
// connector_id (verified byte-identical to the vendored declaration):
|
|
713
|
+
// https://registry.pdpp.dev/connectors/meta
|
|
714
|
+
// ---------------------------------------------------------------------------
|
|
715
|
+
const instagramProfile = {
|
|
716
|
+
scope: "instagram.profile",
|
|
717
|
+
pdppSource: "https://registry.pdpp.dev/connectors/meta",
|
|
718
|
+
pdppStreams: ["profile"],
|
|
719
|
+
legacySchemaPath: "instagram.profile.json",
|
|
720
|
+
fieldsRead: {
|
|
721
|
+
profile: [
|
|
722
|
+
"username",
|
|
723
|
+
"full_name",
|
|
724
|
+
"bio",
|
|
725
|
+
"profile_pic_url",
|
|
726
|
+
"external_url",
|
|
727
|
+
"follower_count",
|
|
728
|
+
"following_count",
|
|
729
|
+
"post_count",
|
|
730
|
+
"is_private",
|
|
731
|
+
"is_verified",
|
|
732
|
+
"is_business",
|
|
733
|
+
],
|
|
734
|
+
},
|
|
735
|
+
primaryKey: { profile: ["id"] },
|
|
736
|
+
lossy: [],
|
|
737
|
+
provenance: [
|
|
738
|
+
{
|
|
739
|
+
kind: "oci",
|
|
740
|
+
ref: "ghcr.io/pdp-connect/connector/meta:0.4.0",
|
|
741
|
+
digest: "sha256:9805c13ab4ad45caf904b4ce834764e701e426f5c3d2f3697fbab2705d1636ea",
|
|
742
|
+
path: "declarations/meta.collection-profile.json#streams[name=profile]",
|
|
743
|
+
},
|
|
744
|
+
],
|
|
745
|
+
project(records, options) {
|
|
746
|
+
const guard = requireStreams("instagram.profile", options, ["profile"]);
|
|
747
|
+
if (guard) {
|
|
748
|
+
return guard;
|
|
749
|
+
}
|
|
750
|
+
const [p] = byStream(records, "profile");
|
|
751
|
+
if (!p) {
|
|
752
|
+
return {
|
|
753
|
+
ok: false,
|
|
754
|
+
error: { kind: "empty_singleton", scope: "instagram.profile" },
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
const username = p.username;
|
|
758
|
+
if (typeof username !== "string") {
|
|
759
|
+
return {
|
|
760
|
+
ok: false,
|
|
761
|
+
error: {
|
|
762
|
+
kind: "invalid_value",
|
|
763
|
+
scope: "instagram.profile",
|
|
764
|
+
reason: "Meta profile is missing username",
|
|
765
|
+
},
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
const fullName = p.full_name == null
|
|
769
|
+
? ""
|
|
770
|
+
: typeof p.full_name === "string"
|
|
771
|
+
? p.full_name
|
|
772
|
+
: undefined;
|
|
773
|
+
if (fullName === undefined) {
|
|
774
|
+
return {
|
|
775
|
+
ok: false,
|
|
776
|
+
error: {
|
|
777
|
+
kind: "invalid_value",
|
|
778
|
+
scope: "instagram.profile",
|
|
779
|
+
reason: "Meta profile full_name is not a string",
|
|
780
|
+
},
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
const payload = {
|
|
784
|
+
username,
|
|
785
|
+
full_name: fullName,
|
|
786
|
+
bio: typeof p.bio === "string" ? p.bio : "",
|
|
787
|
+
};
|
|
788
|
+
if (typeof p.profile_pic_url === "string") {
|
|
789
|
+
payload.profile_pic_url = p.profile_pic_url;
|
|
790
|
+
}
|
|
791
|
+
payload.external_url =
|
|
792
|
+
typeof p.external_url === "string" ? p.external_url : "";
|
|
793
|
+
if (typeof p.follower_count === "number") {
|
|
794
|
+
payload.follower_count = p.follower_count;
|
|
795
|
+
}
|
|
796
|
+
if (typeof p.following_count === "number") {
|
|
797
|
+
payload.following_count = p.following_count;
|
|
798
|
+
}
|
|
799
|
+
if (typeof p.post_count === "number")
|
|
800
|
+
payload.media_count = p.post_count;
|
|
801
|
+
if (typeof p.is_private === "boolean")
|
|
802
|
+
payload.is_private = p.is_private;
|
|
803
|
+
if (typeof p.is_verified === "boolean")
|
|
804
|
+
payload.is_verified = p.is_verified;
|
|
805
|
+
if (typeof p.is_business === "boolean")
|
|
806
|
+
payload.is_business = p.is_business;
|
|
807
|
+
return {
|
|
808
|
+
ok: true,
|
|
809
|
+
payload,
|
|
810
|
+
};
|
|
811
|
+
},
|
|
812
|
+
};
|
|
813
|
+
// ---------------------------------------------------------------------------
|
|
814
|
+
// instagram.posts
|
|
815
|
+
// declarations/meta.collection-profile.json#streams[name=posts]
|
|
816
|
+
// connector_id: https://registry.pdpp.dev/connectors/meta
|
|
817
|
+
// ---------------------------------------------------------------------------
|
|
818
|
+
const instagramPosts = {
|
|
819
|
+
scope: "instagram.posts",
|
|
820
|
+
pdppSource: "https://registry.pdpp.dev/connectors/meta",
|
|
821
|
+
pdppStreams: ["posts", "post_likes"],
|
|
822
|
+
legacySchemaPath: "instagram.posts.json",
|
|
823
|
+
fieldsRead: {
|
|
824
|
+
posts: ["id", "media_url", "caption", "like_count", "taken_at"],
|
|
825
|
+
post_likes: ["post_id", "user_id", "username"],
|
|
826
|
+
},
|
|
827
|
+
primaryKey: { posts: ["id"], post_likes: ["post_id", "liker_ordinal"] },
|
|
828
|
+
// Each post is built from its own post_likes.
|
|
829
|
+
window: {
|
|
830
|
+
parentStream: "posts",
|
|
831
|
+
childStream: "post_likes",
|
|
832
|
+
childKey: "post_id",
|
|
833
|
+
arrayKey: "posts",
|
|
834
|
+
sumKeys: [],
|
|
835
|
+
parentOrder: primaryKeyOrder("id"),
|
|
836
|
+
},
|
|
837
|
+
lossy: [
|
|
838
|
+
"nullable media_url, caption, and like_count use the retained collector's empty-string and zero sentinels; every source post is retained",
|
|
839
|
+
"media_url is only available for images and the first image in a carousel; video posts and later carousel images are absent from the artifact's parser output",
|
|
840
|
+
"who_liked.profile_pic_url is omitted because the post_likes stream does not declare it",
|
|
841
|
+
"who_liked.pk and who_liked.id both use post_likes.user_id because the source exposes one liker identity field",
|
|
842
|
+
"likers without post_id, user_id, or username, or without a matching post, are dropped and counted",
|
|
843
|
+
],
|
|
844
|
+
provenance: [
|
|
845
|
+
{
|
|
846
|
+
kind: "oci",
|
|
847
|
+
ref: "ghcr.io/pdp-connect/connector/meta:0.4.0",
|
|
848
|
+
digest: "sha256:9805c13ab4ad45caf904b4ce834764e701e426f5c3d2f3697fbab2705d1636ea",
|
|
849
|
+
path: "declarations/meta.collection-profile.json#streams[name=posts,post_likes]",
|
|
850
|
+
},
|
|
851
|
+
],
|
|
852
|
+
project(records, options) {
|
|
853
|
+
const guard = requireStreams("instagram.posts", options, [
|
|
854
|
+
"posts",
|
|
855
|
+
"post_likes",
|
|
856
|
+
]);
|
|
857
|
+
if (guard) {
|
|
858
|
+
return guard;
|
|
859
|
+
}
|
|
860
|
+
const sourcePosts = byStream(records, "posts");
|
|
861
|
+
const postIds = new Set(sourcePosts.map((post) => post.id));
|
|
862
|
+
const dropped = new DroppedRows("instagram.posts");
|
|
863
|
+
const likesByPost = new Map();
|
|
864
|
+
for (const liker of byStream(records, "post_likes")) {
|
|
865
|
+
if (typeof liker.post_id !== "string" ||
|
|
866
|
+
typeof liker.user_id !== "string" ||
|
|
867
|
+
typeof liker.username !== "string") {
|
|
868
|
+
dropped.add("post_likes", "Liker lacks post_id, user_id, or username");
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
if (!postIds.has(liker.post_id)) {
|
|
872
|
+
dropped.add("post_likes", "Liker has no matching post");
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
875
|
+
const whoLiked = likesByPost.get(liker.post_id) ?? [];
|
|
876
|
+
whoLiked.push({
|
|
877
|
+
pk: liker.user_id,
|
|
878
|
+
username: liker.username,
|
|
879
|
+
id: liker.user_id,
|
|
880
|
+
});
|
|
881
|
+
likesByPost.set(liker.post_id, whoLiked);
|
|
882
|
+
}
|
|
883
|
+
const posts = [];
|
|
884
|
+
for (const sourcePost of sourcePosts) {
|
|
885
|
+
const projectedPost = {
|
|
886
|
+
img_url: orEmptyString(sourcePost.media_url),
|
|
887
|
+
caption: orEmptyString(sourcePost.caption),
|
|
888
|
+
num_of_likes: orZero(sourcePost.like_count),
|
|
889
|
+
who_liked: typeof sourcePost.id === "string"
|
|
890
|
+
? (likesByPost.get(sourcePost.id) ?? [])
|
|
891
|
+
: [],
|
|
892
|
+
};
|
|
893
|
+
if (typeof sourcePost.taken_at === "string") {
|
|
894
|
+
projectedPost.taken_at = sourcePost.taken_at;
|
|
895
|
+
}
|
|
896
|
+
posts.push(projectedPost);
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
ok: true,
|
|
900
|
+
payload: { posts },
|
|
901
|
+
...withDiagnostics(dropped.diagnostics()),
|
|
902
|
+
};
|
|
903
|
+
},
|
|
904
|
+
};
|
|
905
|
+
// ---------------------------------------------------------------------------
|
|
906
|
+
// instagram.following and instagram.ads
|
|
907
|
+
// declarations/meta.collection-profile.json#streams[name=following,ads]
|
|
908
|
+
// ---------------------------------------------------------------------------
|
|
909
|
+
const instagramFollowing = {
|
|
910
|
+
scope: "instagram.following",
|
|
911
|
+
pdppSource: "https://registry.pdpp.dev/connectors/meta",
|
|
912
|
+
pdppStreams: ["following"],
|
|
913
|
+
legacySchemaPath: "instagram.following.json",
|
|
914
|
+
fieldsRead: {
|
|
915
|
+
following: [
|
|
916
|
+
"id",
|
|
917
|
+
"username",
|
|
918
|
+
"full_name",
|
|
919
|
+
"is_private",
|
|
920
|
+
"is_verified",
|
|
921
|
+
"profile_pic_url",
|
|
922
|
+
],
|
|
923
|
+
},
|
|
924
|
+
primaryKey: { following: ["id"] },
|
|
925
|
+
lossy: [
|
|
926
|
+
"rows without a non-empty string username are dropped and counted because the legacy account schema requires username",
|
|
927
|
+
],
|
|
928
|
+
provenance: [
|
|
929
|
+
{
|
|
930
|
+
kind: "oci",
|
|
931
|
+
ref: "ghcr.io/pdp-connect/connector/meta:0.4.0",
|
|
932
|
+
digest: "sha256:9805c13ab4ad45caf904b4ce834764e701e426f5c3d2f3697fbab2705d1636ea",
|
|
933
|
+
path: "declarations/meta.collection-profile.json#streams[name=following]",
|
|
934
|
+
},
|
|
935
|
+
],
|
|
936
|
+
project(records, options) {
|
|
937
|
+
const guard = requireStreams("instagram.following", options, ["following"]);
|
|
938
|
+
if (guard)
|
|
939
|
+
return guard;
|
|
940
|
+
const dropped = new DroppedRows("instagram.following");
|
|
941
|
+
const accounts = byStream(records, "following").flatMap((r) => {
|
|
942
|
+
if (typeof r.username !== "string" || !r.username) {
|
|
943
|
+
dropped.add("following", "Account lacks a nonempty username");
|
|
944
|
+
return [];
|
|
945
|
+
}
|
|
946
|
+
const account = {
|
|
947
|
+
username: r.username,
|
|
948
|
+
full_name: typeof r.full_name === "string" ? r.full_name : "",
|
|
949
|
+
is_private: r.is_private === true,
|
|
950
|
+
is_verified: r.is_verified === true,
|
|
951
|
+
profile_pic_url: typeof r.profile_pic_url === "string" && r.profile_pic_url
|
|
952
|
+
? r.profile_pic_url
|
|
953
|
+
: null,
|
|
954
|
+
};
|
|
955
|
+
if (typeof r.id === "string")
|
|
956
|
+
account.pk = r.id;
|
|
957
|
+
return [account];
|
|
958
|
+
});
|
|
959
|
+
return {
|
|
960
|
+
ok: true,
|
|
961
|
+
payload: { accounts, total: accounts.length },
|
|
962
|
+
...withDiagnostics(dropped.diagnostics()),
|
|
963
|
+
};
|
|
964
|
+
},
|
|
965
|
+
};
|
|
966
|
+
const instagramAds = {
|
|
967
|
+
scope: "instagram.ads",
|
|
968
|
+
pdppSource: "https://registry.pdpp.dev/connectors/meta",
|
|
969
|
+
pdppStreams: ["ads"],
|
|
970
|
+
legacySchemaPath: "instagram.ads.json",
|
|
971
|
+
fieldsRead: { ads: ["kind", "name", "description"] },
|
|
972
|
+
primaryKey: { ads: ["id"] },
|
|
973
|
+
lossy: [
|
|
974
|
+
"ads rows with a null description omit the optional legacy category description",
|
|
975
|
+
"malformed ads rows without a string name or one of the declaration's three kinds are dropped and counted",
|
|
976
|
+
],
|
|
977
|
+
provenance: [
|
|
978
|
+
{
|
|
979
|
+
kind: "oci",
|
|
980
|
+
ref: "ghcr.io/pdp-connect/connector/meta:0.4.0",
|
|
981
|
+
digest: "sha256:9805c13ab4ad45caf904b4ce834764e701e426f5c3d2f3697fbab2705d1636ea",
|
|
982
|
+
path: "declarations/meta.collection-profile.json#streams[name=ads]",
|
|
983
|
+
},
|
|
984
|
+
],
|
|
985
|
+
project(records, options) {
|
|
986
|
+
const guard = requireStreams("instagram.ads", options, ["ads"]);
|
|
987
|
+
if (guard)
|
|
988
|
+
return guard;
|
|
989
|
+
const advertisers = [];
|
|
990
|
+
const ad_topics = [];
|
|
991
|
+
const categories = [];
|
|
992
|
+
const dropped = new DroppedRows("instagram.ads");
|
|
993
|
+
for (const row of byStream(records, "ads")) {
|
|
994
|
+
if (typeof row.name !== "string" ||
|
|
995
|
+
!["advertiser", "ad_topic", "ad_category"].includes(row.kind)) {
|
|
996
|
+
dropped.add("ads", "Ad row lacks a string name or a declared kind");
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
if (row.kind === "advertiser")
|
|
1000
|
+
advertisers.push({ name: row.name });
|
|
1001
|
+
if (row.kind === "ad_topic")
|
|
1002
|
+
ad_topics.push({ name: row.name });
|
|
1003
|
+
if (row.kind === "ad_category") {
|
|
1004
|
+
categories.push({
|
|
1005
|
+
name: row.name,
|
|
1006
|
+
...(typeof row.description === "string"
|
|
1007
|
+
? { description: row.description }
|
|
1008
|
+
: {}),
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
return {
|
|
1013
|
+
ok: true,
|
|
1014
|
+
payload: { advertisers, ad_topics, categories },
|
|
1015
|
+
...withDiagnostics(dropped.diagnostics()),
|
|
1016
|
+
};
|
|
1017
|
+
},
|
|
1018
|
+
};
|
|
1019
|
+
// ---------------------------------------------------------------------------
|
|
1020
|
+
// github
|
|
1021
|
+
// declarations/github.collection-profile.json
|
|
1022
|
+
// connector_id: https://registry.pdpp.dev/connectors/github
|
|
1023
|
+
// ---------------------------------------------------------------------------
|
|
1024
|
+
const githubRepositories = {
|
|
1025
|
+
scope: "github.repositories",
|
|
1026
|
+
pdppSource: "https://registry.pdpp.dev/connectors/github",
|
|
1027
|
+
pdppStreams: ["repositories"],
|
|
1028
|
+
legacySchemaPath: "github.repositories.json",
|
|
1029
|
+
fieldsRead: {
|
|
1030
|
+
repositories: [
|
|
1031
|
+
"name",
|
|
1032
|
+
"html_url",
|
|
1033
|
+
"description",
|
|
1034
|
+
"language",
|
|
1035
|
+
"stargazers_count",
|
|
1036
|
+
"forks_count",
|
|
1037
|
+
"private",
|
|
1038
|
+
"topics",
|
|
1039
|
+
"updated_at",
|
|
1040
|
+
],
|
|
1041
|
+
},
|
|
1042
|
+
primaryKey: { repositories: ["id"] },
|
|
1043
|
+
lossy: [
|
|
1044
|
+
"description, language, updatedAt: PDPP-side null projects as legacy's own '' / null default, not a fabricated value, but omission still differs from a populated legacy record",
|
|
1045
|
+
],
|
|
1046
|
+
provenance: [
|
|
1047
|
+
{
|
|
1048
|
+
kind: "oci",
|
|
1049
|
+
ref: "ghcr.io/pdp-connect/connector/github:0.7.2",
|
|
1050
|
+
digest: "sha256:5501bb109cdca02d2acd08aa6891613c7af0bbe0869c30eba2a8070836b0d2f7",
|
|
1051
|
+
path: "declarations/github.collection-profile.json#streams[name=repositories]",
|
|
1052
|
+
},
|
|
1053
|
+
],
|
|
1054
|
+
project(records, options) {
|
|
1055
|
+
const guard = requireStreams("github.repositories", options, [
|
|
1056
|
+
"repositories",
|
|
1057
|
+
]);
|
|
1058
|
+
if (guard) {
|
|
1059
|
+
return guard;
|
|
1060
|
+
}
|
|
1061
|
+
const items = byStream(records, "repositories");
|
|
1062
|
+
// Legacy requires name, url per item; allows description, language,
|
|
1063
|
+
// stars, forks, visibility, topics, updatedAt. `url` is `html_url` on
|
|
1064
|
+
// the repositories stream (a real GitHub URL field, not a template).
|
|
1065
|
+
// `visibility` is the literal text GitHub's own repo-list DOM renders,
|
|
1066
|
+
// capitalized "Public"/"Private" (github-playwright.js:416,
|
|
1067
|
+
// `row.querySelector('span.Label')?.textContent || 'Public'`) — derived
|
|
1068
|
+
// here from PDPP's boolean `private` field with the matching casing,
|
|
1069
|
+
// not lowercase.
|
|
1070
|
+
return {
|
|
1071
|
+
ok: true,
|
|
1072
|
+
payload: {
|
|
1073
|
+
repositories: items.map((r) => ({
|
|
1074
|
+
name: orEmptyString(r.name),
|
|
1075
|
+
url: orEmptyString(r.html_url),
|
|
1076
|
+
description: orEmptyString(r.description),
|
|
1077
|
+
language: orEmptyString(r.language),
|
|
1078
|
+
stars: orZero(r.stargazers_count),
|
|
1079
|
+
forks: orZero(r.forks_count),
|
|
1080
|
+
visibility: r.private === true ? "Private" : "Public",
|
|
1081
|
+
topics: Array.isArray(r.topics) ? r.topics : [],
|
|
1082
|
+
updatedAt: typeof r.updated_at === "string" ? r.updated_at : null,
|
|
1083
|
+
})),
|
|
1084
|
+
},
|
|
1085
|
+
};
|
|
1086
|
+
},
|
|
1087
|
+
};
|
|
1088
|
+
const githubStarred = {
|
|
1089
|
+
scope: "github.starred",
|
|
1090
|
+
pdppSource: "https://registry.pdpp.dev/connectors/github",
|
|
1091
|
+
pdppStreams: ["starred"],
|
|
1092
|
+
legacySchemaPath: "github.starred.json",
|
|
1093
|
+
fieldsRead: {
|
|
1094
|
+
starred: [
|
|
1095
|
+
"full_name",
|
|
1096
|
+
"html_url",
|
|
1097
|
+
"description",
|
|
1098
|
+
"language",
|
|
1099
|
+
"stargazers_count",
|
|
1100
|
+
],
|
|
1101
|
+
},
|
|
1102
|
+
primaryKey: { starred: ["id"] },
|
|
1103
|
+
lossy: [
|
|
1104
|
+
"updatedAt changes meaning: legacy is the repo's own last-updated time from the stars page (github-playwright.js:415, relative-time datetime); PDPP's starred stream only carries starred_at, the time the user starred it. Field is emitted as null (no PDPP source for repo update time), not omitted.",
|
|
1105
|
+
"description, language: PDPP-side null projects as ''",
|
|
1106
|
+
],
|
|
1107
|
+
provenance: [
|
|
1108
|
+
{
|
|
1109
|
+
kind: "oci",
|
|
1110
|
+
ref: "ghcr.io/pdp-connect/connector/github:0.7.2",
|
|
1111
|
+
digest: "sha256:5501bb109cdca02d2acd08aa6891613c7af0bbe0869c30eba2a8070836b0d2f7",
|
|
1112
|
+
path: "declarations/github.collection-profile.json#streams[name=starred]",
|
|
1113
|
+
},
|
|
1114
|
+
],
|
|
1115
|
+
project(records, options) {
|
|
1116
|
+
const guard = requireStreams("github.starred", options, ["starred"]);
|
|
1117
|
+
if (guard) {
|
|
1118
|
+
return guard;
|
|
1119
|
+
}
|
|
1120
|
+
const items = byStream(records, "starred");
|
|
1121
|
+
return {
|
|
1122
|
+
ok: true,
|
|
1123
|
+
payload: {
|
|
1124
|
+
starred: items.map((r) => ({
|
|
1125
|
+
fullName: orEmptyString(r.full_name),
|
|
1126
|
+
url: orEmptyString(r.html_url),
|
|
1127
|
+
description: orEmptyString(r.description),
|
|
1128
|
+
language: orEmptyString(r.language),
|
|
1129
|
+
stars: orZero(r.stargazers_count),
|
|
1130
|
+
updatedAt: null,
|
|
1131
|
+
})),
|
|
1132
|
+
},
|
|
1133
|
+
};
|
|
1134
|
+
},
|
|
1135
|
+
};
|
|
1136
|
+
// github.history can be projected from authored pull_requests plus authored
|
|
1137
|
+
// issues. The signed issues stream also contains assigned issues, so it is
|
|
1138
|
+
// filtered against the signed user.login singleton before projection.
|
|
1139
|
+
const githubHistory = {
|
|
1140
|
+
scope: "github.history",
|
|
1141
|
+
pdppSource: "https://registry.pdpp.dev/connectors/github",
|
|
1142
|
+
pdppStreams: ["user", "issues", "pull_requests"],
|
|
1143
|
+
legacySchemaPath: "github.history.json",
|
|
1144
|
+
fieldsRead: {
|
|
1145
|
+
user: ["login"],
|
|
1146
|
+
issues: [
|
|
1147
|
+
"id",
|
|
1148
|
+
"number",
|
|
1149
|
+
"title",
|
|
1150
|
+
"body",
|
|
1151
|
+
"state",
|
|
1152
|
+
"user_login",
|
|
1153
|
+
"labels",
|
|
1154
|
+
"repository_full_name",
|
|
1155
|
+
"html_url",
|
|
1156
|
+
"comments",
|
|
1157
|
+
"reactions_total_count",
|
|
1158
|
+
"created_at",
|
|
1159
|
+
"updated_at",
|
|
1160
|
+
"closed_at",
|
|
1161
|
+
"is_pull_request",
|
|
1162
|
+
],
|
|
1163
|
+
pull_requests: [
|
|
1164
|
+
"id",
|
|
1165
|
+
"number",
|
|
1166
|
+
"title",
|
|
1167
|
+
"body",
|
|
1168
|
+
"state",
|
|
1169
|
+
"labels",
|
|
1170
|
+
"repository_full_name",
|
|
1171
|
+
"html_url",
|
|
1172
|
+
"comments",
|
|
1173
|
+
"reactions_total_count",
|
|
1174
|
+
"created_at",
|
|
1175
|
+
"updated_at",
|
|
1176
|
+
"closed_at",
|
|
1177
|
+
"merged_at",
|
|
1178
|
+
"draft",
|
|
1179
|
+
],
|
|
1180
|
+
},
|
|
1181
|
+
primaryKey: { user: ["id"], issues: ["id"], pull_requests: ["id"] },
|
|
1182
|
+
memoryBound: "Issues and pull requests are two independent lists, each one array, so there is no parent and child to split.",
|
|
1183
|
+
lossy: [
|
|
1184
|
+
"legacy IDs used gh-issue-/gh-pr- prefixes; projection uses the signed PDPP record ID directly",
|
|
1185
|
+
"body is truncated to the legacy connector's 500-character limit",
|
|
1186
|
+
"repoUrl is omitted because no repository URL field is declared on issue or pull request streams",
|
|
1187
|
+
"fetchedAt is set at projection time because the legacy schema requires it and PDPP history records have no fetch timestamp",
|
|
1188
|
+
"an authored item without an id or repository name, or an issue by the signed user without a boolean is_pull_request, fails the scope",
|
|
1189
|
+
],
|
|
1190
|
+
provenance: [
|
|
1191
|
+
{
|
|
1192
|
+
kind: "oci",
|
|
1193
|
+
ref: "ghcr.io/pdp-connect/connector/github:0.7.2",
|
|
1194
|
+
digest: "sha256:5501bb109cdca02d2acd08aa6891613c7af0bbe0869c30eba2a8070836b0d2f7",
|
|
1195
|
+
path: "declarations/github.collection-profile.json#streams[name=user,issues,pull_requests]",
|
|
1196
|
+
},
|
|
1197
|
+
],
|
|
1198
|
+
project(records, options) {
|
|
1199
|
+
const streams = ["user", "issues", "pull_requests"];
|
|
1200
|
+
const guard = requireStreams("github.history", options, streams);
|
|
1201
|
+
if (guard)
|
|
1202
|
+
return guard;
|
|
1203
|
+
const login = byStream(records, "user")[0]?.login;
|
|
1204
|
+
const sourceIssues = byStream(records, "issues");
|
|
1205
|
+
if (typeof login !== "string" && sourceIssues.length > 0) {
|
|
1206
|
+
return {
|
|
1207
|
+
ok: false,
|
|
1208
|
+
error: {
|
|
1209
|
+
kind: "invalid_value",
|
|
1210
|
+
scope: "github.history",
|
|
1211
|
+
reason: "Signed user stream has no login for authored-issue filtering",
|
|
1212
|
+
},
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
const projectItem = (r, type) => {
|
|
1216
|
+
if (typeof r.id !== "string" ||
|
|
1217
|
+
typeof r.repository_full_name !== "string")
|
|
1218
|
+
return null;
|
|
1219
|
+
const item = {
|
|
1220
|
+
id: r.id,
|
|
1221
|
+
type,
|
|
1222
|
+
repo: r.repository_full_name,
|
|
1223
|
+
comments: typeof r.comments === "number" ? r.comments : 0,
|
|
1224
|
+
reactionsTotal: typeof r.reactions_total_count === "number"
|
|
1225
|
+
? r.reactions_total_count
|
|
1226
|
+
: 0,
|
|
1227
|
+
isDraft: type === "pr" &&
|
|
1228
|
+
r.draft === true &&
|
|
1229
|
+
r.state === "open" &&
|
|
1230
|
+
r.merged_at == null,
|
|
1231
|
+
};
|
|
1232
|
+
if (typeof r.number === "number")
|
|
1233
|
+
item.number = r.number;
|
|
1234
|
+
if (typeof r.title === "string" || r.title === null)
|
|
1235
|
+
item.title = r.title;
|
|
1236
|
+
if (typeof r.body === "string" || r.body === null) {
|
|
1237
|
+
item.body = typeof r.body === "string" ? r.body.slice(0, 500) : null;
|
|
1238
|
+
}
|
|
1239
|
+
if (typeof r.state === "string" || r.state === null)
|
|
1240
|
+
item.state = r.state;
|
|
1241
|
+
for (const [source, target] of [
|
|
1242
|
+
["created_at", "createdAt"],
|
|
1243
|
+
["updated_at", "updatedAt"],
|
|
1244
|
+
["closed_at", "closedAt"],
|
|
1245
|
+
["html_url", "url"],
|
|
1246
|
+
]) {
|
|
1247
|
+
if (typeof r[source] === "string" || r[source] === null)
|
|
1248
|
+
item[target] = r[source];
|
|
1249
|
+
}
|
|
1250
|
+
if (type === "pr" &&
|
|
1251
|
+
(typeof r.merged_at === "string" || r.merged_at === null)) {
|
|
1252
|
+
item.mergedAt = r.merged_at;
|
|
1253
|
+
}
|
|
1254
|
+
item.labels = Array.isArray(r.labels)
|
|
1255
|
+
? r.labels.filter((label) => typeof label === "string")
|
|
1256
|
+
: [];
|
|
1257
|
+
return item;
|
|
1258
|
+
};
|
|
1259
|
+
if (sourceIssues.some((r) => r.user_login === login && typeof r.is_pull_request !== "boolean")) {
|
|
1260
|
+
return {
|
|
1261
|
+
ok: false,
|
|
1262
|
+
error: {
|
|
1263
|
+
kind: "incomplete_scope",
|
|
1264
|
+
scope: "github.history",
|
|
1265
|
+
reason: "An issue by the signed user has no boolean is_pull_request, so it cannot be classified",
|
|
1266
|
+
},
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
const pullRequests = byStream(records, "pull_requests").flatMap((r) => {
|
|
1270
|
+
const item = projectItem(r, "pr");
|
|
1271
|
+
return item ? [item] : [];
|
|
1272
|
+
});
|
|
1273
|
+
const issues = sourceIssues.flatMap((r) => {
|
|
1274
|
+
if (typeof r.is_pull_request !== "boolean" ||
|
|
1275
|
+
r.is_pull_request ||
|
|
1276
|
+
r.user_login !== login) {
|
|
1277
|
+
return [];
|
|
1278
|
+
}
|
|
1279
|
+
const item = projectItem(r, "issue");
|
|
1280
|
+
return item ? [item] : [];
|
|
1281
|
+
});
|
|
1282
|
+
const authoredIssues = sourceIssues.filter((r) => typeof login === "string" &&
|
|
1283
|
+
typeof r.is_pull_request === "boolean" &&
|
|
1284
|
+
!r.is_pull_request &&
|
|
1285
|
+
r.user_login === login);
|
|
1286
|
+
if (pullRequests.length !== byStream(records, "pull_requests").length ||
|
|
1287
|
+
issues.length !== authoredIssues.length) {
|
|
1288
|
+
return {
|
|
1289
|
+
ok: false,
|
|
1290
|
+
error: {
|
|
1291
|
+
kind: "incomplete_scope",
|
|
1292
|
+
scope: "github.history",
|
|
1293
|
+
reason: "Cannot preserve every authored history row: required id or repository_full_name is missing",
|
|
1294
|
+
},
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
return {
|
|
1298
|
+
ok: true,
|
|
1299
|
+
payload: { pullRequests, issues, fetchedAt: projectionTime(options) },
|
|
1300
|
+
};
|
|
1301
|
+
},
|
|
1302
|
+
};
|
|
1303
|
+
const githubProfile = {
|
|
1304
|
+
scope: "github.profile",
|
|
1305
|
+
pdppSource: "https://registry.pdpp.dev/connectors/github",
|
|
1306
|
+
pdppStreams: ["user", "user_stats", "pinned_repositories", "organizations"],
|
|
1307
|
+
legacySchemaPath: "github.profile.json",
|
|
1308
|
+
fieldsRead: {
|
|
1309
|
+
user: [
|
|
1310
|
+
"login",
|
|
1311
|
+
"name",
|
|
1312
|
+
"bio",
|
|
1313
|
+
"company",
|
|
1314
|
+
"location",
|
|
1315
|
+
"blog",
|
|
1316
|
+
"avatar_url",
|
|
1317
|
+
"achievements",
|
|
1318
|
+
],
|
|
1319
|
+
user_stats: ["observed_on", "followers", "following", "public_repos"],
|
|
1320
|
+
pinned_repositories: [
|
|
1321
|
+
"full_name",
|
|
1322
|
+
"html_url",
|
|
1323
|
+
"description",
|
|
1324
|
+
"languages",
|
|
1325
|
+
"stargazers_count",
|
|
1326
|
+
],
|
|
1327
|
+
organizations: ["login", "description", "avatar_url"],
|
|
1328
|
+
},
|
|
1329
|
+
primaryKey: {
|
|
1330
|
+
user: ["id"],
|
|
1331
|
+
user_stats: ["id"],
|
|
1332
|
+
pinned_repositories: ["id"],
|
|
1333
|
+
organizations: ["id"],
|
|
1334
|
+
},
|
|
1335
|
+
memoryBound: "The output is one profile object; user_stats gains a row per day and is read in full to pick the latest, and the window has no parent and child to split.",
|
|
1336
|
+
lossy: [
|
|
1337
|
+
"profileUrl is derived from the authenticated user's login using GitHub's canonical profile URL pattern",
|
|
1338
|
+
"organization label and URL are omitted because the organizations stream carries neither field; description is not substituted for label",
|
|
1339
|
+
"pinned repository description, language, URL, and stars are omitted when the source value is absent; languages is a list and legacy supports only one language, so the first collected language is used",
|
|
1340
|
+
"contributionsLastYear is omitted: daily contribution data may be an incremental or caller-limited window and cannot establish a complete rolling-year total",
|
|
1341
|
+
"follower, following, and repository counts use the newest observed_on stats record; no value is emitted if no stats record exists",
|
|
1342
|
+
],
|
|
1343
|
+
provenance: [
|
|
1344
|
+
{
|
|
1345
|
+
kind: "oci",
|
|
1346
|
+
ref: "ghcr.io/pdp-connect/connector/github:0.7.2",
|
|
1347
|
+
digest: "sha256:5501bb109cdca02d2acd08aa6891613c7af0bbe0869c30eba2a8070836b0d2f7",
|
|
1348
|
+
path: "declarations/github.collection-profile.json#streams[name=user,user_stats,pinned_repositories,organizations]",
|
|
1349
|
+
},
|
|
1350
|
+
],
|
|
1351
|
+
project(records, options) {
|
|
1352
|
+
const streams = [
|
|
1353
|
+
"user",
|
|
1354
|
+
"user_stats",
|
|
1355
|
+
"pinned_repositories",
|
|
1356
|
+
"organizations",
|
|
1357
|
+
];
|
|
1358
|
+
const guard = requireStreams("github.profile", options, streams);
|
|
1359
|
+
if (guard)
|
|
1360
|
+
return guard;
|
|
1361
|
+
const user = byStream(records, "user")[0];
|
|
1362
|
+
if (!user || typeof user.login !== "string") {
|
|
1363
|
+
return {
|
|
1364
|
+
ok: false,
|
|
1365
|
+
error: { kind: "empty_singleton", scope: "github.profile" },
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
const dropped = new DroppedRows("github.profile");
|
|
1369
|
+
const payload = {
|
|
1370
|
+
username: user.login,
|
|
1371
|
+
profileUrl: `https://github.com/${user.login}`,
|
|
1372
|
+
};
|
|
1373
|
+
for (const [source, target] of [
|
|
1374
|
+
["name", "fullName"],
|
|
1375
|
+
["bio", "bio"],
|
|
1376
|
+
["company", "company"],
|
|
1377
|
+
["location", "location"],
|
|
1378
|
+
["blog", "website"],
|
|
1379
|
+
["avatar_url", "avatarUrl"],
|
|
1380
|
+
]) {
|
|
1381
|
+
if (typeof user[source] === "string")
|
|
1382
|
+
payload[target] = user[source];
|
|
1383
|
+
}
|
|
1384
|
+
const stats = byStream(records, "user_stats")
|
|
1385
|
+
.filter((r) => {
|
|
1386
|
+
if (typeof r.observed_on === "string")
|
|
1387
|
+
return true;
|
|
1388
|
+
dropped.add("user_stats", "Stats record lacks observed_on");
|
|
1389
|
+
return false;
|
|
1390
|
+
})
|
|
1391
|
+
.sort((a, b) => String(b.observed_on).localeCompare(String(a.observed_on)))[0];
|
|
1392
|
+
if (stats) {
|
|
1393
|
+
for (const [source, target] of [
|
|
1394
|
+
["followers", "followers"],
|
|
1395
|
+
["following", "following"],
|
|
1396
|
+
["public_repos", "repositoryCount"],
|
|
1397
|
+
]) {
|
|
1398
|
+
if (typeof stats[source] === "number")
|
|
1399
|
+
payload[target] = stats[source];
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
if (Array.isArray(user.achievements)) {
|
|
1403
|
+
payload.achievements = user.achievements.flatMap((value) => {
|
|
1404
|
+
if (!value || typeof value !== "object")
|
|
1405
|
+
return [];
|
|
1406
|
+
const item = value;
|
|
1407
|
+
if (typeof item.name !== "string")
|
|
1408
|
+
return [];
|
|
1409
|
+
return [
|
|
1410
|
+
{
|
|
1411
|
+
name: item.name,
|
|
1412
|
+
...(typeof item.icon_url === "string" || item.icon_url === null
|
|
1413
|
+
? { iconUrl: item.icon_url }
|
|
1414
|
+
: {}),
|
|
1415
|
+
},
|
|
1416
|
+
];
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
payload.pinnedRepositories = byStream(records, "pinned_repositories").flatMap((r) => {
|
|
1420
|
+
if (typeof r.full_name !== "string") {
|
|
1421
|
+
dropped.add("pinned_repositories", "Pinned repository lacks full_name");
|
|
1422
|
+
return [];
|
|
1423
|
+
}
|
|
1424
|
+
const item = { fullName: r.full_name };
|
|
1425
|
+
if (typeof r.html_url === "string" || r.html_url === null)
|
|
1426
|
+
item.url = r.html_url;
|
|
1427
|
+
if (typeof r.description === "string")
|
|
1428
|
+
item.description = r.description;
|
|
1429
|
+
if (Array.isArray(r.languages) && typeof r.languages[0] === "string")
|
|
1430
|
+
item.language = r.languages[0];
|
|
1431
|
+
if (typeof r.stargazers_count === "number")
|
|
1432
|
+
item.stars = r.stargazers_count;
|
|
1433
|
+
return [item];
|
|
1434
|
+
});
|
|
1435
|
+
payload.organizations = byStream(records, "organizations").flatMap((r) => {
|
|
1436
|
+
if (typeof r.login !== "string") {
|
|
1437
|
+
dropped.add("organizations", "Organization lacks login");
|
|
1438
|
+
return [];
|
|
1439
|
+
}
|
|
1440
|
+
return [
|
|
1441
|
+
{
|
|
1442
|
+
login: r.login,
|
|
1443
|
+
...(typeof r.avatar_url === "string" || r.avatar_url === null
|
|
1444
|
+
? { avatarUrl: r.avatar_url }
|
|
1445
|
+
: {}),
|
|
1446
|
+
},
|
|
1447
|
+
];
|
|
1448
|
+
});
|
|
1449
|
+
return { ok: true, payload, ...withDiagnostics(dropped.diagnostics()) };
|
|
1450
|
+
},
|
|
1451
|
+
};
|
|
1452
|
+
const githubEvents = {
|
|
1453
|
+
scope: "github.events",
|
|
1454
|
+
pdppSource: "https://registry.pdpp.dev/connectors/github",
|
|
1455
|
+
pdppStreams: ["events"],
|
|
1456
|
+
legacySchemaPath: "github.events.json",
|
|
1457
|
+
fieldsRead: {
|
|
1458
|
+
events: ["id", "type", "created_at", "repository_full_name", "is_public"],
|
|
1459
|
+
},
|
|
1460
|
+
primaryKey: { events: ["id"] },
|
|
1461
|
+
lossy: [
|
|
1462
|
+
"the events API retains only roughly 90 days; the connector emits each collected public event as a legacy event",
|
|
1463
|
+
"legacy action, title, body, URL, branch, commit count, repository URL, and window description are omitted because events records do not declare those values",
|
|
1464
|
+
"fetchedAt is set at projection time because the stream has no collection timestamp",
|
|
1465
|
+
"malformed records missing legacy-required fields are dropped and counted",
|
|
1466
|
+
],
|
|
1467
|
+
provenance: [
|
|
1468
|
+
{
|
|
1469
|
+
kind: "oci",
|
|
1470
|
+
ref: "ghcr.io/pdp-connect/connector/github:0.7.2",
|
|
1471
|
+
digest: "sha256:5501bb109cdca02d2acd08aa6891613c7af0bbe0869c30eba2a8070836b0d2f7",
|
|
1472
|
+
path: "declarations/github.collection-profile.json#streams[name=events]",
|
|
1473
|
+
},
|
|
1474
|
+
],
|
|
1475
|
+
project(records, options) {
|
|
1476
|
+
const guard = requireStreams("github.events", options, ["events"]);
|
|
1477
|
+
if (guard)
|
|
1478
|
+
return guard;
|
|
1479
|
+
const dropped = new DroppedRows("github.events");
|
|
1480
|
+
const events = byStream(records, "events").flatMap((r) => {
|
|
1481
|
+
if (typeof r.id !== "string" ||
|
|
1482
|
+
typeof r.type !== "string" ||
|
|
1483
|
+
typeof r.created_at !== "string" ||
|
|
1484
|
+
typeof r.repository_full_name !== "string" ||
|
|
1485
|
+
typeof r.is_public !== "boolean") {
|
|
1486
|
+
dropped.add("events", "Event lacks a legacy-required id, type, created_at, repository_full_name, or is_public");
|
|
1487
|
+
return [];
|
|
1488
|
+
}
|
|
1489
|
+
return [
|
|
1490
|
+
{
|
|
1491
|
+
id: r.id,
|
|
1492
|
+
type: r.type,
|
|
1493
|
+
createdAt: r.created_at,
|
|
1494
|
+
repo: r.repository_full_name,
|
|
1495
|
+
isPublic: r.is_public,
|
|
1496
|
+
},
|
|
1497
|
+
];
|
|
1498
|
+
});
|
|
1499
|
+
return {
|
|
1500
|
+
ok: true,
|
|
1501
|
+
payload: { events, fetchedAt: projectionTime(options) },
|
|
1502
|
+
...withDiagnostics(dropped.diagnostics()),
|
|
1503
|
+
};
|
|
1504
|
+
},
|
|
1505
|
+
};
|
|
1506
|
+
const githubContributions = {
|
|
1507
|
+
scope: "github.contributions",
|
|
1508
|
+
pdppSource: "https://registry.pdpp.dev/connectors/github",
|
|
1509
|
+
pdppStreams: ["contributions"],
|
|
1510
|
+
legacySchemaPath: "github.contributions.json",
|
|
1511
|
+
fieldsRead: { contributions: ["date", "contribution_count"] },
|
|
1512
|
+
primaryKey: { contributions: ["id"] },
|
|
1513
|
+
lossy: [
|
|
1514
|
+
"daily records are projected to legacy days; level is absent from the source and omitted",
|
|
1515
|
+
"totalContributionsLastYear, yearTotals, monthlyTotals, and topDay are omitted because collected contribution records may cover only an incremental or caller-limited interval",
|
|
1516
|
+
"fetchedAt is set at projection time because contribution records have no collection timestamp",
|
|
1517
|
+
"days without a date or numeric count are dropped and counted",
|
|
1518
|
+
],
|
|
1519
|
+
provenance: [
|
|
1520
|
+
{
|
|
1521
|
+
kind: "oci",
|
|
1522
|
+
ref: "ghcr.io/pdp-connect/connector/github:0.7.2",
|
|
1523
|
+
digest: "sha256:5501bb109cdca02d2acd08aa6891613c7af0bbe0869c30eba2a8070836b0d2f7",
|
|
1524
|
+
path: "declarations/github.collection-profile.json#streams[name=contributions]",
|
|
1525
|
+
},
|
|
1526
|
+
],
|
|
1527
|
+
project(records, options) {
|
|
1528
|
+
const guard = requireStreams("github.contributions", options, [
|
|
1529
|
+
"contributions",
|
|
1530
|
+
]);
|
|
1531
|
+
if (guard)
|
|
1532
|
+
return guard;
|
|
1533
|
+
const dropped = new DroppedRows("github.contributions");
|
|
1534
|
+
const days = byStream(records, "contributions").flatMap((r) => {
|
|
1535
|
+
if (typeof r.date !== "string" ||
|
|
1536
|
+
typeof r.contribution_count !== "number") {
|
|
1537
|
+
dropped.add("contributions", "Contribution day lacks a date or a numeric contribution_count");
|
|
1538
|
+
return [];
|
|
1539
|
+
}
|
|
1540
|
+
return [{ date: r.date, count: r.contribution_count }];
|
|
1541
|
+
});
|
|
1542
|
+
return {
|
|
1543
|
+
ok: true,
|
|
1544
|
+
payload: { days, fetchedAt: projectionTime(options) },
|
|
1545
|
+
...withDiagnostics(dropped.diagnostics()),
|
|
1546
|
+
};
|
|
1547
|
+
},
|
|
1548
|
+
};
|
|
1549
|
+
// ---------------------------------------------------------------------------
|
|
1550
|
+
// openai (chatgpt)
|
|
1551
|
+
// declarations/chatgpt.collection-profile.json
|
|
1552
|
+
// connector_id: https://registry.pdpp.dev/connectors/chatgpt
|
|
1553
|
+
// ---------------------------------------------------------------------------
|
|
1554
|
+
const chatgptMemories = {
|
|
1555
|
+
scope: "chatgpt.memories",
|
|
1556
|
+
pdppSource: "https://registry.pdpp.dev/connectors/chatgpt",
|
|
1557
|
+
pdppStreams: ["memories"],
|
|
1558
|
+
legacySchemaPath: "chatgpt.memories.json",
|
|
1559
|
+
fieldsRead: { memories: ["id", "content", "created_at", "updated_at"] },
|
|
1560
|
+
primaryKey: { memories: ["id"] },
|
|
1561
|
+
lossy: [
|
|
1562
|
+
"type: legacy always emits it, defaulting to the literal string 'memory' when the upstream field is absent (chatgpt-playwright.js:645, `memory.type || 'memory'`); the memories stream has no `type` field at all, so this binding reproduces that same fallback rather than omitting the field the schema allows.",
|
|
1563
|
+
"created_at: a null value falls back to the projection time (options.now, else the wall clock), matching legacy's own `memory.created_at || new Date().toISOString()` fallback (N-M3).",
|
|
1564
|
+
],
|
|
1565
|
+
provenance: [
|
|
1566
|
+
{
|
|
1567
|
+
kind: "oci",
|
|
1568
|
+
ref: "ghcr.io/pdp-connect/connector/chatgpt:0.1.0",
|
|
1569
|
+
digest: "sha256:811daaf8f2a9a346f1ff5109c118ea404212c8e00790cc5d448e89ad9fa9c4a4",
|
|
1570
|
+
path: "declarations/chatgpt.collection-profile.json#streams[name=memories]",
|
|
1571
|
+
},
|
|
1572
|
+
],
|
|
1573
|
+
project(records, options) {
|
|
1574
|
+
const guard = requireStreams("chatgpt.memories", options, ["memories"]);
|
|
1575
|
+
if (guard) {
|
|
1576
|
+
return guard;
|
|
1577
|
+
}
|
|
1578
|
+
const items = byStream(records, "memories");
|
|
1579
|
+
// created_at is required by the legacy schema; the stream types it
|
|
1580
|
+
// nullable, so a null value falls back to now() the same way the
|
|
1581
|
+
// legacy connector does (chatgpt-playwright.js: `created_at:
|
|
1582
|
+
// memory.created_at || new Date().toISOString()`), rather than
|
|
1583
|
+
// passing through a schema-invalid null.
|
|
1584
|
+
return {
|
|
1585
|
+
ok: true,
|
|
1586
|
+
payload: {
|
|
1587
|
+
memories: items.map((m) => ({
|
|
1588
|
+
id: orEmptyString(m.id),
|
|
1589
|
+
content: orEmptyString(m.content),
|
|
1590
|
+
created_at: typeof m.created_at === "string"
|
|
1591
|
+
? m.created_at
|
|
1592
|
+
: projectionTime(options),
|
|
1593
|
+
type: "memory",
|
|
1594
|
+
...(typeof m.updated_at === "string"
|
|
1595
|
+
? { updated_at: m.updated_at }
|
|
1596
|
+
: {}),
|
|
1597
|
+
})),
|
|
1598
|
+
total: items.length,
|
|
1599
|
+
},
|
|
1600
|
+
};
|
|
1601
|
+
},
|
|
1602
|
+
};
|
|
1603
|
+
// Signed ChatGPT 0.1.1 is the source; Desktop ingest remains disabled until
|
|
1604
|
+
// catalog admission and static_secret host setup land separately.
|
|
1605
|
+
const chatgptConversations = {
|
|
1606
|
+
scope: "chatgpt.conversations",
|
|
1607
|
+
pdppSource: "https://registry.pdpp.dev/connectors/chatgpt",
|
|
1608
|
+
pdppStreams: ["conversations", "messages"],
|
|
1609
|
+
legacySchemaPath: "chatgpt.conversations.json",
|
|
1610
|
+
fieldsRead: {
|
|
1611
|
+
conversations: [
|
|
1612
|
+
"id",
|
|
1613
|
+
"title",
|
|
1614
|
+
"create_time",
|
|
1615
|
+
"update_time",
|
|
1616
|
+
"current_node",
|
|
1617
|
+
"message_count_on_current_branch",
|
|
1618
|
+
],
|
|
1619
|
+
messages: [
|
|
1620
|
+
"id",
|
|
1621
|
+
"conversation_id",
|
|
1622
|
+
"parent_id",
|
|
1623
|
+
"role",
|
|
1624
|
+
"content",
|
|
1625
|
+
"content_type",
|
|
1626
|
+
"model_slug",
|
|
1627
|
+
"create_time",
|
|
1628
|
+
"on_current_branch",
|
|
1629
|
+
],
|
|
1630
|
+
},
|
|
1631
|
+
primaryKey: { conversations: ["id"], messages: ["id"] },
|
|
1632
|
+
// Each conversation is built from its own messages; the list is ordered by
|
|
1633
|
+
// the conversation's own update_time and id.
|
|
1634
|
+
window: {
|
|
1635
|
+
parentStream: "conversations",
|
|
1636
|
+
childStream: "messages",
|
|
1637
|
+
childKey: "conversation_id",
|
|
1638
|
+
arrayKey: "conversations",
|
|
1639
|
+
sumKeys: ["total"],
|
|
1640
|
+
parentOrder: newestUpdateFirst,
|
|
1641
|
+
},
|
|
1642
|
+
lossy: [
|
|
1643
|
+
"Conversation create/update times pass through as null when the source lacks them, matching legacy's listed?.create_time ?? fetched.create_time ?? null fallback.",
|
|
1644
|
+
"fetched_at is the projection time (options.now, else the wall clock), matching legacy's per-run toConversationRecord timestamp.",
|
|
1645
|
+
"A conversation without complete current-branch message evidence, a valid id, or valid timestamps is dropped and counted in a records_dropped diagnostic; nested full threads are not invented. Messages whose conversation is absent are dropped and counted the same way.",
|
|
1646
|
+
"Only user/assistant text or multimodal_text messages with nonempty string content are retained, matching the legacy connector's walkMessages filter; message_count is the retained count.",
|
|
1647
|
+
"A missing title becomes 'Untitled', matching the legacy connector's toConversationRecord fallback; model_slug is renamed to model.",
|
|
1648
|
+
"Legacy message ids are source node ids. ChatGPT 0.3.0 stores a message under '<conversation_id>:<node_id>' (and links parent_id the same way); the projection strips that prefix, reads a bare pre-0.3.0 id as it is, and counts a node stored under both forms once, preferring the 0.3.0 row.",
|
|
1649
|
+
],
|
|
1650
|
+
provenance: [
|
|
1651
|
+
{
|
|
1652
|
+
kind: "oci",
|
|
1653
|
+
ref: "ghcr.io/pdp-connect/connector/chatgpt:0.2.0",
|
|
1654
|
+
digest: "sha256:01777566b5163ca62bdb2bd21c316d09dd88f42c30a6d943ca101cfb635494ea",
|
|
1655
|
+
path: "declarations/chatgpt-0.2.0.collection-profile.json#streams[name=conversations,messages]",
|
|
1656
|
+
},
|
|
1657
|
+
],
|
|
1658
|
+
project(records, options) {
|
|
1659
|
+
const scope = "chatgpt.conversations";
|
|
1660
|
+
const guard = requireStreams(scope, options, ["conversations"]);
|
|
1661
|
+
if (guard)
|
|
1662
|
+
return guard;
|
|
1663
|
+
// Without a messages stream at all, a read-time caller still serves the
|
|
1664
|
+
// conversation list (titles and times) with empty threads, and says so.
|
|
1665
|
+
const messagesMissing = !options.fetchedStreams.includes("messages");
|
|
1666
|
+
if (messagesMissing && !options.allowMissingJoinStreams)
|
|
1667
|
+
return missingStream(scope, "messages");
|
|
1668
|
+
const fetchedAt = projectionTime(options);
|
|
1669
|
+
// One malformed conversation must not make the whole scope unreadable:
|
|
1670
|
+
// it is left out and counted, by reason.
|
|
1671
|
+
const dropped = new Map();
|
|
1672
|
+
const drop = (reason) => dropped.set(reason, (dropped.get(reason) ?? 0) + 1);
|
|
1673
|
+
let malformedMessages = 0;
|
|
1674
|
+
let unlinkedMessages = 0;
|
|
1675
|
+
const messagesByConversation = new Map();
|
|
1676
|
+
for (const message of byStream(records, "messages")) {
|
|
1677
|
+
if (!isObjectRow(message)) {
|
|
1678
|
+
malformedMessages += 1;
|
|
1679
|
+
continue;
|
|
1680
|
+
}
|
|
1681
|
+
if (typeof message.conversation_id !== "string") {
|
|
1682
|
+
unlinkedMessages += 1;
|
|
1683
|
+
continue;
|
|
1684
|
+
}
|
|
1685
|
+
const group = messagesByConversation.get(message.conversation_id) ?? [];
|
|
1686
|
+
group.push(message);
|
|
1687
|
+
messagesByConversation.set(message.conversation_id, group);
|
|
1688
|
+
}
|
|
1689
|
+
const sourceConversations = [];
|
|
1690
|
+
for (const row of byStream(records, "conversations")) {
|
|
1691
|
+
if (isObjectRow(row))
|
|
1692
|
+
sourceConversations.push(row);
|
|
1693
|
+
else
|
|
1694
|
+
drop("Conversation record is not an object");
|
|
1695
|
+
}
|
|
1696
|
+
const sourceIds = new Set(sourceConversations.map((c) => c.id));
|
|
1697
|
+
let orphanMessages = 0;
|
|
1698
|
+
for (const [id, group] of messagesByConversation) {
|
|
1699
|
+
if (!sourceIds.has(id))
|
|
1700
|
+
orphanMessages += group.length;
|
|
1701
|
+
}
|
|
1702
|
+
const conversations = [];
|
|
1703
|
+
for (const conversation of sourceConversations) {
|
|
1704
|
+
const { id, create_time, update_time, current_node, message_count_on_current_branch, } = conversation;
|
|
1705
|
+
if (!isOptionalString(create_time) || !isOptionalString(update_time)) {
|
|
1706
|
+
drop("Conversation timestamps must be strings, null, or absent");
|
|
1707
|
+
continue;
|
|
1708
|
+
}
|
|
1709
|
+
if (!isNonEmptyString(id)) {
|
|
1710
|
+
drop("Conversation lacks an id");
|
|
1711
|
+
continue;
|
|
1712
|
+
}
|
|
1713
|
+
const title = typeof conversation.title === "string" && conversation.title.length > 0
|
|
1714
|
+
? conversation.title
|
|
1715
|
+
: "Untitled";
|
|
1716
|
+
if (messagesMissing) {
|
|
1717
|
+
conversations.push({
|
|
1718
|
+
id,
|
|
1719
|
+
title,
|
|
1720
|
+
create_time: create_time ?? null,
|
|
1721
|
+
update_time: update_time ?? null,
|
|
1722
|
+
message_count: 0,
|
|
1723
|
+
messages: [],
|
|
1724
|
+
fetched_at: fetchedAt,
|
|
1725
|
+
});
|
|
1726
|
+
continue;
|
|
1727
|
+
}
|
|
1728
|
+
if (typeof message_count_on_current_branch !== "number" ||
|
|
1729
|
+
!Number.isInteger(message_count_on_current_branch) ||
|
|
1730
|
+
message_count_on_current_branch < 0) {
|
|
1731
|
+
drop("Conversation lacks a current-branch message count");
|
|
1732
|
+
continue;
|
|
1733
|
+
}
|
|
1734
|
+
// Legacy names a message by its source node id. Messages are stored
|
|
1735
|
+
// under their record id: the bare node id before ChatGPT 0.3.0,
|
|
1736
|
+
// `<conversation_id>:<node_id>` since. An instance that holds both
|
|
1737
|
+
// forms of one node uses the current one.
|
|
1738
|
+
const { byNode, unkeyed } = chatgptMessagesByNode(id, messagesByConversation.get(id));
|
|
1739
|
+
const branch = [...byNode.values(), ...unkeyed].filter((m) => m.on_current_branch === true);
|
|
1740
|
+
if (branch.length !== message_count_on_current_branch) {
|
|
1741
|
+
drop("Current branch message count does not match conversation");
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
const ordered = [];
|
|
1745
|
+
const seen = new Set();
|
|
1746
|
+
let node = typeof current_node === "string" ? current_node : null;
|
|
1747
|
+
while (node && !seen.has(node)) {
|
|
1748
|
+
const message = byNode.get(node);
|
|
1749
|
+
if (!message || message.on_current_branch !== true)
|
|
1750
|
+
break;
|
|
1751
|
+
seen.add(node);
|
|
1752
|
+
ordered.push(message);
|
|
1753
|
+
node =
|
|
1754
|
+
typeof message.parent_id === "string"
|
|
1755
|
+
? chatgptNodeId(id, message.parent_id)
|
|
1756
|
+
: null;
|
|
1757
|
+
}
|
|
1758
|
+
if (ordered.length !== branch.length) {
|
|
1759
|
+
drop("Current branch message chain is incomplete");
|
|
1760
|
+
continue;
|
|
1761
|
+
}
|
|
1762
|
+
ordered.reverse();
|
|
1763
|
+
const messages = ordered
|
|
1764
|
+
.filter((m) => (m.role === "user" || m.role === "assistant") &&
|
|
1765
|
+
(m.content_type === "text" ||
|
|
1766
|
+
m.content_type === "multimodal_text") &&
|
|
1767
|
+
typeof m.content === "string" &&
|
|
1768
|
+
m.content.length > 0)
|
|
1769
|
+
.map((m) => ({
|
|
1770
|
+
id: chatgptNodeId(id, m.id),
|
|
1771
|
+
role: m.role,
|
|
1772
|
+
content: m.content,
|
|
1773
|
+
content_type: m.content_type,
|
|
1774
|
+
create_time: typeof m.create_time === "string" ? m.create_time : null,
|
|
1775
|
+
model: typeof m.model_slug === "string" ? m.model_slug : null,
|
|
1776
|
+
}));
|
|
1777
|
+
conversations.push({
|
|
1778
|
+
id,
|
|
1779
|
+
title,
|
|
1780
|
+
create_time: create_time ?? null,
|
|
1781
|
+
update_time: update_time ?? null,
|
|
1782
|
+
message_count: messages.length,
|
|
1783
|
+
messages,
|
|
1784
|
+
fetched_at: fetchedAt,
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
const diagnostics = [];
|
|
1788
|
+
if (dropped.size > 0) {
|
|
1789
|
+
diagnostics.push({
|
|
1790
|
+
kind: "records_dropped",
|
|
1791
|
+
scope,
|
|
1792
|
+
stream: "conversations",
|
|
1793
|
+
count: [...dropped.values()].reduce((sum, n) => sum + n, 0),
|
|
1794
|
+
reasons: [...dropped.keys()],
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
if (orphanMessages + malformedMessages + unlinkedMessages > 0) {
|
|
1798
|
+
diagnostics.push({
|
|
1799
|
+
kind: "records_dropped",
|
|
1800
|
+
scope,
|
|
1801
|
+
stream: "messages",
|
|
1802
|
+
count: orphanMessages + malformedMessages + unlinkedMessages,
|
|
1803
|
+
reasons: [
|
|
1804
|
+
...(orphanMessages > 0
|
|
1805
|
+
? ["Messages have no matching conversation"]
|
|
1806
|
+
: []),
|
|
1807
|
+
...(malformedMessages > 0 ? ["Message record is not an object"] : []),
|
|
1808
|
+
...(unlinkedMessages > 0 ? ["Message lacks a conversation id"] : []),
|
|
1809
|
+
],
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
if (messagesMissing) {
|
|
1813
|
+
diagnostics.push({ kind: "stream_missing", scope, stream: "messages" });
|
|
1814
|
+
}
|
|
1815
|
+
// Legacy delivered the conversation list in ChatGPT's own order: most
|
|
1816
|
+
// recently updated first. A stable order keeps that order, not id order.
|
|
1817
|
+
if (options.orderByPrimaryKey)
|
|
1818
|
+
conversations.sort(newestUpdateFirst);
|
|
1819
|
+
return {
|
|
1820
|
+
ok: true,
|
|
1821
|
+
payload: { conversations, total: conversations.length },
|
|
1822
|
+
...(diagnostics.length > 0 ? { diagnostics } : {}),
|
|
1823
|
+
};
|
|
1824
|
+
},
|
|
1825
|
+
};
|
|
1826
|
+
/**
|
|
1827
|
+
* The source node id of a ChatGPT message record id. ChatGPT 0.3.0 and later
|
|
1828
|
+
* name a message `<conversation_id>:<node_id>`, because a node id can recur in
|
|
1829
|
+
* a forked conversation; earlier versions stored the bare node id. A
|
|
1830
|
+
* conversation id is a UUID and never contains ":", so the prefix is
|
|
1831
|
+
* unambiguous. Applies to `parent_id` too, which names a record the same way.
|
|
1832
|
+
*/
|
|
1833
|
+
function chatgptNodeId(conversationId, recordId) {
|
|
1834
|
+
const prefix = `${conversationId}:`;
|
|
1835
|
+
return recordId.startsWith(prefix) ? recordId.slice(prefix.length) : recordId;
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* One conversation's stored messages by source node id. When an instance holds
|
|
1839
|
+
* a node under both the pre-0.3.0 key and the 0.3.0 key, the 0.3.0 row wins:
|
|
1840
|
+
* it was written later, from the full source body.
|
|
1841
|
+
*/
|
|
1842
|
+
function chatgptMessagesByNode(conversationId, messages) {
|
|
1843
|
+
const byNode = new Map();
|
|
1844
|
+
const unkeyed = [];
|
|
1845
|
+
const current = new Set();
|
|
1846
|
+
for (const message of messages ?? []) {
|
|
1847
|
+
if (typeof message.id !== "string") {
|
|
1848
|
+
unkeyed.push(message);
|
|
1849
|
+
continue;
|
|
1850
|
+
}
|
|
1851
|
+
const node = chatgptNodeId(conversationId, message.id);
|
|
1852
|
+
const isCurrent = node !== message.id;
|
|
1853
|
+
if (byNode.has(node) && (current.has(node) || !isCurrent))
|
|
1854
|
+
continue;
|
|
1855
|
+
byNode.set(node, message);
|
|
1856
|
+
if (isCurrent)
|
|
1857
|
+
current.add(node);
|
|
1858
|
+
}
|
|
1859
|
+
return { byNode, unkeyed };
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Newest `update_time` first; a missing or unparseable time sorts last.
|
|
1863
|
+
* Ties fall back to the id, so the order never depends on input order.
|
|
1864
|
+
*/
|
|
1865
|
+
function newestUpdateFirst(a, b) {
|
|
1866
|
+
const time = (row) => {
|
|
1867
|
+
const parsed = typeof row.update_time === "string" ? Date.parse(row.update_time) : NaN;
|
|
1868
|
+
return Number.isNaN(parsed) ? -Infinity : parsed;
|
|
1869
|
+
};
|
|
1870
|
+
const byTime = time(b) - time(a);
|
|
1871
|
+
if (byTime !== 0 && !Number.isNaN(byTime))
|
|
1872
|
+
return byTime;
|
|
1873
|
+
return String(a.id) < String(b.id) ? -1 : String(a.id) > String(b.id) ? 1 : 0;
|
|
1874
|
+
}
|
|
1875
|
+
/**
|
|
1876
|
+
* The output order of a binding that lists its parents in primary-key order,
|
|
1877
|
+
* which is what `orderByPrimaryKey` gives it: the same key `inPrimaryKeyOrder`
|
|
1878
|
+
* sorts by.
|
|
1879
|
+
*/
|
|
1880
|
+
function primaryKeyOrder(field) {
|
|
1881
|
+
const key = (row) => JSON.stringify([row[field] ?? null]);
|
|
1882
|
+
return (a, b) => (key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0);
|
|
1883
|
+
}
|
|
1884
|
+
// This is the merged 0.1.3 source declaration. Admission remains a separate
|
|
1885
|
+
// decision; this local manifest hash is not the signed OCI artifact digest.
|
|
1886
|
+
export const ANTHROPIC_CONNECTOR_ID = "https://registry.pdpp.dev/connectors/anthropic";
|
|
1887
|
+
// Connector/method identity differs from the public source in the admitted declaration.
|
|
1888
|
+
export const CLAUDE_SOURCE_ID = "https://registry.pdpp.dev/sources/claude";
|
|
1889
|
+
const anthropicProjectionProvenance = [
|
|
1890
|
+
{
|
|
1891
|
+
kind: "collection-profile",
|
|
1892
|
+
ref: "PDP-Connect/data-connectors ae44adf769 (#160)",
|
|
1893
|
+
digest: "sha256:1a156e586c81a95cb3bb1ad9c09c639990a22212074cba7da62268c326593372",
|
|
1894
|
+
path: "declarations/anthropic-0.1.3.collection-profile.json#streams[name=account_profile,conversations,messages,projects,project_documents]",
|
|
1895
|
+
},
|
|
1896
|
+
];
|
|
1897
|
+
function claudeMetadata(scope, records) {
|
|
1898
|
+
const profiles = byStream(records, "account_profile");
|
|
1899
|
+
if (profiles.length !== 1) {
|
|
1900
|
+
return {
|
|
1901
|
+
ok: false,
|
|
1902
|
+
error: {
|
|
1903
|
+
kind: "incomplete_scope",
|
|
1904
|
+
scope,
|
|
1905
|
+
reason: "A single verified account_profile record is required",
|
|
1906
|
+
},
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
const profile = profiles[0];
|
|
1910
|
+
if (typeof profile.id !== "string" ||
|
|
1911
|
+
!profile.id.trim() ||
|
|
1912
|
+
typeof profile.organization_id !== "string" ||
|
|
1913
|
+
!profile.organization_id.trim() ||
|
|
1914
|
+
profile.id !== profile.organization_id ||
|
|
1915
|
+
!(typeof profile.full_name === "string" || profile.full_name === null) ||
|
|
1916
|
+
!(typeof profile.plan === "string" || profile.plan === null) ||
|
|
1917
|
+
!["browser_menu", "users_json", "none"].includes(profile.name_source) ||
|
|
1918
|
+
!["valid", "absent", "malformed", "ambiguous", "mismatch"].includes(profile.metadata_status)) {
|
|
1919
|
+
return {
|
|
1920
|
+
ok: false,
|
|
1921
|
+
error: {
|
|
1922
|
+
kind: "invalid_value",
|
|
1923
|
+
scope,
|
|
1924
|
+
reason: "account_profile does not match its declared verified contract",
|
|
1925
|
+
},
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
return {
|
|
1929
|
+
ok: true,
|
|
1930
|
+
profile: {
|
|
1931
|
+
name: profile.full_name,
|
|
1932
|
+
plan: profile.plan,
|
|
1933
|
+
},
|
|
1934
|
+
organizationId: profile.organization_id,
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
function claudeLiveMetadata(scope, records) {
|
|
1938
|
+
const plans = byStream(records, "account_plan");
|
|
1939
|
+
const plan = plans[0];
|
|
1940
|
+
if (plans.length !== 1 ||
|
|
1941
|
+
!plan ||
|
|
1942
|
+
typeof plan.id !== "string" ||
|
|
1943
|
+
!plan.id.trim() ||
|
|
1944
|
+
typeof plan.account_id !== "string" ||
|
|
1945
|
+
!plan.account_id.trim() ||
|
|
1946
|
+
!(typeof plan.plan_display_name === "string" ||
|
|
1947
|
+
plan.plan_display_name === null)) {
|
|
1948
|
+
return {
|
|
1949
|
+
ok: false,
|
|
1950
|
+
error: {
|
|
1951
|
+
kind: "incomplete_scope",
|
|
1952
|
+
scope,
|
|
1953
|
+
reason: "A single verified organization account_plan is required",
|
|
1954
|
+
},
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
return {
|
|
1958
|
+
ok: true,
|
|
1959
|
+
organizationId: plan.account_id,
|
|
1960
|
+
profile: { name: null, plan: plan.plan_display_name },
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
function claudeConversationsBinding(live = false) {
|
|
1964
|
+
const scope = "claude.conversations";
|
|
1965
|
+
return {
|
|
1966
|
+
scope,
|
|
1967
|
+
pdppSource: live
|
|
1968
|
+
? "https://registry.pdpp.dev/connectors/anthropic-live"
|
|
1969
|
+
: ANTHROPIC_CONNECTOR_ID,
|
|
1970
|
+
pdppStreams: [
|
|
1971
|
+
live ? "account_plan" : "account_profile",
|
|
1972
|
+
"conversations",
|
|
1973
|
+
"messages",
|
|
1974
|
+
],
|
|
1975
|
+
legacySchemaPath: "claude.conversations.json",
|
|
1976
|
+
fieldsRead: {
|
|
1977
|
+
...(live
|
|
1978
|
+
? { account_plan: ["id", "account_id", "plan_display_name"] }
|
|
1979
|
+
: {
|
|
1980
|
+
account_profile: [
|
|
1981
|
+
"id",
|
|
1982
|
+
"organization_id",
|
|
1983
|
+
"full_name",
|
|
1984
|
+
"plan",
|
|
1985
|
+
"name_source",
|
|
1986
|
+
"metadata_status",
|
|
1987
|
+
],
|
|
1988
|
+
}),
|
|
1989
|
+
conversations: [
|
|
1990
|
+
"id",
|
|
1991
|
+
"title",
|
|
1992
|
+
"create_time",
|
|
1993
|
+
"update_time",
|
|
1994
|
+
"project_id",
|
|
1995
|
+
"message_count",
|
|
1996
|
+
"is_starred",
|
|
1997
|
+
],
|
|
1998
|
+
messages: [
|
|
1999
|
+
"id",
|
|
2000
|
+
"conversation_id",
|
|
2001
|
+
"role",
|
|
2002
|
+
"parent_id",
|
|
2003
|
+
"content",
|
|
2004
|
+
"create_time",
|
|
2005
|
+
"update_time",
|
|
2006
|
+
"attachments",
|
|
2007
|
+
],
|
|
2008
|
+
},
|
|
2009
|
+
primaryKey: {
|
|
2010
|
+
[live ? "account_plan" : "account_profile"]: ["id"],
|
|
2011
|
+
conversations: ["id"],
|
|
2012
|
+
messages: ["id"],
|
|
2013
|
+
},
|
|
2014
|
+
// Each conversation is built from its own messages. The list is in
|
|
2015
|
+
// primary-key order, the order `inPrimaryKeyOrder` gives it.
|
|
2016
|
+
window: {
|
|
2017
|
+
parentStream: "conversations",
|
|
2018
|
+
childStream: "messages",
|
|
2019
|
+
childKey: "conversation_id",
|
|
2020
|
+
arrayKey: "conversations",
|
|
2021
|
+
sumKeys: ["total", "messageTotal"],
|
|
2022
|
+
parentOrder: primaryKeyOrder("id"),
|
|
2023
|
+
},
|
|
2024
|
+
lossy: [
|
|
2025
|
+
"href is reconstructed from the retained Claude route convention; rawContent and unavailable fetchError are omitted.",
|
|
2026
|
+
],
|
|
2027
|
+
// The live declaration's conversation blob_ref is the raw envelope; its
|
|
2028
|
+
// typed record and messages are complete without it.
|
|
2029
|
+
...(live ? { ancillaryBlobStreams: ["conversations"] } : {}),
|
|
2030
|
+
provenance: live
|
|
2031
|
+
? [
|
|
2032
|
+
{
|
|
2033
|
+
kind: "oci",
|
|
2034
|
+
ref: "ghcr.io/pdp-connect/connector/anthropic-live:0.3.6",
|
|
2035
|
+
digest: "sha256:817716e8c732c9c991be507049147a0cc887b154363428bc4509cc91ed5d17a6",
|
|
2036
|
+
path: "declarations/anthropic-live-0.3.6.collection-profile.json",
|
|
2037
|
+
},
|
|
2038
|
+
]
|
|
2039
|
+
: anthropicProjectionProvenance,
|
|
2040
|
+
project(records, options) {
|
|
2041
|
+
const guard = requireStreams(scope, options, [
|
|
2042
|
+
live ? "account_plan" : "account_profile",
|
|
2043
|
+
"conversations",
|
|
2044
|
+
"messages",
|
|
2045
|
+
]);
|
|
2046
|
+
if (guard)
|
|
2047
|
+
return guard;
|
|
2048
|
+
const metadata = live
|
|
2049
|
+
? claudeLiveMetadata(scope, records)
|
|
2050
|
+
: claudeMetadata(scope, records);
|
|
2051
|
+
if (!metadata.ok)
|
|
2052
|
+
return metadata;
|
|
2053
|
+
const conversations = byStream(records, "conversations");
|
|
2054
|
+
const messagesByConversation = new Map();
|
|
2055
|
+
for (const message of byStream(records, "messages")) {
|
|
2056
|
+
if (typeof message.conversation_id !== "string")
|
|
2057
|
+
return {
|
|
2058
|
+
ok: false,
|
|
2059
|
+
error: {
|
|
2060
|
+
kind: "invalid_value",
|
|
2061
|
+
scope,
|
|
2062
|
+
reason: "Message has no conversation id",
|
|
2063
|
+
},
|
|
2064
|
+
};
|
|
2065
|
+
const rows = messagesByConversation.get(message.conversation_id) ?? [];
|
|
2066
|
+
rows.push(message);
|
|
2067
|
+
messagesByConversation.set(message.conversation_id, rows);
|
|
2068
|
+
}
|
|
2069
|
+
const ids = new Set(conversations.map((conversation) => conversation.id));
|
|
2070
|
+
if ([...messagesByConversation.keys()].some((id) => !ids.has(id)))
|
|
2071
|
+
return {
|
|
2072
|
+
ok: false,
|
|
2073
|
+
error: {
|
|
2074
|
+
kind: "invalid_value",
|
|
2075
|
+
scope,
|
|
2076
|
+
reason: "Messages have no matching conversation",
|
|
2077
|
+
},
|
|
2078
|
+
};
|
|
2079
|
+
const projected = [];
|
|
2080
|
+
let unknownMessageCounts = 0;
|
|
2081
|
+
for (const conversation of conversations) {
|
|
2082
|
+
if (typeof conversation.id !== "string" ||
|
|
2083
|
+
!conversation.id.trim() ||
|
|
2084
|
+
!(typeof conversation.title === "string" ||
|
|
2085
|
+
conversation.title === null))
|
|
2086
|
+
return {
|
|
2087
|
+
ok: false,
|
|
2088
|
+
error: {
|
|
2089
|
+
kind: "invalid_value",
|
|
2090
|
+
scope,
|
|
2091
|
+
reason: "Conversation id or title has invalid source shape",
|
|
2092
|
+
},
|
|
2093
|
+
};
|
|
2094
|
+
const sourceMessages = messagesByConversation.get(conversation.id) ?? [];
|
|
2095
|
+
if (sourceMessages.some((message) => typeof message.id !== "string" ||
|
|
2096
|
+
!(typeof message.content === "string" || message.content === null) ||
|
|
2097
|
+
!(Array.isArray(message.attachments) ||
|
|
2098
|
+
message.attachments === null)))
|
|
2099
|
+
return {
|
|
2100
|
+
ok: false,
|
|
2101
|
+
error: {
|
|
2102
|
+
kind: "invalid_value",
|
|
2103
|
+
scope,
|
|
2104
|
+
reason: "Message does not match declared source shape",
|
|
2105
|
+
},
|
|
2106
|
+
};
|
|
2107
|
+
const messages = [...sourceMessages]
|
|
2108
|
+
.sort((a, b) => (Date.parse(a.create_time || "") || 0) -
|
|
2109
|
+
(Date.parse(b.create_time || "") || 0))
|
|
2110
|
+
.map((message) => {
|
|
2111
|
+
return {
|
|
2112
|
+
id: message.id,
|
|
2113
|
+
sender: message.role ?? null,
|
|
2114
|
+
parentId: message.parent_id ?? null,
|
|
2115
|
+
createdAt: message.create_time ?? null,
|
|
2116
|
+
updatedAt: message.update_time ?? null,
|
|
2117
|
+
content: message.content ?? "",
|
|
2118
|
+
attachments: message.attachments ?? [],
|
|
2119
|
+
};
|
|
2120
|
+
});
|
|
2121
|
+
// Only the source's own count proves the fetched messages are the
|
|
2122
|
+
// whole conversation. Without one (anthropic-live writes null when
|
|
2123
|
+
// the run did not read the detail) the conversation is reported
|
|
2124
|
+
// partial, never certified complete. messageCount stays the number
|
|
2125
|
+
// of messages collected, as the legacy schema defines it.
|
|
2126
|
+
const sourceCount = conversation.message_count ?? null;
|
|
2127
|
+
const messageCount = messages.length;
|
|
2128
|
+
if (sourceCount === null)
|
|
2129
|
+
unknownMessageCounts += 1;
|
|
2130
|
+
else if (sourceCount !== messageCount)
|
|
2131
|
+
return {
|
|
2132
|
+
ok: false,
|
|
2133
|
+
error: {
|
|
2134
|
+
kind: "incomplete_scope",
|
|
2135
|
+
scope,
|
|
2136
|
+
reason: "Fetched messages do not match conversation message_count",
|
|
2137
|
+
},
|
|
2138
|
+
};
|
|
2139
|
+
projected.push({
|
|
2140
|
+
id: conversation.id,
|
|
2141
|
+
title: conversation.title || "Untitled",
|
|
2142
|
+
href: `/chat/${conversation.id}`,
|
|
2143
|
+
createdAt: conversation.create_time ?? null,
|
|
2144
|
+
updatedAt: conversation.update_time ?? null,
|
|
2145
|
+
starred: conversation.is_starred ?? null,
|
|
2146
|
+
projectId: conversation.project_id ?? null,
|
|
2147
|
+
messageCount,
|
|
2148
|
+
messages,
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
const diagnostics = partialRows(scope, "conversations", "message_count_unknown", unknownMessageCounts);
|
|
2152
|
+
return {
|
|
2153
|
+
ok: true,
|
|
2154
|
+
...(diagnostics.length > 0 ? { diagnostics } : {}),
|
|
2155
|
+
payload: {
|
|
2156
|
+
profile: metadata.profile,
|
|
2157
|
+
organizationId: metadata.organizationId,
|
|
2158
|
+
conversations: projected,
|
|
2159
|
+
total: projected.length,
|
|
2160
|
+
messageTotal: projected.reduce((total, conversation) => total + conversation.messageCount, 0),
|
|
2161
|
+
source: live ? "live-session" : "official-export",
|
|
2162
|
+
},
|
|
2163
|
+
};
|
|
2164
|
+
},
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
export const ANTHROPIC_LIVE_BINDINGS = new Map([["claude.conversations", claudeConversationsBinding(true)]]);
|
|
2168
|
+
const claudeConversations = claudeConversationsBinding();
|
|
2169
|
+
const claudeProjects = {
|
|
2170
|
+
scope: "claude.projects",
|
|
2171
|
+
pdppSource: ANTHROPIC_CONNECTOR_ID,
|
|
2172
|
+
pdppStreams: ["account_profile", "projects", "project_documents"],
|
|
2173
|
+
legacySchemaPath: "claude.projects.json",
|
|
2174
|
+
fieldsRead: {
|
|
2175
|
+
account_profile: [
|
|
2176
|
+
"id",
|
|
2177
|
+
"organization_id",
|
|
2178
|
+
"full_name",
|
|
2179
|
+
"plan",
|
|
2180
|
+
"name_source",
|
|
2181
|
+
"metadata_status",
|
|
2182
|
+
],
|
|
2183
|
+
projects: [
|
|
2184
|
+
"id",
|
|
2185
|
+
"name",
|
|
2186
|
+
"description",
|
|
2187
|
+
"create_time",
|
|
2188
|
+
"update_time",
|
|
2189
|
+
"is_archived",
|
|
2190
|
+
"prompt_template",
|
|
2191
|
+
"creator",
|
|
2192
|
+
"is_private",
|
|
2193
|
+
"is_starter_project",
|
|
2194
|
+
"archived_at",
|
|
2195
|
+
"raw_docs",
|
|
2196
|
+
],
|
|
2197
|
+
project_documents: [
|
|
2198
|
+
"id",
|
|
2199
|
+
"project_id",
|
|
2200
|
+
"filename",
|
|
2201
|
+
"content",
|
|
2202
|
+
"create_time",
|
|
2203
|
+
"update_time",
|
|
2204
|
+
],
|
|
2205
|
+
},
|
|
2206
|
+
primaryKey: {
|
|
2207
|
+
account_profile: ["id"],
|
|
2208
|
+
projects: ["id"],
|
|
2209
|
+
project_documents: ["id"],
|
|
2210
|
+
},
|
|
2211
|
+
// Each project is built from its own project_documents.
|
|
2212
|
+
window: {
|
|
2213
|
+
parentStream: "projects",
|
|
2214
|
+
childStream: "project_documents",
|
|
2215
|
+
childKey: "project_id",
|
|
2216
|
+
arrayKey: "projects",
|
|
2217
|
+
sumKeys: ["total"],
|
|
2218
|
+
parentOrder: primaryKeyOrder("id"),
|
|
2219
|
+
},
|
|
2220
|
+
lossy: [
|
|
2221
|
+
"detail carries only declared project and raw document fields. Other raw-only keys and documents dropped by source parsing cannot be recovered; href and label follow the legacy connector's route and label rules.",
|
|
2222
|
+
],
|
|
2223
|
+
provenance: anthropicProjectionProvenance,
|
|
2224
|
+
project(records, options) {
|
|
2225
|
+
const scope = "claude.projects";
|
|
2226
|
+
const guard = requireStreams(scope, options, [
|
|
2227
|
+
"account_profile",
|
|
2228
|
+
"projects",
|
|
2229
|
+
"project_documents",
|
|
2230
|
+
]);
|
|
2231
|
+
if (guard)
|
|
2232
|
+
return guard;
|
|
2233
|
+
const metadata = claudeMetadata(scope, records);
|
|
2234
|
+
if (!metadata.ok)
|
|
2235
|
+
return metadata;
|
|
2236
|
+
const documents = byStream(records, "project_documents");
|
|
2237
|
+
const projects = byStream(records, "projects");
|
|
2238
|
+
const projectIds = new Set(projects.map((project) => project.id));
|
|
2239
|
+
if (documents.some((document) => typeof document.project_id !== "string" ||
|
|
2240
|
+
!projectIds.has(document.project_id)))
|
|
2241
|
+
return {
|
|
2242
|
+
ok: false,
|
|
2243
|
+
error: {
|
|
2244
|
+
kind: "invalid_value",
|
|
2245
|
+
scope,
|
|
2246
|
+
reason: "Project document has no matching project",
|
|
2247
|
+
},
|
|
2248
|
+
};
|
|
2249
|
+
const projected = [];
|
|
2250
|
+
for (const project of projects) {
|
|
2251
|
+
if (typeof project.id !== "string" ||
|
|
2252
|
+
!project.id.trim() ||
|
|
2253
|
+
typeof project.name !== "string")
|
|
2254
|
+
return {
|
|
2255
|
+
ok: false,
|
|
2256
|
+
error: {
|
|
2257
|
+
kind: "invalid_value",
|
|
2258
|
+
scope,
|
|
2259
|
+
reason: "Project id and name are required by the legacy payload",
|
|
2260
|
+
},
|
|
2261
|
+
};
|
|
2262
|
+
const docs = documents
|
|
2263
|
+
.filter((document) => document.project_id === project.id)
|
|
2264
|
+
.map((document) => ({
|
|
2265
|
+
uuid: document.id,
|
|
2266
|
+
filename: document.filename ?? null,
|
|
2267
|
+
content: document.content ?? null,
|
|
2268
|
+
created_at: document.create_time ?? null,
|
|
2269
|
+
updated_at: document.update_time ?? null,
|
|
2270
|
+
}));
|
|
2271
|
+
const detail = {
|
|
2272
|
+
uuid: project.id,
|
|
2273
|
+
name: project.name,
|
|
2274
|
+
docs,
|
|
2275
|
+
};
|
|
2276
|
+
for (const [sourceKey, legacyKey] of [
|
|
2277
|
+
["description", "description"],
|
|
2278
|
+
["create_time", "created_at"],
|
|
2279
|
+
["update_time", "updated_at"],
|
|
2280
|
+
["prompt_template", "prompt_template"],
|
|
2281
|
+
]) {
|
|
2282
|
+
if (project[sourceKey] !== undefined)
|
|
2283
|
+
detail[legacyKey] = project[sourceKey];
|
|
2284
|
+
}
|
|
2285
|
+
for (const key of ["is_private", "is_starter_project"]) {
|
|
2286
|
+
const value = project[key];
|
|
2287
|
+
if (value !== undefined) {
|
|
2288
|
+
if (value !== null && typeof value !== "boolean")
|
|
2289
|
+
return {
|
|
2290
|
+
ok: false,
|
|
2291
|
+
error: {
|
|
2292
|
+
kind: "invalid_value",
|
|
2293
|
+
scope,
|
|
2294
|
+
reason: `${key} has invalid source shape`,
|
|
2295
|
+
},
|
|
2296
|
+
};
|
|
2297
|
+
detail[key] = value;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
if (project.archived_at !== undefined) {
|
|
2301
|
+
if (project.archived_at !== null &&
|
|
2302
|
+
typeof project.archived_at !== "string")
|
|
2303
|
+
return {
|
|
2304
|
+
ok: false,
|
|
2305
|
+
error: {
|
|
2306
|
+
kind: "invalid_value",
|
|
2307
|
+
scope,
|
|
2308
|
+
reason: "archived_at has invalid source shape",
|
|
2309
|
+
},
|
|
2310
|
+
};
|
|
2311
|
+
detail.archived_at = project.archived_at;
|
|
2312
|
+
}
|
|
2313
|
+
if (project.creator !== undefined) {
|
|
2314
|
+
const creator = project.creator;
|
|
2315
|
+
if (creator !== null &&
|
|
2316
|
+
(typeof creator !== "object" || Array.isArray(creator)))
|
|
2317
|
+
return {
|
|
2318
|
+
ok: false,
|
|
2319
|
+
error: {
|
|
2320
|
+
kind: "invalid_value",
|
|
2321
|
+
scope,
|
|
2322
|
+
reason: "creator has invalid source shape",
|
|
2323
|
+
},
|
|
2324
|
+
};
|
|
2325
|
+
if (creator === null)
|
|
2326
|
+
detail.creator = null;
|
|
2327
|
+
else {
|
|
2328
|
+
const value = creator;
|
|
2329
|
+
if (["uuid", "full_name"].some((key) => value[key] !== undefined && typeof value[key] !== "string"))
|
|
2330
|
+
return {
|
|
2331
|
+
ok: false,
|
|
2332
|
+
error: {
|
|
2333
|
+
kind: "invalid_value",
|
|
2334
|
+
scope,
|
|
2335
|
+
reason: "creator fields have invalid source shape",
|
|
2336
|
+
},
|
|
2337
|
+
};
|
|
2338
|
+
detail.creator = Object.fromEntries(["uuid", "full_name"]
|
|
2339
|
+
.filter((key) => value[key] !== undefined)
|
|
2340
|
+
.map((key) => [key, value[key]]));
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
if (project.raw_docs !== undefined) {
|
|
2344
|
+
if (!Array.isArray(project.raw_docs))
|
|
2345
|
+
return {
|
|
2346
|
+
ok: false,
|
|
2347
|
+
error: {
|
|
2348
|
+
kind: "invalid_value",
|
|
2349
|
+
scope,
|
|
2350
|
+
reason: "raw_docs has invalid source shape",
|
|
2351
|
+
},
|
|
2352
|
+
};
|
|
2353
|
+
const rawKeys = [
|
|
2354
|
+
"uuid",
|
|
2355
|
+
"filename",
|
|
2356
|
+
"content",
|
|
2357
|
+
"created_at",
|
|
2358
|
+
"updated_at",
|
|
2359
|
+
];
|
|
2360
|
+
const rawDocs = [];
|
|
2361
|
+
for (const raw of project.raw_docs) {
|
|
2362
|
+
if (!raw ||
|
|
2363
|
+
typeof raw !== "object" ||
|
|
2364
|
+
Array.isArray(raw) ||
|
|
2365
|
+
rawKeys.some((key) => raw[key] !== undefined &&
|
|
2366
|
+
typeof raw[key] !== "string"))
|
|
2367
|
+
return {
|
|
2368
|
+
ok: false,
|
|
2369
|
+
error: {
|
|
2370
|
+
kind: "invalid_value",
|
|
2371
|
+
scope,
|
|
2372
|
+
reason: "raw document has invalid source shape",
|
|
2373
|
+
},
|
|
2374
|
+
};
|
|
2375
|
+
const value = raw;
|
|
2376
|
+
rawDocs.push(Object.fromEntries(rawKeys
|
|
2377
|
+
.filter((key) => value[key] !== undefined)
|
|
2378
|
+
.map((key) => [key, value[key]])));
|
|
2379
|
+
}
|
|
2380
|
+
detail.raw_docs = rawDocs;
|
|
2381
|
+
}
|
|
2382
|
+
projected.push({
|
|
2383
|
+
id: project.id,
|
|
2384
|
+
title: project.name,
|
|
2385
|
+
href: `/project/${project.id}`,
|
|
2386
|
+
label: `Project, ${project.name}`,
|
|
2387
|
+
createdAt: project.create_time ?? null,
|
|
2388
|
+
updatedAt: project.update_time ?? null,
|
|
2389
|
+
// Legacy emits `Boolean(p?.archived_at)` (claude-export-playwright.js
|
|
2390
|
+
// normalizeProject), so the value is always a boolean, never null.
|
|
2391
|
+
archived: project.is_archived === true || Boolean(project.archived_at),
|
|
2392
|
+
detail,
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
return {
|
|
2396
|
+
ok: true,
|
|
2397
|
+
payload: {
|
|
2398
|
+
profile: metadata.profile,
|
|
2399
|
+
organizationId: metadata.organizationId,
|
|
2400
|
+
projects: projected,
|
|
2401
|
+
total: projected.length,
|
|
2402
|
+
source: "official-export",
|
|
2403
|
+
},
|
|
2404
|
+
};
|
|
2405
|
+
},
|
|
2406
|
+
};
|
|
2407
|
+
// ---------------------------------------------------------------------------
|
|
2408
|
+
// linkedin
|
|
2409
|
+
// declarations/linkedin.collection-profile.json
|
|
2410
|
+
// connector_id: https://registry.pdpp.dev/connectors/linkedin
|
|
2411
|
+
// ---------------------------------------------------------------------------
|
|
2412
|
+
const linkedinProfile = {
|
|
2413
|
+
scope: "linkedin.profile",
|
|
2414
|
+
pdppSource: "https://registry.pdpp.dev/connectors/linkedin",
|
|
2415
|
+
pdppStreams: ["profile"],
|
|
2416
|
+
legacySchemaPath: "linkedin.profile.json",
|
|
2417
|
+
fieldsRead: {
|
|
2418
|
+
profile: [
|
|
2419
|
+
"public_url",
|
|
2420
|
+
"full_name",
|
|
2421
|
+
"headline",
|
|
2422
|
+
"location",
|
|
2423
|
+
"connection_count",
|
|
2424
|
+
"profile_picture_url",
|
|
2425
|
+
"summary",
|
|
2426
|
+
],
|
|
2427
|
+
},
|
|
2428
|
+
primaryKey: { profile: ["id"] },
|
|
2429
|
+
lossy: [
|
|
2430
|
+
"public_url, full_name, headline, location, profile_picture_url, summary: null/missing values become '' to satisfy the required legacy string fields",
|
|
2431
|
+
"connection_count: absent or non-finite/non-number values become '0'; the legacy connector could replace its initial '0' with a fetched connection count, which this projection does not derive",
|
|
2432
|
+
],
|
|
2433
|
+
provenance: [
|
|
2434
|
+
{
|
|
2435
|
+
kind: "oci",
|
|
2436
|
+
ref: "ghcr.io/pdp-connect/connector/linkedin:0.3.1",
|
|
2437
|
+
digest: "sha256:7544a6c015bf4b730afdd97a7521608d10d1c077950af5e9f3adc9405609fd68",
|
|
2438
|
+
path: "declarations/linkedin.collection-profile.json#streams[name=profile]",
|
|
2439
|
+
},
|
|
2440
|
+
],
|
|
2441
|
+
project(records, options) {
|
|
2442
|
+
const guard = requireStreams("linkedin.profile", options, ["profile"]);
|
|
2443
|
+
if (guard) {
|
|
2444
|
+
return guard;
|
|
2445
|
+
}
|
|
2446
|
+
const [profile] = byStream(records, "profile");
|
|
2447
|
+
if (!profile) {
|
|
2448
|
+
return {
|
|
2449
|
+
ok: false,
|
|
2450
|
+
error: { kind: "empty_singleton", scope: "linkedin.profile" },
|
|
2451
|
+
};
|
|
2452
|
+
}
|
|
2453
|
+
return {
|
|
2454
|
+
ok: true,
|
|
2455
|
+
payload: {
|
|
2456
|
+
profileUrl: orEmptyString(profile.public_url),
|
|
2457
|
+
fullName: orEmptyString(profile.full_name),
|
|
2458
|
+
headline: orEmptyString(profile.headline),
|
|
2459
|
+
location: orEmptyString(profile.location),
|
|
2460
|
+
connections: typeof profile.connection_count === "number" &&
|
|
2461
|
+
Number.isFinite(profile.connection_count)
|
|
2462
|
+
? String(profile.connection_count)
|
|
2463
|
+
: "0",
|
|
2464
|
+
profilePictureUrl: orEmptyString(profile.profile_picture_url),
|
|
2465
|
+
// The legacy connector reads this same Voyager summary as `about`.
|
|
2466
|
+
about: orEmptyString(profile.summary),
|
|
2467
|
+
},
|
|
2468
|
+
};
|
|
2469
|
+
},
|
|
2470
|
+
};
|
|
2471
|
+
const linkedinConnections = {
|
|
2472
|
+
scope: "linkedin.connections",
|
|
2473
|
+
pdppSource: "https://registry.pdpp.dev/connectors/linkedin",
|
|
2474
|
+
pdppStreams: ["connections"],
|
|
2475
|
+
legacySchemaPath: "linkedin.connections.json",
|
|
2476
|
+
fieldsRead: {
|
|
2477
|
+
connections: ["id", "full_name", "headline", "profile_url", "connected_at"],
|
|
2478
|
+
},
|
|
2479
|
+
primaryKey: { connections: ["id"] },
|
|
2480
|
+
lossy: [
|
|
2481
|
+
"Null full_name, headline, and profile_url become empty strings, matching the legacy connector's own fallback; connected_at is reduced to the legacy YYYY-MM-DD date text, with missing/invalid values becoming the legacy empty-string fallback.",
|
|
2482
|
+
],
|
|
2483
|
+
provenance: [
|
|
2484
|
+
{
|
|
2485
|
+
kind: "oci",
|
|
2486
|
+
ref: "ghcr.io/pdp-connect/connector/linkedin:0.3.1",
|
|
2487
|
+
digest: "sha256:7544a6c015bf4b730afdd97a7521608d10d1c077950af5e9f3adc9405609fd68",
|
|
2488
|
+
path: "declarations/linkedin.collection-profile.json#streams[name=connections]",
|
|
2489
|
+
},
|
|
2490
|
+
],
|
|
2491
|
+
project(records, options) {
|
|
2492
|
+
const guard = requireStreams("linkedin.connections", options, [
|
|
2493
|
+
"connections",
|
|
2494
|
+
]);
|
|
2495
|
+
if (guard)
|
|
2496
|
+
return guard;
|
|
2497
|
+
return {
|
|
2498
|
+
ok: true,
|
|
2499
|
+
payload: {
|
|
2500
|
+
connections: byStream(records, "connections").map((r) => ({
|
|
2501
|
+
fullName: orEmptyString(r.full_name),
|
|
2502
|
+
headline: orEmptyString(r.headline),
|
|
2503
|
+
profileUrl: orEmptyString(r.profile_url),
|
|
2504
|
+
dateConnected: typeof r.connected_at === "string" &&
|
|
2505
|
+
!Number.isNaN(new Date(r.connected_at).getTime())
|
|
2506
|
+
? new Date(r.connected_at).toISOString().slice(0, 10)
|
|
2507
|
+
: "",
|
|
2508
|
+
})),
|
|
2509
|
+
},
|
|
2510
|
+
};
|
|
2511
|
+
},
|
|
2512
|
+
};
|
|
2513
|
+
const linkedinExperience = {
|
|
2514
|
+
scope: "linkedin.experience",
|
|
2515
|
+
pdppSource: "https://registry.pdpp.dev/connectors/linkedin",
|
|
2516
|
+
pdppStreams: ["experience"],
|
|
2517
|
+
legacySchemaPath: "linkedin.experience.json",
|
|
2518
|
+
fieldsRead: {
|
|
2519
|
+
experience: [
|
|
2520
|
+
"title",
|
|
2521
|
+
"company",
|
|
2522
|
+
"start_date",
|
|
2523
|
+
"end_date",
|
|
2524
|
+
"location",
|
|
2525
|
+
"description",
|
|
2526
|
+
],
|
|
2527
|
+
},
|
|
2528
|
+
primaryKey: { experience: ["id"] },
|
|
2529
|
+
lossy: [
|
|
2530
|
+
"location, description: PDPP-side null projects as '' (matches legacy's own `pos.locationName || ''` / `pos.description || ''`)",
|
|
2531
|
+
],
|
|
2532
|
+
provenance: [
|
|
2533
|
+
{
|
|
2534
|
+
kind: "oci",
|
|
2535
|
+
ref: "ghcr.io/pdp-connect/connector/linkedin:0.3.1",
|
|
2536
|
+
digest: "sha256:7544a6c015bf4b730afdd97a7521608d10d1c077950af5e9f3adc9405609fd68",
|
|
2537
|
+
path: "declarations/linkedin.collection-profile.json#streams[name=experience]",
|
|
2538
|
+
},
|
|
2539
|
+
],
|
|
2540
|
+
project(records, options) {
|
|
2541
|
+
const guard = requireStreams("linkedin.experience", options, [
|
|
2542
|
+
"experience",
|
|
2543
|
+
]);
|
|
2544
|
+
if (guard) {
|
|
2545
|
+
return guard;
|
|
2546
|
+
}
|
|
2547
|
+
const items = byStream(records, "experience");
|
|
2548
|
+
// Legacy `dates` is one free-text field, "M/YYYY - M/YYYY" or
|
|
2549
|
+
// "M/YYYY - Present" (linkedin-playwright.js:129-145,
|
|
2550
|
+
// extractTimePeriod). PDPP declares separate start_date/end_date as
|
|
2551
|
+
// date-time strings; toLegacyTimePeriod reproduces the exact legacy
|
|
2552
|
+
// format from those two real fields, not a fabricated one.
|
|
2553
|
+
return {
|
|
2554
|
+
ok: true,
|
|
2555
|
+
payload: {
|
|
2556
|
+
experiences: items.map((e) => ({
|
|
2557
|
+
jobTitle: orEmptyString(e.title),
|
|
2558
|
+
companyName: orEmptyString(e.company),
|
|
2559
|
+
dates: toLegacyTimePeriod(e.start_date, e.end_date),
|
|
2560
|
+
location: orEmptyString(e.location),
|
|
2561
|
+
description: orEmptyString(e.description),
|
|
2562
|
+
})),
|
|
2563
|
+
},
|
|
2564
|
+
};
|
|
2565
|
+
},
|
|
2566
|
+
};
|
|
2567
|
+
const linkedinEducation = {
|
|
2568
|
+
scope: "linkedin.education",
|
|
2569
|
+
pdppSource: "https://registry.pdpp.dev/connectors/linkedin",
|
|
2570
|
+
pdppStreams: ["education"],
|
|
2571
|
+
legacySchemaPath: "linkedin.education.json",
|
|
2572
|
+
fieldsRead: {
|
|
2573
|
+
education: [
|
|
2574
|
+
"school",
|
|
2575
|
+
"degree",
|
|
2576
|
+
"field_of_study",
|
|
2577
|
+
"start_date",
|
|
2578
|
+
"end_date",
|
|
2579
|
+
"grade",
|
|
2580
|
+
"logo_url",
|
|
2581
|
+
],
|
|
2582
|
+
},
|
|
2583
|
+
primaryKey: { education: ["id"] },
|
|
2584
|
+
lossy: [
|
|
2585
|
+
"school, degree, grade, logo_url: null/missing values become '' to satisfy the required legacy string fields",
|
|
2586
|
+
],
|
|
2587
|
+
provenance: [
|
|
2588
|
+
{
|
|
2589
|
+
kind: "oci",
|
|
2590
|
+
ref: "ghcr.io/pdp-connect/connector/linkedin:0.3.1",
|
|
2591
|
+
digest: "sha256:7544a6c015bf4b730afdd97a7521608d10d1c077950af5e9f3adc9405609fd68",
|
|
2592
|
+
path: "declarations/linkedin.collection-profile.json#streams[name=education]",
|
|
2593
|
+
},
|
|
2594
|
+
],
|
|
2595
|
+
project(records, options) {
|
|
2596
|
+
const guard = requireStreams("linkedin.education", options, ["education"]);
|
|
2597
|
+
if (guard) {
|
|
2598
|
+
return guard;
|
|
2599
|
+
}
|
|
2600
|
+
const items = byStream(records, "education");
|
|
2601
|
+
return {
|
|
2602
|
+
ok: true,
|
|
2603
|
+
payload: {
|
|
2604
|
+
education: items.map((e) => ({
|
|
2605
|
+
schoolName: orEmptyString(e.school),
|
|
2606
|
+
degree: [orEmptyString(e.degree), orEmptyString(e.field_of_study)]
|
|
2607
|
+
.filter(Boolean)
|
|
2608
|
+
.join(", "),
|
|
2609
|
+
years: toLegacyTimePeriod(e.start_date, e.end_date),
|
|
2610
|
+
grade: orEmptyString(e.grade),
|
|
2611
|
+
logoUrl: orEmptyString(e.logo_url),
|
|
2612
|
+
})),
|
|
2613
|
+
},
|
|
2614
|
+
};
|
|
2615
|
+
},
|
|
2616
|
+
};
|
|
2617
|
+
const linkedinLanguages = {
|
|
2618
|
+
scope: "linkedin.languages",
|
|
2619
|
+
pdppSource: "https://registry.pdpp.dev/connectors/linkedin",
|
|
2620
|
+
pdppStreams: ["languages"],
|
|
2621
|
+
legacySchemaPath: "linkedin.languages.json",
|
|
2622
|
+
fieldsRead: { languages: ["name", "proficiency"] },
|
|
2623
|
+
primaryKey: { languages: ["id"] },
|
|
2624
|
+
lossy: [
|
|
2625
|
+
"proficiency: null/missing values become '' to satisfy the required legacy string field",
|
|
2626
|
+
],
|
|
2627
|
+
provenance: [
|
|
2628
|
+
{
|
|
2629
|
+
kind: "oci",
|
|
2630
|
+
ref: "ghcr.io/pdp-connect/connector/linkedin:0.3.1",
|
|
2631
|
+
digest: "sha256:7544a6c015bf4b730afdd97a7521608d10d1c077950af5e9f3adc9405609fd68",
|
|
2632
|
+
path: "declarations/linkedin.collection-profile.json#streams[name=languages]",
|
|
2633
|
+
},
|
|
2634
|
+
],
|
|
2635
|
+
project(records, options) {
|
|
2636
|
+
const guard = requireStreams("linkedin.languages", options, ["languages"]);
|
|
2637
|
+
if (guard) {
|
|
2638
|
+
return guard;
|
|
2639
|
+
}
|
|
2640
|
+
const items = byStream(records, "languages");
|
|
2641
|
+
return {
|
|
2642
|
+
ok: true,
|
|
2643
|
+
payload: {
|
|
2644
|
+
languages: items.map((l) => ({
|
|
2645
|
+
name: orEmptyString(l.name),
|
|
2646
|
+
proficiency: orEmptyString(l.proficiency),
|
|
2647
|
+
})),
|
|
2648
|
+
},
|
|
2649
|
+
};
|
|
2650
|
+
},
|
|
2651
|
+
};
|
|
2652
|
+
const linkedinSkills = {
|
|
2653
|
+
scope: "linkedin.skills",
|
|
2654
|
+
pdppSource: "https://registry.pdpp.dev/connectors/linkedin",
|
|
2655
|
+
pdppStreams: ["skills"],
|
|
2656
|
+
legacySchemaPath: "linkedin.skills.json",
|
|
2657
|
+
fieldsRead: { skills: ["name", "endorsement_count"] },
|
|
2658
|
+
primaryKey: { skills: ["id"] },
|
|
2659
|
+
lossy: [],
|
|
2660
|
+
provenance: [
|
|
2661
|
+
{
|
|
2662
|
+
kind: "oci",
|
|
2663
|
+
ref: "ghcr.io/pdp-connect/connector/linkedin:0.3.1",
|
|
2664
|
+
digest: "sha256:7544a6c015bf4b730afdd97a7521608d10d1c077950af5e9f3adc9405609fd68",
|
|
2665
|
+
path: "declarations/linkedin.collection-profile.json#streams[name=skills]",
|
|
2666
|
+
},
|
|
2667
|
+
],
|
|
2668
|
+
project(records, options) {
|
|
2669
|
+
const guard = requireStreams("linkedin.skills", options, ["skills"]);
|
|
2670
|
+
if (guard) {
|
|
2671
|
+
return guard;
|
|
2672
|
+
}
|
|
2673
|
+
const items = byStream(records, "skills");
|
|
2674
|
+
// Legacy `endorsements` is a string; PDPP `endorsement_count` is a
|
|
2675
|
+
// number. String-converted with legacy's own 0 fallback
|
|
2676
|
+
// (linkedin-playwright.js:551, `String(sk.endorsementCount || ... || 0)`).
|
|
2677
|
+
return {
|
|
2678
|
+
ok: true,
|
|
2679
|
+
payload: {
|
|
2680
|
+
skills: items.map((s) => ({
|
|
2681
|
+
name: orEmptyString(s.name),
|
|
2682
|
+
endorsements: String(orZero(s.endorsement_count)),
|
|
2683
|
+
})),
|
|
2684
|
+
},
|
|
2685
|
+
};
|
|
2686
|
+
},
|
|
2687
|
+
};
|
|
2688
|
+
// ---------------------------------------------------------------------------
|
|
2689
|
+
// spotify
|
|
2690
|
+
// declarations/spotify.collection-profile.json (0.1.4)
|
|
2691
|
+
// connector_id: https://registry.pdpp.dev/connectors/spotify
|
|
2692
|
+
// ---------------------------------------------------------------------------
|
|
2693
|
+
const spotifyProfile = {
|
|
2694
|
+
scope: "spotify.profile",
|
|
2695
|
+
pdppSource: "https://registry.pdpp.dev/connectors/spotify",
|
|
2696
|
+
pdppStreams: ["profile"],
|
|
2697
|
+
legacySchemaPath: "spotify.profile.json",
|
|
2698
|
+
fieldsRead: {
|
|
2699
|
+
profile: ["id", "display_name", "uri", "followers", "following", "images"],
|
|
2700
|
+
},
|
|
2701
|
+
primaryKey: { profile: ["id"] },
|
|
2702
|
+
lossy: [
|
|
2703
|
+
"display_name: PDPP permits null, but the legacy schema requires a string; null projects as ''.",
|
|
2704
|
+
"images: legacy stores string URLs. String entries are retained, and structured PDPP image entries project their string url field.",
|
|
2705
|
+
],
|
|
2706
|
+
provenance: [
|
|
2707
|
+
{
|
|
2708
|
+
kind: "oci",
|
|
2709
|
+
ref: "ghcr.io/pdp-connect/connector/spotify:0.1.4",
|
|
2710
|
+
digest: "sha256:6989f4eceb2142456bebb7b3d442e0a81ce571ef762824aa6dca882afabcba08",
|
|
2711
|
+
path: "declarations/spotify.collection-profile.json#streams[name=profile]",
|
|
2712
|
+
},
|
|
2713
|
+
],
|
|
2714
|
+
project(records, options) {
|
|
2715
|
+
const guard = requireStreams("spotify.profile", options, ["profile"]);
|
|
2716
|
+
if (guard) {
|
|
2717
|
+
return guard;
|
|
2718
|
+
}
|
|
2719
|
+
const [profile] = byStream(records, "profile");
|
|
2720
|
+
if (!profile) {
|
|
2721
|
+
return {
|
|
2722
|
+
ok: false,
|
|
2723
|
+
error: { kind: "empty_singleton", scope: "spotify.profile" },
|
|
2724
|
+
};
|
|
2725
|
+
}
|
|
2726
|
+
return {
|
|
2727
|
+
ok: true,
|
|
2728
|
+
payload: {
|
|
2729
|
+
id: orEmptyString(profile.id),
|
|
2730
|
+
display_name: orEmptyString(profile.display_name),
|
|
2731
|
+
uri: orEmptyString(profile.uri),
|
|
2732
|
+
followers: orZero(profile.followers),
|
|
2733
|
+
following: orZero(profile.following),
|
|
2734
|
+
images: spotifyImageUrls(profile.images),
|
|
2735
|
+
},
|
|
2736
|
+
};
|
|
2737
|
+
},
|
|
2738
|
+
};
|
|
2739
|
+
const spotifySavedTracks = {
|
|
2740
|
+
scope: "spotify.savedTracks",
|
|
2741
|
+
pdppSource: "https://registry.pdpp.dev/connectors/spotify",
|
|
2742
|
+
pdppStreams: ["saved_tracks"],
|
|
2743
|
+
legacySchemaPath: "spotify.savedTracks.json",
|
|
2744
|
+
fieldsRead: {
|
|
2745
|
+
saved_tracks: [
|
|
2746
|
+
"id",
|
|
2747
|
+
"name",
|
|
2748
|
+
"artist_names",
|
|
2749
|
+
"album_name",
|
|
2750
|
+
"duration_ms",
|
|
2751
|
+
"added_at",
|
|
2752
|
+
"uri",
|
|
2753
|
+
"explicit",
|
|
2754
|
+
"album_artist_names",
|
|
2755
|
+
],
|
|
2756
|
+
},
|
|
2757
|
+
primaryKey: { saved_tracks: ["id"] },
|
|
2758
|
+
lossy: [
|
|
2759
|
+
"Rows without the required legacy name and artist list are dropped and counted; nullable album and optional fields retain the connector's empty-string, zero, and false sentinels.",
|
|
2760
|
+
"isrc, popularity, and id have no corresponding legacy fields and are omitted.",
|
|
2761
|
+
],
|
|
2762
|
+
provenance: [
|
|
2763
|
+
{
|
|
2764
|
+
kind: "oci",
|
|
2765
|
+
ref: "ghcr.io/pdp-connect/connector/spotify:0.1.4",
|
|
2766
|
+
digest: "sha256:6989f4eceb2142456bebb7b3d442e0a81ce571ef762824aa6dca882afabcba08",
|
|
2767
|
+
path: "declarations/spotify.collection-profile.json#streams[name=saved_tracks]",
|
|
2768
|
+
},
|
|
2769
|
+
],
|
|
2770
|
+
project(records, options) {
|
|
2771
|
+
const guard = requireStreams("spotify.savedTracks", options, [
|
|
2772
|
+
"saved_tracks",
|
|
2773
|
+
]);
|
|
2774
|
+
if (guard)
|
|
2775
|
+
return guard;
|
|
2776
|
+
const dropped = new Set();
|
|
2777
|
+
let droppedCount = 0;
|
|
2778
|
+
const tracks = byStream(records, "saved_tracks").flatMap((r) => {
|
|
2779
|
+
const { name, artist_names: artistNames } = r;
|
|
2780
|
+
const artists = Array.isArray(artistNames) &&
|
|
2781
|
+
artistNames.every((entry) => typeof entry === "string")
|
|
2782
|
+
? artistNames
|
|
2783
|
+
: null;
|
|
2784
|
+
if (typeof name !== "string" || !artists) {
|
|
2785
|
+
droppedCount += 1;
|
|
2786
|
+
if (typeof name !== "string")
|
|
2787
|
+
dropped.add("Saved track lacks a name");
|
|
2788
|
+
if (!artists)
|
|
2789
|
+
dropped.add("Saved track lacks a valid artist list");
|
|
2790
|
+
return [];
|
|
2791
|
+
}
|
|
2792
|
+
return [
|
|
2793
|
+
{
|
|
2794
|
+
added_at: orEmptyString(r.added_at),
|
|
2795
|
+
name,
|
|
2796
|
+
artists: artists.map((artist) => ({ name: artist })),
|
|
2797
|
+
album: {
|
|
2798
|
+
name: orEmptyString(r.album_name),
|
|
2799
|
+
artists: Array.isArray(r.album_artist_names)
|
|
2800
|
+
? r.album_artist_names
|
|
2801
|
+
.filter((name) => typeof name === "string")
|
|
2802
|
+
.map((name) => ({ name }))
|
|
2803
|
+
: [],
|
|
2804
|
+
},
|
|
2805
|
+
duration_ms: orZero(r.duration_ms),
|
|
2806
|
+
uri: orEmptyString(r.uri),
|
|
2807
|
+
explicit: typeof r.explicit === "boolean" ? r.explicit : false,
|
|
2808
|
+
},
|
|
2809
|
+
];
|
|
2810
|
+
});
|
|
2811
|
+
return {
|
|
2812
|
+
ok: true,
|
|
2813
|
+
payload: { savedTracks: tracks, total: tracks.length },
|
|
2814
|
+
...(droppedCount > 0
|
|
2815
|
+
? {
|
|
2816
|
+
diagnostics: [
|
|
2817
|
+
{
|
|
2818
|
+
kind: "records_dropped",
|
|
2819
|
+
scope: "spotify.savedTracks",
|
|
2820
|
+
stream: "saved_tracks",
|
|
2821
|
+
count: droppedCount,
|
|
2822
|
+
reasons: [...dropped],
|
|
2823
|
+
},
|
|
2824
|
+
],
|
|
2825
|
+
}
|
|
2826
|
+
: {}),
|
|
2827
|
+
};
|
|
2828
|
+
},
|
|
2829
|
+
};
|
|
2830
|
+
const spotifyPlaylists = {
|
|
2831
|
+
scope: "spotify.playlists",
|
|
2832
|
+
pdppSource: "https://registry.pdpp.dev/connectors/spotify",
|
|
2833
|
+
pdppStreams: ["playlists", "playlist_items"],
|
|
2834
|
+
legacySchemaPath: "spotify.playlists.json",
|
|
2835
|
+
fieldsRead: {
|
|
2836
|
+
playlists: [
|
|
2837
|
+
"id",
|
|
2838
|
+
"name",
|
|
2839
|
+
"description",
|
|
2840
|
+
"owner_name",
|
|
2841
|
+
"uri",
|
|
2842
|
+
"followers",
|
|
2843
|
+
"images",
|
|
2844
|
+
"track_count",
|
|
2845
|
+
],
|
|
2846
|
+
playlist_items: [
|
|
2847
|
+
"playlist_id",
|
|
2848
|
+
"position",
|
|
2849
|
+
"added_at",
|
|
2850
|
+
"added_by",
|
|
2851
|
+
"name",
|
|
2852
|
+
"artist_names",
|
|
2853
|
+
"album_name",
|
|
2854
|
+
"duration_ms",
|
|
2855
|
+
"track_id",
|
|
2856
|
+
],
|
|
2857
|
+
},
|
|
2858
|
+
primaryKey: {
|
|
2859
|
+
playlists: ["id"],
|
|
2860
|
+
playlist_items: ["id"],
|
|
2861
|
+
},
|
|
2862
|
+
// Each playlist is built from its own playlist_items.
|
|
2863
|
+
window: {
|
|
2864
|
+
parentStream: "playlists",
|
|
2865
|
+
childStream: "playlist_items",
|
|
2866
|
+
childKey: "playlist_id",
|
|
2867
|
+
arrayKey: "playlists",
|
|
2868
|
+
sumKeys: ["total"],
|
|
2869
|
+
parentOrder: primaryKeyOrder("id"),
|
|
2870
|
+
},
|
|
2871
|
+
lossy: [
|
|
2872
|
+
"tracks[].uri: raw playlist item URIs are retained when available; older pinned records fall back to a canonical Spotify track ID, and a null ID uses the retained collector's empty-string sentinel.",
|
|
2873
|
+
"tracks_total counts joined fetched tracks, as in the retained collector; catalog track_count is not a fetched-row count.",
|
|
2874
|
+
"images: legacy stores string URLs. String entries are retained, and structured PDPP image entries project their string url field.",
|
|
2875
|
+
],
|
|
2876
|
+
provenance: [
|
|
2877
|
+
{
|
|
2878
|
+
kind: "oci",
|
|
2879
|
+
ref: "ghcr.io/pdp-connect/connector/spotify:0.1.4",
|
|
2880
|
+
digest: "sha256:6989f4eceb2142456bebb7b3d442e0a81ce571ef762824aa6dca882afabcba08",
|
|
2881
|
+
path: "declarations/spotify.collection-profile.json#streams[name=playlists,playlist_items]",
|
|
2882
|
+
},
|
|
2883
|
+
],
|
|
2884
|
+
project(records, options) {
|
|
2885
|
+
const guard = requireStreams("spotify.playlists", options, [
|
|
2886
|
+
"playlists",
|
|
2887
|
+
"playlist_items",
|
|
2888
|
+
]);
|
|
2889
|
+
if (guard) {
|
|
2890
|
+
return guard;
|
|
2891
|
+
}
|
|
2892
|
+
const itemsByPlaylist = new Map();
|
|
2893
|
+
for (const item of byStream(records, "playlist_items")) {
|
|
2894
|
+
const playlistId = item.playlist_id;
|
|
2895
|
+
if (typeof playlistId !== "string") {
|
|
2896
|
+
return {
|
|
2897
|
+
ok: false,
|
|
2898
|
+
error: {
|
|
2899
|
+
kind: "incomplete_scope",
|
|
2900
|
+
scope: "spotify.playlists",
|
|
2901
|
+
reason: "A playlist item has no playlist_id to join on",
|
|
2902
|
+
},
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
const group = itemsByPlaylist.get(playlistId);
|
|
2906
|
+
if (group) {
|
|
2907
|
+
group.push(item);
|
|
2908
|
+
}
|
|
2909
|
+
else {
|
|
2910
|
+
itemsByPlaylist.set(playlistId, [item]);
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
const sourcePlaylists = byStream(records, "playlists");
|
|
2914
|
+
const playlistIds = new Set(sourcePlaylists.map((playlist) => playlist.id));
|
|
2915
|
+
const unrepresentablePlaylist = [...itemsByPlaylist].some(([id, tracks]) => !playlistIds.has(id) ||
|
|
2916
|
+
tracks.some((track) => typeof track.uri !== "string" &&
|
|
2917
|
+
track.track_id != null &&
|
|
2918
|
+
(typeof track.track_id !== "string" ||
|
|
2919
|
+
!/^(?:spotify:track:)?[A-Za-z0-9]{22}$/.test(track.track_id))));
|
|
2920
|
+
if (unrepresentablePlaylist) {
|
|
2921
|
+
return {
|
|
2922
|
+
ok: false,
|
|
2923
|
+
error: {
|
|
2924
|
+
kind: "incomplete_scope",
|
|
2925
|
+
scope: "spotify.playlists",
|
|
2926
|
+
reason: "Cannot join every playlist item or derive its Spotify track URI",
|
|
2927
|
+
},
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2930
|
+
const playlists = sourcePlaylists.map((playlist) => {
|
|
2931
|
+
const id = typeof playlist.id === "string" ? playlist.id : "";
|
|
2932
|
+
const trackItems = [...(itemsByPlaylist.get(id) ?? [])].sort((a, b) => orZero(a.position) - orZero(b.position));
|
|
2933
|
+
return {
|
|
2934
|
+
name: orEmptyString(playlist.name),
|
|
2935
|
+
description: orEmptyString(playlist.description),
|
|
2936
|
+
owner: orEmptyString(playlist.owner_name),
|
|
2937
|
+
uri: orEmptyString(playlist.uri),
|
|
2938
|
+
followers: orZero(playlist.followers),
|
|
2939
|
+
images: spotifyImageUrls(playlist.images),
|
|
2940
|
+
tracks_total: trackItems.length,
|
|
2941
|
+
tracks: trackItems.map((track) => ({
|
|
2942
|
+
added_at: orEmptyString(track.added_at),
|
|
2943
|
+
added_by: orEmptyString(track.added_by),
|
|
2944
|
+
name: orEmptyString(track.name),
|
|
2945
|
+
artists: Array.isArray(track.artist_names)
|
|
2946
|
+
? track.artist_names
|
|
2947
|
+
.filter((artist) => typeof artist === "string")
|
|
2948
|
+
.map((name) => ({ name }))
|
|
2949
|
+
: [],
|
|
2950
|
+
album: orEmptyString(track.album_name),
|
|
2951
|
+
duration_ms: orZero(track.duration_ms),
|
|
2952
|
+
uri: typeof track.uri === "string"
|
|
2953
|
+
? track.uri
|
|
2954
|
+
: typeof track.track_id === "string"
|
|
2955
|
+
? track.track_id.startsWith("spotify:track:")
|
|
2956
|
+
? track.track_id
|
|
2957
|
+
: `spotify:track:${track.track_id}`
|
|
2958
|
+
: "",
|
|
2959
|
+
})),
|
|
2960
|
+
};
|
|
2961
|
+
});
|
|
2962
|
+
return {
|
|
2963
|
+
ok: true,
|
|
2964
|
+
payload: { playlists, total: playlists.length },
|
|
2965
|
+
};
|
|
2966
|
+
},
|
|
2967
|
+
};
|
|
2968
|
+
function spotifyImageUrls(value) {
|
|
2969
|
+
if (!Array.isArray(value))
|
|
2970
|
+
return [];
|
|
2971
|
+
return value.flatMap((image) => {
|
|
2972
|
+
if (typeof image === "string")
|
|
2973
|
+
return [image];
|
|
2974
|
+
if (typeof image !== "object" || image === null)
|
|
2975
|
+
return [];
|
|
2976
|
+
const url = image.url;
|
|
2977
|
+
return typeof url === "string" ? [url] : [];
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2980
|
+
// ---------------------------------------------------------------------------
|
|
2981
|
+
// shopify (shop.orders)
|
|
2982
|
+
// declarations/shopify.collection-profile.json (0.2.0)
|
|
2983
|
+
// connector_id: https://registry.pdpp.dev/connectors/shopify
|
|
2984
|
+
// ---------------------------------------------------------------------------
|
|
2985
|
+
const shopOrders = {
|
|
2986
|
+
scope: "shop.orders",
|
|
2987
|
+
pdppSource: "https://registry.pdpp.dev/connectors/shopify",
|
|
2988
|
+
pdppStreams: ["orders"],
|
|
2989
|
+
legacySchemaPath: "shop.orders.json",
|
|
2990
|
+
fieldsRead: {
|
|
2991
|
+
orders: [
|
|
2992
|
+
"id",
|
|
2993
|
+
"order_date",
|
|
2994
|
+
"merchant_name",
|
|
2995
|
+
"total_cents",
|
|
2996
|
+
"currency",
|
|
2997
|
+
"status",
|
|
2998
|
+
"item_count",
|
|
2999
|
+
"line_item_titles",
|
|
3000
|
+
"detail_url",
|
|
3001
|
+
],
|
|
3002
|
+
},
|
|
3003
|
+
primaryKey: { orders: ["id"] },
|
|
3004
|
+
lossy: [
|
|
3005
|
+
"orderNumber: PDPP provides order_number, but the legacy connector derives orderNumber from id (shop-playwright.js:174); keep the existing value to preserve the scope contract",
|
|
3006
|
+
"status: legacy uses displayStatus free text scraped from the storefront; PDPP's normalized `status` value is not verified to match that text 1:1",
|
|
3007
|
+
"placedAt (F5): passed through only when the PDPP source value parses as a valid ISO 8601 date-time; otherwise omitted. legacy's own no-match fallback is '' (shop-playwright.js:175, `orderObj.createdAt || ''`), which the pinned schema does not accept (placedAt is `format: date-time`). A null-shaped legacy fallback would itself fail the pinned schema.",
|
|
3008
|
+
"total, itemCount (N-S1): legacy's own no-match fallbacks are null (:154, top-level total) and `totalItemCount ?? (itemTitles.length || null)` (:180) — none of which the pinned per-item schema accepts (both are `type: number`). A null-shaped legacy fallback would itself fail the pinned schema, and only `id` is required per item, so a missing PDPP value for these two fields is OMITTED from the payload entirely (not defaulted to 0) rather than invented — that omission is itself the disclosed lossy behavior.",
|
|
3009
|
+
],
|
|
3010
|
+
provenance: [
|
|
3011
|
+
{
|
|
3012
|
+
kind: "oci",
|
|
3013
|
+
ref: "ghcr.io/pdp-connect/connector/shopify:0.2.0",
|
|
3014
|
+
digest: "sha256:167cff474a653ad7bce036c973a78adcfc3a3e8e73925a6e24c74961f979ac0e",
|
|
3015
|
+
path: "declarations/shopify.collection-profile.json#streams[name=orders]",
|
|
3016
|
+
},
|
|
3017
|
+
],
|
|
3018
|
+
project(records, options) {
|
|
3019
|
+
const guard = requireStreams("shop.orders", options, ["orders"]);
|
|
3020
|
+
if (guard) {
|
|
3021
|
+
return guard;
|
|
3022
|
+
}
|
|
3023
|
+
const items = byStream(records, "orders");
|
|
3024
|
+
// orderNumber: legacy's own value is String(orderObj.id)
|
|
3025
|
+
// (shop-playwright.js:174) on its primary extraction path — a real,
|
|
3026
|
+
// derivable transform of the same id PDPP carries, not an invented
|
|
3027
|
+
// field. placedAt/total/itemCount: omitted (not defaulted) when the PDPP
|
|
3028
|
+
// source value is absent — see the `lossy` entry above (N-S1). Only
|
|
3029
|
+
// `id` is required per item by the pinned schema, so omitting these is
|
|
3030
|
+
// schema-valid.
|
|
3031
|
+
return {
|
|
3032
|
+
ok: true,
|
|
3033
|
+
payload: {
|
|
3034
|
+
orders: items.map((o) => ({
|
|
3035
|
+
id: orEmptyString(o.id),
|
|
3036
|
+
orderNumber: orEmptyString(o.id),
|
|
3037
|
+
...(typeof o.order_date === "string" &&
|
|
3038
|
+
isValidIso8601DateTime(o.order_date)
|
|
3039
|
+
? { placedAt: o.order_date }
|
|
3040
|
+
: {}),
|
|
3041
|
+
merchantName: orEmptyString(o.merchant_name),
|
|
3042
|
+
...(typeof o.total_cents === "number"
|
|
3043
|
+
? { total: o.total_cents / 100 }
|
|
3044
|
+
: {}),
|
|
3045
|
+
currency: orEmptyString(o.currency),
|
|
3046
|
+
status: orEmptyString(o.status),
|
|
3047
|
+
...(typeof o.item_count === "number"
|
|
3048
|
+
? { itemCount: o.item_count }
|
|
3049
|
+
: {}),
|
|
3050
|
+
...(Array.isArray(o.line_item_titles) &&
|
|
3051
|
+
o.line_item_titles.every((title) => typeof title === "string")
|
|
3052
|
+
? { lineItemTitles: o.line_item_titles }
|
|
3053
|
+
: {}),
|
|
3054
|
+
...(typeof o.detail_url === "string"
|
|
3055
|
+
? { detailUrl: o.detail_url }
|
|
3056
|
+
: {}),
|
|
3057
|
+
})),
|
|
3058
|
+
total: items.length,
|
|
3059
|
+
},
|
|
3060
|
+
};
|
|
3061
|
+
},
|
|
3062
|
+
};
|
|
3063
|
+
// ---------------------------------------------------------------------------
|
|
3064
|
+
// Oura (activity and readiness)
|
|
3065
|
+
// declarations/oura.collection-profile.json (0.1.1, current OCI pin)
|
|
3066
|
+
// connector_id: https://registry.pdpp.dev/connectors/oura
|
|
3067
|
+
// ---------------------------------------------------------------------------
|
|
3068
|
+
const ouraActivity = {
|
|
3069
|
+
scope: "oura.activity",
|
|
3070
|
+
pdppSource: "https://registry.pdpp.dev/connectors/oura",
|
|
3071
|
+
pdppStreams: ["activity"],
|
|
3072
|
+
legacySchemaPath: "oura.activity.json",
|
|
3073
|
+
fieldsRead: {
|
|
3074
|
+
activity: [
|
|
3075
|
+
"id",
|
|
3076
|
+
"day",
|
|
3077
|
+
"score",
|
|
3078
|
+
"active_calories",
|
|
3079
|
+
"total_calories",
|
|
3080
|
+
"steps",
|
|
3081
|
+
"equivalent_walking_distance",
|
|
3082
|
+
"high_activity_time",
|
|
3083
|
+
"medium_activity_time",
|
|
3084
|
+
"low_activity_time",
|
|
3085
|
+
"sedentary_time",
|
|
3086
|
+
"resting_time",
|
|
3087
|
+
"inactivity_alerts",
|
|
3088
|
+
"contributors",
|
|
3089
|
+
],
|
|
3090
|
+
},
|
|
3091
|
+
optionalFieldsRead: { activity: ["timestamp"] },
|
|
3092
|
+
primaryKey: { activity: ["id"] },
|
|
3093
|
+
lossy: [
|
|
3094
|
+
"timestamp: preserved when supplied; absent or null source timestamps are omitted",
|
|
3095
|
+
"target_calories: has no legacy field and is not projected",
|
|
3096
|
+
"Legacy integer fields: fractional source numbers are rounded with Math.round at projection time",
|
|
3097
|
+
],
|
|
3098
|
+
provenance: [
|
|
3099
|
+
{
|
|
3100
|
+
kind: "oci",
|
|
3101
|
+
ref: "ghcr.io/pdp-connect/connector/oura:0.1.1",
|
|
3102
|
+
digest: "sha256:7e39080f5ca65b83f44911cb120f9b8fc5c696b874e6493b26c00f07172efcae",
|
|
3103
|
+
path: "declarations/oura.collection-profile.json#streams[name=activity]",
|
|
3104
|
+
},
|
|
3105
|
+
],
|
|
3106
|
+
project(records, options) {
|
|
3107
|
+
const guard = requireStreams("oura.activity", options, ["activity"]);
|
|
3108
|
+
if (guard)
|
|
3109
|
+
return guard;
|
|
3110
|
+
const { rows, diagnostics } = partitionOuraRows("oura.activity", "activity", byStream(records, "activity"), () => "score");
|
|
3111
|
+
return {
|
|
3112
|
+
ok: true,
|
|
3113
|
+
...(diagnostics.length > 0 ? { diagnostics } : {}),
|
|
3114
|
+
payload: {
|
|
3115
|
+
days: rows.map((r) => ({
|
|
3116
|
+
id: r.id,
|
|
3117
|
+
day: r.day,
|
|
3118
|
+
...(typeof r.timestamp === "string"
|
|
3119
|
+
? { timestamp: r.timestamp }
|
|
3120
|
+
: {}),
|
|
3121
|
+
score: ouraInteger(r.score),
|
|
3122
|
+
...ifDefinedOuraInteger(r, "active_calories", "activeCalories"),
|
|
3123
|
+
...ifDefinedOuraInteger(r, "total_calories", "totalCalories"),
|
|
3124
|
+
...ifDefinedOuraInteger(r, "steps", "steps"),
|
|
3125
|
+
...ifDefinedOuraInteger(r, "equivalent_walking_distance", "equivalentWalkingDistance"),
|
|
3126
|
+
...ifDefinedOuraInteger(r, "high_activity_time", "highActivityTime"),
|
|
3127
|
+
...ifDefinedOuraInteger(r, "medium_activity_time", "mediumActivityTime"),
|
|
3128
|
+
...ifDefinedOuraInteger(r, "low_activity_time", "lowActivityTime"),
|
|
3129
|
+
...ifDefinedOuraInteger(r, "sedentary_time", "sedentaryTime"),
|
|
3130
|
+
...ifDefinedOuraInteger(r, "resting_time", "restingTime"),
|
|
3131
|
+
...ifDefinedOuraInteger(r, "inactivity_alerts", "inactivityAlerts"),
|
|
3132
|
+
...withOuraContributors(r.contributors, OURA_ACTIVITY_CONTRIBUTOR_INTEGERS),
|
|
3133
|
+
})),
|
|
3134
|
+
},
|
|
3135
|
+
};
|
|
3136
|
+
},
|
|
3137
|
+
};
|
|
3138
|
+
const ouraReadiness = {
|
|
3139
|
+
scope: "oura.readiness",
|
|
3140
|
+
pdppSource: "https://registry.pdpp.dev/connectors/oura",
|
|
3141
|
+
pdppStreams: ["readiness"],
|
|
3142
|
+
legacySchemaPath: "oura.readiness.json",
|
|
3143
|
+
fieldsRead: {
|
|
3144
|
+
readiness: [
|
|
3145
|
+
"id",
|
|
3146
|
+
"day",
|
|
3147
|
+
"score",
|
|
3148
|
+
"temperature_deviation",
|
|
3149
|
+
"temperature_trend_deviation",
|
|
3150
|
+
"contributors",
|
|
3151
|
+
],
|
|
3152
|
+
},
|
|
3153
|
+
optionalFieldsRead: { readiness: ["timestamp"] },
|
|
3154
|
+
primaryKey: { readiness: ["id"] },
|
|
3155
|
+
lossy: [
|
|
3156
|
+
"timestamp: preserved when supplied; absent or null source timestamps are omitted",
|
|
3157
|
+
"Legacy integer fields: fractional source numbers are rounded with Math.round at projection time",
|
|
3158
|
+
],
|
|
3159
|
+
provenance: [
|
|
3160
|
+
{
|
|
3161
|
+
kind: "oci",
|
|
3162
|
+
ref: "ghcr.io/pdp-connect/connector/oura:0.1.1",
|
|
3163
|
+
digest: "sha256:7e39080f5ca65b83f44911cb120f9b8fc5c696b874e6493b26c00f07172efcae",
|
|
3164
|
+
path: "declarations/oura.collection-profile.json#streams[name=readiness]",
|
|
3165
|
+
},
|
|
3166
|
+
],
|
|
3167
|
+
project(records, options) {
|
|
3168
|
+
const guard = requireStreams("oura.readiness", options, ["readiness"]);
|
|
3169
|
+
if (guard)
|
|
3170
|
+
return guard;
|
|
3171
|
+
const { rows, diagnostics } = partitionOuraRows("oura.readiness", "readiness", byStream(records, "readiness"), () => "score");
|
|
3172
|
+
return {
|
|
3173
|
+
ok: true,
|
|
3174
|
+
...(diagnostics.length > 0 ? { diagnostics } : {}),
|
|
3175
|
+
payload: {
|
|
3176
|
+
days: rows.map((r) => ({
|
|
3177
|
+
id: r.id,
|
|
3178
|
+
day: r.day,
|
|
3179
|
+
...(typeof r.timestamp === "string"
|
|
3180
|
+
? { timestamp: r.timestamp }
|
|
3181
|
+
: {}),
|
|
3182
|
+
score: ouraInteger(r.score),
|
|
3183
|
+
...ifDefined(r, "temperature_deviation", "temperatureDeviation"),
|
|
3184
|
+
...ifDefined(r, "temperature_trend_deviation", "temperatureTrendDeviation"),
|
|
3185
|
+
...withOuraContributors(r.contributors, OURA_READINESS_CONTRIBUTOR_INTEGERS),
|
|
3186
|
+
})),
|
|
3187
|
+
},
|
|
3188
|
+
};
|
|
3189
|
+
},
|
|
3190
|
+
};
|
|
3191
|
+
const ouraSleep = {
|
|
3192
|
+
scope: "oura.sleep",
|
|
3193
|
+
pdppSource: "https://registry.pdpp.dev/connectors/oura",
|
|
3194
|
+
pdppStreams: ["sleep"],
|
|
3195
|
+
legacySchemaPath: "oura.sleep.json",
|
|
3196
|
+
fieldsRead: {
|
|
3197
|
+
sleep: [
|
|
3198
|
+
"id",
|
|
3199
|
+
"day",
|
|
3200
|
+
"sleep_score",
|
|
3201
|
+
"contributors",
|
|
3202
|
+
"type",
|
|
3203
|
+
"bedtime_start",
|
|
3204
|
+
"bedtime_end",
|
|
3205
|
+
"total_sleep_duration",
|
|
3206
|
+
"time_in_bed",
|
|
3207
|
+
"deep_sleep_duration",
|
|
3208
|
+
"light_sleep_duration",
|
|
3209
|
+
"rem_sleep_duration",
|
|
3210
|
+
"efficiency",
|
|
3211
|
+
"latency",
|
|
3212
|
+
"average_heart_rate",
|
|
3213
|
+
"average_hrv",
|
|
3214
|
+
"lowest_heart_rate",
|
|
3215
|
+
"average_breath",
|
|
3216
|
+
"restless_periods",
|
|
3217
|
+
],
|
|
3218
|
+
},
|
|
3219
|
+
primaryKey: { sleep: ["id"] },
|
|
3220
|
+
lossy: [
|
|
3221
|
+
"awakeTime: no declared PDPP field and is omitted",
|
|
3222
|
+
"dailyScores.timestamp: no source field and is omitted",
|
|
3223
|
+
"sleepPeriods.averageHrv: fractional PDPP numbers are rounded with Math.round to satisfy the legacy integer type",
|
|
3224
|
+
"sleepPeriods.type: unrecognized or null values are omitted because the legacy enum accepts only long_sleep, short_sleep or rest",
|
|
3225
|
+
"Legacy integer fields: fractional source numbers are rounded with Math.round at projection time",
|
|
3226
|
+
],
|
|
3227
|
+
provenance: [
|
|
3228
|
+
{
|
|
3229
|
+
kind: "oci",
|
|
3230
|
+
ref: "ghcr.io/pdp-connect/connector/oura:0.1.1",
|
|
3231
|
+
digest: "sha256:7e39080f5ca65b83f44911cb120f9b8fc5c696b874e6493b26c00f07172efcae",
|
|
3232
|
+
path: "declarations/oura.collection-profile.json#streams[name=sleep]",
|
|
3233
|
+
},
|
|
3234
|
+
],
|
|
3235
|
+
project(records, options) {
|
|
3236
|
+
const guard = requireStreams("oura.sleep", options, ["sleep"]);
|
|
3237
|
+
if (guard)
|
|
3238
|
+
return guard;
|
|
3239
|
+
const sourceRows = byStream(records, "sleep");
|
|
3240
|
+
const { rows, diagnostics } = partitionOuraRows("oura.sleep", "sleep", sourceRows, () => "sleep_score");
|
|
3241
|
+
const { rows: periodRows } = partitionOuraRows("oura.sleep", "sleep", sourceRows, () => undefined);
|
|
3242
|
+
const projectionOmissions = periodRows.flatMap(ouraSleepPeriodOmissions);
|
|
3243
|
+
return {
|
|
3244
|
+
ok: true,
|
|
3245
|
+
...withDiagnostics(diagnostics),
|
|
3246
|
+
...(projectionOmissions.length > 0 ? { projectionOmissions } : {}),
|
|
3247
|
+
payload: {
|
|
3248
|
+
dailyScores: rows.map((r) => ({
|
|
3249
|
+
id: r.id,
|
|
3250
|
+
day: r.day,
|
|
3251
|
+
score: ouraInteger(r.sleep_score),
|
|
3252
|
+
...withOuraContributors(r.contributors, OURA_SLEEP_CONTRIBUTOR_INTEGERS),
|
|
3253
|
+
})),
|
|
3254
|
+
sleepPeriods: periodRows.map(ouraSleepPeriod),
|
|
3255
|
+
},
|
|
3256
|
+
};
|
|
3257
|
+
},
|
|
3258
|
+
};
|
|
3259
|
+
/** One legacy `sleepPeriods` entry from a source sleep session row with a valid day. */
|
|
3260
|
+
export function ouraSleepPeriod(r) {
|
|
3261
|
+
return {
|
|
3262
|
+
id: r.id,
|
|
3263
|
+
day: r.day,
|
|
3264
|
+
...(r.type === "long_sleep" || r.type === "short_sleep" || r.type === "rest"
|
|
3265
|
+
? { type: r.type }
|
|
3266
|
+
: {}),
|
|
3267
|
+
...(r.bedtime_start === null
|
|
3268
|
+
? {}
|
|
3269
|
+
: ifDefined(r, "bedtime_start", "bedtimeStart")),
|
|
3270
|
+
...(r.bedtime_end === null
|
|
3271
|
+
? {}
|
|
3272
|
+
: ifDefined(r, "bedtime_end", "bedtimeEnd")),
|
|
3273
|
+
...ifDefinedOuraInteger(r, "total_sleep_duration", "totalSleepDuration"),
|
|
3274
|
+
...ifDefinedOuraInteger(r, "time_in_bed", "timeInBed"),
|
|
3275
|
+
...ifDefinedOuraInteger(r, "deep_sleep_duration", "deepSleepDuration"),
|
|
3276
|
+
...ifDefinedOuraInteger(r, "light_sleep_duration", "lightSleepDuration"),
|
|
3277
|
+
...ifDefinedOuraInteger(r, "rem_sleep_duration", "remSleepDuration"),
|
|
3278
|
+
...ifDefinedOuraInteger(r, "efficiency", "efficiency"),
|
|
3279
|
+
...ifDefinedOuraInteger(r, "latency", "latency"),
|
|
3280
|
+
...ifDefined(r, "average_heart_rate", "averageHeartRate"),
|
|
3281
|
+
...ifDefinedOuraInteger(r, "average_hrv", "averageHrv"),
|
|
3282
|
+
...ifDefinedOuraInteger(r, "lowest_heart_rate", "lowestHeartRate"),
|
|
3283
|
+
...ifDefined(r, "average_breath", "averageBreath"),
|
|
3284
|
+
...ifDefinedOuraInteger(r, "restless_periods", "restlessPeriods"),
|
|
3285
|
+
};
|
|
3286
|
+
}
|
|
3287
|
+
export function ouraSleepPeriodOmissions(r) {
|
|
3288
|
+
const entityKey = r.id;
|
|
3289
|
+
if ((typeof entityKey !== "string" &&
|
|
3290
|
+
typeof entityKey !== "number" &&
|
|
3291
|
+
typeof entityKey !== "boolean") ||
|
|
3292
|
+
entityKey === "") {
|
|
3293
|
+
return [];
|
|
3294
|
+
}
|
|
3295
|
+
const omissions = [];
|
|
3296
|
+
if (r.type === null ||
|
|
3297
|
+
(r.type !== undefined &&
|
|
3298
|
+
!["long_sleep", "short_sleep", "rest"].includes(String(r.type)))) {
|
|
3299
|
+
omissions.push({
|
|
3300
|
+
entityPath: "$.sleepPeriods[]",
|
|
3301
|
+
entityKey,
|
|
3302
|
+
fieldPath: "type",
|
|
3303
|
+
reason: r.type === null ? "null_type" : "off_enum_type",
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3306
|
+
for (const field of ["bedtime_start", "bedtime_end"]) {
|
|
3307
|
+
if (r[field] === null) {
|
|
3308
|
+
omissions.push({
|
|
3309
|
+
entityPath: "$.sleepPeriods[]",
|
|
3310
|
+
entityKey,
|
|
3311
|
+
fieldPath: field === "bedtime_start" ? "bedtimeStart" : "bedtimeEnd",
|
|
3312
|
+
reason: "null_timestamp",
|
|
3313
|
+
});
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
return omissions;
|
|
3317
|
+
}
|
|
3318
|
+
// ---------------------------------------------------------------------------
|
|
3319
|
+
// amazon
|
|
3320
|
+
// declarations/amazon.collection-profile.json, streams "orders" +
|
|
3321
|
+
// "order_items" (joined on order_items.order_id === orders.id).
|
|
3322
|
+
// connector_id: https://registry.pdpp.dev/connectors/amazon
|
|
3323
|
+
// ---------------------------------------------------------------------------
|
|
3324
|
+
const amazonOrders = {
|
|
3325
|
+
scope: "amazon.orders",
|
|
3326
|
+
pdppSource: "https://registry.pdpp.dev/connectors/amazon",
|
|
3327
|
+
pdppStreams: ["orders", "order_items"],
|
|
3328
|
+
legacySchemaPath: "amazon.orders.json",
|
|
3329
|
+
fieldsRead: {
|
|
3330
|
+
orders: ["id", "order_date", "order_total", "delivery_status"],
|
|
3331
|
+
order_items: ["order_id", "name", "url", "unit_price"],
|
|
3332
|
+
},
|
|
3333
|
+
primaryKey: { orders: ["id"], order_items: ["id"] },
|
|
3334
|
+
// Each order is built from its own order_items.
|
|
3335
|
+
window: {
|
|
3336
|
+
parentStream: "orders",
|
|
3337
|
+
childStream: "order_items",
|
|
3338
|
+
childKey: "order_id",
|
|
3339
|
+
arrayKey: "orders",
|
|
3340
|
+
sumKeys: ["total"],
|
|
3341
|
+
parentOrder: primaryKeyOrder("id"),
|
|
3342
|
+
},
|
|
3343
|
+
lossy: [
|
|
3344
|
+
"items[].quantity: no legacy field (legacy schema does not carry quantity at all; PDPP-side quantity is simply not projected)",
|
|
3345
|
+
"items[].price (N-S2): legacy's own connector ALWAYS emits the literal constant '' for this field (amazon-playwright.js:222, `price: ''` — not a fallback for a missing value, the connector never scrapes a real price here at all). This projection instead emits PDPP's real `unit_price` when present, so an app reading this field gets a populated value where legacy always gave it an empty string — a value change, not a gap-fill, and the comment at the call site below previously implied the two matched when they do not.",
|
|
3346
|
+
],
|
|
3347
|
+
provenance: [
|
|
3348
|
+
{
|
|
3349
|
+
kind: "oci",
|
|
3350
|
+
ref: "ghcr.io/pdp-connect/connector/amazon:0.1.0",
|
|
3351
|
+
digest: "sha256:dfddeffbc11c53fa2577c71f45428b87ccb25a69175218621398342a22b415d4",
|
|
3352
|
+
path: "declarations/amazon.collection-profile.json#streams[name=orders,order_items]",
|
|
3353
|
+
},
|
|
3354
|
+
],
|
|
3355
|
+
project(records, options) {
|
|
3356
|
+
const guard = requireStreams("amazon.orders", options, [
|
|
3357
|
+
"orders",
|
|
3358
|
+
"order_items",
|
|
3359
|
+
]);
|
|
3360
|
+
if (guard) {
|
|
3361
|
+
return guard;
|
|
3362
|
+
}
|
|
3363
|
+
const orders = byStream(records, "orders");
|
|
3364
|
+
const items = byStream(records, "order_items");
|
|
3365
|
+
const orderIds = new Set(orders.map((o) => o.id));
|
|
3366
|
+
const orphanItems = items.filter((i) => !orderIds.has(i.order_id)).length;
|
|
3367
|
+
const dropped = new DroppedRows("amazon.orders");
|
|
3368
|
+
dropped.add("order_items", "Order item has no matching order", orphanItems);
|
|
3369
|
+
// orderDate: legacy scrapes "MonthName D, YYYY" out of card text via
|
|
3370
|
+
// regex (amazon-playwright.js:184-187); toLegacyLongDate reproduces
|
|
3371
|
+
// that exact text shape from PDPP's ISO order_date, not an ISO
|
|
3372
|
+
// passthrough. Item price: legacy ALWAYS emits the literal constant ''
|
|
3373
|
+
// here (amazon-playwright.js:222, `price: ''`) — it never scrapes a
|
|
3374
|
+
// real price for line items. This binding instead emits PDPP's real
|
|
3375
|
+
// `unit_price` when present, a disclosed value change, see `lossy`
|
|
3376
|
+
// (N-S2), not a match with legacy's own behavior.
|
|
3377
|
+
return {
|
|
3378
|
+
ok: true,
|
|
3379
|
+
payload: {
|
|
3380
|
+
orders: orders.map((o) => ({
|
|
3381
|
+
orderId: orEmptyString(o.id),
|
|
3382
|
+
orderDate: toLegacyLongDate(o.order_date),
|
|
3383
|
+
orderTotal: orEmptyString(o.order_total),
|
|
3384
|
+
deliveryStatus: orEmptyString(o.delivery_status),
|
|
3385
|
+
items: items
|
|
3386
|
+
.filter((i) => i.order_id === o.id)
|
|
3387
|
+
.map((i) => ({
|
|
3388
|
+
name: orEmptyString(i.name),
|
|
3389
|
+
url: orEmptyString(i.url),
|
|
3390
|
+
price: orEmptyString(i.unit_price),
|
|
3391
|
+
})),
|
|
3392
|
+
})),
|
|
3393
|
+
total: orders.length,
|
|
3394
|
+
},
|
|
3395
|
+
...withDiagnostics(dropped.diagnostics()),
|
|
3396
|
+
};
|
|
3397
|
+
},
|
|
3398
|
+
};
|
|
3399
|
+
// ---------------------------------------------------------------------------
|
|
3400
|
+
// H-E-B 0.5.3 is pinned to the published, signature-verified OCI artifact.
|
|
3401
|
+
// Product identity remains H-E-B's provider product_id.
|
|
3402
|
+
const hebSource = "https://registry.pdpp.dev/connectors/heb";
|
|
3403
|
+
const hebPublishedEvidence = {
|
|
3404
|
+
kind: "oci",
|
|
3405
|
+
ref: "ghcr.io/pdp-connect/connector/heb:0.5.3",
|
|
3406
|
+
digest: "sha256:9de1c9203453b3897305ca99dfe93755f0e5528b3e7e79d0a9e6c8313445c02a",
|
|
3407
|
+
path: "declarations/heb.collection-profile.json#streams[name=profile]",
|
|
3408
|
+
};
|
|
3409
|
+
const hebProfile = {
|
|
3410
|
+
scope: "heb.profile",
|
|
3411
|
+
pdppSource: hebSource,
|
|
3412
|
+
pdppStreams: ["profile"],
|
|
3413
|
+
legacySchemaPath: "heb.profile.json",
|
|
3414
|
+
fieldsRead: { profile: ["name", "email", "phone", "delivery_addresses"] },
|
|
3415
|
+
primaryKey: { profile: ["id"] },
|
|
3416
|
+
lossy: ["fetched_at is not part of the legacy profile payload."],
|
|
3417
|
+
provenance: [hebPublishedEvidence],
|
|
3418
|
+
project(records, options) {
|
|
3419
|
+
const guard = requireStreams("heb.profile", options, ["profile"]);
|
|
3420
|
+
if (guard)
|
|
3421
|
+
return guard;
|
|
3422
|
+
const profiles = byStream(records, "profile");
|
|
3423
|
+
if (profiles.length === 0)
|
|
3424
|
+
return {
|
|
3425
|
+
ok: false,
|
|
3426
|
+
error: { kind: "empty_singleton", scope: "heb.profile" },
|
|
3427
|
+
};
|
|
3428
|
+
if (profiles.length !== 1)
|
|
3429
|
+
return {
|
|
3430
|
+
ok: false,
|
|
3431
|
+
error: {
|
|
3432
|
+
kind: "incomplete_scope",
|
|
3433
|
+
scope: "heb.profile",
|
|
3434
|
+
reason: "profile stream did not contain exactly one record",
|
|
3435
|
+
},
|
|
3436
|
+
};
|
|
3437
|
+
const [p] = profiles;
|
|
3438
|
+
if ((p.name != null && typeof p.name !== "string") ||
|
|
3439
|
+
(p.email != null && typeof p.email !== "string") ||
|
|
3440
|
+
(p.phone != null && typeof p.phone !== "string")) {
|
|
3441
|
+
return {
|
|
3442
|
+
ok: false,
|
|
3443
|
+
error: {
|
|
3444
|
+
kind: "incomplete_scope",
|
|
3445
|
+
scope: "heb.profile",
|
|
3446
|
+
reason: "profile contains a malformed scalar value",
|
|
3447
|
+
},
|
|
3448
|
+
};
|
|
3449
|
+
}
|
|
3450
|
+
if (!Array.isArray(p.delivery_addresses)) {
|
|
3451
|
+
return {
|
|
3452
|
+
ok: false,
|
|
3453
|
+
error: {
|
|
3454
|
+
kind: "incomplete_scope",
|
|
3455
|
+
scope: "heb.profile",
|
|
3456
|
+
reason: "profile.delivery_addresses is unavailable",
|
|
3457
|
+
},
|
|
3458
|
+
};
|
|
3459
|
+
}
|
|
3460
|
+
if (Array.isArray(p.delivery_addresses) &&
|
|
3461
|
+
p.delivery_addresses.some((entry) => entry === null ||
|
|
3462
|
+
typeof entry !== "object" ||
|
|
3463
|
+
typeof entry.address !== "string" ||
|
|
3464
|
+
typeof entry.is_primary !== "boolean" ||
|
|
3465
|
+
!(typeof entry.label === "string" || entry.label === null))) {
|
|
3466
|
+
return {
|
|
3467
|
+
ok: false,
|
|
3468
|
+
error: {
|
|
3469
|
+
kind: "incomplete_scope",
|
|
3470
|
+
scope: "heb.profile",
|
|
3471
|
+
reason: "profile.delivery_addresses contains an unrepresentable address",
|
|
3472
|
+
},
|
|
3473
|
+
};
|
|
3474
|
+
}
|
|
3475
|
+
const deliveryAddresses = p.delivery_addresses.map((entry) => {
|
|
3476
|
+
const a = entry;
|
|
3477
|
+
return {
|
|
3478
|
+
address: a.address,
|
|
3479
|
+
isPrimary: a.is_primary,
|
|
3480
|
+
label: a.label,
|
|
3481
|
+
};
|
|
3482
|
+
});
|
|
3483
|
+
return {
|
|
3484
|
+
ok: true,
|
|
3485
|
+
payload: {
|
|
3486
|
+
name: typeof p.name === "string" ? p.name : null,
|
|
3487
|
+
email: typeof p.email === "string" ? p.email : null,
|
|
3488
|
+
phone: p.phone === undefined || p.phone === null ? null : p.phone,
|
|
3489
|
+
deliveryAddresses,
|
|
3490
|
+
},
|
|
3491
|
+
};
|
|
3492
|
+
},
|
|
3493
|
+
};
|
|
3494
|
+
// H-E-B emits one nutrition outcome for each distinct source order-item
|
|
3495
|
+
// product. Keep the source item stream in this projection so missing outcomes
|
|
3496
|
+
// cannot become a successful but incomplete legacy payload.
|
|
3497
|
+
const hebNutritionFields = [
|
|
3498
|
+
"product_id",
|
|
3499
|
+
"name",
|
|
3500
|
+
"source",
|
|
3501
|
+
"confidence",
|
|
3502
|
+
"calories",
|
|
3503
|
+
"protein_g",
|
|
3504
|
+
"carbs_g",
|
|
3505
|
+
"fat_g",
|
|
3506
|
+
"sodium_mg",
|
|
3507
|
+
"fiber_g",
|
|
3508
|
+
"sugar_g",
|
|
3509
|
+
"saturated_fat_g",
|
|
3510
|
+
"trans_fat_g",
|
|
3511
|
+
"cholesterol_mg",
|
|
3512
|
+
"added_sugar_g",
|
|
3513
|
+
"calcium_mg",
|
|
3514
|
+
"iron_mg",
|
|
3515
|
+
"potassium_mg",
|
|
3516
|
+
"vitamin_d_mcg",
|
|
3517
|
+
"serving_size",
|
|
3518
|
+
"servings_per_container",
|
|
3519
|
+
"upc",
|
|
3520
|
+
"ingredients",
|
|
3521
|
+
"allergens",
|
|
3522
|
+
"category",
|
|
3523
|
+
"highlights",
|
|
3524
|
+
"product_url",
|
|
3525
|
+
];
|
|
3526
|
+
const hebNutrition = {
|
|
3527
|
+
scope: "heb.nutrition",
|
|
3528
|
+
pdppSource: hebSource,
|
|
3529
|
+
pdppStreams: ["nutrition", "orders", "order_items"],
|
|
3530
|
+
legacySchemaPath: "heb.nutrition.json",
|
|
3531
|
+
fieldsRead: {
|
|
3532
|
+
nutrition: hebNutritionFields,
|
|
3533
|
+
orders: [],
|
|
3534
|
+
order_items: ["product_id", "name", "product_url"],
|
|
3535
|
+
},
|
|
3536
|
+
primaryKey: { nutrition: ["id"], orders: ["id"], order_items: ["id"] },
|
|
3537
|
+
memoryBound: "The output is one map keyed by product with whole-scope coverage totals and checks, not one row per parent.",
|
|
3538
|
+
lossy: [
|
|
3539
|
+
"The legacy map key is the declared H-E-B product_id; no global UPC identity is inferred.",
|
|
3540
|
+
"fetched_at is omitted.",
|
|
3541
|
+
],
|
|
3542
|
+
provenance: [
|
|
3543
|
+
{
|
|
3544
|
+
...hebPublishedEvidence,
|
|
3545
|
+
path: "declarations/heb.collection-profile.json#streams[name=orders,order_items,nutrition]",
|
|
3546
|
+
},
|
|
3547
|
+
],
|
|
3548
|
+
project(records, options) {
|
|
3549
|
+
const guard = requireStreams("heb.nutrition", options, [
|
|
3550
|
+
"nutrition",
|
|
3551
|
+
"orders",
|
|
3552
|
+
"order_items",
|
|
3553
|
+
]);
|
|
3554
|
+
if (guard)
|
|
3555
|
+
return guard;
|
|
3556
|
+
const orderedProducts = new Map();
|
|
3557
|
+
for (const row of byStream(records, "order_items")) {
|
|
3558
|
+
// The source only creates nutrition targets for order lines with a
|
|
3559
|
+
// product_id, and deduplicates those targets by that id.
|
|
3560
|
+
if (!isNonEmptyString(row.product_id))
|
|
3561
|
+
continue;
|
|
3562
|
+
if (!isNonEmptyString(row.name) ||
|
|
3563
|
+
(row.product_url !== null && !isNonEmptyString(row.product_url))) {
|
|
3564
|
+
return {
|
|
3565
|
+
ok: false,
|
|
3566
|
+
error: {
|
|
3567
|
+
kind: "incomplete_scope",
|
|
3568
|
+
scope: "heb.nutrition",
|
|
3569
|
+
reason: "order item lacks its source product name or URL",
|
|
3570
|
+
},
|
|
3571
|
+
};
|
|
3572
|
+
}
|
|
3573
|
+
// The legacy browser connector deduplicates by product id and retains
|
|
3574
|
+
// the first observed order line as the product's name and URL.
|
|
3575
|
+
if (!orderedProducts.has(row.product_id)) {
|
|
3576
|
+
orderedProducts.set(row.product_id, {
|
|
3577
|
+
name: row.name,
|
|
3578
|
+
productUrl: row.product_url,
|
|
3579
|
+
});
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
const items = Object.create(null);
|
|
3583
|
+
let found = 0, foundUSDA = 0, blocked = 0;
|
|
3584
|
+
for (const n of byStream(records, "nutrition")) {
|
|
3585
|
+
if (!isNonEmptyString(n.product_id) ||
|
|
3586
|
+
!orderedProducts.has(n.product_id) ||
|
|
3587
|
+
n.product_url !== orderedProducts.get(n.product_id)?.productUrl ||
|
|
3588
|
+
typeof n.source !== "string" ||
|
|
3589
|
+
![
|
|
3590
|
+
"heb_product_page",
|
|
3591
|
+
"usda_fdc",
|
|
3592
|
+
"not_found",
|
|
3593
|
+
"error",
|
|
3594
|
+
"blocked",
|
|
3595
|
+
].includes(n.source) ||
|
|
3596
|
+
(n.product_url === null && n.source !== "not_found")) {
|
|
3597
|
+
return {
|
|
3598
|
+
ok: false,
|
|
3599
|
+
error: {
|
|
3600
|
+
kind: "incomplete_scope",
|
|
3601
|
+
scope: "heb.nutrition",
|
|
3602
|
+
reason: "nutrition row lacks a product id, matching product URL, or valid observed outcome",
|
|
3603
|
+
},
|
|
3604
|
+
};
|
|
3605
|
+
}
|
|
3606
|
+
if (Object.hasOwn(items, n.product_id)) {
|
|
3607
|
+
return {
|
|
3608
|
+
ok: false,
|
|
3609
|
+
error: {
|
|
3610
|
+
kind: "incomplete_scope",
|
|
3611
|
+
scope: "heb.nutrition",
|
|
3612
|
+
reason: "duplicate nutrition product id",
|
|
3613
|
+
},
|
|
3614
|
+
};
|
|
3615
|
+
}
|
|
3616
|
+
const item = {
|
|
3617
|
+
name: orderedProducts.get(n.product_id).name,
|
|
3618
|
+
productUrl: n.product_url,
|
|
3619
|
+
source: n.source,
|
|
3620
|
+
};
|
|
3621
|
+
if (["high", "medium", "low"].includes(String(n.confidence))) {
|
|
3622
|
+
item.confidence = n.confidence;
|
|
3623
|
+
}
|
|
3624
|
+
for (const field of hebNutritionFields.slice(4, 19)) {
|
|
3625
|
+
if (n[field] === null || typeof n[field] === "number") {
|
|
3626
|
+
item[field] = n[field];
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
if (n.serving_size === null || typeof n.serving_size === "string")
|
|
3630
|
+
item.servingSize = n.serving_size;
|
|
3631
|
+
if (n.servings_per_container === null ||
|
|
3632
|
+
typeof n.servings_per_container === "string")
|
|
3633
|
+
item.servingsPerContainer = n.servings_per_container;
|
|
3634
|
+
for (const field of [
|
|
3635
|
+
"upc",
|
|
3636
|
+
"ingredients",
|
|
3637
|
+
"allergens",
|
|
3638
|
+
"category",
|
|
3639
|
+
"highlights",
|
|
3640
|
+
]) {
|
|
3641
|
+
if (n[field] !== undefined)
|
|
3642
|
+
item[field] = n[field];
|
|
3643
|
+
}
|
|
3644
|
+
// Preserve the legacy connector's productImageUrl() mapping. These URLs
|
|
3645
|
+
// are deterministic from the observed H-E-B product id; they are not
|
|
3646
|
+
// scraped or inferred from nutrition content.
|
|
3647
|
+
const paddedProductId = n.product_id.padStart(9, "0");
|
|
3648
|
+
item.images = {
|
|
3649
|
+
thumbnail: `https://images.heb.com/is/image/HEBGrocery/prd-small/${paddedProductId}.jpg`,
|
|
3650
|
+
full: `https://images.heb.com/is/image/HEBGrocery/${n.product_id}-1`,
|
|
3651
|
+
};
|
|
3652
|
+
items[n.product_id] = item;
|
|
3653
|
+
if (n.source === "heb_product_page")
|
|
3654
|
+
found++;
|
|
3655
|
+
if (n.source === "usda_fdc")
|
|
3656
|
+
foundUSDA++;
|
|
3657
|
+
if (n.source === "blocked")
|
|
3658
|
+
blocked++;
|
|
3659
|
+
}
|
|
3660
|
+
const total = Object.keys(items).length;
|
|
3661
|
+
if (total !== orderedProducts.size) {
|
|
3662
|
+
return {
|
|
3663
|
+
ok: false,
|
|
3664
|
+
error: {
|
|
3665
|
+
kind: "incomplete_scope",
|
|
3666
|
+
scope: "heb.nutrition",
|
|
3667
|
+
reason: "nutrition outcomes do not cover every ordered product",
|
|
3668
|
+
},
|
|
3669
|
+
};
|
|
3670
|
+
}
|
|
3671
|
+
return {
|
|
3672
|
+
ok: true,
|
|
3673
|
+
payload: {
|
|
3674
|
+
items,
|
|
3675
|
+
coverage: {
|
|
3676
|
+
total,
|
|
3677
|
+
found,
|
|
3678
|
+
foundUSDA,
|
|
3679
|
+
blocked,
|
|
3680
|
+
percentCovered: total
|
|
3681
|
+
? Math.round(((found + foundUSDA) / total) * 100)
|
|
3682
|
+
: 0,
|
|
3683
|
+
},
|
|
3684
|
+
},
|
|
3685
|
+
};
|
|
3686
|
+
},
|
|
3687
|
+
};
|
|
3688
|
+
// Grocery order semantics follow the accepted Unity projection fold
|
|
3689
|
+
// (vana-unity 9256b5a8e): an order with no usable line is a detail gap unless
|
|
3690
|
+
// the source count is a known zero; a gap or an unkeyable order is left out and
|
|
3691
|
+
// counted; zero survivors from nonempty orders is rejected, never served empty.
|
|
3692
|
+
// Reason strings are that fold's diagnostic codes.
|
|
3693
|
+
// ---------------------------------------------------------------------------
|
|
3694
|
+
/** Reason for an order dropped because its id is unusable; index.ts lets exactly these rows past its primary-key check. */
|
|
3695
|
+
export const GROCERY_INVALID_ORDER = "projection_invalid_order";
|
|
3696
|
+
const GROCERY_ORDER_ITEMS_GAP = "projection_order_items_gap";
|
|
3697
|
+
function partialRows(scope, stream, reason, count) {
|
|
3698
|
+
return count > 0
|
|
3699
|
+
? [{ kind: "records_partial", scope, stream, count, reasons: [reason] }]
|
|
3700
|
+
: [];
|
|
3701
|
+
}
|
|
3702
|
+
function groceryRejection(scope, diagnostics) {
|
|
3703
|
+
return {
|
|
3704
|
+
ok: false,
|
|
3705
|
+
error: {
|
|
3706
|
+
kind: "incomplete_scope",
|
|
3707
|
+
scope,
|
|
3708
|
+
reason: "No source order could be projected",
|
|
3709
|
+
diagnostics,
|
|
3710
|
+
},
|
|
3711
|
+
};
|
|
3712
|
+
}
|
|
3713
|
+
const hebOrders = {
|
|
3714
|
+
scope: "heb.orders",
|
|
3715
|
+
pdppSource: "https://registry.pdpp.dev/connectors/heb",
|
|
3716
|
+
pdppStreams: ["orders", "order_items"],
|
|
3717
|
+
legacySchemaPath: "heb.orders.json",
|
|
3718
|
+
fieldsRead: {
|
|
3719
|
+
orders: ["id", "order_date", "total_cents", "item_count", "status"],
|
|
3720
|
+
order_items: [
|
|
3721
|
+
"order_id",
|
|
3722
|
+
"name",
|
|
3723
|
+
"product_id",
|
|
3724
|
+
"product_url",
|
|
3725
|
+
"image_url",
|
|
3726
|
+
"quantity",
|
|
3727
|
+
"line_total_cents",
|
|
3728
|
+
],
|
|
3729
|
+
},
|
|
3730
|
+
primaryKey: { orders: ["id"], order_items: ["id"] },
|
|
3731
|
+
memoryBound: "Rejects the whole scope when every order is dropped, a decision a window of orders cannot make.",
|
|
3732
|
+
lossy: [
|
|
3733
|
+
"orderUrl and address: the signed profile has no equivalent fields; fulfillment_location is not treated as an address.",
|
|
3734
|
+
"status_code, store_name, timeslot_start/end, unfulfilled_count, fulfillment_method, and fetched_at are not represented by the legacy schema.",
|
|
3735
|
+
"total and item price: derived from declared integer cents when present; omitted when absent. No currency or decimal text is guessed.",
|
|
3736
|
+
"the retained collector emitted only product-linked named lines; a source line without either field is dropped and counted, and its order is delivered without it.",
|
|
3737
|
+
"An order without a usable id, or with no usable line and an item_count that is not a known zero, is left out and counted; valid peers are still delivered.",
|
|
3738
|
+
"item_count counts quantity units; an order whose summed line quantities differ is delivered and reported partial.",
|
|
3739
|
+
"quantity: a declared numeric quantity is converted to its decimal string form to match the legacy connector output type.",
|
|
3740
|
+
],
|
|
3741
|
+
provenance: [
|
|
3742
|
+
{
|
|
3743
|
+
...hebPublishedEvidence,
|
|
3744
|
+
path: "declarations/heb.collection-profile.json#streams[name=orders,order_items]",
|
|
3745
|
+
},
|
|
3746
|
+
],
|
|
3747
|
+
project(records, options) {
|
|
3748
|
+
const guard = requireStreams("heb.orders", options, [
|
|
3749
|
+
"orders",
|
|
3750
|
+
"order_items",
|
|
3751
|
+
]);
|
|
3752
|
+
if (guard)
|
|
3753
|
+
return guard;
|
|
3754
|
+
const sourceItems = byStream(records, "order_items");
|
|
3755
|
+
const sourceOrders = byStream(records, "orders");
|
|
3756
|
+
const sourceOrderIds = new Set(sourceOrders.map((order) => order.id));
|
|
3757
|
+
if (sourceItems.some((item) => !sourceOrderIds.has(item.order_id))) {
|
|
3758
|
+
return {
|
|
3759
|
+
ok: false,
|
|
3760
|
+
error: {
|
|
3761
|
+
kind: "incomplete_scope",
|
|
3762
|
+
scope: "heb.orders",
|
|
3763
|
+
reason: "order_items.order_id has no matching order",
|
|
3764
|
+
},
|
|
3765
|
+
};
|
|
3766
|
+
}
|
|
3767
|
+
const dropped = new DroppedRows("heb.orders");
|
|
3768
|
+
let unitCountMismatches = 0;
|
|
3769
|
+
const orders = sourceOrders.flatMap((order) => {
|
|
3770
|
+
// Without a usable id an order cannot be keyed: it is left out and
|
|
3771
|
+
// counted (see GROCERY_INVALID_ORDER), never failing its valid peers.
|
|
3772
|
+
if (!isNonEmptyString(order.id)) {
|
|
3773
|
+
dropped.add("orders", GROCERY_INVALID_ORDER);
|
|
3774
|
+
return [];
|
|
3775
|
+
}
|
|
3776
|
+
const items = sourceItems
|
|
3777
|
+
.filter((item) => item.order_id === order.id)
|
|
3778
|
+
.flatMap((item) => {
|
|
3779
|
+
if (!isNonEmptyString(item.name)) {
|
|
3780
|
+
dropped.add("order_items", "projection_order_item_missing_name");
|
|
3781
|
+
return [];
|
|
3782
|
+
}
|
|
3783
|
+
if (!isNonEmptyString(item.product_id)) {
|
|
3784
|
+
dropped.add("order_items", "projection_order_item_missing_product_id");
|
|
3785
|
+
return [];
|
|
3786
|
+
}
|
|
3787
|
+
const quantity = typeof item.quantity === "number" && Number.isFinite(item.quantity)
|
|
3788
|
+
? String(item.quantity)
|
|
3789
|
+
: null;
|
|
3790
|
+
const price = typeof item.line_total_cents === "number"
|
|
3791
|
+
? item.line_total_cents / 100
|
|
3792
|
+
: undefined;
|
|
3793
|
+
return [
|
|
3794
|
+
{
|
|
3795
|
+
name: item.name,
|
|
3796
|
+
productId: item.product_id,
|
|
3797
|
+
productUrl: typeof item.product_url === "string" ? item.product_url : null,
|
|
3798
|
+
imageUrl: typeof item.image_url === "string" ? item.image_url : null,
|
|
3799
|
+
quantity,
|
|
3800
|
+
...(price === undefined ? {} : { price }),
|
|
3801
|
+
},
|
|
3802
|
+
];
|
|
3803
|
+
});
|
|
3804
|
+
// No usable line proves an empty order only when the source count is a
|
|
3805
|
+
// known zero. A positive, missing, or malformed count is a detail gap:
|
|
3806
|
+
// the order is left out until its lines arrive.
|
|
3807
|
+
if (items.length === 0 && order.item_count !== 0) {
|
|
3808
|
+
dropped.add("orders", GROCERY_ORDER_ITEMS_GAP);
|
|
3809
|
+
return [];
|
|
3810
|
+
}
|
|
3811
|
+
// H-E-B item_count counts quantity units, not lines.
|
|
3812
|
+
if (typeof order.item_count === "number" &&
|
|
3813
|
+
Number.isInteger(order.item_count)) {
|
|
3814
|
+
const units = items.reduce((total, item) => total + (item.quantity === null ? 0 : Number(item.quantity)), 0);
|
|
3815
|
+
if (units !== order.item_count)
|
|
3816
|
+
unitCountMismatches += 1;
|
|
3817
|
+
}
|
|
3818
|
+
return [
|
|
3819
|
+
{
|
|
3820
|
+
orderId: order.id,
|
|
3821
|
+
items,
|
|
3822
|
+
orderDate: toLegacyLongDate(order.order_date),
|
|
3823
|
+
...(typeof order.total_cents === "number"
|
|
3824
|
+
? { total: order.total_cents / 100 }
|
|
3825
|
+
: {}),
|
|
3826
|
+
...(typeof order.item_count === "number"
|
|
3827
|
+
? { itemCount: order.item_count }
|
|
3828
|
+
: {}),
|
|
3829
|
+
...(typeof order.status === "string" || order.status === null
|
|
3830
|
+
? { status: order.status }
|
|
3831
|
+
: {}),
|
|
3832
|
+
},
|
|
3833
|
+
];
|
|
3834
|
+
});
|
|
3835
|
+
// Zero survivors from nonempty orders is not an empty history.
|
|
3836
|
+
const diagnostics = [
|
|
3837
|
+
...dropped.diagnostics(),
|
|
3838
|
+
...partialRows("heb.orders", "orders", "projection_order_unit_count_mismatch", unitCountMismatches),
|
|
3839
|
+
];
|
|
3840
|
+
if (sourceOrders.length > 0 && orders.length === 0) {
|
|
3841
|
+
return groceryRejection("heb.orders", diagnostics);
|
|
3842
|
+
}
|
|
3843
|
+
return {
|
|
3844
|
+
ok: true,
|
|
3845
|
+
payload: {
|
|
3846
|
+
orders,
|
|
3847
|
+
totalOrders: orders.length,
|
|
3848
|
+
totalItems: orders.reduce((total, order) => total + order.items.length, 0),
|
|
3849
|
+
},
|
|
3850
|
+
...withDiagnostics(diagnostics),
|
|
3851
|
+
};
|
|
3852
|
+
},
|
|
3853
|
+
};
|
|
3854
|
+
// Whole Foods 0.3.0 is the published, signature-verified OCI artifact.
|
|
3855
|
+
const wholefoodsSource = "https://registry.pdpp.dev/connectors/wholefoods";
|
|
3856
|
+
const wholefoodsEvidence = {
|
|
3857
|
+
kind: "oci",
|
|
3858
|
+
ref: "ghcr.io/pdp-connect/connector/wholefoods:0.3.0",
|
|
3859
|
+
digest: "sha256:873e287a153673bb9b96cae87dfe64e36730e18b30ea2e5c1731bdcff8d4432c",
|
|
3860
|
+
path: "declarations/wholefoods.collection-profile.json",
|
|
3861
|
+
};
|
|
3862
|
+
const wholefoodsProfile = {
|
|
3863
|
+
scope: "wholefoods.profile",
|
|
3864
|
+
pdppSource: wholefoodsSource,
|
|
3865
|
+
pdppStreams: ["profile"],
|
|
3866
|
+
legacySchemaPath: "wholefoods.profile.json",
|
|
3867
|
+
fieldsRead: { profile: ["name", "email"] },
|
|
3868
|
+
primaryKey: { profile: ["id"] },
|
|
3869
|
+
lossy: [
|
|
3870
|
+
"The legacy schema has no account id field; the Amazon customer id is not emitted.",
|
|
3871
|
+
],
|
|
3872
|
+
provenance: [
|
|
3873
|
+
{
|
|
3874
|
+
...wholefoodsEvidence,
|
|
3875
|
+
path: "declarations/wholefoods.collection-profile.json#streams[name=profile]",
|
|
3876
|
+
},
|
|
3877
|
+
],
|
|
3878
|
+
project(records, options) {
|
|
3879
|
+
const guard = requireStreams("wholefoods.profile", options, ["profile"]);
|
|
3880
|
+
if (guard)
|
|
3881
|
+
return guard;
|
|
3882
|
+
const profiles = byStream(records, "profile");
|
|
3883
|
+
if (profiles.length === 0)
|
|
3884
|
+
return {
|
|
3885
|
+
ok: false,
|
|
3886
|
+
error: { kind: "empty_singleton", scope: "wholefoods.profile" },
|
|
3887
|
+
};
|
|
3888
|
+
if (profiles.length !== 1)
|
|
3889
|
+
return {
|
|
3890
|
+
ok: false,
|
|
3891
|
+
error: {
|
|
3892
|
+
kind: "incomplete_scope",
|
|
3893
|
+
scope: "wholefoods.profile",
|
|
3894
|
+
reason: "profile stream did not contain exactly one record",
|
|
3895
|
+
},
|
|
3896
|
+
};
|
|
3897
|
+
const [p] = profiles;
|
|
3898
|
+
if ((p.name != null && typeof p.name !== "string") ||
|
|
3899
|
+
(p.email != null && typeof p.email !== "string")) {
|
|
3900
|
+
return {
|
|
3901
|
+
ok: false,
|
|
3902
|
+
error: {
|
|
3903
|
+
kind: "incomplete_scope",
|
|
3904
|
+
scope: "wholefoods.profile",
|
|
3905
|
+
reason: "profile contains a malformed scalar value",
|
|
3906
|
+
},
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
return {
|
|
3910
|
+
ok: true,
|
|
3911
|
+
payload: {
|
|
3912
|
+
name: typeof p.name === "string" ? p.name : null,
|
|
3913
|
+
email: typeof p.email === "string" ? p.email : null,
|
|
3914
|
+
},
|
|
3915
|
+
};
|
|
3916
|
+
},
|
|
3917
|
+
};
|
|
3918
|
+
const wholefoodsOrders = {
|
|
3919
|
+
scope: "wholefoods.orders",
|
|
3920
|
+
pdppSource: wholefoodsSource,
|
|
3921
|
+
pdppStreams: ["orders", "order_items"],
|
|
3922
|
+
legacySchemaPath: "wholefoods.orders.json",
|
|
3923
|
+
fieldsRead: {
|
|
3924
|
+
orders: [
|
|
3925
|
+
"id",
|
|
3926
|
+
"order_date",
|
|
3927
|
+
"order_url",
|
|
3928
|
+
"status",
|
|
3929
|
+
"total_cents",
|
|
3930
|
+
"item_count",
|
|
3931
|
+
],
|
|
3932
|
+
order_items: [
|
|
3933
|
+
"order_id",
|
|
3934
|
+
"name",
|
|
3935
|
+
"product_id",
|
|
3936
|
+
"product_url",
|
|
3937
|
+
"image_url",
|
|
3938
|
+
"quantity",
|
|
3939
|
+
"unit_price_cents",
|
|
3940
|
+
],
|
|
3941
|
+
},
|
|
3942
|
+
primaryKey: { orders: ["id"], order_items: ["id"] },
|
|
3943
|
+
memoryBound: "Rejects the whole scope when every order is dropped, a decision a window of orders cannot make.",
|
|
3944
|
+
lossy: [
|
|
3945
|
+
"The retained collector emitted only product-linked named lines; a source line without either field is dropped and counted, and its order is delivered without it.",
|
|
3946
|
+
"An order with no usable line and an item_count that is not a known zero is left out and counted; an order whose line count differs from item_count, or whose item_count is unknown, is delivered and reported partial. A missing or duplicate order id still fails the scope.",
|
|
3947
|
+
"Product identity is the source Amazon ASIN in product_id.",
|
|
3948
|
+
],
|
|
3949
|
+
provenance: [
|
|
3950
|
+
{
|
|
3951
|
+
...wholefoodsEvidence,
|
|
3952
|
+
path: "declarations/wholefoods.collection-profile.json#streams[name=orders,order_items]",
|
|
3953
|
+
},
|
|
3954
|
+
],
|
|
3955
|
+
project(records, options) {
|
|
3956
|
+
const guard = requireStreams("wholefoods.orders", options, [
|
|
3957
|
+
"orders",
|
|
3958
|
+
"order_items",
|
|
3959
|
+
]);
|
|
3960
|
+
if (guard)
|
|
3961
|
+
return guard;
|
|
3962
|
+
const sourceItems = byStream(records, "order_items");
|
|
3963
|
+
const sourceOrders = byStream(records, "orders");
|
|
3964
|
+
const sourceOrderIds = new Set(sourceOrders.map((order) => order.id));
|
|
3965
|
+
if (sourceOrderIds.size !== sourceOrders.length ||
|
|
3966
|
+
sourceOrders.some((order) => !isNonEmptyString(order.id))) {
|
|
3967
|
+
return {
|
|
3968
|
+
ok: false,
|
|
3969
|
+
error: {
|
|
3970
|
+
kind: "incomplete_scope",
|
|
3971
|
+
scope: "wholefoods.orders",
|
|
3972
|
+
reason: "orders contain a missing or duplicate id",
|
|
3973
|
+
},
|
|
3974
|
+
};
|
|
3975
|
+
}
|
|
3976
|
+
if (sourceItems.some((item) => !sourceOrderIds.has(item.order_id))) {
|
|
3977
|
+
return {
|
|
3978
|
+
ok: false,
|
|
3979
|
+
error: {
|
|
3980
|
+
kind: "incomplete_scope",
|
|
3981
|
+
scope: "wholefoods.orders",
|
|
3982
|
+
reason: "order_items.order_id has no matching order",
|
|
3983
|
+
},
|
|
3984
|
+
};
|
|
3985
|
+
}
|
|
3986
|
+
const dropped = new DroppedRows("wholefoods.orders");
|
|
3987
|
+
let countMismatches = 0;
|
|
3988
|
+
const orders = sourceOrders.flatMap((o) => {
|
|
3989
|
+
const items = sourceItems
|
|
3990
|
+
.filter((i) => i.order_id === o.id)
|
|
3991
|
+
.flatMap((i) => {
|
|
3992
|
+
if (!isNonEmptyString(i.name)) {
|
|
3993
|
+
dropped.add("order_items", "projection_order_item_missing_name");
|
|
3994
|
+
return [];
|
|
3995
|
+
}
|
|
3996
|
+
if (!isNonEmptyString(i.product_id)) {
|
|
3997
|
+
dropped.add("order_items", "projection_order_item_missing_product_id");
|
|
3998
|
+
return [];
|
|
3999
|
+
}
|
|
4000
|
+
return [
|
|
4001
|
+
{
|
|
4002
|
+
name: i.name,
|
|
4003
|
+
productId: i.product_id,
|
|
4004
|
+
...(typeof i.product_url === "string"
|
|
4005
|
+
? { productUrl: i.product_url }
|
|
4006
|
+
: {}),
|
|
4007
|
+
...(typeof i.image_url === "string"
|
|
4008
|
+
? { imageUrl: i.image_url }
|
|
4009
|
+
: {}),
|
|
4010
|
+
quantity: typeof i.quantity === "number" ? String(i.quantity) : null,
|
|
4011
|
+
price: typeof i.unit_price_cents === "number"
|
|
4012
|
+
? i.unit_price_cents / 100
|
|
4013
|
+
: null,
|
|
4014
|
+
},
|
|
4015
|
+
];
|
|
4016
|
+
});
|
|
4017
|
+
// Whole Foods item_count counts lines. Only a known zero proves an
|
|
4018
|
+
// order with no usable line is empty; otherwise it is a detail gap.
|
|
4019
|
+
const itemCount = o.item_count;
|
|
4020
|
+
const knownCount = typeof itemCount === "number" &&
|
|
4021
|
+
Number.isSafeInteger(itemCount) &&
|
|
4022
|
+
itemCount >= 0;
|
|
4023
|
+
if (items.length === 0 && !(knownCount && itemCount === 0)) {
|
|
4024
|
+
dropped.add("orders", GROCERY_ORDER_ITEMS_GAP);
|
|
4025
|
+
return [];
|
|
4026
|
+
}
|
|
4027
|
+
if (!knownCount || items.length !== itemCount)
|
|
4028
|
+
countMismatches += 1;
|
|
4029
|
+
return [
|
|
4030
|
+
{
|
|
4031
|
+
orderId: o.id,
|
|
4032
|
+
items,
|
|
4033
|
+
...(typeof o.order_url === "string" ? { orderUrl: o.order_url } : {}),
|
|
4034
|
+
...(typeof o.order_date === "string" || o.order_date === null
|
|
4035
|
+
? { orderDate: o.order_date }
|
|
4036
|
+
: {}),
|
|
4037
|
+
// The legacy Whole Foods collector labeled every observed order Completed;
|
|
4038
|
+
// source 0.3.0 correctly reports status as unknown (null).
|
|
4039
|
+
...(o.status === null
|
|
4040
|
+
? { status: "Completed" }
|
|
4041
|
+
: typeof o.status === "string"
|
|
4042
|
+
? { status: o.status }
|
|
4043
|
+
: {}),
|
|
4044
|
+
...(typeof o.total_cents === "number"
|
|
4045
|
+
? { total: o.total_cents / 100 }
|
|
4046
|
+
: {}),
|
|
4047
|
+
...(typeof o.item_count === "number"
|
|
4048
|
+
? { itemCount: o.item_count }
|
|
4049
|
+
: {}),
|
|
4050
|
+
},
|
|
4051
|
+
];
|
|
4052
|
+
});
|
|
4053
|
+
const diagnostics = [
|
|
4054
|
+
...dropped.diagnostics(),
|
|
4055
|
+
...partialRows("wholefoods.orders", "orders", "projection_order_item_count_mismatch", countMismatches),
|
|
4056
|
+
];
|
|
4057
|
+
if (sourceOrders.length > 0 && orders.length === 0) {
|
|
4058
|
+
return groceryRejection("wholefoods.orders", diagnostics);
|
|
4059
|
+
}
|
|
4060
|
+
return {
|
|
4061
|
+
ok: true,
|
|
4062
|
+
payload: {
|
|
4063
|
+
orders,
|
|
4064
|
+
totalOrders: orders.length,
|
|
4065
|
+
totalItems: orders.reduce((sum, o) => sum + o.items.length, 0),
|
|
4066
|
+
},
|
|
4067
|
+
...withDiagnostics(diagnostics),
|
|
4068
|
+
};
|
|
4069
|
+
},
|
|
4070
|
+
};
|
|
4071
|
+
const wholefoodsNutritionFields = [
|
|
4072
|
+
"product_id",
|
|
4073
|
+
"name",
|
|
4074
|
+
"source",
|
|
4075
|
+
"confidence",
|
|
4076
|
+
"calories",
|
|
4077
|
+
"protein_g",
|
|
4078
|
+
"carbs_g",
|
|
4079
|
+
"fat_g",
|
|
4080
|
+
"sodium_mg",
|
|
4081
|
+
"fiber_g",
|
|
4082
|
+
"sugar_g",
|
|
4083
|
+
"serving_size",
|
|
4084
|
+
"servings_per_container",
|
|
4085
|
+
];
|
|
4086
|
+
const wholefoodsNutrition = {
|
|
4087
|
+
scope: "wholefoods.nutrition",
|
|
4088
|
+
pdppSource: wholefoodsSource,
|
|
4089
|
+
pdppStreams: ["nutrition", "order_items"],
|
|
4090
|
+
legacySchemaPath: "wholefoods.nutrition.json",
|
|
4091
|
+
fieldsRead: {
|
|
4092
|
+
nutrition: wholefoodsNutritionFields,
|
|
4093
|
+
order_items: ["product_id", "name", "product_url", "image_url"],
|
|
4094
|
+
},
|
|
4095
|
+
primaryKey: { nutrition: ["product_id"], order_items: ["id"] },
|
|
4096
|
+
memoryBound: "The output is one map keyed by product with whole-scope coverage totals and checks, not one row per parent.",
|
|
4097
|
+
lossy: [
|
|
4098
|
+
"ingredients and allergens are not collected by the current nutrition stream.",
|
|
4099
|
+
"servingsPerContainer is converted from the declared number to the legacy string field.",
|
|
4100
|
+
],
|
|
4101
|
+
provenance: [
|
|
4102
|
+
{
|
|
4103
|
+
...wholefoodsEvidence,
|
|
4104
|
+
path: "declarations/wholefoods.collection-profile.json#streams[name=nutrition]",
|
|
4105
|
+
},
|
|
4106
|
+
],
|
|
4107
|
+
project(records, options) {
|
|
4108
|
+
const guard = requireStreams("wholefoods.nutrition", options, [
|
|
4109
|
+
"nutrition",
|
|
4110
|
+
"order_items",
|
|
4111
|
+
]);
|
|
4112
|
+
if (guard)
|
|
4113
|
+
return guard;
|
|
4114
|
+
const items = Object.create(null);
|
|
4115
|
+
const orderedProducts = new Map();
|
|
4116
|
+
for (const row of byStream(records, "order_items")) {
|
|
4117
|
+
if (!isNonEmptyString(row.product_id) || typeof row.name !== "string")
|
|
4118
|
+
return {
|
|
4119
|
+
ok: false,
|
|
4120
|
+
error: {
|
|
4121
|
+
kind: "incomplete_scope",
|
|
4122
|
+
scope: "wholefoods.nutrition",
|
|
4123
|
+
reason: "order item lacks a source ASIN or name",
|
|
4124
|
+
},
|
|
4125
|
+
};
|
|
4126
|
+
orderedProducts.set(row.product_id, {
|
|
4127
|
+
name: row.name,
|
|
4128
|
+
...(typeof row.product_url === "string"
|
|
4129
|
+
? { productUrl: row.product_url }
|
|
4130
|
+
: {}),
|
|
4131
|
+
...(typeof row.image_url === "string"
|
|
4132
|
+
? { imageUrl: row.image_url }
|
|
4133
|
+
: {}),
|
|
4134
|
+
});
|
|
4135
|
+
}
|
|
4136
|
+
let found = 0, foundUSDA = 0, blocked = 0;
|
|
4137
|
+
const seenNutrition = new Set();
|
|
4138
|
+
for (const n of byStream(records, "nutrition")) {
|
|
4139
|
+
if (!isNonEmptyString(n.product_id) ||
|
|
4140
|
+
typeof n.source !== "string" ||
|
|
4141
|
+
![
|
|
4142
|
+
"wholefoods_product_page",
|
|
4143
|
+
"usda_fdc",
|
|
4144
|
+
"not_found",
|
|
4145
|
+
"error",
|
|
4146
|
+
"blocked",
|
|
4147
|
+
].includes(n.source) ||
|
|
4148
|
+
!orderedProducts.has(n.product_id) ||
|
|
4149
|
+
seenNutrition.has(n.product_id))
|
|
4150
|
+
return {
|
|
4151
|
+
ok: false,
|
|
4152
|
+
error: {
|
|
4153
|
+
kind: "incomplete_scope",
|
|
4154
|
+
scope: "wholefoods.nutrition",
|
|
4155
|
+
reason: "nutrition row has an invalid, duplicate, or unordered product outcome",
|
|
4156
|
+
},
|
|
4157
|
+
};
|
|
4158
|
+
seenNutrition.add(n.product_id);
|
|
4159
|
+
const ordered = orderedProducts.get(n.product_id);
|
|
4160
|
+
const name = typeof n.name === "string" ? n.name : ordered?.name;
|
|
4161
|
+
if (typeof name !== "string")
|
|
4162
|
+
return {
|
|
4163
|
+
ok: false,
|
|
4164
|
+
error: {
|
|
4165
|
+
kind: "incomplete_scope",
|
|
4166
|
+
scope: "wholefoods.nutrition",
|
|
4167
|
+
reason: "nutrition product name is unavailable",
|
|
4168
|
+
},
|
|
4169
|
+
};
|
|
4170
|
+
const item = { name, source: n.source };
|
|
4171
|
+
if (ordered?.productUrl !== undefined)
|
|
4172
|
+
item.productUrl = ordered.productUrl;
|
|
4173
|
+
if (ordered?.imageUrl !== undefined)
|
|
4174
|
+
item.images = ordered.imageUrl;
|
|
4175
|
+
if (["high", "medium", "low"].includes(String(n.confidence))) {
|
|
4176
|
+
item.confidence = n.confidence;
|
|
4177
|
+
}
|
|
4178
|
+
for (const field of [
|
|
4179
|
+
"calories",
|
|
4180
|
+
"protein_g",
|
|
4181
|
+
"carbs_g",
|
|
4182
|
+
"fat_g",
|
|
4183
|
+
"sodium_mg",
|
|
4184
|
+
"fiber_g",
|
|
4185
|
+
"sugar_g",
|
|
4186
|
+
]) {
|
|
4187
|
+
if (n[field] === null || typeof n[field] === "number") {
|
|
4188
|
+
item[field] = n[field];
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
if (n.serving_size === null || typeof n.serving_size === "string")
|
|
4192
|
+
item.servingSize = n.serving_size;
|
|
4193
|
+
if (typeof n.servings_per_container === "number")
|
|
4194
|
+
item.servingsPerContainer = String(n.servings_per_container);
|
|
4195
|
+
else if (n.servings_per_container === null)
|
|
4196
|
+
item.servingsPerContainer = null;
|
|
4197
|
+
items[n.product_id] = item;
|
|
4198
|
+
if (n.source === "wholefoods_product_page")
|
|
4199
|
+
found++;
|
|
4200
|
+
if (n.source === "usda_fdc")
|
|
4201
|
+
foundUSDA++;
|
|
4202
|
+
if (n.source === "blocked")
|
|
4203
|
+
blocked++;
|
|
4204
|
+
}
|
|
4205
|
+
const total = orderedProducts.size;
|
|
4206
|
+
if (seenNutrition.size !== total)
|
|
4207
|
+
return {
|
|
4208
|
+
ok: false,
|
|
4209
|
+
error: {
|
|
4210
|
+
kind: "incomplete_scope",
|
|
4211
|
+
scope: "wholefoods.nutrition",
|
|
4212
|
+
reason: "nutrition outcomes do not cover every ordered product",
|
|
4213
|
+
},
|
|
4214
|
+
};
|
|
4215
|
+
return {
|
|
4216
|
+
ok: true,
|
|
4217
|
+
payload: {
|
|
4218
|
+
items,
|
|
4219
|
+
coverage: {
|
|
4220
|
+
total,
|
|
4221
|
+
found,
|
|
4222
|
+
foundUSDA,
|
|
4223
|
+
blocked,
|
|
4224
|
+
percentCovered: total
|
|
4225
|
+
? Math.round(((found + foundUSDA) / total) * 100)
|
|
4226
|
+
: 0,
|
|
4227
|
+
},
|
|
4228
|
+
},
|
|
4229
|
+
};
|
|
4230
|
+
},
|
|
4231
|
+
};
|
|
4232
|
+
// iCloud Notes is bound to the signed 0.1.0 collection profile. Desktop
|
|
4233
|
+
// admission and ingest projection are separate gates.
|
|
4234
|
+
const icloudNoteFolders = {
|
|
4235
|
+
scope: "icloud_notes.folders",
|
|
4236
|
+
pdppSource: "https://registry.pdpp.dev/connectors/icloud-notes",
|
|
4237
|
+
pdppStreams: ["folders"],
|
|
4238
|
+
legacySchemaPath: "icloud_notes.folders.json",
|
|
4239
|
+
fieldsRead: { folders: ["id", "name"] },
|
|
4240
|
+
primaryKey: { folders: ["id"] },
|
|
4241
|
+
lossy: [],
|
|
4242
|
+
provenance: [
|
|
4243
|
+
{
|
|
4244
|
+
kind: "oci",
|
|
4245
|
+
ref: "ghcr.io/pdp-connect/connector/icloud-notes:0.1.0",
|
|
4246
|
+
digest: "sha256:fe5497bb79b0d567c30790cc71b1e591b955fe474725679b996441bd70c09944",
|
|
4247
|
+
path: "declarations/icloud-notes.collection-profile.json#streams[name=folders]",
|
|
4248
|
+
},
|
|
4249
|
+
],
|
|
4250
|
+
project(records, options) {
|
|
4251
|
+
const guard = requireStreams("icloud_notes.folders", options, ["folders"]);
|
|
4252
|
+
if (guard)
|
|
4253
|
+
return guard;
|
|
4254
|
+
const folders = byStream(records, "folders");
|
|
4255
|
+
return {
|
|
4256
|
+
ok: true,
|
|
4257
|
+
payload: {
|
|
4258
|
+
folders: folders.map((folder) => ({
|
|
4259
|
+
recordName: orEmptyString(folder.id),
|
|
4260
|
+
title: orEmptyString(folder.name),
|
|
4261
|
+
})),
|
|
4262
|
+
total: folders.length,
|
|
4263
|
+
},
|
|
4264
|
+
};
|
|
4265
|
+
},
|
|
4266
|
+
};
|
|
4267
|
+
const ICLOUD_NOTES_PROFILE_PROVENANCE = {
|
|
4268
|
+
kind: "collection-profile",
|
|
4269
|
+
ref: "https://github.com/PDP-Connect/data-connectors/tree/3ac4dd636938fbff9168eb662d2300eb85554801/connectors/icloud_notes",
|
|
4270
|
+
digest: "sha256:ad6d28dac69a84019be2c81ac5f1f2ae8fa9c6602eb179370f0bb9d9022e33b2",
|
|
4271
|
+
path: "declarations/icloud-notes-0.1.24.collection-profile.json#streams[name=profile,notes,folders]",
|
|
4272
|
+
};
|
|
4273
|
+
const icloudNotes = {
|
|
4274
|
+
scope: "icloud_notes.notes",
|
|
4275
|
+
pdppSource: "https://registry.pdpp.dev/connectors/icloud-notes",
|
|
4276
|
+
pdppStreams: ["notes", "folders", "profile"],
|
|
4277
|
+
legacySchemaPath: "icloud_notes.notes.json",
|
|
4278
|
+
fieldsRead: {
|
|
4279
|
+
notes: [
|
|
4280
|
+
"id",
|
|
4281
|
+
"title",
|
|
4282
|
+
"snippet",
|
|
4283
|
+
"folder_id",
|
|
4284
|
+
"is_pinned",
|
|
4285
|
+
"created_at",
|
|
4286
|
+
"modified_at",
|
|
4287
|
+
"has_attachments",
|
|
4288
|
+
"text_content",
|
|
4289
|
+
],
|
|
4290
|
+
folders: ["id", "name"],
|
|
4291
|
+
profile: ["id", "user_name"],
|
|
4292
|
+
},
|
|
4293
|
+
primaryKey: { notes: ["id"], folders: ["id"], profile: ["id"] },
|
|
4294
|
+
memoryBound: "One flat list of notes; folders is a name lookup, so there are no per-parent children to split.",
|
|
4295
|
+
lossy: [
|
|
4296
|
+
"userName is null when the profile stream has no readable user_name (legacy's fullName default); it is never inferred from an Apple ID or the account id.",
|
|
4297
|
+
"folder uses the legacy display-name shape; unresolved folder references fall back to folder_id.",
|
|
4298
|
+
],
|
|
4299
|
+
provenance: [ICLOUD_NOTES_PROFILE_PROVENANCE],
|
|
4300
|
+
project(records, options) {
|
|
4301
|
+
const guard = requireStreams("icloud_notes.notes", options, [
|
|
4302
|
+
"notes",
|
|
4303
|
+
"folders",
|
|
4304
|
+
"profile",
|
|
4305
|
+
]);
|
|
4306
|
+
if (guard)
|
|
4307
|
+
return guard;
|
|
4308
|
+
// The profile stream is a singleton: legacy's fullName maps to exactly one
|
|
4309
|
+
// account. No row, several rows, or an unreadable name leave userName null.
|
|
4310
|
+
const profiles = byStream(records, "profile");
|
|
4311
|
+
const profileName = profiles.length === 1 ? profiles[0]?.user_name : undefined;
|
|
4312
|
+
const userName = typeof profileName === "string" && profileName.trim().length > 0
|
|
4313
|
+
? profileName
|
|
4314
|
+
: null;
|
|
4315
|
+
const folders = new Map();
|
|
4316
|
+
for (const folder of byStream(records, "folders")) {
|
|
4317
|
+
if (typeof folder.id !== "string" ||
|
|
4318
|
+
folder.id.length === 0 ||
|
|
4319
|
+
typeof folder.name !== "string" ||
|
|
4320
|
+
folder.name.length === 0) {
|
|
4321
|
+
return {
|
|
4322
|
+
ok: false,
|
|
4323
|
+
error: {
|
|
4324
|
+
kind: "invalid_value",
|
|
4325
|
+
scope: "icloud_notes.notes",
|
|
4326
|
+
reason: "iCloud Notes folder is missing a declared required field",
|
|
4327
|
+
},
|
|
4328
|
+
};
|
|
4329
|
+
}
|
|
4330
|
+
folders.set(folder.id, folder.name);
|
|
4331
|
+
}
|
|
4332
|
+
const notes = byStream(records, "notes").map((note) => {
|
|
4333
|
+
if (typeof note.id !== "string" || note.id.length === 0)
|
|
4334
|
+
return undefined;
|
|
4335
|
+
const optionalString = (field) => {
|
|
4336
|
+
const value = note[field];
|
|
4337
|
+
return value == null || typeof value === "string"
|
|
4338
|
+
? (value ?? null)
|
|
4339
|
+
: undefined;
|
|
4340
|
+
};
|
|
4341
|
+
const title = optionalString("title");
|
|
4342
|
+
const snippet = optionalString("snippet");
|
|
4343
|
+
const folderId = optionalString("folder_id");
|
|
4344
|
+
const createdDate = optionalString("created_at");
|
|
4345
|
+
const modifiedDate = optionalString("modified_at");
|
|
4346
|
+
const textContent = optionalString("text_content");
|
|
4347
|
+
if (title === undefined ||
|
|
4348
|
+
snippet === undefined ||
|
|
4349
|
+
folderId === undefined ||
|
|
4350
|
+
createdDate === undefined ||
|
|
4351
|
+
modifiedDate === undefined ||
|
|
4352
|
+
textContent === undefined ||
|
|
4353
|
+
typeof note.is_pinned !== "boolean" ||
|
|
4354
|
+
typeof note.has_attachments !== "boolean")
|
|
4355
|
+
return undefined;
|
|
4356
|
+
return {
|
|
4357
|
+
recordName: note.id,
|
|
4358
|
+
title,
|
|
4359
|
+
snippet,
|
|
4360
|
+
folder: folderId === null ? null : (folders.get(folderId) ?? folderId),
|
|
4361
|
+
isPinned: note.is_pinned,
|
|
4362
|
+
createdDate,
|
|
4363
|
+
modifiedDate,
|
|
4364
|
+
hasAttachments: note.has_attachments,
|
|
4365
|
+
textContent,
|
|
4366
|
+
};
|
|
4367
|
+
});
|
|
4368
|
+
if (notes.some((note) => note === undefined)) {
|
|
4369
|
+
return {
|
|
4370
|
+
ok: false,
|
|
4371
|
+
error: {
|
|
4372
|
+
kind: "invalid_value",
|
|
4373
|
+
scope: "icloud_notes.notes",
|
|
4374
|
+
reason: "iCloud Notes contains a record that does not match its declared schema",
|
|
4375
|
+
},
|
|
4376
|
+
};
|
|
4377
|
+
}
|
|
4378
|
+
return {
|
|
4379
|
+
ok: true,
|
|
4380
|
+
payload: { notes, total: notes.length, userName },
|
|
4381
|
+
};
|
|
4382
|
+
},
|
|
4383
|
+
};
|
|
4384
|
+
// ---------------------------------------------------------------------------
|
|
4385
|
+
// strava (strava.activities, strava.coverage_diagnostics)
|
|
4386
|
+
// declarations/strava.collection-profile.json (1.0.8, digest-pinned)
|
|
4387
|
+
// connector_id: https://registry.pdpp.dev/connectors/strava
|
|
4388
|
+
//
|
|
4389
|
+
// Desktop's export served each scope as `{ <stream>: [record.data, ...] }`
|
|
4390
|
+
// (apps/desktop pdpp_export_projection.rs at e970213f). Both bindings are
|
|
4391
|
+
// that identity: every native field, null and unknown field is kept, and the
|
|
4392
|
+
// two streams never read each other.
|
|
4393
|
+
// ---------------------------------------------------------------------------
|
|
4394
|
+
const STRAVA_DIGEST = "sha256:b33086156d3003d0cbe48cb0de4adf48a7fde7241f28c2ea5e350cff1f17c82c";
|
|
4395
|
+
const STRAVA_FIELDS = {
|
|
4396
|
+
activities: [
|
|
4397
|
+
"id",
|
|
4398
|
+
"activity_type",
|
|
4399
|
+
"start_date",
|
|
4400
|
+
"start_time",
|
|
4401
|
+
"start_time_basis",
|
|
4402
|
+
"distance_m",
|
|
4403
|
+
"moving_time_s",
|
|
4404
|
+
"elapsed_time_s",
|
|
4405
|
+
"total_elevation_gain_m",
|
|
4406
|
+
"average_heartrate",
|
|
4407
|
+
"max_heartrate",
|
|
4408
|
+
"calories_kcal",
|
|
4409
|
+
"gear",
|
|
4410
|
+
"freshness",
|
|
4411
|
+
"exported_at",
|
|
4412
|
+
],
|
|
4413
|
+
coverage_diagnostics: [
|
|
4414
|
+
"id",
|
|
4415
|
+
"stream",
|
|
4416
|
+
"status",
|
|
4417
|
+
"reason",
|
|
4418
|
+
"record_count",
|
|
4419
|
+
"fields_unavailable",
|
|
4420
|
+
"window_requested_from",
|
|
4421
|
+
"window_requested_to",
|
|
4422
|
+
"window_covered_from",
|
|
4423
|
+
"window_covered_to",
|
|
4424
|
+
"freshness",
|
|
4425
|
+
"exported_at",
|
|
4426
|
+
],
|
|
4427
|
+
};
|
|
4428
|
+
function stravaIdentity(stream, lossy) {
|
|
4429
|
+
const scope = `strava.${stream}`;
|
|
4430
|
+
return {
|
|
4431
|
+
scope,
|
|
4432
|
+
pdppSource: "https://registry.pdpp.dev/connectors/strava",
|
|
4433
|
+
pdppStreams: [stream],
|
|
4434
|
+
legacySchemaPath: `${scope}.json`,
|
|
4435
|
+
fieldsRead: { [stream]: [...STRAVA_FIELDS[stream]] },
|
|
4436
|
+
primaryKey: { [stream]: ["id"] },
|
|
4437
|
+
lossy,
|
|
4438
|
+
rowOrder: "arrival",
|
|
4439
|
+
provenance: [
|
|
4440
|
+
{
|
|
4441
|
+
kind: "oci",
|
|
4442
|
+
ref: "ghcr.io/pdp-connect/connector/strava:1.0.8",
|
|
4443
|
+
digest: STRAVA_DIGEST,
|
|
4444
|
+
path: `declarations/strava.collection-profile.json#streams[name=${stream}]`,
|
|
4445
|
+
},
|
|
4446
|
+
],
|
|
4447
|
+
project(records, options) {
|
|
4448
|
+
const guard = requireStreams(scope, options, [stream]);
|
|
4449
|
+
if (guard)
|
|
4450
|
+
return guard;
|
|
4451
|
+
return { ok: true, payload: { [stream]: byStream(records, stream) } };
|
|
4452
|
+
},
|
|
4453
|
+
};
|
|
4454
|
+
}
|
|
4455
|
+
const stravaActivities = stravaIdentity("activities", [
|
|
4456
|
+
"No field is dropped, derived or defaulted: the body is the native records.",
|
|
4457
|
+
"Row order: Desktop's snapshot was in arrival order (a re-emitted id, changed or not, moved to the end). The binding keeps its input order; the read facade supplies arrival order and reports rows it cannot place.",
|
|
4458
|
+
"Coverage: the body carries rows only, as Desktop's did. Whether the export was read in full is producer data in strava.coverage_diagnostics; this scope neither reads nor judges it.",
|
|
4459
|
+
]);
|
|
4460
|
+
const stravaCoverageDiagnostics = stravaIdentity("coverage_diagnostics", [
|
|
4461
|
+
"No field is dropped, derived or defaulted: the body is the native records, so a partial or empty status, its reason and fields_unavailable reach the reader as written.",
|
|
4462
|
+
"Row order: as for strava.activities.",
|
|
4463
|
+
"Absence of a row is not evidence of a complete collection: the producer emits no diagnostic when only diagnostics are requested and the import directory exists. The read facade serves an empty list only with that stream's own completion receipt.",
|
|
4464
|
+
]);
|
|
4465
|
+
export const LEGACY_SCOPE_BINDINGS = new Map(Object.entries({
|
|
4466
|
+
"instagram.profile": instagramProfile,
|
|
4467
|
+
"instagram.posts": instagramPosts,
|
|
4468
|
+
"instagram.following": instagramFollowing,
|
|
4469
|
+
"instagram.ads": instagramAds,
|
|
4470
|
+
"github.repositories": githubRepositories,
|
|
4471
|
+
"github.starred": githubStarred,
|
|
4472
|
+
"github.history": githubHistory,
|
|
4473
|
+
"github.profile": githubProfile,
|
|
4474
|
+
"github.events": githubEvents,
|
|
4475
|
+
"github.contributions": githubContributions,
|
|
4476
|
+
"chatgpt.memories": chatgptMemories,
|
|
4477
|
+
"chatgpt.conversations": chatgptConversations,
|
|
4478
|
+
"linkedin.profile": linkedinProfile,
|
|
4479
|
+
"linkedin.connections": linkedinConnections,
|
|
4480
|
+
"linkedin.experience": linkedinExperience,
|
|
4481
|
+
"linkedin.education": linkedinEducation,
|
|
4482
|
+
"linkedin.skills": linkedinSkills,
|
|
4483
|
+
"linkedin.languages": linkedinLanguages,
|
|
4484
|
+
"spotify.profile": spotifyProfile,
|
|
4485
|
+
"spotify.savedTracks": spotifySavedTracks,
|
|
4486
|
+
"spotify.playlists": spotifyPlaylists,
|
|
4487
|
+
"shop.orders": shopOrders,
|
|
4488
|
+
"amazon.orders": amazonOrders,
|
|
4489
|
+
"heb.orders": hebOrders,
|
|
4490
|
+
"heb.profile": hebProfile,
|
|
4491
|
+
"heb.nutrition": hebNutrition,
|
|
4492
|
+
"wholefoods.profile": wholefoodsProfile,
|
|
4493
|
+
"wholefoods.orders": wholefoodsOrders,
|
|
4494
|
+
"wholefoods.nutrition": wholefoodsNutrition,
|
|
4495
|
+
"oura.activity": ouraActivity,
|
|
4496
|
+
"oura.readiness": ouraReadiness,
|
|
4497
|
+
"oura.sleep": ouraSleep,
|
|
4498
|
+
"icloud_notes.notes": icloudNotes,
|
|
4499
|
+
"icloud_notes.folders": icloudNoteFolders,
|
|
4500
|
+
"youtube.profile": youtubeProfile,
|
|
4501
|
+
"youtube.subscriptions": youtubeSubscriptions,
|
|
4502
|
+
"youtube.playlists": youtubePlaylists,
|
|
4503
|
+
"youtube.playlistItems": youtubePlaylistItems,
|
|
4504
|
+
"youtube.likes": youtubeLikes,
|
|
4505
|
+
"youtube.watchLater": youtubeWatchLater,
|
|
4506
|
+
"youtube.history": youtubeHistory,
|
|
4507
|
+
"claude.conversations": claudeConversations,
|
|
4508
|
+
"claude.projects": claudeProjects,
|
|
4509
|
+
"strava.activities": stravaActivities,
|
|
4510
|
+
"strava.coverage_diagnostics": stravaCoverageDiagnostics,
|
|
4511
|
+
}));
|
|
4512
|
+
//# sourceMappingURL=bindings.js.map
|