@kikiutils/shared 18.3.0 → 20.0.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.
Files changed (161) hide show
  1. package/README.md +0 -7
  2. package/dist/buffer.d.ts +0 -2
  3. package/dist/buffer.d.ts.map +1 -1
  4. package/dist/buffer.js +1 -2
  5. package/dist/classes/enhanced-date.d.ts +0 -2
  6. package/dist/classes/enhanced-date.d.ts.map +1 -1
  7. package/dist/classes/enhanced-date.js +1 -2
  8. package/dist/classes/path.d.ts +1 -3
  9. package/dist/classes/path.d.ts.map +1 -1
  10. package/dist/classes/path.js +1 -2
  11. package/dist/classes/precision-number.d.ts +0 -2
  12. package/dist/classes/precision-number.d.ts.map +1 -1
  13. package/dist/classes/precision-number.js +1 -2
  14. package/dist/clipboard.d.ts +0 -2
  15. package/dist/clipboard.d.ts.map +1 -1
  16. package/dist/clipboard.js +1 -2
  17. package/dist/crypto-hash.d.ts +0 -2
  18. package/dist/crypto-hash.d.ts.map +1 -1
  19. package/dist/crypto-hash.js +1 -2
  20. package/dist/datetime.d.ts +0 -2
  21. package/dist/datetime.d.ts.map +1 -1
  22. package/dist/datetime.js +1 -2
  23. package/dist/element-plus.d.ts +0 -2
  24. package/dist/element-plus.d.ts.map +1 -1
  25. package/dist/element-plus.js +1 -2
  26. package/dist/enum.d.ts +0 -2
  27. package/dist/enum.d.ts.map +1 -1
  28. package/dist/enum.js +1 -2
  29. package/dist/env.d.ts +0 -2
  30. package/dist/env.d.ts.map +1 -1
  31. package/dist/env.js +1 -2
  32. package/dist/event-awaiter.d.ts +0 -2
  33. package/dist/event-awaiter.d.ts.map +1 -1
  34. package/dist/event-awaiter.js +1 -2
  35. package/dist/file.d.ts +0 -2
  36. package/dist/file.d.ts.map +1 -1
  37. package/dist/file.js +1 -2
  38. package/dist/general.d.ts +0 -2
  39. package/dist/general.d.ts.map +1 -1
  40. package/dist/general.js +1 -2
  41. package/dist/hash.d.ts +0 -2
  42. package/dist/hash.d.ts.map +1 -1
  43. package/dist/hash.js +1 -2
  44. package/dist/logger/_internals/formatter.d.ts +13 -0
  45. package/dist/logger/_internals/formatter.d.ts.map +1 -0
  46. package/dist/logger/_internals/formatter.js +57 -0
  47. package/dist/logger/_internals/formatter.js.map +1 -0
  48. package/dist/logger/_internals/levels.d.ts +54 -0
  49. package/dist/logger/_internals/levels.d.ts.map +1 -0
  50. package/dist/logger/_internals/levels.js +59 -0
  51. package/dist/logger/_internals/levels.js.map +1 -0
  52. package/dist/logger/_internals/logger.d.ts +12 -0
  53. package/dist/logger/_internals/logger.d.ts.map +1 -0
  54. package/dist/logger/_internals/logger.js +147 -0
  55. package/dist/logger/_internals/logger.js.map +1 -0
  56. package/dist/logger/_internals/types.d.ts +12 -0
  57. package/dist/logger/_internals/types.d.ts.map +1 -0
  58. package/dist/logger/_internals/types.js +1 -0
  59. package/dist/logger/index.d.ts +10 -0
  60. package/dist/logger/index.d.ts.map +1 -0
  61. package/dist/logger/index.js +25 -0
  62. package/dist/logger/index.js.map +1 -0
  63. package/dist/logger/node/_internals/file-writer.d.ts +11 -0
  64. package/dist/logger/node/_internals/file-writer.d.ts.map +1 -0
  65. package/dist/logger/node/_internals/file-writer.js +188 -0
  66. package/dist/logger/node/_internals/file-writer.js.map +1 -0
  67. package/dist/logger/node/_internals/formatter.d.ts +4 -0
  68. package/dist/logger/node/_internals/formatter.d.ts.map +1 -0
  69. package/dist/logger/node/_internals/formatter.js +21 -0
  70. package/dist/logger/node/_internals/formatter.js.map +1 -0
  71. package/dist/logger/node/index.d.ts +10 -0
  72. package/dist/logger/node/index.d.ts.map +1 -0
  73. package/dist/logger/node/index.js +123 -0
  74. package/dist/logger/node/index.js.map +1 -0
  75. package/dist/logger/node/types.d.ts +43 -0
  76. package/dist/logger/node/types.d.ts.map +1 -0
  77. package/dist/logger/node/types.js +1 -0
  78. package/dist/logger/types.d.ts +50 -0
  79. package/dist/logger/types.d.ts.map +1 -0
  80. package/dist/logger/types.js +1 -0
  81. package/dist/math.d.ts +0 -2
  82. package/dist/math.d.ts.map +1 -1
  83. package/dist/math.js +1 -2
  84. package/dist/number.d.ts +0 -2
  85. package/dist/number.d.ts.map +1 -1
  86. package/dist/number.js +1 -2
  87. package/dist/random.d.ts +0 -2
  88. package/dist/random.d.ts.map +1 -1
  89. package/dist/random.js +1 -2
  90. package/dist/redis/script-runner.d.ts +0 -2
  91. package/dist/redis/script-runner.d.ts.map +1 -1
  92. package/dist/redis/script-runner.js +1 -2
  93. package/dist/storages/lru/keyed-store.d.ts +0 -2
  94. package/dist/storages/lru/keyed-store.d.ts.map +1 -1
  95. package/dist/storages/lru/keyed-store.js +1 -2
  96. package/dist/storages/redis/keyed-store.d.ts +4 -4
  97. package/dist/storages/redis/keyed-store.d.ts.map +1 -1
  98. package/dist/storages/redis/keyed-store.js +7 -4
  99. package/dist/storages/redis/keyed-store.js.map +1 -1
  100. package/dist/storages/redis/msgpack.d.ts +10 -3
  101. package/dist/storages/redis/msgpack.d.ts.map +1 -1
  102. package/dist/storages/redis/msgpack.js +18 -3
  103. package/dist/storages/redis/msgpack.js.map +1 -1
  104. package/dist/storages/redis/types.d.ts +30 -2
  105. package/dist/storages/redis/types.d.ts.map +1 -1
  106. package/dist/string.d.ts +0 -2
  107. package/dist/string.d.ts.map +1 -1
  108. package/dist/string.js +1 -2
  109. package/dist/time.d.ts +0 -2
  110. package/dist/time.d.ts.map +1 -1
  111. package/dist/time.js +1 -2
  112. package/dist/types/filtered-key-path.d.ts +0 -2
  113. package/dist/types/filtered-key-path.d.ts.map +1 -1
  114. package/dist/types/index.d.ts +0 -10
  115. package/dist/types/index.d.ts.map +1 -1
  116. package/dist/types/vue.d.ts +0 -2
  117. package/dist/types/vue.d.ts.map +1 -1
  118. package/dist/url.d.ts +0 -2
  119. package/dist/url.d.ts.map +1 -1
  120. package/dist/url.js +1 -2
  121. package/dist/vue.d.ts +0 -2
  122. package/dist/vue.d.ts.map +1 -1
  123. package/dist/vue.js +1 -2
  124. package/dist/web.d.ts +0 -2
  125. package/dist/web.d.ts.map +1 -1
  126. package/dist/web.js +1 -2
  127. package/package.json +73 -45
  128. package/src/logger/_internals/formatter.ts +80 -0
  129. package/src/logger/_internals/levels.ts +60 -0
  130. package/src/logger/_internals/logger.ts +224 -0
  131. package/src/logger/_internals/types.ts +12 -0
  132. package/src/logger/index.ts +34 -0
  133. package/src/logger/node/_internals/file-writer.ts +298 -0
  134. package/src/logger/node/_internals/formatter.ts +33 -0
  135. package/src/logger/node/index.ts +173 -0
  136. package/src/logger/node/types.ts +58 -0
  137. package/src/logger/types.ts +60 -0
  138. package/src/storages/redis/keyed-store.ts +6 -2
  139. package/src/storages/redis/msgpack.ts +17 -1
  140. package/src/storages/redis/types.ts +34 -0
  141. package/src/types/index.ts +0 -10
  142. package/dist/classes/ssh-client.d.ts +0 -40
  143. package/dist/classes/ssh-client.d.ts.map +0 -1
  144. package/dist/classes/ssh-client.js +0 -130
  145. package/dist/classes/ssh-client.js.map +0 -1
  146. package/dist/consola.d.ts +0 -24
  147. package/dist/consola.d.ts.map +0 -1
  148. package/dist/consola.js +0 -29
  149. package/dist/consola.js.map +0 -1
  150. package/dist/object.d.ts +0 -44
  151. package/dist/object.d.ts.map +0 -1
  152. package/dist/object.js +0 -59
  153. package/dist/object.js.map +0 -1
  154. package/dist/pino.d.ts +0 -25
  155. package/dist/pino.d.ts.map +0 -1
  156. package/dist/pino.js +0 -34
  157. package/dist/pino.js.map +0 -1
  158. package/src/classes/ssh-client.ts +0 -175
  159. package/src/consola.ts +0 -25
  160. package/src/object.ts +0 -78
  161. package/src/pino.ts +0 -33
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","names":[],"sources":["../../../../src/logger/node/_internals/formatter.ts"],"sourcesContent":["import { inspect } from 'node:util';\n\nimport { formatLoggerParts } from '../../_internals/formatter';\nimport type { LoggerRecord } from '../../_internals/types';\n\n// Functions\n\n/** Preserve user ANSI for console output without invoking custom inspect callbacks/getters. */\nexport function formatNodeLoggerRecord(record: LoggerRecord, colors = false) {\n const message = record.args.map(\n (arg) => typeof arg === 'string'\n ? arg\n : inspect(\n arg,\n {\n colors: false,\n customInspect: false,\n depth: 6,\n getters: false,\n maxArrayLength: 100,\n maxStringLength: 10_000,\n },\n ),\n ).join(' ');\n\n return formatLoggerParts(\n {\n ...record,\n args: record.args.length ? [message] : [],\n },\n colors,\n ).join(' ');\n}\n"],"mappings":";;;;AAQA,SAAgB,uBAAuB,QAAsB,SAAS,OAAO;CACzE,MAAM,UAAU,OAAO,KAAK,KACvB,QAAQ,OAAO,QAAQ,WAClB,MACA,QACE,KACA;EACI,QAAQ;EACR,eAAe;EACf,OAAO;EACP,SAAS;EACT,gBAAgB;EAChB,iBAAiB;CACrB,CACJ,CACR,CAAC,CAAC,KAAK,GAAG;CAEV,OAAO,kBACH;EACI,GAAG;EACH,MAAM,OAAO,KAAK,SAAS,CAAC,OAAO,IAAI,CAAC;CAC5C,GACA,MACJ,CAAC,CAAC,KAAK,GAAG;AACd"}
@@ -0,0 +1,10 @@
1
+ import { NodeLogger, NodeLoggerOptions } from "./types.js";
2
+ /**
3
+ * Creates a Node.js/Bun logger with optional bounded, append-only file output and rotation.
4
+ *
5
+ * Log calls never throw or reject. Awaiting them waits for processing, not proof of successful
6
+ * persistence: overload drops the newest file record and failures are reported safely. Factory
7
+ * validation/open failures reject. Call close explicitly; no process signal handlers are installed.
8
+ */
9
+ export declare function createNodeLogger(options?: NodeLoggerOptions): Promise<Readonly<NodeLogger>>;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/logger/node/index.ts"],"mappings":";;;;;;;;wBAqCsB,iBAAiB,UAAS,oBAAyB,QAAQ,SAAS"}
@@ -0,0 +1,123 @@
1
+ import { getLoggerStreamName } from "../_internals/levels.js";
2
+ import { supportsLoggerColor } from "../_internals/formatter.js";
3
+ import { createDiagnosticReporter, createLoggerCore } from "../_internals/logger.js";
4
+ import { createFileWriter } from "./_internals/file-writer.js";
5
+ import { formatNodeLoggerRecord } from "./_internals/formatter.js";
6
+ import { writeSync } from "node:fs";
7
+ import { stripVTControlCharacters } from "node:util";
8
+ // src/logger/node/index.ts
9
+ const consoleStreams = /* @__PURE__ */ new WeakMap();
10
+ /**
11
+ * Creates a Node.js/Bun logger with optional bounded, append-only file output and rotation.
12
+ *
13
+ * Log calls never throw or reject. Awaiting them waits for processing, not proof of successful
14
+ * persistence: overload drops the newest file record and failures are reported safely. Factory
15
+ * validation/open failures reject. Call close explicitly; no process signal handlers are installed.
16
+ */
17
+ async function createNodeLogger(options = {}) {
18
+ const report = createDiagnosticReporter(options.onError, (message) => writeSync(2, message));
19
+ let writer;
20
+ let closed = false;
21
+ let closePromise;
22
+ const consoleOwner = {};
23
+ const consoleTargets = /* @__PURE__ */ new Set();
24
+ const consoleWrites = /* @__PURE__ */ new Set();
25
+ const logger = createLoggerCore(options, {
26
+ report,
27
+ write(record) {
28
+ if (closed) {
29
+ report({
30
+ message: "Logger is closed.",
31
+ type: "closed"
32
+ });
33
+ return;
34
+ }
35
+ if (!record.console && !writer) return;
36
+ const target = process[getLoggerStreamName(record.type)];
37
+ const text = formatNodeLoggerRecord(record, record.console && supportsLoggerColor(target));
38
+ if (record.console) {
39
+ const line = `${text}\n`;
40
+ consoleTargets.add(target);
41
+ const completion = writeConsole(target, line, report, consoleOwner);
42
+ consoleWrites.add(completion);
43
+ completion.then(() => consoleWrites.delete(completion));
44
+ const fileCompletion = writer?.write(`${stripVTControlCharacters(text)}\n`);
45
+ return fileCompletion ? Promise.all([completion, fileCompletion]).then(() => {}) : completion;
46
+ }
47
+ return writer?.write(`${stripVTControlCharacters(text)}\n`);
48
+ }
49
+ });
50
+ if (options.file !== void 0 && options.file !== false) writer = await createFileWriter(options.file, report);
51
+ return Object.freeze({
52
+ ...logger,
53
+ close() {
54
+ if (closePromise) return closePromise;
55
+ closed = true;
56
+ closePromise = (async () => {
57
+ await Promise.all([writer?.close(), ...consoleWrites]);
58
+ for (const target of consoleTargets) {
59
+ const state = consoleStreams.get(target);
60
+ if (!state) continue;
61
+ state.owners.delete(consoleOwner);
62
+ if (!state.owners.size) {
63
+ target.off("error", state.onError);
64
+ target.off("close", state.onClose);
65
+ consoleStreams.delete(target);
66
+ }
67
+ }
68
+ consoleTargets.clear();
69
+ })();
70
+ return closePromise;
71
+ },
72
+ getStats: () => writer?.getStats() ?? Object.freeze({
73
+ droppedCount: 0,
74
+ pendingBytes: 0,
75
+ writeErrorCount: 0
76
+ })
77
+ });
78
+ }
79
+ /** One error listener per shared output stream; retained until its last owning logger calls close(). */
80
+ function writeConsole(target, text, report, owner) {
81
+ let state = consoleStreams.get(target);
82
+ if (!state) {
83
+ const pending = /* @__PURE__ */ new Set();
84
+ const onError = (error) => {
85
+ for (const settle of pending) settle(error);
86
+ };
87
+ const onClose = () => onError(/* @__PURE__ */ new Error("Console stream closed."));
88
+ state = {
89
+ onClose,
90
+ onError,
91
+ owners: /* @__PURE__ */ new Set(),
92
+ pending
93
+ };
94
+ consoleStreams.set(target, state);
95
+ target.on("error", onError);
96
+ target.on("close", onClose);
97
+ }
98
+ state.owners.add(owner);
99
+ const current = state;
100
+ return new Promise((resolveWritten) => {
101
+ let settled = false;
102
+ const settle = (error) => {
103
+ if (settled) return;
104
+ settled = true;
105
+ current.pending.delete(settle);
106
+ if (error) report({
107
+ error,
108
+ message: "Console output failed.",
109
+ type: "console"
110
+ });
111
+ resolveWritten();
112
+ };
113
+ current.pending.add(settle);
114
+ try {
115
+ target.write(text, settle);
116
+ } catch (error) {
117
+ settle(error instanceof Error ? error : /* @__PURE__ */ new Error("Console output failed."));
118
+ }
119
+ });
120
+ }
121
+ export { createNodeLogger };
122
+
123
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/logger/node/index.ts"],"sourcesContent":["import { writeSync } from 'node:fs';\nimport { stripVTControlCharacters } from 'node:util';\n\nimport { supportsLoggerColor } from '../_internals/formatter';\nimport { getLoggerStreamName } from '../_internals/levels';\nimport {\n createDiagnosticReporter,\n createLoggerCore,\n} from '../_internals/logger';\nimport type { LoggerDiagnostic } from '../types';\n\nimport { createFileWriter } from './_internals/file-writer';\nimport { formatNodeLoggerRecord } from './_internals/formatter';\nimport type {\n NodeLogger,\n NodeLoggerOptions,\n} from './types';\n\ninterface ConsoleStreamState {\n onClose: () => void;\n onError: (error: Error) => void;\n owners: Set<object>;\n pending: Set<(error?: Error | null) => void>;\n}\n\n// Constants/Variables\nconst consoleStreams = new WeakMap<NodeJS.WriteStream, ConsoleStreamState>();\n\n// Functions\n\n/**\n * Creates a Node.js/Bun logger with optional bounded, append-only file output and rotation.\n *\n * Log calls never throw or reject. Awaiting them waits for processing, not proof of successful\n * persistence: overload drops the newest file record and failures are reported safely. Factory\n * validation/open failures reject. Call close explicitly; no process signal handlers are installed.\n */\nexport async function createNodeLogger(options: NodeLoggerOptions = {}): Promise<Readonly<NodeLogger>> {\n const report = createDiagnosticReporter(options.onError, (message) => writeSync(2, message));\n let writer: Awaited<ReturnType<typeof createFileWriter>> | undefined;\n let closed = false;\n let closePromise: Promise<void> | undefined;\n const consoleOwner = {};\n const consoleTargets = new Set<NodeJS.WriteStream>();\n const consoleWrites = new Set<Promise<void>>();\n const logger = createLoggerCore(\n options,\n {\n report,\n write(record) {\n if (closed) {\n report({\n message: 'Logger is closed.',\n type: 'closed',\n });\n\n return;\n }\n\n if (!record.console && !writer) return;\n const target = process[getLoggerStreamName(record.type)];\n\n const text = formatNodeLoggerRecord(record, record.console && supportsLoggerColor(target));\n if (record.console) {\n const line = `${text}\\n`;\n consoleTargets.add(target);\n const completion = writeConsole(target, line, report, consoleOwner);\n consoleWrites.add(completion);\n void completion.then(() => consoleWrites.delete(completion));\n const fileCompletion = writer?.write(`${stripVTControlCharacters(text)}\\n`);\n return fileCompletion\n ? Promise.all([\n completion,\n fileCompletion,\n ]).then(() => {})\n : completion;\n }\n\n return writer?.write(`${stripVTControlCharacters(text)}\\n`);\n },\n },\n );\n\n if (options.file !== undefined && options.file !== false) writer = await createFileWriter(options.file, report);\n\n return Object.freeze({\n ...logger,\n close() {\n if (closePromise) return closePromise;\n closed = true;\n closePromise = (async () => {\n await Promise.all([\n writer?.close(),\n ...consoleWrites,\n ]);\n\n for (const target of consoleTargets) {\n const state = consoleStreams.get(target);\n if (!state) continue;\n state.owners.delete(consoleOwner);\n if (!state.owners.size) {\n target.off('error', state.onError);\n target.off('close', state.onClose);\n consoleStreams.delete(target);\n }\n }\n\n consoleTargets.clear();\n })();\n return closePromise;\n },\n getStats: () => writer?.getStats() ?? Object.freeze({\n droppedCount: 0,\n pendingBytes: 0,\n writeErrorCount: 0,\n }),\n });\n}\n\n/** One error listener per shared output stream; retained until its last owning logger calls close(). */\nfunction writeConsole(\n target: NodeJS.WriteStream,\n text: string,\n report: (event: LoggerDiagnostic) => void,\n owner: object,\n) {\n let state = consoleStreams.get(target);\n if (!state) {\n const pending = new Set<(error?: Error | null) => void>();\n const onError = (error: Error) => {\n for (const settle of pending) settle(error);\n };\n\n const onClose = () => onError(new Error('Console stream closed.'));\n state = {\n onClose,\n onError,\n owners: new Set(),\n pending,\n };\n\n consoleStreams.set(target, state);\n target.on('error', onError);\n target.on('close', onClose);\n }\n\n state.owners.add(owner);\n const current = state;\n return new Promise<void>((resolveWritten) => {\n let settled = false;\n const settle = (error?: Error | null) => {\n if (settled) return;\n settled = true;\n current.pending.delete(settle);\n if (error) {\n report({\n error,\n message: 'Console output failed.',\n type: 'console',\n });\n }\n\n resolveWritten();\n };\n\n current.pending.add(settle);\n try {\n target.write(text, settle);\n } catch (error) {\n settle(error instanceof Error ? error : new Error('Console output failed.'));\n }\n });\n}\n"],"mappings":"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"}
@@ -0,0 +1,43 @@
1
+ import { PathLike } from "../../classes/path.js";
2
+ import { Logger, LoggerOptions } from "../types.js";
3
+ /** Specify interval and/or maxSize. Size limits use positive integers with B, K, M, or G (binary units). */
4
+ export type LoggerRotationOptions = {
5
+ /** Gzip historical files. Defaults to true. */
6
+ compress?: boolean;
7
+ /** Number of historical files, excluding the active file. Defaults to 30. */
8
+ keepFiles?: number;
9
+ /** Maximum combined size of historical files. */
10
+ maxTotalSize?: string;
11
+ } & ({
12
+ /** Opt-in time rotation aligned to the system's local calendar boundary. */
13
+ interval: 'daily' | 'hourly';
14
+ maxSize?: string;
15
+ } | {
16
+ /** Opt-in time rotation aligned to the system's local calendar boundary. */
17
+ interval?: 'daily' | 'hourly';
18
+ maxSize: string;
19
+ });
20
+ export interface LoggerFileOptions {
21
+ /** Maximum unfinished payload bytes, including data already submitted to the stream. */
22
+ maxPendingBytes?: number;
23
+ /** Resolved once at creation. The file is opened in append mode. */
24
+ path: PathLike;
25
+ /** Omitted or false disables rotation. An object must specify interval or maxSize. */
26
+ rotate?: false | LoggerRotationOptions;
27
+ }
28
+ export interface NodeLogger extends Logger {
29
+ /** Stop accepting records, finish accepted file writes, then release the stream. Not fsync. */
30
+ close: () => Promise<void>;
31
+ /** A fresh, frozen file-output snapshot. Dropped/failed records still resolve their logging promises. */
32
+ getStats: () => Readonly<NodeLoggerStats>;
33
+ }
34
+ export interface NodeLoggerOptions extends LoggerOptions {
35
+ /** Disabled by default. Each logger owns at most one fixed file destination. */
36
+ file?: false | LoggerFileOptions;
37
+ }
38
+ export interface NodeLoggerStats {
39
+ droppedCount: number;
40
+ pendingBytes: number;
41
+ writeErrorCount: number;
42
+ }
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/logger/node/types.ts"],"mappings":";;;YAOY;;EAER;;EAGA;;EAGA;;;EAIE;EACA;;;EAIA;EACA;;iBAIW;;EAEb;;EAGA,MAAM;;EAGN,iBAAiB;;iBAGJ,mBAAmB;;EAEhC,aAAa;;EAGb,gBAAgB,SAAS;;iBAGZ,0BAA0B;;EAEvC,eAAe;;iBAGF;EACb;EACA;EACA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,50 @@
1
+ /** Minimum severity to emit; `success` uses the same threshold as `info`. */
2
+ export type LoggerLevel = 'debug' | 'error' | 'fatal' | 'info' | 'silent' | 'trace' | 'warn';
3
+ /** A logging method, including the informational success presentation. */
4
+ export type LoggerMethod = 'success' | Exclude<LoggerLevel, 'silent'>;
5
+ /**
6
+ * A logger whose logging methods never throw or reject for recoverable failures.
7
+ *
8
+ * Awaiting a method waits for processing, not guaranteed successful delivery or fsync.
9
+ * Configuration errors may throw from the factory, configure(), or setLevel().
10
+ * Factories freeze the API object; settings remain adjustable through its methods.
11
+ */
12
+ export interface Logger {
13
+ configure: (options: Pick<LoggerOptions, 'console' | 'icons' | 'prefix' | 'suffix' | 'timestamp'>) => void;
14
+ debug: (...args: unknown[]) => Promise<void>;
15
+ error: (...args: unknown[]) => Promise<void>;
16
+ fatal: (...args: unknown[]) => Promise<void>;
17
+ info: (...args: unknown[]) => Promise<void>;
18
+ /** Accepts success as an informational method; it is not a configurable threshold. */
19
+ isLevelEnabled: (level: LoggerLevel | LoggerMethod) => boolean;
20
+ /** Sets a severity threshold (not success); env restores environment-driven filtering. */
21
+ setLevel: (level: 'env' | LoggerLevel) => void;
22
+ success: (...args: unknown[]) => Promise<void>;
23
+ trace: (...args: unknown[]) => Promise<void>;
24
+ warn: (...args: unknown[]) => Promise<void>;
25
+ }
26
+ /** A shallow-frozen failure notification; nested error values retain their original ownership. */
27
+ export interface LoggerDiagnostic {
28
+ droppedCount?: number;
29
+ error?: unknown;
30
+ message: string;
31
+ /** Same-type notifications suppressed since the previous emitted diagnostic. */
32
+ suppressedCount?: number;
33
+ type: 'closed' | 'console' | 'file' | 'format' | 'invalid-level' | 'overflow';
34
+ }
35
+ /** Configuration shared by browser and server loggers. */
36
+ export interface LoggerOptions {
37
+ /** Enables console output. Defaults to `true`. */
38
+ console?: boolean;
39
+ /** Enables Unicode level icons. Defaults to `true`. */
40
+ icons?: boolean;
41
+ /** Overrides LOG_LEVEL; `env` restores the environment-driven threshold. */
42
+ level?: 'env' | LoggerLevel;
43
+ /** Best-effort, rate-limited notification; failures in this callback are contained. */
44
+ onError?: (event: Readonly<LoggerDiagnostic>) => void;
45
+ prefix?: string;
46
+ suffix?: string;
47
+ /** Enables the fixed local-time millisecond prefix. Defaults to `true`. */
48
+ timestamp?: boolean;
49
+ }
50
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/logger/types.ts"],"mappings":";YACY;;YAGA,2BAA2B,QAAQ;;;;;;;;iBAS9B;EACb,YAAY,SAAS,KAAK;EAC1B,WAAW,oBAAoB;EAC/B,WAAW,oBAAoB;EAC/B,WAAW,oBAAoB;EAC/B,UAAU,oBAAoB;;EAG9B,iBAAiB,OAAO,cAAc;;EAGtC,WAAW,eAAe;EAC1B,aAAa,oBAAoB;EACjC,WAAW,oBAAoB;EAC/B,UAAU,oBAAoB;;;iBAIjB;EACb;EACA;EACA;;EAGA;EACA;;;iBAIa;;EAEb;;EAGA;;EAGA,gBAAgB;;EAGhB,WAAW,OAAO,SAAS;EAC3B;EACA;;EAGA"}
@@ -0,0 +1 @@
1
+ export {};
package/dist/math.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Decimal } from "decimal.js";
2
- //#region src/math.d.ts
3
2
  type CalculableValue = Decimal.Value | {
4
3
  toString: () => string;
5
4
  };
