@lumeweb/pinner 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +690 -28
- package/dist/cjs/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/cjs/adapters/pinata/adapter.cjs +88 -0
- package/dist/cjs/adapters/pinata/adapter.cjs.map +1 -0
- package/dist/cjs/adapters/pinata/adapter.d.cts +35 -0
- package/dist/cjs/adapters/pinata/builder.cjs +194 -0
- package/dist/cjs/adapters/pinata/builder.cjs.map +1 -0
- package/dist/cjs/adapters/pinata/index.cjs +3 -0
- package/dist/cjs/adapters/pinata/list-builder.cjs +52 -0
- package/dist/cjs/adapters/pinata/list-builder.cjs.map +1 -0
- package/dist/cjs/blockstore/index.cjs +2 -0
- package/dist/cjs/blockstore/unstorage-base.cjs +240 -0
- package/dist/cjs/blockstore/unstorage-base.cjs.map +1 -0
- package/dist/cjs/blockstore/unstorage-base.d.cts +23 -0
- package/dist/cjs/blockstore/unstorage.cjs +39 -0
- package/dist/cjs/blockstore/unstorage.cjs.map +1 -0
- package/dist/cjs/blockstore/unstorage.d.cts +36 -0
- package/dist/cjs/config.d.cts +51 -0
- package/dist/cjs/encoder/base64.cjs +38 -0
- package/dist/cjs/encoder/base64.cjs.map +1 -0
- package/dist/cjs/encoder/csv/csv-formatter.cjs +81 -0
- package/dist/cjs/encoder/csv/csv-formatter.cjs.map +1 -0
- package/dist/cjs/encoder/csv/field-formatter.cjs +76 -0
- package/dist/cjs/encoder/csv/field-formatter.cjs.map +1 -0
- package/dist/cjs/encoder/csv/row-formatter.cjs +159 -0
- package/dist/cjs/encoder/csv/row-formatter.cjs.map +1 -0
- package/dist/cjs/encoder/csv.cjs +44 -0
- package/dist/cjs/encoder/csv.cjs.map +1 -0
- package/dist/cjs/encoder/error.cjs +19 -0
- package/dist/cjs/encoder/error.cjs.map +1 -0
- package/dist/cjs/encoder/index.cjs +6 -0
- package/dist/cjs/encoder/json.cjs +36 -0
- package/dist/cjs/encoder/json.cjs.map +1 -0
- package/dist/cjs/encoder/text.cjs +35 -0
- package/dist/cjs/encoder/text.cjs.map +1 -0
- package/dist/cjs/encoder/url.cjs +39 -0
- package/dist/cjs/encoder/url.cjs.map +1 -0
- package/dist/cjs/errors/index.cjs +104 -0
- package/dist/cjs/errors/index.cjs.map +1 -0
- package/dist/cjs/errors/index.d.cts +47 -0
- package/dist/cjs/index.cjs +42 -0
- package/dist/cjs/index.d.cts +14 -0
- package/dist/cjs/pin/client.cjs +96 -0
- package/dist/cjs/pin/client.cjs.map +1 -0
- package/dist/cjs/pin/index.cjs +1 -0
- package/dist/cjs/pinner.cjs +126 -0
- package/dist/cjs/pinner.cjs.map +1 -0
- package/dist/cjs/pinner.d.cts +77 -0
- package/dist/cjs/types/constants.cjs +34 -0
- package/dist/cjs/types/constants.cjs.map +1 -0
- package/dist/cjs/types/mime-types.cjs +11 -0
- package/dist/cjs/types/mime-types.cjs.map +1 -0
- package/dist/cjs/types/mime-types.d.cts +7 -0
- package/dist/cjs/types/pin.d.cts +74 -0
- package/dist/cjs/types/pinata.d.cts +99 -0
- package/dist/cjs/types/type-guards.cjs +20 -0
- package/dist/cjs/types/type-guards.cjs.map +1 -0
- package/dist/cjs/types/type-guards.d.cts +15 -0
- package/dist/cjs/types/upload.cjs +18 -0
- package/dist/cjs/types/upload.cjs.map +1 -0
- package/dist/cjs/types/upload.d.cts +189 -0
- package/dist/cjs/upload/base-upload.cjs +135 -0
- package/dist/cjs/upload/base-upload.cjs.map +1 -0
- package/dist/cjs/upload/builder.cjs +174 -0
- package/dist/cjs/upload/builder.cjs.map +1 -0
- package/dist/cjs/upload/builder.d.cts +60 -0
- package/dist/cjs/upload/car.cjs +129 -0
- package/dist/cjs/upload/car.cjs.map +1 -0
- package/dist/cjs/upload/car.d.cts +19 -0
- package/dist/cjs/upload/constants.cjs +9 -0
- package/dist/cjs/upload/constants.cjs.map +1 -0
- package/dist/cjs/upload/index.cjs +8 -0
- package/dist/cjs/upload/manager.cjs +249 -0
- package/dist/cjs/upload/manager.cjs.map +1 -0
- package/dist/cjs/upload/manager.d.cts +35 -0
- package/dist/cjs/upload/normalize.cjs +28 -0
- package/dist/cjs/upload/normalize.cjs.map +1 -0
- package/dist/cjs/upload/tus-upload.cjs +74 -0
- package/dist/cjs/upload/tus-upload.cjs.map +1 -0
- package/dist/cjs/upload/xhr-upload.cjs +41 -0
- package/dist/cjs/upload/xhr-upload.cjs.map +1 -0
- package/dist/cjs/utils/env.cjs +12 -0
- package/dist/cjs/utils/env.cjs.map +1 -0
- package/dist/cjs/utils/stream.cjs +141 -0
- package/dist/cjs/utils/stream.cjs.map +1 -0
- package/dist/cjs/utils/stream.d.cts +23 -0
- package/dist/cjs/utils/tus-patch.cjs +50 -0
- package/dist/cjs/utils/tus-patch.cjs.map +1 -0
- package/dist/cjs/utils/validation.cjs +62 -0
- package/dist/cjs/utils/validation.cjs.map +1 -0
- package/dist/esm/_virtual/rolldown_runtime.js +8 -0
- package/dist/esm/adapters/pinata/adapter.d.ts +35 -0
- package/dist/esm/adapters/pinata/adapter.js +87 -0
- package/dist/esm/adapters/pinata/adapter.js.map +1 -0
- package/dist/esm/adapters/pinata/builder.d.ts +1 -0
- package/dist/esm/adapters/pinata/builder.js +187 -0
- package/dist/esm/adapters/pinata/builder.js.map +1 -0
- package/dist/esm/adapters/pinata/index.d.ts +4 -0
- package/dist/esm/adapters/pinata/index.js +3 -0
- package/dist/esm/adapters/pinata/list-builder.d.ts +1 -0
- package/dist/esm/adapters/pinata/list-builder.js +51 -0
- package/dist/esm/adapters/pinata/list-builder.js.map +1 -0
- package/dist/esm/blockstore/index.d.ts +2 -0
- package/dist/esm/blockstore/index.js +2 -0
- package/dist/esm/blockstore/unstorage-base.d.ts +23 -0
- package/dist/esm/blockstore/unstorage-base.js +231 -0
- package/dist/esm/blockstore/unstorage-base.js.map +1 -0
- package/dist/esm/blockstore/unstorage.d.ts +36 -0
- package/dist/esm/blockstore/unstorage.js +38 -0
- package/dist/esm/blockstore/unstorage.js.map +1 -0
- package/dist/esm/config.d.ts +51 -0
- package/dist/esm/encoder/base64.js +37 -0
- package/dist/esm/encoder/base64.js.map +1 -0
- package/dist/esm/encoder/csv/csv-formatter.js +81 -0
- package/dist/esm/encoder/csv/csv-formatter.js.map +1 -0
- package/dist/esm/encoder/csv/field-formatter.js +75 -0
- package/dist/esm/encoder/csv/field-formatter.js.map +1 -0
- package/dist/esm/encoder/csv/row-formatter.js +159 -0
- package/dist/esm/encoder/csv/row-formatter.js.map +1 -0
- package/dist/esm/encoder/csv.js +43 -0
- package/dist/esm/encoder/csv.js.map +1 -0
- package/dist/esm/encoder/error.js +18 -0
- package/dist/esm/encoder/error.js.map +1 -0
- package/dist/esm/encoder/index.js +6 -0
- package/dist/esm/encoder/json.js +35 -0
- package/dist/esm/encoder/json.js.map +1 -0
- package/dist/esm/encoder/text.js +34 -0
- package/dist/esm/encoder/text.js.map +1 -0
- package/dist/esm/encoder/url.js +36 -0
- package/dist/esm/encoder/url.js.map +1 -0
- package/dist/esm/errors/index.d.ts +47 -0
- package/dist/esm/errors/index.js +93 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/pin/client.js +95 -0
- package/dist/esm/pin/client.js.map +1 -0
- package/dist/esm/pin/index.js +1 -0
- package/dist/esm/pinner.d.ts +77 -0
- package/dist/esm/pinner.js +125 -0
- package/dist/esm/pinner.js.map +1 -0
- package/dist/esm/types/constants.js +29 -0
- package/dist/esm/types/constants.js.map +1 -0
- package/dist/esm/types/mime-types.d.ts +7 -0
- package/dist/esm/types/mime-types.js +8 -0
- package/dist/esm/types/mime-types.js.map +1 -0
- package/dist/esm/types/pin.d.ts +74 -0
- package/dist/esm/types/pinata.d.ts +99 -0
- package/dist/esm/types/type-guards.d.ts +15 -0
- package/dist/esm/types/type-guards.js +19 -0
- package/dist/esm/types/type-guards.js.map +1 -0
- package/dist/esm/types/upload.d.ts +189 -0
- package/dist/esm/types/upload.js +16 -0
- package/dist/esm/types/upload.js.map +1 -0
- package/dist/esm/upload/base-upload.js +132 -0
- package/dist/esm/upload/base-upload.js.map +1 -0
- package/dist/esm/upload/builder.d.ts +60 -0
- package/dist/esm/upload/builder.js +173 -0
- package/dist/esm/upload/builder.js.map +1 -0
- package/dist/esm/upload/car.d.ts +19 -0
- package/dist/esm/upload/car.js +125 -0
- package/dist/esm/upload/car.js.map +1 -0
- package/dist/esm/upload/constants.js +7 -0
- package/dist/esm/upload/constants.js.map +1 -0
- package/dist/esm/upload/index.js +8 -0
- package/dist/esm/upload/manager.d.ts +35 -0
- package/dist/esm/upload/manager.js +248 -0
- package/dist/esm/upload/manager.js.map +1 -0
- package/dist/esm/upload/normalize.js +28 -0
- package/dist/esm/upload/normalize.js.map +1 -0
- package/dist/esm/upload/tus-upload.js +72 -0
- package/dist/esm/upload/tus-upload.js.map +1 -0
- package/dist/esm/upload/xhr-upload.js +39 -0
- package/dist/esm/upload/xhr-upload.js.map +1 -0
- package/dist/esm/utils/env.js +11 -0
- package/dist/esm/utils/env.js.map +1 -0
- package/dist/esm/utils/stream.d.ts +23 -0
- package/dist/esm/utils/stream.js +134 -0
- package/dist/esm/utils/stream.js.map +1 -0
- package/dist/esm/utils/tus-patch.js +51 -0
- package/dist/esm/utils/tus-patch.js.map +1 -0
- package/dist/esm/utils/validation.js +60 -0
- package/dist/esm/utils/validation.js.map +1 -0
- package/package.json +95 -8
- package/public/mockServiceWorker.js +349 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EncoderError } from "./error.js";
|
|
2
|
+
import ky, { isHTTPError, isTimeoutError } from "ky";
|
|
3
|
+
|
|
4
|
+
//#region src/encoder/url.ts
|
|
5
|
+
/**
|
|
6
|
+
* URL encoder - fetches content from URLs and converts to File objects.
|
|
7
|
+
*/
|
|
8
|
+
var UrlEncoder = class {
|
|
9
|
+
async encode(urlString, options) {
|
|
10
|
+
try {
|
|
11
|
+
const blob = await ky(urlString, { fetch: options?.fetch }).blob();
|
|
12
|
+
const filename = options?.name || new URL(urlString).pathname.split("/").pop() || "file";
|
|
13
|
+
return {
|
|
14
|
+
file: new File([blob], filename, { type: blob.type }),
|
|
15
|
+
options: {
|
|
16
|
+
name: options?.name,
|
|
17
|
+
keyvalues: options?.keyvalues
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (isHTTPError(error) || isTimeoutError(error)) throw new EncoderError(`URL encoding failed: ${error.message}`, "NETWORK_ERROR", error);
|
|
22
|
+
if (error instanceof Error) throw new EncoderError(`URL encoding failed: ${error.message}`, "NETWORK_ERROR", error);
|
|
23
|
+
throw new EncoderError("URL encoding failed: unknown error", "UNKNOWN");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Encode a URL to a File object by fetching the content.
|
|
29
|
+
*/
|
|
30
|
+
async function urlToFile(urlString, options) {
|
|
31
|
+
return new UrlEncoder().encode(urlString, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { UrlEncoder, urlToFile };
|
|
36
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","names":[],"sources":["../../../src/encoder/url.ts"],"sourcesContent":["import ky, { isHTTPError, isTimeoutError } from \"ky\";\nimport type { Encoder, EncoderResult, UploadOptions } from \"./types\";\nimport { EncoderError } from \"./error\";\n\n/**\n * URL encoder - fetches content from URLs and converts to File objects.\n */\nexport class UrlEncoder implements Encoder<string> {\n async encode(\n urlString: string,\n options?: UploadOptions,\n ): Promise<EncoderResult> {\n try {\n const blob = await ky(urlString, { fetch: options?.fetch }).blob();\n const filename =\n options?.name || new URL(urlString).pathname.split(\"/\").pop() || \"file\";\n const file = new File([blob], filename, { type: blob.type });\n\n return {\n file,\n options: {\n name: options?.name,\n keyvalues: options?.keyvalues,\n },\n };\n } catch (error) {\n if (isHTTPError(error) || isTimeoutError(error)) {\n throw new EncoderError(\n `URL encoding failed: ${error.message}`,\n \"NETWORK_ERROR\",\n error,\n );\n }\n\n if (error instanceof Error) {\n throw new EncoderError(\n `URL encoding failed: ${error.message}`,\n \"NETWORK_ERROR\",\n error,\n );\n }\n\n throw new EncoderError(\"URL encoding failed: unknown error\", \"UNKNOWN\");\n }\n }\n}\n\n/**\n * Encode a URL to a File object by fetching the content.\n */\nexport async function urlToFile(\n urlString: string,\n options?: UploadOptions,\n): Promise<EncoderResult> {\n const encoder = new UrlEncoder();\n return encoder.encode(urlString, options);\n}\n"],"mappings":";;;;;;;AAOA,IAAa,aAAb,MAAmD;CACjD,MAAM,OACJ,WACA,SACwB;AACxB,MAAI;GACF,MAAM,OAAO,MAAM,GAAG,WAAW,EAAE,OAAO,SAAS,OAAO,CAAC,CAAC,MAAM;GAClE,MAAM,WACJ,SAAS,QAAQ,IAAI,IAAI,UAAU,CAAC,SAAS,MAAM,IAAI,CAAC,KAAK,IAAI;AAGnE,UAAO;IACL,MAHW,IAAI,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAI1D,SAAS;KACP,MAAM,SAAS;KACf,WAAW,SAAS;KACrB;IACF;WACM,OAAO;AACd,OAAI,YAAY,MAAM,IAAI,eAAe,MAAM,CAC7C,OAAM,IAAI,aACR,wBAAwB,MAAM,WAC9B,iBACA,MACD;AAGH,OAAI,iBAAiB,MACnB,OAAM,IAAI,aACR,wBAAwB,MAAM,WAC9B,iBACA,MACD;AAGH,SAAM,IAAI,aAAa,sCAAsC,UAAU;;;;;;;AAQ7E,eAAsB,UACpB,WACA,SACwB;AAExB,QADgB,IAAI,YAAY,CACjB,OAAO,WAAW,QAAQ"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/errors/index.d.ts
|
|
2
|
+
declare class PinnerError extends Error {
|
|
3
|
+
code: string;
|
|
4
|
+
retryable: boolean;
|
|
5
|
+
cause?: Error | undefined;
|
|
6
|
+
constructor(code: string, message: string, retryable: boolean, cause?: Error | undefined);
|
|
7
|
+
}
|
|
8
|
+
declare class ConfigurationError extends PinnerError {
|
|
9
|
+
constructor(message: string, cause?: Error);
|
|
10
|
+
}
|
|
11
|
+
declare class AuthenticationError extends PinnerError {
|
|
12
|
+
constructor(message?: string, cause?: Error);
|
|
13
|
+
}
|
|
14
|
+
declare class UploadError extends PinnerError {
|
|
15
|
+
retryable: boolean;
|
|
16
|
+
code: string;
|
|
17
|
+
constructor(message: string, retryable?: boolean, cause?: Error);
|
|
18
|
+
}
|
|
19
|
+
declare class NetworkError extends UploadError {
|
|
20
|
+
constructor(message?: string, cause?: Error);
|
|
21
|
+
}
|
|
22
|
+
declare class ValidationError extends UploadError {
|
|
23
|
+
field?: string | undefined;
|
|
24
|
+
constructor(message: string, field?: string | undefined, cause?: Error);
|
|
25
|
+
}
|
|
26
|
+
declare class EmptyFileError extends ValidationError {
|
|
27
|
+
constructor(message?: string, cause?: Error);
|
|
28
|
+
}
|
|
29
|
+
declare class TimeoutError extends UploadError {
|
|
30
|
+
constructor(message?: string, cause?: Error);
|
|
31
|
+
}
|
|
32
|
+
declare class PinError extends PinnerError {
|
|
33
|
+
constructor(message?: string, retryable?: boolean, cause?: Error);
|
|
34
|
+
}
|
|
35
|
+
declare class NotFoundError extends PinError {
|
|
36
|
+
constructor(message?: string, cause?: Error);
|
|
37
|
+
}
|
|
38
|
+
declare class RateLimitError extends PinError {
|
|
39
|
+
/**
|
|
40
|
+
* Seconds to wait before retry.
|
|
41
|
+
*/
|
|
42
|
+
retryAfter?: number;
|
|
43
|
+
constructor(message?: string, retryAfter?: number, cause?: Error);
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { AuthenticationError, ConfigurationError, EmptyFileError, NetworkError, NotFoundError, PinError, PinnerError, RateLimitError, TimeoutError, UploadError, ValidationError };
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//#region src/errors/index.ts
|
|
2
|
+
var PinnerError = class extends Error {
|
|
3
|
+
constructor(code, message, retryable, cause) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.retryable = retryable;
|
|
7
|
+
this.cause = cause;
|
|
8
|
+
this.name = "PinnerError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var ConfigurationError = class extends PinnerError {
|
|
12
|
+
constructor(message, cause) {
|
|
13
|
+
super("CONFIGURATION_ERROR", message, false, cause);
|
|
14
|
+
this.name = "ConfigurationError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var AuthenticationError = class extends PinnerError {
|
|
18
|
+
constructor(message = "Authentication failed", cause) {
|
|
19
|
+
super("AUTHENTICATION_ERROR", message, false, cause);
|
|
20
|
+
this.name = "AuthenticationError";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var UploadError = class extends PinnerError {
|
|
24
|
+
code = "UPLOAD_ERROR";
|
|
25
|
+
constructor(message, retryable = false, cause) {
|
|
26
|
+
super("UPLOAD_ERROR", message, retryable, cause);
|
|
27
|
+
this.retryable = retryable;
|
|
28
|
+
this.name = "UploadError";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var NetworkError = class extends UploadError {
|
|
32
|
+
constructor(message = "Network request failed", cause) {
|
|
33
|
+
super(message, true, cause);
|
|
34
|
+
this.name = "NetworkError";
|
|
35
|
+
this.code = "NETWORK_ERROR";
|
|
36
|
+
this.retryable = true;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var ValidationError = class extends UploadError {
|
|
40
|
+
constructor(message, field, cause) {
|
|
41
|
+
super(message, false, cause);
|
|
42
|
+
this.field = field;
|
|
43
|
+
this.name = "ValidationError";
|
|
44
|
+
this.code = "VALIDATION_ERROR";
|
|
45
|
+
this.retryable = false;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var EmptyFileError = class extends ValidationError {
|
|
49
|
+
constructor(message = "Cannot upload empty file", cause) {
|
|
50
|
+
super(message, "file", cause);
|
|
51
|
+
this.name = "EmptyFileError";
|
|
52
|
+
this.code = "EMPTY_FILE_ERROR";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var TimeoutError = class extends UploadError {
|
|
56
|
+
constructor(message = "Request timed out", cause) {
|
|
57
|
+
super(message, true, cause);
|
|
58
|
+
this.name = "TimeoutError";
|
|
59
|
+
this.code = "TIMEOUT_ERROR";
|
|
60
|
+
this.retryable = true;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var PinError = class extends PinnerError {
|
|
64
|
+
constructor(message = "Pin operation failed", retryable = false, cause) {
|
|
65
|
+
super("PIN_ERROR", message, retryable, cause);
|
|
66
|
+
this.name = "PinError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var NotFoundError = class extends PinError {
|
|
70
|
+
constructor(message = "Resource not found", cause) {
|
|
71
|
+
super(message, false, cause);
|
|
72
|
+
this.name = "NotFoundError";
|
|
73
|
+
this.code = "NOT_FOUND";
|
|
74
|
+
this.retryable = false;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var RateLimitError = class extends PinError {
|
|
78
|
+
/**
|
|
79
|
+
* Seconds to wait before retry.
|
|
80
|
+
*/
|
|
81
|
+
retryAfter;
|
|
82
|
+
constructor(message = "Rate limit exceeded", retryAfter, cause) {
|
|
83
|
+
super(message, true, cause);
|
|
84
|
+
this.name = "RateLimitError";
|
|
85
|
+
this.code = "RATE_LIMIT_EXCEEDED";
|
|
86
|
+
this.retryable = true;
|
|
87
|
+
this.retryAfter = retryAfter;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
export { AuthenticationError, ConfigurationError, EmptyFileError, NetworkError, NotFoundError, PinError, PinnerError, RateLimitError, TimeoutError, UploadError, ValidationError };
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/errors/index.ts"],"sourcesContent":["export class PinnerError extends Error {\n constructor(\n public code: string,\n message: string,\n public retryable: boolean,\n public cause?: Error\n ) {\n super(message);\n this.name = \"PinnerError\";\n }\n}\n\nexport class ConfigurationError extends PinnerError {\n constructor(message: string, cause?: Error) {\n super(\"CONFIGURATION_ERROR\", message, false, cause);\n this.name = \"ConfigurationError\";\n }\n}\n\nexport class AuthenticationError extends PinnerError {\n constructor(message: string = \"Authentication failed\", cause?: Error) {\n super(\"AUTHENTICATION_ERROR\", message, false, cause);\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class UploadError extends PinnerError {\n code = \"UPLOAD_ERROR\";\n\n constructor(\n message: string,\n public override retryable: boolean = false,\n cause?: Error\n ) {\n super(\"UPLOAD_ERROR\", message, retryable, cause);\n this.name = \"UploadError\";\n }\n}\n\nexport class NetworkError extends UploadError {\n constructor(message: string = \"Network request failed\", cause?: Error) {\n super(message, true, cause);\n this.name = \"NetworkError\";\n this.code = \"NETWORK_ERROR\";\n this.retryable = true;\n }\n}\n\nexport class ValidationError extends UploadError {\n constructor(message: string, public field?: string, cause?: Error) {\n super(message, false, cause);\n this.name = \"ValidationError\";\n this.code = \"VALIDATION_ERROR\";\n this.retryable = false;\n }\n}\n\nexport class EmptyFileError extends ValidationError {\n constructor(message: string = \"Cannot upload empty file\", cause?: Error) {\n super(message, \"file\", cause);\n this.name = \"EmptyFileError\";\n this.code = \"EMPTY_FILE_ERROR\";\n }\n}\n\nexport class TimeoutError extends UploadError {\n constructor(message: string = \"Request timed out\", cause?: Error) {\n super(message, true, cause);\n this.name = \"TimeoutError\";\n this.code = \"TIMEOUT_ERROR\";\n this.retryable = true;\n }\n}\n\nexport class PinError extends PinnerError {\n constructor(message: string = \"Pin operation failed\", retryable: boolean = false, cause?: Error) {\n super(\"PIN_ERROR\", message, retryable, cause);\n this.name = \"PinError\";\n }\n}\n\nexport class NotFoundError extends PinError {\n constructor(message: string = \"Resource not found\", cause?: Error) {\n super(message, false, cause);\n this.name = \"NotFoundError\";\n this.code = \"NOT_FOUND\";\n this.retryable = false;\n }\n}\n\nexport class RateLimitError extends PinError {\n /**\n * Seconds to wait before retry.\n */\n retryAfter?: number;\n\n constructor(message: string = \"Rate limit exceeded\", retryAfter?: number, cause?: Error) {\n super(message, true, cause);\n this.name = \"RateLimitError\";\n this.code = \"RATE_LIMIT_EXCEEDED\";\n this.retryable = true;\n this.retryAfter = retryAfter;\n }\n}\n\nexport class EnvironmentError extends PinnerError {\n constructor(message: string = \"Unsupported environment\", cause?: Error) {\n super(\"ENVIRONMENT_ERROR\", message, false, cause);\n this.name = \"EnvironmentError\";\n }\n}"],"mappings":";AAAA,IAAa,cAAb,cAAiC,MAAM;CACrC,YACE,AAAO,MACP,SACA,AAAO,WACP,AAAO,OACP;AACA,QAAM,QAAQ;EALP;EAEA;EACA;AAGP,OAAK,OAAO;;;AAIhB,IAAa,qBAAb,cAAwC,YAAY;CAClD,YAAY,SAAiB,OAAe;AAC1C,QAAM,uBAAuB,SAAS,OAAO,MAAM;AACnD,OAAK,OAAO;;;AAIhB,IAAa,sBAAb,cAAyC,YAAY;CACnD,YAAY,UAAkB,yBAAyB,OAAe;AACpE,QAAM,wBAAwB,SAAS,OAAO,MAAM;AACpD,OAAK,OAAO;;;AAIhB,IAAa,cAAb,cAAiC,YAAY;CAC3C,OAAO;CAEP,YACE,SACA,AAAgB,YAAqB,OACrC,OACA;AACA,QAAM,gBAAgB,SAAS,WAAW,MAAM;EAHhC;AAIhB,OAAK,OAAO;;;AAIhB,IAAa,eAAb,cAAkC,YAAY;CAC5C,YAAY,UAAkB,0BAA0B,OAAe;AACrE,QAAM,SAAS,MAAM,MAAM;AAC3B,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,YAAY;;;AAIrB,IAAa,kBAAb,cAAqC,YAAY;CAC/C,YAAY,SAAiB,AAAO,OAAgB,OAAe;AACjE,QAAM,SAAS,OAAO,MAAM;EADM;AAElC,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,YAAY;;;AAIrB,IAAa,iBAAb,cAAoC,gBAAgB;CAClD,YAAY,UAAkB,4BAA4B,OAAe;AACvE,QAAM,SAAS,QAAQ,MAAM;AAC7B,OAAK,OAAO;AACZ,OAAK,OAAO;;;AAIhB,IAAa,eAAb,cAAkC,YAAY;CAC5C,YAAY,UAAkB,qBAAqB,OAAe;AAChE,QAAM,SAAS,MAAM,MAAM;AAC3B,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,YAAY;;;AAIrB,IAAa,WAAb,cAA8B,YAAY;CACxC,YAAY,UAAkB,wBAAwB,YAAqB,OAAO,OAAe;AAC/F,QAAM,aAAa,SAAS,WAAW,MAAM;AAC7C,OAAK,OAAO;;;AAIhB,IAAa,gBAAb,cAAmC,SAAS;CAC1C,YAAY,UAAkB,sBAAsB,OAAe;AACjE,QAAM,SAAS,OAAO,MAAM;AAC5B,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,YAAY;;;AAIrB,IAAa,iBAAb,cAAoC,SAAS;;;;CAI3C;CAEA,YAAY,UAAkB,uBAAuB,YAAqB,OAAe;AACvF,QAAM,SAAS,MAAM,MAAM;AAC3B,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,YAAY;AACjB,OAAK,aAAa"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PinnerConfig } from "./config.js";
|
|
2
|
+
import { UploadInput, UploadOperation, UploadOptions, UploadProgress, UploadResult } from "./types/upload.js";
|
|
3
|
+
import { RemoteAddOptions, RemoteLsOptions, RemotePin, RemotePins } from "./types/pin.js";
|
|
4
|
+
import { Pinner } from "./pinner.js";
|
|
5
|
+
import { UploadManager } from "./upload/manager.js";
|
|
6
|
+
import { CarPreprocessOptions, CarPreprocessResult, destroyCarPreprocessor, isCarFile, preprocessToCar } from "./upload/car.js";
|
|
7
|
+
import { AuthenticationError, ConfigurationError, EmptyFileError, NetworkError, NotFoundError, PinError, PinnerError, RateLimitError, TimeoutError, UploadError, ValidationError } from "./errors/index.js";
|
|
8
|
+
import { isAuthenticationError, isRetryable } from "./types/type-guards.js";
|
|
9
|
+
import { FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM } from "./types/mime-types.js";
|
|
10
|
+
import { UnstorageBlockstoreOptions, setDriverFactory } from "./blockstore/unstorage-base.js";
|
|
11
|
+
import { createBlockstore, createDatastore } from "./blockstore/unstorage.js";
|
|
12
|
+
import "./blockstore/index.js";
|
|
13
|
+
import { asyncGeneratorToReadableStream, calculateStreamSize, readableStreamToAsyncIterable, streamToBlob } from "./utils/stream.js";
|
|
14
|
+
import { pinataAdapter } from "./adapters/pinata/adapter.js";
|
|
15
|
+
import "./adapters/pinata/index.js";
|
|
16
|
+
export { AuthenticationError, type CarPreprocessOptions, type CarPreprocessResult, ConfigurationError, EmptyFileError, FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM, NetworkError, NotFoundError, PinError, Pinner, type PinnerConfig, PinnerError, RateLimitError, type RemoteAddOptions, type RemoteLsOptions, type RemotePin, type RemotePins, TimeoutError, type UnstorageBlockstoreOptions, UploadError, type UploadInput, UploadManager, type UploadOperation, type UploadOptions, type UploadProgress, type UploadResult, ValidationError, asyncGeneratorToReadableStream, calculateStreamSize, createBlockstore, createDatastore, destroyCarPreprocessor, isAuthenticationError, isCarFile, isRetryable, pinataAdapter, preprocessToCar, readableStreamToAsyncIterable, setDriverFactory, streamToBlob };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM } from "./types/mime-types.js";
|
|
2
|
+
import { asyncGeneratorToReadableStream, calculateStreamSize, readableStreamToAsyncIterable, streamToBlob } from "./utils/stream.js";
|
|
3
|
+
import { setDriverFactory } from "./blockstore/unstorage-base.js";
|
|
4
|
+
import { createBlockstore, createDatastore } from "./blockstore/unstorage.js";
|
|
5
|
+
import "./blockstore/index.js";
|
|
6
|
+
import { destroyCarPreprocessor, isCarFile, preprocessToCar } from "./upload/car.js";
|
|
7
|
+
import { AuthenticationError, ConfigurationError, EmptyFileError, NetworkError, NotFoundError, PinError, PinnerError, RateLimitError, TimeoutError, UploadError, ValidationError } from "./errors/index.js";
|
|
8
|
+
import { UploadManager } from "./upload/manager.js";
|
|
9
|
+
import { Pinner } from "./pinner.js";
|
|
10
|
+
import { isAuthenticationError, isRetryable } from "./types/type-guards.js";
|
|
11
|
+
import { pinataAdapter } from "./adapters/pinata/adapter.js";
|
|
12
|
+
import "./adapters/pinata/index.js";
|
|
13
|
+
|
|
14
|
+
export { AuthenticationError, ConfigurationError, EmptyFileError, FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM, NetworkError, NotFoundError, PinError, Pinner, PinnerError, RateLimitError, TimeoutError, UploadError, UploadManager, ValidationError, asyncGeneratorToReadableStream, calculateStreamSize, createBlockstore, createDatastore, destroyCarPreprocessor, isAuthenticationError, isCarFile, isRetryable, pinataAdapter, preprocessToCar, readableStreamToAsyncIterable, setDriverFactory, streamToBlob };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ConfigurationError, NotFoundError } from "../errors/index.js";
|
|
2
|
+
import { CID } from "multiformats/cid";
|
|
3
|
+
import { Configuration, RemotePinningServiceClient } from "@ipfs-shipyard/pinning-service-client";
|
|
4
|
+
|
|
5
|
+
//#region src/pin/client.ts
|
|
6
|
+
var PinClient = class {
|
|
7
|
+
client = null;
|
|
8
|
+
config;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
}
|
|
12
|
+
getClient() {
|
|
13
|
+
if (this.client) return this.client;
|
|
14
|
+
if (!this.config.jwt) throw new ConfigurationError("JWT token is required");
|
|
15
|
+
this.client = new RemotePinningServiceClient(new Configuration({
|
|
16
|
+
endpointUrl: this.config.endpoint,
|
|
17
|
+
accessToken: this.config.jwt,
|
|
18
|
+
fetchApi: this.config.fetch ?? fetch
|
|
19
|
+
}));
|
|
20
|
+
return this.client;
|
|
21
|
+
}
|
|
22
|
+
async *add(cid, options) {
|
|
23
|
+
const client = this.getClient();
|
|
24
|
+
const pin = {
|
|
25
|
+
cid: cid.toString(),
|
|
26
|
+
name: options?.name,
|
|
27
|
+
meta: options?.metadata,
|
|
28
|
+
origins: options?.origins
|
|
29
|
+
};
|
|
30
|
+
await client.pinsPost({ pin }, { signal: options?.signal });
|
|
31
|
+
yield cid;
|
|
32
|
+
}
|
|
33
|
+
async *ls(options) {
|
|
34
|
+
const response = await this.getClient().pinsGet(this.normalizeListOptions(options), { signal: options?.signal });
|
|
35
|
+
for (const result of response.results) yield this.mapResponse(result);
|
|
36
|
+
}
|
|
37
|
+
async isPinned(cid, options) {
|
|
38
|
+
try {
|
|
39
|
+
await this.get(cid, options);
|
|
40
|
+
return true;
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async get(cid, options) {
|
|
46
|
+
const response = await this.getClient().pinsGet({ cid: [cid.toString()] }, { signal: options?.signal });
|
|
47
|
+
if (response.results.length === 0) throw new NotFoundError(`Pin not found for CID: ${cid.toString()}`);
|
|
48
|
+
return this.mapResponse(response.results[0]);
|
|
49
|
+
}
|
|
50
|
+
async setMetadata(cid, metadata, options) {
|
|
51
|
+
const client = this.getClient();
|
|
52
|
+
const response = await client.pinsGet({ cid: [cid.toString()] }, { signal: options?.signal });
|
|
53
|
+
if (response.results.length === 0) throw new NotFoundError(`Pin not found for CID: ${cid.toString()}`);
|
|
54
|
+
const pin = response.results[0];
|
|
55
|
+
await client.pinsRequestidPost({
|
|
56
|
+
requestid: pin.requestid,
|
|
57
|
+
pin: {
|
|
58
|
+
cid: pin.pin.cid,
|
|
59
|
+
name: pin.pin.name,
|
|
60
|
+
meta: metadata,
|
|
61
|
+
origins: pin.pin.origins
|
|
62
|
+
}
|
|
63
|
+
}, { signal: options?.signal });
|
|
64
|
+
}
|
|
65
|
+
async *rm(cid, options) {
|
|
66
|
+
const client = this.getClient();
|
|
67
|
+
const response = await client.pinsGet({ cid: [cid.toString()] }, { signal: options?.signal });
|
|
68
|
+
await Promise.all([...response.results].map(async (result) => {
|
|
69
|
+
return client.pinsRequestidDelete({ requestid: result.requestid }, { signal: options?.signal });
|
|
70
|
+
}));
|
|
71
|
+
yield cid;
|
|
72
|
+
}
|
|
73
|
+
mapResponse(response) {
|
|
74
|
+
return {
|
|
75
|
+
cid: CID.parse(response.pin.cid),
|
|
76
|
+
name: response.pin.name,
|
|
77
|
+
status: response.status,
|
|
78
|
+
created: response.created,
|
|
79
|
+
size: response.pin.meta?.size ? parseInt(response.pin.meta.size, 10) : void 0,
|
|
80
|
+
metadata: response.pin.meta
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
normalizeListOptions(options) {
|
|
84
|
+
const request = {};
|
|
85
|
+
if (options?.limit !== void 0) request.limit = options.limit;
|
|
86
|
+
if (options?.cursor !== void 0) request.after = options.cursor;
|
|
87
|
+
if (options?.status !== void 0) request.status = options.status;
|
|
88
|
+
if (options?.name !== void 0) request.name = options.name;
|
|
89
|
+
return request;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { PinClient };
|
|
95
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../../src/pin/client.ts"],"sourcesContent":["import {\n Configuration,\n type Pin,\n type PinStatus,\n RemotePinningServiceClient,\n} from \"@ipfs-shipyard/pinning-service-client\";\nimport type { PinnerConfig } from \"../config\";\nimport type {\n AbortOptions,\n RemoteAddOptions,\n RemoteLsOptions,\n RemotePin,\n RemotePins,\n} from \"@/types/pin\";\nimport { CID } from \"multiformats/cid\";\nimport { ConfigurationError, NotFoundError } from \"@/errors\";\n\nexport class PinClient implements RemotePins {\n private client: RemotePinningServiceClient | null = null;\n private config: PinnerConfig;\n\n constructor(config: PinnerConfig) {\n this.config = config;\n }\n\n protected getClient(): RemotePinningServiceClient {\n if (this.client) {\n return this.client;\n }\n\n if (!this.config.jwt) {\n throw new ConfigurationError(\"JWT token is required\");\n }\n\n const configuration = new Configuration({\n endpointUrl: this.config.endpoint,\n accessToken: this.config.jwt,\n fetchApi: this.config.fetch ?? fetch,\n });\n\n this.client = new RemotePinningServiceClient(configuration);\n return this.client;\n }\n\n async *add(\n cid: CID,\n options?: RemoteAddOptions,\n ): AsyncGenerator<CID, void, undefined> {\n const client = this.getClient();\n\n const pin: Pin = {\n cid: cid.toString(),\n name: options?.name,\n meta: options?.metadata,\n origins: options?.origins,\n };\n\n await client.pinsPost({ pin }, { signal: options?.signal });\n\n yield cid;\n }\n\n async *ls(\n options?: RemoteLsOptions,\n ): AsyncGenerator<RemotePin, void, undefined> {\n const client = this.getClient();\n const response = await client.pinsGet(this.normalizeListOptions(options), {\n signal: options?.signal,\n });\n\n for (const result of response.results) {\n yield this.mapResponse(result);\n }\n }\n\n async isPinned(cid: CID, options?: AbortOptions): Promise<boolean> {\n try {\n await this.get(cid, options);\n return true;\n } catch {\n return false;\n }\n }\n\n async get(cid: CID, options?: AbortOptions): Promise<RemotePin> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n {\n signal: options?.signal,\n },\n );\n\n if (response.results.length === 0) {\n throw new NotFoundError(`Pin not found for CID: ${cid.toString()}`);\n }\n\n return this.mapResponse(response.results[0]);\n }\n\n async setMetadata(\n cid: CID,\n metadata: Record<string, string> | undefined,\n options?: AbortOptions,\n ): Promise<void> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n {\n signal: options?.signal,\n },\n );\n\n if (response.results.length === 0) {\n throw new NotFoundError(`Pin not found for CID: ${cid.toString()}`);\n }\n\n const pin = response.results[0];\n await client.pinsRequestidPost(\n {\n requestid: pin.requestid,\n pin: {\n cid: pin.pin.cid,\n name: pin.pin.name,\n meta: metadata,\n origins: pin.pin.origins,\n },\n },\n { signal: options?.signal },\n );\n }\n\n async *rm(\n cid: CID,\n options?: AbortOptions,\n ): AsyncGenerator<CID, void, undefined> {\n const client = this.getClient();\n const response = await client.pinsGet(\n { cid: [cid.toString()] },\n { signal: options?.signal },\n );\n\n await Promise.all(\n [...response.results].map(async (result) => {\n return client.pinsRequestidDelete(\n { requestid: result.requestid },\n { signal: options?.signal },\n );\n }),\n );\n\n yield cid;\n }\n\n private mapResponse(response: PinStatus): RemotePin {\n return {\n cid: CID.parse(response.pin.cid),\n name: response.pin.name,\n status: response.status,\n created: response.created,\n size: response.pin.meta?.size\n ? parseInt(response.pin.meta.size, 10)\n : undefined,\n metadata: response.pin.meta,\n };\n }\n\n private normalizeListOptions(\n options?: RemoteLsOptions,\n ): Record<string, unknown> {\n const request: Record<string, unknown> = {};\n\n if (options?.limit !== undefined) {\n request.limit = options.limit;\n }\n if (options?.cursor !== undefined) {\n request.after = options.cursor;\n }\n if (options?.status !== undefined) {\n request.status = options.status;\n }\n if (options?.name !== undefined) {\n request.name = options.name;\n }\n\n return request;\n }\n}\n"],"mappings":";;;;;AAiBA,IAAa,YAAb,MAA6C;CAC3C,AAAQ,SAA4C;CACpD,AAAQ;CAER,YAAY,QAAsB;AAChC,OAAK,SAAS;;CAGhB,AAAU,YAAwC;AAChD,MAAI,KAAK,OACP,QAAO,KAAK;AAGd,MAAI,CAAC,KAAK,OAAO,IACf,OAAM,IAAI,mBAAmB,wBAAwB;AASvD,OAAK,SAAS,IAAI,2BANI,IAAI,cAAc;GACtC,aAAa,KAAK,OAAO;GACzB,aAAa,KAAK,OAAO;GACzB,UAAU,KAAK,OAAO,SAAS;GAChC,CAAC,CAEyD;AAC3D,SAAO,KAAK;;CAGd,OAAO,IACL,KACA,SACsC;EACtC,MAAM,SAAS,KAAK,WAAW;EAE/B,MAAM,MAAW;GACf,KAAK,IAAI,UAAU;GACnB,MAAM,SAAS;GACf,MAAM,SAAS;GACf,SAAS,SAAS;GACnB;AAED,QAAM,OAAO,SAAS,EAAE,KAAK,EAAE,EAAE,QAAQ,SAAS,QAAQ,CAAC;AAE3D,QAAM;;CAGR,OAAO,GACL,SAC4C;EAE5C,MAAM,WAAW,MADF,KAAK,WAAW,CACD,QAAQ,KAAK,qBAAqB,QAAQ,EAAE,EACxE,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAK,MAAM,UAAU,SAAS,QAC5B,OAAM,KAAK,YAAY,OAAO;;CAIlC,MAAM,SAAS,KAAU,SAA0C;AACjE,MAAI;AACF,SAAM,KAAK,IAAI,KAAK,QAAQ;AAC5B,UAAO;UACD;AACN,UAAO;;;CAIX,MAAM,IAAI,KAAU,SAA4C;EAE9D,MAAM,WAAW,MADF,KAAK,WAAW,CACD,QAC5B,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,EAAE,EACzB,EACE,QAAQ,SAAS,QAClB,CACF;AAED,MAAI,SAAS,QAAQ,WAAW,EAC9B,OAAM,IAAI,cAAc,0BAA0B,IAAI,UAAU,GAAG;AAGrE,SAAO,KAAK,YAAY,SAAS,QAAQ,GAAG;;CAG9C,MAAM,YACJ,KACA,UACA,SACe;EACf,MAAM,SAAS,KAAK,WAAW;EAC/B,MAAM,WAAW,MAAM,OAAO,QAC5B,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,EAAE,EACzB,EACE,QAAQ,SAAS,QAClB,CACF;AAED,MAAI,SAAS,QAAQ,WAAW,EAC9B,OAAM,IAAI,cAAc,0BAA0B,IAAI,UAAU,GAAG;EAGrE,MAAM,MAAM,SAAS,QAAQ;AAC7B,QAAM,OAAO,kBACX;GACE,WAAW,IAAI;GACf,KAAK;IACH,KAAK,IAAI,IAAI;IACb,MAAM,IAAI,IAAI;IACd,MAAM;IACN,SAAS,IAAI,IAAI;IAClB;GACF,EACD,EAAE,QAAQ,SAAS,QAAQ,CAC5B;;CAGH,OAAO,GACL,KACA,SACsC;EACtC,MAAM,SAAS,KAAK,WAAW;EAC/B,MAAM,WAAW,MAAM,OAAO,QAC5B,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,EAAE,EACzB,EAAE,QAAQ,SAAS,QAAQ,CAC5B;AAED,QAAM,QAAQ,IACZ,CAAC,GAAG,SAAS,QAAQ,CAAC,IAAI,OAAO,WAAW;AAC1C,UAAO,OAAO,oBACZ,EAAE,WAAW,OAAO,WAAW,EAC/B,EAAE,QAAQ,SAAS,QAAQ,CAC5B;IACD,CACH;AAED,QAAM;;CAGR,AAAQ,YAAY,UAAgC;AAClD,SAAO;GACL,KAAK,IAAI,MAAM,SAAS,IAAI,IAAI;GAChC,MAAM,SAAS,IAAI;GACnB,QAAQ,SAAS;GACjB,SAAS,SAAS;GAClB,MAAM,SAAS,IAAI,MAAM,OACrB,SAAS,SAAS,IAAI,KAAK,MAAM,GAAG,GACpC;GACJ,UAAU,SAAS,IAAI;GACxB;;CAGH,AAAQ,qBACN,SACyB;EACzB,MAAM,UAAmC,EAAE;AAE3C,MAAI,SAAS,UAAU,OACrB,SAAQ,QAAQ,QAAQ;AAE1B,MAAI,SAAS,WAAW,OACtB,SAAQ,QAAQ,QAAQ;AAE1B,MAAI,SAAS,WAAW,OACtB,SAAQ,SAAS,QAAQ;AAE3B,MAAI,SAAS,SAAS,OACpB,SAAQ,OAAO,QAAQ;AAGzB,SAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { PinClient } from "./client.js";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { PinnerConfig } from "./config.js";
|
|
2
|
+
import { UploadOperation, UploadOptions, UploadResult } from "./types/upload.js";
|
|
3
|
+
import { UploadMethodAndBuilder } from "./upload/builder.js";
|
|
4
|
+
import { AbortOptions, RemoteAddOptions, RemoteLsOptions, RemotePin, RemotePins } from "./types/pin.js";
|
|
5
|
+
import { OperationPollingOptions } from "@lumeweb/portal-sdk";
|
|
6
|
+
import { CID } from "multiformats/cid";
|
|
7
|
+
|
|
8
|
+
//#region src/pinner.d.ts
|
|
9
|
+
declare class Pinner {
|
|
10
|
+
private uploadManager;
|
|
11
|
+
private _pins;
|
|
12
|
+
private _upload?;
|
|
13
|
+
constructor(config: PinnerConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Access the remote pins interface.
|
|
16
|
+
*/
|
|
17
|
+
get pins(): RemotePins;
|
|
18
|
+
/**
|
|
19
|
+
* Upload interface that works as both a method and a builder namespace.
|
|
20
|
+
*
|
|
21
|
+
* As a method: upload(file, options) -> UploadOperation
|
|
22
|
+
* As a property: upload.file(), upload.json(), etc. -> Builder
|
|
23
|
+
*/
|
|
24
|
+
get upload(): UploadMethodAndBuilder;
|
|
25
|
+
/**
|
|
26
|
+
* Upload a file and wait for completion.
|
|
27
|
+
* Convenience method for simple use cases where controls aren't needed.
|
|
28
|
+
*/
|
|
29
|
+
uploadAndWait(file: File, options?: UploadOptions): Promise<UploadResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Wait for an operation to complete or reach a settled state.
|
|
32
|
+
* @param input Either an operation ID (number) or an UploadResult
|
|
33
|
+
* @param options Polling options (interval, timeout, settledStates)
|
|
34
|
+
* @returns UploadResult with operation status merged in
|
|
35
|
+
*/
|
|
36
|
+
waitForOperation(input: number | UploadResult, options?: OperationPollingOptions): Promise<UploadResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Upload a directory to IPFS.
|
|
39
|
+
*/
|
|
40
|
+
uploadDirectory(files: File[], options?: UploadOptions): Promise<UploadOperation>;
|
|
41
|
+
/**
|
|
42
|
+
* Upload a CAR file without preprocessing.
|
|
43
|
+
* This is useful for passthrough of pre-generated CAR files.
|
|
44
|
+
*/
|
|
45
|
+
uploadCar(file: File | ReadableStream<Uint8Array>, options?: UploadOptions): Promise<UploadOperation>;
|
|
46
|
+
/**
|
|
47
|
+
* Pin existing content by CID.
|
|
48
|
+
*/
|
|
49
|
+
pinByHash(cid: string | CID, options?: RemoteAddOptions): Promise<AsyncGenerator<CID, void, undefined>>;
|
|
50
|
+
/**
|
|
51
|
+
* List pinned content.
|
|
52
|
+
*/
|
|
53
|
+
listPins(options?: RemoteLsOptions): Promise<RemotePin[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Get pin status.
|
|
56
|
+
*/
|
|
57
|
+
getPinStatus(cid: string | CID): Promise<RemotePin>;
|
|
58
|
+
/**
|
|
59
|
+
* Check if content is pinned.
|
|
60
|
+
*/
|
|
61
|
+
isPinned(cid: string | CID): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Update pin metadata.
|
|
64
|
+
*/
|
|
65
|
+
setPinMetadata(cid: string | CID, metadata: Record<string, string> | undefined): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Remove a pin. The block may be deleted when garbage collection is run.
|
|
68
|
+
*/
|
|
69
|
+
unpin(cid: string | CID, options?: AbortOptions): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Destroy the client and cleanup resources.
|
|
72
|
+
*/
|
|
73
|
+
destroy(): void;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { Pinner };
|
|
77
|
+
//# sourceMappingURL=pinner.d.ts.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { UploadManager } from "./upload/manager.js";
|
|
2
|
+
import { createUploadBuilderNamespace } from "./upload/builder.js";
|
|
3
|
+
import "./upload/index.js";
|
|
4
|
+
import { PinClient } from "./pin/client.js";
|
|
5
|
+
import "./pin/index.js";
|
|
6
|
+
import { CID } from "multiformats/cid";
|
|
7
|
+
|
|
8
|
+
//#region src/pinner.ts
|
|
9
|
+
var Pinner = class {
|
|
10
|
+
uploadManager;
|
|
11
|
+
_pins;
|
|
12
|
+
_upload;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.uploadManager = new UploadManager(config);
|
|
15
|
+
this._pins = new PinClient(config);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Access the remote pins interface.
|
|
19
|
+
*/
|
|
20
|
+
get pins() {
|
|
21
|
+
return this._pins;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Upload interface that works as both a method and a builder namespace.
|
|
25
|
+
*
|
|
26
|
+
* As a method: upload(file, options) -> UploadOperation
|
|
27
|
+
* As a property: upload.file(), upload.json(), etc. -> Builder
|
|
28
|
+
*/
|
|
29
|
+
get upload() {
|
|
30
|
+
if (!this._upload) {
|
|
31
|
+
const builderNamespace = createUploadBuilderNamespace(this);
|
|
32
|
+
const uploadMethod = async (file, options) => {
|
|
33
|
+
return this.uploadManager.upload(file, options);
|
|
34
|
+
};
|
|
35
|
+
this._upload = new Proxy(uploadMethod, { get(target, prop) {
|
|
36
|
+
if (prop in builderNamespace) return Reflect.get(builderNamespace, prop);
|
|
37
|
+
return Reflect.get(target, prop);
|
|
38
|
+
} });
|
|
39
|
+
}
|
|
40
|
+
return this._upload;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Upload a file and wait for completion.
|
|
44
|
+
* Convenience method for simple use cases where controls aren't needed.
|
|
45
|
+
*/
|
|
46
|
+
async uploadAndWait(file, options) {
|
|
47
|
+
return (await this.upload(file, options)).result;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Wait for an operation to complete or reach a settled state.
|
|
51
|
+
* @param input Either an operation ID (number) or an UploadResult
|
|
52
|
+
* @param options Polling options (interval, timeout, settledStates)
|
|
53
|
+
* @returns UploadResult with operation status merged in
|
|
54
|
+
*/
|
|
55
|
+
async waitForOperation(input, options) {
|
|
56
|
+
return this.uploadManager.waitForOperation(input, options);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Upload a directory to IPFS.
|
|
60
|
+
*/
|
|
61
|
+
async uploadDirectory(files, options) {
|
|
62
|
+
return this.uploadManager.uploadDirectory(files, options);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Upload a CAR file without preprocessing.
|
|
66
|
+
* This is useful for passthrough of pre-generated CAR files.
|
|
67
|
+
*/
|
|
68
|
+
async uploadCar(file, options) {
|
|
69
|
+
return this.uploadManager.uploadCar(file, options);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Pin existing content by CID.
|
|
73
|
+
*/
|
|
74
|
+
async pinByHash(cid, options) {
|
|
75
|
+
const cidObj = typeof cid === "string" ? CID.parse(cid) : cid;
|
|
76
|
+
return this.pins.add(cidObj, options);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* List pinned content.
|
|
80
|
+
*/
|
|
81
|
+
async listPins(options) {
|
|
82
|
+
const pins = [];
|
|
83
|
+
for await (const pin of this.pins.ls(options)) pins.push(pin);
|
|
84
|
+
return pins;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get pin status.
|
|
88
|
+
*/
|
|
89
|
+
async getPinStatus(cid) {
|
|
90
|
+
const cidObj = typeof cid === "string" ? CID.parse(cid) : cid;
|
|
91
|
+
return this.pins.get(cidObj);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if content is pinned.
|
|
95
|
+
*/
|
|
96
|
+
async isPinned(cid) {
|
|
97
|
+
const cidObj = typeof cid === "string" ? CID.parse(cid) : cid;
|
|
98
|
+
return this.pins.isPinned(cidObj);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Update pin metadata.
|
|
102
|
+
*/
|
|
103
|
+
async setPinMetadata(cid, metadata) {
|
|
104
|
+
const cidObj = typeof cid === "string" ? CID.parse(cid) : cid;
|
|
105
|
+
return this.pins.setMetadata(cidObj, metadata);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Remove a pin. The block may be deleted when garbage collection is run.
|
|
109
|
+
*/
|
|
110
|
+
async unpin(cid, options) {
|
|
111
|
+
const cidObj = typeof cid === "string" ? CID.parse(cid) : cid;
|
|
112
|
+
const generator = this.pins.rm(cidObj, options);
|
|
113
|
+
for await (const _ of generator);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Destroy the client and cleanup resources.
|
|
117
|
+
*/
|
|
118
|
+
destroy() {
|
|
119
|
+
this.uploadManager.destroy();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
export { Pinner };
|
|
125
|
+
//# sourceMappingURL=pinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinner.js","names":[],"sources":["../../src/pinner.ts"],"sourcesContent":["import type { PinnerConfig } from \"./config\";\nimport { UploadManager } from \"./upload\";\nimport { PinClient } from \"./pin\";\nimport type { UploadMethodAndBuilder } from \"@/upload/builder\";\nimport { createUploadBuilderNamespace } from \"@/upload/builder\";\nimport type {\n UploadOperation,\n UploadOptions,\n UploadResult,\n} from \"@/types/upload\";\nimport type { OperationPollingOptions } from \"@lumeweb/portal-sdk\";\nimport type {\n AbortOptions,\n RemoteAddOptions,\n RemoteLsOptions,\n RemotePin,\n RemotePins,\n} from \"@/types/pin\";\nimport { CID } from \"multiformats/cid\";\n\nexport class Pinner {\n private uploadManager: UploadManager;\n private _pins: RemotePins;\n private _upload?: UploadMethodAndBuilder;\n\n constructor(config: PinnerConfig) {\n this.uploadManager = new UploadManager(config);\n this._pins = new PinClient(config);\n }\n\n /**\n * Access the remote pins interface.\n */\n get pins(): RemotePins {\n return this._pins;\n }\n\n /**\n * Upload interface that works as both a method and a builder namespace.\n *\n * As a method: upload(file, options) -> UploadOperation\n * As a property: upload.file(), upload.json(), etc. -> Builder\n */\n get upload(): UploadMethodAndBuilder {\n if (!this._upload) {\n const builderNamespace = createUploadBuilderNamespace(this);\n const uploadMethod = async (\n file: File,\n options?: UploadOptions,\n ): Promise<UploadOperation> => {\n return this.uploadManager.upload(file, options);\n };\n\n this._upload = new Proxy(uploadMethod, {\n get(target, prop) {\n if (prop in builderNamespace) {\n return Reflect.get(builderNamespace, prop);\n }\n return Reflect.get(target, prop);\n },\n }) as UploadMethodAndBuilder;\n }\n return this._upload;\n }\n\n /**\n * Upload a file and wait for completion.\n * Convenience method for simple use cases where controls aren't needed.\n */\n async uploadAndWait(\n file: File,\n options?: UploadOptions,\n ): Promise<UploadResult> {\n const operation = await this.upload(file, options);\n return operation.result;\n }\n\n /**\n * Wait for an operation to complete or reach a settled state.\n * @param input Either an operation ID (number) or an UploadResult\n * @param options Polling options (interval, timeout, settledStates)\n * @returns UploadResult with operation status merged in\n */\n async waitForOperation(\n input: number | UploadResult,\n options?: OperationPollingOptions,\n ): Promise<UploadResult> {\n return this.uploadManager.waitForOperation(input, options);\n }\n\n /**\n * Upload a directory to IPFS.\n */\n async uploadDirectory(\n files: File[],\n options?: UploadOptions,\n ): Promise<UploadOperation> {\n return this.uploadManager.uploadDirectory(files, options);\n }\n\n /**\n * Upload a CAR file without preprocessing.\n * This is useful for passthrough of pre-generated CAR files.\n */\n async uploadCar(\n file: File | ReadableStream<Uint8Array>,\n options?: UploadOptions,\n ): Promise<UploadOperation> {\n return this.uploadManager.uploadCar(file, options);\n }\n\n /**\n * Pin existing content by CID.\n */\n async pinByHash(\n cid: string | CID,\n options?: RemoteAddOptions,\n ): Promise<AsyncGenerator<CID, void, undefined>> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.add(cidObj, options);\n }\n\n /**\n * List pinned content.\n */\n async listPins(options?: RemoteLsOptions): Promise<RemotePin[]> {\n const pins: RemotePin[] = [];\n for await (const pin of this.pins.ls(options)) {\n pins.push(pin);\n }\n return pins;\n }\n\n /**\n * Get pin status.\n */\n async getPinStatus(cid: string | CID): Promise<RemotePin> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.get(cidObj);\n }\n\n /**\n * Check if content is pinned.\n */\n async isPinned(cid: string | CID): Promise<boolean> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.isPinned(cidObj);\n }\n\n /**\n * Update pin metadata.\n */\n async setPinMetadata(\n cid: string | CID,\n metadata: Record<string, string> | undefined,\n ): Promise<void> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n return this.pins.setMetadata(cidObj, metadata);\n }\n\n /**\n * Remove a pin. The block may be deleted when garbage collection is run.\n */\n async unpin(cid: string | CID, options?: AbortOptions): Promise<void> {\n const cidObj = typeof cid === \"string\" ? CID.parse(cid) : cid;\n const generator = this.pins.rm(cidObj, options);\n for await (const _ of generator) {\n // Consume the generator to complete the unpin operation\n }\n }\n\n /**\n * Destroy the client and cleanup resources.\n */\n destroy(): void {\n this.uploadManager.destroy();\n }\n}\n"],"mappings":";;;;;;;;AAoBA,IAAa,SAAb,MAAoB;CAClB,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,QAAsB;AAChC,OAAK,gBAAgB,IAAI,cAAc,OAAO;AAC9C,OAAK,QAAQ,IAAI,UAAU,OAAO;;;;;CAMpC,IAAI,OAAmB;AACrB,SAAO,KAAK;;;;;;;;CASd,IAAI,SAAiC;AACnC,MAAI,CAAC,KAAK,SAAS;GACjB,MAAM,mBAAmB,6BAA6B,KAAK;GAC3D,MAAM,eAAe,OACnB,MACA,YAC6B;AAC7B,WAAO,KAAK,cAAc,OAAO,MAAM,QAAQ;;AAGjD,QAAK,UAAU,IAAI,MAAM,cAAc,EACrC,IAAI,QAAQ,MAAM;AAChB,QAAI,QAAQ,iBACV,QAAO,QAAQ,IAAI,kBAAkB,KAAK;AAE5C,WAAO,QAAQ,IAAI,QAAQ,KAAK;MAEnC,CAAC;;AAEJ,SAAO,KAAK;;;;;;CAOd,MAAM,cACJ,MACA,SACuB;AAEvB,UADkB,MAAM,KAAK,OAAO,MAAM,QAAQ,EACjC;;;;;;;;CASnB,MAAM,iBACJ,OACA,SACuB;AACvB,SAAO,KAAK,cAAc,iBAAiB,OAAO,QAAQ;;;;;CAM5D,MAAM,gBACJ,OACA,SAC0B;AAC1B,SAAO,KAAK,cAAc,gBAAgB,OAAO,QAAQ;;;;;;CAO3D,MAAM,UACJ,MACA,SAC0B;AAC1B,SAAO,KAAK,cAAc,UAAU,MAAM,QAAQ;;;;;CAMpD,MAAM,UACJ,KACA,SAC+C;EAC/C,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,IAAI,QAAQ,QAAQ;;;;;CAMvC,MAAM,SAAS,SAAiD;EAC9D,MAAM,OAAoB,EAAE;AAC5B,aAAW,MAAM,OAAO,KAAK,KAAK,GAAG,QAAQ,CAC3C,MAAK,KAAK,IAAI;AAEhB,SAAO;;;;;CAMT,MAAM,aAAa,KAAuC;EACxD,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;CAM9B,MAAM,SAAS,KAAqC;EAClD,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,SAAS,OAAO;;;;;CAMnC,MAAM,eACJ,KACA,UACe;EACf,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;AAC1D,SAAO,KAAK,KAAK,YAAY,QAAQ,SAAS;;;;;CAMhD,MAAM,MAAM,KAAmB,SAAuC;EACpE,MAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,GAAG;EAC1D,MAAM,YAAY,KAAK,KAAK,GAAG,QAAQ,QAAQ;AAC/C,aAAW,MAAM,KAAK;;;;;CAQxB,UAAgB;AACd,OAAK,cAAc,SAAS"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/types/constants.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default API endpoint URL for the pinning service.
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_ENDPOINT = "https://api.lumeweb.com";
|
|
6
|
+
/**
|
|
7
|
+
* Default TUS upload size threshold (100MB).
|
|
8
|
+
* Files larger than this will use TUS protocol for resumable uploads.
|
|
9
|
+
*/
|
|
10
|
+
const TUS_SIZE_THRESHOLD = 100 * 1024 * 1024;
|
|
11
|
+
/**
|
|
12
|
+
* Default key prefix for blockstore keys.
|
|
13
|
+
* This is prepended to CID strings in storage keys.
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_BLOCKSTORE_PREFIX = "pinner-helia-blocks";
|
|
16
|
+
/**
|
|
17
|
+
* Default base path for blockstore storage driver.
|
|
18
|
+
* For IndexedDB: "pinner:" - the database name prefix
|
|
19
|
+
* For filesystem: "./.pinner-blocks" - the directory path
|
|
20
|
+
*/
|
|
21
|
+
const DEFAULT_BLOCKSTORE_BASE = "pinner:";
|
|
22
|
+
/**
|
|
23
|
+
* Default base path for blockstore filesystem storage driver (Node.js).
|
|
24
|
+
*/
|
|
25
|
+
const DEFAULT_BLOCKSTORE_FS_BASE = "./.pinner-blocks";
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { DEFAULT_BLOCKSTORE_BASE, DEFAULT_BLOCKSTORE_FS_BASE, DEFAULT_BLOCKSTORE_PREFIX, DEFAULT_ENDPOINT, TUS_SIZE_THRESHOLD };
|
|
29
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/types/constants.ts"],"sourcesContent":["/**\n * Default API endpoint URL for the pinning service.\n */\nexport const DEFAULT_ENDPOINT = \"https://api.lumeweb.com\";\n\n/**\n * Default IPFS gateway URL for content retrieval.\n */\nexport const DEFAULT_GATEWAY = \"https://gateway.lumeweb.com\";\n\n/**\n * Default TUS upload size threshold (100MB).\n * Files larger than this will use TUS protocol for resumable uploads.\n */\nexport const TUS_SIZE_THRESHOLD = 100 * 1024 * 1024;\n\n/**\n * Default base path for Helia datastore storage.\n */\nexport const DEFAULT_DATASTORE_BASE = \"pinner-helia-data\";\n\n/**\n * Default key prefix for blockstore keys.\n * This is prepended to CID strings in storage keys.\n */\nexport const DEFAULT_BLOCKSTORE_PREFIX = \"pinner-helia-blocks\";\n\n/**\n * Default base path for blockstore storage driver.\n * For IndexedDB: \"pinner:\" - the database name prefix\n * For filesystem: \"./.pinner-blocks\" - the directory path\n */\nexport const DEFAULT_BLOCKSTORE_BASE = \"pinner:\";\n\n/**\n * Default base path for blockstore filesystem storage driver (Node.js).\n */\nexport const DEFAULT_BLOCKSTORE_FS_BASE = \"./.pinner-blocks\";\n\n/**\n * Default base path for datastore filesystem storage driver (Node.js).\n */\nexport const DEFAULT_DATASTORE_FS_BASE = \"./.pinner-data\";\n"],"mappings":";;;;AAGA,MAAa,mBAAmB;;;;;AAWhC,MAAa,qBAAqB,MAAM,OAAO;;;;;AAW/C,MAAa,4BAA4B;;;;;;AAOzC,MAAa,0BAA0B;;;;AAKvC,MAAa,6BAA6B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/types/mime-types.d.ts
|
|
2
|
+
declare const MIME_TYPE_CAR = "application/vnd.ipld.car";
|
|
3
|
+
declare const MIME_TYPE_OCTET_STREAM = "application/octet-stream";
|
|
4
|
+
declare const FILE_EXTENSION_CAR = ".car";
|
|
5
|
+
//#endregion
|
|
6
|
+
export { FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM };
|
|
7
|
+
//# sourceMappingURL=mime-types.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/types/mime-types.ts
|
|
2
|
+
const MIME_TYPE_CAR = "application/vnd.ipld.car";
|
|
3
|
+
const MIME_TYPE_OCTET_STREAM = "application/octet-stream";
|
|
4
|
+
const FILE_EXTENSION_CAR = ".car";
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { FILE_EXTENSION_CAR, MIME_TYPE_CAR, MIME_TYPE_OCTET_STREAM };
|
|
8
|
+
//# sourceMappingURL=mime-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mime-types.js","names":[],"sources":["../../../src/types/mime-types.ts"],"sourcesContent":["export const MIME_TYPE_CAR = \"application/vnd.ipld.car\";\nexport const MIME_TYPE_OCTET_STREAM = \"application/octet-stream\";\nexport const FILE_EXTENSION_CAR = \".car\";\n"],"mappings":";AAAA,MAAa,gBAAgB;AAC7B,MAAa,yBAAyB;AACtC,MAAa,qBAAqB"}
|