@dbx-tools/shared-core 0.1.17 → 0.1.19

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 CHANGED
@@ -12,7 +12,6 @@ import {
12
12
  error,
13
13
  hash,
14
14
  http,
15
- iterable,
16
15
  log,
17
16
  net,
18
17
  object,
@@ -20,8 +19,8 @@ import {
20
19
  } from "@dbx-tools/shared-core";
21
20
  ```
22
21
 
23
- Node-only helpers live in [`@dbx-tools/node-core`](../../node/core). AppKit and
24
- Databricks SDK helpers live in [`@dbx-tools/node-appkit`](../../node/appkit).
22
+ Node-only helpers live in [`@dbx-tools/core`](../../node/core). AppKit and
23
+ Databricks SDK helpers live in [`@dbx-tools/appkit`](../../node/appkit).
25
24
 
26
25
  Key features:
27
26
 
@@ -33,7 +32,7 @@ Key features:
33
32
  and generated names.
34
33
  - String normalization helpers for slugs, identifiers, unique labels, and prompt
35
34
  descriptions.
36
- - Object, predicate, iterable, HTTP, cookie, network, token, memoization, and
35
+ - Object/iterable, predicate, HTTP, cookie, network, token, memoization, and
37
36
  logging helpers that avoid Node-only dependencies.
38
37
  - Namespace exports that make utility call sites explicit without creating a
39
38
  grab-bag default import.
@@ -120,14 +119,14 @@ short-circuits. `predicate.create()` returns composable predicates with `and`,
120
119
  ## Iterables
121
120
 
122
121
  ```ts
123
- const names = iterable
122
+ const names = object
124
123
  .sequence(packages)
125
124
  .map((p) => p.name)
126
125
  .filter(Boolean)
127
126
  .distinct()
128
127
  .toArray();
129
128
 
130
- const grouped = iterable.group(packages, {
129
+ const grouped = object.group(packages, {
131
130
  node: (p) => p.tags.includes("node"),
132
131
  ui: (p) => p.tags.includes("ui"),
133
132
  });
@@ -210,8 +209,8 @@ without paying formatting cost when disabled.
210
209
  - `hash` - ids, FNV hashes, and base32 encoding.
211
210
  - `string` - tokenization, slugs, identifiers, descriptions, pluralization, and
212
211
  HTML escaping.
213
- - `object` - record checks, boolean coercion, deep equality, and shape types.
214
- - `iterable` - lazy sequence transforms and collection helpers.
212
+ - `object` - record checks, boolean coercion, deep equality, shape types, and
213
+ lazy sequence transforms + collection helpers.
215
214
  - `predicate` - composable boolean/type predicates.
216
215
  - `http` - header iteration, cookie parsing, and fetch error creation.
217
216
  - `net` - URL building, email parsing, path matching, IP/CIDR helpers.
package/index.ts CHANGED
@@ -7,7 +7,6 @@ export * as error from "./src/error";
7
7
  export * as functionModule from "./src/function";
8
8
  export * as hash from "./src/hash";
9
9
  export * as http from "./src/http";
10
- export * as iterable from "./src/iterable";
11
10
  export * as log from "./src/log";
12
11
  export * as net from "./src/net";
13
12
  export * as object from "./src/object";
@@ -18,9 +17,8 @@ export type { PollContext, PollProducer, PollOptions } from "./src/async";
18
17
  export type { ErrorContext } from "./src/error";
19
18
  export type { MemoizeOptions } from "./src/function";
20
19
  export type { HeaderLike } from "./src/http";
21
- export type { Sequence, Container, Collection, OneOrMany } from "./src/iterable";
22
20
  export type { LogLevel, Logger } from "./src/log";
23
21
  export type { UrlLike, IpVersion, ParsedIp, Cidr, UrlBuilder, ParseEmailsOptions } from "./src/net";
24
- export type { NameLike, NonFunctionKeys, DeepEqualComparator } from "./src/object";
22
+ export type { Sequence, Container, Collection, OneOrMany, NameLike, NonFunctionKeys, DeepEqualComparator } from "./src/object";
25
23
  export type { PredicateFunction, TypePredicateFunction, PredicateInput, Predicate } from "./src/predicate";
26
24
  export type { TokenizeOptions, KeyOptions, IdentifierOptions, Description } from "./src/string";
package/package.json CHANGED
@@ -16,7 +16,10 @@
16
16
  },
17
17
  "main": "index.ts",
18
18
  "license": "UNLICENSED",
19
- "version": "0.1.17",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "version": "0.1.19",
20
23
  "types": "index.ts",
21
24
  "type": "module",
22
25
  "exports": {
package/src/log.ts CHANGED
@@ -48,6 +48,19 @@ interface BunLike {
48
48
  const globalProcess = (globalThis as { process?: ProcessLike }).process;
49
49
  const globalBun = (globalThis as { Bun?: BunLike }).Bun;
50
50
 
51
+ /**
52
+ * Node `process.stderr` when writable, else `undefined` (stable for the
53
+ * process). Typed loosely (`any`) because it is handed to consola's
54
+ * `ctx.options.stdout` (a `WriteStream`) and to the console fallback's
55
+ * `.write`, neither of which our structural {@link ProcessLike} shape satisfies
56
+ * nominally.
57
+ */
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ const globalProcessStdErr: any =
60
+ globalProcess && typeof globalProcess.stderr?.write === "function"
61
+ ? globalProcess.stderr
62
+ : undefined;
63
+
51
64
  const LOG_LEVELS = ["debug", "info", "warn", "error"] as const;
52
65
  const LOG_LEVEL_RANK = Object.fromEntries(
53
66
  LOG_LEVELS.map((level, index) => [level, index]),
@@ -102,14 +115,18 @@ type LoggerFactory = (name?: string) => Logger;
102
115
  *
103
116
  * Builds one `createConsola` instance (badge off, level `verbose`) whose
104
117
  * reporter calls {@link shouldEmit} on `logObj.type` before delegating to
105
- * consola's default reporters. In Node, when `processStdErr` is set,
118
+ * consola's default reporters. In Node, when `globalProcessStdErr` is set,
106
119
  * recognized {@link LogLevel} types are redirected to stderr for that write.
107
120
  * Tags use `withTag` (rendered `[name]`, not merged into args).
121
+ *
122
+ * Memoized: the dynamic `consola` import, env checks, and `createConsola`
123
+ * setup (plus the import/throw fallback) run once; later calls share the one
124
+ * resolved factory (or the one resolved `undefined`). A rejection is evicted
125
+ * by {@link memoize} so a later call retries.
108
126
  */
109
- async function createConsolaLoggerFactory(
110
- globalProcessStdErr: any,
111
- ): Promise<LoggerFactory | undefined> {
112
- const consolaDisabled = toBoolean(globalProcess?.env?.LOG_CONSOLA_DISABLED);
127
+ const createConsolaLoggerFactory = memoize(
128
+ async (): Promise<LoggerFactory | undefined> => {
129
+ const consolaDisabled = toBoolean(globalProcess?.env?.LOG_CONSOLA_DISABLED);
113
130
  if (!consolaDisabled) {
114
131
  try {
115
132
  const { consola, createConsola, LogLevels } = await import("consola");
@@ -147,7 +164,7 @@ async function createConsolaLoggerFactory(
147
164
  }
148
165
  }
149
166
  return undefined;
150
- }
167
+ });
151
168
 
152
169
  /**
153
170
  * Console {@link LoggerFactory}; always succeeds.
@@ -236,12 +253,8 @@ async function createConsoleLoggerFactory(globalProcessStdErr: any): Promise<Log
236
253
  * chosen factory with a resolved tag. Env toggles are read only during init.
237
254
  */
238
255
  const createLogger: LoggerFactory = await (async () => {
239
- const globalProcessStdErr =
240
- globalProcess && typeof globalProcess.stderr?.write === "function"
241
- ? globalProcess.stderr
242
- : undefined;
243
256
  return (
244
- (await createConsolaLoggerFactory(globalProcessStdErr)) ??
257
+ (await createConsolaLoggerFactory()) ??
245
258
  (await createConsoleLoggerFactory(globalProcessStdErr))
246
259
  );
247
260
  })();
@@ -378,8 +391,3 @@ export function logger(loggerName: NameLike | string | undefined): Logger {
378
391
  const name = extractLoggerName(loggerName);
379
392
  return createLogger(name);
380
393
  }
381
-
382
-
383
- if (import.meta.main) {
384
-
385
- }