@bcts/hubert 1.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +48 -0
- package/README.md +18 -0
- package/dist/arid-derivation-1CJuU-kZ.cjs +150 -0
- package/dist/arid-derivation-1CJuU-kZ.cjs.map +1 -0
- package/dist/arid-derivation-CbqACjdg.mjs +126 -0
- package/dist/arid-derivation-CbqACjdg.mjs.map +1 -0
- package/dist/bin/hubert.cjs +384 -0
- package/dist/bin/hubert.cjs.map +1 -0
- package/dist/bin/hubert.d.cts +1 -0
- package/dist/bin/hubert.d.mts +1 -0
- package/dist/bin/hubert.mjs +383 -0
- package/dist/bin/hubert.mjs.map +1 -0
- package/dist/chunk-CbDLau6x.cjs +34 -0
- package/dist/hybrid/index.cjs +14 -0
- package/dist/hybrid/index.d.cts +3 -0
- package/dist/hybrid/index.d.mts +3 -0
- package/dist/hybrid/index.mjs +6 -0
- package/dist/hybrid-BZhumygj.mjs +356 -0
- package/dist/hybrid-BZhumygj.mjs.map +1 -0
- package/dist/hybrid-dX5JLumO.cjs +410 -0
- package/dist/hybrid-dX5JLumO.cjs.map +1 -0
- package/dist/index-BEzpUC7r.d.mts +380 -0
- package/dist/index-BEzpUC7r.d.mts.map +1 -0
- package/dist/index-C2F6ugLL.d.mts +210 -0
- package/dist/index-C2F6ugLL.d.mts.map +1 -0
- package/dist/index-CUnDouMb.d.mts +215 -0
- package/dist/index-CUnDouMb.d.mts.map +1 -0
- package/dist/index-CV6lZJqY.d.cts +380 -0
- package/dist/index-CV6lZJqY.d.cts.map +1 -0
- package/dist/index-CY3TCzIm.d.cts +217 -0
- package/dist/index-CY3TCzIm.d.cts.map +1 -0
- package/dist/index-DEr4SR1J.d.cts +215 -0
- package/dist/index-DEr4SR1J.d.cts.map +1 -0
- package/dist/index-T1LHanIb.d.mts +217 -0
- package/dist/index-T1LHanIb.d.mts.map +1 -0
- package/dist/index-jyzuOhFB.d.cts +210 -0
- package/dist/index-jyzuOhFB.d.cts.map +1 -0
- package/dist/index.cjs +60 -0
- package/dist/index.d.cts +161 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +161 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +10 -0
- package/dist/ipfs/index.cjs +13 -0
- package/dist/ipfs/index.d.cts +3 -0
- package/dist/ipfs/index.d.mts +3 -0
- package/dist/ipfs/index.mjs +5 -0
- package/dist/ipfs-BRMMCBjv.mjs +1 -0
- package/dist/ipfs-CetOVQcO.cjs +0 -0
- package/dist/kv-BAmhmMOo.cjs +425 -0
- package/dist/kv-BAmhmMOo.cjs.map +1 -0
- package/dist/kv-C-emxv0w.mjs +375 -0
- package/dist/kv-C-emxv0w.mjs.map +1 -0
- package/dist/kv-DJiKvypY.mjs +403 -0
- package/dist/kv-DJiKvypY.mjs.map +1 -0
- package/dist/kv-store-DmngWWuw.d.mts +183 -0
- package/dist/kv-store-DmngWWuw.d.mts.map +1 -0
- package/dist/kv-store-ww-AUyLd.d.cts +183 -0
- package/dist/kv-store-ww-AUyLd.d.cts.map +1 -0
- package/dist/kv-yjvQa_LH.cjs +457 -0
- package/dist/kv-yjvQa_LH.cjs.map +1 -0
- package/dist/logging-hmzNzifq.mjs +158 -0
- package/dist/logging-hmzNzifq.mjs.map +1 -0
- package/dist/logging-qc9uMgil.cjs +212 -0
- package/dist/logging-qc9uMgil.cjs.map +1 -0
- package/dist/mainline/index.cjs +12 -0
- package/dist/mainline/index.d.cts +3 -0
- package/dist/mainline/index.d.mts +3 -0
- package/dist/mainline/index.mjs +5 -0
- package/dist/mainline-D_jfeFMh.cjs +0 -0
- package/dist/mainline-cFIuXbo-.mjs +1 -0
- package/dist/server/index.cjs +14 -0
- package/dist/server/index.d.cts +3 -0
- package/dist/server/index.d.mts +3 -0
- package/dist/server/index.mjs +3 -0
- package/dist/server-BBNRZ30D.cjs +912 -0
- package/dist/server-BBNRZ30D.cjs.map +1 -0
- package/dist/server-DVyk9gqU.mjs +836 -0
- package/dist/server-DVyk9gqU.mjs.map +1 -0
- package/package.json +125 -0
- package/src/arid-derivation.ts +155 -0
- package/src/bin/hubert.ts +667 -0
- package/src/error.ts +89 -0
- package/src/hybrid/error.ts +77 -0
- package/src/hybrid/index.ts +24 -0
- package/src/hybrid/kv.ts +236 -0
- package/src/hybrid/reference.ts +176 -0
- package/src/index.ts +145 -0
- package/src/ipfs/error.ts +83 -0
- package/src/ipfs/index.ts +24 -0
- package/src/ipfs/kv.ts +476 -0
- package/src/ipfs/value.ts +85 -0
- package/src/kv-store.ts +128 -0
- package/src/logging.ts +88 -0
- package/src/mainline/error.ts +108 -0
- package/src/mainline/index.ts +23 -0
- package/src/mainline/kv.ts +411 -0
- package/src/server/error.ts +83 -0
- package/src/server/index.ts +29 -0
- package/src/server/kv.ts +211 -0
- package/src/server/memory-kv.ts +191 -0
- package/src/server/server-kv.ts +92 -0
- package/src/server/server.ts +369 -0
- package/src/server/sqlite-kv.ts +295 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
//#region src/error.ts
|
|
2
|
+
/**
|
|
3
|
+
* Top-level error types for the hubert library.
|
|
4
|
+
*
|
|
5
|
+
* Port of error.rs from hubert-rust.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base error class for all Hubert errors.
|
|
11
|
+
*
|
|
12
|
+
* @category Errors
|
|
13
|
+
*/
|
|
14
|
+
var HubertError = class extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "HubertError";
|
|
18
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Error thrown when attempting to store at an ARID that already exists.
|
|
23
|
+
*
|
|
24
|
+
* Port of `Error::AlreadyExists { arid }` from error.rs line 6.
|
|
25
|
+
*
|
|
26
|
+
* @category Errors
|
|
27
|
+
*/
|
|
28
|
+
var AlreadyExistsError = class extends HubertError {
|
|
29
|
+
/** The ARID that already exists */
|
|
30
|
+
arid;
|
|
31
|
+
constructor(arid) {
|
|
32
|
+
super(`${arid} already exists`);
|
|
33
|
+
this.name = "AlreadyExistsError";
|
|
34
|
+
this.arid = arid;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when an ARID is not found.
|
|
39
|
+
*
|
|
40
|
+
* Port of `Error::NotFound` from error.rs line 8.
|
|
41
|
+
*
|
|
42
|
+
* @category Errors
|
|
43
|
+
*/
|
|
44
|
+
var NotFoundError = class extends HubertError {
|
|
45
|
+
constructor() {
|
|
46
|
+
super("Not found");
|
|
47
|
+
this.name = "NotFoundError";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Error thrown when an ARID format is invalid.
|
|
52
|
+
*
|
|
53
|
+
* Port of `Error::InvalidArid` from error.rs line 11.
|
|
54
|
+
*
|
|
55
|
+
* @category Errors
|
|
56
|
+
*/
|
|
57
|
+
var InvalidAridError = class extends HubertError {
|
|
58
|
+
constructor() {
|
|
59
|
+
super("Invalid ARID format");
|
|
60
|
+
this.name = "InvalidAridError";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Error thrown for I/O operations.
|
|
65
|
+
*
|
|
66
|
+
* Port of `Error::Io(e)` from error.rs line 35.
|
|
67
|
+
*
|
|
68
|
+
* @category Errors
|
|
69
|
+
*/
|
|
70
|
+
var IoError = class extends HubertError {
|
|
71
|
+
/** The underlying error */
|
|
72
|
+
cause;
|
|
73
|
+
constructor(message, cause) {
|
|
74
|
+
super(`IO error: ${message}`);
|
|
75
|
+
this.name = "IoError";
|
|
76
|
+
if (cause !== void 0) this.cause = cause;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/logging.ts
|
|
82
|
+
/**
|
|
83
|
+
* Logging utilities for verbose output with timestamps.
|
|
84
|
+
*
|
|
85
|
+
* Port of logging.rs from hubert-rust.
|
|
86
|
+
*
|
|
87
|
+
* @module
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* Format a timestamp in ISO-8601 Zulu format with fractional seconds.
|
|
91
|
+
*
|
|
92
|
+
* Port of `timestamp()` from logging.rs lines 6-71.
|
|
93
|
+
*
|
|
94
|
+
* @returns Timestamp string in format "YYYY-MM-DDTHH:MM:SS.mmmZ"
|
|
95
|
+
* @category Logging
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* timestamp() // => "2024-01-15T14:30:45.123Z"
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function timestamp() {
|
|
103
|
+
const now = /* @__PURE__ */ new Date();
|
|
104
|
+
return `${now.getUTCFullYear()}-${String(now.getUTCMonth() + 1).padStart(2, "0")}-${String(now.getUTCDate()).padStart(2, "0")}T${String(now.getUTCHours()).padStart(2, "0")}:${String(now.getUTCMinutes()).padStart(2, "0")}:${String(now.getUTCSeconds()).padStart(2, "0")}.${String(now.getUTCMilliseconds()).padStart(3, "0")}Z`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Print a verbose message with timestamp prefix.
|
|
108
|
+
*
|
|
109
|
+
* Port of `verbose_println()` from logging.rs lines 74-78.
|
|
110
|
+
*
|
|
111
|
+
* @param message - The message to print
|
|
112
|
+
* @category Logging
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* verbosePrintln("Starting operation...");
|
|
117
|
+
* // Output: [2024-01-15T14:30:45.123Z] Starting operation...
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
function verbosePrintln(message) {
|
|
121
|
+
if (message.length > 0) console.log(`[${timestamp()}] ${message}`);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Print a polling dot on the same line (no newline).
|
|
125
|
+
*
|
|
126
|
+
* Port of `verbose_print_dot()` from logging.rs lines 81-84.
|
|
127
|
+
*
|
|
128
|
+
* @category Logging
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* verbosePrintDot(); // Prints "." without newline
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
function verbosePrintDot() {
|
|
136
|
+
process.stdout.write(".");
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Print a newline after dots.
|
|
140
|
+
*
|
|
141
|
+
* Port of `verbose_newline()` from logging.rs lines 87-89.
|
|
142
|
+
*
|
|
143
|
+
* @category Logging
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* verbosePrintDot();
|
|
148
|
+
* verbosePrintDot();
|
|
149
|
+
* verboseNewline(); // Completes the line of dots
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
function verboseNewline() {
|
|
153
|
+
console.log();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
export { AlreadyExistsError as a, IoError as c, verbosePrintln as i, NotFoundError as l, verboseNewline as n, HubertError as o, verbosePrintDot as r, InvalidAridError as s, timestamp as t };
|
|
158
|
+
//# sourceMappingURL=logging-hmzNzifq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging-hmzNzifq.mjs","names":[],"sources":["../src/error.ts","../src/logging.ts"],"sourcesContent":["/**\n * Top-level error types for the hubert library.\n *\n * Port of error.rs from hubert-rust.\n *\n * @module\n */\n\n/**\n * Base error class for all Hubert errors.\n *\n * @category Errors\n */\nexport class HubertError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"HubertError\";\n // Maintains proper stack trace for where error was thrown (V8 only)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error thrown when attempting to store at an ARID that already exists.\n *\n * Port of `Error::AlreadyExists { arid }` from error.rs line 6.\n *\n * @category Errors\n */\nexport class AlreadyExistsError extends HubertError {\n /** The ARID that already exists */\n readonly arid: string;\n\n constructor(arid: string) {\n super(`${arid} already exists`);\n this.name = \"AlreadyExistsError\";\n this.arid = arid;\n }\n}\n\n/**\n * Error thrown when an ARID is not found.\n *\n * Port of `Error::NotFound` from error.rs line 8.\n *\n * @category Errors\n */\nexport class NotFoundError extends HubertError {\n constructor() {\n super(\"Not found\");\n this.name = \"NotFoundError\";\n }\n}\n\n/**\n * Error thrown when an ARID format is invalid.\n *\n * Port of `Error::InvalidArid` from error.rs line 11.\n *\n * @category Errors\n */\nexport class InvalidAridError extends HubertError {\n constructor() {\n super(\"Invalid ARID format\");\n this.name = \"InvalidAridError\";\n }\n}\n\n/**\n * Error thrown for I/O operations.\n *\n * Port of `Error::Io(e)` from error.rs line 35.\n *\n * @category Errors\n */\nexport class IoError extends HubertError {\n /** The underlying error */\n override readonly cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(`IO error: ${message}`);\n this.name = \"IoError\";\n if (cause !== undefined) {\n this.cause = cause;\n }\n }\n}\n","/**\n * Logging utilities for verbose output with timestamps.\n *\n * Port of logging.rs from hubert-rust.\n *\n * @module\n */\n\n/**\n * Format a timestamp in ISO-8601 Zulu format with fractional seconds.\n *\n * Port of `timestamp()` from logging.rs lines 6-71.\n *\n * @returns Timestamp string in format \"YYYY-MM-DDTHH:MM:SS.mmmZ\"\n * @category Logging\n *\n * @example\n * ```typescript\n * timestamp() // => \"2024-01-15T14:30:45.123Z\"\n * ```\n */\nexport function timestamp(): string {\n const now = new Date();\n\n const year = now.getUTCFullYear();\n const month = String(now.getUTCMonth() + 1).padStart(2, \"0\");\n const day = String(now.getUTCDate()).padStart(2, \"0\");\n const hours = String(now.getUTCHours()).padStart(2, \"0\");\n const minutes = String(now.getUTCMinutes()).padStart(2, \"0\");\n const seconds = String(now.getUTCSeconds()).padStart(2, \"0\");\n const millis = String(now.getUTCMilliseconds()).padStart(3, \"0\");\n\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${millis}Z`;\n}\n\n/**\n * Print a verbose message with timestamp prefix.\n *\n * Port of `verbose_println()` from logging.rs lines 74-78.\n *\n * @param message - The message to print\n * @category Logging\n *\n * @example\n * ```typescript\n * verbosePrintln(\"Starting operation...\");\n * // Output: [2024-01-15T14:30:45.123Z] Starting operation...\n * ```\n */\nexport function verbosePrintln(message: string): void {\n if (message.length > 0) {\n console.log(`[${timestamp()}] ${message}`);\n }\n}\n\n/**\n * Print a polling dot on the same line (no newline).\n *\n * Port of `verbose_print_dot()` from logging.rs lines 81-84.\n *\n * @category Logging\n *\n * @example\n * ```typescript\n * verbosePrintDot(); // Prints \".\" without newline\n * ```\n */\nexport function verbosePrintDot(): void {\n process.stdout.write(\".\");\n}\n\n/**\n * Print a newline after dots.\n *\n * Port of `verbose_newline()` from logging.rs lines 87-89.\n *\n * @category Logging\n *\n * @example\n * ```typescript\n * verbosePrintDot();\n * verbosePrintDot();\n * verboseNewline(); // Completes the line of dots\n * ```\n */\nexport function verboseNewline(): void {\n console.log();\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;AAEZ,MAAI,MAAM,kBACR,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;;;;;AAYrD,IAAa,qBAAb,cAAwC,YAAY;;CAElD,AAAS;CAET,YAAY,MAAc;AACxB,QAAM,GAAG,KAAK,iBAAiB;AAC/B,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;;;;;AAWhB,IAAa,gBAAb,cAAmC,YAAY;CAC7C,cAAc;AACZ,QAAM,YAAY;AAClB,OAAK,OAAO;;;;;;;;;;AAWhB,IAAa,mBAAb,cAAsC,YAAY;CAChD,cAAc;AACZ,QAAM,sBAAsB;AAC5B,OAAK,OAAO;;;;;;;;;;AAWhB,IAAa,UAAb,cAA6B,YAAY;;CAEvC,AAAkB;CAElB,YAAY,SAAiB,OAAe;AAC1C,QAAM,aAAa,UAAU;AAC7B,OAAK,OAAO;AACZ,MAAI,UAAU,OACZ,MAAK,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;AChEnB,SAAgB,YAAoB;CAClC,MAAM,sBAAM,IAAI,MAAM;AAUtB,QAAO,GARM,IAAI,gBAAgB,CAQlB,GAPD,OAAO,IAAI,aAAa,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,CAOpC,GANZ,OAAO,IAAI,YAAY,CAAC,CAAC,SAAS,GAAG,IAAI,CAMtB,GALjB,OAAO,IAAI,aAAa,CAAC,CAAC,SAAS,GAAG,IAAI,CAKhB,GAJxB,OAAO,IAAI,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,CAIT,GAHnC,OAAO,IAAI,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,CAGE,GAF/C,OAAO,IAAI,oBAAoB,CAAC,CAAC,SAAS,GAAG,IAAI,CAEQ;;;;;;;;;;;;;;;;AAiB1E,SAAgB,eAAe,SAAuB;AACpD,KAAI,QAAQ,SAAS,EACnB,SAAQ,IAAI,IAAI,WAAW,CAAC,IAAI,UAAU;;;;;;;;;;;;;;AAgB9C,SAAgB,kBAAwB;AACtC,SAAQ,OAAO,MAAM,IAAI;;;;;;;;;;;;;;;;AAiB3B,SAAgB,iBAAuB;AACrC,SAAQ,KAAK"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/error.ts
|
|
3
|
+
/**
|
|
4
|
+
* Top-level error types for the hubert library.
|
|
5
|
+
*
|
|
6
|
+
* Port of error.rs from hubert-rust.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Base error class for all Hubert errors.
|
|
12
|
+
*
|
|
13
|
+
* @category Errors
|
|
14
|
+
*/
|
|
15
|
+
var HubertError = class extends Error {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "HubertError";
|
|
19
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown when attempting to store at an ARID that already exists.
|
|
24
|
+
*
|
|
25
|
+
* Port of `Error::AlreadyExists { arid }` from error.rs line 6.
|
|
26
|
+
*
|
|
27
|
+
* @category Errors
|
|
28
|
+
*/
|
|
29
|
+
var AlreadyExistsError = class extends HubertError {
|
|
30
|
+
/** The ARID that already exists */
|
|
31
|
+
arid;
|
|
32
|
+
constructor(arid) {
|
|
33
|
+
super(`${arid} already exists`);
|
|
34
|
+
this.name = "AlreadyExistsError";
|
|
35
|
+
this.arid = arid;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Error thrown when an ARID is not found.
|
|
40
|
+
*
|
|
41
|
+
* Port of `Error::NotFound` from error.rs line 8.
|
|
42
|
+
*
|
|
43
|
+
* @category Errors
|
|
44
|
+
*/
|
|
45
|
+
var NotFoundError = class extends HubertError {
|
|
46
|
+
constructor() {
|
|
47
|
+
super("Not found");
|
|
48
|
+
this.name = "NotFoundError";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Error thrown when an ARID format is invalid.
|
|
53
|
+
*
|
|
54
|
+
* Port of `Error::InvalidArid` from error.rs line 11.
|
|
55
|
+
*
|
|
56
|
+
* @category Errors
|
|
57
|
+
*/
|
|
58
|
+
var InvalidAridError = class extends HubertError {
|
|
59
|
+
constructor() {
|
|
60
|
+
super("Invalid ARID format");
|
|
61
|
+
this.name = "InvalidAridError";
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Error thrown for I/O operations.
|
|
66
|
+
*
|
|
67
|
+
* Port of `Error::Io(e)` from error.rs line 35.
|
|
68
|
+
*
|
|
69
|
+
* @category Errors
|
|
70
|
+
*/
|
|
71
|
+
var IoError = class extends HubertError {
|
|
72
|
+
/** The underlying error */
|
|
73
|
+
cause;
|
|
74
|
+
constructor(message, cause) {
|
|
75
|
+
super(`IO error: ${message}`);
|
|
76
|
+
this.name = "IoError";
|
|
77
|
+
if (cause !== void 0) this.cause = cause;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/logging.ts
|
|
83
|
+
/**
|
|
84
|
+
* Logging utilities for verbose output with timestamps.
|
|
85
|
+
*
|
|
86
|
+
* Port of logging.rs from hubert-rust.
|
|
87
|
+
*
|
|
88
|
+
* @module
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Format a timestamp in ISO-8601 Zulu format with fractional seconds.
|
|
92
|
+
*
|
|
93
|
+
* Port of `timestamp()` from logging.rs lines 6-71.
|
|
94
|
+
*
|
|
95
|
+
* @returns Timestamp string in format "YYYY-MM-DDTHH:MM:SS.mmmZ"
|
|
96
|
+
* @category Logging
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* timestamp() // => "2024-01-15T14:30:45.123Z"
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
function timestamp() {
|
|
104
|
+
const now = /* @__PURE__ */ new Date();
|
|
105
|
+
return `${now.getUTCFullYear()}-${String(now.getUTCMonth() + 1).padStart(2, "0")}-${String(now.getUTCDate()).padStart(2, "0")}T${String(now.getUTCHours()).padStart(2, "0")}:${String(now.getUTCMinutes()).padStart(2, "0")}:${String(now.getUTCSeconds()).padStart(2, "0")}.${String(now.getUTCMilliseconds()).padStart(3, "0")}Z`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Print a verbose message with timestamp prefix.
|
|
109
|
+
*
|
|
110
|
+
* Port of `verbose_println()` from logging.rs lines 74-78.
|
|
111
|
+
*
|
|
112
|
+
* @param message - The message to print
|
|
113
|
+
* @category Logging
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* verbosePrintln("Starting operation...");
|
|
118
|
+
* // Output: [2024-01-15T14:30:45.123Z] Starting operation...
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
function verbosePrintln(message) {
|
|
122
|
+
if (message.length > 0) console.log(`[${timestamp()}] ${message}`);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Print a polling dot on the same line (no newline).
|
|
126
|
+
*
|
|
127
|
+
* Port of `verbose_print_dot()` from logging.rs lines 81-84.
|
|
128
|
+
*
|
|
129
|
+
* @category Logging
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* verbosePrintDot(); // Prints "." without newline
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
function verbosePrintDot() {
|
|
137
|
+
process.stdout.write(".");
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Print a newline after dots.
|
|
141
|
+
*
|
|
142
|
+
* Port of `verbose_newline()` from logging.rs lines 87-89.
|
|
143
|
+
*
|
|
144
|
+
* @category Logging
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* verbosePrintDot();
|
|
149
|
+
* verbosePrintDot();
|
|
150
|
+
* verboseNewline(); // Completes the line of dots
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
function verboseNewline() {
|
|
154
|
+
console.log();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//#endregion
|
|
158
|
+
Object.defineProperty(exports, 'AlreadyExistsError', {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function () {
|
|
161
|
+
return AlreadyExistsError;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(exports, 'HubertError', {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () {
|
|
167
|
+
return HubertError;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(exports, 'InvalidAridError', {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function () {
|
|
173
|
+
return InvalidAridError;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(exports, 'IoError', {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function () {
|
|
179
|
+
return IoError;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(exports, 'NotFoundError', {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
get: function () {
|
|
185
|
+
return NotFoundError;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(exports, 'timestamp', {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function () {
|
|
191
|
+
return timestamp;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(exports, 'verboseNewline', {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function () {
|
|
197
|
+
return verboseNewline;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(exports, 'verbosePrintDot', {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function () {
|
|
203
|
+
return verbosePrintDot;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(exports, 'verbosePrintln', {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function () {
|
|
209
|
+
return verbosePrintln;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
//# sourceMappingURL=logging-qc9uMgil.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging-qc9uMgil.cjs","names":[],"sources":["../src/error.ts","../src/logging.ts"],"sourcesContent":["/**\n * Top-level error types for the hubert library.\n *\n * Port of error.rs from hubert-rust.\n *\n * @module\n */\n\n/**\n * Base error class for all Hubert errors.\n *\n * @category Errors\n */\nexport class HubertError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"HubertError\";\n // Maintains proper stack trace for where error was thrown (V8 only)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error thrown when attempting to store at an ARID that already exists.\n *\n * Port of `Error::AlreadyExists { arid }` from error.rs line 6.\n *\n * @category Errors\n */\nexport class AlreadyExistsError extends HubertError {\n /** The ARID that already exists */\n readonly arid: string;\n\n constructor(arid: string) {\n super(`${arid} already exists`);\n this.name = \"AlreadyExistsError\";\n this.arid = arid;\n }\n}\n\n/**\n * Error thrown when an ARID is not found.\n *\n * Port of `Error::NotFound` from error.rs line 8.\n *\n * @category Errors\n */\nexport class NotFoundError extends HubertError {\n constructor() {\n super(\"Not found\");\n this.name = \"NotFoundError\";\n }\n}\n\n/**\n * Error thrown when an ARID format is invalid.\n *\n * Port of `Error::InvalidArid` from error.rs line 11.\n *\n * @category Errors\n */\nexport class InvalidAridError extends HubertError {\n constructor() {\n super(\"Invalid ARID format\");\n this.name = \"InvalidAridError\";\n }\n}\n\n/**\n * Error thrown for I/O operations.\n *\n * Port of `Error::Io(e)` from error.rs line 35.\n *\n * @category Errors\n */\nexport class IoError extends HubertError {\n /** The underlying error */\n override readonly cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(`IO error: ${message}`);\n this.name = \"IoError\";\n if (cause !== undefined) {\n this.cause = cause;\n }\n }\n}\n","/**\n * Logging utilities for verbose output with timestamps.\n *\n * Port of logging.rs from hubert-rust.\n *\n * @module\n */\n\n/**\n * Format a timestamp in ISO-8601 Zulu format with fractional seconds.\n *\n * Port of `timestamp()` from logging.rs lines 6-71.\n *\n * @returns Timestamp string in format \"YYYY-MM-DDTHH:MM:SS.mmmZ\"\n * @category Logging\n *\n * @example\n * ```typescript\n * timestamp() // => \"2024-01-15T14:30:45.123Z\"\n * ```\n */\nexport function timestamp(): string {\n const now = new Date();\n\n const year = now.getUTCFullYear();\n const month = String(now.getUTCMonth() + 1).padStart(2, \"0\");\n const day = String(now.getUTCDate()).padStart(2, \"0\");\n const hours = String(now.getUTCHours()).padStart(2, \"0\");\n const minutes = String(now.getUTCMinutes()).padStart(2, \"0\");\n const seconds = String(now.getUTCSeconds()).padStart(2, \"0\");\n const millis = String(now.getUTCMilliseconds()).padStart(3, \"0\");\n\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${millis}Z`;\n}\n\n/**\n * Print a verbose message with timestamp prefix.\n *\n * Port of `verbose_println()` from logging.rs lines 74-78.\n *\n * @param message - The message to print\n * @category Logging\n *\n * @example\n * ```typescript\n * verbosePrintln(\"Starting operation...\");\n * // Output: [2024-01-15T14:30:45.123Z] Starting operation...\n * ```\n */\nexport function verbosePrintln(message: string): void {\n if (message.length > 0) {\n console.log(`[${timestamp()}] ${message}`);\n }\n}\n\n/**\n * Print a polling dot on the same line (no newline).\n *\n * Port of `verbose_print_dot()` from logging.rs lines 81-84.\n *\n * @category Logging\n *\n * @example\n * ```typescript\n * verbosePrintDot(); // Prints \".\" without newline\n * ```\n */\nexport function verbosePrintDot(): void {\n process.stdout.write(\".\");\n}\n\n/**\n * Print a newline after dots.\n *\n * Port of `verbose_newline()` from logging.rs lines 87-89.\n *\n * @category Logging\n *\n * @example\n * ```typescript\n * verbosePrintDot();\n * verbosePrintDot();\n * verboseNewline(); // Completes the line of dots\n * ```\n */\nexport function verboseNewline(): void {\n console.log();\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;AAEZ,MAAI,MAAM,kBACR,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;;;;;AAYrD,IAAa,qBAAb,cAAwC,YAAY;;CAElD,AAAS;CAET,YAAY,MAAc;AACxB,QAAM,GAAG,KAAK,iBAAiB;AAC/B,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;;;;;AAWhB,IAAa,gBAAb,cAAmC,YAAY;CAC7C,cAAc;AACZ,QAAM,YAAY;AAClB,OAAK,OAAO;;;;;;;;;;AAWhB,IAAa,mBAAb,cAAsC,YAAY;CAChD,cAAc;AACZ,QAAM,sBAAsB;AAC5B,OAAK,OAAO;;;;;;;;;;AAWhB,IAAa,UAAb,cAA6B,YAAY;;CAEvC,AAAkB;CAElB,YAAY,SAAiB,OAAe;AAC1C,QAAM,aAAa,UAAU;AAC7B,OAAK,OAAO;AACZ,MAAI,UAAU,OACZ,MAAK,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;AChEnB,SAAgB,YAAoB;CAClC,MAAM,sBAAM,IAAI,MAAM;AAUtB,QAAO,GARM,IAAI,gBAAgB,CAQlB,GAPD,OAAO,IAAI,aAAa,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,CAOpC,GANZ,OAAO,IAAI,YAAY,CAAC,CAAC,SAAS,GAAG,IAAI,CAMtB,GALjB,OAAO,IAAI,aAAa,CAAC,CAAC,SAAS,GAAG,IAAI,CAKhB,GAJxB,OAAO,IAAI,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,CAIT,GAHnC,OAAO,IAAI,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,CAGE,GAF/C,OAAO,IAAI,oBAAoB,CAAC,CAAC,SAAS,GAAG,IAAI,CAEQ;;;;;;;;;;;;;;;;AAiB1E,SAAgB,eAAe,SAAuB;AACpD,KAAI,QAAQ,SAAS,EACnB,SAAQ,IAAI,IAAI,WAAW,CAAC,IAAI,UAAU;;;;;;;;;;;;;;AAgB9C,SAAgB,kBAAwB;AACtC,SAAQ,OAAO,MAAM,IAAI;;;;;;;;;;;;;;;;AAiB3B,SAAgB,iBAAuB;AACrC,SAAQ,KAAK"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require('../arid-derivation-1CJuU-kZ.cjs');
|
|
2
|
+
const require_kv = require('../kv-BAmhmMOo.cjs');
|
|
3
|
+
require('../mainline-D_jfeFMh.cjs');
|
|
4
|
+
|
|
5
|
+
exports.DecodeIdError = require_kv.DecodeIdError;
|
|
6
|
+
exports.DhtError = require_kv.DhtError;
|
|
7
|
+
exports.MainlineDhtKv = require_kv.MainlineDhtKv;
|
|
8
|
+
exports.MainlineError = require_kv.MainlineError;
|
|
9
|
+
exports.MainlineIoError = require_kv.MainlineIoError;
|
|
10
|
+
exports.PutMutableError = require_kv.PutMutableError;
|
|
11
|
+
exports.PutQueryError = require_kv.PutQueryError;
|
|
12
|
+
exports.ValueTooLargeError = require_kv.ValueTooLargeError;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "../kv-store-ww-AUyLd.cjs";
|
|
2
|
+
import { a as MainlineIoError, c as ValueTooLargeError, i as MainlineError, n as DecodeIdError, o as PutMutableError, r as DhtError, s as PutQueryError, t as MainlineDhtKv } from "../index-jyzuOhFB.cjs";
|
|
3
|
+
export { DecodeIdError, DhtError, MainlineDhtKv, MainlineError, MainlineIoError, PutMutableError, PutQueryError, ValueTooLargeError };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "../kv-store-DmngWWuw.mjs";
|
|
2
|
+
import { a as MainlineIoError, c as ValueTooLargeError, i as MainlineError, n as DecodeIdError, o as PutMutableError, r as DhtError, s as PutQueryError, t as MainlineDhtKv } from "../index-C2F6ugLL.mjs";
|
|
3
|
+
export { DecodeIdError, DhtError, MainlineDhtKv, MainlineError, MainlineIoError, PutMutableError, PutQueryError, ValueTooLargeError };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "../arid-derivation-CbqACjdg.mjs";
|
|
2
|
+
import { a as MainlineIoError, c as ValueTooLargeError, i as MainlineError, n as DecodeIdError, o as PutMutableError, r as DhtError, s as PutQueryError, t as MainlineDhtKv } from "../kv-C-emxv0w.mjs";
|
|
3
|
+
import "../mainline-cFIuXbo-.mjs";
|
|
4
|
+
|
|
5
|
+
export { DecodeIdError, DhtError, MainlineDhtKv, MainlineError, MainlineIoError, PutMutableError, PutQueryError, ValueTooLargeError };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const require_server = require('../server-BBNRZ30D.cjs');
|
|
2
|
+
|
|
3
|
+
exports.MemoryKv = require_server.MemoryKv;
|
|
4
|
+
exports.Server = require_server.Server;
|
|
5
|
+
exports.ServerError = require_server.ServerError;
|
|
6
|
+
exports.ServerGeneralError = require_server.ServerGeneralError;
|
|
7
|
+
exports.ServerKvClient = require_server.ServerKvClient;
|
|
8
|
+
exports.ServerNetworkError = require_server.ServerNetworkError;
|
|
9
|
+
exports.ServerParseError = require_server.ServerParseError;
|
|
10
|
+
exports.SqliteError = require_server.SqliteError;
|
|
11
|
+
exports.SqliteKv = require_server.SqliteKv;
|
|
12
|
+
exports.createMemoryKv = require_server.createMemoryKv;
|
|
13
|
+
exports.createSqliteKv = require_server.createSqliteKv;
|
|
14
|
+
exports.defaultServerConfig = require_server.defaultServerConfig;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "../kv-store-ww-AUyLd.cjs";
|
|
2
|
+
import { a as ServerKv, c as SqliteKv, d as ServerGeneralError, f as ServerNetworkError, i as defaultServerConfig, l as MemoryKv, m as SqliteError, n as Server, o as createMemoryKv, p as ServerParseError, r as ServerConfig, s as createSqliteKv, t as ServerKvClient, u as ServerError } from "../index-CV6lZJqY.cjs";
|
|
3
|
+
export { MemoryKv, Server, ServerConfig, ServerError, ServerGeneralError, ServerKv, ServerKvClient, ServerNetworkError, ServerParseError, SqliteError, SqliteKv, createMemoryKv, createSqliteKv, defaultServerConfig };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "../kv-store-DmngWWuw.mjs";
|
|
2
|
+
import { a as ServerKv, c as SqliteKv, d as ServerGeneralError, f as ServerNetworkError, i as defaultServerConfig, l as MemoryKv, m as SqliteError, n as Server, o as createMemoryKv, p as ServerParseError, r as ServerConfig, s as createSqliteKv, t as ServerKvClient, u as ServerError } from "../index-BEzpUC7r.mjs";
|
|
3
|
+
export { MemoryKv, Server, ServerConfig, ServerError, ServerGeneralError, ServerKv, ServerKvClient, ServerNetworkError, ServerParseError, SqliteError, SqliteKv, createMemoryKv, createSqliteKv, defaultServerConfig };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as createSqliteKv, c as ServerError, d as ServerParseError, f as SqliteError, i as createMemoryKv, l as ServerGeneralError, n as Server, o as SqliteKv, r as defaultServerConfig, s as MemoryKv, t as ServerKvClient, u as ServerNetworkError } from "../server-DVyk9gqU.mjs";
|
|
2
|
+
|
|
3
|
+
export { MemoryKv, Server, ServerError, ServerGeneralError, ServerKvClient, ServerNetworkError, ServerParseError, SqliteError, SqliteKv, createMemoryKv, createSqliteKv, defaultServerConfig };
|