@opendatalabs/personal-server-ts-core 0.0.1-canary.01ca694 → 0.0.1-canary.052d47e
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/api/index.d.ts +282 -9
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +867 -163
- package/dist/api/index.js.map +1 -1
- package/dist/auth/request.d.ts.map +1 -1
- package/dist/auth/request.js.map +1 -1
- package/dist/client.d.ts +8 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +21 -3
- package/dist/client.js.map +1 -1
- package/dist/contracts/binary.d.ts +12 -0
- package/dist/contracts/binary.d.ts.map +1 -1
- package/dist/contracts/binary.js +31 -0
- package/dist/contracts/binary.js.map +1 -1
- package/dist/contracts/data.d.ts +51 -5
- package/dist/contracts/data.d.ts.map +1 -1
- package/dist/contracts/data.js +166 -30
- package/dist/contracts/data.js.map +1 -1
- package/dist/contracts/grants.d.ts +7 -5
- package/dist/contracts/grants.d.ts.map +1 -1
- package/dist/contracts/grants.js +60 -37
- package/dist/contracts/grants.js.map +1 -1
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/derivatives/api.d.ts +48 -0
- package/dist/derivatives/api.d.ts.map +1 -0
- package/dist/derivatives/api.js +366 -0
- package/dist/derivatives/api.js.map +1 -0
- package/dist/derivatives/compute.d.ts +106 -0
- package/dist/derivatives/compute.d.ts.map +1 -0
- package/dist/derivatives/compute.js +414 -0
- package/dist/derivatives/compute.js.map +1 -0
- package/dist/derivatives/e2ee/aad.d.ts +22 -0
- package/dist/derivatives/e2ee/aad.d.ts.map +1 -0
- package/dist/derivatives/e2ee/aad.js +32 -0
- package/dist/derivatives/e2ee/aad.js.map +1 -0
- package/dist/derivatives/e2ee/attestation.d.ts +134 -0
- package/dist/derivatives/e2ee/attestation.d.ts.map +1 -0
- package/dist/derivatives/e2ee/attestation.js +248 -0
- package/dist/derivatives/e2ee/attestation.js.map +1 -0
- package/dist/derivatives/e2ee/index.d.ts +6 -0
- package/dist/derivatives/e2ee/index.d.ts.map +1 -0
- package/dist/derivatives/e2ee/index.js +6 -0
- package/dist/derivatives/e2ee/index.js.map +1 -0
- package/dist/derivatives/e2ee/jcs.d.ts +17 -0
- package/dist/derivatives/e2ee/jcs.d.ts.map +1 -0
- package/dist/derivatives/e2ee/jcs.js +55 -0
- package/dist/derivatives/e2ee/jcs.js.map +1 -0
- package/dist/derivatives/e2ee/phala.d.ts +62 -0
- package/dist/derivatives/e2ee/phala.d.ts.map +1 -0
- package/dist/derivatives/e2ee/phala.js +168 -0
- package/dist/derivatives/e2ee/phala.js.map +1 -0
- package/dist/derivatives/e2ee/suite.d.ts +56 -0
- package/dist/derivatives/e2ee/suite.d.ts.map +1 -0
- package/dist/derivatives/e2ee/suite.js +164 -0
- package/dist/derivatives/e2ee/suite.js.map +1 -0
- package/dist/derivatives/index.d.ts +10 -0
- package/dist/derivatives/index.d.ts.map +1 -0
- package/dist/derivatives/index.js +10 -0
- package/dist/derivatives/index.js.map +1 -0
- package/dist/derivatives/inference.d.ts +151 -0
- package/dist/derivatives/inference.d.ts.map +1 -0
- package/dist/derivatives/inference.js +262 -0
- package/dist/derivatives/inference.js.map +1 -0
- package/dist/derivatives/prompt.d.ts +64 -0
- package/dist/derivatives/prompt.d.ts.map +1 -0
- package/dist/derivatives/prompt.js +193 -0
- package/dist/derivatives/prompt.js.map +1 -0
- package/dist/derivatives/registration.d.ts +54 -0
- package/dist/derivatives/registration.d.ts.map +1 -0
- package/dist/derivatives/registration.js +180 -0
- package/dist/derivatives/registration.js.map +1 -0
- package/dist/derivatives/scheduler.d.ts +84 -0
- package/dist/derivatives/scheduler.d.ts.map +1 -0
- package/dist/derivatives/scheduler.js +257 -0
- package/dist/derivatives/scheduler.js.map +1 -0
- package/dist/derivatives/store.d.ts +14 -0
- package/dist/derivatives/store.d.ts.map +1 -0
- package/dist/derivatives/store.js +77 -0
- package/dist/derivatives/store.js.map +1 -0
- package/dist/derivatives/types.d.ts +92 -0
- package/dist/derivatives/types.d.ts.map +1 -0
- package/dist/derivatives/types.js +27 -0
- package/dist/derivatives/types.js.map +1 -0
- package/dist/errors/catalog.d.ts +75 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/catalog.js +104 -0
- package/dist/errors/catalog.js.map +1 -1
- package/dist/grants/index.d.ts +2 -1
- package/dist/grants/index.d.ts.map +1 -1
- package/dist/grants/index.js +1 -1
- package/dist/grants/index.js.map +1 -1
- package/dist/keys/index.d.ts +1 -0
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +1 -1
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/public-only-account.d.ts +8 -0
- package/dist/keys/public-only-account.d.ts.map +1 -0
- package/dist/keys/public-only-account.js +21 -0
- package/dist/keys/public-only-account.js.map +1 -0
- package/dist/keys/server-account.d.ts +2 -2
- package/dist/keys/server-account.d.ts.map +1 -1
- package/dist/lineage/attestation.d.ts +42 -0
- package/dist/lineage/attestation.d.ts.map +1 -0
- package/dist/lineage/attestation.js +25 -0
- package/dist/lineage/attestation.js.map +1 -0
- package/dist/lineage/gateway.d.ts +105 -0
- package/dist/lineage/gateway.d.ts.map +1 -0
- package/dist/lineage/gateway.js +242 -0
- package/dist/lineage/gateway.js.map +1 -0
- package/dist/lineage/index.d.ts +5 -0
- package/dist/lineage/index.d.ts.map +1 -0
- package/dist/lineage/index.js +5 -0
- package/dist/lineage/index.js.map +1 -0
- package/dist/lineage/lineage.d.ts +141 -0
- package/dist/lineage/lineage.d.ts.map +1 -0
- package/dist/lineage/lineage.js +255 -0
- package/dist/lineage/lineage.js.map +1 -0
- package/dist/logging/access-log.d.ts +10 -1
- package/dist/logging/access-log.d.ts.map +1 -1
- package/dist/mcp/activity.d.ts.map +1 -1
- package/dist/mcp/activity.js.map +1 -1
- package/dist/mcp/connection-api.d.ts.map +1 -1
- package/dist/mcp/connection-api.js +0 -1
- package/dist/mcp/connection-api.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/read-client.d.ts +61 -1
- package/dist/mcp/read-client.d.ts.map +1 -1
- package/dist/mcp/read-client.js +397 -42
- package/dist/mcp/read-client.js.map +1 -1
- package/dist/mcp/resources.d.ts +37 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +114 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/search/index.d.ts.map +1 -1
- package/dist/mcp/search/index.js +108 -21
- package/dist/mcp/search/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +27 -9
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session.d.ts +160 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +243 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +29 -3
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +515 -48
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/payment/index.d.ts +2 -0
- package/dist/payment/index.d.ts.map +1 -0
- package/dist/payment/index.js +2 -0
- package/dist/payment/index.js.map +1 -0
- package/dist/payment/x402.d.ts +155 -0
- package/dist/payment/x402.d.ts.map +1 -0
- package/dist/payment/x402.js +402 -0
- package/dist/payment/x402.js.map +1 -0
- package/dist/policy/data-read.d.ts +18 -2
- package/dist/policy/data-read.d.ts.map +1 -1
- package/dist/policy/data-read.js +80 -49
- package/dist/policy/data-read.js.map +1 -1
- package/dist/policy/data-write.d.ts +69 -0
- package/dist/policy/data-write.d.ts.map +1 -0
- package/dist/policy/data-write.js +131 -0
- package/dist/policy/data-write.js.map +1 -0
- package/dist/policy/index.d.ts +3 -1
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +3 -1
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/signed-artifacts.d.ts +17 -0
- package/dist/policy/signed-artifacts.d.ts.map +1 -0
- package/dist/policy/signed-artifacts.js +110 -0
- package/dist/policy/signed-artifacts.js.map +1 -0
- package/dist/ports/index.d.ts +159 -32
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js +6 -5
- package/dist/ports/index.js.map +1 -1
- package/dist/schemas/server-config.d.ts +49 -4
- package/dist/schemas/server-config.d.ts.map +1 -1
- package/dist/schemas/server-config.js +95 -13
- package/dist/schemas/server-config.js.map +1 -1
- package/dist/signing/index.d.ts +2 -2
- package/dist/signing/index.d.ts.map +1 -1
- package/dist/signing/index.js +1 -1
- package/dist/signing/index.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/signing/signer.d.ts +27 -25
- package/dist/signing/signer.d.ts.map +1 -1
- package/dist/signing/signer.js +27 -51
- package/dist/signing/signer.js.map +1 -1
- package/dist/storage/adapters/index.d.ts +1 -1
- package/dist/storage/adapters/index.d.ts.map +1 -1
- package/dist/storage/adapters/index.js +1 -1
- package/dist/storage/adapters/index.js.map +1 -1
- package/dist/storage/adapters/interface.d.ts +10 -0
- package/dist/storage/adapters/interface.d.ts.map +1 -1
- package/dist/storage/adapters/sdk.d.ts +11 -1
- package/dist/storage/adapters/sdk.d.ts.map +1 -1
- package/dist/storage/adapters/sdk.js +38 -3
- package/dist/storage/adapters/sdk.js.map +1 -1
- package/dist/storage/adapters/vana.d.ts +3 -0
- package/dist/storage/adapters/vana.d.ts.map +1 -1
- package/dist/storage/adapters/vana.js +95 -2
- package/dist/storage/adapters/vana.js.map +1 -1
- package/dist/storage/blocks/errors.d.ts.map +1 -1
- package/dist/storage/blocks/errors.js.map +1 -1
- package/dist/storage/blocks/index.d.ts +2 -0
- package/dist/storage/blocks/index.d.ts.map +1 -1
- package/dist/storage/blocks/index.js +2 -0
- package/dist/storage/blocks/index.js.map +1 -1
- package/dist/storage/blocks/select.d.ts +29 -0
- package/dist/storage/blocks/select.d.ts.map +1 -0
- package/dist/storage/blocks/select.js +120 -0
- package/dist/storage/blocks/select.js.map +1 -0
- package/dist/storage/blocks/types.d.ts +7 -0
- package/dist/storage/blocks/types.d.ts.map +1 -1
- package/dist/storage/index/manager.d.ts +30 -2
- 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 +6 -1
- package/dist/storage/index/types.d.ts.map +1 -1
- package/dist/sync/data-point-feed.d.ts +35 -0
- package/dist/sync/data-point-feed.d.ts.map +1 -0
- package/dist/sync/data-point-feed.js +122 -0
- package/dist/sync/data-point-feed.js.map +1 -0
- package/dist/sync/data-point-id.d.ts +7 -0
- package/dist/sync/data-point-id.d.ts.map +1 -0
- package/dist/sync/data-point-id.js +16 -0
- package/dist/sync/data-point-id.js.map +1 -0
- package/dist/sync/delete-data-port.d.ts +50 -0
- package/dist/sync/delete-data-port.d.ts.map +1 -0
- package/dist/sync/delete-data-port.js +244 -0
- package/dist/sync/delete-data-port.js.map +1 -0
- package/dist/sync/engine/sync-manager.d.ts +16 -4
- package/dist/sync/engine/sync-manager.d.ts.map +1 -1
- package/dist/sync/engine/sync-manager.js +93 -32
- package/dist/sync/engine/sync-manager.js.map +1 -1
- package/dist/sync/index.d.ts +7 -0
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +7 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/issues.d.ts.map +1 -1
- package/dist/sync/issues.js +21 -3
- package/dist/sync/issues.js.map +1 -1
- package/dist/sync/pending-blob-deletions.d.ts +29 -0
- package/dist/sync/pending-blob-deletions.d.ts.map +1 -0
- package/dist/sync/pending-blob-deletions.js +116 -0
- package/dist/sync/pending-blob-deletions.js.map +1 -0
- package/dist/sync/retry-memory.d.ts +33 -0
- package/dist/sync/retry-memory.d.ts.map +1 -0
- package/dist/sync/retry-memory.js +68 -0
- package/dist/sync/retry-memory.js.map +1 -0
- package/dist/sync/scope-deletions.d.ts +155 -0
- package/dist/sync/scope-deletions.d.ts.map +1 -0
- package/dist/sync/scope-deletions.js +225 -0
- package/dist/sync/scope-deletions.js.map +1 -0
- package/dist/sync/tombstone.d.ts +27 -0
- package/dist/sync/tombstone.d.ts.map +1 -0
- package/dist/sync/tombstone.js +28 -0
- package/dist/sync/tombstone.js.map +1 -0
- package/dist/sync/workers/delete.d.ts +152 -31
- package/dist/sync/workers/delete.d.ts.map +1 -1
- package/dist/sync/workers/delete.js +457 -55
- package/dist/sync/workers/delete.js.map +1 -1
- package/dist/sync/workers/download.d.ts +108 -27
- package/dist/sync/workers/download.d.ts.map +1 -1
- package/dist/sync/workers/download.js +321 -126
- package/dist/sync/workers/download.js.map +1 -1
- package/dist/sync/workers/upload.d.ts +65 -10
- package/dist/sync/workers/upload.d.ts.map +1 -1
- package/dist/sync/workers/upload.js +371 -42
- package/dist/sync/workers/upload.js.map +1 -1
- package/dist/test-utils/e2ee-fixtures.d.ts +94 -0
- package/dist/test-utils/e2ee-fixtures.d.ts.map +1 -0
- package/dist/test-utils/e2ee-fixtures.js +116 -0
- package/dist/test-utils/e2ee-fixtures.js.map +1 -0
- package/dist/test-utils/e2ee-gateway.d.ts +61 -0
- package/dist/test-utils/e2ee-gateway.d.ts.map +1 -0
- package/dist/test-utils/e2ee-gateway.js +248 -0
- package/dist/test-utils/e2ee-gateway.js.map +1 -0
- package/dist/test-utils/index.d.ts +3 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +3 -0
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/memory-storage.d.ts +12 -0
- package/dist/test-utils/memory-storage.d.ts.map +1 -0
- package/dist/test-utils/memory-storage.js +146 -0
- package/dist/test-utils/memory-storage.js.map +1 -0
- package/dist/test-utils/wallet.d.ts +6 -0
- package/dist/test-utils/wallet.d.ts.map +1 -1
- package/dist/test-utils/wallet.js +46 -0
- package/dist/test-utils/wallet.js.map +1 -1
- package/dist/write/attribution.d.ts +185 -0
- package/dist/write/attribution.d.ts.map +1 -0
- package/dist/write/attribution.js +450 -0
- package/dist/write/attribution.js.map +1 -0
- package/dist/write/authorize.d.ts +77 -0
- package/dist/write/authorize.d.ts.map +1 -0
- package/dist/write/authorize.js +109 -0
- package/dist/write/authorize.js.map +1 -0
- package/dist/write/index.d.ts +5 -0
- package/dist/write/index.d.ts.map +1 -0
- package/dist/write/index.js +5 -0
- package/dist/write/index.js.map +1 -0
- package/dist/write/route.d.ts +61 -0
- package/dist/write/route.d.ts.map +1 -0
- package/dist/write/route.js +132 -0
- package/dist/write/route.js.map +1 -0
- package/dist/write/session.d.ts +96 -0
- package/dist/write/session.d.ts.map +1 -0
- package/dist/write/session.js +136 -0
- package/dist/write/session.js.map +1 -0
- package/package.json +19 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,MAAM,CACJ,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvC;AACD,MAAM,MAAM,yBAAyB,GAAG,MAAM,kBAAkB,CAAC;AAEjE,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,kBAAkB,GAAG,yBAAyB,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,MAAM,CACJ,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvC;AACD,MAAM,MAAM,yBAAyB,GAAG,MAAM,kBAAkB,CAAC;AAEjE,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC;AAED,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,kBAAkB,GAAG,yBAAyB,EACjE,OAAO,CAAC,EAAE,wBAAwB,GACjC,cAAc,CAmDhB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export function createSdkStorageAdapter(providerOrFactory) {
|
|
1
|
+
export function createSdkStorageAdapter(providerOrFactory, options) {
|
|
2
2
|
let cachedProvider;
|
|
3
|
+
const urlForKey = options?.urlForKey ?? ((key) => key);
|
|
3
4
|
function provider() {
|
|
4
5
|
if (typeof providerOrFactory === "function") {
|
|
5
6
|
cachedProvider ??= providerOrFactory();
|
|
@@ -12,6 +13,7 @@ export function createSdkStorageAdapter(providerOrFactory) {
|
|
|
12
13
|
const result = await provider().upload(new Blob([copyBytes(data)], { type: "application/octet-stream" }), key);
|
|
13
14
|
return result.url;
|
|
14
15
|
},
|
|
16
|
+
urlForKey,
|
|
15
17
|
async download(storageUrl) {
|
|
16
18
|
const blob = await provider().download(storageUrl);
|
|
17
19
|
return new Uint8Array(await blob.arrayBuffer());
|
|
@@ -20,16 +22,49 @@ export function createSdkStorageAdapter(providerOrFactory) {
|
|
|
20
22
|
return provider().delete(storageUrl);
|
|
21
23
|
},
|
|
22
24
|
async exists(storageUrl) {
|
|
25
|
+
// The SDK provider interface has no HEAD/metadata call, so existence is
|
|
26
|
+
// probed with a full download (follow-up: add a HEAD to the vana
|
|
27
|
+
// provider). Only a definitive not-found may report "absent" — a
|
|
28
|
+
// transient error (network, 5xx, auth blip) must throw instead, so the
|
|
29
|
+
// caller retries next cycle rather than acting on a false "missing"
|
|
30
|
+
// (e.g. the upload worker's blob heal overwriting a blob that is
|
|
31
|
+
// actually there).
|
|
23
32
|
try {
|
|
24
33
|
await provider().download(storageUrl);
|
|
25
34
|
return true;
|
|
26
35
|
}
|
|
27
|
-
catch {
|
|
28
|
-
|
|
36
|
+
catch (err) {
|
|
37
|
+
if (isDefinitiveNotFound(err)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
throw err;
|
|
29
41
|
}
|
|
30
42
|
},
|
|
31
43
|
};
|
|
32
44
|
}
|
|
45
|
+
// Prefer a numeric status property when the error carries one; today the
|
|
46
|
+
// SDK's StorageError does NOT (the HTTP status lives only in its message —
|
|
47
|
+
// "vana-storage download failed: 404 Not Found"), so fall back to that
|
|
48
|
+
// stable message shape (also matches R2's "R2 download failed: 404 ...").
|
|
49
|
+
// Providers with other message shapes (ipfs, pinata, dropbox) match
|
|
50
|
+
// neither and so surface as errors — safe, never a false "missing". When
|
|
51
|
+
// vana-sdk grows a status field on StorageError, the property check takes
|
|
52
|
+
// over and the regex becomes dead fallback.
|
|
53
|
+
function isDefinitiveNotFound(err) {
|
|
54
|
+
const status = numericProperty(err, "status") ?? numericProperty(err, "statusCode");
|
|
55
|
+
if (status !== undefined) {
|
|
56
|
+
return status === 404 || status === 410;
|
|
57
|
+
}
|
|
58
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
59
|
+
return /download failed: (404|410)\b/.test(message);
|
|
60
|
+
}
|
|
61
|
+
function numericProperty(value, key) {
|
|
62
|
+
if (typeof value !== "object" || value === null || !(key in value)) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const property = value[key];
|
|
66
|
+
return typeof property === "number" ? property : undefined;
|
|
67
|
+
}
|
|
33
68
|
function copyBytes(data) {
|
|
34
69
|
const copy = new Uint8Array(data.byteLength);
|
|
35
70
|
copy.set(data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/storage/adapters/sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/storage/adapters/sdk.ts"],"names":[],"mappings":"AAuBA,MAAM,UAAU,uBAAuB,CACrC,iBAAiE,EACjE,OAAkC;IAElC,IAAI,cAA8C,CAAC;IACnD,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;IAE/D,SAAS,QAAQ;QACf,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE,CAAC;YAC5C,cAAc,KAAK,iBAAiB,EAAE,CAAC;YACvC,OAAO,cAAc,CAAC;QACxB,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI;YACpB,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC,MAAM,CACpC,IAAI,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAA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,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,8BAA8B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,GAAW;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC;QACnE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,QAAQ,GAAI,KAAiC,CAAC,GAAG,CAAC,CAAC;IACzD,OAAO,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC;AAED,SAAS,SAAS,CAAC,IAAgB;IACjC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACf,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ServerConfig } from "../../schemas/server-config.js";
|
|
2
2
|
import type { ServerAccount } from "../../keys/server-account.js";
|
|
3
3
|
import type { StorageAdapter } from "./interface.js";
|
|
4
|
+
/** Storage base URL the sync adapter targets (config override or SDK default). */
|
|
5
|
+
export declare function resolveVanaStorageEndpoint(config: ServerConfig): string;
|
|
4
6
|
export declare function createVanaSyncStorageAdapter(params: {
|
|
5
7
|
config: ServerConfig;
|
|
6
8
|
serverOwner: `0x${string}`;
|
|
7
9
|
serverAccount: ServerAccount;
|
|
10
|
+
reads?: "signed" | "public";
|
|
8
11
|
}): StorageAdapter;
|
|
9
12
|
//# sourceMappingURL=vana.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vana.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/vana.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vana.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/vana.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAarD,kFAAkF;AAClF,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAIvE;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE;IACnD,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC7B,GAAG,cAAc,CAgDjB"}
|
|
@@ -1,13 +1,106 @@
|
|
|
1
1
|
import { createVanaStorageProvider } from "@opendatalabs/vana-sdk/browser";
|
|
2
|
+
import { StorageError } from "@opendatalabs/vana-sdk/storage/index";
|
|
3
|
+
import { ServerSigningUnavailableError } from "../../errors/catalog.js";
|
|
2
4
|
import { createSdkStorageAdapter } from "./sdk.js";
|
|
5
|
+
// Default endpoint baked into the SDK's vana-storage provider; mirrored here
|
|
6
|
+
// so urlForKey resolves to the same host the provider uploads to when no
|
|
7
|
+
// explicit apiUrl is configured.
|
|
8
|
+
const DEFAULT_VANA_STORAGE_ENDPOINT = "https://storage.vana.org";
|
|
9
|
+
const GET_METHOD = "GET";
|
|
10
|
+
const PUBLIC_READS = "public";
|
|
11
|
+
const DOWNLOAD_ERROR = "DOWNLOAD_ERROR";
|
|
12
|
+
const DOWNLOAD_FAILED = "DOWNLOAD_FAILED";
|
|
13
|
+
const VANA_STORAGE = "vana-storage";
|
|
14
|
+
/** Storage base URL the sync adapter targets (config override or SDK default). */
|
|
15
|
+
export function resolveVanaStorageEndpoint(config) {
|
|
16
|
+
return (config.storage.config.vana?.apiUrl ?? DEFAULT_VANA_STORAGE_ENDPOINT).replace(/\/+$/, "");
|
|
17
|
+
}
|
|
3
18
|
export function createVanaSyncStorageAdapter(params) {
|
|
19
|
+
const endpoint = resolveVanaStorageEndpoint(params.config);
|
|
20
|
+
// The SDK's vana-storage provider lowercases the owner before building the
|
|
21
|
+
// blob path (and its URL validator compares against the lowercased form),
|
|
22
|
+
// so urlForKey MUST lowercase too or the reconstructed download URL won't
|
|
23
|
+
// match the uploaded blob's key.
|
|
24
|
+
// serverOwner is already a 0x-hex address; lowercasing preserves that, but
|
|
25
|
+
// .toLowerCase() widens to string. vana-sdk 3.14.0 types the provider's
|
|
26
|
+
// ownerAddress as `0x${string}`, so re-narrow to the known-hex form.
|
|
27
|
+
const owner = params.serverOwner.toLowerCase();
|
|
28
|
+
// Storage blob paths are scoped by the protocol chain id so data for the same
|
|
29
|
+
// owner/scope/version never collides across networks. The chain id is the
|
|
30
|
+
// gateway's — it is never inferred from the storage host (apiUrl), which
|
|
31
|
+
// selects the product host independently.
|
|
32
|
+
const chainId = params.config.gateway.chainId;
|
|
33
|
+
// enclave sandbox --> public blob GET ----------> vana-storage
|
|
34
|
+
// desktop/cloud ---> signed PUT / GET / DELETE -> vana-storage
|
|
35
|
+
if (params.reads === PUBLIC_READS) {
|
|
36
|
+
// TODO(decision): blob reads stay public (architecture, resolved 2026-09-02); revisit if storage adds read auth.
|
|
37
|
+
return createPublicReadAdapter({ endpoint, chainId, owner });
|
|
38
|
+
}
|
|
4
39
|
return createSdkStorageAdapter(createVanaStorageProvider({
|
|
5
40
|
endpoint: params.config.storage.config.vana?.apiUrl,
|
|
6
|
-
|
|
41
|
+
chainId,
|
|
42
|
+
ownerAddress: owner,
|
|
7
43
|
signer: {
|
|
8
44
|
address: params.serverAccount.address,
|
|
9
45
|
signMessage: (message) => params.serverAccount.signMessage(message),
|
|
10
46
|
},
|
|
11
|
-
})
|
|
47
|
+
}), {
|
|
48
|
+
// Mirror the provider's keying: PUT/GET target
|
|
49
|
+
// `${endpoint}/v1/chains/${chainId}/blobs/${owner}/${encodeURIComponent-per-segment(key)}`.
|
|
50
|
+
// The download worker hands us `{scope}/{version}` and we rebuild the
|
|
51
|
+
// exact URL the provider's pathFromUrl() validator accepts.
|
|
52
|
+
urlForKey: (key) => {
|
|
53
|
+
const subpath = key
|
|
54
|
+
.split("/")
|
|
55
|
+
.map((segment) => encodeURIComponent(segment))
|
|
56
|
+
.join("/");
|
|
57
|
+
return `${endpoint}/v1/chains/${chainId}/blobs/${owner}/${subpath}`;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function createPublicReadAdapter(options) {
|
|
62
|
+
const blobPrefix = `${options.endpoint}/v1/chains/${options.chainId}/blobs/${options.owner}/`;
|
|
63
|
+
function invalidBlobUrl() {
|
|
64
|
+
return new StorageError("Public blob URL does not match the configured storage namespace", DOWNLOAD_FAILED, VANA_STORAGE);
|
|
65
|
+
}
|
|
66
|
+
return createSdkStorageAdapter({
|
|
67
|
+
async upload() {
|
|
68
|
+
throw new ServerSigningUnavailableError();
|
|
69
|
+
},
|
|
70
|
+
async download(storageUrl) {
|
|
71
|
+
let requestUrl;
|
|
72
|
+
try {
|
|
73
|
+
requestUrl = new URL(storageUrl).href;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
throw invalidBlobUrl();
|
|
77
|
+
}
|
|
78
|
+
if (!requestUrl.startsWith(blobPrefix)) {
|
|
79
|
+
throw invalidBlobUrl();
|
|
80
|
+
}
|
|
81
|
+
let response;
|
|
82
|
+
try {
|
|
83
|
+
response = await fetch(requestUrl, { method: GET_METHOD });
|
|
84
|
+
}
|
|
85
|
+
catch (cause) {
|
|
86
|
+
throw new StorageError("vana-storage public download network error", DOWNLOAD_ERROR, VANA_STORAGE, { cause: cause instanceof Error ? cause : undefined });
|
|
87
|
+
}
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
throw new StorageError(`vana-storage download failed: ${response.status} ${response.statusText}`, DOWNLOAD_FAILED, VANA_STORAGE);
|
|
90
|
+
}
|
|
91
|
+
return response.blob();
|
|
92
|
+
},
|
|
93
|
+
async delete() {
|
|
94
|
+
throw new ServerSigningUnavailableError();
|
|
95
|
+
},
|
|
96
|
+
}, {
|
|
97
|
+
urlForKey(key) {
|
|
98
|
+
const subpath = key
|
|
99
|
+
.split("/")
|
|
100
|
+
.map((segment) => encodeURIComponent(segment))
|
|
101
|
+
.join("/");
|
|
102
|
+
return `${blobPrefix}${subpath}`;
|
|
103
|
+
},
|
|
104
|
+
});
|
|
12
105
|
}
|
|
13
106
|
//# sourceMappingURL=vana.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vana.js","sourceRoot":"","sources":["../../../src/storage/adapters/vana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"vana.js","sourceRoot":"","sources":["../../../src/storage/adapters/vana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAIxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD,6EAA6E;AAC7E,yEAAyE;AACzE,iCAAiC;AACjC,MAAM,6BAA6B,GAAG,0BAA0B,CAAC;AACjE,MAAM,UAAU,GAAG,KAAK,CAAC;AACzB,MAAM,YAAY,GAAG,QAAQ,CAAC;AAC9B,MAAM,cAAc,GAAG,gBAAgB,CAAC;AACxC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAC1C,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,kFAAkF;AAClF,MAAM,UAAU,0BAA0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Y,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,CACtD,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,YAAY,CACpB,iCAAiC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,EACzE,eAAe,EACf,YAAY,CACb,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;QAED,KAAK,CAAC,MAAM;YACV,MAAM,IAAI,6BAA6B,EAAE,CAAC;QAC5C,CAAC;KACF,EACD;QACE,SAAS,CAAC,GAAG;YACX,MAAM,OAAO,GAAG,GAAG;iBAChB,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;iBAC7C,IAAI,CAAC,GAAG,CAAC,CAAC;YACb,OAAO,GAAG,UAAU,GAAG,OAAO,EAAE,CAAC;QACnC,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/storage/blocks/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/storage/blocks/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GACnC,0BAA0B,GAAG,yBAAyB,GAAG,gBAAgB,CAAC;AAE5E,qBAAa,qBAAsB,SAAQ,KAAK;aAE5B,IAAI,EAAE,yBAAyB;gBAA/B,IAAI,EAAE,yBAAyB,EAC/C,OAAO,EAAE,MAAM;CAKlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/storage/blocks/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/storage/blocks/errors.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAE5B;IADlB,YACkB,IAA+B,EAC/C,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAA2B;QAI/C,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { ContentKind, DataBlockManifest, DataBlockRef, DataBlockWarning, DataScopeBlock, ReadScopeBlocksRequest, ReadScopeBlocksResponse, } from "./types.js";
|
|
2
2
|
export { decodeDataBlockCursor, encodeDataBlockCursor, validateDataBlockCursor, type DataBlockCursor, type DataBlockCursorError, type DataBlockCursorErrorCode, type DecodeDataBlockCursorResult, type EncodeDataBlockCursorInput, type ValidateDataBlockCursorResult, } from "./cursor.js";
|
|
3
|
+
export { buildDataBlocksAsync } from "./build.js";
|
|
4
|
+
export { MAX_SELECTED_BLOCK_IDS, selectScopeBlocksByIds, type SelectScopeBlocksResult, } from "./select.js";
|
|
3
5
|
export { DataBlockStorageError, type DataBlockStorageErrorCode, } from "./errors.js";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/blocks/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,GACnC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,qBAAqB,EACrB,KAAK,yBAAyB,GAC/B,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/blocks/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,GACnC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,qBAAqB,EACrB,KAAK,yBAAyB,GAC/B,MAAM,aAAa,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { decodeDataBlockCursor, encodeDataBlockCursor, validateDataBlockCursor, } from "./cursor.js";
|
|
2
|
+
export { buildDataBlocksAsync } from "./build.js";
|
|
3
|
+
export { MAX_SELECTED_BLOCK_IDS, selectScopeBlocksByIds, } from "./select.js";
|
|
2
4
|
export { DataBlockStorageError, } from "./errors.js";
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/blocks/index.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,GAOxB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,qBAAqB,GAEtB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/blocks/index.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,GAOxB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GAEvB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,qBAAqB,GAEtB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block-addressed selection: read exactly the blocks a caller names.
|
|
3
|
+
*
|
|
4
|
+
* Search returns a `blockRef` per hit and the manifest is a table of contents,
|
|
5
|
+
* but without this path a client still has to walk `nextCursor` from the start
|
|
6
|
+
* of the scope to reach a block it already knows the id of. Every storage
|
|
7
|
+
* implementation pages the manifest identically, so the selection loop lives
|
|
8
|
+
* here instead of being copied into each of them.
|
|
9
|
+
*/
|
|
10
|
+
import type { DataBlockManifest, DataBlockWarning, DataScopeBlock } from "./types.js";
|
|
11
|
+
/** Upper bound on block ids honoured in a single block-addressed read. */
|
|
12
|
+
export declare const MAX_SELECTED_BLOCK_IDS = 50;
|
|
13
|
+
export interface SelectScopeBlocksResult {
|
|
14
|
+
blocks: DataScopeBlock[];
|
|
15
|
+
warnings: DataBlockWarning[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Return the requested blocks in the order they were asked for, bounded by
|
|
19
|
+
* `maxBytes`. Ids that are not in the manifest, ids dropped by the id cap, and
|
|
20
|
+
* ids left out because the byte budget ran out are reported as warnings rather
|
|
21
|
+
* than errors — a partially answered selection is still useful.
|
|
22
|
+
*
|
|
23
|
+
* No cursor is produced: the selection order is the caller's, not the
|
|
24
|
+
* manifest's, so a manifest-index cursor could not resume it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function selectScopeBlocksByIds(manifest: DataBlockManifest, blockIds: readonly string[], options: {
|
|
27
|
+
maxBytes: number;
|
|
28
|
+
}, loadBlock: (blockId: string) => Promise<DataScopeBlock | null>): Promise<SelectScopeBlocksResult>;
|
|
29
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/storage/blocks/select.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,0EAA0E;AAC1E,eAAO,MAAM,sBAAsB,KAAK,CAAC;AASzC,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC7B,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,GAC7D,OAAO,CAAC,uBAAuB,CAAC,CAsElC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block-addressed selection: read exactly the blocks a caller names.
|
|
3
|
+
*
|
|
4
|
+
* Search returns a `blockRef` per hit and the manifest is a table of contents,
|
|
5
|
+
* but without this path a client still has to walk `nextCursor` from the start
|
|
6
|
+
* of the scope to reach a block it already knows the id of. Every storage
|
|
7
|
+
* implementation pages the manifest identically, so the selection loop lives
|
|
8
|
+
* here instead of being copied into each of them.
|
|
9
|
+
*/
|
|
10
|
+
/** Upper bound on block ids honoured in a single block-addressed read. */
|
|
11
|
+
export const MAX_SELECTED_BLOCK_IDS = 50;
|
|
12
|
+
/** Ids listed inline in a warning message before it is summarized by count. */
|
|
13
|
+
const WARNING_ID_SAMPLE = 10;
|
|
14
|
+
const TEXT_PAGE_MEDIA_TYPE = "text/plain; charset=utf-8";
|
|
15
|
+
const textEncoder = new TextEncoder();
|
|
16
|
+
const textDecoder = new TextDecoder();
|
|
17
|
+
/**
|
|
18
|
+
* Return the requested blocks in the order they were asked for, bounded by
|
|
19
|
+
* `maxBytes`. Ids that are not in the manifest, ids dropped by the id cap, and
|
|
20
|
+
* ids left out because the byte budget ran out are reported as warnings rather
|
|
21
|
+
* than errors — a partially answered selection is still useful.
|
|
22
|
+
*
|
|
23
|
+
* No cursor is produced: the selection order is the caller's, not the
|
|
24
|
+
* manifest's, so a manifest-index cursor could not resume it.
|
|
25
|
+
*/
|
|
26
|
+
export async function selectScopeBlocksByIds(manifest, blockIds, options, loadBlock) {
|
|
27
|
+
const maxBytes = Math.max(1, options.maxBytes);
|
|
28
|
+
const refById = new Map(manifest.blocks.map((ref) => [ref.id, ref]));
|
|
29
|
+
const requested = [];
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
let cappedIds = 0;
|
|
32
|
+
for (const blockId of blockIds) {
|
|
33
|
+
if (typeof blockId !== "string" || !blockId || seen.has(blockId))
|
|
34
|
+
continue;
|
|
35
|
+
seen.add(blockId);
|
|
36
|
+
if (requested.length >= MAX_SELECTED_BLOCK_IDS) {
|
|
37
|
+
cappedIds += 1;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
requested.push(blockId);
|
|
41
|
+
}
|
|
42
|
+
const blocks = [];
|
|
43
|
+
const missingIds = [];
|
|
44
|
+
const skippedIds = [];
|
|
45
|
+
const warnings = [];
|
|
46
|
+
let bytes = 0;
|
|
47
|
+
for (let index = 0; index < requested.length; index += 1) {
|
|
48
|
+
const blockId = requested[index];
|
|
49
|
+
const ref = refById.get(blockId);
|
|
50
|
+
if (!ref) {
|
|
51
|
+
missingIds.push(blockId);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
// Mirrors the cursor path: a block that does not fit whole is only sliced
|
|
55
|
+
// when it is the first one in the page, so a caller always makes progress.
|
|
56
|
+
if (blocks.length > 0 && bytes + ref.sizeBytes > maxBytes) {
|
|
57
|
+
skippedIds.push(...requested.slice(index));
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
const block = await loadBlock(blockId);
|
|
61
|
+
if (!block) {
|
|
62
|
+
missingIds.push(blockId);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const page = pageBlock(block, maxBytes - bytes);
|
|
66
|
+
blocks.push(page.block);
|
|
67
|
+
bytes += page.block.sizeBytes;
|
|
68
|
+
if (page.truncated) {
|
|
69
|
+
skippedIds.push(...requested.slice(index + 1));
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (cappedIds > 0) {
|
|
74
|
+
warnings.push({
|
|
75
|
+
code: "block_selection_capped",
|
|
76
|
+
message: `${cappedIds} block ids beyond the ${MAX_SELECTED_BLOCK_IDS} id limit were ignored`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (missingIds.length > 0) {
|
|
80
|
+
warnings.push({
|
|
81
|
+
code: "block_not_found",
|
|
82
|
+
message: `${missingIds.length} requested block ids are not in this scope: ${summarizeIds(missingIds)}`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (skippedIds.length > 0) {
|
|
86
|
+
warnings.push({
|
|
87
|
+
code: "block_selection_truncated",
|
|
88
|
+
message: `maxBytes reached; ${skippedIds.length} requested blocks were not returned: ${summarizeIds(skippedIds)}. Request them in a follow-up read.`,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return { blocks, warnings };
|
|
92
|
+
}
|
|
93
|
+
function summarizeIds(ids) {
|
|
94
|
+
const sample = ids.slice(0, WARNING_ID_SAMPLE).join(", ");
|
|
95
|
+
return ids.length > WARNING_ID_SAMPLE
|
|
96
|
+
? `${sample}, ...(${ids.length - WARNING_ID_SAMPLE} more)`
|
|
97
|
+
: sample;
|
|
98
|
+
}
|
|
99
|
+
function pageBlock(block, maxBytes) {
|
|
100
|
+
const text = typeof block.value === "string" ? block.value : JSON.stringify(block.value);
|
|
101
|
+
const bytes = textEncoder.encode(text);
|
|
102
|
+
if (bytes.length <= maxBytes) {
|
|
103
|
+
return { block, truncated: false };
|
|
104
|
+
}
|
|
105
|
+
const end = Math.max(1, maxBytes);
|
|
106
|
+
return {
|
|
107
|
+
block: {
|
|
108
|
+
...block,
|
|
109
|
+
path: `${block.path}[bytes 0:${end}]`,
|
|
110
|
+
mediaType: block.mediaType.startsWith("text/")
|
|
111
|
+
? block.mediaType
|
|
112
|
+
: TEXT_PAGE_MEDIA_TYPE,
|
|
113
|
+
value: textDecoder.decode(bytes.slice(0, end)),
|
|
114
|
+
sizeBytes: end,
|
|
115
|
+
truncated: true,
|
|
116
|
+
},
|
|
117
|
+
truncated: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/storage/blocks/select.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,+EAA+E;AAC/E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AACzD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAOtC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,QAA2B,EAC3B,QAA2B,EAC3B,OAA6B,EAC7B,SAA8D;IAE9D,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,GAA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,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YAC9C,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,IAAI;SAChB;QACD,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -28,6 +28,13 @@ export interface ReadScopeBlocksRequest {
|
|
|
28
28
|
collectedAt?: string;
|
|
29
29
|
cursor?: string;
|
|
30
30
|
maxBytes?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Read only these blocks, in this order, instead of paging the scope from
|
|
33
|
+
* `cursor`. Ids come from a manifest listing or from a search hit's
|
|
34
|
+
* `blockRef`. When set, `cursor` is ignored and no `nextCursor` is returned;
|
|
35
|
+
* `maxBytes` still bounds the response.
|
|
36
|
+
*/
|
|
37
|
+
blockIds?: string[];
|
|
31
38
|
}
|
|
32
39
|
export interface ReadScopeBlocksResponse {
|
|
33
40
|
scope: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/storage/blocks/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/storage/blocks/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACrB,eAAe,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEvE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -6,6 +6,12 @@ export interface IndexManager {
|
|
|
6
6
|
findLatestByScope(scope: string): IndexEntry | undefined;
|
|
7
7
|
countByScope(scope: string): number;
|
|
8
8
|
deleteByPath(path: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Delete a row by path ONLY if it is still unsynced (`dataPointId` null).
|
|
11
|
+
* Atomic guard so a row that raced to synced after selection keeps its
|
|
12
|
+
* metadata. Returns true only when an unsynced row was actually removed.
|
|
13
|
+
*/
|
|
14
|
+
deleteUnsyncedByPath(path: string): boolean;
|
|
9
15
|
listDistinctScopes(options?: {
|
|
10
16
|
scopePrefix?: string;
|
|
11
17
|
limit?: number;
|
|
@@ -16,9 +22,12 @@ export interface IndexManager {
|
|
|
16
22
|
};
|
|
17
23
|
findClosestByScope(scope: string, at: string): IndexEntry | undefined;
|
|
18
24
|
findByFileId(fileId: string): IndexEntry | undefined;
|
|
25
|
+
/** Find an index entry by its DPv2 data-point id (download dedup). */
|
|
26
|
+
findByDataPointId(dataPointId: string): IndexEntry | undefined;
|
|
19
27
|
/**
|
|
20
|
-
* Find all index entries where
|
|
21
|
-
* Returns entries ordered by created_at ASC (oldest
|
|
28
|
+
* Find all index entries where dataPointId is null (not yet synced /
|
|
29
|
+
* registered on-chain). Returns entries ordered by created_at ASC (oldest
|
|
30
|
+
* first).
|
|
22
31
|
*/
|
|
23
32
|
findUnsynced(options?: {
|
|
24
33
|
limit?: number;
|
|
@@ -28,6 +37,25 @@ export interface IndexManager {
|
|
|
28
37
|
* @returns true if row was updated, false if path not found
|
|
29
38
|
*/
|
|
30
39
|
updateFileId(path: string, fileId: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the highest stored `version` for a scope, or 0 if none. Used by
|
|
42
|
+
* `insert` to derive the next expectedVersion for DPv2 AddData.
|
|
43
|
+
*/
|
|
44
|
+
findLatestVersionByScope(scope: string): number;
|
|
45
|
+
/**
|
|
46
|
+
* Update the dataPointId for an index entry (after successful DPv2
|
|
47
|
+
* registerDataPoint). Sync-worker step that runs alongside fileId update.
|
|
48
|
+
* @returns true if row was updated, false if path not found
|
|
49
|
+
*/
|
|
50
|
+
updateDataPointId(path: string, dataPointId: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Update the DPv2 `version` for an index entry. Used by the upload worker
|
|
53
|
+
* when a registration is rebased onto the registry's live version after a
|
|
54
|
+
* stale-expectedVersion conflict (the blob key embeds the version, so the
|
|
55
|
+
* local row must follow).
|
|
56
|
+
* @returns true if row was updated, false if path not found
|
|
57
|
+
*/
|
|
58
|
+
updateVersion(path: string, version: number): boolean;
|
|
31
59
|
/** Deletes all index entries for a scope. Returns count of deleted rows. */
|
|
32
60
|
deleteByScope(scope: string): number;
|
|
33
61
|
close(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/storage/index/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAAC;IACzC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACjD,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,UAAU,EAAE,CAAC;IACrD,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACzD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,kBAAkB,CAAC,OAAO,CAAC,EAAE;QAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG;QAAE,MAAM,EAAE,YAAY,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACtE,YAAY,CAAC,MAAM,EAAE,MAAM,G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KAAE,GAAG,UAAU,EAAE,CAAC;IACzD;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACpD;;;OAGG;IACH,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAChD;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9D;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACtD,4EAA4E;IAC5E,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const INDEX_SCHEMA_VERSION =
|
|
1
|
+
export declare const INDEX_SCHEMA_VERSION = 3;
|
|
2
2
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const INDEX_SCHEMA_VERSION =
|
|
1
|
+
export const INDEX_SCHEMA_VERSION = 3;
|
|
2
2
|
//# sourceMappingURL=schema.js.map
|
|
@@ -7,9 +7,14 @@ export interface IndexEntry {
|
|
|
7
7
|
collectedAt: string;
|
|
8
8
|
createdAt: string;
|
|
9
9
|
sizeBytes: number;
|
|
10
|
+
version: number;
|
|
11
|
+
dataPointId: string | null;
|
|
12
|
+
afterTombstoneVersion?: number | null;
|
|
10
13
|
}
|
|
11
|
-
export type NewIndexEntry = Omit<IndexEntry, "id" | "createdAt" | "schemaId"> & {
|
|
14
|
+
export type NewIndexEntry = Omit<IndexEntry, "id" | "createdAt" | "schemaId" | "version" | "dataPointId"> & {
|
|
12
15
|
schemaId?: string | null;
|
|
16
|
+
version?: number;
|
|
17
|
+
dataPointId?: string | null;
|
|
13
18
|
};
|
|
14
19
|
export interface IndexListOptions {
|
|
15
20
|
scope?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/storage/index/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/storage/index/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAIlB,OAAO,EAAE,MAAM,CAAC;IAGhB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAO3B,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,UAAU,EACV,IAAI,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,CAC5D,GAAG;IACF,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAIzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAClC,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DataPointFeedListOptions, DataPointFeedPort } from "../ports/index.js";
|
|
2
|
+
export interface GatewayDataPointFeedOptions {
|
|
3
|
+
/** Gateway base URL, e.g. https://dp-rpc.vana.org */
|
|
4
|
+
gatewayUrl: string;
|
|
5
|
+
/** Test seam; defaults to the global fetch. */
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
/** Test seam for the fallback `deletedAt` when a 410 body carries none. */
|
|
8
|
+
now?: () => Date;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Deletion-aware gateway feed over the same REST endpoints the SDK client
|
|
12
|
+
* uses, plus the `includeDeleted=true` query the SDK does not expose:
|
|
13
|
+
*
|
|
14
|
+
* GET {gateway}/v1/data?user={owner}&includeDeleted=true[&cursor=..][&since=..][&limit=..]
|
|
15
|
+
* GET {gateway}/v1/data/{dataPointId}?includeDeleted=true
|
|
16
|
+
*
|
|
17
|
+
* Rows come back with `deletedAt` (null while live). A gateway that answers
|
|
18
|
+
* the single lookup of a tombstoned point with 410 instead of a row is
|
|
19
|
+
* normalised into a deleted record so callers never have to catch a 410.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createGatewayDataPointFeed(options: GatewayDataPointFeedOptions): DataPointFeedPort;
|
|
22
|
+
/**
|
|
23
|
+
* Adapter from the SDK `GatewayClient` listing to the feed shape. Used when a
|
|
24
|
+
* host wires no dedicated feed: deletions are only visible if the gateway
|
|
25
|
+
* happens to include `deletedAt` without being asked, so this is a
|
|
26
|
+
* degraded mode. Prefer `createGatewayDataPointFeed`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function feedFromGatewayClient(gateway: {
|
|
29
|
+
listDataPointsByOwner(owner: string, cursor: string | null, options?: DataPointFeedListOptions): Promise<{
|
|
30
|
+
dataPoints: unknown[];
|
|
31
|
+
cursor: string | null;
|
|
32
|
+
}>;
|
|
33
|
+
getDataPoint(dataPointId: string): Promise<unknown | null>;
|
|
34
|
+
}): DataPointFeedPort;
|
|
35
|
+
//# sourceMappingURL=data-point-feed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-point-feed.d.ts","sourceRoot":"","sources":["../../src/sync/data-point-feed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EAExB,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,2BAA2B;IAC1C,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,2EAA2E;IAC3E,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,2BAA2B,GACnC,iBAAiB,CAuEnB;AA8BD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,qBAAqB,CACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC;QAAE,UAAU,EAAE,OAAO,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAC7D,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC5D,GAAG,iBAAiB,CAqBpB"}
|