@bazariodev/docket 0.0.0-stage → 1.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 (96) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +21 -0
  3. package/README.md +985 -2
  4. package/dist/browser/constants.d.cts +14 -0
  5. package/dist/browser/constants.d.ts +14 -0
  6. package/dist/browser/index.cjs +192 -0
  7. package/dist/browser/index.cjs.map +1 -0
  8. package/dist/browser/index.d.cts +29 -0
  9. package/dist/browser/index.d.ts +29 -0
  10. package/dist/browser/index.js +187 -0
  11. package/dist/browser/index.js.map +1 -0
  12. package/dist/chunk-7ld72rnl.js +376 -0
  13. package/dist/chunk-7ld72rnl.js.map +1 -0
  14. package/dist/chunk-BLf-eCDO.cjs +53 -0
  15. package/dist/chunk-BLf-eCDO.cjs.map +1 -0
  16. package/dist/chunk-CEhpwtwJ.cjs +379 -0
  17. package/dist/chunk-CEhpwtwJ.cjs.map +1 -0
  18. package/dist/chunk-CSS3f4_M.js +46 -0
  19. package/dist/chunk-CSS3f4_M.js.map +1 -0
  20. package/dist/chunk-CXZYNALm.cjs +124 -0
  21. package/dist/chunk-CXZYNALm.cjs.map +1 -0
  22. package/dist/chunk-DYcNnkOV.js +50 -0
  23. package/dist/chunk-DYcNnkOV.js.map +1 -0
  24. package/dist/chunk-DkvWLziD.js +437 -0
  25. package/dist/chunk-DkvWLziD.js.map +1 -0
  26. package/dist/chunk-DqK_3eFr.cjs +53 -0
  27. package/dist/chunk-DqK_3eFr.cjs.map +1 -0
  28. package/dist/chunk-LRCHwVuE.js +110 -0
  29. package/dist/chunk-LRCHwVuE.js.map +1 -0
  30. package/dist/chunk-ieB8yTEn.cjs +439 -0
  31. package/dist/chunk-ieB8yTEn.cjs.map +1 -0
  32. package/dist/client/index.cjs +167 -0
  33. package/dist/client/index.cjs.map +1 -0
  34. package/dist/client/index.d.cts +40 -0
  35. package/dist/client/index.d.ts +40 -0
  36. package/dist/client/index.js +165 -0
  37. package/dist/client/index.js.map +1 -0
  38. package/dist/constants.d.cts +4 -0
  39. package/dist/constants.d.ts +4 -0
  40. package/dist/core/constants.d.cts +43 -0
  41. package/dist/core/constants.d.ts +43 -0
  42. package/dist/devtools/index.cjs +37 -0
  43. package/dist/devtools/index.cjs.map +1 -0
  44. package/dist/devtools/index.d.cts +11 -0
  45. package/dist/devtools/index.d.ts +11 -0
  46. package/dist/devtools/index.js +35 -0
  47. package/dist/devtools/index.js.map +1 -0
  48. package/dist/export/index.cjs +139 -0
  49. package/dist/export/index.cjs.map +1 -0
  50. package/dist/export/index.d.cts +49 -0
  51. package/dist/export/index.d.ts +49 -0
  52. package/dist/export/index.js +137 -0
  53. package/dist/export/index.js.map +1 -0
  54. package/dist/history/index.cjs +30 -0
  55. package/dist/history/index.cjs.map +1 -0
  56. package/dist/history/index.d.cts +11 -0
  57. package/dist/history/index.d.ts +11 -0
  58. package/dist/history/index.js +28 -0
  59. package/dist/history/index.js.map +1 -0
  60. package/dist/index.cjs +14 -0
  61. package/dist/index.cjs.map +1 -0
  62. package/dist/index.d.cts +159 -0
  63. package/dist/index.d.ts +159 -0
  64. package/dist/index.js +6 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/indexeddb/index.cjs +26 -0
  67. package/dist/indexeddb/index.cjs.map +1 -0
  68. package/dist/indexeddb/index.d.cts +61 -0
  69. package/dist/indexeddb/index.d.ts +61 -0
  70. package/dist/indexeddb/index.js +23 -0
  71. package/dist/indexeddb/index.js.map +1 -0
  72. package/dist/redaction/index.cjs +154 -0
  73. package/dist/redaction/index.cjs.map +1 -0
  74. package/dist/redaction/index.d.cts +70 -0
  75. package/dist/redaction/index.d.ts +70 -0
  76. package/dist/redaction/index.js +152 -0
  77. package/dist/redaction/index.js.map +1 -0
  78. package/dist/sip/index.cjs +336 -0
  79. package/dist/sip/index.cjs.map +1 -0
  80. package/dist/sip/index.d.cts +34 -0
  81. package/dist/sip/index.d.ts +34 -0
  82. package/dist/sip/index.js +333 -0
  83. package/dist/sip/index.js.map +1 -0
  84. package/dist/storage/constants.d.cts +11 -0
  85. package/dist/storage/constants.d.ts +11 -0
  86. package/dist/storage/contracts.d.cts +31 -0
  87. package/dist/storage/contracts.d.ts +31 -0
  88. package/dist/upload/constants.d.cts +17 -0
  89. package/dist/upload/constants.d.ts +17 -0
  90. package/dist/upload/index.cjs +246 -0
  91. package/dist/upload/index.cjs.map +1 -0
  92. package/dist/upload/index.d.cts +51 -0
  93. package/dist/upload/index.d.ts +51 -0
  94. package/dist/upload/index.js +244 -0
  95. package/dist/upload/index.js.map +1 -0
  96. package/package.json +150 -3
