@infinitetoken/lumber-kit 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -11
- package/contract/README.md +21 -0
- package/contract/schema.json +2317 -0
- package/contract/vectors.json +180 -0
- package/dist/index.d.mts +116 -44
- package/dist/index.d.ts +116 -44
- package/dist/index.js +73 -7
- package/dist/index.mjs +64 -7
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -22,12 +22,16 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
APP_COLORS: () => APP_COLORS,
|
|
24
24
|
DEFAULT_ACCENT: () => DEFAULT_ACCENT,
|
|
25
|
+
DEFAULT_API_ENDPOINT: () => DEFAULT_API_ENDPOINT,
|
|
25
26
|
DEFAULT_PUSH_THRESHOLD: () => DEFAULT_PUSH_THRESHOLD,
|
|
27
|
+
DEFAULT_TIME_FORMAT: () => DEFAULT_TIME_FORMAT,
|
|
28
|
+
LOG_KEY_VERSION: () => LOG_KEY_VERSION,
|
|
26
29
|
LogLevel: () => LogLevel,
|
|
27
30
|
PUSH_OFF: () => PUSH_OFF,
|
|
28
31
|
SubscriptionLevel: () => SubscriptionLevel,
|
|
29
32
|
apiErrorCodeOf: () => apiErrorCodeOf,
|
|
30
33
|
apiErrorCodes: () => apiErrorCodes,
|
|
34
|
+
buildLogPayload: () => buildLogPayload,
|
|
31
35
|
isApiErrorCode: () => isApiErrorCode,
|
|
32
36
|
isValidAppearance: () => isValidAppearance,
|
|
33
37
|
isValidColor: () => isValidColor,
|
|
@@ -36,13 +40,18 @@ __export(index_exports, {
|
|
|
36
40
|
isValidLogLevel: () => isValidLogLevel,
|
|
37
41
|
isValidSubscriptionLevel: () => isValidSubscriptionLevel,
|
|
38
42
|
isValidTeamMemberRole: () => isValidTeamMemberRole,
|
|
43
|
+
isValidTimeFormat: () => isValidTimeFormat,
|
|
39
44
|
joinApiKey: () => joinApiKey,
|
|
45
|
+
logDelivery: () => logDelivery,
|
|
46
|
+
logDeliveryOutcome: () => logDeliveryOutcome,
|
|
40
47
|
logLevelColors: () => logLevelColors,
|
|
41
48
|
logLevelNameToLevel: () => logLevelNameToLevel,
|
|
42
49
|
logLevelToName: () => logLevelToName,
|
|
43
50
|
logLevels: () => logLevels,
|
|
51
|
+
logRetryDelayMs: () => logRetryDelayMs,
|
|
44
52
|
nameColor: () => nameColor,
|
|
45
53
|
normalizePushThreshold: () => normalizePushThreshold,
|
|
54
|
+
normalizeTimeFormat: () => normalizeTimeFormat,
|
|
46
55
|
parsePushData: () => parsePushData,
|
|
47
56
|
personColor: () => personColor,
|
|
48
57
|
resolveAppColor: () => resolveAppColor,
|
|
@@ -55,13 +64,13 @@ __export(index_exports, {
|
|
|
55
64
|
module.exports = __toCommonJS(index_exports);
|
|
56
65
|
|
|
57
66
|
// src/constants/logLevel.ts
|
|
58
|
-
var LogLevel = /* @__PURE__ */ ((
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return
|
|
67
|
+
var LogLevel = /* @__PURE__ */ ((LogLevel3) => {
|
|
68
|
+
LogLevel3[LogLevel3["Debug"] = 0] = "Debug";
|
|
69
|
+
LogLevel3[LogLevel3["Info"] = 1] = "Info";
|
|
70
|
+
LogLevel3[LogLevel3["Warn"] = 2] = "Warn";
|
|
71
|
+
LogLevel3[LogLevel3["Error"] = 3] = "Error";
|
|
72
|
+
LogLevel3[LogLevel3["Fatal"] = 4] = "Fatal";
|
|
73
|
+
return LogLevel3;
|
|
65
74
|
})(LogLevel || {});
|
|
66
75
|
var logLevelToName = {
|
|
67
76
|
[0 /* Debug */]: "debug",
|
|
@@ -108,9 +117,20 @@ var apiErrorCodes = [
|
|
|
108
117
|
"HAS_ACCOUNT"
|
|
109
118
|
];
|
|
110
119
|
|
|
120
|
+
// src/constants/ingest.ts
|
|
121
|
+
var DEFAULT_API_ENDPOINT = "https://api.lumber.infinitetoken.com";
|
|
122
|
+
var LOG_KEY_VERSION = 1;
|
|
123
|
+
var logDelivery = {
|
|
124
|
+
maxAttempts: 5,
|
|
125
|
+
baseDelayMs: 1e3,
|
|
126
|
+
maxDelayMs: 3e4,
|
|
127
|
+
pauseMs: 60 * 60 * 1e3
|
|
128
|
+
};
|
|
129
|
+
|
|
111
130
|
// src/constants/notifications.ts
|
|
112
131
|
var PUSH_OFF = 5;
|
|
113
132
|
var DEFAULT_PUSH_THRESHOLD = 2 /* Warn */;
|
|
133
|
+
var DEFAULT_TIME_FORMAT = { clock: "24h", zone: "local" };
|
|
114
134
|
|
|
115
135
|
// src/constants/subscription.ts
|
|
116
136
|
var SubscriptionLevel = /* @__PURE__ */ ((SubscriptionLevel3) => {
|
|
@@ -140,9 +160,46 @@ var subscriptionPlans = {
|
|
|
140
160
|
[3 /* Enterprise */]: { name: "Enterprise", monthlyPrice: null }
|
|
141
161
|
};
|
|
142
162
|
|
|
163
|
+
// src/utils/ingest.ts
|
|
164
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
165
|
+
var buildLogPayload = (level, message, data, autoContext) => {
|
|
166
|
+
const { requestId, traceId, context: givenContext, metadata: givenMetadata, ...rest } = data ?? {};
|
|
167
|
+
const context = isRecord(givenContext) ? givenContext : void 0;
|
|
168
|
+
const metadata = isRecord(givenMetadata) ? givenMetadata : void 0;
|
|
169
|
+
if (givenContext != null && !context) rest.context = givenContext;
|
|
170
|
+
if (givenMetadata != null && !metadata) rest.metadata = givenMetadata;
|
|
171
|
+
const mergedMetadata = Object.keys(rest).length > 0 ? { ...rest, ...metadata ?? {} } : metadata;
|
|
172
|
+
const mergedContext = autoContext && Object.keys(autoContext).length > 0 ? { ...autoContext, ...context ?? {} } : context;
|
|
173
|
+
const payload = { level, message };
|
|
174
|
+
if (requestId !== void 0) payload.requestId = requestId;
|
|
175
|
+
if (traceId !== void 0) payload.traceId = traceId;
|
|
176
|
+
if (mergedContext !== void 0) payload.context = mergedContext;
|
|
177
|
+
if (mergedMetadata !== void 0) payload.metadata = mergedMetadata;
|
|
178
|
+
return payload;
|
|
179
|
+
};
|
|
180
|
+
var logDeliveryOutcome = (status) => {
|
|
181
|
+
if (status === null) return "retry";
|
|
182
|
+
if (status >= 200 && status < 300) return "sent";
|
|
183
|
+
if (status === 429) return "pause";
|
|
184
|
+
if (status >= 400 && status < 500) return "drop";
|
|
185
|
+
return "retry";
|
|
186
|
+
};
|
|
187
|
+
var logRetryDelayMs = (failedAttempts) => Math.min(logDelivery.baseDelayMs * 2 ** Math.max(0, failedAttempts - 1), logDelivery.maxDelayMs);
|
|
188
|
+
|
|
143
189
|
// src/utils/index.ts
|
|
144
190
|
var appearanceValues = ["system", "dark", "light"];
|
|
145
191
|
var isValidAppearance = (value) => appearanceValues.includes(value);
|
|
192
|
+
var timeClocks = ["24h", "12h"];
|
|
193
|
+
var timeZoneChoices = ["local", "utc"];
|
|
194
|
+
var isValidTimeFormat = (value) => {
|
|
195
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
196
|
+
const { clock, zone, ...rest } = value;
|
|
197
|
+
return timeClocks.includes(clock) && timeZoneChoices.includes(zone) && Object.keys(rest).length === 0;
|
|
198
|
+
};
|
|
199
|
+
var normalizeTimeFormat = (value) => {
|
|
200
|
+
const { clock, zone } = value && typeof value === "object" ? value : {};
|
|
201
|
+
return { clock: timeClocks.includes(clock) ? clock : DEFAULT_TIME_FORMAT.clock, zone: timeZoneChoices.includes(zone) ? zone : DEFAULT_TIME_FORMAT.zone };
|
|
202
|
+
};
|
|
146
203
|
var isValidColor = (value) => /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value);
|
|
147
204
|
var hashName = (name) => {
|
|
148
205
|
let hash = 2166136261;
|
|
@@ -215,12 +272,16 @@ var parsePushData = (data) => {
|
|
|
215
272
|
0 && (module.exports = {
|
|
216
273
|
APP_COLORS,
|
|
217
274
|
DEFAULT_ACCENT,
|
|
275
|
+
DEFAULT_API_ENDPOINT,
|
|
218
276
|
DEFAULT_PUSH_THRESHOLD,
|
|
277
|
+
DEFAULT_TIME_FORMAT,
|
|
278
|
+
LOG_KEY_VERSION,
|
|
219
279
|
LogLevel,
|
|
220
280
|
PUSH_OFF,
|
|
221
281
|
SubscriptionLevel,
|
|
222
282
|
apiErrorCodeOf,
|
|
223
283
|
apiErrorCodes,
|
|
284
|
+
buildLogPayload,
|
|
224
285
|
isApiErrorCode,
|
|
225
286
|
isValidAppearance,
|
|
226
287
|
isValidColor,
|
|
@@ -229,13 +290,18 @@ var parsePushData = (data) => {
|
|
|
229
290
|
isValidLogLevel,
|
|
230
291
|
isValidSubscriptionLevel,
|
|
231
292
|
isValidTeamMemberRole,
|
|
293
|
+
isValidTimeFormat,
|
|
232
294
|
joinApiKey,
|
|
295
|
+
logDelivery,
|
|
296
|
+
logDeliveryOutcome,
|
|
233
297
|
logLevelColors,
|
|
234
298
|
logLevelNameToLevel,
|
|
235
299
|
logLevelToName,
|
|
236
300
|
logLevels,
|
|
301
|
+
logRetryDelayMs,
|
|
237
302
|
nameColor,
|
|
238
303
|
normalizePushThreshold,
|
|
304
|
+
normalizeTimeFormat,
|
|
239
305
|
parsePushData,
|
|
240
306
|
personColor,
|
|
241
307
|
resolveAppColor,
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// src/constants/logLevel.ts
|
|
2
|
-
var LogLevel = /* @__PURE__ */ ((
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return
|
|
2
|
+
var LogLevel = /* @__PURE__ */ ((LogLevel3) => {
|
|
3
|
+
LogLevel3[LogLevel3["Debug"] = 0] = "Debug";
|
|
4
|
+
LogLevel3[LogLevel3["Info"] = 1] = "Info";
|
|
5
|
+
LogLevel3[LogLevel3["Warn"] = 2] = "Warn";
|
|
6
|
+
LogLevel3[LogLevel3["Error"] = 3] = "Error";
|
|
7
|
+
LogLevel3[LogLevel3["Fatal"] = 4] = "Fatal";
|
|
8
|
+
return LogLevel3;
|
|
9
9
|
})(LogLevel || {});
|
|
10
10
|
var logLevelToName = {
|
|
11
11
|
[0 /* Debug */]: "debug",
|
|
@@ -52,9 +52,20 @@ var apiErrorCodes = [
|
|
|
52
52
|
"HAS_ACCOUNT"
|
|
53
53
|
];
|
|
54
54
|
|
|
55
|
+
// src/constants/ingest.ts
|
|
56
|
+
var DEFAULT_API_ENDPOINT = "https://api.lumber.infinitetoken.com";
|
|
57
|
+
var LOG_KEY_VERSION = 1;
|
|
58
|
+
var logDelivery = {
|
|
59
|
+
maxAttempts: 5,
|
|
60
|
+
baseDelayMs: 1e3,
|
|
61
|
+
maxDelayMs: 3e4,
|
|
62
|
+
pauseMs: 60 * 60 * 1e3
|
|
63
|
+
};
|
|
64
|
+
|
|
55
65
|
// src/constants/notifications.ts
|
|
56
66
|
var PUSH_OFF = 5;
|
|
57
67
|
var DEFAULT_PUSH_THRESHOLD = 2 /* Warn */;
|
|
68
|
+
var DEFAULT_TIME_FORMAT = { clock: "24h", zone: "local" };
|
|
58
69
|
|
|
59
70
|
// src/constants/subscription.ts
|
|
60
71
|
var SubscriptionLevel = /* @__PURE__ */ ((SubscriptionLevel3) => {
|
|
@@ -84,9 +95,46 @@ var subscriptionPlans = {
|
|
|
84
95
|
[3 /* Enterprise */]: { name: "Enterprise", monthlyPrice: null }
|
|
85
96
|
};
|
|
86
97
|
|
|
98
|
+
// src/utils/ingest.ts
|
|
99
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
100
|
+
var buildLogPayload = (level, message, data, autoContext) => {
|
|
101
|
+
const { requestId, traceId, context: givenContext, metadata: givenMetadata, ...rest } = data ?? {};
|
|
102
|
+
const context = isRecord(givenContext) ? givenContext : void 0;
|
|
103
|
+
const metadata = isRecord(givenMetadata) ? givenMetadata : void 0;
|
|
104
|
+
if (givenContext != null && !context) rest.context = givenContext;
|
|
105
|
+
if (givenMetadata != null && !metadata) rest.metadata = givenMetadata;
|
|
106
|
+
const mergedMetadata = Object.keys(rest).length > 0 ? { ...rest, ...metadata ?? {} } : metadata;
|
|
107
|
+
const mergedContext = autoContext && Object.keys(autoContext).length > 0 ? { ...autoContext, ...context ?? {} } : context;
|
|
108
|
+
const payload = { level, message };
|
|
109
|
+
if (requestId !== void 0) payload.requestId = requestId;
|
|
110
|
+
if (traceId !== void 0) payload.traceId = traceId;
|
|
111
|
+
if (mergedContext !== void 0) payload.context = mergedContext;
|
|
112
|
+
if (mergedMetadata !== void 0) payload.metadata = mergedMetadata;
|
|
113
|
+
return payload;
|
|
114
|
+
};
|
|
115
|
+
var logDeliveryOutcome = (status) => {
|
|
116
|
+
if (status === null) return "retry";
|
|
117
|
+
if (status >= 200 && status < 300) return "sent";
|
|
118
|
+
if (status === 429) return "pause";
|
|
119
|
+
if (status >= 400 && status < 500) return "drop";
|
|
120
|
+
return "retry";
|
|
121
|
+
};
|
|
122
|
+
var logRetryDelayMs = (failedAttempts) => Math.min(logDelivery.baseDelayMs * 2 ** Math.max(0, failedAttempts - 1), logDelivery.maxDelayMs);
|
|
123
|
+
|
|
87
124
|
// src/utils/index.ts
|
|
88
125
|
var appearanceValues = ["system", "dark", "light"];
|
|
89
126
|
var isValidAppearance = (value) => appearanceValues.includes(value);
|
|
127
|
+
var timeClocks = ["24h", "12h"];
|
|
128
|
+
var timeZoneChoices = ["local", "utc"];
|
|
129
|
+
var isValidTimeFormat = (value) => {
|
|
130
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
131
|
+
const { clock, zone, ...rest } = value;
|
|
132
|
+
return timeClocks.includes(clock) && timeZoneChoices.includes(zone) && Object.keys(rest).length === 0;
|
|
133
|
+
};
|
|
134
|
+
var normalizeTimeFormat = (value) => {
|
|
135
|
+
const { clock, zone } = value && typeof value === "object" ? value : {};
|
|
136
|
+
return { clock: timeClocks.includes(clock) ? clock : DEFAULT_TIME_FORMAT.clock, zone: timeZoneChoices.includes(zone) ? zone : DEFAULT_TIME_FORMAT.zone };
|
|
137
|
+
};
|
|
90
138
|
var isValidColor = (value) => /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value);
|
|
91
139
|
var hashName = (name) => {
|
|
92
140
|
let hash = 2166136261;
|
|
@@ -158,12 +206,16 @@ var parsePushData = (data) => {
|
|
|
158
206
|
export {
|
|
159
207
|
APP_COLORS,
|
|
160
208
|
DEFAULT_ACCENT,
|
|
209
|
+
DEFAULT_API_ENDPOINT,
|
|
161
210
|
DEFAULT_PUSH_THRESHOLD,
|
|
211
|
+
DEFAULT_TIME_FORMAT,
|
|
212
|
+
LOG_KEY_VERSION,
|
|
162
213
|
LogLevel,
|
|
163
214
|
PUSH_OFF,
|
|
164
215
|
SubscriptionLevel,
|
|
165
216
|
apiErrorCodeOf,
|
|
166
217
|
apiErrorCodes,
|
|
218
|
+
buildLogPayload,
|
|
167
219
|
isApiErrorCode,
|
|
168
220
|
isValidAppearance,
|
|
169
221
|
isValidColor,
|
|
@@ -172,13 +224,18 @@ export {
|
|
|
172
224
|
isValidLogLevel,
|
|
173
225
|
isValidSubscriptionLevel,
|
|
174
226
|
isValidTeamMemberRole,
|
|
227
|
+
isValidTimeFormat,
|
|
175
228
|
joinApiKey,
|
|
229
|
+
logDelivery,
|
|
230
|
+
logDeliveryOutcome,
|
|
176
231
|
logLevelColors,
|
|
177
232
|
logLevelNameToLevel,
|
|
178
233
|
logLevelToName,
|
|
179
234
|
logLevels,
|
|
235
|
+
logRetryDelayMs,
|
|
180
236
|
nameColor,
|
|
181
237
|
normalizePushThreshold,
|
|
238
|
+
normalizeTimeFormat,
|
|
182
239
|
parsePushData,
|
|
183
240
|
personColor,
|
|
184
241
|
resolveAppColor,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infinitetoken/lumber-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Shared TypeScript types and wire format contracts for the Lumber cloud logging suite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lumber",
|
|
@@ -31,17 +31,20 @@
|
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"default": "./dist/index.js"
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
|
+
"./contract/*": "./contract/*"
|
|
35
36
|
},
|
|
36
37
|
"main": "./dist/index.js",
|
|
37
38
|
"module": "./dist/index.mjs",
|
|
38
39
|
"types": "./dist/index.d.ts",
|
|
39
40
|
"files": [
|
|
40
|
-
"dist"
|
|
41
|
+
"dist",
|
|
42
|
+
"contract"
|
|
41
43
|
],
|
|
42
44
|
"scripts": {
|
|
43
45
|
"build": "tsup",
|
|
44
46
|
"clean": "rm -rf dist coverage",
|
|
47
|
+
"contract": "node scripts/contract.cjs",
|
|
45
48
|
"fix": "eslint . --fix",
|
|
46
49
|
"lint": "eslint .",
|
|
47
50
|
"prepublishOnly": "npm run build",
|
|
@@ -61,9 +64,11 @@
|
|
|
61
64
|
"@infinitetoken/tsconfig": "^0.6.0",
|
|
62
65
|
"@types/jest": "^30.0.0",
|
|
63
66
|
"@types/node": "^25.0.0",
|
|
67
|
+
"ajv": "^8.20.0",
|
|
64
68
|
"eslint": "^10.2.1",
|
|
65
69
|
"jest": "^30.4.2",
|
|
66
70
|
"prettier": "^3.8.3",
|
|
71
|
+
"ts-json-schema-generator": "^2.9.0",
|
|
67
72
|
"tsup": "^8.5.1",
|
|
68
73
|
"typescript": "^6.0.3"
|
|
69
74
|
},
|