@ariestools/aries-datalake-client 0.1.18 → 0.1.20
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/README.md +51 -0
- package/dist/browser/PayloadsClient.d.ts.map +1 -1
- package/dist/browser/RestPublicPayloadsReader.d.ts +38 -0
- package/dist/browser/RestPublicPayloadsReader.d.ts.map +1 -0
- package/dist/browser/browser.d.ts +2 -0
- package/dist/browser/browser.d.ts.map +1 -1
- package/dist/browser/browser.mjs +101 -18
- package/dist/browser/browser.mjs.map +4 -4
- package/dist/node/PayloadsClient.d.ts.map +1 -1
- package/dist/node/RestPublicPayloadsReader.d.ts +38 -0
- package/dist/node/RestPublicPayloadsReader.d.ts.map +1 -0
- package/dist/node/browser.d.ts +2 -0
- package/dist/node/browser.d.ts.map +1 -1
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.mjs +100 -15
- package/dist/node/index.mjs.map +4 -4
- package/dist/node/payloadRequest.d.ts +11 -0
- package/dist/node/payloadRequest.d.ts.map +1 -0
- package/package.json +18 -14
package/README.md
CHANGED
|
@@ -36,3 +36,54 @@ const payloads = new RestPayloadsClient({
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
The supplier receives the exact control-plane audience or datalake id. Treat its return value as a sensitive, short-lived bearer token: cache it only in page memory when useful, and never persist it in browser storage or logs. The wallet gateway controls key access; the Aries HTTP services independently verify audience, signature, origin, scope, signer identity, and live ACL state.
|
|
39
|
+
|
|
40
|
+
## Explicit public payload reads
|
|
41
|
+
|
|
42
|
+
Use `RestPublicPayloadsReader` when the provider has granted public viewer access
|
|
43
|
+
to the datalake. This is separate from the authenticated clients above; an
|
|
44
|
+
authentication failure never triggers an anonymous retry.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { RestPublicPayloadsReader } from '@ariestools/aries-datalake-client/browser'
|
|
48
|
+
|
|
49
|
+
const reader = new RestPublicPayloadsReader({
|
|
50
|
+
baseUrl: 'https://data.example/plane/v1/datalakes/dl_public',
|
|
51
|
+
datalakeId: 'dl_public',
|
|
52
|
+
})
|
|
53
|
+
const controller = new AbortController()
|
|
54
|
+
const payload = await reader.get('configured-content-hash', {
|
|
55
|
+
maxResponseBytes: 65_536,
|
|
56
|
+
signal: controller.signal,
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The reader exposes only `get(hash, options?)` and `getMany(hashes, options?)`.
|
|
61
|
+
It has no token supplier, header hooks, listing or mutation methods. Requests
|
|
62
|
+
omit ambient credentials and reject redirects. Configuration accepts absolute
|
|
63
|
+
HTTP(S) URLs, including a shared-host path prefix, and rejects userinfo and
|
|
64
|
+
fragments. Local HTTP is permitted explicitly; address/DNS policy remains the
|
|
65
|
+
host's responsibility. An optional `fetchImpl` is a trusted transport override
|
|
66
|
+
that must retain those policies. Without it, fetch is resolved at request time.
|
|
67
|
+
|
|
68
|
+
`maxResponseBytes` is an optional positive safe integer. It counts decoded Fetch
|
|
69
|
+
response-stream bytes before JSON parsing, on success and error responses,
|
|
70
|
+
including the whole native object/array and its metadata. Omission means no size
|
|
71
|
+
limit. It does not bound raw compressed traffic, headers, decompression work or
|
|
72
|
+
connection buffers. The signal is forwarded to fetch and remains active during
|
|
73
|
+
body consumption; aborting does not wait indefinitely for stream cleanup.
|
|
74
|
+
|
|
75
|
+
Successful reads validate the stored-payload shape and preserve all fields.
|
|
76
|
+
Neither requested paths nor `_hash`/`_dataHash` metadata verify content identity;
|
|
77
|
+
callers that need content assurance must hash and validate the returned data.
|
|
78
|
+
Transport, size, cancellation, malformed-response and access failures remain
|
|
79
|
+
failed reads, not evidence that an advertised object never existed.
|
|
80
|
+
|
|
81
|
+
Public viewer access applies to the **whole datalake**, including provider-side
|
|
82
|
+
enumeration and usage APIs. Prefer a dedicated public viewer lake with
|
|
83
|
+
authenticated writers; public runner access also permits mutations. New lakes
|
|
84
|
+
are private until granted access, and browser access additionally requires the
|
|
85
|
+
provider's CORS configuration. This client does not change ACLs or retention.
|
|
86
|
+
|
|
87
|
+
The public reader requires the released `@ariestools/sdk` 8.2.0 or a compatible
|
|
88
|
+
8.2 patch, plus its required `@opentelemetry/api` peer. It does not require zod
|
|
89
|
+
for these reads; other SDK features and datalake peers can have separate needs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadsClient.d.ts","sourceRoot":"","sources":["../../src/PayloadsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"PayloadsClient.d.ts","sourceRoot":"","sources":["../../src/PayloadsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,oBAAoB,EACpB,mBAAmB,EAEnB,kBAAkB,EAClB,OAAO,EACP,eAAe,EAChB,MAAM,yCAAyC,CAAA;AAchD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIrD,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE;QACX,SAAS,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAA;QAChD,aAAa,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAA;KACrD,CAAA;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACrC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAA;IACpD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,O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G,OAAO,CAAC,kBAAkB,CAAC;IAepE,KAAK,IAAI,OAAO,CAAC,mBAAmB,CAAC;YAI7B,OAAO;YAKP,kBAAkB;CAuBjC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Payload, WithStorageMeta } from '@ariestools/aries-datalake-core/browser';
|
|
2
|
+
/** Policy for one public HTTP response, including its JSON envelope and metadata. */
|
|
3
|
+
export interface RestPublicPayloadsReadOptions {
|
|
4
|
+
/**
|
|
5
|
+
Positive safe-integer limit on decoded Fetch-body bytes before JSON parsing.
|
|
6
|
+
Omission leaves the body size unlimited; this is not a raw network-byte limit.
|
|
7
|
+
*/
|
|
8
|
+
readonly maxResponseBytes?: number;
|
|
9
|
+
/** Caller cancellation remains active through response-body consumption. */
|
|
10
|
+
readonly signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface RestPublicPayloadsReaderOptions {
|
|
13
|
+
/** Absolute HTTP(S) data-plane URL, optionally including its API path prefix. */
|
|
14
|
+
readonly baseUrl: string;
|
|
15
|
+
/** Datalake id used to regenerate the canonical native data-plane paths. */
|
|
16
|
+
readonly datalakeId: string;
|
|
17
|
+
/**
|
|
18
|
+
Trusted transport override. It must preserve the public no-credentials and
|
|
19
|
+
no-redirect policy and honor cancellation. Defaults to request-time global fetch.
|
|
20
|
+
*/
|
|
21
|
+
readonly fetchImpl?: typeof fetch;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Exact-hash reads using the native data-plane protocol without token handling.
|
|
25
|
+
* The server must grant public viewer access. Public access applies to the whole
|
|
26
|
+
* lake; this reader neither grants access nor falls back from authenticated I/O.
|
|
27
|
+
* Returned metadata is structural transport data, not verified content identity.
|
|
28
|
+
*/
|
|
29
|
+
export declare class RestPublicPayloadsReader {
|
|
30
|
+
private readonly datalakeId;
|
|
31
|
+
private readonly fetchImpl?;
|
|
32
|
+
private readonly requestBase;
|
|
33
|
+
constructor(options: RestPublicPayloadsReaderOptions);
|
|
34
|
+
get(hash: string, options?: RestPublicPayloadsReadOptions): Promise<WithStorageMeta<Payload>>;
|
|
35
|
+
getMany(hashes: readonly string[], options?: RestPublicPayloadsReadOptions): Promise<WithStorageMeta<Payload>[]>;
|
|
36
|
+
private request;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=RestPublicPayloadsReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RestPublicPayloadsReader.d.ts","sourceRoot":"","sources":["../../src/RestPublicPayloadsReader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAA;AAMvF,qFAAqF;AACrF,MAAM,WAAW,6BAA6B;IAC5C;;;MAGE;IACF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAC9B;AAED,MAAM,WAAW,+BAA+B;IAC9C,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B;;;MAGE;IACF,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CAClC;AAED;;;;;GAKG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAc;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;gBAExB,OAAO,EAAE,+BAA+B;IAM9C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,6BAAkC,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAMjG,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,GAAE,6BAAkC,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;YAW5G,OAAO;CAoBtB"}
|
|
@@ -4,5 +4,7 @@ export type { DatalakeUsageReport, PayloadsAuthTokenSource, PayloadsClient, Rest
|
|
|
4
4
|
export { RestPayloadsClient } from './PayloadsClient.ts';
|
|
5
5
|
export type { RestDatalakeClientOptions } from './RestDatalakeClient.ts';
|
|
6
6
|
export { RestDatalakeClient } from './RestDatalakeClient.ts';
|
|
7
|
+
export type { RestPublicPayloadsReaderOptions, RestPublicPayloadsReadOptions } from './RestPublicPayloadsReader.ts';
|
|
8
|
+
export { RestPublicPayloadsReader } from './RestPublicPayloadsReader.ts';
|
|
7
9
|
export * from '@ariestools/aries-datalake-core/browser';
|
|
8
10
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,GACrD,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,cAAc,yCAAyC,CAAA"}
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,GACrD,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,YAAY,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAA;AACnH,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,cAAc,yCAAyC,CAAA"}
|
package/dist/browser/browser.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// src/PayloadsClient.ts
|
|
2
2
|
import {
|
|
3
|
-
DATALAKE_API_VERSION,
|
|
4
3
|
DATALAKE_HEADER_DUPLICATES,
|
|
5
4
|
DATALAKE_HEADER_NEXT_CURSOR,
|
|
6
5
|
DATALAKE_HEADER_REJECTED,
|
|
7
|
-
DatalakeApiError,
|
|
8
6
|
datalakePlaneClearPath,
|
|
9
7
|
datalakePlaneDeletePath,
|
|
10
8
|
datalakePlaneGetManyPath,
|
|
@@ -19,7 +17,8 @@ async function resolveAuthToken(source, audience) {
|
|
|
19
17
|
return typeof source === "function" ? await source({ audience }) : source;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
// src/
|
|
20
|
+
// src/payloadRequest.ts
|
|
21
|
+
import { DATALAKE_API_VERSION, DatalakeApiError } from "@ariestools/aries-datalake-core/browser";
|
|
23
22
|
function extractRequestBase(urlWithPossiblePath) {
|
|
24
23
|
try {
|
|
25
24
|
const parsed = new URL(urlWithPossiblePath);
|
|
@@ -31,6 +30,24 @@ function extractRequestBase(urlWithPossiblePath) {
|
|
|
31
30
|
return urlWithPossiblePath.replace(/\/$/, "");
|
|
32
31
|
}
|
|
33
32
|
}
|
|
33
|
+
function parsePayloadResponse(response, text, method) {
|
|
34
|
+
const payload = text.length > 0 ? JSON.parse(text) : void 0;
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const errorBody = isApiErrorBody(payload) ? payload : {
|
|
37
|
+
code: "internal",
|
|
38
|
+
message: "Unexpected " + response.status + " response from " + method + " data plane"
|
|
39
|
+
};
|
|
40
|
+
throw new DatalakeApiError(response.status, errorBody);
|
|
41
|
+
}
|
|
42
|
+
return payload;
|
|
43
|
+
}
|
|
44
|
+
function isApiErrorBody(value) {
|
|
45
|
+
if (typeof value !== "object" || value === null) return false;
|
|
46
|
+
const maybe = value;
|
|
47
|
+
return typeof maybe.code === "string" && typeof maybe.message === "string";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/PayloadsClient.ts
|
|
34
51
|
var RestPayloadsClient = class {
|
|
35
52
|
authToken;
|
|
36
53
|
datalakeId;
|
|
@@ -114,15 +131,7 @@ var RestPayloadsClient = class {
|
|
|
114
131
|
const response = await this.fetchImpl(`${this.requestBase}${path}`, init);
|
|
115
132
|
if (response.status === 204) return { data: void 0, headers: response.headers };
|
|
116
133
|
const text = await response.text();
|
|
117
|
-
|
|
118
|
-
if (!response.ok) {
|
|
119
|
-
const errorBody = isApiErrorBody(payload) ? payload : {
|
|
120
|
-
code: "internal",
|
|
121
|
-
message: `Unexpected ${response.status} response from ${method} data plane`
|
|
122
|
-
};
|
|
123
|
-
throw new DatalakeApiError(response.status, errorBody);
|
|
124
|
-
}
|
|
125
|
-
return { data: payload, headers: response.headers };
|
|
134
|
+
return { data: parsePayloadResponse(response, text, method), headers: response.headers };
|
|
126
135
|
}
|
|
127
136
|
};
|
|
128
137
|
function readInsertSummary(headers) {
|
|
@@ -135,11 +144,6 @@ function readInsertSummary(headers) {
|
|
|
135
144
|
rejected
|
|
136
145
|
};
|
|
137
146
|
}
|
|
138
|
-
function isApiErrorBody(value) {
|
|
139
|
-
if (typeof value !== "object" || value === null) return false;
|
|
140
|
-
const maybe = value;
|
|
141
|
-
return typeof maybe.code === "string" && typeof maybe.message === "string";
|
|
142
|
-
}
|
|
143
147
|
|
|
144
148
|
// src/RestDatalakeClient.ts
|
|
145
149
|
import {
|
|
@@ -235,10 +239,89 @@ function isApiErrorBody2(value) {
|
|
|
235
239
|
return typeof maybe.code === "string" && typeof maybe.message === "string";
|
|
236
240
|
}
|
|
237
241
|
|
|
242
|
+
// src/RestPublicPayloadsReader.ts
|
|
243
|
+
import { datalakePlaneGetManyPath as datalakePlaneGetManyPath2, datalakePlaneGetPath as datalakePlaneGetPath2 } from "@ariestools/aries-datalake-core/browser";
|
|
244
|
+
import { readResponseText } from "@ariestools/sdk/fetch";
|
|
245
|
+
var RestPublicPayloadsReader = class {
|
|
246
|
+
datalakeId;
|
|
247
|
+
fetchImpl;
|
|
248
|
+
requestBase;
|
|
249
|
+
constructor(options) {
|
|
250
|
+
this.requestBase = publicRequestBase(options.baseUrl);
|
|
251
|
+
this.datalakeId = options.datalakeId;
|
|
252
|
+
this.fetchImpl = options.fetchImpl;
|
|
253
|
+
}
|
|
254
|
+
async get(hash, options = {}) {
|
|
255
|
+
const payload = await this.request(datalakePlaneGetPath2(this.datalakeId, hash), options);
|
|
256
|
+
if (!isStoredPayload(payload)) throw new TypeError("Data plane returned an invalid stored payload");
|
|
257
|
+
return payload;
|
|
258
|
+
}
|
|
259
|
+
async getMany(hashes, options = {}) {
|
|
260
|
+
const policy = pinReadOptions(options);
|
|
261
|
+
const requested = [...hashes];
|
|
262
|
+
if (requested.length === 0) return [];
|
|
263
|
+
const payloads = await this.request(datalakePlaneGetManyPath2(this.datalakeId), policy, requested);
|
|
264
|
+
if (!Array.isArray(payloads) || !payloads.every(isStoredPayload)) {
|
|
265
|
+
throw new TypeError("Data plane returned an invalid stored-payload array");
|
|
266
|
+
}
|
|
267
|
+
return payloads;
|
|
268
|
+
}
|
|
269
|
+
async request(path, options, hashes) {
|
|
270
|
+
const { maxResponseBytes, signal } = pinReadOptions(options);
|
|
271
|
+
const method = hashes === void 0 ? "GET" : "POST";
|
|
272
|
+
const headers = { accept: "application/json" };
|
|
273
|
+
const init = {
|
|
274
|
+
credentials: "omit",
|
|
275
|
+
headers,
|
|
276
|
+
method,
|
|
277
|
+
redirect: "error",
|
|
278
|
+
signal
|
|
279
|
+
};
|
|
280
|
+
if (hashes !== void 0) {
|
|
281
|
+
headers["content-type"] = "application/json";
|
|
282
|
+
init.body = JSON.stringify(hashes);
|
|
283
|
+
}
|
|
284
|
+
const fetchImpl = this.fetchImpl ?? globalThis.fetch;
|
|
285
|
+
const response = await fetchImpl(this.requestBase + path, init);
|
|
286
|
+
const text = await readResponseText(response, { maxResponseBytes, signal });
|
|
287
|
+
return parsePayloadResponse(response, text, method);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
function pinReadOptions(options) {
|
|
291
|
+
const { maxResponseBytes, signal } = options;
|
|
292
|
+
if (maxResponseBytes !== void 0 && (!Number.isSafeInteger(maxResponseBytes) || maxResponseBytes <= 0)) {
|
|
293
|
+
throw new RangeError("maxResponseBytes must be a positive safe integer");
|
|
294
|
+
}
|
|
295
|
+
signal?.throwIfAborted();
|
|
296
|
+
return { maxResponseBytes, signal };
|
|
297
|
+
}
|
|
298
|
+
function publicRequestBase(baseUrl) {
|
|
299
|
+
let parsed;
|
|
300
|
+
try {
|
|
301
|
+
parsed = new URL(baseUrl);
|
|
302
|
+
} catch {
|
|
303
|
+
throw new TypeError("baseUrl must be an absolute HTTP(S) URL");
|
|
304
|
+
}
|
|
305
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
306
|
+
throw new TypeError("baseUrl must be an absolute HTTP(S) URL");
|
|
307
|
+
}
|
|
308
|
+
if (parsed.username !== "" || parsed.password !== "") {
|
|
309
|
+
throw new TypeError("Public data-plane URLs must not contain credentials");
|
|
310
|
+
}
|
|
311
|
+
if (parsed.href.includes("#")) throw new TypeError("Public data-plane URLs must not contain fragments");
|
|
312
|
+
return extractRequestBase(baseUrl);
|
|
313
|
+
}
|
|
314
|
+
function isStoredPayload(value) {
|
|
315
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
316
|
+
const payload = value;
|
|
317
|
+
return ["schema", "_hash", "_dataHash", "_sequence"].every((key) => Object.hasOwn(payload, key) && typeof payload[key] === "string");
|
|
318
|
+
}
|
|
319
|
+
|
|
238
320
|
// src/browser.ts
|
|
239
321
|
export * from "@ariestools/aries-datalake-core/browser";
|
|
240
322
|
export {
|
|
241
323
|
RestDatalakeClient,
|
|
242
|
-
RestPayloadsClient
|
|
324
|
+
RestPayloadsClient,
|
|
325
|
+
RestPublicPayloadsReader
|
|
243
326
|
};
|
|
244
327
|
//# sourceMappingURL=browser.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/PayloadsClient.ts", "../../src/AuthToken.ts", "../../src/RestDatalakeClient.ts", "../../src/browser.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n ApiErrorBody,\n DatalakeInsertSummary,\n InsertPayloadsBody,\n InsertPayloadsResponse,\n InsertPayloadsResult,\n NextPayloadsOptions,\n NextPayloadsResponse,\n NextPayloadsResult,\n Payload,\n WithStorageMeta,\n} from '@ariestools/aries-datalake-core/browser'\nimport {\n DATALAKE_API_VERSION,\n DATALAKE_HEADER_DUPLICATES,\n DATALAKE_HEADER_NEXT_CURSOR,\n DATALAKE_HEADER_REJECTED,\n DatalakeApiError,\n datalakePlaneClearPath,\n datalakePlaneDeletePath,\n datalakePlaneGetManyPath,\n datalakePlaneGetPath,\n datalakePlaneInsertPath,\n datalakePlaneNextPath,\n datalakePlaneUsagePath,\n} from '@ariestools/aries-datalake-core/browser'\n\nimport type { AuthTokenSource } from './AuthToken.ts'\nimport { resolveAuthToken } from './AuthToken.ts'\n\nexport interface DatalakeUsageReport {\n datalakeId: string\n payloadCount: number\n rateLimits?: {\n anonymous?: { limit: number; remaining: number }\n authenticated?: { limit: number; remaining: number }\n }\n}\n\n/**\n * HTTP client for a single datalake's data plane. Clients send bare\n * `Payload` objects (no `_hash` / `_dataHash` \u2014 those are stamped on\n * insert by the data plane's archivist). Responses always carry the\n * archivist-computed storage meta.\n *\n * Wire format mirrors the XYO archivist REST middleware: `/insert`,\n * `/get/:hash`, `/next`, bare arrays as bodies. Datalake-specific\n * extras (duplicates count, rejected hashes, next cursor) are delivered\n * via response headers.\n */\nexport interface PayloadsClient {\n clear(): Promise<{ removed: number }>\n delete(hash: string): Promise<void>\n get(hash: string): Promise<WithStorageMeta<Payload>>\n getMany(hashes: string[]): Promise<WithStorageMeta<Payload>[]>\n insert(payloads: Payload[]): Promise<InsertPayloadsResult>\n next(options?: NextPayloadsOptions): Promise<NextPayloadsResult>\n usage(): Promise<DatalakeUsageReport>\n}\n\n/**\n * Either a static bearer token, or a factory invoked per-request. The factory\n * form lets callers mint a fresh self-signed wallet JWT per call (with\n * `aud` bound to the datalake id).\n */\nexport type PayloadsAuthTokenSource = AuthTokenSource\n\nexport interface RestPayloadsClientOptions {\n /**\n Static bearer token, or async factory minted per-request.\n */\n authToken: PayloadsAuthTokenSource\n /**\n Data-plane base URL without trailing slash.\n */\n baseUrl: string\n /**\n Datalake id; appended to `/v1/datalakes/:id/...`.\n */\n datalakeId: string\n /**\n Optional `fetch` override; defaults to global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\ninterface RequestOptions {\n body?: unknown\n method?: string\n}\n\ninterface RequestResult<T> {\n data: T\n headers: Headers\n}\n\n/**\n * The data plane is typically addressed by a URL that already includes the\n * datalake id (e.g. `https://plane/v1/datalakes/dl_abc`). Preserve any path\n * prefix before `/v1/datalakes` so a shared ALB can expose the data plane at\n * `https://host/plane` while the path helpers regenerate the canonical API\n * suffix from the id.\n */\nfunction extractRequestBase(urlWithPossiblePath: string): string {\n try {\n const parsed = new URL(urlWithPossiblePath)\n const apiMarker = `/${DATALAKE_API_VERSION}/datalakes`\n const markerIndex = parsed.pathname.indexOf(apiMarker)\n const prefix = markerIndex === -1\n ? parsed.pathname.replace(/\\/$/, '')\n : parsed.pathname.slice(0, markerIndex)\n return `${parsed.protocol}//${parsed.host}${prefix}`\n } catch {\n return urlWithPossiblePath.replace(/\\/$/, '')\n }\n}\n\nexport class RestPayloadsClient implements PayloadsClient {\n private readonly authToken: PayloadsAuthTokenSource\n private readonly datalakeId: string\n private readonly fetchImpl: typeof fetch\n private readonly requestBase: string\n\n constructor(options: RestPayloadsClientOptions) {\n this.requestBase = extractRequestBase(options.baseUrl)\n this.datalakeId = options.datalakeId\n this.authToken = options.authToken\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async clear(): Promise<{ removed: number }> {\n return this.request<{ removed: number }>(\n datalakePlaneClearPath(this.datalakeId),\n { method: 'POST' },\n )\n }\n\n async delete(hash: string): Promise<void> {\n await this.request<void>(\n datalakePlaneDeletePath(this.datalakeId, hash),\n { method: 'DELETE' },\n )\n }\n\n async get(hash: string): Promise<WithStorageMeta<Payload>> {\n return this.request<WithStorageMeta<Payload>>(datalakePlaneGetPath(this.datalakeId, hash))\n }\n\n async getMany(hashes: string[]): Promise<WithStorageMeta<Payload>[]> {\n if (hashes.length === 0) return []\n return this.request<WithStorageMeta<Payload>[]>(\n datalakePlaneGetManyPath(this.datalakeId),\n { method: 'POST', body: hashes },\n )\n }\n\n async insert(payloads: Payload[]): Promise<InsertPayloadsResult> {\n const body: InsertPayloadsBody = payloads\n const { data, headers } = await this.requestWithHeaders<InsertPayloadsResponse>(\n datalakePlaneInsertPath(this.datalakeId),\n { method: 'POST', body },\n )\n return {\n inserted: data,\n summary: readInsertSummary(headers),\n }\n }\n\n async next(options: NextPayloadsOptions = {}): Promise<NextPayloadsResult> {\n const params = new URLSearchParams()\n if (options.limit !== undefined) params.set('limit', String(options.limit))\n if (options.cursor) params.set('cursor', options.cursor)\n if (options.schemas && options.schemas.length > 0) params.set('schemas', options.schemas.join(','))\n if (options.order) params.set('order', options.order)\n const suffix = params.toString()\n const path = suffix\n ? `${datalakePlaneNextPath(this.datalakeId)}?${suffix}`\n : datalakePlaneNextPath(this.datalakeId)\n const { data, headers } = await this.requestWithHeaders<NextPayloadsResponse>(path)\n const nextCursor = headers.get(DATALAKE_HEADER_NEXT_CURSOR) ?? undefined\n return { payloads: data, nextCursor }\n }\n\n async usage(): Promise<DatalakeUsageReport> {\n return this.request<DatalakeUsageReport>(datalakePlaneUsagePath(this.datalakeId))\n }\n\n private async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const { data } = await this.requestWithHeaders<T>(path, options)\n return data\n }\n\n private async requestWithHeaders<T>(path: string, options: RequestOptions = {}): Promise<RequestResult<T>> {\n const method = options.method ?? 'GET'\n const token = await resolveAuthToken(this.authToken, this.datalakeId)\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n }\n if (options.body !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(options.body)\n }\n\n const response = await this.fetchImpl(`${this.requestBase}${path}`, init)\n if (response.status === 204) return { data: undefined as T, headers: response.headers }\n const text = await response.text()\n const payload: unknown = text.length > 0 ? JSON.parse(text) : undefined\n\n if (!response.ok) {\n const errorBody: ApiErrorBody = isApiErrorBody(payload)\n ? payload\n : {\n code: 'internal',\n message: `Unexpected ${response.status} response from ${method} data plane`,\n }\n throw new DatalakeApiError(response.status, errorBody)\n }\n return { data: payload as T, headers: response.headers }\n }\n}\n\nfunction readInsertSummary(headers: Headers): DatalakeInsertSummary {\n const duplicatesRaw = headers.get(DATALAKE_HEADER_DUPLICATES)\n const duplicates = duplicatesRaw === null ? 0 : Number.parseInt(duplicatesRaw, 10)\n const rejectedRaw = headers.get(DATALAKE_HEADER_REJECTED)\n const rejected = rejectedRaw === null || rejectedRaw.length === 0\n ? []\n : rejectedRaw.split(',').map(value => value.trim()).filter(value => value.length > 0)\n return {\n duplicates: Number.isFinite(duplicates) ? duplicates : 0,\n rejected,\n }\n}\n\nfunction isApiErrorBody(value: unknown): value is ApiErrorBody {\n if (typeof value !== 'object' || value === null) return false\n const maybe = value as Record<string, unknown>\n return typeof maybe.code === 'string' && typeof maybe.message === 'string'\n}\n", "export interface AuthTokenRequest {\n /**\n Exact JWT audience required by the target service or datalake.\n */\n audience: string\n}\n\n/**\nInvoked for every request so callers can obtain a fresh wallet JWT.\n*/\nexport type AuthTokenSupplier = (request: AuthTokenRequest) => Promise<string>\n\nexport type AuthTokenSource = AuthTokenSupplier | string\n\nexport async function resolveAuthToken(source: AuthTokenSource, audience: string): Promise<string> {\n return typeof source === 'function' ? await source({ audience }) : source\n}\n", "import type {\n ApiErrorBody,\n CreateDatalakeBody,\n DatalakeDescriptor,\n DatalakeToken,\n GrantBody,\n MintTokenBody,\n} from '@ariestools/aries-datalake-core/browser'\nimport {\n DATALAKE_CONTROL_AUDIENCE,\n DatalakeApiError,\n datalakeCollectionPath,\n datalakeGrantPath,\n datalakeGrantsPath,\n datalakeResourcePath,\n datalakeTokensPath,\n} from '@ariestools/aries-datalake-core/browser'\n\nimport type { AuthTokenSource } from './AuthToken.ts'\nimport { resolveAuthToken } from './AuthToken.ts'\nimport type {\n CreateDatalakeRequest,\n DatalakeClient,\n GrantRequest,\n RevokeRequest,\n TokenRequest,\n} from './DatalakeClient.ts'\n\nexport interface RestDatalakeClientOptions {\n /**\n Exact control-plane JWT audience.\n */\n audience?: string\n /**\n Static token, or async factory minted per-request.\n */\n authToken: AuthTokenSource\n /**\n Control-plane base URL, e.g. `https://dl-control.xylabs.io`.\n */\n baseUrl: string\n /**\n Optional `fetch` override; defaults to global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\ninterface RequestOptions {\n body?: unknown\n method?: string\n}\n\n/**\n * HTTP client for the datalake control plane. Implements the stable\n * `DatalakeClient` contract so callers are independent of transport.\n */\nexport class RestDatalakeClient implements DatalakeClient {\n private readonly audience: string\n private readonly authToken: AuthTokenSource\n private readonly baseUrl: string\n private readonly fetchImpl: typeof fetch\n\n constructor(options: RestDatalakeClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '')\n this.audience = options.audience ?? DATALAKE_CONTROL_AUDIENCE\n this.authToken = options.authToken\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async create(request: CreateDatalakeRequest): Promise<DatalakeDescriptor> {\n const body: CreateDatalakeBody = { name: request.name, config: request.config }\n return this.request<DatalakeDescriptor>(datalakeCollectionPath(), { method: 'POST', body })\n }\n\n async describe(idOrName: string): Promise<DatalakeDescriptor> {\n return this.request<DatalakeDescriptor>(datalakeResourcePath(idOrName))\n }\n\n async destroy(idOrName: string): Promise<void> {\n await this.request<void>(datalakeResourcePath(idOrName), { method: 'DELETE' })\n }\n\n async grant(request: GrantRequest): Promise<DatalakeDescriptor> {\n const body: GrantBody = { principal: request.principal, role: request.role }\n return this.request<DatalakeDescriptor>(\n datalakeGrantsPath(request.datalakeId),\n { method: 'POST', body },\n )\n }\n\n async list(): Promise<DatalakeDescriptor[]> {\n return this.request<DatalakeDescriptor[]>(datalakeCollectionPath())\n }\n\n async mintToken(request: TokenRequest): Promise<DatalakeToken> {\n const body: MintTokenBody = { role: request.role, ttlSeconds: request.ttlSeconds }\n return this.request<DatalakeToken>(\n datalakeTokensPath(request.datalakeId),\n { method: 'POST', body },\n )\n }\n\n async revoke(request: RevokeRequest): Promise<DatalakeDescriptor> {\n return this.request<DatalakeDescriptor>(\n datalakeGrantPath(request.datalakeId, request.principal),\n { method: 'DELETE' },\n )\n }\n\n private async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const url = `${this.baseUrl}${path}`\n const method = options.method ?? 'GET'\n const token = await resolveAuthToken(this.authToken, this.audience)\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n }\n if (options.body !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(options.body)\n }\n\n const response = await this.fetchImpl(url, init)\n if (response.status === 204) {\n return undefined as T\n }\n const text = await response.text()\n const payload: unknown = text.length > 0 ? JSON.parse(text) : undefined\n\n if (!response.ok) {\n const errorBody: ApiErrorBody = isApiErrorBody(payload)\n ? payload\n : {\n code: 'internal',\n message: `Unexpected ${response.status} response from ${method} control plane`,\n }\n throw new DatalakeApiError(response.status, errorBody)\n }\n return payload as T\n }\n}\n\nfunction isApiErrorBody(value: unknown): value is ApiErrorBody {\n if (typeof value !== 'object' || value === null) return false\n const maybe = value as Record<string, unknown>\n return typeof maybe.code === 'string' && typeof maybe.message === 'string'\n}\n", "export type {\n AuthTokenRequest, AuthTokenSource, AuthTokenSupplier,\n} from './AuthToken.ts'\nexport type {\n CreateDatalakeRequest,\n DatalakeClient,\n GrantRequest,\n RevokeRequest,\n TokenRequest,\n} from './DatalakeClient.ts'\nexport type {\n DatalakeUsageReport,\n PayloadsAuthTokenSource,\n PayloadsClient,\n RestPayloadsClientOptions,\n} from './PayloadsClient.ts'\nexport { RestPayloadsClient } from './PayloadsClient.ts'\nexport type { RestDatalakeClientOptions } from './RestDatalakeClient.ts'\nexport { RestDatalakeClient } from './RestDatalakeClient.ts'\nexport * from '@ariestools/aries-datalake-core/browser'\n"],
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": ["DatalakeApiError", "isApiErrorBody", "DatalakeApiError"]
|
|
3
|
+
"sources": ["../../src/PayloadsClient.ts", "../../src/AuthToken.ts", "../../src/payloadRequest.ts", "../../src/RestDatalakeClient.ts", "../../src/RestPublicPayloadsReader.ts", "../../src/browser.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n DatalakeInsertSummary,\n InsertPayloadsBody,\n InsertPayloadsResponse,\n InsertPayloadsResult,\n NextPayloadsOptions,\n NextPayloadsResponse,\n NextPayloadsResult,\n Payload,\n WithStorageMeta,\n} from '@ariestools/aries-datalake-core/browser'\nimport {\n DATALAKE_HEADER_DUPLICATES,\n DATALAKE_HEADER_NEXT_CURSOR,\n DATALAKE_HEADER_REJECTED,\n datalakePlaneClearPath,\n datalakePlaneDeletePath,\n datalakePlaneGetManyPath,\n datalakePlaneGetPath,\n datalakePlaneInsertPath,\n datalakePlaneNextPath,\n datalakePlaneUsagePath,\n} from '@ariestools/aries-datalake-core/browser'\n\nimport type { AuthTokenSource } from './AuthToken.ts'\nimport { resolveAuthToken } from './AuthToken.ts'\nimport { extractRequestBase, parsePayloadResponse } from './payloadRequest.ts'\n\nexport interface DatalakeUsageReport {\n datalakeId: string\n payloadCount: number\n rateLimits?: {\n anonymous?: { limit: number; remaining: number }\n authenticated?: { limit: number; remaining: number }\n }\n}\n\n/**\n * HTTP client for a single datalake's data plane. Clients send bare\n * `Payload` objects (no `_hash` / `_dataHash` \u2014 those are stamped on\n * insert by the data plane's archivist). Responses always carry the\n * archivist-computed storage meta.\n *\n * Wire format mirrors the XYO archivist REST middleware: `/insert`,\n * `/get/:hash`, `/next`, bare arrays as bodies. Datalake-specific\n * extras (duplicates count, rejected hashes, next cursor) are delivered\n * via response headers.\n */\nexport interface PayloadsClient {\n clear(): Promise<{ removed: number }>\n delete(hash: string): Promise<void>\n get(hash: string): Promise<WithStorageMeta<Payload>>\n getMany(hashes: string[]): Promise<WithStorageMeta<Payload>[]>\n insert(payloads: Payload[]): Promise<InsertPayloadsResult>\n next(options?: NextPayloadsOptions): Promise<NextPayloadsResult>\n usage(): Promise<DatalakeUsageReport>\n}\n\n/**\n * Either a static bearer token, or a factory invoked per-request. The factory\n * form lets callers mint a fresh self-signed wallet JWT per call (with\n * `aud` bound to the datalake id).\n */\nexport type PayloadsAuthTokenSource = AuthTokenSource\n\nexport interface RestPayloadsClientOptions {\n /**\n Static bearer token, or async factory minted per-request.\n */\n authToken: PayloadsAuthTokenSource\n /**\n Data-plane base URL without trailing slash.\n */\n baseUrl: string\n /**\n Datalake id; appended to `/v1/datalakes/:id/...`.\n */\n datalakeId: string\n /**\n Optional `fetch` override; defaults to global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\ninterface RequestOptions {\n body?: unknown\n method?: string\n}\n\ninterface RequestResult<T> {\n data: T\n headers: Headers\n}\n\nexport class RestPayloadsClient implements PayloadsClient {\n private readonly authToken: PayloadsAuthTokenSource\n private readonly datalakeId: string\n private readonly fetchImpl: typeof fetch\n private readonly requestBase: string\n\n constructor(options: RestPayloadsClientOptions) {\n this.requestBase = extractRequestBase(options.baseUrl)\n this.datalakeId = options.datalakeId\n this.authToken = options.authToken\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async clear(): Promise<{ removed: number }> {\n return this.request<{ removed: number }>(\n datalakePlaneClearPath(this.datalakeId),\n { method: 'POST' },\n )\n }\n\n async delete(hash: string): Promise<void> {\n await this.request<void>(\n datalakePlaneDeletePath(this.datalakeId, hash),\n { method: 'DELETE' },\n )\n }\n\n async get(hash: string): Promise<WithStorageMeta<Payload>> {\n return this.request<WithStorageMeta<Payload>>(datalakePlaneGetPath(this.datalakeId, hash))\n }\n\n async getMany(hashes: string[]): Promise<WithStorageMeta<Payload>[]> {\n if (hashes.length === 0) return []\n return this.request<WithStorageMeta<Payload>[]>(\n datalakePlaneGetManyPath(this.datalakeId),\n { method: 'POST', body: hashes },\n )\n }\n\n async insert(payloads: Payload[]): Promise<InsertPayloadsResult> {\n const body: InsertPayloadsBody = payloads\n const { data, headers } = await this.requestWithHeaders<InsertPayloadsResponse>(\n datalakePlaneInsertPath(this.datalakeId),\n { method: 'POST', body },\n )\n return {\n inserted: data,\n summary: readInsertSummary(headers),\n }\n }\n\n async next(options: NextPayloadsOptions = {}): Promise<NextPayloadsResult> {\n const params = new URLSearchParams()\n if (options.limit !== undefined) params.set('limit', String(options.limit))\n if (options.cursor) params.set('cursor', options.cursor)\n if (options.schemas && options.schemas.length > 0) params.set('schemas', options.schemas.join(','))\n if (options.order) params.set('order', options.order)\n const suffix = params.toString()\n const path = suffix\n ? `${datalakePlaneNextPath(this.datalakeId)}?${suffix}`\n : datalakePlaneNextPath(this.datalakeId)\n const { data, headers } = await this.requestWithHeaders<NextPayloadsResponse>(path)\n const nextCursor = headers.get(DATALAKE_HEADER_NEXT_CURSOR) ?? undefined\n return { payloads: data, nextCursor }\n }\n\n async usage(): Promise<DatalakeUsageReport> {\n return this.request<DatalakeUsageReport>(datalakePlaneUsagePath(this.datalakeId))\n }\n\n private async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const { data } = await this.requestWithHeaders<T>(path, options)\n return data\n }\n\n private async requestWithHeaders<T>(path: string, options: RequestOptions = {}): Promise<RequestResult<T>> {\n const method = options.method ?? 'GET'\n const token = await resolveAuthToken(this.authToken, this.datalakeId)\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n }\n if (options.body !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(options.body)\n }\n\n const response = await this.fetchImpl(`${this.requestBase}${path}`, init)\n if (response.status === 204) return { data: undefined as T, headers: response.headers }\n const text = await response.text()\n return { data: parsePayloadResponse<T>(response, text, method), headers: response.headers }\n }\n}\n\nfunction readInsertSummary(headers: Headers): DatalakeInsertSummary {\n const duplicatesRaw = headers.get(DATALAKE_HEADER_DUPLICATES)\n const duplicates = duplicatesRaw === null ? 0 : Number.parseInt(duplicatesRaw, 10)\n const rejectedRaw = headers.get(DATALAKE_HEADER_REJECTED)\n const rejected = rejectedRaw === null || rejectedRaw.length === 0\n ? []\n : rejectedRaw.split(',').map(value => value.trim()).filter(value => value.length > 0)\n return {\n duplicates: Number.isFinite(duplicates) ? duplicates : 0,\n rejected,\n }\n}\n", "export interface AuthTokenRequest {\n /**\n Exact JWT audience required by the target service or datalake.\n */\n audience: string\n}\n\n/**\nInvoked for every request so callers can obtain a fresh wallet JWT.\n*/\nexport type AuthTokenSupplier = (request: AuthTokenRequest) => Promise<string>\n\nexport type AuthTokenSource = AuthTokenSupplier | string\n\nexport async function resolveAuthToken(source: AuthTokenSource, audience: string): Promise<string> {\n return typeof source === 'function' ? await source({ audience }) : source\n}\n", "import type { ApiErrorBody } from '@ariestools/aries-datalake-core/browser'\nimport { DATALAKE_API_VERSION, DatalakeApiError } from '@ariestools/aries-datalake-core/browser'\n\n/**\n * The data plane is typically addressed by a URL that already includes the\n * datalake id (e.g. `https://plane/v1/datalakes/dl_abc`). Preserve any path\n * prefix before `/v1/datalakes` so a shared ALB can expose the data plane at\n * `https://host/plane` while the path helpers regenerate the canonical API\n * suffix from the id.\n */\nexport function extractRequestBase(urlWithPossiblePath: string): string {\n try {\n const parsed = new URL(urlWithPossiblePath)\n const apiMarker = `/${DATALAKE_API_VERSION}/datalakes`\n const markerIndex = parsed.pathname.indexOf(apiMarker)\n const prefix = markerIndex === -1\n ? parsed.pathname.replace(/\\/$/, '')\n : parsed.pathname.slice(0, markerIndex)\n return `${parsed.protocol}//${parsed.host}${prefix}`\n } catch {\n return urlWithPossiblePath.replace(/\\/$/, '')\n }\n}\n\n/** Preserve the native data-plane JSON and API-error response contract. */\nexport function parsePayloadResponse<T>(response: Response, text: string, method: string): T {\n const payload: unknown = text.length > 0 ? JSON.parse(text) : undefined\n\n if (!response.ok) {\n const errorBody: ApiErrorBody = isApiErrorBody(payload)\n ? payload\n : {\n code: 'internal',\n message: 'Unexpected ' + response.status + ' response from ' + method + ' data plane',\n }\n throw new DatalakeApiError(response.status, errorBody)\n }\n return payload as T\n}\n\nfunction isApiErrorBody(value: unknown): value is ApiErrorBody {\n if (typeof value !== 'object' || value === null) return false\n const maybe = value as Record<string, unknown>\n return typeof maybe.code === 'string' && typeof maybe.message === 'string'\n}\n", "import type {\n ApiErrorBody,\n CreateDatalakeBody,\n DatalakeDescriptor,\n DatalakeToken,\n GrantBody,\n MintTokenBody,\n} from '@ariestools/aries-datalake-core/browser'\nimport {\n DATALAKE_CONTROL_AUDIENCE,\n DatalakeApiError,\n datalakeCollectionPath,\n datalakeGrantPath,\n datalakeGrantsPath,\n datalakeResourcePath,\n datalakeTokensPath,\n} from '@ariestools/aries-datalake-core/browser'\n\nimport type { AuthTokenSource } from './AuthToken.ts'\nimport { resolveAuthToken } from './AuthToken.ts'\nimport type {\n CreateDatalakeRequest,\n DatalakeClient,\n GrantRequest,\n RevokeRequest,\n TokenRequest,\n} from './DatalakeClient.ts'\n\nexport interface RestDatalakeClientOptions {\n /**\n Exact control-plane JWT audience.\n */\n audience?: string\n /**\n Static token, or async factory minted per-request.\n */\n authToken: AuthTokenSource\n /**\n Control-plane base URL, e.g. `https://dl-control.xylabs.io`.\n */\n baseUrl: string\n /**\n Optional `fetch` override; defaults to global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\ninterface RequestOptions {\n body?: unknown\n method?: string\n}\n\n/**\n * HTTP client for the datalake control plane. Implements the stable\n * `DatalakeClient` contract so callers are independent of transport.\n */\nexport class RestDatalakeClient implements DatalakeClient {\n private readonly audience: string\n private readonly authToken: AuthTokenSource\n private readonly baseUrl: string\n private readonly fetchImpl: typeof fetch\n\n constructor(options: RestDatalakeClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '')\n this.audience = options.audience ?? DATALAKE_CONTROL_AUDIENCE\n this.authToken = options.authToken\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async create(request: CreateDatalakeRequest): Promise<DatalakeDescriptor> {\n const body: CreateDatalakeBody = { name: request.name, config: request.config }\n return this.request<DatalakeDescriptor>(datalakeCollectionPath(), { method: 'POST', body })\n }\n\n async describe(idOrName: string): Promise<DatalakeDescriptor> {\n return this.request<DatalakeDescriptor>(datalakeResourcePath(idOrName))\n }\n\n async destroy(idOrName: string): Promise<void> {\n await this.request<void>(datalakeResourcePath(idOrName), { method: 'DELETE' })\n }\n\n async grant(request: GrantRequest): Promise<DatalakeDescriptor> {\n const body: GrantBody = { principal: request.principal, role: request.role }\n return this.request<DatalakeDescriptor>(\n datalakeGrantsPath(request.datalakeId),\n { method: 'POST', body },\n )\n }\n\n async list(): Promise<DatalakeDescriptor[]> {\n return this.request<DatalakeDescriptor[]>(datalakeCollectionPath())\n }\n\n async mintToken(request: TokenRequest): Promise<DatalakeToken> {\n const body: MintTokenBody = { role: request.role, ttlSeconds: request.ttlSeconds }\n return this.request<DatalakeToken>(\n datalakeTokensPath(request.datalakeId),\n { method: 'POST', body },\n )\n }\n\n async revoke(request: RevokeRequest): Promise<DatalakeDescriptor> {\n return this.request<DatalakeDescriptor>(\n datalakeGrantPath(request.datalakeId, request.principal),\n { method: 'DELETE' },\n )\n }\n\n private async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const url = `${this.baseUrl}${path}`\n const method = options.method ?? 'GET'\n const token = await resolveAuthToken(this.authToken, this.audience)\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n }\n if (options.body !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(options.body)\n }\n\n const response = await this.fetchImpl(url, init)\n if (response.status === 204) {\n return undefined as T\n }\n const text = await response.text()\n const payload: unknown = text.length > 0 ? JSON.parse(text) : undefined\n\n if (!response.ok) {\n const errorBody: ApiErrorBody = isApiErrorBody(payload)\n ? payload\n : {\n code: 'internal',\n message: `Unexpected ${response.status} response from ${method} control plane`,\n }\n throw new DatalakeApiError(response.status, errorBody)\n }\n return payload as T\n }\n}\n\nfunction isApiErrorBody(value: unknown): value is ApiErrorBody {\n if (typeof value !== 'object' || value === null) return false\n const maybe = value as Record<string, unknown>\n return typeof maybe.code === 'string' && typeof maybe.message === 'string'\n}\n", "import type { Payload, WithStorageMeta } from '@ariestools/aries-datalake-core/browser'\nimport { datalakePlaneGetManyPath, datalakePlaneGetPath } from '@ariestools/aries-datalake-core/browser'\nimport { readResponseText } from '@ariestools/sdk/fetch'\n\nimport { extractRequestBase, parsePayloadResponse } from './payloadRequest.ts'\n\n/** Policy for one public HTTP response, including its JSON envelope and metadata. */\nexport interface RestPublicPayloadsReadOptions {\n /**\n Positive safe-integer limit on decoded Fetch-body bytes before JSON parsing.\n Omission leaves the body size unlimited; this is not a raw network-byte limit.\n */\n readonly maxResponseBytes?: number\n /** Caller cancellation remains active through response-body consumption. */\n readonly signal?: AbortSignal\n}\n\nexport interface RestPublicPayloadsReaderOptions {\n /** Absolute HTTP(S) data-plane URL, optionally including its API path prefix. */\n readonly baseUrl: string\n /** Datalake id used to regenerate the canonical native data-plane paths. */\n readonly datalakeId: string\n /**\n Trusted transport override. It must preserve the public no-credentials and\n no-redirect policy and honor cancellation. Defaults to request-time global fetch.\n */\n readonly fetchImpl?: typeof fetch\n}\n\n/**\n * Exact-hash reads using the native data-plane protocol without token handling.\n * The server must grant public viewer access. Public access applies to the whole\n * lake; this reader neither grants access nor falls back from authenticated I/O.\n * Returned metadata is structural transport data, not verified content identity.\n */\nexport class RestPublicPayloadsReader {\n private readonly datalakeId: string\n private readonly fetchImpl?: typeof fetch\n private readonly requestBase: string\n\n constructor(options: RestPublicPayloadsReaderOptions) {\n this.requestBase = publicRequestBase(options.baseUrl)\n this.datalakeId = options.datalakeId\n this.fetchImpl = options.fetchImpl\n }\n\n async get(hash: string, options: RestPublicPayloadsReadOptions = {}): Promise<WithStorageMeta<Payload>> {\n const payload = await this.request(datalakePlaneGetPath(this.datalakeId, hash), options)\n if (!isStoredPayload(payload)) throw new TypeError('Data plane returned an invalid stored payload')\n return payload\n }\n\n async getMany(hashes: readonly string[], options: RestPublicPayloadsReadOptions = {}): Promise<WithStorageMeta<Payload>[]> {\n const policy = pinReadOptions(options)\n const requested = [...hashes]\n if (requested.length === 0) return []\n const payloads = await this.request(datalakePlaneGetManyPath(this.datalakeId), policy, requested)\n if (!Array.isArray(payloads) || !payloads.every(isStoredPayload)) {\n throw new TypeError('Data plane returned an invalid stored-payload array')\n }\n return payloads\n }\n\n private async request(path: string, options: RestPublicPayloadsReadOptions, hashes?: readonly string[]): Promise<unknown> {\n const { maxResponseBytes, signal } = pinReadOptions(options)\n const method = hashes === undefined ? 'GET' : 'POST'\n const headers: Record<string, string> = { accept: 'application/json' }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n signal,\n }\n if (hashes !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(hashes)\n }\n const fetchImpl = this.fetchImpl ?? globalThis.fetch\n const response = await fetchImpl(this.requestBase + path, init)\n const text = await readResponseText(response, { maxResponseBytes, signal })\n return parsePayloadResponse<unknown>(response, text, method)\n }\n}\n\nfunction pinReadOptions(options: RestPublicPayloadsReadOptions): RestPublicPayloadsReadOptions {\n const { maxResponseBytes, signal } = options\n if (maxResponseBytes !== undefined && (!Number.isSafeInteger(maxResponseBytes) || maxResponseBytes <= 0)) {\n throw new RangeError('maxResponseBytes must be a positive safe integer')\n }\n signal?.throwIfAborted()\n return { maxResponseBytes, signal }\n}\n\nfunction publicRequestBase(baseUrl: string): string {\n let parsed: URL\n try {\n parsed = new URL(baseUrl)\n } catch {\n throw new TypeError('baseUrl must be an absolute HTTP(S) URL')\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new TypeError('baseUrl must be an absolute HTTP(S) URL')\n }\n if (parsed.username !== '' || parsed.password !== '') {\n throw new TypeError('Public data-plane URLs must not contain credentials')\n }\n if (parsed.href.includes('#')) throw new TypeError('Public data-plane URLs must not contain fragments')\n return extractRequestBase(baseUrl)\n}\n\nfunction isStoredPayload(value: unknown): value is WithStorageMeta<Payload> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const payload = value as Record<string, unknown>\n return ['schema', '_hash', '_dataHash', '_sequence'].every(key => Object.hasOwn(payload, key) && typeof payload[key] === 'string')\n}\n", "export type {\n AuthTokenRequest, AuthTokenSource, AuthTokenSupplier,\n} from './AuthToken.ts'\nexport type {\n CreateDatalakeRequest,\n DatalakeClient,\n GrantRequest,\n RevokeRequest,\n TokenRequest,\n} from './DatalakeClient.ts'\nexport type {\n DatalakeUsageReport,\n PayloadsAuthTokenSource,\n PayloadsClient,\n RestPayloadsClientOptions,\n} from './PayloadsClient.ts'\nexport { RestPayloadsClient } from './PayloadsClient.ts'\nexport type { RestDatalakeClientOptions } from './RestDatalakeClient.ts'\nexport { RestDatalakeClient } from './RestDatalakeClient.ts'\nexport type { RestPublicPayloadsReaderOptions, RestPublicPayloadsReadOptions } from './RestPublicPayloadsReader.ts'\nexport { RestPublicPayloadsReader } from './RestPublicPayloadsReader.ts'\nexport * from '@ariestools/aries-datalake-core/browser'\n"],
|
|
5
|
+
"mappings": ";AAWA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACRP,eAAsB,iBAAiB,QAAyB,UAAmC;AACjG,SAAO,OAAO,WAAW,aAAa,MAAM,OAAO,EAAE,SAAS,CAAC,IAAI;AACrE;;;ACfA,SAAS,sBAAsB,wBAAwB;AAShD,SAAS,mBAAmB,qBAAqC;AACtE,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,mBAAmB;AAC1C,UAAM,YAAY,IAAI,oBAAoB;AAC1C,UAAM,cAAc,OAAO,SAAS,QAAQ,SAAS;AACrD,UAAM,SAAS,gBAAgB,KAC3B,OAAO,SAAS,QAAQ,OAAO,EAAE,IACjC,OAAO,SAAS,MAAM,GAAG,WAAW;AACxC,WAAO,GAAG,OAAO,QAAQ,KAAK,OAAO,IAAI,GAAG,MAAM;AAAA,EACpD,QAAQ;AACN,WAAO,oBAAoB,QAAQ,OAAO,EAAE;AAAA,EAC9C;AACF;AAGO,SAAS,qBAAwB,UAAoB,MAAc,QAAmB;AAC3F,QAAM,UAAmB,KAAK,SAAS,IAAI,KAAK,MAAM,IAAI,IAAI;AAE9D,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,YAA0B,eAAe,OAAO,IAClD,UACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS,gBAAgB,SAAS,SAAS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;AAAA,EACzE;AACA,UAAQ,eAAe;AACvB,SAAO,EAAE,kBAAkB,OAAO;AACpC;AAEA,SAAS,kBAAkB,SAAyB;AAClD,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,OAAO;AAAA,EAC1B,QAAQ;AACN,UAAM,IAAI,UAAU,yCAAyC;AAAA,EAC/D;AACA,MAAI,OAAO,aAAa,WAAW,OAAO,aAAa,UAAU;AAC/D,UAAM,IAAI,UAAU,yCAAyC;AAAA,EAC/D;AACA,MAAI,OAAO,aAAa,MAAM,OAAO,aAAa,IAAI;AACpD,UAAM,IAAI,UAAU,qDAAqD;AAAA,EAC3E;AACA,MAAI,OAAO,KAAK,SAAS,GAAG,EAAG,OAAM,IAAI,UAAU,mDAAmD;AACtG,SAAO,mBAAmB,OAAO;AACnC;AAEA,SAAS,gBAAgB,OAAmD;AAC1E,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,UAAU;AAChB,SAAO,CAAC,UAAU,SAAS,aAAa,WAAW,EAAE,MAAM,SAAO,OAAO,OAAO,SAAS,GAAG,KAAK,OAAO,QAAQ,GAAG,MAAM,QAAQ;AACnI;;;AC9FA,cAAc;",
|
|
6
|
+
"names": ["DatalakeApiError", "isApiErrorBody", "DatalakeApiError", "datalakePlaneGetManyPath", "datalakePlaneGetPath", "datalakePlaneGetPath", "datalakePlaneGetManyPath"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadsClient.d.ts","sourceRoot":"","sources":["../../src/PayloadsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"PayloadsClient.d.ts","sourceRoot":"","sources":["../../src/PayloadsClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,oBAAoB,EACpB,mBAAmB,EAEnB,kBAAkB,EAClB,OAAO,EACP,eAAe,EAChB,MAAM,yCAAyC,CA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C,EAAE,OAAO,KAAK,CAAA;CACzB;AAYD,qBAAa,kBAAmB,YAAW,cAAc;IACvD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;gBAExB,OAAO,EAAE,yBAAyB;IAOxC,KAAK,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAOrC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAIpD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;IAQ9D,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAY1D,IAAI,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAepE,KAAK,IAAI,OAAO,CAAC,mBAAmB,CAAC;YAI7B,OAAO;YAKP,kBAAkB;CAuBjC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Payload, WithStorageMeta } from '@ariestools/aries-datalake-core/browser';
|
|
2
|
+
/** Policy for one public HTTP response, including its JSON envelope and metadata. */
|
|
3
|
+
export interface RestPublicPayloadsReadOptions {
|
|
4
|
+
/**
|
|
5
|
+
Positive safe-integer limit on decoded Fetch-body bytes before JSON parsing.
|
|
6
|
+
Omission leaves the body size unlimited; this is not a raw network-byte limit.
|
|
7
|
+
*/
|
|
8
|
+
readonly maxResponseBytes?: number;
|
|
9
|
+
/** Caller cancellation remains active through response-body consumption. */
|
|
10
|
+
readonly signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface RestPublicPayloadsReaderOptions {
|
|
13
|
+
/** Absolute HTTP(S) data-plane URL, optionally including its API path prefix. */
|
|
14
|
+
readonly baseUrl: string;
|
|
15
|
+
/** Datalake id used to regenerate the canonical native data-plane paths. */
|
|
16
|
+
readonly datalakeId: string;
|
|
17
|
+
/**
|
|
18
|
+
Trusted transport override. It must preserve the public no-credentials and
|
|
19
|
+
no-redirect policy and honor cancellation. Defaults to request-time global fetch.
|
|
20
|
+
*/
|
|
21
|
+
readonly fetchImpl?: typeof fetch;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Exact-hash reads using the native data-plane protocol without token handling.
|
|
25
|
+
* The server must grant public viewer access. Public access applies to the whole
|
|
26
|
+
* lake; this reader neither grants access nor falls back from authenticated I/O.
|
|
27
|
+
* Returned metadata is structural transport data, not verified content identity.
|
|
28
|
+
*/
|
|
29
|
+
export declare class RestPublicPayloadsReader {
|
|
30
|
+
private readonly datalakeId;
|
|
31
|
+
private readonly fetchImpl?;
|
|
32
|
+
private readonly requestBase;
|
|
33
|
+
constructor(options: RestPublicPayloadsReaderOptions);
|
|
34
|
+
get(hash: string, options?: RestPublicPayloadsReadOptions): Promise<WithStorageMeta<Payload>>;
|
|
35
|
+
getMany(hashes: readonly string[], options?: RestPublicPayloadsReadOptions): Promise<WithStorageMeta<Payload>[]>;
|
|
36
|
+
private request;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=RestPublicPayloadsReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RestPublicPayloadsReader.d.ts","sourceRoot":"","sources":["../../src/RestPublicPayloadsReader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAA;AAMvF,qFAAqF;AACrF,MAAM,WAAW,6BAA6B;IAC5C;;;MAGE;IACF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAC9B;AAED,MAAM,WAAW,+BAA+B;IAC9C,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B;;;MAGE;IACF,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CAClC;AAED;;;;;GAKG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAc;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;gBAExB,OAAO,EAAE,+BAA+B;IAM9C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,6BAAkC,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAMjG,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,GAAE,6BAAkC,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;YAW5G,OAAO;CAoBtB"}
|
package/dist/node/browser.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export type { DatalakeUsageReport, PayloadsAuthTokenSource, PayloadsClient, Rest
|
|
|
4
4
|
export { RestPayloadsClient } from './PayloadsClient.ts';
|
|
5
5
|
export type { RestDatalakeClientOptions } from './RestDatalakeClient.ts';
|
|
6
6
|
export { RestDatalakeClient } from './RestDatalakeClient.ts';
|
|
7
|
+
export type { RestPublicPayloadsReaderOptions, RestPublicPayloadsReadOptions } from './RestPublicPayloadsReader.ts';
|
|
8
|
+
export { RestPublicPayloadsReader } from './RestPublicPayloadsReader.ts';
|
|
7
9
|
export * from '@ariestools/aries-datalake-core/browser';
|
|
8
10
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,GACrD,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,cAAc,yCAAyC,CAAA"}
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,GACrD,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,YAAY,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAA;AACnH,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,cAAc,yCAAyC,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -10,4 +10,6 @@ export type { DatalakeUsageReport, PayloadsAuthTokenSource, PayloadsClient, Rest
|
|
|
10
10
|
export { RestPayloadsClient } from './PayloadsClient.ts';
|
|
11
11
|
export type { RestDatalakeClientOptions } from './RestDatalakeClient.ts';
|
|
12
12
|
export { RestDatalakeClient } from './RestDatalakeClient.ts';
|
|
13
|
+
export type { RestPublicPayloadsReaderOptions, RestPublicPayloadsReadOptions } from './RestPublicPayloadsReader.ts';
|
|
14
|
+
export { RestPublicPayloadsReader } from './RestPublicPayloadsReader.ts';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,GACrD,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC/E,OAAO,EACL,gBAAgB,EAAE,sBAAsB,EAAE,eAAe,EAAE,eAAe,GAC3E,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,GAC7D,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACrF,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,GACrD,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC/E,OAAO,EACL,gBAAgB,EAAE,sBAAsB,EAAE,eAAe,EAAE,eAAe,GAC3E,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,GAC7D,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACrF,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,YAAY,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAA;AACnH,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -362,11 +362,9 @@ function clearDefaultDatalake() {
|
|
|
362
362
|
|
|
363
363
|
// src/PayloadsClient.ts
|
|
364
364
|
import {
|
|
365
|
-
DATALAKE_API_VERSION,
|
|
366
365
|
DATALAKE_HEADER_DUPLICATES,
|
|
367
366
|
DATALAKE_HEADER_NEXT_CURSOR,
|
|
368
367
|
DATALAKE_HEADER_REJECTED,
|
|
369
|
-
DatalakeApiError as DatalakeApiError2,
|
|
370
368
|
datalakePlaneClearPath,
|
|
371
369
|
datalakePlaneDeletePath,
|
|
372
370
|
datalakePlaneGetManyPath,
|
|
@@ -375,6 +373,9 @@ import {
|
|
|
375
373
|
datalakePlaneNextPath,
|
|
376
374
|
datalakePlaneUsagePath
|
|
377
375
|
} from "@ariestools/aries-datalake-core/browser";
|
|
376
|
+
|
|
377
|
+
// src/payloadRequest.ts
|
|
378
|
+
import { DATALAKE_API_VERSION, DatalakeApiError as DatalakeApiError2 } from "@ariestools/aries-datalake-core/browser";
|
|
378
379
|
function extractRequestBase(urlWithPossiblePath) {
|
|
379
380
|
try {
|
|
380
381
|
const parsed = new URL(urlWithPossiblePath);
|
|
@@ -386,6 +387,24 @@ function extractRequestBase(urlWithPossiblePath) {
|
|
|
386
387
|
return urlWithPossiblePath.replace(/\/$/, "");
|
|
387
388
|
}
|
|
388
389
|
}
|
|
390
|
+
function parsePayloadResponse(response, text, method) {
|
|
391
|
+
const payload = text.length > 0 ? JSON.parse(text) : void 0;
|
|
392
|
+
if (!response.ok) {
|
|
393
|
+
const errorBody = isApiErrorBody2(payload) ? payload : {
|
|
394
|
+
code: "internal",
|
|
395
|
+
message: "Unexpected " + response.status + " response from " + method + " data plane"
|
|
396
|
+
};
|
|
397
|
+
throw new DatalakeApiError2(response.status, errorBody);
|
|
398
|
+
}
|
|
399
|
+
return payload;
|
|
400
|
+
}
|
|
401
|
+
function isApiErrorBody2(value) {
|
|
402
|
+
if (typeof value !== "object" || value === null) return false;
|
|
403
|
+
const maybe = value;
|
|
404
|
+
return typeof maybe.code === "string" && typeof maybe.message === "string";
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// src/PayloadsClient.ts
|
|
389
408
|
var RestPayloadsClient = class {
|
|
390
409
|
authToken;
|
|
391
410
|
datalakeId;
|
|
@@ -469,15 +488,7 @@ var RestPayloadsClient = class {
|
|
|
469
488
|
const response = await this.fetchImpl(`${this.requestBase}${path4}`, init);
|
|
470
489
|
if (response.status === 204) return { data: void 0, headers: response.headers };
|
|
471
490
|
const text = await response.text();
|
|
472
|
-
|
|
473
|
-
if (!response.ok) {
|
|
474
|
-
const errorBody = isApiErrorBody2(payload) ? payload : {
|
|
475
|
-
code: "internal",
|
|
476
|
-
message: `Unexpected ${response.status} response from ${method} data plane`
|
|
477
|
-
};
|
|
478
|
-
throw new DatalakeApiError2(response.status, errorBody);
|
|
479
|
-
}
|
|
480
|
-
return { data: payload, headers: response.headers };
|
|
491
|
+
return { data: parsePayloadResponse(response, text, method), headers: response.headers };
|
|
481
492
|
}
|
|
482
493
|
};
|
|
483
494
|
function readInsertSummary(headers) {
|
|
@@ -490,15 +501,89 @@ function readInsertSummary(headers) {
|
|
|
490
501
|
rejected
|
|
491
502
|
};
|
|
492
503
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
504
|
+
|
|
505
|
+
// src/RestPublicPayloadsReader.ts
|
|
506
|
+
import { datalakePlaneGetManyPath as datalakePlaneGetManyPath2, datalakePlaneGetPath as datalakePlaneGetPath2 } from "@ariestools/aries-datalake-core/browser";
|
|
507
|
+
import { readResponseText } from "@ariestools/sdk/fetch";
|
|
508
|
+
var RestPublicPayloadsReader = class {
|
|
509
|
+
datalakeId;
|
|
510
|
+
fetchImpl;
|
|
511
|
+
requestBase;
|
|
512
|
+
constructor(options) {
|
|
513
|
+
this.requestBase = publicRequestBase(options.baseUrl);
|
|
514
|
+
this.datalakeId = options.datalakeId;
|
|
515
|
+
this.fetchImpl = options.fetchImpl;
|
|
516
|
+
}
|
|
517
|
+
async get(hash, options = {}) {
|
|
518
|
+
const payload = await this.request(datalakePlaneGetPath2(this.datalakeId, hash), options);
|
|
519
|
+
if (!isStoredPayload(payload)) throw new TypeError("Data plane returned an invalid stored payload");
|
|
520
|
+
return payload;
|
|
521
|
+
}
|
|
522
|
+
async getMany(hashes, options = {}) {
|
|
523
|
+
const policy = pinReadOptions(options);
|
|
524
|
+
const requested = [...hashes];
|
|
525
|
+
if (requested.length === 0) return [];
|
|
526
|
+
const payloads = await this.request(datalakePlaneGetManyPath2(this.datalakeId), policy, requested);
|
|
527
|
+
if (!Array.isArray(payloads) || !payloads.every(isStoredPayload)) {
|
|
528
|
+
throw new TypeError("Data plane returned an invalid stored-payload array");
|
|
529
|
+
}
|
|
530
|
+
return payloads;
|
|
531
|
+
}
|
|
532
|
+
async request(path4, options, hashes) {
|
|
533
|
+
const { maxResponseBytes, signal } = pinReadOptions(options);
|
|
534
|
+
const method = hashes === void 0 ? "GET" : "POST";
|
|
535
|
+
const headers = { accept: "application/json" };
|
|
536
|
+
const init = {
|
|
537
|
+
credentials: "omit",
|
|
538
|
+
headers,
|
|
539
|
+
method,
|
|
540
|
+
redirect: "error",
|
|
541
|
+
signal
|
|
542
|
+
};
|
|
543
|
+
if (hashes !== void 0) {
|
|
544
|
+
headers["content-type"] = "application/json";
|
|
545
|
+
init.body = JSON.stringify(hashes);
|
|
546
|
+
}
|
|
547
|
+
const fetchImpl = this.fetchImpl ?? globalThis.fetch;
|
|
548
|
+
const response = await fetchImpl(this.requestBase + path4, init);
|
|
549
|
+
const text = await readResponseText(response, { maxResponseBytes, signal });
|
|
550
|
+
return parsePayloadResponse(response, text, method);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
function pinReadOptions(options) {
|
|
554
|
+
const { maxResponseBytes, signal } = options;
|
|
555
|
+
if (maxResponseBytes !== void 0 && (!Number.isSafeInteger(maxResponseBytes) || maxResponseBytes <= 0)) {
|
|
556
|
+
throw new RangeError("maxResponseBytes must be a positive safe integer");
|
|
557
|
+
}
|
|
558
|
+
signal?.throwIfAborted();
|
|
559
|
+
return { maxResponseBytes, signal };
|
|
560
|
+
}
|
|
561
|
+
function publicRequestBase(baseUrl) {
|
|
562
|
+
let parsed;
|
|
563
|
+
try {
|
|
564
|
+
parsed = new URL(baseUrl);
|
|
565
|
+
} catch {
|
|
566
|
+
throw new TypeError("baseUrl must be an absolute HTTP(S) URL");
|
|
567
|
+
}
|
|
568
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
569
|
+
throw new TypeError("baseUrl must be an absolute HTTP(S) URL");
|
|
570
|
+
}
|
|
571
|
+
if (parsed.username !== "" || parsed.password !== "") {
|
|
572
|
+
throw new TypeError("Public data-plane URLs must not contain credentials");
|
|
573
|
+
}
|
|
574
|
+
if (parsed.href.includes("#")) throw new TypeError("Public data-plane URLs must not contain fragments");
|
|
575
|
+
return extractRequestBase(baseUrl);
|
|
576
|
+
}
|
|
577
|
+
function isStoredPayload(value) {
|
|
578
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
579
|
+
const payload = value;
|
|
580
|
+
return ["schema", "_hash", "_dataHash", "_sequence"].every((key) => Object.hasOwn(payload, key) && typeof payload[key] === "string");
|
|
497
581
|
}
|
|
498
582
|
export {
|
|
499
583
|
LocalDatalakeClient,
|
|
500
584
|
RestDatalakeClient,
|
|
501
585
|
RestPayloadsClient,
|
|
586
|
+
RestPublicPayloadsReader,
|
|
502
587
|
clearCredentials,
|
|
503
588
|
clearDefaultDatalake,
|
|
504
589
|
createDatalakeClient,
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/credentials.ts", "../../src/paths.ts", "../../src/LocalDatalakeClient.ts", "../../src/RestDatalakeClient.ts", "../../src/AuthToken.ts", "../../src/createDatalakeClient.ts", "../../src/defaultDatalake.ts", "../../src/PayloadsClient.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n chmodSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync,\n} from 'node:fs'\nimport path from 'node:path'\n\nimport { getAriesHome, getCredentialsPath } from './paths.ts'\n\n/**\n * Hints for self-signed wallet-JWT mode. When present, the CLI is expected to\n * mint a fresh ES256K JWT per request using the active aries wallet. The\n * server-side `authToken` field is unused in this mode.\n */\nexport interface WalletJwtCredentials {\n /**\n `aud` claim to use for control-plane calls (default `aries-datalake-control`).\n */\n controlAudience?: string\n /**\n Derivation offset of the signing account (default `'0'`).\n */\n offset?: string\n /**\n TTL (seconds) for each minted JWT (default `120`).\n */\n ttlSeconds?: number\n}\n\nexport interface StoredCredentials {\n /**\n * Static bearer token for legacy/static-token mode. Absent when `walletJwt`\n * mode is configured \u2014 the CLI mints a token per request instead.\n */\n authToken?: string\n baseUrl: string\n /**\n ISO-8601 expiration of the access token.\n */\n expiresAt?: string\n /**\n Optional refresh token for long-lived sessions.\n */\n refreshToken?: string\n userId?: string\n /**\n Wallet-JWT mode hints. When set, the CLI mints self-signed JWTs.\n */\n walletJwt?: WalletJwtCredentials\n}\n\nexport function saveCredentials(credentials: StoredCredentials): void {\n const home = getAriesHome()\n if (!existsSync(home)) mkdirSync(home, { recursive: true })\n const filePath = getCredentialsPath()\n writeFileSync(filePath, JSON.stringify(credentials, undefined, 2), 'utf8')\n try {\n chmodSync(filePath, 0o600)\n } catch {\n // chmod can fail on some filesystems (e.g. Windows); tolerate silently.\n }\n}\n\nexport function loadCredentials(): StoredCredentials | undefined {\n const filePath = getCredentialsPath()\n if (!existsSync(filePath)) return undefined\n try {\n const raw = readFileSync(filePath, 'utf8')\n return JSON.parse(raw) as StoredCredentials\n } catch {\n return undefined\n }\n}\n\nexport function clearCredentials(): void {\n const filePath = getCredentialsPath()\n if (existsSync(filePath)) unlinkSync(filePath)\n}\n\nexport function getCredentialsLocation(): string {\n return path.resolve(getCredentialsPath())\n}\n", "import { homedir } from 'node:os'\nimport path from 'node:path'\n\n/**\n * Root directory for all Aries state (credentials, local datalake stub, etc.).\n * Overridable via `ARIES_HOME` so tests can redirect to a temp dir.\n */\nexport function getAriesHome(): string {\n return process.env.ARIES_HOME ?? path.join(homedir(), '.aries')\n}\n\nexport function getDatalakeStoreDir(): string {\n return path.join(getAriesHome(), 'datalakes')\n}\n\n/**\n * JSON file backing the `LocalDatalakeClient`. A lightweight substitute for\n * the real control plane during P0 development.\n */\nexport function getLocalDatalakeStorePath(): string {\n return path.join(getDatalakeStoreDir(), 'local-store.json')\n}\n\nexport function getCredentialsPath(): string {\n return path.join(getAriesHome(), 'credentials.json')\n}\n\nexport function getDefaultDatalakePath(): string {\n return path.join(getAriesHome(), 'datalake-default.json')\n}\n", "import {\n existsSync, mkdirSync, readFileSync, writeFileSync,\n} from 'node:fs'\nimport path from 'node:path'\n\nimport type {\n DatalakeDescriptor,\n DatalakeTier,\n DatalakeToken,\n} from '@ariestools/aries-datalake-core'\n\nimport type {\n CreateDatalakeRequest,\n DatalakeClient,\n GrantRequest,\n RevokeRequest,\n TokenRequest,\n} from './DatalakeClient.ts'\nimport { getDatalakeStoreDir, getLocalDatalakeStorePath } from './paths.ts'\n\ninterface LocalStore {\n datalakes: DatalakeDescriptor[]\n}\n\nconst LOCAL_OWNER_ID = 'local-user'\n\nconst TIER_SIZE_DEFAULTS: Record<DatalakeTier, number> = {\n small: 10 * 1024 * 1024 * 1024,\n medium: 100 * 1024 * 1024 * 1024,\n large: 1024 * 1024 * 1024 * 1024,\n archive: 10 * 1024 * 1024 * 1024 * 1024,\n}\n\nconst TIER_IOPS_DEFAULTS: Record<DatalakeTier, number> = {\n small: 500,\n medium: 2000,\n large: 10_000,\n archive: 0,\n}\n\nfunction readStore(): LocalStore {\n const filePath = getLocalDatalakeStorePath()\n if (!existsSync(filePath)) return { datalakes: [] }\n try {\n const raw = readFileSync(filePath, 'utf8')\n return JSON.parse(raw) as LocalStore\n } catch {\n return { datalakes: [] }\n }\n}\n\nfunction writeStore(store: LocalStore): void {\n const dir = getDatalakeStoreDir()\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n writeFileSync(getLocalDatalakeStorePath(), JSON.stringify(store, undefined, 2), 'utf8')\n}\n\nfunction generateId(): string {\n return `dl_${Math.random().toString(36).slice(2, 10)}${Date.now().toString(36)}`\n}\n\nfunction findDatalake(store: LocalStore, idOrName: string): DatalakeDescriptor | undefined {\n return store.datalakes.find(dl => dl.id === idOrName || dl.name === idOrName)\n}\n\nfunction requireDatalake(store: LocalStore, idOrName: string): DatalakeDescriptor {\n const found = findDatalake(store, idOrName)\n if (!found) throw new Error(`Datalake not found: ${idOrName}`)\n return found\n}\n\n/**\n * Filesystem-backed stub implementation of `DatalakeClient` used during P0\n * development. Pretends to provision datalakes instantly, persists metadata\n * to `~/.aries/datalakes/local-store.json`, and mints opaque non-JWT tokens.\n *\n * Not suitable for production use \u2014 replace with `RestDatalakeClient` once\n * the control plane is live.\n */\nexport class LocalDatalakeClient implements DatalakeClient {\n async create(request: CreateDatalakeRequest): Promise<DatalakeDescriptor> {\n const store = readStore()\n if (store.datalakes.some(dl => dl.name === request.name)) {\n throw new Error(`Datalake already exists: ${request.name}`)\n }\n\n const now = new Date().toISOString()\n const tier = request.config.tier\n const descriptor: DatalakeDescriptor = {\n id: generateId(),\n name: request.name,\n ownerId: LOCAL_OWNER_ID,\n config: {\n tier,\n sizeBytes: request.config.sizeBytes ?? TIER_SIZE_DEFAULTS[tier],\n iops: request.config.iops ?? TIER_IOPS_DEFAULTS[tier],\n retentionDays: request.config.retentionDays ?? 30,\n region: request.config.region ?? 'us-west-2',\n allowedSchemas: request.config.allowedSchemas ?? [],\n disallowedSchemas: request.config.disallowedSchemas ?? [],\n },\n status: 'ready',\n url: `http://localhost:8080/datalakes/${request.name}`,\n acl: [],\n usage: {\n payloadCount: 0,\n bytesStored: 0,\n bytesStoredLimit: request.config.sizeBytes ?? TIER_SIZE_DEFAULTS[tier],\n readsLast24h: 0,\n writesLast24h: 0,\n },\n createdAt: now,\n updatedAt: now,\n }\n\n store.datalakes.push(descriptor)\n writeStore(store)\n return descriptor\n }\n\n async describe(idOrName: string): Promise<DatalakeDescriptor> {\n const store = readStore()\n return requireDatalake(store, idOrName)\n }\n\n async destroy(idOrName: string): Promise<void> {\n const store = readStore()\n const found = findDatalake(store, idOrName)\n if (!found) throw new Error(`Datalake not found: ${idOrName}`)\n store.datalakes = store.datalakes.filter(dl => dl.id !== found.id)\n writeStore(store)\n }\n\n async grant(request: GrantRequest): Promise<DatalakeDescriptor> {\n const store = readStore()\n const datalake = requireDatalake(store, request.datalakeId)\n const existing = datalake.acl.findIndex(entry => entry.principal === request.principal)\n const entry = {\n principal: request.principal,\n role: request.role,\n grantedAt: new Date().toISOString(),\n grantedBy: LOCAL_OWNER_ID,\n }\n if (existing === -1) {\n datalake.acl.push(entry)\n } else {\n datalake.acl[existing] = entry\n }\n datalake.updatedAt = entry.grantedAt\n writeStore(store)\n return datalake\n }\n\n async list(): Promise<DatalakeDescriptor[]> {\n return readStore().datalakes\n }\n\n async mintToken(request: TokenRequest): Promise<DatalakeToken> {\n const store = readStore()\n const datalake = requireDatalake(store, request.datalakeId)\n const ttl = request.ttlSeconds ?? 3600\n const issued = Buffer.from(\n JSON.stringify({\n dl: datalake.id,\n role: request.role,\n exp: Math.floor(Date.now() / 1000) + ttl,\n }),\n ).toString('base64url')\n return {\n token: `local.${issued}`,\n datalakeId: datalake.id,\n role: request.role,\n expiresAt: new Date(Date.now() + ttl * 1000).toISOString(),\n url: datalake.url ?? `http://localhost:8080/datalakes/${datalake.name}`,\n }\n }\n\n async revoke(request: RevokeRequest): Promise<DatalakeDescriptor> {\n const store = readStore()\n const datalake = requireDatalake(store, request.datalakeId)\n datalake.acl = datalake.acl.filter(entry => entry.principal !== request.principal)\n datalake.updatedAt = new Date().toISOString()\n writeStore(store)\n return datalake\n }\n}\n\n/**\n * Convenience: the absolute path where the local store persists state.\n * Useful in tests and for `aries datalake describe --debug`.\n */\nexport function getLocalStoreLocation(): string {\n return path.resolve(getLocalDatalakeStorePath())\n}\n", "import type {\n ApiErrorBody,\n CreateDatalakeBody,\n DatalakeDescriptor,\n DatalakeToken,\n GrantBody,\n MintTokenBody,\n} from '@ariestools/aries-datalake-core/browser'\nimport {\n DATALAKE_CONTROL_AUDIENCE,\n DatalakeApiError,\n datalakeCollectionPath,\n datalakeGrantPath,\n datalakeGrantsPath,\n datalakeResourcePath,\n datalakeTokensPath,\n} from '@ariestools/aries-datalake-core/browser'\n\nimport type { AuthTokenSource } from './AuthToken.ts'\nimport { resolveAuthToken } from './AuthToken.ts'\nimport type {\n CreateDatalakeRequest,\n DatalakeClient,\n GrantRequest,\n RevokeRequest,\n TokenRequest,\n} from './DatalakeClient.ts'\n\nexport interface RestDatalakeClientOptions {\n /**\n Exact control-plane JWT audience.\n */\n audience?: string\n /**\n Static token, or async factory minted per-request.\n */\n authToken: AuthTokenSource\n /**\n Control-plane base URL, e.g. `https://dl-control.xylabs.io`.\n */\n baseUrl: string\n /**\n Optional `fetch` override; defaults to global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\ninterface RequestOptions {\n body?: unknown\n method?: string\n}\n\n/**\n * HTTP client for the datalake control plane. Implements the stable\n * `DatalakeClient` contract so callers are independent of transport.\n */\nexport class RestDatalakeClient implements DatalakeClient {\n private readonly audience: string\n private readonly authToken: AuthTokenSource\n private readonly baseUrl: string\n private readonly fetchImpl: typeof fetch\n\n constructor(options: RestDatalakeClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '')\n this.audience = options.audience ?? DATALAKE_CONTROL_AUDIENCE\n this.authToken = options.authToken\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async create(request: CreateDatalakeRequest): Promise<DatalakeDescriptor> {\n const body: CreateDatalakeBody = { name: request.name, config: request.config }\n return this.request<DatalakeDescriptor>(datalakeCollectionPath(), { method: 'POST', body })\n }\n\n async describe(idOrName: string): Promise<DatalakeDescriptor> {\n return this.request<DatalakeDescriptor>(datalakeResourcePath(idOrName))\n }\n\n async destroy(idOrName: string): Promise<void> {\n await this.request<void>(datalakeResourcePath(idOrName), { method: 'DELETE' })\n }\n\n async grant(request: GrantRequest): Promise<DatalakeDescriptor> {\n const body: GrantBody = { principal: request.principal, role: request.role }\n return this.request<DatalakeDescriptor>(\n datalakeGrantsPath(request.datalakeId),\n { method: 'POST', body },\n )\n }\n\n async list(): Promise<DatalakeDescriptor[]> {\n return this.request<DatalakeDescriptor[]>(datalakeCollectionPath())\n }\n\n async mintToken(request: TokenRequest): Promise<DatalakeToken> {\n const body: MintTokenBody = { role: request.role, ttlSeconds: request.ttlSeconds }\n return this.request<DatalakeToken>(\n datalakeTokensPath(request.datalakeId),\n { method: 'POST', body },\n )\n }\n\n async revoke(request: RevokeRequest): Promise<DatalakeDescriptor> {\n return this.request<DatalakeDescriptor>(\n datalakeGrantPath(request.datalakeId, request.principal),\n { method: 'DELETE' },\n )\n }\n\n private async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const url = `${this.baseUrl}${path}`\n const method = options.method ?? 'GET'\n const token = await resolveAuthToken(this.authToken, this.audience)\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n }\n if (options.body !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(options.body)\n }\n\n const response = await this.fetchImpl(url, init)\n if (response.status === 204) {\n return undefined as T\n }\n const text = await response.text()\n const payload: unknown = text.length > 0 ? JSON.parse(text) : undefined\n\n if (!response.ok) {\n const errorBody: ApiErrorBody = isApiErrorBody(payload)\n ? payload\n : {\n code: 'internal',\n message: `Unexpected ${response.status} response from ${method} control plane`,\n }\n throw new DatalakeApiError(response.status, errorBody)\n }\n return payload as T\n }\n}\n\nfunction isApiErrorBody(value: unknown): value is ApiErrorBody {\n if (typeof value !== 'object' || value === null) return false\n const maybe = value as Record<string, unknown>\n return typeof maybe.code === 'string' && typeof maybe.message === 'string'\n}\n", "export interface AuthTokenRequest {\n /**\n Exact JWT audience required by the target service or datalake.\n */\n audience: string\n}\n\n/**\nInvoked for every request so callers can obtain a fresh wallet JWT.\n*/\nexport type AuthTokenSupplier = (request: AuthTokenRequest) => Promise<string>\n\nexport type AuthTokenSource = AuthTokenSupplier | string\n\nexport async function resolveAuthToken(source: AuthTokenSource, audience: string): Promise<string> {\n return typeof source === 'function' ? await source({ audience }) : source\n}\n", "import type { AuthTokenSource } from './AuthToken.ts'\nimport { loadCredentials } from './credentials.ts'\nimport type { DatalakeClient } from './DatalakeClient.ts'\nimport { LocalDatalakeClient } from './LocalDatalakeClient.ts'\nimport { RestDatalakeClient } from './RestDatalakeClient.ts'\n\nexport interface CreateDatalakeClientOptions {\n /**\n * Override the auth token (otherwise read from credentials). Accepts either\n * a static bearer string or an async factory \u2014 pass a factory when minting\n * self-signed wallet JWTs per request.\n */\n authToken?: AuthTokenSource\n /**\n Override the control-plane URL (otherwise read from env / credentials).\n */\n baseUrl?: string\n /**\n * Force a specific driver. Defaults to:\n * - `rest` when `ARIES_DATALAKE_API` is set or credentials are present\n * - `local` otherwise\n */\n driver?: 'local' | 'rest'\n}\n\n/**\n * Returns a `DatalakeClient` wired for the current environment. The CLI uses\n * this factory so every command picks up the same resolution rules.\n */\nexport function createDatalakeClient(options: CreateDatalakeClientOptions = {}): DatalakeClient {\n const envBaseUrl = process.env.ARIES_DATALAKE_API\n const credentials = loadCredentials()\n const baseUrl = options.baseUrl ?? envBaseUrl ?? credentials?.baseUrl\n const authToken: AuthTokenSource | undefined = options.authToken ?? credentials?.authToken\n\n const driver = options.driver\n ?? (baseUrl && authToken ? 'rest' : 'local')\n\n if (driver === 'rest') {\n if (!baseUrl || !authToken) {\n throw new Error(\n 'REST driver requires a baseUrl and authToken. '\n + 'Run `aries datalake login` or set ARIES_DATALAKE_API and sign in.',\n )\n }\n return new RestDatalakeClient({ baseUrl, authToken })\n }\n\n return new LocalDatalakeClient()\n}\n", "import {\n existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync,\n} from 'node:fs'\n\nimport { getAriesHome, getDefaultDatalakePath } from './paths.ts'\n\ninterface DefaultDatalakeFile {\n id?: string\n name: string\n setAt: string\n}\n\n/**\n * Remembers which datalake the user selected via `aries datalake use`. Read by\n * commands that accept an optional `<name>` and fall back to the default.\n */\nexport function setDefaultDatalake(name: string, id?: string): void {\n const home = getAriesHome()\n if (!existsSync(home)) mkdirSync(home, { recursive: true })\n const payload: DefaultDatalakeFile = {\n name, id, setAt: new Date().toISOString(),\n }\n writeFileSync(getDefaultDatalakePath(), JSON.stringify(payload, undefined, 2), 'utf8')\n}\n\nexport function getDefaultDatalake(): string | undefined {\n const filePath = getDefaultDatalakePath()\n if (!existsSync(filePath)) return undefined\n try {\n const raw = readFileSync(filePath, 'utf8')\n const parsed = JSON.parse(raw) as DefaultDatalakeFile\n return parsed.name\n } catch {\n return undefined\n }\n}\n\nexport function clearDefaultDatalake(): void {\n const filePath = getDefaultDatalakePath()\n if (existsSync(filePath)) unlinkSync(filePath)\n}\n", "import type {\n ApiErrorBody,\n DatalakeInsertSummary,\n InsertPayloadsBody,\n InsertPayloadsResponse,\n InsertPayloadsResult,\n NextPayloadsOptions,\n NextPayloadsResponse,\n NextPayloadsResult,\n Payload,\n WithStorageMeta,\n} from '@ariestools/aries-datalake-core/browser'\nimport {\n DATALAKE_API_VERSION,\n DATALAKE_HEADER_DUPLICATES,\n DATALAKE_HEADER_NEXT_CURSOR,\n DATALAKE_HEADER_REJECTED,\n DatalakeApiError,\n datalakePlaneClearPath,\n datalakePlaneDeletePath,\n datalakePlaneGetManyPath,\n datalakePlaneGetPath,\n datalakePlaneInsertPath,\n datalakePlaneNextPath,\n datalakePlaneUsagePath,\n} from '@ariestools/aries-datalake-core/browser'\n\nimport type { AuthTokenSource } from './AuthToken.ts'\nimport { resolveAuthToken } from './AuthToken.ts'\n\nexport interface DatalakeUsageReport {\n datalakeId: string\n payloadCount: number\n rateLimits?: {\n anonymous?: { limit: number; remaining: number }\n authenticated?: { limit: number; remaining: number }\n }\n}\n\n/**\n * HTTP client for a single datalake's data plane. Clients send bare\n * `Payload` objects (no `_hash` / `_dataHash` \u2014 those are stamped on\n * insert by the data plane's archivist). Responses always carry the\n * archivist-computed storage meta.\n *\n * Wire format mirrors the XYO archivist REST middleware: `/insert`,\n * `/get/:hash`, `/next`, bare arrays as bodies. Datalake-specific\n * extras (duplicates count, rejected hashes, next cursor) are delivered\n * via response headers.\n */\nexport interface PayloadsClient {\n clear(): Promise<{ removed: number }>\n delete(hash: string): Promise<void>\n get(hash: string): Promise<WithStorageMeta<Payload>>\n getMany(hashes: string[]): Promise<WithStorageMeta<Payload>[]>\n insert(payloads: Payload[]): Promise<InsertPayloadsResult>\n next(options?: NextPayloadsOptions): Promise<NextPayloadsResult>\n usage(): Promise<DatalakeUsageReport>\n}\n\n/**\n * Either a static bearer token, or a factory invoked per-request. The factory\n * form lets callers mint a fresh self-signed wallet JWT per call (with\n * `aud` bound to the datalake id).\n */\nexport type PayloadsAuthTokenSource = AuthTokenSource\n\nexport interface RestPayloadsClientOptions {\n /**\n Static bearer token, or async factory minted per-request.\n */\n authToken: PayloadsAuthTokenSource\n /**\n Data-plane base URL without trailing slash.\n */\n baseUrl: string\n /**\n Datalake id; appended to `/v1/datalakes/:id/...`.\n */\n datalakeId: string\n /**\n Optional `fetch` override; defaults to global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\ninterface RequestOptions {\n body?: unknown\n method?: string\n}\n\ninterface RequestResult<T> {\n data: T\n headers: Headers\n}\n\n/**\n * The data plane is typically addressed by a URL that already includes the\n * datalake id (e.g. `https://plane/v1/datalakes/dl_abc`). Preserve any path\n * prefix before `/v1/datalakes` so a shared ALB can expose the data plane at\n * `https://host/plane` while the path helpers regenerate the canonical API\n * suffix from the id.\n */\nfunction extractRequestBase(urlWithPossiblePath: string): string {\n try {\n const parsed = new URL(urlWithPossiblePath)\n const apiMarker = `/${DATALAKE_API_VERSION}/datalakes`\n const markerIndex = parsed.pathname.indexOf(apiMarker)\n const prefix = markerIndex === -1\n ? parsed.pathname.replace(/\\/$/, '')\n : parsed.pathname.slice(0, markerIndex)\n return `${parsed.protocol}//${parsed.host}${prefix}`\n } catch {\n return urlWithPossiblePath.replace(/\\/$/, '')\n }\n}\n\nexport class RestPayloadsClient implements PayloadsClient {\n private readonly authToken: PayloadsAuthTokenSource\n private readonly datalakeId: string\n private readonly fetchImpl: typeof fetch\n private readonly requestBase: string\n\n constructor(options: RestPayloadsClientOptions) {\n this.requestBase = extractRequestBase(options.baseUrl)\n this.datalakeId = options.datalakeId\n this.authToken = options.authToken\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async clear(): Promise<{ removed: number }> {\n return this.request<{ removed: number }>(\n datalakePlaneClearPath(this.datalakeId),\n { method: 'POST' },\n )\n }\n\n async delete(hash: string): Promise<void> {\n await this.request<void>(\n datalakePlaneDeletePath(this.datalakeId, hash),\n { method: 'DELETE' },\n )\n }\n\n async get(hash: string): Promise<WithStorageMeta<Payload>> {\n return this.request<WithStorageMeta<Payload>>(datalakePlaneGetPath(this.datalakeId, hash))\n }\n\n async getMany(hashes: string[]): Promise<WithStorageMeta<Payload>[]> {\n if (hashes.length === 0) return []\n return this.request<WithStorageMeta<Payload>[]>(\n datalakePlaneGetManyPath(this.datalakeId),\n { method: 'POST', body: hashes },\n )\n }\n\n async insert(payloads: Payload[]): Promise<InsertPayloadsResult> {\n const body: InsertPayloadsBody = payloads\n const { data, headers } = await this.requestWithHeaders<InsertPayloadsResponse>(\n datalakePlaneInsertPath(this.datalakeId),\n { method: 'POST', body },\n )\n return {\n inserted: data,\n summary: readInsertSummary(headers),\n }\n }\n\n async next(options: NextPayloadsOptions = {}): Promise<NextPayloadsResult> {\n const params = new URLSearchParams()\n if (options.limit !== undefined) params.set('limit', String(options.limit))\n if (options.cursor) params.set('cursor', options.cursor)\n if (options.schemas && options.schemas.length > 0) params.set('schemas', options.schemas.join(','))\n if (options.order) params.set('order', options.order)\n const suffix = params.toString()\n const path = suffix\n ? `${datalakePlaneNextPath(this.datalakeId)}?${suffix}`\n : datalakePlaneNextPath(this.datalakeId)\n const { data, headers } = await this.requestWithHeaders<NextPayloadsResponse>(path)\n const nextCursor = headers.get(DATALAKE_HEADER_NEXT_CURSOR) ?? undefined\n return { payloads: data, nextCursor }\n }\n\n async usage(): Promise<DatalakeUsageReport> {\n return this.request<DatalakeUsageReport>(datalakePlaneUsagePath(this.datalakeId))\n }\n\n private async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const { data } = await this.requestWithHeaders<T>(path, options)\n return data\n }\n\n private async requestWithHeaders<T>(path: string, options: RequestOptions = {}): Promise<RequestResult<T>> {\n const method = options.method ?? 'GET'\n const token = await resolveAuthToken(this.authToken, this.datalakeId)\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n }\n if (options.body !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(options.body)\n }\n\n const response = await this.fetchImpl(`${this.requestBase}${path}`, init)\n if (response.status === 204) return { data: undefined as T, headers: response.headers }\n const text = await response.text()\n const payload: unknown = text.length > 0 ? JSON.parse(text) : undefined\n\n if (!response.ok) {\n const errorBody: ApiErrorBody = isApiErrorBody(payload)\n ? payload\n : {\n code: 'internal',\n message: `Unexpected ${response.status} response from ${method} data plane`,\n }\n throw new DatalakeApiError(response.status, errorBody)\n }\n return { data: payload as T, headers: response.headers }\n }\n}\n\nfunction readInsertSummary(headers: Headers): DatalakeInsertSummary {\n const duplicatesRaw = headers.get(DATALAKE_HEADER_DUPLICATES)\n const duplicates = duplicatesRaw === null ? 0 : Number.parseInt(duplicatesRaw, 10)\n const rejectedRaw = headers.get(DATALAKE_HEADER_REJECTED)\n const rejected = rejectedRaw === null || rejectedRaw.length === 0\n ? []\n : rejectedRaw.split(',').map(value => value.trim()).filter(value => value.length > 0)\n return {\n duplicates: Number.isFinite(duplicates) ? duplicates : 0,\n rejected,\n }\n}\n\nfunction isApiErrorBody(value: unknown): value is ApiErrorBody {\n if (typeof value !== 'object' || value === null) return false\n const maybe = value as Record<string, unknown>\n return typeof maybe.code === 'string' && typeof maybe.message === 'string'\n}\n"],
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACE;AAAA,EAAW;AAAA,EAAY;AAAA,EAAW;AAAA,EAAc;AAAA,EAAY;AAAA,OACvD;AACP,OAAOA,WAAU;;;ACHjB,SAAS,eAAe;AACxB,OAAO,UAAU;AAMV,SAAS,eAAuB;AACrC,SAAO,QAAQ,IAAI,cAAc,KAAK,KAAK,QAAQ,GAAG,QAAQ;AAChE;AAEO,SAAS,sBAA8B;AAC5C,SAAO,KAAK,KAAK,aAAa,GAAG,WAAW;AAC9C;AAMO,SAAS,4BAAoC;AAClD,SAAO,KAAK,KAAK,oBAAoB,GAAG,kBAAkB;AAC5D;AAEO,SAAS,qBAA6B;AAC3C,SAAO,KAAK,KAAK,aAAa,GAAG,kBAAkB;AACrD;AAEO,SAAS,yBAAiC;AAC/C,SAAO,KAAK,KAAK,aAAa,GAAG,uBAAuB;AAC1D;;;ADoBO,SAAS,gBAAgB,aAAsC;AACpE,QAAM,OAAO,aAAa;AAC1B,MAAI,CAAC,WAAW,IAAI,EAAG,WAAU,MAAM,EAAE,WAAW,KAAK,CAAC;AAC1D,QAAM,WAAW,mBAAmB;AACpC,gBAAc,UAAU,KAAK,UAAU,aAAa,QAAW,CAAC,GAAG,MAAM;AACzE,MAAI;AACF,cAAU,UAAU,GAAK;AAAA,EAC3B,QAAQ;AAAA,EAER;AACF;AAEO,SAAS,kBAAiD;AAC/D,QAAM,WAAW,mBAAmB;AACpC,MAAI,CAAC,WAAW,QAAQ,EAAG,QAAO;AAClC,MAAI;AACF,UAAM,MAAM,aAAa,UAAU,MAAM;AACzC,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,mBAAyB;AACvC,QAAM,WAAW,mBAAmB;A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KAAI,IAAI,IAAI;AACxE,QAAI,SAAS,WAAW,IAAK,QAAO,EAAE,MAAM,QAAgB,SAAS,SAAS,QAAQ;AACtF,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,UAAM,UAAmB,KAAK,SAAS,IAAI,KAAK,MAAM,IAAI,IAAI;AAE9D,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,YAA0BC,gBAAe,OAAO,IAClD,UACA;AAAA,QACE,MAAM;AAAA,QACN,SAAS,cAAc,SAAS,MAAM,kBAAkB,MAAM;AAAA,MAChE;AACJ,YAAM,IAAIC,kBAAiB,SAAS,QAAQ,SAAS;AAAA,IACvD;AACA,WAAO,EAAE,MAAM,SAAc,SAAS,SAAS,QAAQ;AAAA,EACzD;AACF;AAEA,SAAS,kBAAkB,SAAyC;AAClE,QAAM,gBAAgB,QAAQ,IAAI,0BAA0B;AAC5D,QAAM,aAAa,kBAAkB,OAAO,IAAI,OAAO,SAAS,eAAe,EAAE;AACjF,QAAM,cAAc,QAAQ,IAAI,wBAAwB;AACxD,QAAM,WAAW,gBAAgB,QAAQ,YAAY,WAAW,IAC5D,CAAC,IACD,YAAY,MAAM,GAAG,EAAE,IAAI,WAAS,MAAM,KAAK,CAAC,EAAE,OAAO,WAAS,MAAM,SAAS,CAAC;AACtF,SAAO;AAAA,IACL,YAAY,OAAO,SAAS,UAAU,IAAI,aAAa;AAAA,IACvD;AAAA,EACF;AACF;AAEA,SAASD,gBAAe,OAAuC;AAC7D,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,QAAQ;AACd,SAAO,OAAO,MAAM,SAAS,YAAY,OAAO,MAAM,YAAY;AACpE;",
|
|
6
|
-
"names": ["path", "path", "existsSync", "mkdirSync", "readFileSync", "writeFileSync", "path", "existsSync", "readFileSync", "mkdirSync", "writeFileSync", "entry", "path", "path", "existsSync", "mkdirSync", "readFileSync", "unlinkSync", "writeFileSync", "existsSync", "mkdirSync", "writeFileSync", "readFileSync", "unlinkSync", "DatalakeApiError", "path", "
|
|
3
|
+
"sources": ["../../src/credentials.ts", "../../src/paths.ts", "../../src/LocalDatalakeClient.ts", "../../src/RestDatalakeClient.ts", "../../src/AuthToken.ts", "../../src/createDatalakeClient.ts", "../../src/defaultDatalake.ts", "../../src/PayloadsClient.ts", "../../src/payloadRequest.ts", "../../src/RestPublicPayloadsReader.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n chmodSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync,\n} from 'node:fs'\nimport path from 'node:path'\n\nimport { getAriesHome, getCredentialsPath } from './paths.ts'\n\n/**\n * Hints for self-signed wallet-JWT mode. When present, the CLI is expected to\n * mint a fresh ES256K JWT per request using the active aries wallet. The\n * server-side `authToken` field is unused in this mode.\n */\nexport interface WalletJwtCredentials {\n /**\n `aud` claim to use for control-plane calls (default `aries-datalake-control`).\n */\n controlAudience?: string\n /**\n Derivation offset of the signing account (default `'0'`).\n */\n offset?: string\n /**\n TTL (seconds) for each minted JWT (default `120`).\n */\n ttlSeconds?: number\n}\n\nexport interface StoredCredentials {\n /**\n * Static bearer token for legacy/static-token mode. Absent when `walletJwt`\n * mode is configured \u2014 the CLI mints a token per request instead.\n */\n authToken?: string\n baseUrl: string\n /**\n ISO-8601 expiration of the access token.\n */\n expiresAt?: string\n /**\n Optional refresh token for long-lived sessions.\n */\n refreshToken?: string\n userId?: string\n /**\n Wallet-JWT mode hints. When set, the CLI mints self-signed JWTs.\n */\n walletJwt?: WalletJwtCredentials\n}\n\nexport function saveCredentials(credentials: StoredCredentials): void {\n const home = getAriesHome()\n if (!existsSync(home)) mkdirSync(home, { recursive: true })\n const filePath = getCredentialsPath()\n writeFileSync(filePath, JSON.stringify(credentials, undefined, 2), 'utf8')\n try {\n chmodSync(filePath, 0o600)\n } catch {\n // chmod can fail on some filesystems (e.g. Windows); tolerate silently.\n }\n}\n\nexport function loadCredentials(): StoredCredentials | undefined {\n const filePath = getCredentialsPath()\n if (!existsSync(filePath)) return undefined\n try {\n const raw = readFileSync(filePath, 'utf8')\n return JSON.parse(raw) as StoredCredentials\n } catch {\n return undefined\n }\n}\n\nexport function clearCredentials(): void {\n const filePath = getCredentialsPath()\n if (existsSync(filePath)) unlinkSync(filePath)\n}\n\nexport function getCredentialsLocation(): string {\n return path.resolve(getCredentialsPath())\n}\n", "import { homedir } from 'node:os'\nimport path from 'node:path'\n\n/**\n * Root directory for all Aries state (credentials, local datalake stub, etc.).\n * Overridable via `ARIES_HOME` so tests can redirect to a temp dir.\n */\nexport function getAriesHome(): string {\n return process.env.ARIES_HOME ?? path.join(homedir(), '.aries')\n}\n\nexport function getDatalakeStoreDir(): string {\n return path.join(getAriesHome(), 'datalakes')\n}\n\n/**\n * JSON file backing the `LocalDatalakeClient`. A lightweight substitute for\n * the real control plane during P0 development.\n */\nexport function getLocalDatalakeStorePath(): string {\n return path.join(getDatalakeStoreDir(), 'local-store.json')\n}\n\nexport function getCredentialsPath(): string {\n return path.join(getAriesHome(), 'credentials.json')\n}\n\nexport function getDefaultDatalakePath(): string {\n return path.join(getAriesHome(), 'datalake-default.json')\n}\n", "import {\n existsSync, mkdirSync, readFileSync, writeFileSync,\n} from 'node:fs'\nimport path from 'node:path'\n\nimport type {\n DatalakeDescriptor,\n DatalakeTier,\n DatalakeToken,\n} from '@ariestools/aries-datalake-core'\n\nimport type {\n CreateDatalakeRequest,\n DatalakeClient,\n GrantRequest,\n RevokeRequest,\n TokenRequest,\n} from './DatalakeClient.ts'\nimport { getDatalakeStoreDir, getLocalDatalakeStorePath } from './paths.ts'\n\ninterface LocalStore {\n datalakes: DatalakeDescriptor[]\n}\n\nconst LOCAL_OWNER_ID = 'local-user'\n\nconst TIER_SIZE_DEFAULTS: Record<DatalakeTier, number> = {\n small: 10 * 1024 * 1024 * 1024,\n medium: 100 * 1024 * 1024 * 1024,\n large: 1024 * 1024 * 1024 * 1024,\n archive: 10 * 1024 * 1024 * 1024 * 1024,\n}\n\nconst TIER_IOPS_DEFAULTS: Record<DatalakeTier, number> = {\n small: 500,\n medium: 2000,\n large: 10_000,\n archive: 0,\n}\n\nfunction readStore(): LocalStore {\n const filePath = getLocalDatalakeStorePath()\n if (!existsSync(filePath)) return { datalakes: [] }\n try {\n const raw = readFileSync(filePath, 'utf8')\n return JSON.parse(raw) as LocalStore\n } catch {\n return { datalakes: [] }\n }\n}\n\nfunction writeStore(store: LocalStore): void {\n const dir = getDatalakeStoreDir()\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n writeFileSync(getLocalDatalakeStorePath(), JSON.stringify(store, undefined, 2), 'utf8')\n}\n\nfunction generateId(): string {\n return `dl_${Math.random().toString(36).slice(2, 10)}${Date.now().toString(36)}`\n}\n\nfunction findDatalake(store: LocalStore, idOrName: string): DatalakeDescriptor | undefined {\n return store.datalakes.find(dl => dl.id === idOrName || dl.name === idOrName)\n}\n\nfunction requireDatalake(store: LocalStore, idOrName: string): DatalakeDescriptor {\n const found = findDatalake(store, idOrName)\n if (!found) throw new Error(`Datalake not found: ${idOrName}`)\n return found\n}\n\n/**\n * Filesystem-backed stub implementation of `DatalakeClient` used during P0\n * development. Pretends to provision datalakes instantly, persists metadata\n * to `~/.aries/datalakes/local-store.json`, and mints opaque non-JWT tokens.\n *\n * Not suitable for production use \u2014 replace with `RestDatalakeClient` once\n * the control plane is live.\n */\nexport class LocalDatalakeClient implements DatalakeClient {\n async create(request: CreateDatalakeRequest): Promise<DatalakeDescriptor> {\n const store = readStore()\n if (store.datalakes.some(dl => dl.name === request.name)) {\n throw new Error(`Datalake already exists: ${request.name}`)\n }\n\n const now = new Date().toISOString()\n const tier = request.config.tier\n const descriptor: DatalakeDescriptor = {\n id: generateId(),\n name: request.name,\n ownerId: LOCAL_OWNER_ID,\n config: {\n tier,\n sizeBytes: request.config.sizeBytes ?? TIER_SIZE_DEFAULTS[tier],\n iops: request.config.iops ?? TIER_IOPS_DEFAULTS[tier],\n retentionDays: request.config.retentionDays ?? 30,\n region: request.config.region ?? 'us-west-2',\n allowedSchemas: request.config.allowedSchemas ?? [],\n disallowedSchemas: request.config.disallowedSchemas ?? [],\n },\n status: 'ready',\n url: `http://localhost:8080/datalakes/${request.name}`,\n acl: [],\n usage: {\n payloadCount: 0,\n bytesStored: 0,\n bytesStoredLimit: request.config.sizeBytes ?? TIER_SIZE_DEFAULTS[tier],\n readsLast24h: 0,\n writesLast24h: 0,\n },\n createdAt: now,\n updatedAt: now,\n }\n\n store.datalakes.push(descriptor)\n writeStore(store)\n return descriptor\n }\n\n async describe(idOrName: string): Promise<DatalakeDescriptor> {\n const store = readStore()\n return requireDatalake(store, idOrName)\n }\n\n async destroy(idOrName: string): Promise<void> {\n const store = readStore()\n const found = findDatalake(store, idOrName)\n if (!found) throw new Error(`Datalake not found: ${idOrName}`)\n store.datalakes = store.datalakes.filter(dl => dl.id !== found.id)\n writeStore(store)\n }\n\n async grant(request: GrantRequest): Promise<DatalakeDescriptor> {\n const store = readStore()\n const datalake = requireDatalake(store, request.datalakeId)\n const existing = datalake.acl.findIndex(entry => entry.principal === request.principal)\n const entry = {\n principal: request.principal,\n role: request.role,\n grantedAt: new Date().toISOString(),\n grantedBy: LOCAL_OWNER_ID,\n }\n if (existing === -1) {\n datalake.acl.push(entry)\n } else {\n datalake.acl[existing] = entry\n }\n datalake.updatedAt = entry.grantedAt\n writeStore(store)\n return datalake\n }\n\n async list(): Promise<DatalakeDescriptor[]> {\n return readStore().datalakes\n }\n\n async mintToken(request: TokenRequest): Promise<DatalakeToken> {\n const store = readStore()\n const datalake = requireDatalake(store, request.datalakeId)\n const ttl = request.ttlSeconds ?? 3600\n const issued = Buffer.from(\n JSON.stringify({\n dl: datalake.id,\n role: request.role,\n exp: Math.floor(Date.now() / 1000) + ttl,\n }),\n ).toString('base64url')\n return {\n token: `local.${issued}`,\n datalakeId: datalake.id,\n role: request.role,\n expiresAt: new Date(Date.now() + ttl * 1000).toISOString(),\n url: datalake.url ?? `http://localhost:8080/datalakes/${datalake.name}`,\n }\n }\n\n async revoke(request: RevokeRequest): Promise<DatalakeDescriptor> {\n const store = readStore()\n const datalake = requireDatalake(store, request.datalakeId)\n datalake.acl = datalake.acl.filter(entry => entry.principal !== request.principal)\n datalake.updatedAt = new Date().toISOString()\n writeStore(store)\n return datalake\n }\n}\n\n/**\n * Convenience: the absolute path where the local store persists state.\n * Useful in tests and for `aries datalake describe --debug`.\n */\nexport function getLocalStoreLocation(): string {\n return path.resolve(getLocalDatalakeStorePath())\n}\n", "import type {\n ApiErrorBody,\n CreateDatalakeBody,\n DatalakeDescriptor,\n DatalakeToken,\n GrantBody,\n MintTokenBody,\n} from '@ariestools/aries-datalake-core/browser'\nimport {\n DATALAKE_CONTROL_AUDIENCE,\n DatalakeApiError,\n datalakeCollectionPath,\n datalakeGrantPath,\n datalakeGrantsPath,\n datalakeResourcePath,\n datalakeTokensPath,\n} from '@ariestools/aries-datalake-core/browser'\n\nimport type { AuthTokenSource } from './AuthToken.ts'\nimport { resolveAuthToken } from './AuthToken.ts'\nimport type {\n CreateDatalakeRequest,\n DatalakeClient,\n GrantRequest,\n RevokeRequest,\n TokenRequest,\n} from './DatalakeClient.ts'\n\nexport interface RestDatalakeClientOptions {\n /**\n Exact control-plane JWT audience.\n */\n audience?: string\n /**\n Static token, or async factory minted per-request.\n */\n authToken: AuthTokenSource\n /**\n Control-plane base URL, e.g. `https://dl-control.xylabs.io`.\n */\n baseUrl: string\n /**\n Optional `fetch` override; defaults to global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\ninterface RequestOptions {\n body?: unknown\n method?: string\n}\n\n/**\n * HTTP client for the datalake control plane. Implements the stable\n * `DatalakeClient` contract so callers are independent of transport.\n */\nexport class RestDatalakeClient implements DatalakeClient {\n private readonly audience: string\n private readonly authToken: AuthTokenSource\n private readonly baseUrl: string\n private readonly fetchImpl: typeof fetch\n\n constructor(options: RestDatalakeClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, '')\n this.audience = options.audience ?? DATALAKE_CONTROL_AUDIENCE\n this.authToken = options.authToken\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async create(request: CreateDatalakeRequest): Promise<DatalakeDescriptor> {\n const body: CreateDatalakeBody = { name: request.name, config: request.config }\n return this.request<DatalakeDescriptor>(datalakeCollectionPath(), { method: 'POST', body })\n }\n\n async describe(idOrName: string): Promise<DatalakeDescriptor> {\n return this.request<DatalakeDescriptor>(datalakeResourcePath(idOrName))\n }\n\n async destroy(idOrName: string): Promise<void> {\n await this.request<void>(datalakeResourcePath(idOrName), { method: 'DELETE' })\n }\n\n async grant(request: GrantRequest): Promise<DatalakeDescriptor> {\n const body: GrantBody = { principal: request.principal, role: request.role }\n return this.request<DatalakeDescriptor>(\n datalakeGrantsPath(request.datalakeId),\n { method: 'POST', body },\n )\n }\n\n async list(): Promise<DatalakeDescriptor[]> {\n return this.request<DatalakeDescriptor[]>(datalakeCollectionPath())\n }\n\n async mintToken(request: TokenRequest): Promise<DatalakeToken> {\n const body: MintTokenBody = { role: request.role, ttlSeconds: request.ttlSeconds }\n return this.request<DatalakeToken>(\n datalakeTokensPath(request.datalakeId),\n { method: 'POST', body },\n )\n }\n\n async revoke(request: RevokeRequest): Promise<DatalakeDescriptor> {\n return this.request<DatalakeDescriptor>(\n datalakeGrantPath(request.datalakeId, request.principal),\n { method: 'DELETE' },\n )\n }\n\n private async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const url = `${this.baseUrl}${path}`\n const method = options.method ?? 'GET'\n const token = await resolveAuthToken(this.authToken, this.audience)\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n }\n if (options.body !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(options.body)\n }\n\n const response = await this.fetchImpl(url, init)\n if (response.status === 204) {\n return undefined as T\n }\n const text = await response.text()\n const payload: unknown = text.length > 0 ? JSON.parse(text) : undefined\n\n if (!response.ok) {\n const errorBody: ApiErrorBody = isApiErrorBody(payload)\n ? payload\n : {\n code: 'internal',\n message: `Unexpected ${response.status} response from ${method} control plane`,\n }\n throw new DatalakeApiError(response.status, errorBody)\n }\n return payload as T\n }\n}\n\nfunction isApiErrorBody(value: unknown): value is ApiErrorBody {\n if (typeof value !== 'object' || value === null) return false\n const maybe = value as Record<string, unknown>\n return typeof maybe.code === 'string' && typeof maybe.message === 'string'\n}\n", "export interface AuthTokenRequest {\n /**\n Exact JWT audience required by the target service or datalake.\n */\n audience: string\n}\n\n/**\nInvoked for every request so callers can obtain a fresh wallet JWT.\n*/\nexport type AuthTokenSupplier = (request: AuthTokenRequest) => Promise<string>\n\nexport type AuthTokenSource = AuthTokenSupplier | string\n\nexport async function resolveAuthToken(source: AuthTokenSource, audience: string): Promise<string> {\n return typeof source === 'function' ? await source({ audience }) : source\n}\n", "import type { AuthTokenSource } from './AuthToken.ts'\nimport { loadCredentials } from './credentials.ts'\nimport type { DatalakeClient } from './DatalakeClient.ts'\nimport { LocalDatalakeClient } from './LocalDatalakeClient.ts'\nimport { RestDatalakeClient } from './RestDatalakeClient.ts'\n\nexport interface CreateDatalakeClientOptions {\n /**\n * Override the auth token (otherwise read from credentials). Accepts either\n * a static bearer string or an async factory \u2014 pass a factory when minting\n * self-signed wallet JWTs per request.\n */\n authToken?: AuthTokenSource\n /**\n Override the control-plane URL (otherwise read from env / credentials).\n */\n baseUrl?: string\n /**\n * Force a specific driver. Defaults to:\n * - `rest` when `ARIES_DATALAKE_API` is set or credentials are present\n * - `local` otherwise\n */\n driver?: 'local' | 'rest'\n}\n\n/**\n * Returns a `DatalakeClient` wired for the current environment. The CLI uses\n * this factory so every command picks up the same resolution rules.\n */\nexport function createDatalakeClient(options: CreateDatalakeClientOptions = {}): DatalakeClient {\n const envBaseUrl = process.env.ARIES_DATALAKE_API\n const credentials = loadCredentials()\n const baseUrl = options.baseUrl ?? envBaseUrl ?? credentials?.baseUrl\n const authToken: AuthTokenSource | undefined = options.authToken ?? credentials?.authToken\n\n const driver = options.driver\n ?? (baseUrl && authToken ? 'rest' : 'local')\n\n if (driver === 'rest') {\n if (!baseUrl || !authToken) {\n throw new Error(\n 'REST driver requires a baseUrl and authToken. '\n + 'Run `aries datalake login` or set ARIES_DATALAKE_API and sign in.',\n )\n }\n return new RestDatalakeClient({ baseUrl, authToken })\n }\n\n return new LocalDatalakeClient()\n}\n", "import {\n existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync,\n} from 'node:fs'\n\nimport { getAriesHome, getDefaultDatalakePath } from './paths.ts'\n\ninterface DefaultDatalakeFile {\n id?: string\n name: string\n setAt: string\n}\n\n/**\n * Remembers which datalake the user selected via `aries datalake use`. Read by\n * commands that accept an optional `<name>` and fall back to the default.\n */\nexport function setDefaultDatalake(name: string, id?: string): void {\n const home = getAriesHome()\n if (!existsSync(home)) mkdirSync(home, { recursive: true })\n const payload: DefaultDatalakeFile = {\n name, id, setAt: new Date().toISOString(),\n }\n writeFileSync(getDefaultDatalakePath(), JSON.stringify(payload, undefined, 2), 'utf8')\n}\n\nexport function getDefaultDatalake(): string | undefined {\n const filePath = getDefaultDatalakePath()\n if (!existsSync(filePath)) return undefined\n try {\n const raw = readFileSync(filePath, 'utf8')\n const parsed = JSON.parse(raw) as DefaultDatalakeFile\n return parsed.name\n } catch {\n return undefined\n }\n}\n\nexport function clearDefaultDatalake(): void {\n const filePath = getDefaultDatalakePath()\n if (existsSync(filePath)) unlinkSync(filePath)\n}\n", "import type {\n DatalakeInsertSummary,\n InsertPayloadsBody,\n InsertPayloadsResponse,\n InsertPayloadsResult,\n NextPayloadsOptions,\n NextPayloadsResponse,\n NextPayloadsResult,\n Payload,\n WithStorageMeta,\n} from '@ariestools/aries-datalake-core/browser'\nimport {\n DATALAKE_HEADER_DUPLICATES,\n DATALAKE_HEADER_NEXT_CURSOR,\n DATALAKE_HEADER_REJECTED,\n datalakePlaneClearPath,\n datalakePlaneDeletePath,\n datalakePlaneGetManyPath,\n datalakePlaneGetPath,\n datalakePlaneInsertPath,\n datalakePlaneNextPath,\n datalakePlaneUsagePath,\n} from '@ariestools/aries-datalake-core/browser'\n\nimport type { AuthTokenSource } from './AuthToken.ts'\nimport { resolveAuthToken } from './AuthToken.ts'\nimport { extractRequestBase, parsePayloadResponse } from './payloadRequest.ts'\n\nexport interface DatalakeUsageReport {\n datalakeId: string\n payloadCount: number\n rateLimits?: {\n anonymous?: { limit: number; remaining: number }\n authenticated?: { limit: number; remaining: number }\n }\n}\n\n/**\n * HTTP client for a single datalake's data plane. Clients send bare\n * `Payload` objects (no `_hash` / `_dataHash` \u2014 those are stamped on\n * insert by the data plane's archivist). Responses always carry the\n * archivist-computed storage meta.\n *\n * Wire format mirrors the XYO archivist REST middleware: `/insert`,\n * `/get/:hash`, `/next`, bare arrays as bodies. Datalake-specific\n * extras (duplicates count, rejected hashes, next cursor) are delivered\n * via response headers.\n */\nexport interface PayloadsClient {\n clear(): Promise<{ removed: number }>\n delete(hash: string): Promise<void>\n get(hash: string): Promise<WithStorageMeta<Payload>>\n getMany(hashes: string[]): Promise<WithStorageMeta<Payload>[]>\n insert(payloads: Payload[]): Promise<InsertPayloadsResult>\n next(options?: NextPayloadsOptions): Promise<NextPayloadsResult>\n usage(): Promise<DatalakeUsageReport>\n}\n\n/**\n * Either a static bearer token, or a factory invoked per-request. The factory\n * form lets callers mint a fresh self-signed wallet JWT per call (with\n * `aud` bound to the datalake id).\n */\nexport type PayloadsAuthTokenSource = AuthTokenSource\n\nexport interface RestPayloadsClientOptions {\n /**\n Static bearer token, or async factory minted per-request.\n */\n authToken: PayloadsAuthTokenSource\n /**\n Data-plane base URL without trailing slash.\n */\n baseUrl: string\n /**\n Datalake id; appended to `/v1/datalakes/:id/...`.\n */\n datalakeId: string\n /**\n Optional `fetch` override; defaults to global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\ninterface RequestOptions {\n body?: unknown\n method?: string\n}\n\ninterface RequestResult<T> {\n data: T\n headers: Headers\n}\n\nexport class RestPayloadsClient implements PayloadsClient {\n private readonly authToken: PayloadsAuthTokenSource\n private readonly datalakeId: string\n private readonly fetchImpl: typeof fetch\n private readonly requestBase: string\n\n constructor(options: RestPayloadsClientOptions) {\n this.requestBase = extractRequestBase(options.baseUrl)\n this.datalakeId = options.datalakeId\n this.authToken = options.authToken\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n async clear(): Promise<{ removed: number }> {\n return this.request<{ removed: number }>(\n datalakePlaneClearPath(this.datalakeId),\n { method: 'POST' },\n )\n }\n\n async delete(hash: string): Promise<void> {\n await this.request<void>(\n datalakePlaneDeletePath(this.datalakeId, hash),\n { method: 'DELETE' },\n )\n }\n\n async get(hash: string): Promise<WithStorageMeta<Payload>> {\n return this.request<WithStorageMeta<Payload>>(datalakePlaneGetPath(this.datalakeId, hash))\n }\n\n async getMany(hashes: string[]): Promise<WithStorageMeta<Payload>[]> {\n if (hashes.length === 0) return []\n return this.request<WithStorageMeta<Payload>[]>(\n datalakePlaneGetManyPath(this.datalakeId),\n { method: 'POST', body: hashes },\n )\n }\n\n async insert(payloads: Payload[]): Promise<InsertPayloadsResult> {\n const body: InsertPayloadsBody = payloads\n const { data, headers } = await this.requestWithHeaders<InsertPayloadsResponse>(\n datalakePlaneInsertPath(this.datalakeId),\n { method: 'POST', body },\n )\n return {\n inserted: data,\n summary: readInsertSummary(headers),\n }\n }\n\n async next(options: NextPayloadsOptions = {}): Promise<NextPayloadsResult> {\n const params = new URLSearchParams()\n if (options.limit !== undefined) params.set('limit', String(options.limit))\n if (options.cursor) params.set('cursor', options.cursor)\n if (options.schemas && options.schemas.length > 0) params.set('schemas', options.schemas.join(','))\n if (options.order) params.set('order', options.order)\n const suffix = params.toString()\n const path = suffix\n ? `${datalakePlaneNextPath(this.datalakeId)}?${suffix}`\n : datalakePlaneNextPath(this.datalakeId)\n const { data, headers } = await this.requestWithHeaders<NextPayloadsResponse>(path)\n const nextCursor = headers.get(DATALAKE_HEADER_NEXT_CURSOR) ?? undefined\n return { payloads: data, nextCursor }\n }\n\n async usage(): Promise<DatalakeUsageReport> {\n return this.request<DatalakeUsageReport>(datalakePlaneUsagePath(this.datalakeId))\n }\n\n private async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const { data } = await this.requestWithHeaders<T>(path, options)\n return data\n }\n\n private async requestWithHeaders<T>(path: string, options: RequestOptions = {}): Promise<RequestResult<T>> {\n const method = options.method ?? 'GET'\n const token = await resolveAuthToken(this.authToken, this.datalakeId)\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${token}`,\n }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n }\n if (options.body !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(options.body)\n }\n\n const response = await this.fetchImpl(`${this.requestBase}${path}`, init)\n if (response.status === 204) return { data: undefined as T, headers: response.headers }\n const text = await response.text()\n return { data: parsePayloadResponse<T>(response, text, method), headers: response.headers }\n }\n}\n\nfunction readInsertSummary(headers: Headers): DatalakeInsertSummary {\n const duplicatesRaw = headers.get(DATALAKE_HEADER_DUPLICATES)\n const duplicates = duplicatesRaw === null ? 0 : Number.parseInt(duplicatesRaw, 10)\n const rejectedRaw = headers.get(DATALAKE_HEADER_REJECTED)\n const rejected = rejectedRaw === null || rejectedRaw.length === 0\n ? []\n : rejectedRaw.split(',').map(value => value.trim()).filter(value => value.length > 0)\n return {\n duplicates: Number.isFinite(duplicates) ? duplicates : 0,\n rejected,\n }\n}\n", "import type { ApiErrorBody } from '@ariestools/aries-datalake-core/browser'\nimport { DATALAKE_API_VERSION, DatalakeApiError } from '@ariestools/aries-datalake-core/browser'\n\n/**\n * The data plane is typically addressed by a URL that already includes the\n * datalake id (e.g. `https://plane/v1/datalakes/dl_abc`). Preserve any path\n * prefix before `/v1/datalakes` so a shared ALB can expose the data plane at\n * `https://host/plane` while the path helpers regenerate the canonical API\n * suffix from the id.\n */\nexport function extractRequestBase(urlWithPossiblePath: string): string {\n try {\n const parsed = new URL(urlWithPossiblePath)\n const apiMarker = `/${DATALAKE_API_VERSION}/datalakes`\n const markerIndex = parsed.pathname.indexOf(apiMarker)\n const prefix = markerIndex === -1\n ? parsed.pathname.replace(/\\/$/, '')\n : parsed.pathname.slice(0, markerIndex)\n return `${parsed.protocol}//${parsed.host}${prefix}`\n } catch {\n return urlWithPossiblePath.replace(/\\/$/, '')\n }\n}\n\n/** Preserve the native data-plane JSON and API-error response contract. */\nexport function parsePayloadResponse<T>(response: Response, text: string, method: string): T {\n const payload: unknown = text.length > 0 ? JSON.parse(text) : undefined\n\n if (!response.ok) {\n const errorBody: ApiErrorBody = isApiErrorBody(payload)\n ? payload\n : {\n code: 'internal',\n message: 'Unexpected ' + response.status + ' response from ' + method + ' data plane',\n }\n throw new DatalakeApiError(response.status, errorBody)\n }\n return payload as T\n}\n\nfunction isApiErrorBody(value: unknown): value is ApiErrorBody {\n if (typeof value !== 'object' || value === null) return false\n const maybe = value as Record<string, unknown>\n return typeof maybe.code === 'string' && typeof maybe.message === 'string'\n}\n", "import type { Payload, WithStorageMeta } from '@ariestools/aries-datalake-core/browser'\nimport { datalakePlaneGetManyPath, datalakePlaneGetPath } from '@ariestools/aries-datalake-core/browser'\nimport { readResponseText } from '@ariestools/sdk/fetch'\n\nimport { extractRequestBase, parsePayloadResponse } from './payloadRequest.ts'\n\n/** Policy for one public HTTP response, including its JSON envelope and metadata. */\nexport interface RestPublicPayloadsReadOptions {\n /**\n Positive safe-integer limit on decoded Fetch-body bytes before JSON parsing.\n Omission leaves the body size unlimited; this is not a raw network-byte limit.\n */\n readonly maxResponseBytes?: number\n /** Caller cancellation remains active through response-body consumption. */\n readonly signal?: AbortSignal\n}\n\nexport interface RestPublicPayloadsReaderOptions {\n /** Absolute HTTP(S) data-plane URL, optionally including its API path prefix. */\n readonly baseUrl: string\n /** Datalake id used to regenerate the canonical native data-plane paths. */\n readonly datalakeId: string\n /**\n Trusted transport override. It must preserve the public no-credentials and\n no-redirect policy and honor cancellation. Defaults to request-time global fetch.\n */\n readonly fetchImpl?: typeof fetch\n}\n\n/**\n * Exact-hash reads using the native data-plane protocol without token handling.\n * The server must grant public viewer access. Public access applies to the whole\n * lake; this reader neither grants access nor falls back from authenticated I/O.\n * Returned metadata is structural transport data, not verified content identity.\n */\nexport class RestPublicPayloadsReader {\n private readonly datalakeId: string\n private readonly fetchImpl?: typeof fetch\n private readonly requestBase: string\n\n constructor(options: RestPublicPayloadsReaderOptions) {\n this.requestBase = publicRequestBase(options.baseUrl)\n this.datalakeId = options.datalakeId\n this.fetchImpl = options.fetchImpl\n }\n\n async get(hash: string, options: RestPublicPayloadsReadOptions = {}): Promise<WithStorageMeta<Payload>> {\n const payload = await this.request(datalakePlaneGetPath(this.datalakeId, hash), options)\n if (!isStoredPayload(payload)) throw new TypeError('Data plane returned an invalid stored payload')\n return payload\n }\n\n async getMany(hashes: readonly string[], options: RestPublicPayloadsReadOptions = {}): Promise<WithStorageMeta<Payload>[]> {\n const policy = pinReadOptions(options)\n const requested = [...hashes]\n if (requested.length === 0) return []\n const payloads = await this.request(datalakePlaneGetManyPath(this.datalakeId), policy, requested)\n if (!Array.isArray(payloads) || !payloads.every(isStoredPayload)) {\n throw new TypeError('Data plane returned an invalid stored-payload array')\n }\n return payloads\n }\n\n private async request(path: string, options: RestPublicPayloadsReadOptions, hashes?: readonly string[]): Promise<unknown> {\n const { maxResponseBytes, signal } = pinReadOptions(options)\n const method = hashes === undefined ? 'GET' : 'POST'\n const headers: Record<string, string> = { accept: 'application/json' }\n const init: RequestInit = {\n credentials: 'omit',\n headers,\n method,\n redirect: 'error',\n signal,\n }\n if (hashes !== undefined) {\n headers['content-type'] = 'application/json'\n init.body = JSON.stringify(hashes)\n }\n const fetchImpl = this.fetchImpl ?? globalThis.fetch\n const response = await fetchImpl(this.requestBase + path, init)\n const text = await readResponseText(response, { maxResponseBytes, signal })\n return parsePayloadResponse<unknown>(response, text, method)\n }\n}\n\nfunction pinReadOptions(options: RestPublicPayloadsReadOptions): RestPublicPayloadsReadOptions {\n const { maxResponseBytes, signal } = options\n if (maxResponseBytes !== undefined && (!Number.isSafeInteger(maxResponseBytes) || maxResponseBytes <= 0)) {\n throw new RangeError('maxResponseBytes must be a positive safe integer')\n }\n signal?.throwIfAborted()\n return { maxResponseBytes, signal }\n}\n\nfunction publicRequestBase(baseUrl: string): string {\n let parsed: URL\n try {\n parsed = new URL(baseUrl)\n } catch {\n throw new TypeError('baseUrl must be an absolute HTTP(S) URL')\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new TypeError('baseUrl must be an absolute HTTP(S) URL')\n }\n if (parsed.username !== '' || parsed.password !== '') {\n throw new TypeError('Public data-plane URLs must not contain credentials')\n }\n if (parsed.href.includes('#')) throw new TypeError('Public data-plane URLs must not contain fragments')\n return extractRequestBase(baseUrl)\n}\n\nfunction isStoredPayload(value: unknown): value is WithStorageMeta<Payload> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const payload = value as Record<string, unknown>\n return ['schema', '_hash', '_dataHash', '_sequence'].every(key => Object.hasOwn(payload, key) && typeof payload[key] === 'string')\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACE;AAAA,EAAW;AAAA,EAAY;AAAA,EAAW;AAAA,EAAc;AAAA,EAAY;AAAA,OACvD;AACP,OAAOA,WAAU;;;ACHjB,SAAS,eAAe;AACxB,OAAO,UAAU;AAMV,SAAS,eAAuB;AACrC,SAAO,QAAQ,IAAI,cAAc,KAAK,KAAK,QAAQ,GAAG,QAAQ;AAChE;AAEO,SAAS,sBAA8B;AAC5C,SAAO,KAAK,KAAK,aAAa,GAAG,WAAW;AAC9C;AAMO,SAAS,4BAAoC;AAClD,SAAO,KAAK,KAAK,oBAAoB,GAAG,kBAAkB;AAC5D;AAEO,SAAS,qBAA6B;AAC3C,SAAO,KAAK,KAAK,aAAa,GAAG,kBAAkB;AACrD;AAEO,SAAS,yBAAiC;AAC/C,SAAO,KAAK,KAAK,aAAa,GAAG,uB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U,qDAAqD;AAAA,EAC3E;AACA,MAAI,OAAO,KAAK,SAAS,GAAG,EAAG,OAAM,IAAI,UAAU,mDAAmD;AACtG,SAAO,mBAAmB,OAAO;AACnC;AAEA,SAAS,gBAAgB,OAAmD;AAC1E,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,UAAU;AAChB,SAAO,CAAC,UAAU,SAAS,aAAa,WAAW,EAAE,MAAM,SAAO,OAAO,OAAO,SAAS,GAAG,KAAK,OAAO,QAAQ,GAAG,MAAM,QAAQ;AACnI;",
|
|
6
|
+
"names": ["path", "path", "existsSync", "mkdirSync", "readFileSync", "writeFileSync", "path", "existsSync", "readFileSync", "mkdirSync", "writeFileSync", "entry", "path", "path", "existsSync", "mkdirSync", "readFileSync", "unlinkSync", "writeFileSync", "existsSync", "mkdirSync", "writeFileSync", "readFileSync", "unlinkSync", "DatalakeApiError", "isApiErrorBody", "path", "datalakePlaneGetManyPath", "datalakePlaneGetPath", "datalakePlaneGetPath", "datalakePlaneGetManyPath", "path"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data plane is typically addressed by a URL that already includes the
|
|
3
|
+
* datalake id (e.g. `https://plane/v1/datalakes/dl_abc`). Preserve any path
|
|
4
|
+
* prefix before `/v1/datalakes` so a shared ALB can expose the data plane at
|
|
5
|
+
* `https://host/plane` while the path helpers regenerate the canonical API
|
|
6
|
+
* suffix from the id.
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractRequestBase(urlWithPossiblePath: string): string;
|
|
9
|
+
/** Preserve the native data-plane JSON and API-error response contract. */
|
|
10
|
+
export declare function parsePayloadResponse<T>(response: Response, text: string, method: string): T;
|
|
11
|
+
//# sourceMappingURL=payloadRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloadRequest.d.ts","sourceRoot":"","sources":["../../src/payloadRequest.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAYtE;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAa3F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ariestools/aries-datalake-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Client SDK for the Aries on-demand XL1 datalake control plane",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xylabs",
|
|
@@ -42,23 +42,24 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ariestools/
|
|
45
|
+
"@ariestools/sdk": "~8.2.0",
|
|
46
|
+
"@ariestools/aries-datalake-core": "~0.1.20"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@ariestools/sdk": "~8.
|
|
49
|
-
"@ariestools/toolchain": "~9.
|
|
50
|
-
"@ariestools/tsconfig": "~9.
|
|
49
|
+
"@ariestools/sdk": "~8.2.0",
|
|
50
|
+
"@ariestools/toolchain": "~9.1.2",
|
|
51
|
+
"@ariestools/tsconfig": "~9.1.2",
|
|
51
52
|
"@opentelemetry/api": "~1.9.1",
|
|
52
|
-
"@types/node": "~26.
|
|
53
|
-
"@xyo-network/sdk": "~7.
|
|
54
|
-
"@xyo-network/sdk-protocol": "~7.2
|
|
55
|
-
"fastify": "~5.12.
|
|
53
|
+
"@types/node": "~26.4.0",
|
|
54
|
+
"@xyo-network/sdk": "~7.4.0",
|
|
55
|
+
"@xyo-network/sdk-protocol": "~7.4.2",
|
|
56
|
+
"fastify": "~5.12.1",
|
|
56
57
|
"typescript": "~6.0.3",
|
|
57
|
-
"vite": "~8.2.
|
|
58
|
-
"vitest": "~4.1.
|
|
59
|
-
"zod": "~4.
|
|
60
|
-
"@ariestools/aries-datalake-
|
|
61
|
-
"@ariestools/aries-datalake-
|
|
58
|
+
"vite": "~8.2.2",
|
|
59
|
+
"vitest": "~4.1.11",
|
|
60
|
+
"zod": "~4.5.1",
|
|
61
|
+
"@ariestools/aries-datalake-plane": "~0.1.20",
|
|
62
|
+
"@ariestools/aries-datalake-control": "~0.1.20"
|
|
62
63
|
},
|
|
63
64
|
"engines": {
|
|
64
65
|
"node": ">=18.17.1"
|
|
@@ -67,6 +68,9 @@
|
|
|
67
68
|
"publishConfig": {
|
|
68
69
|
"access": "public"
|
|
69
70
|
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@opentelemetry/api": "^1.9"
|
|
73
|
+
},
|
|
70
74
|
"scripts": {
|
|
71
75
|
"package-compile": "package-compile-only && node ../../scripts/pruneBrowserDeclarations.mjs dist/browser/browser.d.ts"
|
|
72
76
|
}
|