@@ -0,0 +1,167 @@
1
+ 'use strict';
2
+
3
+ var hub = require('../chunk-ieB8yTEn.cjs');
4
+ var history_index = require('../history/index.cjs');
5
+ var upload_index = require('../upload/index.cjs');
6
+ require('../chunk-CXZYNALm.cjs');
7
+ require('../chunk-BLf-eCDO.cjs');
8
+ require('../chunk-CEhpwtwJ.cjs');
9
+ require('@bazariodev/coordination');
10
+
11
+ const CLIENT_DEFAULTS = Object.freeze({
12
+ MAX_HISTORY_RECORDS: 1000,
13
+ MAX_BATCH_RECORDS: 100,
14
+ INTERVAL_MS: 5000,
15
+ });
16
+
17
+ const HISTORY_METHODS = Object.freeze({
18
+ REQUIRED: Object.freeze(['write', 'query', 'clear']),
19
+ OPTIONAL: Object.freeze(['flush', 'stop', 'getStatus']),
20
+ });
21
+
22
+ function resolveHistory(history) {
23
+ if (history === false) return undefined;
24
+ if (history === undefined)
25
+ return history_index.createMemoryHistory({
26
+ maxRecords: CLIENT_DEFAULTS.MAX_HISTORY_RECORDS,
27
+ });
28
+ if (!history || typeof history !== 'object')
29
+ throw new TypeError('Invalid history options');
30
+ if (
31
+ !HISTORY_METHODS.REQUIRED.some((method) => method in history) &&
32
+ !HISTORY_METHODS.OPTIONAL.some((method) => method in history)
33
+ )
34
+ return history_index.createMemoryHistory(history);
35
+ if (
36
+ HISTORY_METHODS.REQUIRED.some(
37
+ (method) => typeof history[method] !== 'function',
38
+ )
39
+ )
40
+ throw new TypeError('A history client requires write, query, and clear');
41
+ for (const method of HISTORY_METHODS.OPTIONAL)
42
+ if (history[method] !== undefined && typeof history[method] !== 'function')
43
+ throw new TypeError(`Invalid history ${method}`);
44
+ return history;
45
+ }
46
+
47
+ function createDocket(options) {
48
+ if (!options || typeof options !== 'object')
49
+ throw new TypeError('Docket options are required');
50
+ const {
51
+ areas,
52
+ redactor,
53
+ sinks: suppliedSinks,
54
+ context,
55
+ levelStorage,
56
+ maxOverrideMs,
57
+ stormLimit,
58
+ scheduler,
59
+ now,
60
+ monotonicNow,
61
+ createRunId,
62
+ onError,
63
+ history: historyOption,
64
+ upload: uploadOption,
65
+ isActive: isApplicationActive,
66
+ } = options;
67
+ const history = resolveHistory(historyOption);
68
+ let upload;
69
+ let uploadOptions;
70
+ let outbox;
71
+ if (uploadOption !== undefined && uploadOption !== false) {
72
+ if (!uploadOption || typeof uploadOption !== 'object')
73
+ throw new TypeError('Invalid upload options');
74
+ outbox = uploadOption.outbox;
75
+ if (
76
+ !outbox ||
77
+ outbox === history ||
78
+ typeof outbox.clear !== 'function' ||
79
+ typeof outbox.stop !== 'function'
80
+ )
81
+ throw new TypeError('Upload requires a separate outbox client');
82
+ const {
83
+ maxBatchRecords = CLIENT_DEFAULTS.MAX_BATCH_RECORDS,
84
+ intervalMs = CLIENT_DEFAULTS.INTERVAL_MS,
85
+ scheduler,
86
+ onError,
87
+ send,
88
+ } = uploadOption;
89
+ if (typeof send !== 'function')
90
+ throw new TypeError('An upload callback is required');
91
+ uploadOptions = {
92
+ maxBatchRecords,
93
+ intervalMs,
94
+ scheduler,
95
+ onError,
96
+ send: (records, signal, token) =>
97
+ send.call(uploadOption, records, signal, token),
98
+ };
99
+ }
100
+ const sinks = [...(suppliedSinks ?? [])];
101
+ if (history) sinks.push(history);
102
+ for (const sink of sinks)
103
+ if (!sink || typeof sink.write !== 'function')
104
+ throw new TypeError('A sink must have write');
105
+ let closed = false;
106
+ const logging = hub.createLogging({
107
+ areas,
108
+ redactor,
109
+ context,
110
+ levelStorage,
111
+ maxOverrideMs,
112
+ stormLimit,
113
+ scheduler,
114
+ now,
115
+ monotonicNow,
116
+ createRunId: createRunId ? () => createRunId.call(options) : createRunId,
117
+ onError,
118
+ isActive() {
119
+ if (closed) return false;
120
+ const active = isApplicationActive?.call(options);
121
+ return !closed && active !== false;
122
+ },
123
+ sinks: [],
124
+ });
125
+ const detachments = [];
126
+ try {
127
+ if (uploadOptions) upload = upload_index.createUploadSink(uploadOptions, outbox);
128
+ if (upload) sinks.push(upload);
129
+ for (const sink of sinks) detachments.push(logging.addSink(sink));
130
+ } catch (error) {
131
+ for (const detach of detachments) detach();
132
+ void upload?.stop();
133
+ void logging.stop().catch(() => {});
134
+ throw error;
135
+ }
136
+ let stopped;
137
+ return Object.freeze({
138
+ ...logging,
139
+ history,
140
+ upload,
141
+ outbox,
142
+ stop() {
143
+ if (stopped) return stopped;
144
+ closed = true;
145
+ stopped = Promise.resolve().then(async () => {
146
+ const failures = [];
147
+ try {
148
+ await logging.stop();
149
+ } catch (error) {
150
+ failures.push(error);
151
+ }
152
+ try {
153
+ await outbox?.stop();
154
+ } catch (error) {
155
+ failures.push(error);
156
+ }
157
+ if (failures.length)
158
+ throw new AggregateError(failures, 'Docket shutdown failed');
159
+ });
160
+ void upload?.stop();
161
+ return stopped;
162
+ },
163
+ });
164
+ }
165
+
166
+ exports.createDocket = createDocket;
167
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/client/constants.js","../../src/client/index.js"],"sourcesContent":["export const CLIENT_DEFAULTS = Object.freeze({\n MAX_HISTORY_RECORDS: 1000,\n MAX_BATCH_RECORDS: 100,\n INTERVAL_MS: 5000,\n});\n\nexport const HISTORY_METHODS = Object.freeze({\n REQUIRED: Object.freeze(['write', 'query', 'clear']),\n OPTIONAL: Object.freeze(['flush', 'stop', 'getStatus']),\n});\n","import { createLogging } from '../core/hub.js';\nimport { createMemoryHistory } from '../history/index.js';\nimport { createUploadSink } from '../upload/index.js';\nimport { CLIENT_DEFAULTS, HISTORY_METHODS } from './constants.js';\n\nfunction resolveHistory(history) {\n if (history === false) return undefined;\n if (history === undefined)\n return createMemoryHistory({\n maxRecords: CLIENT_DEFAULTS.MAX_HISTORY_RECORDS,\n });\n if (!history || typeof history !== 'object')\n throw new TypeError('Invalid history options');\n if (\n !HISTORY_METHODS.REQUIRED.some((method) => method in history) &&\n !HISTORY_METHODS.OPTIONAL.some((method) => method in history)\n )\n return createMemoryHistory(history);\n if (\n HISTORY_METHODS.REQUIRED.some(\n (method) => typeof history[method] !== 'function',\n )\n )\n throw new TypeError('A history client requires write, query, and clear');\n for (const method of HISTORY_METHODS.OPTIONAL)\n if (history[method] !== undefined && typeof history[method] !== 'function')\n throw new TypeError(`Invalid history ${method}`);\n return history;\n}\n\nexport function createDocket(options) {\n if (!options || typeof options !== 'object')\n throw new TypeError('Docket options are required');\n const {\n areas,\n redactor,\n sinks: suppliedSinks,\n context,\n levelStorage,\n maxOverrideMs,\n stormLimit,\n scheduler,\n now,\n monotonicNow,\n createRunId,\n onError,\n history: historyOption,\n upload: uploadOption,\n isActive: isApplicationActive,\n } = options;\n const history = resolveHistory(historyOption);\n let upload;\n let uploadOptions;\n let outbox;\n if (uploadOption !== undefined && uploadOption !== false) {\n if (!uploadOption || typeof uploadOption !== 'object')\n throw new TypeError('Invalid upload options');\n outbox = uploadOption.outbox;\n if (\n !outbox ||\n outbox === history ||\n typeof outbox.clear !== 'function' ||\n typeof outbox.stop !== 'function'\n )\n throw new TypeError('Upload requires a separate outbox client');\n const {\n maxBatchRecords = CLIENT_DEFAULTS.MAX_BATCH_RECORDS,\n intervalMs = CLIENT_DEFAULTS.INTERVAL_MS,\n scheduler,\n onError,\n send,\n } = uploadOption;\n if (typeof send !== 'function')\n throw new TypeError('An upload callback is required');\n uploadOptions = {\n maxBatchRecords,\n intervalMs,\n scheduler,\n onError,\n send: (records, signal, token) =>\n send.call(uploadOption, records, signal, token),\n };\n }\n const sinks = [...(suppliedSinks ?? [])];\n if (history) sinks.push(history);\n for (const sink of sinks)\n if (!sink || typeof sink.write !== 'function')\n throw new TypeError('A sink must have write');\n let closed = false;\n const logging = createLogging({\n areas,\n redactor,\n context,\n levelStorage,\n maxOverrideMs,\n stormLimit,\n scheduler,\n now,\n monotonicNow,\n createRunId: createRunId ? () => createRunId.call(options) : createRunId,\n onError,\n isActive() {\n if (closed) return false;\n const active = isApplicationActive?.call(options);\n return !closed && active !== false;\n },\n sinks: [],\n });\n const detachments = [];\n try {\n if (uploadOptions) upload = createUploadSink(uploadOptions, outbox);\n if (upload) sinks.push(upload);\n for (const sink of sinks) detachments.push(logging.addSink(sink));\n } catch (error) {\n for (const detach of detachments) detach();\n void upload?.stop();\n void logging.stop().catch(() => {});\n throw error;\n }\n let stopped;\n return Object.freeze({\n ...logging,\n history,\n upload,\n outbox,\n stop() {\n if (stopped) return stopped;\n closed = true;\n stopped = Promise.resolve().then(async () => {\n const failures = [];\n try {\n await logging.stop();\n } catch (error) {\n failures.push(error);\n }\n try {\n await outbox?.stop();\n } catch (error) {\n failures.push(error);\n }\n if (failures.length)\n throw new AggregateError(failures, 'Docket shutdown failed');\n });\n void upload?.stop();\n return stopped;\n },\n });\n}\n"],"names":["createMemoryHistory","createLogging","createUploadSink"],"mappings":";;;;;;;;;;AAAO,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7C,EAAE,mBAAmB,EAAE,IAAI;AAC3B,EAAE,iBAAiB,EAAE,GAAG;AACxB,EAAE,WAAW,EAAE,IAAI;AACnB,CAAC,CAAC;;AAEK,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7C,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACtD,EAAE,QAAQ,EAAE,MAAM,C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C,MAAM;AAC3B,UAAU,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,wBAAwB,CAAC;AACtE,MAAM,CAAC,CAAC;AACR,MAAM,KAAK,MAAM,EAAE,IAAI,EAAE;AACzB,MAAM,OAAO,OAAO;AACpB,IAAI,CAAC;AACL,GAAG,CAAC;AACJ;;"}
@@ -0,0 +1,40 @@
1
+ import type { MemoryHistoryOptions } from "../history/index.cjs";
2
+ import type { Logging, LoggingOptions, LogSink, LogSource } from "../index.cjs";
3
+ import type {
4
+ UploadOutbox,
5
+ UploadSink,
6
+ UploadSinkOptions,
7
+ } from "../upload/index.cjs";
8
+
9
+ export type HistoryClient = LogSink &
10
+ LogSource &
11
+ Readonly<{
12
+ clear(): void | Promise<void>;
13
+ }>;
14
+ export type OutboxClient = UploadOutbox &
15
+ Readonly<{
16
+ clear(): Promise<void>;
17
+ stop(): Promise<void>;
18
+ }>;
19
+ export type DocketUploadOptions = Readonly<{
20
+ outbox: OutboxClient;
21
+ send: UploadSinkOptions['send'];
22
+ maxBatchRecords?: number;
23
+ intervalMs?: number;
24
+ scheduler?: UploadSinkOptions['scheduler'];
25
+ onError?: UploadSinkOptions['onError'];
26
+ }>;
27
+ export type DocketOptions<TArea extends string> = LoggingOptions<TArea> &
28
+ Readonly<{
29
+ history?: false | MemoryHistoryOptions | HistoryClient;
30
+ upload?: false | DocketUploadOptions;
31
+ }>;
32
+ export type Docket<TArea extends string> = Logging<TArea> &
33
+ Readonly<{
34
+ history: HistoryClient | undefined;
35
+ upload: UploadSink | undefined;
36
+ outbox: OutboxClient | undefined;
37
+ }>;
38
+ export declare function createDocket<TArea extends string>(
39
+ options: DocketOptions<TArea>,
40
+ ): Docket<TArea>;
@@ -0,0 +1,40 @@
1
+ import type { MemoryHistoryOptions } from '../history/index.js';
2
+ import type { Logging, LoggingOptions, LogSink, LogSource } from '../index.js';
3
+ import type {
4
+ UploadOutbox,
5
+ UploadSink,
6
+ UploadSinkOptions,
7
+ } from '../upload/index.js';
8
+
9
+ export type HistoryClient = LogSink &
10
+ LogSource &
11
+ Readonly<{
12
+ clear(): void | Promise<void>;
13
+ }>;
14
+ export type OutboxClient = UploadOutbox &
15
+ Readonly<{
16
+ clear(): Promise<void>;
17
+ stop(): Promise<void>;
18
+ }>;
19
+ export type DocketUploadOptions = Readonly<{
20
+ outbox: OutboxClient;
21
+ send: UploadSinkOptions['send'];
22
+ maxBatchRecords?: number;
23
+ intervalMs?: number;
24
+ scheduler?: UploadSinkOptions['scheduler'];
25
+ onError?: UploadSinkOptions['onError'];
26
+ }>;
27
+ export type DocketOptions<TArea extends string> = LoggingOptions<TArea> &
28
+ Readonly<{
29
+ history?: false | MemoryHistoryOptions | HistoryClient;
30
+ upload?: false | DocketUploadOptions;
31
+ }>;
32
+ export type Docket<TArea extends string> = Logging<TArea> &
33
+ Readonly<{
34
+ history: HistoryClient | undefined;
35
+ upload: UploadSink | undefined;
36
+ outbox: OutboxClient | undefined;
37
+ }>;
38
+ export declare function createDocket<TArea extends string>(
39
+ options: DocketOptions<TArea>,
40
+ ): Docket<TArea>;
@@ -0,0 +1,165 @@
1
+ import { c as createLogging } from '../chunk-DkvWLziD.js';
2
+ import { createMemoryHistory } from '../history/index.js';
3
+ import { createUploadSink } from '../upload/index.js';
4
+ import '../chunk-LRCHwVuE.js';
5
+ import '../chunk-CSS3f4_M.js';
6
+ import '../chunk-7ld72rnl.js';
7
+ import '@bazariodev/coordination';
8
+
9
+ const CLIENT_DEFAULTS = Object.freeze({
10
+ MAX_HISTORY_RECORDS: 1000,
11
+ MAX_BATCH_RECORDS: 100,
12
+ INTERVAL_MS: 5000,
13
+ });
14
+
15
+ const HISTORY_METHODS = Object.freeze({
16
+ REQUIRED: Object.freeze(['write', 'query', 'clear']),
17
+ OPTIONAL: Object.freeze(['flush', 'stop', 'getStatus']),
18
+ });
19
+
20
+ function resolveHistory(history) {
21
+ if (history === false) return undefined;
22
+ if (history === undefined)
23
+ return createMemoryHistory({
24
+ maxRecords: CLIENT_DEFAULTS.MAX_HISTORY_RECORDS,
25
+ });
26
+ if (!history || typeof history !== 'object')
27
+ throw new TypeError('Invalid history options');
28
+ if (
29
+ !HISTORY_METHODS.REQUIRED.some((method) => method in history) &&
30
+ !HISTORY_METHODS.OPTIONAL.some((method) => method in history)
31
+ )
32
+ return createMemoryHistory(history);
33
+ if (
34
+ HISTORY_METHODS.REQUIRED.some(
35
+ (method) => typeof history[method] !== 'function',
36
+ )
37
+ )
38
+ throw new TypeError('A history client requires write, query, and clear');
39
+ for (const method of HISTORY_METHODS.OPTIONAL)
40
+ if (history[method] !== undefined && typeof history[method] !== 'function')
41
+ throw new TypeError(`Invalid history ${method}`);
42
+ return history;
43
+ }
44
+
45
+ function createDocket(options) {
46
+ if (!options || typeof options !== 'object')
47
+ throw new TypeError('Docket options are required');
48
+ const {
49
+ areas,
50
+ redactor,
51
+ sinks: suppliedSinks,
52
+ context,
53
+ levelStorage,
54
+ maxOverrideMs,
55
+ stormLimit,
56
+ scheduler,
57
+ now,
58
+ monotonicNow,
59
+ createRunId,
60
+ onError,
61
+ history: historyOption,
62
+ upload: uploadOption,
63
+ isActive: isApplicationActive,
64
+ } = options;
65
+ const history = resolveHistory(historyOption);
66
+ let upload;
67
+ let uploadOptions;
68
+ let outbox;
69
+ if (uploadOption !== undefined && uploadOption !== false) {
70
+ if (!uploadOption || typeof uploadOption !== 'object')
71
+ throw new TypeError('Invalid upload options');
72
+ outbox = uploadOption.outbox;
73
+ if (
74
+ !outbox ||
75
+ outbox === history ||
76
+ typeof outbox.clear !== 'function' ||
77
+ typeof outbox.stop !== 'function'
78
+ )
79
+ throw new TypeError('Upload requires a separate outbox client');
80
+ const {
81
+ maxBatchRecords = CLIENT_DEFAULTS.MAX_BATCH_RECORDS,
82
+ intervalMs = CLIENT_DEFAULTS.INTERVAL_MS,
83
+ scheduler,
84
+ onError,
85
+ send,
86
+ } = uploadOption;
87
+ if (typeof send !== 'function')
88
+ throw new TypeError('An upload callback is required');
89
+ uploadOptions = {
90
+ maxBatchRecords,
91
+ intervalMs,
92
+ scheduler,
93
+ onError,
94
+ send: (records, signal, token) =>
95
+ send.call(uploadOption, records, signal, token),
96
+ };
97
+ }
98
+ const sinks = [...(suppliedSinks ?? [])];
99
+ if (history) sinks.push(history);
100
+ for (const sink of sinks)
101
+ if (!sink || typeof sink.write !== 'function')
102
+ throw new TypeError('A sink must have write');
103
+ let closed = false;
104
+ const logging = createLogging({
105
+ areas,
106
+ redactor,
107
+ context,
108
+ levelStorage,
109
+ maxOverrideMs,
110
+ stormLimit,
111
+ scheduler,
112
+ now,
113
+ monotonicNow,
114
+ createRunId: createRunId ? () => createRunId.call(options) : createRunId,
115
+ onError,
116
+ isActive() {
117
+ if (closed) return false;
118
+ const active = isApplicationActive?.call(options);
119
+ return !closed && active !== false;
120
+ },
121
+ sinks: [],
122
+ });
123
+ const detachments = [];
124
+ try {
125
+ if (uploadOptions) upload = createUploadSink(uploadOptions, outbox);
126
+ if (upload) sinks.push(upload);
127
+ for (const sink of sinks) detachments.push(logging.addSink(sink));
128
+ } catch (error) {
129
+ for (const detach of detachments) detach();
130
+ void upload?.stop();
131
+ void logging.stop().catch(() => {});
132
+ throw error;
133
+ }
134
+ let stopped;
135
+ return Object.freeze({
136
+ ...logging,
137
+ history,
138
+ upload,
139
+ outbox,
140
+ stop() {
141
+ if (stopped) return stopped;
142
+ closed = true;
143
+ stopped = Promise.resolve().then(async () => {
144
+ const failures = [];
145
+ try {
146
+ await logging.stop();
147
+ } catch (error) {
148
+ failures.push(error);
149
+ }
150
+ try {
151
+ await outbox?.stop();
152
+ } catch (error) {
153
+ failures.push(error);
154
+ }
155
+ if (failures.length)
156
+ throw new AggregateError(failures, 'Docket shutdown failed');
157
+ });
158
+ void upload?.stop();
159
+ return stopped;
160
+ },
161
+ });
162
+ }
163
+
164
+ export { createDocket };
165
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/client/constants.js","../../src/client/index.js"],"sourcesContent":["export const CLIENT_DEFAULTS = Object.freeze({\n MAX_HISTORY_RECORDS: 1000,\n MAX_BATCH_RECORDS: 100,\n INTERVAL_MS: 5000,\n});\n\nexport const HISTORY_METHODS = Object.freeze({\n REQUIRED: Object.freeze(['write', 'query', 'clear']),\n OPTIONAL: Object.freeze(['flush', 'stop', 'getStatus']),\n});\n","import { createLogging } from '../core/hub.js';\nimport { createMemoryHistory } from '../history/index.js';\nimport { createUploadSink } from '../upload/index.js';\nimport { CLIENT_DEFAULTS, HISTORY_METHODS } from './constants.js';\n\nfunction resolveHistory(history) {\n if (history === false) return undefined;\n if (history === undefined)\n return createMemoryHistory({\n maxRecords: CLIENT_DEFAULTS.MAX_HISTORY_RECORDS,\n });\n if (!history || typeof history !== 'object')\n throw new TypeError('Invalid history options');\n if (\n !HISTORY_METHODS.REQUIRED.some((method) => method in history) &&\n !HISTORY_METHODS.OPTIONAL.some((method) => method in history)\n )\n return createMemoryHistory(history);\n if (\n HISTORY_METHODS.REQUIRED.some(\n (method) => typeof history[method] !== 'function',\n )\n )\n throw new TypeError('A history client requires write, query, and clear');\n for (const method of HISTORY_METHODS.OPTIONAL)\n if (history[method] !== undefined && typeof history[method] !== 'function')\n throw new TypeError(`Invalid history ${method}`);\n return history;\n}\n\nexport function createDocket(options) {\n if (!options || typeof options !== 'object')\n throw new TypeError('Docket options are required');\n const {\n areas,\n redactor,\n sinks: suppliedSinks,\n context,\n levelStorage,\n maxOverrideMs,\n stormLimit,\n scheduler,\n now,\n monotonicNow,\n createRunId,\n onError,\n history: historyOption,\n upload: uploadOption,\n isActive: isApplicationActive,\n } = options;\n const history = resolveHistory(historyOption);\n let upload;\n let uploadOptions;\n let outbox;\n if (uploadOption !== undefined && uploadOption !== false) {\n if (!uploadOption || typeof uploadOption !== 'object')\n throw new TypeError('Invalid upload options');\n outbox = uploadOption.outbox;\n if (\n !outbox ||\n outbox === history ||\n typeof outbox.clear !== 'function' ||\n typeof outbox.stop !== 'function'\n )\n throw new TypeError('Upload requires a separate outbox client');\n const {\n maxBatchRecords = CLIENT_DEFAULTS.MAX_BATCH_RECORDS,\n intervalMs = CLIENT_DEFAULTS.INTERVAL_MS,\n scheduler,\n onError,\n send,\n } = uploadOption;\n if (typeof send !== 'function')\n throw new TypeError('An upload callback is required');\n uploadOptions = {\n maxBatchRecords,\n intervalMs,\n scheduler,\n onError,\n send: (records, signal, token) =>\n send.call(uploadOption, records, signal, token),\n };\n }\n const sinks = [...(suppliedSinks ?? [])];\n if (history) sinks.push(history);\n for (const sink of sinks)\n if (!sink || typeof sink.write !== 'function')\n throw new TypeError('A sink must have write');\n let closed = false;\n const logging = createLogging({\n areas,\n redactor,\n context,\n levelStorage,\n maxOverrideMs,\n stormLimit,\n scheduler,\n now,\n monotonicNow,\n createRunId: createRunId ? () => createRunId.call(options) : createRunId,\n onError,\n isActive() {\n if (closed) return false;\n const active = isApplicationActive?.call(options);\n return !closed && active !== false;\n },\n sinks: [],\n });\n const detachments = [];\n try {\n if (uploadOptions) upload = createUploadSink(uploadOptions, outbox);\n if (upload) sinks.push(upload);\n for (const sink of sinks) detachments.push(logging.addSink(sink));\n } catch (error) {\n for (const detach of detachments) detach();\n void upload?.stop();\n void logging.stop().catch(() => {});\n throw error;\n }\n let stopped;\n return Object.freeze({\n ...logging,\n history,\n upload,\n outbox,\n stop() {\n if (stopped) return stopped;\n closed = true;\n stopped = Promise.resolve().then(async () => {\n const failures = [];\n try {\n await logging.stop();\n } catch (error) {\n failures.push(error);\n }\n try {\n await outbox?.stop();\n } catch (error) {\n failures.push(error);\n }\n if (failures.length)\n throw new AggregateError(failures, 'Docket shutdown failed');\n });\n void upload?.stop();\n return stopped;\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;AAAO,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7C,EAAE,mBAAmB,EAAE,IAAI;AAC3B,EAAE,iBAAiB,EAAE,GAAG;AACxB,EAAE,WAAW,EAAE,IAAI;AACnB,CAA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AI;AACZ,UAAU,MAAM,MAAM,EAAE,IAAI,EAAE;AAC9B,QAAQ,CAAC,CAAC,OAAO,KAAK,EAAE;AACxB,UAAU,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;AAC9B,QAAQ;AACR,QAAQ,IAAI,QAAQ,CAAC,MAAM;AAC3B,UAAU,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,wBAAwB,CAAC;AACtE,MAAM,CAAC,CAAC;AACR,MAAM,KAAK,MAAM,EAAE,IAAI,EAAE;AACzB,MAAM,OAAO,OAAO;AACpB,IAAI,CAAC;AACL,GAAG,CAAC;AACJ;;"}
@@ -0,0 +1,4 @@
1
+ export { ENVIRONMENT_FIELDS } from "./browser/constants.cjs";
2
+ export { UPLOAD_STORAGE_MODES } from "./upload/constants.cjs";
3
+ export { LEVELS, LIMITS, LOGGING_ERROR_CODES, LOGGING_ERROR_SOURCES, MARKERS } from "./core/constants.cjs";
4
+ export { OVERFLOW_STRATEGIES, STORE_MODES } from "./storage/constants.cjs";
@@ -0,0 +1,4 @@
1
+ export { ENVIRONMENT_FIELDS } from "./browser/constants.js";
2
+ export { UPLOAD_STORAGE_MODES } from "./upload/constants.js";
3
+ export { LEVELS, LIMITS, LOGGING_ERROR_CODES, LOGGING_ERROR_SOURCES, MARKERS } from "./core/constants.js";
4
+ export { OVERFLOW_STRATEGIES, STORE_MODES } from "./storage/constants.js";
@@ -0,0 +1,43 @@
1
+ export const LEVELS: Readonly<{
2
+ DEBUG: "debug";
3
+ INFO: "info";
4
+ WARN: "warn";
5
+ ERROR: "error";
6
+ }>;
7
+ export const LOGGING_LIMITS: Readonly<{
8
+ ROOT_LOGGER_CACHE_PAIRS: 1000;
9
+ STORM_SCOPE_PAIRS: 1000;
10
+ STORM_WINDOW_MS: 1000;
11
+ STORM_SUMMARY_DELAY_MS: 1000;
12
+ DEFAULT_LEVEL_OVERRIDE_MS: 86400000;
13
+ MAX_TIMER_DELAY_MS: 2147483647;
14
+ DEFAULT_STORM_LIMIT: 100;
15
+ }>;
16
+ export const LOGGING_ERROR_CODES: Readonly<{
17
+ RECURSIVE_LOGGING: "recursive-logging";
18
+ ROOT_LOGGER_CACHE_LIMIT: "root-logger-cache-limit";
19
+ STOPPED: "stopped";
20
+ }>;
21
+ export const LOGGING_ERROR_SOURCES: Readonly<{
22
+ DATA: "data";
23
+ REDACTOR: "redactor";
24
+ SINK: "sink";
25
+ STORAGE: "storage";
26
+ SCOPE: "scope";
27
+ REENTRY: "reentry";
28
+ }>;
29
+ export const LIMITS: Readonly<{
30
+ maxDepth: 6;
31
+ maxStringLength: 16384;
32
+ maxArrayLength: 100;
33
+ maxKeys: 100;
34
+ maxNodes: 1000;
35
+ maxRecordSize: 65536;
36
+ }>;
37
+ export const MARKERS: Readonly<{
38
+ LIMIT: "[truncated]";
39
+ CYCLE: "[circular]";
40
+ ACCESSOR: "[accessor]";
41
+ UNSUPPORTED: "[unsupported]";
42
+ MASK: "[redacted]";
43
+ }>;
@@ -0,0 +1,43 @@
1
+ export const LEVELS: Readonly<{
2
+ DEBUG: "debug";
3
+ INFO: "info";
4
+ WARN: "warn";
5
+ ERROR: "error";
6
+ }>;
7
+ export const LOGGING_LIMITS: Readonly<{
8
+ ROOT_LOGGER_CACHE_PAIRS: 1000;
9
+ STORM_SCOPE_PAIRS: 1000;
10
+ STORM_WINDOW_MS: 1000;
11
+ STORM_SUMMARY_DELAY_MS: 1000;
12
+ DEFAULT_LEVEL_OVERRIDE_MS: 86400000;
13
+ MAX_TIMER_DELAY_MS: 2147483647;
14
+ DEFAULT_STORM_LIMIT: 100;
15
+ }>;
16
+ export const LOGGING_ERROR_CODES: Readonly<{
17
+ RECURSIVE_LOGGING: "recursive-logging";
18
+ ROOT_LOGGER_CACHE_LIMIT: "root-logger-cache-limit";
19
+ STOPPED: "stopped";
20
+ }>;
21
+ export const LOGGING_ERROR_SOURCES: Readonly<{
22
+ DATA: "data";
23
+ REDACTOR: "redactor";
24
+ SINK: "sink";
25
+ STORAGE: "storage";
26
+ SCOPE: "scope";
27
+ REENTRY: "reentry";
28
+ }>;
29
+ export const LIMITS: Readonly<{
30
+ maxDepth: 6;
31
+ maxStringLength: 16384;
32
+ maxArrayLength: 100;
33
+ maxKeys: 100;
34
+ maxNodes: 1000;
35
+ maxRecordSize: 65536;
36
+ }>;
37
+ export const MARKERS: Readonly<{
38
+ LIMIT: "[truncated]";
39
+ CYCLE: "[circular]";
40
+ ACCESSOR: "[accessor]";
41
+ UNSUPPORTED: "[unsupported]";
42
+ MASK: "[redacted]";
43
+ }>;
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ function installConsoleApi({
4
+ logging,
5
+ clear,
6
+ exportBundle,
7
+ name = '__LOGGING__',
8
+ target = globalThis,
9
+ }) {
10
+ if (typeof name !== 'string' || !name || name in target)
11
+ throw new TypeError('Console API name is unavailable');
12
+ const api = Object.freeze({
13
+ levels: () => logging.getLevels(),
14
+ setLevel: (...args) => logging.setLevel(...args),
15
+ resetLevel: (area) => logging.resetLevel(area),
16
+ export: async () =>
17
+ exportBundle
18
+ ? exportBundle()
19
+ : Promise.reject(new Error('Export is not configured')),
20
+ clear: async () =>
21
+ clear ? clear() : Promise.reject(new Error('Clear is not configured')),
22
+ help: () =>
23
+ 'levels(), setLevel(area, level, { durationMs }), resetLevel(area?), export(), clear()',
24
+ });
25
+ Object.defineProperty(target, name, {
26
+ value: api,
27
+ configurable: true,
28
+ writable: true,
29
+ });
30
+ return () => {
31
+ if (Object.getOwnPropertyDescriptor(target, name)?.value === api)
32
+ delete target[name];
33
+ };
34
+ }
35
+
36
+ exports.installConsoleApi = installConsoleApi;
37
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/devtools/index.js"],"sourcesContent":["export function installConsoleApi({\n logging,\n clear,\n exportBundle,\n name = '__LOGGING__',\n target = globalThis,\n}) {\n if (typeof name !== 'string' || !name || name in target)\n throw new TypeError('Console API name is unavailable');\n const api = Object.freeze({\n levels: () => logging.getLevels(),\n setLevel: (...args) => logging.setLevel(...args),\n resetLevel: (area) => logging.resetLevel(area),\n export: async () =>\n exportBundle\n ? exportBundle()\n : Promise.reject(new Error('Export is not configured')),\n clear: async () =>\n clear ? clear() : Promise.reject(new Error('Clear is not configured')),\n help: () =>\n 'levels(), setLevel(area, level, { durationMs }), resetLevel(area?), export(), clear()',\n });\n Object.defineProperty(target, name, {\n value: api,\n configurable: true,\n writable: true,\n });\n return () => {\n if (Object.getOwnPropertyDescriptor(target, name)?.value === api)\n delete target[name];\n };\n}\n"],"names":[],"mappings":";;AAAO,SAAS,iBAAiB,CAAC;AAClC,EAAE,OAAO;AACT,EAAE,KAAK;AACP,EAAE,YAAY;AACd,EAAE,IAAI,GAAG,aAAa;AACtB,EAAE,MAAM,GAAG,UAAU;AACrB,CAAC,EAAE;AACH,EAAE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM;AACzD,IAAI,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC;AAC1D,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,EAAE,MAAM,OAAO,CAAC,SAAS,EAAE;AACrC,IAAI,QAAQ,EAAE,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;AACpD,IAAI,UAAU,EAAE,CAAC,IAAI,KAAK,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;AAClD,IAAI,MAAM,EAAE;AACZ,MAAM;AACN,UAAU,YAAY;AACtB,UAAU,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAC/D,IAAI,KAAK,EAAE;AACX,MAAM,KAAK,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC5E,IAAI,IAAI,EAAE;AACV,MAAM,uFAAuF;AAC7F,GAAG,CAAC;AACJ,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE;AACtC,IAAI,KAAK,EAAE,GAAG;AACd,IAAI,YAAY,EAAE,IAAI;AACtB,IAAI,QAAQ,EAAE,IAAI;AAClB,GAAG,CAAC;AACJ,EAAE,OAAO,MAAM;AACf,IAAI,IAAI,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,KAAK,GAAG;AACpE,MAAM,OAAO,MAAM,CAAC,IAAI,CAAC;AACzB,EAAE,CAAC;AACH;;"}
@@ -0,0 +1,11 @@
1
+ import type { Logging } from "../index.cjs";
2
+
3
+ export declare function installConsoleApi<TArea extends string>(
4
+ options: Readonly<{
5
+ logging: Pick<Logging<TArea>, 'getLevels' | 'setLevel' | 'resetLevel'>;
6
+ clear?: () => Promise<unknown>;
7
+ exportBundle?: () => Promise<void>;
8
+ name?: string;
9
+ target?: object;
10
+ }>,
11
+ ): () => void;
@@ -0,0 +1,11 @@
1
+ import type { Logging } from '../index.js';
2
+
3
+ export declare function installConsoleApi<TArea extends string>(
4
+ options: Readonly<{
5
+ logging: Pick<Logging<TArea>, 'getLevels' | 'setLevel' | 'resetLevel'>;
6
+ clear?: () => Promise<unknown>;
7
+ exportBundle?: () => Promise<void>;
8
+ name?: string;
9
+ target?: object;
10
+ }>,
11
+ ): () => void;
@@ -0,0 +1,35 @@
1
+ function installConsoleApi({
2
+ logging,
3
+ clear,
4
+ exportBundle,
5
+ name = '__LOGGING__',
6
+ target = globalThis,
7
+ }) {
8
+ if (typeof name !== 'string' || !name || name in target)
9
+ throw new TypeError('Console API name is unavailable');
10
+ const api = Object.freeze({
11
+ levels: () => logging.getLevels(),
12
+ setLevel: (...args) => logging.setLevel(...args),
13
+ resetLevel: (area) => logging.resetLevel(area),
14
+ export: async () =>
15
+ exportBundle
16
+ ? exportBundle()
17
+ : Promise.reject(new Error('Export is not configured')),
18
+ clear: async () =>
19
+ clear ? clear() : Promise.reject(new Error('Clear is not configured')),
20
+ help: () =>
21
+ 'levels(), setLevel(area, level, { durationMs }), resetLevel(area?), export(), clear()',
22
+ });
23
+ Object.defineProperty(target, name, {
24
+ value: api,
25
+ configurable: true,
26
+ writable: true,
27
+ });
28
+ return () => {
29
+ if (Object.getOwnPropertyDescriptor(target, name)?.value === api)
30
+ delete target[name];
31
+ };
32
+ }
33
+
34
+ export { installConsoleApi };
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/devtools/index.js"],"sourcesContent":["export function installConsoleApi({\n logging,\n clear,\n exportBundle,\n name = '__LOGGING__',\n target = globalThis,\n}) {\n if (typeof name !== 'string' || !name || name in target)\n throw new TypeError('Console API name is unavailable');\n const api = Object.freeze({\n levels: () => logging.getLevels(),\n setLevel: (...args) => logging.setLevel(...args),\n resetLevel: (area) => logging.resetLevel(area),\n export: async () =>\n exportBundle\n ? exportBundle()\n : Promise.reject(new Error('Export is not configured')),\n clear: async () =>\n clear ? clear() : Promise.reject(new Error('Clear is not configured')),\n help: () =>\n 'levels(), setLevel(area, level, { durationMs }), resetLevel(area?), export(), clear()',\n });\n Object.defineProperty(target, name, {\n value: api,\n configurable: true,\n writable: true,\n });\n return () => {\n if (Object.getOwnPropertyDescriptor(target, name)?.value === api)\n delete target[name];\n };\n}\n"],"names":[],"mappings":"AAAO,SAAS,iBAAiB,CAAC;AAClC,EAAE,OAAO;AACT,EAAE,KAAK;AACP,EAAE,YAAY;AACd,EAAE,IAAI,GAAG,aAAa;AACtB,EAAE,MAAM,GAAG,UAAU;AACrB,CAAC,EAAE;AACH,EAAE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM;AACzD,IAAI,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC;AAC1D,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;AAC5B,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