@dbx-tools/shared 0.1.18 → 0.1.20
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 +14 -1
- package/dist/src/api.js +0 -4
- package/dist/src/common.d.ts +15 -0
- package/dist/src/common.js +17 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/api.ts +0 -4
- package/src/common.ts +18 -0
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -183,10 +183,6 @@ export function toContext(
|
|
|
183
183
|
* `cancellationToken.onCancellationRequested` to it, so this
|
|
184
184
|
* adapter is the one-line bridge from "platform-standard
|
|
185
185
|
* cancellation" to "the SDK aborts the fetch on your behalf".
|
|
186
|
-
*
|
|
187
|
-
* Kept private for now: the genie package is the only consumer in
|
|
188
|
-
* the workspace. Lift to `@dbx-tools/shared` (`apiUtils`) the
|
|
189
|
-
* moment a second package needs SDK-call cancellation.
|
|
190
186
|
*/
|
|
191
187
|
function signalToCancellationToken(signal: AbortSignal): CancellationToken {
|
|
192
188
|
return {
|
package/src/common.ts
CHANGED
|
@@ -332,6 +332,24 @@ export function shortId(length: number = 8): string {
|
|
|
332
332
|
return globalThis.crypto.randomUUID().replace(/-/g, "").slice(0, length);
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
+
/**
|
|
336
|
+
* Extract a human-readable message from any thrown value. Returns
|
|
337
|
+
* `value.message` when `value` is an `Error`, otherwise coerces
|
|
338
|
+
* via `String(value)`. Collapses the ubiquitous
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* err instanceof Error ? err.message : String(err)
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* dance into a single helper, useful for log attributes and any
|
|
345
|
+
* other "give me something printable" context where the caller
|
|
346
|
+
* doesn't want to re-throw or rely on `console.error`'s default
|
|
347
|
+
* formatting.
|
|
348
|
+
*/
|
|
349
|
+
export function errorMessage(value: unknown): string {
|
|
350
|
+
return value instanceof Error ? value.message : String(value);
|
|
351
|
+
}
|
|
352
|
+
|
|
335
353
|
export function fnvHash(...values: string[]): string {
|
|
336
354
|
return fnvHashWithOptions({}, ...values);
|
|
337
355
|
}
|