@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,439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effective Schema Computation Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests verify that defineOpContext properly computes the effective schema
|
|
5
|
+
* by combining the app's schema with all dep contributed schemas:
|
|
6
|
+
* - OpGroup deps contribute their original schema fields
|
|
7
|
+
* - MappedOpGroup deps contribute their transformed fields (after prefix/mapping)
|
|
8
|
+
* - Null-mapped columns are dropped
|
|
9
|
+
* - Conflict detection works (same column from multiple deps throws)
|
|
10
|
+
* - Schema is accessible via OpContextFactory.logSchema
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, expect, it } from 'bun:test';
|
|
14
|
+
import { defineOpContext } from '../defineOpContext.js';
|
|
15
|
+
import { S } from '../schema/builder.js';
|
|
16
|
+
import { defineLogSchema } from '../schema/defineLogSchema.js';
|
|
17
|
+
|
|
18
|
+
describe('Effective Schema Computation', () => {
|
|
19
|
+
describe('No Dependencies', () => {
|
|
20
|
+
it('should return app schema when no deps', () => {
|
|
21
|
+
const appSchema = defineLogSchema({
|
|
22
|
+
userId: S.category(),
|
|
23
|
+
endpoint: S.text(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const context = defineOpContext({
|
|
27
|
+
logSchema: appSchema,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(context.logSchema._columnNames).toEqual(['userId', 'endpoint']);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('Single Dependency', () => {
|
|
35
|
+
it('should combine app schema + unprefixed dep schema', () => {
|
|
36
|
+
// Define library
|
|
37
|
+
const httpSchema = defineLogSchema({
|
|
38
|
+
status: S.number(),
|
|
39
|
+
method: S.enum(['GET', 'POST'] as const),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const httpContext = defineOpContext({
|
|
43
|
+
logSchema: httpSchema,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const httpOps = httpContext.defineOps({
|
|
47
|
+
fetch: async (ctx) => ctx.ok({ data: 'ok' }),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Define app using library (no prefix)
|
|
51
|
+
const appSchema = defineLogSchema({
|
|
52
|
+
userId: S.category(),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const appContext = defineOpContext({
|
|
56
|
+
logSchema: appSchema,
|
|
57
|
+
deps: {
|
|
58
|
+
http: httpOps, // No prefix - contributes original fields
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Should have all fields from both schemas
|
|
63
|
+
expect(appContext.logSchema._columnNames).toContain('userId');
|
|
64
|
+
expect(appContext.logSchema._columnNames).toContain('status');
|
|
65
|
+
expect(appContext.logSchema._columnNames).toContain('method');
|
|
66
|
+
expect(appContext.logSchema._columnNames.length).toBe(3);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should combine app schema + prefixed dep schema', () => {
|
|
70
|
+
// Define library
|
|
71
|
+
const httpSchema = defineLogSchema({
|
|
72
|
+
status: S.number(),
|
|
73
|
+
method: S.enum(['GET', 'POST'] as const),
|
|
74
|
+
url: S.text(),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const httpContext = defineOpContext({
|
|
78
|
+
logSchema: httpSchema,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const httpOps = httpContext.defineOps({
|
|
82
|
+
fetch: async (ctx) => ctx.ok({ data: 'ok' }),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Define app using library with prefix
|
|
86
|
+
const appSchema = defineLogSchema({
|
|
87
|
+
userId: S.category(),
|
|
88
|
+
endpoint: S.text(),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const appContext = defineOpContext({
|
|
92
|
+
logSchema: appSchema,
|
|
93
|
+
deps: {
|
|
94
|
+
http: httpOps.prefix('http'),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Should have app fields + prefixed library fields
|
|
99
|
+
expect(appContext.logSchema._columnNames).toContain('userId');
|
|
100
|
+
expect(appContext.logSchema._columnNames).toContain('endpoint');
|
|
101
|
+
expect(appContext.logSchema._columnNames).toContain('http_status');
|
|
102
|
+
expect(appContext.logSchema._columnNames).toContain('http_method');
|
|
103
|
+
expect(appContext.logSchema._columnNames).toContain('http_url');
|
|
104
|
+
expect(appContext.logSchema._columnNames.length).toBe(5);
|
|
105
|
+
|
|
106
|
+
// Should NOT have unprefixed library fields
|
|
107
|
+
expect(appContext.logSchema._columnNames).not.toContain('status');
|
|
108
|
+
expect(appContext.logSchema._columnNames).not.toContain('method');
|
|
109
|
+
expect(appContext.logSchema._columnNames).not.toContain('url');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('Multiple Dependencies', () => {
|
|
114
|
+
it('should combine app schema + multiple prefixed deps', () => {
|
|
115
|
+
// Define HTTP library
|
|
116
|
+
const httpSchema = defineLogSchema({
|
|
117
|
+
status: S.number(),
|
|
118
|
+
method: S.enum(['GET', 'POST'] as const),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const httpContext = defineOpContext({
|
|
122
|
+
logSchema: httpSchema,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const httpOps = httpContext.defineOps({
|
|
126
|
+
fetch: async (ctx) => ctx.ok({ data: 'ok' }),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Define DB library
|
|
130
|
+
const dbSchema = defineLogSchema({
|
|
131
|
+
query: S.text(),
|
|
132
|
+
duration: S.number(),
|
|
133
|
+
rows: S.number(),
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const dbContext = defineOpContext({
|
|
137
|
+
logSchema: dbSchema,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const dbOps = dbContext.defineOps({
|
|
141
|
+
execute: async (ctx) => ctx.ok({ rows: 0 }),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Define app using both libraries
|
|
145
|
+
const appSchema = defineLogSchema({
|
|
146
|
+
userId: S.category(),
|
|
147
|
+
endpoint: S.text(),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const appContext = defineOpContext({
|
|
151
|
+
logSchema: appSchema,
|
|
152
|
+
deps: {
|
|
153
|
+
http: httpOps.prefix('http'),
|
|
154
|
+
db: dbOps.prefix('db'),
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Should have app fields
|
|
159
|
+
expect(appContext.logSchema._columnNames).toContain('userId');
|
|
160
|
+
expect(appContext.logSchema._columnNames).toContain('endpoint');
|
|
161
|
+
|
|
162
|
+
// Should have HTTP fields with prefix
|
|
163
|
+
expect(appContext.logSchema._columnNames).toContain('http_status');
|
|
164
|
+
expect(appContext.logSchema._columnNames).toContain('http_method');
|
|
165
|
+
|
|
166
|
+
// Should have DB fields with prefix
|
|
167
|
+
expect(appContext.logSchema._columnNames).toContain('db_query');
|
|
168
|
+
expect(appContext.logSchema._columnNames).toContain('db_duration');
|
|
169
|
+
expect(appContext.logSchema._columnNames).toContain('db_rows');
|
|
170
|
+
|
|
171
|
+
expect(appContext.logSchema._columnNames.length).toBe(7);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should handle mixed prefixed and unprefixed deps', () => {
|
|
175
|
+
// Define retry library
|
|
176
|
+
const retrySchema = defineLogSchema({
|
|
177
|
+
attempt: S.number(),
|
|
178
|
+
delay: S.number(),
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const retryContext = defineOpContext({
|
|
182
|
+
logSchema: retrySchema,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const retryOps = retryContext.defineOps({
|
|
186
|
+
withRetry: async (ctx) => ctx.ok({}),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Define HTTP library
|
|
190
|
+
const httpSchema = defineLogSchema({
|
|
191
|
+
status: S.number(),
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const httpContext = defineOpContext({
|
|
195
|
+
logSchema: httpSchema,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const httpOps = httpContext.defineOps({
|
|
199
|
+
fetch: async (ctx) => ctx.ok({}),
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// Define app
|
|
203
|
+
const appSchema = defineLogSchema({
|
|
204
|
+
userId: S.category(),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const appContext = defineOpContext({
|
|
208
|
+
logSchema: appSchema,
|
|
209
|
+
deps: {
|
|
210
|
+
retry: retryOps, // No prefix
|
|
211
|
+
http: httpOps.prefix('http'),
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Should have all fields
|
|
216
|
+
expect(appContext.logSchema._columnNames).toContain('userId');
|
|
217
|
+
expect(appContext.logSchema._columnNames).toContain('attempt'); // unprefixed
|
|
218
|
+
expect(appContext.logSchema._columnNames).toContain('delay'); // unprefixed
|
|
219
|
+
expect(appContext.logSchema._columnNames).toContain('http_status'); // prefixed
|
|
220
|
+
expect(appContext.logSchema._columnNames.length).toBe(4);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
describe('Column Mapping', () => {
|
|
225
|
+
it('should drop null-mapped columns', () => {
|
|
226
|
+
// Define library with debug column
|
|
227
|
+
const libSchema = defineLogSchema({
|
|
228
|
+
publicData: S.text(),
|
|
229
|
+
debugFlag: S.number(),
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const libContext = defineOpContext({
|
|
233
|
+
logSchema: libSchema,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const libOps = libContext.defineOps({
|
|
237
|
+
doWork: async (ctx) => ctx.ok({}),
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Define app that drops debug column
|
|
241
|
+
const appSchema = defineLogSchema({
|
|
242
|
+
userId: S.category(),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const appContext = defineOpContext({
|
|
246
|
+
logSchema: appSchema,
|
|
247
|
+
deps: {
|
|
248
|
+
lib: libOps.mapColumns({ publicData: 'lib_data', debugFlag: null }),
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// Should have userId + lib_data, but NOT debugFlag
|
|
253
|
+
expect(appContext.logSchema._columnNames).toContain('userId');
|
|
254
|
+
expect(appContext.logSchema._columnNames).toContain('lib_data');
|
|
255
|
+
expect(appContext.logSchema._columnNames).not.toContain('debugFlag');
|
|
256
|
+
expect(appContext.logSchema._columnNames).not.toContain('publicData'); // renamed to lib_data
|
|
257
|
+
expect(appContext.logSchema._columnNames.length).toBe(2);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
describe('Conflict Detection', () => {
|
|
262
|
+
it('should throw when deps contribute conflicting column names', () => {
|
|
263
|
+
// Define two libraries with same column name
|
|
264
|
+
const lib1Schema = defineLogSchema({
|
|
265
|
+
status: S.number(),
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const lib1Context = defineOpContext({
|
|
269
|
+
logSchema: lib1Schema,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const lib1Ops = lib1Context.defineOps({
|
|
273
|
+
op1: async (ctx) => ctx.ok({}),
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
const lib2Schema = defineLogSchema({
|
|
277
|
+
status: S.text(), // Same name, different type
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const lib2Context = defineOpContext({
|
|
281
|
+
logSchema: lib2Schema,
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const lib2Ops = lib2Context.defineOps({
|
|
285
|
+
op2: async (ctx) => ctx.ok({}),
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// Define app with both (should throw due to conflict)
|
|
289
|
+
const appSchema = defineLogSchema({
|
|
290
|
+
userId: S.category(),
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
expect(() => {
|
|
294
|
+
defineOpContext({
|
|
295
|
+
logSchema: appSchema,
|
|
296
|
+
deps: {
|
|
297
|
+
lib1: lib1Ops,
|
|
298
|
+
lib2: lib2Ops, // Conflict: both contribute 'status'
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
}).toThrow(/conflict/i);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('should NOT conflict when using different prefixes', () => {
|
|
305
|
+
// Define two libraries with same column name
|
|
306
|
+
const lib1Schema = defineLogSchema({
|
|
307
|
+
status: S.number(),
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const lib1Context = defineOpContext({
|
|
311
|
+
logSchema: lib1Schema,
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
const lib1Ops = lib1Context.defineOps({
|
|
315
|
+
op1: async (ctx) => ctx.ok({}),
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
const lib2Schema = defineLogSchema({
|
|
319
|
+
status: S.text(), // Same name, different type
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
const lib2Context = defineOpContext({
|
|
323
|
+
logSchema: lib2Schema,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const lib2Ops = lib2Context.defineOps({
|
|
327
|
+
op2: async (ctx) => ctx.ok({}),
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// Define app with prefixes (no conflict)
|
|
331
|
+
const appSchema = defineLogSchema({
|
|
332
|
+
userId: S.category(),
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const appContext = defineOpContext({
|
|
336
|
+
logSchema: appSchema,
|
|
337
|
+
deps: {
|
|
338
|
+
lib1: lib1Ops.prefix('lib1'),
|
|
339
|
+
lib2: lib2Ops.prefix('lib2'),
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Should have both with different names
|
|
344
|
+
expect(appContext.logSchema._columnNames).toContain('userId');
|
|
345
|
+
expect(appContext.logSchema._columnNames).toContain('lib1_status');
|
|
346
|
+
expect(appContext.logSchema._columnNames).toContain('lib2_status');
|
|
347
|
+
expect(appContext.logSchema._columnNames.length).toBe(3);
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
describe('LogBinding Schema', () => {
|
|
352
|
+
it('should expose effective schema via factory.logSchema', () => {
|
|
353
|
+
// Define library
|
|
354
|
+
const httpSchema = defineLogSchema({
|
|
355
|
+
status: S.number(),
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
const httpContext = defineOpContext({
|
|
359
|
+
logSchema: httpSchema,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const httpOps = httpContext.defineOps({
|
|
363
|
+
fetch: async (ctx) => ctx.ok({}),
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
// Define app
|
|
367
|
+
const appSchema = defineLogSchema({
|
|
368
|
+
userId: S.category(),
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
const appContext = defineOpContext({
|
|
372
|
+
logSchema: appSchema,
|
|
373
|
+
deps: {
|
|
374
|
+
http: httpOps.prefix('http'),
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
// Factory's logSchema should be the effective schema
|
|
379
|
+
expect(appContext.logSchema._columnNames).toContain('userId');
|
|
380
|
+
expect(appContext.logSchema._columnNames).toContain('http_status');
|
|
381
|
+
expect(appContext.logSchema._columnNames.length).toBe(2);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
describe('Reserved Property Validation', () => {
|
|
386
|
+
it('should throw when using reserved SpanContext property names in ctx', () => {
|
|
387
|
+
const schema = defineLogSchema({ userId: S.category() });
|
|
388
|
+
|
|
389
|
+
// Test each reserved property
|
|
390
|
+
const reservedProps = ['buffer', 'tag', 'log', 'scope', 'setScope', 'ok', 'err', 'span', 'ff', 'deps'];
|
|
391
|
+
|
|
392
|
+
for (const prop of reservedProps) {
|
|
393
|
+
const invalidCtx: Record<string, unknown> = { [prop]: 'bad' };
|
|
394
|
+
expect(() => {
|
|
395
|
+
defineOpContext({
|
|
396
|
+
logSchema: schema,
|
|
397
|
+
ctx: invalidCtx,
|
|
398
|
+
});
|
|
399
|
+
}).toThrow(`Cannot use '${prop}' in ctx - it is a reserved SpanContext property`);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('should throw when using underscore-prefixed property names in ctx', () => {
|
|
404
|
+
const schema = defineLogSchema({ userId: S.category() });
|
|
405
|
+
|
|
406
|
+
// Use props NOT in the explicit RESERVED_CONTEXT_PROPS list
|
|
407
|
+
// to test the underscore prefix check specifically
|
|
408
|
+
const underscoreProps = ['_internal', '_private', '_meta', '_custom', '_foo'];
|
|
409
|
+
|
|
410
|
+
for (const prop of underscoreProps) {
|
|
411
|
+
const invalidCtx: Record<string, unknown> = { [prop]: 'bad' };
|
|
412
|
+
expect(() => {
|
|
413
|
+
defineOpContext({
|
|
414
|
+
logSchema: schema,
|
|
415
|
+
ctx: invalidCtx,
|
|
416
|
+
});
|
|
417
|
+
}).toThrow(`Cannot use '${prop}' in ctx - properties starting with '_' are reserved for internal use`);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it('should allow valid property names in ctx', () => {
|
|
422
|
+
const schema = defineLogSchema({ userId: S.category() });
|
|
423
|
+
|
|
424
|
+
// These should NOT throw
|
|
425
|
+
expect(() => {
|
|
426
|
+
defineOpContext({
|
|
427
|
+
logSchema: schema,
|
|
428
|
+
ctx: {
|
|
429
|
+
env: null as unknown,
|
|
430
|
+
config: { retry: 3 },
|
|
431
|
+
requestId: null as string | null,
|
|
432
|
+
userId: undefined as string | undefined,
|
|
433
|
+
debug: false,
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
}).not.toThrow();
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { uint8, uint16 } from '@uwdata/flechette';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
getArrowIndexArrayConstructorOr,
|
|
6
|
+
getArrowIndexTypeOr,
|
|
7
|
+
hasArrowIndexMetadata,
|
|
8
|
+
hasArrowIndexType,
|
|
9
|
+
hasTypeId,
|
|
10
|
+
} from '../arrow/flechette.js';
|
|
11
|
+
|
|
12
|
+
describe('flechette helpers', () => {
|
|
13
|
+
it('reads enum index metadata from schema objects', () => {
|
|
14
|
+
const schema = {
|
|
15
|
+
__arrow_index_type: uint16(),
|
|
16
|
+
__index_array_ctor: Uint16Array,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
expect(hasArrowIndexType(schema)).toBe(true);
|
|
20
|
+
expect(hasArrowIndexMetadata(schema)).toBe(true);
|
|
21
|
+
expect(getArrowIndexTypeOr(schema, uint8()).typeId).toBe(uint16().typeId);
|
|
22
|
+
expect(getArrowIndexArrayConstructorOr(schema)).toBe(Uint16Array);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('falls back when metadata is missing or incomplete', () => {
|
|
26
|
+
const missingCtor = {
|
|
27
|
+
__arrow_index_type: uint16(),
|
|
28
|
+
__index_array_ctor: Array,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
expect(hasArrowIndexType({})).toBe(false);
|
|
32
|
+
expect(hasArrowIndexMetadata(missingCtor)).toBe(false);
|
|
33
|
+
expect(getArrowIndexTypeOr({}, uint8()).typeId).toBe(uint8().typeId);
|
|
34
|
+
expect(getArrowIndexArrayConstructorOr(missingCtor)).toBe(Uint8Array);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('rejects array inputs for object metadata guards', () => {
|
|
38
|
+
expect(hasTypeId([{ typeId: 1 }])).toBe(false);
|
|
39
|
+
expect(hasArrowIndexType([{ __arrow_index_type: uint16() }])).toBe(false);
|
|
40
|
+
expect(hasArrowIndexMetadata([{ __arrow_index_type: uint16(), __index_array_ctor: Uint16Array }])).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
});
|