@smoothbricks/lmao 0.1.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 +269 -0
- package/dist/allocator.wasm +0 -0
- package/dist/bun/preload.d.ts +11 -0
- package/dist/bun/preload.d.ts.map +1 -0
- package/dist/bun/preload.js +10 -0
- package/dist/bun/trace-preload.d.ts +8 -0
- package/dist/bun/trace-preload.d.ts.map +1 -0
- package/dist/bun/trace-preload.js +12 -0
- package/dist/es.d.ts +8 -0
- package/dist/es.d.ts.map +1 -0
- package/dist/es.js +9 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/lib/JsBufferStrategy.d.ts +49 -0
- package/dist/lib/JsBufferStrategy.d.ts.map +1 -0
- package/dist/lib/JsBufferStrategy.js +60 -0
- package/dist/lib/archive/chunkCompaction.d.ts +15 -0
- package/dist/lib/archive/chunkCompaction.d.ts.map +1 -0
- package/dist/lib/archive/chunkCompaction.js +24 -0
- package/dist/lib/archive/chunkEnvelope.d.ts +21 -0
- package/dist/lib/archive/chunkEnvelope.d.ts.map +1 -0
- package/dist/lib/archive/chunkEnvelope.js +55 -0
- package/dist/lib/archive/chunkRouting.d.ts +10 -0
- package/dist/lib/archive/chunkRouting.d.ts.map +1 -0
- package/dist/lib/archive/chunkRouting.js +47 -0
- package/dist/lib/archive/chunkStats.d.ts +12 -0
- package/dist/lib/archive/chunkStats.d.ts.map +1 -0
- package/dist/lib/archive/chunkStats.js +10 -0
- package/dist/lib/archive/index.d.ts +5 -0
- package/dist/lib/archive/index.d.ts.map +1 -0
- package/dist/lib/archive/index.js +4 -0
- package/dist/lib/arrow/capacityStats.d.ts +9 -0
- package/dist/lib/arrow/capacityStats.d.ts.map +1 -0
- package/dist/lib/arrow/capacityStats.js +231 -0
- package/dist/lib/arrow/dictionaries.d.ts +27 -0
- package/dist/lib/arrow/dictionaries.d.ts.map +1 -0
- package/dist/lib/arrow/dictionaries.js +135 -0
- package/dist/lib/arrow/flechette.d.ts +40 -0
- package/dist/lib/arrow/flechette.d.ts.map +1 -0
- package/dist/lib/arrow/flechette.js +67 -0
- package/dist/lib/arrow/utils.d.ts +38 -0
- package/dist/lib/arrow/utils.d.ts.map +1 -0
- package/dist/lib/arrow/utils.js +112 -0
- package/dist/lib/buffer/Nanoseconds.d.ts +109 -0
- package/dist/lib/buffer/Nanoseconds.d.ts.map +1 -0
- package/dist/lib/buffer/Nanoseconds.js +86 -0
- package/dist/lib/bufferStrategy.d.ts +95 -0
- package/dist/lib/bufferStrategy.d.ts.map +1 -0
- package/dist/lib/bufferStrategy.js +1 -0
- package/dist/lib/capacityTuning.d.ts +50 -0
- package/dist/lib/capacityTuning.d.ts.map +1 -0
- package/dist/lib/capacityTuning.js +65 -0
- package/dist/lib/codegen/evaluatorGenerator.d.ts +35 -0
- package/dist/lib/codegen/evaluatorGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/evaluatorGenerator.js +199 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts +139 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.js +289 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts +115 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/spanLoggerGenerator.js +575 -0
- package/dist/lib/convertToArrow.d.ts +40 -0
- package/dist/lib/convertToArrow.d.ts.map +1 -0
- package/dist/lib/convertToArrow.js +1467 -0
- package/dist/lib/defineOpContext.d.ts +96 -0
- package/dist/lib/defineOpContext.d.ts.map +1 -0
- package/dist/lib/defineOpContext.js +227 -0
- package/dist/lib/errors/Blocked.d.ts +113 -0
- package/dist/lib/errors/Blocked.d.ts.map +1 -0
- package/dist/lib/errors/Blocked.js +68 -0
- package/dist/lib/errors/CodeError.d.ts +101 -0
- package/dist/lib/errors/CodeError.d.ts.map +1 -0
- package/dist/lib/errors/CodeError.js +42 -0
- package/dist/lib/errors/RetriesExhausted.d.ts +67 -0
- package/dist/lib/errors/RetriesExhausted.d.ts.map +1 -0
- package/dist/lib/errors/RetriesExhausted.js +31 -0
- package/dist/lib/errors/Transient.d.ts +115 -0
- package/dist/lib/errors/Transient.d.ts.map +1 -0
- package/dist/lib/errors/Transient.js +54 -0
- package/dist/lib/errors/index.d.ts +14 -0
- package/dist/lib/errors/index.d.ts.map +1 -0
- package/dist/lib/errors/index.js +16 -0
- package/dist/lib/errors/retry-policy.d.ts +60 -0
- package/dist/lib/errors/retry-policy.d.ts.map +1 -0
- package/dist/lib/errors/retry-policy.js +54 -0
- package/dist/lib/flushScheduler.d.ts +162 -0
- package/dist/lib/flushScheduler.d.ts.map +1 -0
- package/dist/lib/flushScheduler.js +388 -0
- package/dist/lib/library.d.ts +149 -0
- package/dist/lib/library.d.ts.map +1 -0
- package/dist/lib/library.js +588 -0
- package/dist/lib/logApi.d.ts +61 -0
- package/dist/lib/logApi.d.ts.map +1 -0
- package/dist/lib/logApi.js +12 -0
- package/dist/lib/logBinding.d.ts +63 -0
- package/dist/lib/logBinding.d.ts.map +1 -0
- package/dist/lib/logBinding.js +1 -0
- package/dist/lib/op.d.ts +105 -0
- package/dist/lib/op.d.ts.map +1 -0
- package/dist/lib/op.js +59 -0
- package/dist/lib/opContext/contextTypes.d.ts +88 -0
- package/dist/lib/opContext/contextTypes.d.ts.map +1 -0
- package/dist/lib/opContext/contextTypes.js +34 -0
- package/dist/lib/opContext/createOpGroup.d.ts +57 -0
- package/dist/lib/opContext/createOpGroup.d.ts.map +1 -0
- package/dist/lib/opContext/createOpGroup.js +341 -0
- package/dist/lib/opContext/defineOp.d.ts +83 -0
- package/dist/lib/opContext/defineOp.d.ts.map +1 -0
- package/dist/lib/opContext/defineOp.js +197 -0
- package/dist/lib/opContext/featureFlagTypes.d.ts +58 -0
- package/dist/lib/opContext/featureFlagTypes.d.ts.map +1 -0
- package/dist/lib/opContext/featureFlagTypes.js +1 -0
- package/dist/lib/opContext/index.d.ts +13 -0
- package/dist/lib/opContext/index.d.ts.map +1 -0
- package/dist/lib/opContext/index.js +15 -0
- package/dist/lib/opContext/opGroupTypes.d.ts +250 -0
- package/dist/lib/opContext/opGroupTypes.d.ts.map +1 -0
- package/dist/lib/opContext/opGroupTypes.js +31 -0
- package/dist/lib/opContext/opTypes.d.ts +48 -0
- package/dist/lib/opContext/opTypes.d.ts.map +1 -0
- package/dist/lib/opContext/opTypes.js +7 -0
- package/dist/lib/opContext/spanContextTypes.d.ts +347 -0
- package/dist/lib/opContext/spanContextTypes.d.ts.map +1 -0
- package/dist/lib/opContext/spanContextTypes.js +1 -0
- package/dist/lib/opContext/types.d.ts +297 -0
- package/dist/lib/opContext/types.d.ts.map +1 -0
- package/dist/lib/opContext/types.js +16 -0
- package/dist/lib/result.d.ts +308 -0
- package/dist/lib/result.d.ts.map +1 -0
- package/dist/lib/result.js +359 -0
- package/dist/lib/schema/LogSchema.d.ts +62 -0
- package/dist/lib/schema/LogSchema.d.ts.map +1 -0
- package/dist/lib/schema/LogSchema.js +134 -0
- package/dist/lib/schema/builder.d.ts +12 -0
- package/dist/lib/schema/builder.d.ts.map +1 -0
- package/dist/lib/schema/builder.js +169 -0
- package/dist/lib/schema/defineFeatureFlags.d.ts +60 -0
- package/dist/lib/schema/defineFeatureFlags.d.ts.map +1 -0
- package/dist/lib/schema/defineFeatureFlags.js +29 -0
- package/dist/lib/schema/defineLogSchema.d.ts +87 -0
- package/dist/lib/schema/defineLogSchema.d.ts.map +1 -0
- package/dist/lib/schema/defineLogSchema.js +171 -0
- package/dist/lib/schema/evaluator.d.ts +267 -0
- package/dist/lib/schema/evaluator.d.ts.map +1 -0
- package/dist/lib/schema/evaluator.js +169 -0
- package/dist/lib/schema/extend.d.ts +14 -0
- package/dist/lib/schema/extend.d.ts.map +1 -0
- package/dist/lib/schema/extend.js +51 -0
- package/dist/lib/schema/systemSchema.d.ts +112 -0
- package/dist/lib/schema/systemSchema.d.ts.map +1 -0
- package/dist/lib/schema/systemSchema.js +260 -0
- package/dist/lib/schema/typeGuards.d.ts +52 -0
- package/dist/lib/schema/typeGuards.d.ts.map +1 -0
- package/dist/lib/schema/typeGuards.js +127 -0
- package/dist/lib/schema/types.d.ts +156 -0
- package/dist/lib/schema/types.d.ts.map +1 -0
- package/dist/lib/schema/types.js +4 -0
- package/dist/lib/spanBuffer.d.ts +133 -0
- package/dist/lib/spanBuffer.d.ts.map +1 -0
- package/dist/lib/spanBuffer.js +442 -0
- package/dist/lib/spanBufferHelpers.d.ts +53 -0
- package/dist/lib/spanBufferHelpers.d.ts.map +1 -0
- package/dist/lib/spanBufferHelpers.js +65 -0
- package/dist/lib/spanBufferStats.d.ts +38 -0
- package/dist/lib/spanBufferStats.d.ts.map +1 -0
- package/dist/lib/spanBufferStats.js +1 -0
- package/dist/lib/spanContext.d.ts +141 -0
- package/dist/lib/spanContext.d.ts.map +1 -0
- package/dist/lib/spanContext.js +763 -0
- package/dist/lib/sqlite/index.d.ts +14 -0
- package/dist/lib/sqlite/index.d.ts.map +1 -0
- package/dist/lib/sqlite/index.js +12 -0
- package/dist/lib/sqlite/sqlite-async-writer.d.ts +24 -0
- package/dist/lib/sqlite/sqlite-async-writer.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-async-writer.js +65 -0
- package/dist/lib/sqlite/sqlite-common.d.ts +37 -0
- package/dist/lib/sqlite/sqlite-common.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-common.js +207 -0
- package/dist/lib/sqlite/sqlite-d1.d.ts +25 -0
- package/dist/lib/sqlite/sqlite-d1.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-d1.js +67 -0
- package/dist/lib/sqlite/sqlite-db.d.ts +29 -0
- package/dist/lib/sqlite/sqlite-db.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-db.js +1 -0
- package/dist/lib/sqlite/sqlite-node.d.ts +16 -0
- package/dist/lib/sqlite/sqlite-node.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-node.js +68 -0
- package/dist/lib/sqlite/sqlite-writer.d.ts +39 -0
- package/dist/lib/sqlite/sqlite-writer.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-writer.js +78 -0
- package/dist/lib/testing/bun-harness.d.ts +150 -0
- package/dist/lib/testing/bun-harness.d.ts.map +1 -0
- package/dist/lib/testing/bun-harness.js +729 -0
- package/dist/lib/testing/extractFacts.d.ts +73 -0
- package/dist/lib/testing/extractFacts.d.ts.map +1 -0
- package/dist/lib/testing/extractFacts.js +237 -0
- package/dist/lib/testing/facts.d.ts +235 -0
- package/dist/lib/testing/facts.d.ts.map +1 -0
- package/dist/lib/testing/facts.js +209 -0
- package/dist/lib/testing/index.d.ts +58 -0
- package/dist/lib/testing/index.d.ts.map +1 -0
- package/dist/lib/testing/index.js +74 -0
- package/dist/lib/testing/queryable-span.d.ts +39 -0
- package/dist/lib/testing/queryable-span.d.ts.map +1 -0
- package/dist/lib/testing/queryable-span.js +58 -0
- package/dist/lib/testing/span-query.d.ts +21 -0
- package/dist/lib/testing/span-query.d.ts.map +1 -0
- package/dist/lib/testing/span-query.js +47 -0
- package/dist/lib/testing/stdio-replay.d.ts +4 -0
- package/dist/lib/testing/stdio-replay.d.ts.map +1 -0
- package/dist/lib/testing/stdio-replay.js +42 -0
- package/dist/lib/testing/trace-query.d.ts +59 -0
- package/dist/lib/testing/trace-query.d.ts.map +1 -0
- package/dist/lib/testing/trace-query.js +462 -0
- package/dist/lib/testing/vitest-harness.d.ts +135 -0
- package/dist/lib/testing/vitest-harness.d.ts.map +1 -0
- package/dist/lib/testing/vitest-harness.js +486 -0
- package/dist/lib/threadId.d.ts +58 -0
- package/dist/lib/threadId.d.ts.map +1 -0
- package/dist/lib/threadId.js +123 -0
- package/dist/lib/traceContext.d.ts +116 -0
- package/dist/lib/traceContext.d.ts.map +1 -0
- package/dist/lib/traceContext.js +37 -0
- package/dist/lib/traceId.d.ts +78 -0
- package/dist/lib/traceId.d.ts.map +1 -0
- package/dist/lib/traceId.js +87 -0
- package/dist/lib/traceRoot.d.ts +133 -0
- package/dist/lib/traceRoot.d.ts.map +1 -0
- package/dist/lib/traceRoot.es.d.ts +75 -0
- package/dist/lib/traceRoot.es.d.ts.map +1 -0
- package/dist/lib/traceRoot.es.js +129 -0
- package/dist/lib/traceRoot.js +19 -0
- package/dist/lib/traceRoot.node.d.ts +77 -0
- package/dist/lib/traceRoot.node.d.ts.map +1 -0
- package/dist/lib/traceRoot.node.js +133 -0
- package/dist/lib/traceRoot.universal.d.ts +3 -0
- package/dist/lib/traceRoot.universal.d.ts.map +1 -0
- package/dist/lib/traceRoot.universal.js +17 -0
- package/dist/lib/tracer.d.ts +296 -0
- package/dist/lib/tracer.d.ts.map +1 -0
- package/dist/lib/tracer.js +346 -0
- package/dist/lib/tracers/ArrayQueueTracer.d.ts +56 -0
- package/dist/lib/tracers/ArrayQueueTracer.d.ts.map +1 -0
- package/dist/lib/tracers/ArrayQueueTracer.js +67 -0
- package/dist/lib/tracers/CompositeTracer.d.ts +24 -0
- package/dist/lib/tracers/CompositeTracer.d.ts.map +1 -0
- package/dist/lib/tracers/CompositeTracer.js +57 -0
- package/dist/lib/tracers/NoOpTracer.d.ts +58 -0
- package/dist/lib/tracers/NoOpTracer.d.ts.map +1 -0
- package/dist/lib/tracers/NoOpTracer.js +41 -0
- package/dist/lib/tracers/SQLiteTracer.d.ts +42 -0
- package/dist/lib/tracers/SQLiteTracer.d.ts.map +1 -0
- package/dist/lib/tracers/SQLiteTracer.js +84 -0
- package/dist/lib/tracers/StdioTracer.d.ts +83 -0
- package/dist/lib/tracers/StdioTracer.d.ts.map +1 -0
- package/dist/lib/tracers/StdioTracer.js +270 -0
- package/dist/lib/tracers/TestTracer.d.ts +95 -0
- package/dist/lib/tracers/TestTracer.d.ts.map +1 -0
- package/dist/lib/tracers/TestTracer.js +87 -0
- package/dist/lib/tracers/index.d.ts +12 -0
- package/dist/lib/tracers/index.d.ts.map +1 -0
- package/dist/lib/tracers/index.js +11 -0
- package/dist/lib/types.d.ts +366 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/utf8Cache.d.ts +111 -0
- package/dist/lib/utf8Cache.d.ts.map +1 -0
- package/dist/lib/utf8Cache.js +177 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts +88 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts.map +1 -0
- package/dist/lib/wasm/WasmBufferStrategy.js +138 -0
- package/dist/lib/wasm/wasmAllocator.d.ts +109 -0
- package/dist/lib/wasm/wasmAllocator.d.ts.map +1 -0
- package/dist/lib/wasm/wasmAllocator.js +227 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts +123 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts.map +1 -0
- package/dist/lib/wasm/wasmSpanBuffer.js +772 -0
- package/dist/lib/wasm/wasmTraceRoot.d.ts +167 -0
- package/dist/lib/wasm/wasmTraceRoot.d.ts.map +1 -0
- package/dist/lib/wasm/wasmTraceRoot.js +264 -0
- package/dist/node.d.ts +7 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +8 -0
- package/dist/testing.d.ts +18 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +17 -0
- package/package.json +193 -0
- package/src/bun/preload.ts +11 -0
- package/src/bun/trace-preload.ts +14 -0
- package/src/es.ts +11 -0
- package/src/index.ts +194 -0
- package/src/lib/JsBufferStrategy.ts +102 -0
- package/src/lib/__tests__/arrow-builder-integration/arrow-conversion.test.ts +485 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-arrow-conversion.test.ts +390 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-comparison.test.ts +647 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-format-compliance.test.ts +292 -0
- package/src/lib/__tests__/arrow-builder-integration/buffer-chaining.test.ts +354 -0
- package/src/lib/__tests__/arrow-builder-integration/foundation.test.ts +127 -0
- package/src/lib/__tests__/arrow-builder-integration/integration.test.ts +392 -0
- package/src/lib/__tests__/arrow-builder-integration/lazy-columns.test.ts +389 -0
- package/src/lib/__tests__/arrow-conversion-algorithms.test.ts +54 -0
- package/src/lib/__tests__/arrow-test-helpers.ts +71 -0
- package/src/lib/__tests__/binary-e2e.test.ts +203 -0
- package/src/lib/__tests__/buffer-overflow-op-api.test.ts +608 -0
- package/src/lib/__tests__/buffer-overflow.test.ts +612 -0
- package/src/lib/__tests__/capacity-tuning.test.ts +544 -0
- package/src/lib/__tests__/effective-schema.test.ts +439 -0
- package/src/lib/__tests__/flechette.test.ts +42 -0
- package/src/lib/__tests__/flushScheduler.test.ts +537 -0
- package/src/lib/__tests__/integration.test.ts +600 -0
- package/src/lib/__tests__/library.test.ts +934 -0
- package/src/lib/__tests__/nested-library-tasks.test.ts +849 -0
- package/src/lib/__tests__/op-context-binding.test.ts +135 -0
- package/src/lib/__tests__/op-metadata.test.ts +198 -0
- package/src/lib/__tests__/op-type-safety.test.ts +71 -0
- package/src/lib/__tests__/package-exports.test.ts +57 -0
- package/src/lib/__tests__/remapped-buffer-view-integration.test.ts +319 -0
- package/src/lib/__tests__/remapped-buffer-view.test.ts +635 -0
- package/src/lib/__tests__/scope-attributes.test.ts +348 -0
- package/src/lib/__tests__/span-lifecycle.test.ts +680 -0
- package/src/lib/__tests__/sync-async-trace.test.ts +435 -0
- package/src/lib/__tests__/test-helpers.ts +318 -0
- package/src/lib/__tests__/timestamp.test.ts +259 -0
- package/src/lib/__tests__/trace-archive-primitives.test.ts +98 -0
- package/src/lib/__tests__/traceContext-type-enforcement.test.ts +271 -0
- package/src/lib/__tests__/tracer.test.ts +211 -0
- package/src/lib/__tests__/type-narrowing.test.ts +137 -0
- package/src/lib/archive/chunkCompaction.ts +44 -0
- package/src/lib/archive/chunkEnvelope.ts +79 -0
- package/src/lib/archive/chunkRouting.ts +70 -0
- package/src/lib/archive/chunkStats.ts +25 -0
- package/src/lib/archive/index.ts +4 -0
- package/src/lib/arrow/capacityStats.ts +340 -0
- package/src/lib/arrow/dictionaries.ts +159 -0
- package/src/lib/arrow/flechette.ts +114 -0
- package/src/lib/arrow/utils.ts +126 -0
- package/src/lib/buffer/Nanoseconds.ts +131 -0
- package/src/lib/bufferStrategy.ts +106 -0
- package/src/lib/capacityTuning.ts +102 -0
- package/src/lib/codegen/__tests__/__snapshots__/evaluatorGenerator.test.ts.snap +160 -0
- package/src/lib/codegen/__tests__/__snapshots__/scopeGenerator.test.ts.snap +196 -0
- package/src/lib/codegen/__tests__/__snapshots__/spanLoggerGenerator.test.ts.snap +1965 -0
- package/src/lib/codegen/__tests__/evaluatorGenerator.test.ts +516 -0
- package/src/lib/codegen/__tests__/nullBitmap.test.ts +207 -0
- package/src/lib/codegen/__tests__/spanLoggerGenerator.test.ts +237 -0
- package/src/lib/codegen/evaluatorGenerator.ts +309 -0
- package/src/lib/codegen/fixedPositionWriterGenerator.ts +444 -0
- package/src/lib/codegen/spanLoggerGenerator.ts +715 -0
- package/src/lib/convertToArrow.ts +1805 -0
- package/src/lib/defineOpContext.ts +398 -0
- package/src/lib/errors/Blocked.ts +165 -0
- package/src/lib/errors/CodeError.ts +132 -0
- package/src/lib/errors/RetriesExhausted.ts +78 -0
- package/src/lib/errors/Transient.ts +168 -0
- package/src/lib/errors/__tests__/Blocked-config.test.ts +152 -0
- package/src/lib/errors/__tests__/Transient.test.ts +129 -0
- package/src/lib/errors/__tests__/retry-policy.test.ts +85 -0
- package/src/lib/errors/index.ts +24 -0
- package/src/lib/errors/retry-policy.ts +87 -0
- package/src/lib/flushScheduler.ts +509 -0
- package/src/lib/library.ts +682 -0
- package/src/lib/logApi.ts +70 -0
- package/src/lib/logBinding.ts +67 -0
- package/src/lib/op.ts +103 -0
- package/src/lib/opContext/__tests__/retry.test.ts +764 -0
- package/src/lib/opContext/contextTypes.ts +130 -0
- package/src/lib/opContext/createOpGroup.ts +456 -0
- package/src/lib/opContext/defineOp.ts +281 -0
- package/src/lib/opContext/featureFlagTypes.ts +54 -0
- package/src/lib/opContext/index.ts +16 -0
- package/src/lib/opContext/opGroupTypes.ts +342 -0
- package/src/lib/opContext/opTypes.ts +80 -0
- package/src/lib/opContext/spanContextTypes.ts +398 -0
- package/src/lib/opContext/types.ts +403 -0
- package/src/lib/result.ts +550 -0
- package/src/lib/schema/LogSchema.ts +153 -0
- package/src/lib/schema/__tests__/defineLogSchema.test.ts +342 -0
- package/src/lib/schema/__tests__/featureFlags.test.ts +443 -0
- package/src/lib/schema/builder.ts +201 -0
- package/src/lib/schema/defineFeatureFlags.ts +91 -0
- package/src/lib/schema/defineLogSchema.ts +291 -0
- package/src/lib/schema/evaluator.ts +404 -0
- package/src/lib/schema/extend.ts +69 -0
- package/src/lib/schema/systemSchema.ts +339 -0
- package/src/lib/schema/typeGuards.ts +163 -0
- package/src/lib/schema/types.ts +265 -0
- package/src/lib/spanBuffer.ts +571 -0
- package/src/lib/spanBufferHelpers.ts +73 -0
- package/src/lib/spanBufferStats.ts +40 -0
- package/src/lib/spanContext.ts +1566 -0
- package/src/lib/sqlite/__tests__/sqlite-common.test.ts +89 -0
- package/src/lib/sqlite/index.ts +26 -0
- package/src/lib/sqlite/sqlite-async-writer.ts +101 -0
- package/src/lib/sqlite/sqlite-common.ts +309 -0
- package/src/lib/sqlite/sqlite-d1.ts +104 -0
- package/src/lib/sqlite/sqlite-db.ts +32 -0
- package/src/lib/sqlite/sqlite-node.ts +83 -0
- package/src/lib/sqlite/sqlite-writer.ts +128 -0
- package/src/lib/testing/TRACE-TESTING.md +100 -0
- package/src/lib/testing/__tests__/bun-harness.test.ts +108 -0
- package/src/lib/testing/__tests__/extractFacts.test.ts +279 -0
- package/src/lib/testing/__tests__/facts.test.ts +324 -0
- package/src/lib/testing/__tests__/vitest-harness.test.ts +32 -0
- package/src/lib/testing/bun-harness.ts +990 -0
- package/src/lib/testing/extractFacts.ts +362 -0
- package/src/lib/testing/facts.ts +470 -0
- package/src/lib/testing/index.ts +141 -0
- package/src/lib/testing/queryable-span.ts +108 -0
- package/src/lib/testing/span-query.ts +65 -0
- package/src/lib/testing/stdio-replay.ts +50 -0
- package/src/lib/testing/trace-query.ts +329 -0
- package/src/lib/testing/vitest-harness.ts +691 -0
- package/src/lib/threadId.ts +135 -0
- package/src/lib/traceContext.ts +182 -0
- package/src/lib/traceId.ts +142 -0
- package/src/lib/traceRoot.es.ts +157 -0
- package/src/lib/traceRoot.node.ts +170 -0
- package/src/lib/traceRoot.ts +154 -0
- package/src/lib/traceRoot.universal.ts +22 -0
- package/src/lib/tracer.ts +896 -0
- package/src/lib/tracers/ArrayQueueTracer.ts +76 -0
- package/src/lib/tracers/CompositeTracer.ts +76 -0
- package/src/lib/tracers/NoOpTracer.ts +73 -0
- package/src/lib/tracers/SQLiteTracer.ts +115 -0
- package/src/lib/tracers/StdioTracer.ts +380 -0
- package/src/lib/tracers/TestTracer.ts +146 -0
- package/src/lib/tracers/__tests__/ArrayQueueTracer.test.ts +184 -0
- package/src/lib/tracers/__tests__/NoOpTracer.test.ts +204 -0
- package/src/lib/tracers/__tests__/StdioTracer.test.ts +313 -0
- package/src/lib/tracers/__tests__/TestTracer.test.ts +200 -0
- package/src/lib/tracers/index.ts +12 -0
- package/src/lib/types.ts +498 -0
- package/src/lib/utf8Cache.ts +201 -0
- package/src/lib/wasm/WasmBufferStrategy.ts +219 -0
- package/src/lib/wasm/__tests__/WasmBufferStrategy.test.ts +256 -0
- package/src/lib/wasm/__tests__/wasm-integration.test.ts +476 -0
- package/src/lib/wasm/__tests__/wasmAllocator.test.ts +699 -0
- package/src/lib/wasm/__tests__/wasmSpanBuffer.test.ts +449 -0
- package/src/lib/wasm/__tests__/wasmTraceRoot.test.ts +390 -0
- package/src/lib/wasm/__tests__/wasmTracer.test.ts.disabled +444 -0
- package/src/lib/wasm/allocator.zig +945 -0
- package/src/lib/wasm/wasmAllocator.ts +469 -0
- package/src/lib/wasm/wasmSpanBuffer.ts +1014 -0
- package/src/lib/wasm/wasmTraceRoot.ts +315 -0
- package/src/node.ts +10 -0
- package/src/testing.ts +18 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema extension utilities for composing tag attribute schemas
|
|
3
|
+
*
|
|
4
|
+
* This enables building complex schemas from smaller, reusable pieces:
|
|
5
|
+
* - Base attributes (requestId, userId, etc.)
|
|
6
|
+
* - HTTP-specific attributes (httpStatus, httpMethod, etc.)
|
|
7
|
+
* - Database-specific attributes (dbQuery, dbDuration, etc.)
|
|
8
|
+
* - Custom domain attributes
|
|
9
|
+
*/
|
|
10
|
+
import { LogSchema } from './LogSchema.js';
|
|
11
|
+
/**
|
|
12
|
+
* Merge two log schemas with conflict detection
|
|
13
|
+
*
|
|
14
|
+
* This performs shallow merge and validates:
|
|
15
|
+
* - No conflicting field names
|
|
16
|
+
* - No reserved names in extension
|
|
17
|
+
*
|
|
18
|
+
* Example:
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const base = { requestId: S.category() };
|
|
21
|
+
* const httpAttrs = { httpStatus: S.number(), httpMethod: S.enum(['GET', 'POST']) };
|
|
22
|
+
* const combined = extendSchema(base, httpAttrs);
|
|
23
|
+
* // Result: { requestId, httpStatus, httpMethod }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param base - Base log schema (LogSchema or plain object)
|
|
27
|
+
* @param extension - Additional attributes to add
|
|
28
|
+
* @returns Merged schema
|
|
29
|
+
* @throws Error if field names conflict
|
|
30
|
+
*/
|
|
31
|
+
export function extendSchema(base, extension) {
|
|
32
|
+
// Extract base fields (from LogSchema.fields or plain object)
|
|
33
|
+
const baseFields = base instanceof LogSchema ? base.fields : base;
|
|
34
|
+
const baseKeys = new Set(Object.keys(baseFields));
|
|
35
|
+
// Check for field name conflicts
|
|
36
|
+
for (const key of Object.keys(extension)) {
|
|
37
|
+
if (baseKeys.has(key)) {
|
|
38
|
+
throw new Error(`Schema conflict: attribute '${key}' already exists in base schema. ` +
|
|
39
|
+
`Base schema has: ${Object.keys(baseFields).join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Assert extension doesn't use reserved names
|
|
43
|
+
LogSchema.assertUserFieldNames(Object.keys(extension));
|
|
44
|
+
// Perform shallow merge
|
|
45
|
+
const merged = { ...baseFields, ...extension };
|
|
46
|
+
// If base was LogSchema, return LogSchema; otherwise return plain object
|
|
47
|
+
if (base instanceof LogSchema) {
|
|
48
|
+
return new LogSchema(merged);
|
|
49
|
+
}
|
|
50
|
+
return merged;
|
|
51
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System schema - base columns that all modules inherit
|
|
3
|
+
*
|
|
4
|
+
* Per specs/lmao/01h_entry_types_and_logging_primitives.md and 01f_arrow_table_structure.md:
|
|
5
|
+
* - These columns are available in all traces regardless of user schema
|
|
6
|
+
* - The `message` column is UNIFIED for span names, log message templates, exception messages, result messages, and feature flag names
|
|
7
|
+
*/
|
|
8
|
+
import type { EagerCategorySchema, LazyBigUint64Schema, LazyCategorySchema, LazyNumberSchema, LazyTextSchema } from '@smoothbricks/arrow-builder';
|
|
9
|
+
import { type DefinedLogSchema } from './defineLogSchema.js';
|
|
10
|
+
import { type Schema } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* System schema field type - explicit type to avoid Sury's internal brand symbol leaking.
|
|
13
|
+
*/
|
|
14
|
+
export interface SystemSchemaFieldTypes extends Record<string, Schema<unknown>> {
|
|
15
|
+
message: EagerCategorySchema;
|
|
16
|
+
line: LazyNumberSchema;
|
|
17
|
+
error_code: LazyCategorySchema;
|
|
18
|
+
retry_attempt: LazyNumberSchema;
|
|
19
|
+
retry_delay_ms: LazyNumberSchema;
|
|
20
|
+
exception_stack: LazyTextSchema;
|
|
21
|
+
ff_value: LazyCategorySchema;
|
|
22
|
+
uint64_value: LazyBigUint64Schema;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Raw system schema fields object.
|
|
26
|
+
* Using explicit type annotation to ensure proper type inference.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* System schema field names - used to filter out system fields when processing user schema
|
|
30
|
+
* These fields are handled separately in Arrow conversion and should not be included
|
|
31
|
+
* in the user attribute columns.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SYSTEM_SCHEMA_FIELD_NAMES: Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Reserved system column names - these correspond to Arrow table columns and cannot be
|
|
36
|
+
* used as user schema field names because they conflict with SpanBuffer properties.
|
|
37
|
+
*/
|
|
38
|
+
export declare const RESERVED_SYSTEM_COLUMN_NAMES: Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Base system schema that all modules inherit.
|
|
41
|
+
* Wrapped with defineLogSchema for validation and extension support.
|
|
42
|
+
*/
|
|
43
|
+
export declare const systemSchema: DefinedLogSchema<SystemSchemaFieldTypes>;
|
|
44
|
+
/**
|
|
45
|
+
* Merge system schema with user schema
|
|
46
|
+
* System columns are always included, user schema extends them
|
|
47
|
+
*
|
|
48
|
+
* Warns if user schema conflicts with system schema fields or reserved column names.
|
|
49
|
+
*/
|
|
50
|
+
export declare function mergeWithSystemSchema<T extends Record<string, unknown>>(userSchema: T): SystemSchemaFieldTypes & T;
|
|
51
|
+
/** Span start event - written at row 0 when a span begins */
|
|
52
|
+
export declare const ENTRY_TYPE_SPAN_START = 1;
|
|
53
|
+
/** Span success completion - written to row 1 via ctx.ok() */
|
|
54
|
+
export declare const ENTRY_TYPE_SPAN_OK = 2;
|
|
55
|
+
/** Span error completion - written to row 1 via ctx.err() */
|
|
56
|
+
export declare const ENTRY_TYPE_SPAN_ERR = 3;
|
|
57
|
+
/** Span exception - written to row 1 when an unhandled exception occurs */
|
|
58
|
+
export declare const ENTRY_TYPE_SPAN_EXCEPTION = 4;
|
|
59
|
+
/** Span retry - written when a transient failure triggers a retry attempt (Phase 19) */
|
|
60
|
+
export declare const ENTRY_TYPE_SPAN_RETRY = 5;
|
|
61
|
+
/** Trace log level entry - via ctx.log.trace() (most verbose) */
|
|
62
|
+
export declare const ENTRY_TYPE_TRACE = 6;
|
|
63
|
+
/** Debug log level entry - via ctx.log.debug() */
|
|
64
|
+
export declare const ENTRY_TYPE_DEBUG = 7;
|
|
65
|
+
/** Info log level entry - via ctx.log.info() */
|
|
66
|
+
export declare const ENTRY_TYPE_INFO = 8;
|
|
67
|
+
/** Warning log level entry - via ctx.log.warn() */
|
|
68
|
+
export declare const ENTRY_TYPE_WARN = 9;
|
|
69
|
+
/** Error log level entry - via ctx.log.error() */
|
|
70
|
+
export declare const ENTRY_TYPE_ERROR = 10;
|
|
71
|
+
/** Feature flag access event - logged when a flag value is first read in a span */
|
|
72
|
+
export declare const ENTRY_TYPE_FF_ACCESS = 11;
|
|
73
|
+
/** Feature flag usage event - logged when a flag influences a code path decision */
|
|
74
|
+
export declare const ENTRY_TYPE_FF_USAGE = 12;
|
|
75
|
+
/** Period start marker - written at the beginning of each metrics collection period */
|
|
76
|
+
export declare const ENTRY_TYPE_PERIOD_START = 13;
|
|
77
|
+
/** Op invocations counter - total calls to this operation */
|
|
78
|
+
export declare const ENTRY_TYPE_OP_INVOCATIONS = 14;
|
|
79
|
+
/** Op errors counter - calls that returned err() */
|
|
80
|
+
export declare const ENTRY_TYPE_OP_ERRORS = 15;
|
|
81
|
+
/** Op exceptions counter - calls that threw unhandled exceptions */
|
|
82
|
+
export declare const ENTRY_TYPE_OP_EXCEPTIONS = 16;
|
|
83
|
+
/** Op duration total - sum of all invocation durations (ms) */
|
|
84
|
+
export declare const ENTRY_TYPE_OP_DURATION_TOTAL = 17;
|
|
85
|
+
/** Op duration ok - sum of successful invocation durations (ms) */
|
|
86
|
+
export declare const ENTRY_TYPE_OP_DURATION_OK = 18;
|
|
87
|
+
/** Op duration err - sum of error invocation durations (ms) */
|
|
88
|
+
export declare const ENTRY_TYPE_OP_DURATION_ERR = 19;
|
|
89
|
+
/** Op duration min - minimum invocation duration (ms) */
|
|
90
|
+
export declare const ENTRY_TYPE_OP_DURATION_MIN = 20;
|
|
91
|
+
/** Op duration max - maximum invocation duration (ms) */
|
|
92
|
+
export declare const ENTRY_TYPE_OP_DURATION_MAX = 21;
|
|
93
|
+
/** Buffer writes counter - total writes across all buffers */
|
|
94
|
+
export declare const ENTRY_TYPE_BUFFER_WRITES = 22;
|
|
95
|
+
/** Buffer spans counter - number of spans created (non-overflow buffers) */
|
|
96
|
+
export declare const ENTRY_TYPE_BUFFER_SPANS = 23;
|
|
97
|
+
/** Buffer capacity - current buffer capacity for this module */
|
|
98
|
+
export declare const ENTRY_TYPE_BUFFER_CAPACITY = 24;
|
|
99
|
+
/**
|
|
100
|
+
* Human-readable names for entry types, indexed by entry type code.
|
|
101
|
+
*
|
|
102
|
+
* Used for Arrow dictionary encoding and display purposes.
|
|
103
|
+
* Index 0 is unused (entry types start at 1).
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const entryType = buffer.entry_type[index];
|
|
108
|
+
* const typeName = ENTRY_TYPE_NAMES[entryType]; // e.g., 'span-ok'
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare const ENTRY_TYPE_NAMES: readonly ["", "span-start", "span-ok", "span-err", "span-exception", "span-retry", "trace", "debug", "info", "warn", "error", "ff-access", "ff-usage", "period-start", "op-invocations", "op-errors", "op-exceptions", "op-duration-total", "op-duration-ok", "op-duration-err", "op-duration-min", "op-duration-max", "buffer-writes", "buffer-spans", "buffer-capacity"];
|
|
112
|
+
//# sourceMappingURL=systemSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemSchema.d.ts","sourceRoot":"","sources":["../../../src/lib/schema/systemSchema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAa,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7E,OAAO,EAAE,mBAAmB,CAAC;IAC7B,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,aAAa,EAAE,gBAAgB,CAAC;IAChC,cAAc,EAAE,gBAAgB,CAAC;IACjC,eAAe,EAAE,cAAc,CAAC;IAChC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAaD;;;GAGG;AACH;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,aASpC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,4BAA4B,aASvC,CAAC;AAoEH;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,sBAAsB,CAIjE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,sBAAsB,GAAG,CAAC,CA0ClH;AAaD,6DAA6D;AAC7D,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,gDAAgD;AAChD,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,mDAAmD;AACnD,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,oFAAoF;AACpF,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAMtC,uFAAuF;AACvF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAM1C,6DAA6D;AAC7D,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,oDAAoD;AACpD,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,+DAA+D;AAC/D,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C,mEAAmE;AACnE,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,+DAA+D;AAC/D,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,yDAAyD;AACzD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,yDAAyD;AACzD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAM7C,8DAA8D;AAC9D,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,gEAAgE;AAChE,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,4WA0BnB,CAAC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { S as ArrowS } from '@smoothbricks/arrow-builder';
|
|
2
|
+
import { defineLogSchema } from './defineLogSchema.js';
|
|
3
|
+
import { LogSchema } from './types.js';
|
|
4
|
+
// Use arrow-builder's S directly (not lmao's wrapped version) to get clean types
|
|
5
|
+
// that don't include the flag builder methods - this avoids type inference issues.
|
|
6
|
+
const messageSchema = ArrowS.category().eager();
|
|
7
|
+
const lineSchema = ArrowS.number();
|
|
8
|
+
const errorCodeSchema = ArrowS.category();
|
|
9
|
+
const retryAttemptSchema = ArrowS.number();
|
|
10
|
+
const retryDelayMsSchema = ArrowS.number();
|
|
11
|
+
const exceptionStackSchema = ArrowS.text();
|
|
12
|
+
const ffValueSchema = ArrowS.category();
|
|
13
|
+
const uint64ValueSchema = ArrowS.bigUint64();
|
|
14
|
+
/**
|
|
15
|
+
* Raw system schema fields object.
|
|
16
|
+
* Using explicit type annotation to ensure proper type inference.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* System schema field names - used to filter out system fields when processing user schema
|
|
20
|
+
* These fields are handled separately in Arrow conversion and should not be included
|
|
21
|
+
* in the user attribute columns.
|
|
22
|
+
*/
|
|
23
|
+
export const SYSTEM_SCHEMA_FIELD_NAMES = new Set([
|
|
24
|
+
'message',
|
|
25
|
+
'line',
|
|
26
|
+
'error_code',
|
|
27
|
+
'retry_attempt',
|
|
28
|
+
'retry_delay_ms',
|
|
29
|
+
'exception_stack',
|
|
30
|
+
'ff_value',
|
|
31
|
+
'uint64_value',
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* Reserved system column names - these correspond to Arrow table columns and cannot be
|
|
35
|
+
* used as user schema field names because they conflict with SpanBuffer properties.
|
|
36
|
+
*/
|
|
37
|
+
export const RESERVED_SYSTEM_COLUMN_NAMES = new Set([
|
|
38
|
+
// Arrow table columns (exact names)
|
|
39
|
+
'trace_id',
|
|
40
|
+
'thread_id',
|
|
41
|
+
'span_id',
|
|
42
|
+
'parent_thread_id',
|
|
43
|
+
'parent_span_id',
|
|
44
|
+
'timestamp',
|
|
45
|
+
'entry_type',
|
|
46
|
+
]);
|
|
47
|
+
const systemSchemaFields = {
|
|
48
|
+
/**
|
|
49
|
+
* Unified message column - serves different purposes based on entry type.
|
|
50
|
+
*
|
|
51
|
+
* Per specs/lmao/01h_entry_types_and_logging_primitives.md:
|
|
52
|
+
* - span-start, span-ok, span-err: Span name (e.g., 'create-user')
|
|
53
|
+
* - span-exception: Exception message (e.g., 'Connection timeout')
|
|
54
|
+
* - info, debug, warn, error, trace: Log message TEMPLATE (e.g., 'User ${userId} created')
|
|
55
|
+
* - ff-access, ff-usage: Feature flag name (e.g., 'darkMode')
|
|
56
|
+
* - tag: Span name (same as span lifecycle entries)
|
|
57
|
+
*
|
|
58
|
+
* Uses S.category().eager() because:
|
|
59
|
+
* - Message is ALWAYS written for every entry type (span name, log message, etc.)
|
|
60
|
+
* - Eager allocation eliminates null bitmap overhead (never null)
|
|
61
|
+
* - Span names repeat across many traces
|
|
62
|
+
* - Log templates repeat (only values differ)
|
|
63
|
+
* - Flag names repeat across evaluations
|
|
64
|
+
* - Exception messages often repeat (same error types)
|
|
65
|
+
* - String interning provides excellent compression
|
|
66
|
+
*
|
|
67
|
+
* NOTE: Log messages are FORMAT STRINGS, NOT interpolated! The template is stored
|
|
68
|
+
* verbatim, and values go in their own typed columns for queryability.
|
|
69
|
+
*/
|
|
70
|
+
message: messageSchema,
|
|
71
|
+
/**
|
|
72
|
+
* Source code line number for this entry.
|
|
73
|
+
*
|
|
74
|
+
* Per specs/lmao/01c_context_flow_and_op_wrappers.md "Line Number System":
|
|
75
|
+
* - Uint16 column (max 65535 lines per file)
|
|
76
|
+
* - TypeScript transformer injects line numbers at compile time
|
|
77
|
+
* - No runtime overhead - just a method call with literal number
|
|
78
|
+
* - Value of 0 means "line number not set"
|
|
79
|
+
*
|
|
80
|
+
* Used for:
|
|
81
|
+
* - Linking trace entries back to source code
|
|
82
|
+
* - Debugging and error analysis
|
|
83
|
+
* - IDE integration for "jump to line"
|
|
84
|
+
*/
|
|
85
|
+
line: lineSchema,
|
|
86
|
+
// Error handling
|
|
87
|
+
error_code: errorCodeSchema,
|
|
88
|
+
retry_attempt: retryAttemptSchema,
|
|
89
|
+
retry_delay_ms: retryDelayMsSchema,
|
|
90
|
+
exception_stack: exceptionStackSchema,
|
|
91
|
+
// Feature flags (ffName is now part of unified `message` column)
|
|
92
|
+
ff_value: ffValueSchema, // Can be boolean, string, or number as string
|
|
93
|
+
/**
|
|
94
|
+
* uint64 value column for metrics and user .uint64() API.
|
|
95
|
+
*
|
|
96
|
+
* Per specs/lmao/01f_arrow_table_structure.md:
|
|
97
|
+
* - Metric values (counts, durations in nanoseconds)
|
|
98
|
+
* - User large integers via .uint64() fluent method
|
|
99
|
+
* - Sparse data (only rows that need uint64)
|
|
100
|
+
*
|
|
101
|
+
* Uses S.bigUint64() (lazy BigUint64Array) because:
|
|
102
|
+
* - Most trace rows don't have a uint64 value
|
|
103
|
+
* - Only metrics rows and entries where .uint64() is called
|
|
104
|
+
* - Zero overhead for rows that don't use it
|
|
105
|
+
*/
|
|
106
|
+
uint64_value: uint64ValueSchema,
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Base system schema that all modules inherit.
|
|
110
|
+
* Wrapped with defineLogSchema for validation and extension support.
|
|
111
|
+
*/
|
|
112
|
+
export const systemSchema = defineLogSchema(systemSchemaFields,
|
|
113
|
+
// Skip reserved name validation for system schema - `message` is a system column
|
|
114
|
+
{ _skipReservedNameValidation: true });
|
|
115
|
+
/**
|
|
116
|
+
* Merge system schema with user schema
|
|
117
|
+
* System columns are always included, user schema extends them
|
|
118
|
+
*
|
|
119
|
+
* Warns if user schema conflicts with system schema fields or reserved column names.
|
|
120
|
+
*/
|
|
121
|
+
export function mergeWithSystemSchema(userSchema) {
|
|
122
|
+
// Check for conflicts between user schema and system schema
|
|
123
|
+
// Use fieldNames to get only actual field names, not ColumnSchema properties or methods
|
|
124
|
+
const systemKeys = new Set(systemSchema._columnNames);
|
|
125
|
+
const reservedKeys = RESERVED_SYSTEM_COLUMN_NAMES;
|
|
126
|
+
const userKeys = userSchema instanceof LogSchema ? userSchema._columnNames : Object.keys(userSchema);
|
|
127
|
+
const userFields = userSchema instanceof LogSchema ? userSchema.fields : userSchema;
|
|
128
|
+
const conflictingSystemKeys = userKeys.filter((key) => {
|
|
129
|
+
// Only check if it's a schema field (not a method like validate/parse/extend)
|
|
130
|
+
const value = userFields[key];
|
|
131
|
+
return systemKeys.has(key) && typeof value !== 'function';
|
|
132
|
+
});
|
|
133
|
+
const conflictingReservedKeys = userKeys.filter((key) => {
|
|
134
|
+
const value = userFields[key];
|
|
135
|
+
return reservedKeys.has(key) && typeof value !== 'function';
|
|
136
|
+
});
|
|
137
|
+
if (conflictingSystemKeys.length > 0) {
|
|
138
|
+
throw new Error(`User schema conflicts with system schema fields: ${conflictingSystemKeys.join(', ')}\n` +
|
|
139
|
+
'System schema fields are reserved and cannot be overridden.\n' +
|
|
140
|
+
`System fields: ${Array.from(systemKeys).join(', ')}`);
|
|
141
|
+
}
|
|
142
|
+
if (conflictingReservedKeys.length > 0) {
|
|
143
|
+
throw new Error(`User schema cannot include reserved system column names: ${conflictingReservedKeys.join(', ')}\n` +
|
|
144
|
+
' These names conflict with SpanBuffer properties that correspond to Arrow table columns.\n' +
|
|
145
|
+
` Reserved names: ${Array.from(reservedKeys).join(', ')}`);
|
|
146
|
+
}
|
|
147
|
+
// Spread .fields to get the actual schema field definitions
|
|
148
|
+
// (spreading systemSchema directly would spread class instance properties like _fieldNames, not schema fields)
|
|
149
|
+
const merged = {
|
|
150
|
+
...systemSchema.fields,
|
|
151
|
+
...userFields,
|
|
152
|
+
};
|
|
153
|
+
return merged;
|
|
154
|
+
}
|
|
155
|
+
// =============================================================================
|
|
156
|
+
// Entry Type Constants
|
|
157
|
+
// =============================================================================
|
|
158
|
+
// Per specs/lmao/01h_entry_types_and_logging_primitives.md
|
|
159
|
+
// Stored in Uint8Array for 1-byte storage per entry.
|
|
160
|
+
// Ordered by frequency/importance:
|
|
161
|
+
// 1-4: Span lifecycle (most common - every span has start + end)
|
|
162
|
+
// 5-9: Logging levels (ordered by verbosity: trace < debug < info < warn < error)
|
|
163
|
+
// 10-11: Feature flags (least common)
|
|
164
|
+
// =============================================================================
|
|
165
|
+
/** Span start event - written at row 0 when a span begins */
|
|
166
|
+
export const ENTRY_TYPE_SPAN_START = 1;
|
|
167
|
+
/** Span success completion - written to row 1 via ctx.ok() */
|
|
168
|
+
export const ENTRY_TYPE_SPAN_OK = 2;
|
|
169
|
+
/** Span error completion - written to row 1 via ctx.err() */
|
|
170
|
+
export const ENTRY_TYPE_SPAN_ERR = 3;
|
|
171
|
+
/** Span exception - written to row 1 when an unhandled exception occurs */
|
|
172
|
+
export const ENTRY_TYPE_SPAN_EXCEPTION = 4;
|
|
173
|
+
/** Span retry - written when a transient failure triggers a retry attempt (Phase 19) */
|
|
174
|
+
export const ENTRY_TYPE_SPAN_RETRY = 5;
|
|
175
|
+
/** Trace log level entry - via ctx.log.trace() (most verbose) */
|
|
176
|
+
export const ENTRY_TYPE_TRACE = 6;
|
|
177
|
+
/** Debug log level entry - via ctx.log.debug() */
|
|
178
|
+
export const ENTRY_TYPE_DEBUG = 7;
|
|
179
|
+
/** Info log level entry - via ctx.log.info() */
|
|
180
|
+
export const ENTRY_TYPE_INFO = 8;
|
|
181
|
+
/** Warning log level entry - via ctx.log.warn() */
|
|
182
|
+
export const ENTRY_TYPE_WARN = 9;
|
|
183
|
+
/** Error log level entry - via ctx.log.error() */
|
|
184
|
+
export const ENTRY_TYPE_ERROR = 10;
|
|
185
|
+
/** Feature flag access event - logged when a flag value is first read in a span */
|
|
186
|
+
export const ENTRY_TYPE_FF_ACCESS = 11;
|
|
187
|
+
/** Feature flag usage event - logged when a flag influences a code path decision */
|
|
188
|
+
export const ENTRY_TYPE_FF_USAGE = 12;
|
|
189
|
+
// =============================================================================
|
|
190
|
+
// Period Markers
|
|
191
|
+
// =============================================================================
|
|
192
|
+
/** Period start marker - written at the beginning of each metrics collection period */
|
|
193
|
+
export const ENTRY_TYPE_PERIOD_START = 13;
|
|
194
|
+
// =============================================================================
|
|
195
|
+
// Op Metrics (per specs/lmao/01n_op_and_buffer_metrics.md)
|
|
196
|
+
// =============================================================================
|
|
197
|
+
/** Op invocations counter - total calls to this operation */
|
|
198
|
+
export const ENTRY_TYPE_OP_INVOCATIONS = 14;
|
|
199
|
+
/** Op errors counter - calls that returned err() */
|
|
200
|
+
export const ENTRY_TYPE_OP_ERRORS = 15;
|
|
201
|
+
/** Op exceptions counter - calls that threw unhandled exceptions */
|
|
202
|
+
export const ENTRY_TYPE_OP_EXCEPTIONS = 16;
|
|
203
|
+
/** Op duration total - sum of all invocation durations (ms) */
|
|
204
|
+
export const ENTRY_TYPE_OP_DURATION_TOTAL = 17;
|
|
205
|
+
/** Op duration ok - sum of successful invocation durations (ms) */
|
|
206
|
+
export const ENTRY_TYPE_OP_DURATION_OK = 18;
|
|
207
|
+
/** Op duration err - sum of error invocation durations (ms) */
|
|
208
|
+
export const ENTRY_TYPE_OP_DURATION_ERR = 19;
|
|
209
|
+
/** Op duration min - minimum invocation duration (ms) */
|
|
210
|
+
export const ENTRY_TYPE_OP_DURATION_MIN = 20;
|
|
211
|
+
/** Op duration max - maximum invocation duration (ms) */
|
|
212
|
+
export const ENTRY_TYPE_OP_DURATION_MAX = 21;
|
|
213
|
+
// =============================================================================
|
|
214
|
+
// Buffer Metrics (utilization-based capacity tuning)
|
|
215
|
+
// =============================================================================
|
|
216
|
+
/** Buffer writes counter - total writes across all buffers */
|
|
217
|
+
export const ENTRY_TYPE_BUFFER_WRITES = 22;
|
|
218
|
+
/** Buffer spans counter - number of spans created (non-overflow buffers) */
|
|
219
|
+
export const ENTRY_TYPE_BUFFER_SPANS = 23;
|
|
220
|
+
/** Buffer capacity - current buffer capacity for this module */
|
|
221
|
+
export const ENTRY_TYPE_BUFFER_CAPACITY = 24;
|
|
222
|
+
/**
|
|
223
|
+
* Human-readable names for entry types, indexed by entry type code.
|
|
224
|
+
*
|
|
225
|
+
* Used for Arrow dictionary encoding and display purposes.
|
|
226
|
+
* Index 0 is unused (entry types start at 1).
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* const entryType = buffer.entry_type[index];
|
|
231
|
+
* const typeName = ENTRY_TYPE_NAMES[entryType]; // e.g., 'span-ok'
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export const ENTRY_TYPE_NAMES = [
|
|
235
|
+
'', // 0 - unused
|
|
236
|
+
'span-start', // 1
|
|
237
|
+
'span-ok', // 2
|
|
238
|
+
'span-err', // 3
|
|
239
|
+
'span-exception', // 4
|
|
240
|
+
'span-retry', // 5 (Phase 19 - transient failure retry)
|
|
241
|
+
'trace', // 6 (most verbose)
|
|
242
|
+
'debug', // 7
|
|
243
|
+
'info', // 8
|
|
244
|
+
'warn', // 9
|
|
245
|
+
'error', // 10
|
|
246
|
+
'ff-access', // 11
|
|
247
|
+
'ff-usage', // 12
|
|
248
|
+
'period-start', // 13
|
|
249
|
+
'op-invocations', // 14
|
|
250
|
+
'op-errors', // 15
|
|
251
|
+
'op-exceptions', // 16
|
|
252
|
+
'op-duration-total', // 17
|
|
253
|
+
'op-duration-ok', // 18
|
|
254
|
+
'op-duration-err', // 19
|
|
255
|
+
'op-duration-min', // 20
|
|
256
|
+
'op-duration-max', // 21
|
|
257
|
+
'buffer-writes', // 22
|
|
258
|
+
'buffer-spans', // 23
|
|
259
|
+
'buffer-capacity', // 24
|
|
260
|
+
];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard functions for runtime type checking
|
|
3
|
+
*
|
|
4
|
+
* Re-exports schema type guards from arrow-builder and adds lmao-specific guards.
|
|
5
|
+
*/
|
|
6
|
+
export { getBinaryEncoder, getEnumUtf8, getEnumValues, getSchemaType, isEnumSchema, isSchemaWithMetadata, } from '@smoothbricks/arrow-builder';
|
|
7
|
+
import type { EvaluationContext, UsageContext } from './defineFeatureFlags.js';
|
|
8
|
+
import type { FeatureFlagDefinition } from './types.js';
|
|
9
|
+
/** Narrow unknown to Record<string, unknown> — non-null object with string-keyed access. */
|
|
10
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Type guard to check if a value is a FeatureFlagDefinition
|
|
13
|
+
*/
|
|
14
|
+
export declare function isFeatureFlagDefinition(value: unknown): value is FeatureFlagDefinition<string | number | boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a value is a valid EvaluationContext
|
|
17
|
+
*/
|
|
18
|
+
export declare function isEvaluationContext(value: unknown): value is EvaluationContext;
|
|
19
|
+
/**
|
|
20
|
+
* Type guard to check if a value is a valid UsageContext
|
|
21
|
+
*/
|
|
22
|
+
export declare function isUsageContext(value: unknown): value is UsageContext;
|
|
23
|
+
/**
|
|
24
|
+
* Type guard to check if a value is a string
|
|
25
|
+
* Useful for narrowing unknown types in safe contexts
|
|
26
|
+
*/
|
|
27
|
+
export declare function isString(value: unknown): value is string;
|
|
28
|
+
/**
|
|
29
|
+
* Type guard to check if a value is a number
|
|
30
|
+
* Useful for narrowing unknown types in safe contexts
|
|
31
|
+
*/
|
|
32
|
+
export declare function isNumber(value: unknown): value is number;
|
|
33
|
+
/**
|
|
34
|
+
* Type guard to check if a value is a boolean
|
|
35
|
+
* Useful for narrowing unknown types in safe contexts
|
|
36
|
+
*/
|
|
37
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Type guard to check if a value is a primitive type (string | number | boolean)
|
|
40
|
+
* Useful for validating feature flag values and tag attributes
|
|
41
|
+
*/
|
|
42
|
+
export declare function isPrimitive(value: unknown): value is string | number | boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Type guard to check if a value is a plain object (not array, not null)
|
|
45
|
+
*/
|
|
46
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* Type guard to check if a value is a valid record with primitive values
|
|
49
|
+
* Useful for validating tag attribute objects
|
|
50
|
+
*/
|
|
51
|
+
export declare function isRecordOfPrimitives(value: unknown): value is Record<string, string | number | boolean>;
|
|
52
|
+
//# sourceMappingURL=typeGuards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../../src/lib/schema/typeGuards.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,4FAA4F;AAC5F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAWjH;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAe9E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAqCpE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM,GAAG,OAAO,CAE9E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAO9E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAYvG"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard functions for runtime type checking
|
|
3
|
+
*
|
|
4
|
+
* Re-exports schema type guards from arrow-builder and adds lmao-specific guards.
|
|
5
|
+
*/
|
|
6
|
+
// Re-export schema type guards from arrow-builder
|
|
7
|
+
export { getBinaryEncoder, getEnumUtf8, getEnumValues, getSchemaType, isEnumSchema, isSchemaWithMetadata, } from '@smoothbricks/arrow-builder';
|
|
8
|
+
/** Narrow unknown to Record<string, unknown> — non-null object with string-keyed access. */
|
|
9
|
+
export function isRecord(value) {
|
|
10
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to check if a value is a FeatureFlagDefinition
|
|
14
|
+
*/
|
|
15
|
+
export function isFeatureFlagDefinition(value) {
|
|
16
|
+
if (!isRecord(value)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return ('schema' in value &&
|
|
20
|
+
'defaultValue' in value &&
|
|
21
|
+
'evaluationType' in value &&
|
|
22
|
+
(value.evaluationType === 'sync' || value.evaluationType === 'async'));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Type guard to check if a value is a valid EvaluationContext
|
|
26
|
+
*/
|
|
27
|
+
export function isEvaluationContext(value) {
|
|
28
|
+
if (!isRecord(value)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// EvaluationContext can have various string/number/boolean properties
|
|
32
|
+
// Check that all values are of valid types
|
|
33
|
+
for (const key in value) {
|
|
34
|
+
const val = value[key];
|
|
35
|
+
if (val !== undefined && typeof val !== 'string' && typeof val !== 'number' && typeof val !== 'boolean') {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Type guard to check if a value is a valid UsageContext
|
|
43
|
+
*/
|
|
44
|
+
export function isUsageContext(value) {
|
|
45
|
+
if (!isRecord(value)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// Check action property if present
|
|
49
|
+
if ('action' in value && typeof value.action !== 'string' && value.action !== undefined) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
// Check outcome property if present
|
|
53
|
+
if ('outcome' in value && value.outcome !== undefined && value.outcome !== 'success' && value.outcome !== 'failure') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// Check value property if present
|
|
57
|
+
if ('value' in value && typeof value.value !== 'number' && value.value !== undefined) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
// Check metadata property if present
|
|
61
|
+
if ('metadata' in value && value.metadata !== undefined) {
|
|
62
|
+
if (!isRecord(value.metadata)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// Validate metadata values
|
|
66
|
+
const metadata = value.metadata;
|
|
67
|
+
for (const key in metadata) {
|
|
68
|
+
const val = metadata[key];
|
|
69
|
+
if (typeof val !== 'string' && typeof val !== 'number' && typeof val !== 'boolean') {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Type guard to check if a value is a string
|
|
78
|
+
* Useful for narrowing unknown types in safe contexts
|
|
79
|
+
*/
|
|
80
|
+
export function isString(value) {
|
|
81
|
+
return typeof value === 'string';
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Type guard to check if a value is a number
|
|
85
|
+
* Useful for narrowing unknown types in safe contexts
|
|
86
|
+
*/
|
|
87
|
+
export function isNumber(value) {
|
|
88
|
+
return typeof value === 'number' && !Number.isNaN(value);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Type guard to check if a value is a boolean
|
|
92
|
+
* Useful for narrowing unknown types in safe contexts
|
|
93
|
+
*/
|
|
94
|
+
export function isBoolean(value) {
|
|
95
|
+
return typeof value === 'boolean';
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Type guard to check if a value is a primitive type (string | number | boolean)
|
|
99
|
+
* Useful for validating feature flag values and tag attributes
|
|
100
|
+
*/
|
|
101
|
+
export function isPrimitive(value) {
|
|
102
|
+
return isString(value) || isNumber(value) || isBoolean(value);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Type guard to check if a value is a plain object (not array, not null)
|
|
106
|
+
*/
|
|
107
|
+
export function isPlainObject(value) {
|
|
108
|
+
return (typeof value === 'object' &&
|
|
109
|
+
value !== null &&
|
|
110
|
+
!Array.isArray(value) &&
|
|
111
|
+
Object.getPrototypeOf(value) === Object.prototype);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Type guard to check if a value is a valid record with primitive values
|
|
115
|
+
* Useful for validating tag attribute objects
|
|
116
|
+
*/
|
|
117
|
+
export function isRecordOfPrimitives(value) {
|
|
118
|
+
if (!isPlainObject(value)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
for (const key in value) {
|
|
122
|
+
if (!isPrimitive(value[key])) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|