@@ -45,6 +44,5 @@ export interface ToPercentageStringOptions {
45
44
  * ```
46
45
  */
47
46
  export declare function toPercentageString(molecular: CalculableValue, denominator: CalculableValue, options?: ToPercentageStringOptions): string;
48
- //#endregion
49
47
  export {};
50
48
  //# sourceMappingURL=math.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"math.d.ts","names":[],"sources":["../src/math.ts"],"mappings":";;KAEK,kBAAkB,QAAQ;EAAU;;;;;iBAKxB;;;;;;EAMb;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BY,mBACZ,WAAW,iBACX,aAAa,iBACb,UAAU"}
1
+ {"version":3,"file":"math.d.ts","names":[],"sources":["../src/math.ts"],"mappings":";KAEK,kBAAkB,QAAQ;EAAU;;;;;iBAKxB;;;;;;EAMb;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BY,mBACZ,WAAW,iBACX,aAAa,iBACb,UAAU"}
package/dist/math.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Decimal } from "decimal.js";
2
- //#region src/math.ts
2
+ // src/math.ts
3
3
  /**
4
4
  * Converts a numerator and denominator into a formatted percentage.
5
5
  *
@@ -31,7 +31,6 @@ function toPercentageString(molecular, denominator, options) {
31
31
  const result = calculationResult.isNaN() || !calculationResult.isFinite() ? "0.00" : calculationResult.times(100).toFixed(options?.decimalPlaces ?? 2);
32
32
  return options?.withSymbol ?? true ? `${result}%` : result;
33
33
  }
34
- //#endregion
35
34
  export { toPercentageString };
36
35
 
37
36
  //# sourceMappingURL=math.js.map
package/dist/number.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { millify } from "millify";
2
- //#region src/number.d.ts
3
2
  /**
4
3
  * Converts a large number into a compact, human-readable string using `millify`.
5
4
  *
@@ -21,5 +20,4 @@ import { millify } from "millify";
21
20
  * ```
22
21
  */
23
22
  export declare function toCompactNumberString(value: number, options?: Parameters<typeof millify>[1]): string;
24
- //#endregion
25
23
  //# sourceMappingURL=number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","names":[],"sources":["../src/number.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;wBAsBgB,sBAAsB,eAAe,UAAU,kBAAkB"}
1
+ {"version":3,"file":"number.d.ts","names":[],"sources":["../src/number.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;wBAsBgB,sBAAsB,eAAe,UAAU,kBAAkB"}
package/dist/number.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { millify } from "millify";
2
- //#region src/number.ts
2
+ // src/number.ts
3
3
  /**
4
4
  * Converts a large number into a compact, human-readable string using `millify`.
5
5
  *
@@ -27,7 +27,6 @@ function toCompactNumberString(value, options) {
27
27
  ...options
28
28
  });
29
29
  }
30
- //#endregion
31
30
  export { toCompactNumberString };
32
31
 
33
32
  //# sourceMappingURL=number.js.map
package/dist/random.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/random.d.ts
2
1
  /**
3
2
  * Calls a generator once with a length sampled from two nested random ranges.
4
3
  *
@@ -23,5 +22,4 @@
23
22
  * @throws Error if `minMin` exceeds `minMax` or `maxMin` exceeds `maxMax`.
24
23
  */
25
24
  export declare function generateWithNestedRandomLength<T = string>(generator: (length: number) => T, minMin: number, minMax: number, maxMin: number, maxMax: number): T;
26
- //#endregion
27
25
  //# sourceMappingURL=random.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"random.d.ts","names":[],"sources":["../src/random.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;wBAuBgB,+BAA+B,YAC3C,YAAY,mBAAmB,GAC/B,gBACA,gBACA,gBACA,iBAAc"}
1
+ {"version":3,"file":"random.d.ts","names":[],"sources":["../src/random.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;wBAuBgB,+BAA+B,YAC3C,YAAY,mBAAmB,GAC/B,gBACA,gBACA,gBACA,iBAAc"}
package/dist/random.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/random.ts
1
+ // src/random.ts
2
2
  /**
3
3
  * Calls a generator once with a length sampled from two nested random ranges.
4
4
  *
@@ -29,7 +29,6 @@ function generateWithNestedRandomLength(generator, minMin, minMax, maxMin, maxMa
29
29
  const innerMin = random(minMin, minMax);
30
30
  return generator(random(Math.max(innerMin, maxMin), maxMax));
31
31
  }
32
- //#endregion
33
32
  export { generateWithNestedRandomLength };
34
33
 
35
34
  //# sourceMappingURL=random.js.map
@@ -1,4 +1,3 @@
1
- //#region src/redis/script-runner.d.ts
2
1
  /**
3
2
  * An asynchronous Lua script runner with caller-declared results.
4
3
  *
@@ -53,5 +52,4 @@ export interface RedisLikeScriptClient {
53
52
  * @throws RangeError if `maxAttempts` is not a positive safe integer.
54
53
  */
55
54
  export declare function createRedisScriptRunner<T = unknown>(client: RedisLikeScriptClient, source: string, maxAttempts?: number): RedisScriptRunner<T>;
56
- //#endregion
57
55
  //# sourceMappingURL=script-runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"script-runner.d.ts","names":[],"sources":["../../src/redis/script-runner.ts"],"mappings":";;;;;;;;;;;;;;;YAgBY,kBAAkB,gBAAgB,yBAAyB,uCAAuC,QAC1G;;;;;;;;;iBAWa;;;;;;;EAOb,OAAO,iBAAiB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;wBAwB/B,wBAAwB,aACpC,QAAQ,uBACR,gBACA,uBACD,kBAAkB"}
1
+ {"version":3,"file":"script-runner.d.ts","names":[],"sources":["../../src/redis/script-runner.ts"],"mappings":";;;;;;;;;;;;;;YAgBY,kBAAkB,gBAAgB,yBAAyB,uCAAuC,QAC1G;;;;;;;;;iBAWa;;;;;;;EAOb,OAAO,iBAAiB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;wBAwB/B,wBAAwB,aACpC,QAAQ,uBACR,gBACA,uBACD,kBAAkB"}
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- //#region src/redis/script-runner.ts
2
+ // src/redis/script-runner.ts
3
3
  /**
4
4
  * Creates a Lua script runner that reloads missing cached scripts before retrying execution.
5
5
  *
@@ -40,7 +40,6 @@ function createRedisScriptRunner(client, source, maxAttempts = 3) {
40
40
  }
41
41
  };
42
42
  }
43
- //#endregion
44
43
  export { createRedisScriptRunner };
45
44
 
46
45
  //# sourceMappingURL=script-runner.js.map
@@ -1,5 +1,4 @@
1
1
  import { LRUCache } from "lru-cache";
2
- //#region src/storages/lru/keyed-store.d.ts
3
2
  /**
4
3
  * Creates a keyed cache factory sharing a caller-owned LRU cache.
5
4
  *
@@ -45,5 +44,4 @@ export declare function createLruKeyedStore<D = unknown>(lruInstance: LRUCache<a
45
44
  setItem: (value: D, ...args: P) => LRUCache<any, any, any>;
46
45
  setItemWithTtl(ttlMilliseconds: number, value: D, ...args: P): LRUCache<any, any, any>;
47
46
  }>;
48
- //#endregion
49
47
  //# sourceMappingURL=keyed-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyed-store.d.ts","names":[],"sources":["../../../src/storages/lru/keyed-store.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BgB,oBAAoB,aAAa,aAAa,2BAClD,iBAAiB,WAAW,MAAM,iBAAY;;;;;;EAMjC,WAAA,MAAA,IAAC,YAAA;EAII,gBAAA,MAAA;EACH,aAAA,MAAA;EACG,gBAAA,MAAA;;;;EAIA,gBAAA,MAAA;EACL,UAAA,OAAA,MAAC,MAAW,MAAC;EACE,eAAA,yBAAM,OAAS,MAAC,MAAW,IAAC"}
1
+ {"version":3,"file":"keyed-store.d.ts","names":[],"sources":["../../../src/storages/lru/keyed-store.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BgB,oBAAoB,aAAa,aAAa,2BAClD,iBAAiB,WAAW,MAAM,iBAAY;;;;;;EAMjC,WAAA,MAAA,IAAC,YAAA;EAII,gBAAA,MAAA;EACH,aAAA,MAAA;EACG,gBAAA,MAAA;;;;EAIA,gBAAA,MAAA;EACL,UAAA,OAAA,MAAC,MAAW,MAAC;EACE,eAAA,yBAAM,OAAS,MAAC,MAAW,IAAC"}
@@ -1,4 +1,4 @@
1
- //#region src/storages/lru/keyed-store.ts
1
+ // src/storages/lru/keyed-store.ts
2
2
  /**
3
3
  * Creates a keyed cache factory sharing a caller-owned LRU cache.
4
4
  *
@@ -50,7 +50,6 @@ function createLruKeyedStore(lruInstance) {
50
50
  }
51
51
  });
52
52
  }
53
- //#endregion
54
53
  export { createLruKeyedStore };
55
54
 
56
55
  //# sourceMappingURL=keyed-store.js.map
@@ -1,13 +1,12 @@
1
1
  import { MaybeReadonly } from "../../types/index.js";
2
2
  import { RedisLikeStorage } from "./types.js";
3
- //#region src/storages/redis/keyed-store.d.ts
4
3
  /**
5
4
  * Creates a keyed store factory sharing a caller-owned Redis-like storage facade.
6
5
  *
7
6
  * @remarks
8
7
  * The key resolver is called synchronously once per operation with the operation's key arguments.
9
8
  * Resolver exceptions propagate synchronously; asynchronous storage failures retain the underlying rejection.
10
- * `setItemWithTtl` accepts its TTL in seconds before the value and key arguments.
9
+ * `setItemWithTtl` and `setItemWithTtlIfAbsent` accept their TTL in seconds before the value and key arguments.
11
10
  * The factory does not open or close the underlying connection; cleanup remains the caller's responsibility.
12
11
  *
13
12
  * @typeParam D - The stored value type used by reads and writes.
@@ -15,9 +14,10 @@ import { RedisLikeStorage } from "./types.js";
15
14
  * @param storage - The shared Redis-like storage instance.
16
15
  *
17
16
  * @returns A factory accepting a key resolver and returning a new frozen keyed facade sharing the storage.
18
- * Reads, writes, removals, and TTL results retain the underlying storage contract.
17
+ * Reads, atomic read-and-removals, writes, removals, and TTL results retain the underlying storage contract.
19
18
  */
20
19
  export declare function createRedisKeyedStore<D = unknown>(storage: MaybeReadonly<RedisLikeStorage>): <P extends any[]>(keyFn: (...args: P) => string) => Readonly<{
20
+ getAndRemoveItem: (...args: P) => Promise<D | null>;
21
21
  getItem: (...args: P) => Promise<D | null>;
22
22
  getItemTtl: (...args: P) => Promise<number>;
23
23
  hasItem: (...args: P) => Promise<boolean>;
@@ -25,6 +25,6 @@ export declare function createRedisKeyedStore<D = unknown>(storage: MaybeReadonl
25
25
  resolveKey: (...args: P) => string;
26
26
  setItem: (value: D, ...args: P) => Promise<boolean>;
27
27
  setItemWithTtl(ttlSeconds: number, value: D, ...args: P): Promise<boolean>;
28
+ setItemWithTtlIfAbsent(ttlSeconds: number, value: D, ...args: P): Promise<boolean>;
28
29
  }>;
29
- //#endregion
30
30
  //# sourceMappingURL=keyed-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyed-store.d.ts","names":[],"sources":["../../../src/storages/redis/keyed-store.ts"],"mappings":";;;;;;;;;;;;;;;;;;;wBAoBgB,sBAAsB,aAAa,SAAS,cAAc,qBAC9D,iBAAiB,WAAW,MAAM,iBAAY;EAC/B,aAAA,MAAA,MAAC,QAAA;EACE,gBAAA,MAAA,MAAC;EACJ,aAAA,MAAA,MAAC;EACE,gBAAA,MAAA,MAAC;EACD,gBAAA,MAAA;EACL,UAAA,OAAA,MAAC,MAAW,MAAC;EACH,eAAA,oBAAM,OAAS,MAAC,MAAW,IAAC"}
1
+ {"version":3,"file":"keyed-store.d.ts","names":[],"sources":["../../../src/storages/redis/keyed-store.ts"],"mappings":";;;;;;;;;;;;;;;;;;wBAoBgB,sBAAsB,aAAa,SAAS,cAAc,qBAC9D,iBAAiB,WAAW,MAAM,iBAAY;EACtB,sBAAA,MAAA,MAAC,QAAA;EACV,aAAA,MAAA,MAAC,QAAA;EACE,gBAAA,MAAA,MAAC;EACJ,aAAA,MAAA,MAAC;EACE,gBAAA,MAAA,MAAC;EACD,gBAAA,MAAA;EACL,UAAA,OAAA,MAAC,MAAW,MAAC;EACH,eAAA,oBAAM,OAAS,MAAC,MAAW,IAAC;EAGpB,uBAAA,oBAAM,OAAS,MAAC,MAAW,IAAC"}
@@ -1,11 +1,11 @@
1
- //#region src/storages/redis/keyed-store.ts
1
+ // src/storages/redis/keyed-store.ts
2
2
  /**
3
3
  * Creates a keyed store factory sharing a caller-owned Redis-like storage facade.
4
4
  *
5
5
  * @remarks
6
6
  * The key resolver is called synchronously once per operation with the operation's key arguments.
7
7
  * Resolver exceptions propagate synchronously; asynchronous storage failures retain the underlying rejection.
8
- * `setItemWithTtl` accepts its TTL in seconds before the value and key arguments.
8
+ * `setItemWithTtl` and `setItemWithTtlIfAbsent` accept their TTL in seconds before the value and key arguments.
9
9
  * The factory does not open or close the underlying connection; cleanup remains the caller's responsibility.
10
10
  *
11
11
  * @typeParam D - The stored value type used by reads and writes.
@@ -13,10 +13,11 @@
13
13
  * @param storage - The shared Redis-like storage instance.
14
14
  *
15
15
  * @returns A factory accepting a key resolver and returning a new frozen keyed facade sharing the storage.
16
- * Reads, writes, removals, and TTL results retain the underlying storage contract.
16
+ * Reads, atomic read-and-removals, writes, removals, and TTL results retain the underlying storage contract.
17
17
  */
18
18
  function createRedisKeyedStore(storage) {
19
19
  return (keyFn) => Object.freeze({
20
+ getAndRemoveItem: (...args) => storage.getAndRemoveItem(keyFn(...args)),
20
21
  getItem: (...args) => storage.getItem(keyFn(...args)),
21
22
  getItemTtl: (...args) => storage.getItemTtl(keyFn(...args)),
22
23
  hasItem: (...args) => storage.hasItem(keyFn(...args)),
@@ -25,10 +26,12 @@ function createRedisKeyedStore(storage) {
25
26
  setItem: (value, ...args) => storage.setItem(keyFn(...args), value),
26
27
  setItemWithTtl(ttlSeconds, value, ...args) {
27
28
  return storage.setItemWithTtl(keyFn(...args), ttlSeconds, value);
29
+ },
30
+ setItemWithTtlIfAbsent(ttlSeconds, value, ...args) {
31
+ return storage.setItemWithTtlIfAbsent(keyFn(...args), ttlSeconds, value);
28
32
  }
29
33
  });
30
34
  }
31
- //#endregion
32
35
  export { createRedisKeyedStore };
33
36
 
34
37
  //# sourceMappingURL=keyed-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyed-store.js","names":[],"sources":["../../../src/storages/redis/keyed-store.ts"],"sourcesContent":["import type { MaybeReadonly } from '../../types';\n\nimport type { RedisLikeStorage } from './types';\n\n/**\n * Creates a keyed store factory sharing a caller-owned Redis-like storage facade.\n *\n * @remarks\n * The key resolver is called synchronously once per operation with the operation's key arguments.\n * Resolver exceptions propagate synchronously; asynchronous storage failures retain the underlying rejection.\n * `setItemWithTtl` accepts its TTL in seconds before the value and key arguments.\n * The factory does not open or close the underlying connection; cleanup remains the caller's responsibility.\n *\n * @typeParam D - The stored value type used by reads and writes.\n *\n * @param storage - The shared Redis-like storage instance.\n *\n * @returns A factory accepting a key resolver and returning a new frozen keyed facade sharing the storage.\n * Reads, writes, removals, and TTL results retain the underlying storage contract.\n */\nexport function createRedisKeyedStore<D = unknown>(storage: MaybeReadonly<RedisLikeStorage>) {\n return <P extends any[]>(keyFn: (...args: P) => string) => Object.freeze({\n getItem: (...args: P) => storage.getItem<D>(keyFn(...args)),\n getItemTtl: (...args: P) => storage.getItemTtl(keyFn(...args)),\n hasItem: (...args: P) => storage.hasItem(keyFn(...args)),\n removeItem: (...args: P) => storage.removeItem(keyFn(...args)),\n resolveKey: (...args: P) => keyFn(...args),\n setItem: (value: D, ...args: P) => storage.setItem(keyFn(...args), value),\n setItemWithTtl(ttlSeconds: number, value: D, ...args: P) {\n return storage.setItemWithTtl(keyFn(...args), ttlSeconds, value);\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,SAAgB,sBAAmC,SAA0C;CACzF,QAAyB,UAAkC,OAAO,OAAO;EACrE,UAAU,GAAG,SAAY,QAAQ,QAAW,MAAM,GAAG,IAAI,CAAC;EAC1D,aAAa,GAAG,SAAY,QAAQ,WAAW,MAAM,GAAG,IAAI,CAAC;EAC7D,UAAU,GAAG,SAAY,QAAQ,QAAQ,MAAM,GAAG,IAAI,CAAC;EACvD,aAAa,GAAG,SAAY,QAAQ,WAAW,MAAM,GAAG,IAAI,CAAC;EAC7D,aAAa,GAAG,SAAY,MAAM,GAAG,IAAI;EACzC,UAAU,OAAU,GAAG,SAAY,QAAQ,QAAQ,MAAM,GAAG,IAAI,GAAG,KAAK;EACxE,eAAe,YAAoB,OAAU,GAAG,MAAS;GACrD,OAAO,QAAQ,eAAe,MAAM,GAAG,IAAI,GAAG,YAAY,KAAK;EACnE;CACJ,CAAC;AACL"}
1
+ {"version":3,"file":"keyed-store.js","names":[],"sources":["../../../src/storages/redis/keyed-store.ts"],"sourcesContent":["import type { MaybeReadonly } from '../../types';\n\nimport type { RedisLikeStorage } from './types';\n\n/**\n * Creates a keyed store factory sharing a caller-owned Redis-like storage facade.\n *\n * @remarks\n * The key resolver is called synchronously once per operation with the operation's key arguments.\n * Resolver exceptions propagate synchronously; asynchronous storage failures retain the underlying rejection.\n * `setItemWithTtl` and `setItemWithTtlIfAbsent` accept their TTL in seconds before the value and key arguments.\n * The factory does not open or close the underlying connection; cleanup remains the caller's responsibility.\n *\n * @typeParam D - The stored value type used by reads and writes.\n *\n * @param storage - The shared Redis-like storage instance.\n *\n * @returns A factory accepting a key resolver and returning a new frozen keyed facade sharing the storage.\n * Reads, atomic read-and-removals, writes, removals, and TTL results retain the underlying storage contract.\n */\nexport function createRedisKeyedStore<D = unknown>(storage: MaybeReadonly<RedisLikeStorage>) {\n return <P extends any[]>(keyFn: (...args: P) => string) => Object.freeze({\n getAndRemoveItem: (...args: P) => storage.getAndRemoveItem<D>(keyFn(...args)),\n getItem: (...args: P) => storage.getItem<D>(keyFn(...args)),\n getItemTtl: (...args: P) => storage.getItemTtl(keyFn(...args)),\n hasItem: (...args: P) => storage.hasItem(keyFn(...args)),\n removeItem: (...args: P) => storage.removeItem(keyFn(...args)),\n resolveKey: (...args: P) => keyFn(...args),\n setItem: (value: D, ...args: P) => storage.setItem(keyFn(...args), value),\n setItemWithTtl(ttlSeconds: number, value: D, ...args: P) {\n return storage.setItemWithTtl(keyFn(...args), ttlSeconds, value);\n },\n setItemWithTtlIfAbsent(ttlSeconds: number, value: D, ...args: P) {\n return storage.setItemWithTtlIfAbsent(keyFn(...args), ttlSeconds, value);\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,SAAgB,sBAAmC,SAA0C;CACzF,QAAyB,UAAkC,OAAO,OAAO;EACrE,mBAAmB,GAAG,SAAY,QAAQ,iBAAoB,MAAM,GAAG,IAAI,CAAC;EAC5E,UAAU,GAAG,SAAY,QAAQ,QAAW,MAAM,GAAG,IAAI,CAAC;EAC1D,aAAa,GAAG,SAAY,QAAQ,WAAW,MAAM,GAAG,IAAI,CAAC;EAC7D,UAAU,GAAG,SAAY,QAAQ,QAAQ,MAAM,GAAG,IAAI,CAAC;EACvD,aAAa,GAAG,SAAY,QAAQ,WAAW,MAAM,GAAG,IAAI,CAAC;EAC7D,aAAa,GAAG,SAAY,MAAM,GAAG,IAAI;EACzC,UAAU,OAAU,GAAG,SAAY,QAAQ,QAAQ,MAAM,GAAG,IAAI,GAAG,KAAK;EACxE,eAAe,YAAoB,OAAU,GAAG,MAAS;GACrD,OAAO,QAAQ,eAAe,MAAM,GAAG,IAAI,GAAG,YAAY,KAAK;EACnE;EACA,uBAAuB,YAAoB,OAAU,GAAG,MAAS;GAC7D,OAAO,QAAQ,uBAAuB,MAAM,GAAG,IAAI,GAAG,YAAY,KAAK;EAC3E;CACJ,CAAC;AACL"}
@@ -1,11 +1,11 @@
1
1
  import { RedisLikeAdapter, RedisLikeStorage } from "./types.js";
2
- //#region src/storages/redis/msgpack.d.ts
3
2
  /**
4
3
  * Creates a frozen Redis-like storage facade using MessagePack serialization.
5
4
  *
6
5
  * @remarks
7
6
  * Adapter rejections and MessagePack serialization errors propagate to the caller.
8
- * Reads resolve to `null` when no raw value exists. Writes resolve to `true` only when the adapter returns `OK`;
7
+ * Reads resolve to `null` when no raw value exists; `getAndRemoveItem` reads and deletes in one atomic adapter call.
8
+ * Writes resolve to `true` only when the adapter returns `OK`;
9
9
  * removal resolves to `true` only when exactly one key is deleted.
10
10
  * The adapter remains caller-owned; creating the facade does not open or close a connection.
11
11
  *
@@ -24,6 +24,11 @@ import { RedisLikeAdapter, RedisLikeStorage } from "./types.js";
24
24
  * const adapter: RedisLikeAdapter = {
25
25
  * delete: async (key) => values.delete(key) ? 1 : 0,
26
26
  * getBuffer: async (key) => values.get(key) ?? null,
27
+ * getBufferAndDelete: async (key) => {
28
+ * const value = values.get(key) ?? null;
29
+ * values.delete(key);
30
+ * return value;
31
+ * },
27
32
  * has: async (key) => values.has(key),
28
33
  * setBuffer: async (key, value) => {
29
34
  * values.set(key, value);
@@ -32,6 +37,9 @@ import { RedisLikeAdapter, RedisLikeStorage } from "./types.js";
32
37
  * setBufferEx: async () => {
33
38
  * throw new Error('TTL writes are not supported by this example adapter');
34
39
  * },
40
+ * setBufferExNx: async () => {
41
+ * throw new Error('TTL writes are not supported by this example adapter');
42
+ * },
35
43
  * ttl: async (key) => values.has(key) ? -1 : -2,
36
44
  * };
37
45
  *
@@ -42,5 +50,4 @@ import { RedisLikeAdapter, RedisLikeStorage } from "./types.js";
42
50
  * ```
43
51
  */
44
52
  export declare function createRedisMsgpackStorage(adapter: RedisLikeAdapter): Readonly<RedisLikeStorage>;
45
- //#endregion
46
53
  //# sourceMappingURL=msgpack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"msgpack.d.ts","names":[],"sources":["../../../src/storages/redis/msgpack.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwDgB,0BAA0B,SAAS,mBAAmB,SAAS"}
1
+ {"version":3,"file":"msgpack.d.ts","names":[],"sources":["../../../src/storages/redis/msgpack.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiEgB,0BAA0B,SAAS,mBAAmB,SAAS"}