@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,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Op-Centric API Type Definitions Hub
|
|
3
|
+
*
|
|
4
|
+
* This is the central hub for all Op-centric API types. Consumers should import
|
|
5
|
+
* from this file rather than individual type files.
|
|
6
|
+
*
|
|
7
|
+
* Organized into logical groups:
|
|
8
|
+
* - Context utilities (reserved props, null/undefined key extraction, validation)
|
|
9
|
+
* - Feature flags (schema, evaluator, bound flags)
|
|
10
|
+
* - OpGroup (groups, mapping, deps, schema combination)
|
|
11
|
+
* - Op (metadata, function signature, instance)
|
|
12
|
+
* - SpanContext (tag writer, logger, span function, full context)
|
|
13
|
+
*
|
|
14
|
+
* @module opContext/types
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// =============================================================================
|
|
18
|
+
// RE-EXPORTS FROM EXTRACTED TYPE FILES
|
|
19
|
+
// =============================================================================
|
|
20
|
+
|
|
21
|
+
// FlagEvaluator interface is in schema/evaluator.ts
|
|
22
|
+
export type { FlagEvaluator, SpanContextWithoutFf } from '../schema/evaluator.js';
|
|
23
|
+
// Context type utilities (reserved props, null/undefined key extraction, validation)
|
|
24
|
+
export {
|
|
25
|
+
type DefaultKeys,
|
|
26
|
+
type NullKeys,
|
|
27
|
+
type OptionalContextParams,
|
|
28
|
+
RESERVED_CONTEXT_PROPS,
|
|
29
|
+
type RequiredContextParams,
|
|
30
|
+
type ReservedContextProp,
|
|
31
|
+
type ResolvedContext,
|
|
32
|
+
type TraceContextParams,
|
|
33
|
+
type UndefinedKeys,
|
|
34
|
+
type ValidateUserContext,
|
|
35
|
+
} from './contextTypes.js';
|
|
36
|
+
// Feature flag types
|
|
37
|
+
export type { BoundFeatureFlags, FeatureFlagSchema } from './featureFlagTypes.js';
|
|
38
|
+
// OpGroup types (groups, mapping, deps, schema combination)
|
|
39
|
+
export type {
|
|
40
|
+
AnyOpGroup,
|
|
41
|
+
ColumnMapping,
|
|
42
|
+
CombinedDepsSchema,
|
|
43
|
+
ContributedSchemaOf,
|
|
44
|
+
DepsConfig,
|
|
45
|
+
EffectiveSchema,
|
|
46
|
+
MappedOpGroup,
|
|
47
|
+
MappedSchema,
|
|
48
|
+
OpGroup,
|
|
49
|
+
PrefixedSchema,
|
|
50
|
+
ResolvedDeps,
|
|
51
|
+
SchemaFieldsOf,
|
|
52
|
+
UnionToIntersection,
|
|
53
|
+
} from './opGroupTypes.js';
|
|
54
|
+
// Op types (metadata, function signature, instance)
|
|
55
|
+
export type { Op, OpFn, OpMetadata, OpsFromRecord } from './opTypes.js';
|
|
56
|
+
// SpanContext types (tag writer, logger, span function, full context)
|
|
57
|
+
export type { FluentLogEntry, SpanContext, SpanFn, SpanLogger, SpanSyncFn, TagWriter } from './spanContextTypes.js';
|
|
58
|
+
|
|
59
|
+
// =============================================================================
|
|
60
|
+
// CONVENIENCE RE-EXPORTS
|
|
61
|
+
// =============================================================================
|
|
62
|
+
|
|
63
|
+
export { LogSchema } from '../schema/LogSchema.js';
|
|
64
|
+
export type { FeatureFlagDefinition, InferSchema, SchemaFields } from '../schema/types.js';
|
|
65
|
+
|
|
66
|
+
// =============================================================================
|
|
67
|
+
// OP CONTEXT TYPE SYMBOL
|
|
68
|
+
// =============================================================================
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Unique symbol to carry OpContext type on OpContextFactory.
|
|
72
|
+
* Allows extracting the bundled type without passing 4 separate params.
|
|
73
|
+
* Must be a runtime value (not just `declare const`) so it can be used as property key.
|
|
74
|
+
*/
|
|
75
|
+
const opContextType: unique symbol = Symbol('opContextType');
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Helper to extract OpContext from a factory.
|
|
79
|
+
* @example
|
|
80
|
+
* const { defineOp } = defineOpContext({ ... });
|
|
81
|
+
* type MyCtx = OpContextOf<typeof factory>; // OpContext<T, FF, Deps, UserCtx>
|
|
82
|
+
*/
|
|
83
|
+
export type OpContextOf<F> = F extends { readonly [opContextType]?: infer Ctx } ? Ctx : never;
|
|
84
|
+
|
|
85
|
+
export { opContextType };
|
|
86
|
+
|
|
87
|
+
// =============================================================================
|
|
88
|
+
// OP CONTEXT BUNDLE TYPE
|
|
89
|
+
// =============================================================================
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Bundled type parameters for Op context.
|
|
93
|
+
*
|
|
94
|
+
* Created by defineOpContext() and shared by all Ops from that factory.
|
|
95
|
+
* Reduces type parameter count: Op<Ctx, Args, S, E> instead of Op<T, FF, Deps, UserCtx, Args, R>
|
|
96
|
+
*
|
|
97
|
+
* @template T - LogSchema type
|
|
98
|
+
* @template FF - Feature flag schema
|
|
99
|
+
* @template Deps - Dependencies config
|
|
100
|
+
* @template UserCtx - User context properties
|
|
101
|
+
*/
|
|
102
|
+
export type OpContext<
|
|
103
|
+
T extends LogSchema = LogSchema,
|
|
104
|
+
FF extends FeatureFlagSchema = FeatureFlagSchema,
|
|
105
|
+
Deps extends DepsConfig = DepsConfig,
|
|
106
|
+
UserCtx extends Record<string, unknown> = Record<string, unknown>,
|
|
107
|
+
> = {
|
|
108
|
+
readonly logSchema: T;
|
|
109
|
+
readonly flags: FF;
|
|
110
|
+
readonly deps: Deps;
|
|
111
|
+
readonly userCtx: UserCtx;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// =============================================================================
|
|
115
|
+
// OP CONTEXT CONFIGURATION
|
|
116
|
+
// =============================================================================
|
|
117
|
+
|
|
118
|
+
import type { LogSchema } from '../schema/LogSchema.js';
|
|
119
|
+
import type { SchemaFields } from '../schema/types.js';
|
|
120
|
+
import type { ValidateUserContext } from './contextTypes.js';
|
|
121
|
+
import type { FeatureFlagSchema } from './featureFlagTypes.js';
|
|
122
|
+
import type { DepsConfig, OpGroup } from './opGroupTypes.js';
|
|
123
|
+
import type { Op, OpFn, OpMetadata, OpsFromRecord } from './opTypes.js';
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Configuration for defineOpContext
|
|
127
|
+
*
|
|
128
|
+
* This is the main configuration interface for creating an Op context factory.
|
|
129
|
+
* It defines:
|
|
130
|
+
* - The app's own schema (logSchema)
|
|
131
|
+
* - Dependencies from other OpGroups (deps)
|
|
132
|
+
* - Feature flag schema (flags)
|
|
133
|
+
* - User-defined context properties (ctx)
|
|
134
|
+
*
|
|
135
|
+
* @template T - LogSchema fields (app's own schema)
|
|
136
|
+
* @template FF - Feature flag schema
|
|
137
|
+
* @template Deps - Dependency record (other OpGroups with mappings)
|
|
138
|
+
* @template UserCtx - User-defined context properties
|
|
139
|
+
*
|
|
140
|
+
* The effective schema for ops = `T & CombinedDepsSchema<Deps>`.
|
|
141
|
+
* This means ops can write to columns from both the app's schema AND
|
|
142
|
+
* all columns contributed by wired dependencies (after mapping/prefixing).
|
|
143
|
+
*/
|
|
144
|
+
export interface OpContextConfig<
|
|
145
|
+
T extends SchemaFields,
|
|
146
|
+
FF extends FeatureFlagSchema,
|
|
147
|
+
Deps extends DepsConfig,
|
|
148
|
+
UserCtx extends Record<string, unknown>,
|
|
149
|
+
> {
|
|
150
|
+
/**
|
|
151
|
+
* Log schema defining the app's own columns.
|
|
152
|
+
*
|
|
153
|
+
* The effective schema for ops is this PLUS columns from deps.
|
|
154
|
+
* E.g., if you wire `http: httpOps.prefix('http')`, ops can also
|
|
155
|
+
* write to `http_status`, `http_url`, etc.
|
|
156
|
+
*/
|
|
157
|
+
readonly logSchema: LogSchema<T>;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Dependencies - other OpGroups that can be invoked via ctx.deps
|
|
161
|
+
*
|
|
162
|
+
* Each dep's columns are added to the effective schema based on its mapping:
|
|
163
|
+
* - `.prefix('http')` → columns become `http_status`, `http_url`, etc.
|
|
164
|
+
* - `.mapColumns({ query: 'query' })` → shares the `query` column
|
|
165
|
+
* - `.mapColumns({ _internal: null })` → drops the `_internal` column
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* deps: {
|
|
169
|
+
* pg: postgresOps.mapColumns({ query: 'query', rows: 'pg_rows' }),
|
|
170
|
+
* mysql: mysqlOps.mapColumns({ query: 'query', duration: 'mysql_duration' }),
|
|
171
|
+
* http: httpOps.prefix('http'),
|
|
172
|
+
* }
|
|
173
|
+
* // Effective schema includes: query, pg_rows, mysql_duration, http_status, http_url, ...
|
|
174
|
+
*/
|
|
175
|
+
readonly deps?: Deps;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Feature flag schema - defines available flags and their types
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* flags: defineFeatureFlags({
|
|
182
|
+
* newCheckout: S.boolean().default(false).async(),
|
|
183
|
+
* maxRetries: S.number().default(3).sync(),
|
|
184
|
+
* })
|
|
185
|
+
*/
|
|
186
|
+
readonly flags?: FF;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* User-defined context properties
|
|
190
|
+
*
|
|
191
|
+
* ALL properties must be declared here for V8 hidden class optimization.
|
|
192
|
+
* Properties set to `null` must be provided when calling createTrace().
|
|
193
|
+
* Properties with values have defaults and can be optionally overridden.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ctx: {
|
|
197
|
+
* env: null as CFWorkerEnv, // Must provide at createTrace()
|
|
198
|
+
* config: { retryCount: 3 }, // Has default, can override
|
|
199
|
+
* requestId: null as string, // Must provide at createTrace()
|
|
200
|
+
* }
|
|
201
|
+
*/
|
|
202
|
+
readonly ctx?: ValidateUserContext<UserCtx>;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// =============================================================================
|
|
206
|
+
// OP CONTEXT BINDING (For Tracer)
|
|
207
|
+
// =============================================================================
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Runtime binding from defineOpContext for use with Tracer.
|
|
211
|
+
*
|
|
212
|
+
* Contains everything a Tracer needs to create traces:
|
|
213
|
+
* - logBinding: Schema and capacity stats for buffer creation
|
|
214
|
+
* - ctxDefaults: User context defaults (with null sentinels for required fields)
|
|
215
|
+
* - deps: Wired dependencies for ctx.deps
|
|
216
|
+
*
|
|
217
|
+
* Carries phantom type via [opContextType] for full OpContext inference.
|
|
218
|
+
* This allows `new TestTracer(ctx)` to infer T from ctx.logBinding without
|
|
219
|
+
* explicit type parameters.
|
|
220
|
+
*
|
|
221
|
+
* @template T - LogSchema type
|
|
222
|
+
* @template FF - Feature flag schema
|
|
223
|
+
* @template Deps - Dependencies config
|
|
224
|
+
* @template UserCtx - User context properties
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const ctx = defineOpContext({
|
|
229
|
+
* logSchema: defineLogSchema({ userId: S.category() }),
|
|
230
|
+
* ctx: { env: null as Env },
|
|
231
|
+
* });
|
|
232
|
+
*
|
|
233
|
+
* // Tracer infers types from binding - no explicit type params needed
|
|
234
|
+
* const { trace } = new TestTracer(ctx);
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export interface OpContextBinding<
|
|
238
|
+
T extends LogSchema = LogSchema,
|
|
239
|
+
FF extends FeatureFlagSchema = FeatureFlagSchema,
|
|
240
|
+
Deps extends DepsConfig = DepsConfig,
|
|
241
|
+
UserCtx extends Record<string, unknown> = Record<string, unknown>,
|
|
242
|
+
> {
|
|
243
|
+
/**
|
|
244
|
+
* Phantom type - extract via OpContextOf<typeof binding>
|
|
245
|
+
*
|
|
246
|
+
* Carries the bundled OpContext type for type inference.
|
|
247
|
+
* Tracers use this to infer the full context type without explicit parameters.
|
|
248
|
+
*
|
|
249
|
+
* @internal
|
|
250
|
+
*/
|
|
251
|
+
readonly [opContextType]?: OpContext<T, FF, Deps, UserCtx>;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* LogBinding for this context (schema, capacity stats, optional prefix view).
|
|
255
|
+
* Used by Tracer to create SpanBuffers and SpanContexts.
|
|
256
|
+
* Typed with schema T for Op type safety.
|
|
257
|
+
*/
|
|
258
|
+
readonly logBinding: import('../logBinding.js').LogBinding<T>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Feature flag schema needed by tracers to bootstrap typed evaluators.
|
|
262
|
+
*/
|
|
263
|
+
readonly flags: FF;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* User context defaults from ctx config.
|
|
267
|
+
* Used by Tracer to merge with trace-level overrides.
|
|
268
|
+
* Properties with null values are required at trace creation.
|
|
269
|
+
*/
|
|
270
|
+
readonly ctxDefaults: UserCtx;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Dependencies wired at defineOpContext time.
|
|
274
|
+
* Used by Tracer to populate ctx.deps on root spans.
|
|
275
|
+
*/
|
|
276
|
+
readonly deps: Deps;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// =============================================================================
|
|
280
|
+
// OP CONTEXT FACTORY
|
|
281
|
+
// =============================================================================
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Return type of defineOpContext
|
|
285
|
+
*
|
|
286
|
+
* This is the factory returned by defineOpContext that provides:
|
|
287
|
+
* - `defineOp`: Define a single Op with explicit name
|
|
288
|
+
* - `defineOps`: Define multiple Ops and create an OpGroup
|
|
289
|
+
* - `logSchema`: The combined effective schema
|
|
290
|
+
* - `flags`: The feature flag schema
|
|
291
|
+
*
|
|
292
|
+
* Extends OpContextBinding to provide everything Tracer needs.
|
|
293
|
+
* Uses unique symbol [opContextType] to carry the bundled OpContext type
|
|
294
|
+
* for extraction via OpContextOf<typeof factory>.
|
|
295
|
+
*
|
|
296
|
+
* @template T - The app's LogSchema
|
|
297
|
+
* @template FF - Feature flag schema
|
|
298
|
+
* @template Deps - Wired dependencies
|
|
299
|
+
* @template UserCtx - User context properties
|
|
300
|
+
*
|
|
301
|
+
* The effective schema for ops is `T & CombinedDepsSchema<Deps>` - the app's
|
|
302
|
+
* schema combined with all columns contributed by wired dependencies.
|
|
303
|
+
*/
|
|
304
|
+
export interface OpContextFactory<
|
|
305
|
+
T extends LogSchema,
|
|
306
|
+
FF extends FeatureFlagSchema,
|
|
307
|
+
Deps extends DepsConfig,
|
|
308
|
+
UserCtx extends Record<string, unknown>,
|
|
309
|
+
> extends OpContextBinding<T, FF, Deps, UserCtx> {
|
|
310
|
+
/**
|
|
311
|
+
* The combined log schema (app schema + dep contributions).
|
|
312
|
+
*
|
|
313
|
+
* This is the effective schema that ops can write to. It includes:
|
|
314
|
+
* - All columns from the app's logSchema
|
|
315
|
+
* - All mapped/prefixed columns from dependencies
|
|
316
|
+
*
|
|
317
|
+
* External consumers can use this to see the full schema shape.
|
|
318
|
+
*/
|
|
319
|
+
readonly logSchema: T;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* The feature flag schema (for external consumers)
|
|
323
|
+
*/
|
|
324
|
+
readonly flags: FF;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Define a single Op with explicit name.
|
|
328
|
+
*
|
|
329
|
+
* Creates an Op instance that wraps your function with metadata for tracing.
|
|
330
|
+
* The Op can be invoked via ctx.span() or exported for use by other modules.
|
|
331
|
+
*
|
|
332
|
+
* @param name - Op name (used for default span naming and metrics)
|
|
333
|
+
* @param fn - Op function receiving SpanContext and returning Result<S, E>
|
|
334
|
+
* @param metadata - Optional metadata override (package_name, package_file, etc.)
|
|
335
|
+
* @returns Op instance with type Op<OpContext<T, FF, Deps, UserCtx>, Args, S, E>
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* const fetchUser = defineOp('fetchUser', async (ctx, userId: string) => {
|
|
340
|
+
* ctx.tag.userId(userId);
|
|
341
|
+
* const user = await db.getUser(userId);
|
|
342
|
+
* if (!user) return ctx.err('NOT_FOUND', { userId });
|
|
343
|
+
* return ctx.ok(user);
|
|
344
|
+
* });
|
|
345
|
+
*
|
|
346
|
+
* // Invoke via span:
|
|
347
|
+
* const result = await ctx.span('get-user', fetchUser, 'user-123');
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
defineOp<Args extends unknown[], S, E>(
|
|
351
|
+
name: string,
|
|
352
|
+
fn: OpFn<OpContext<T, FF, Deps, UserCtx>, Args, S, E>,
|
|
353
|
+
metadata?: Partial<OpMetadata>,
|
|
354
|
+
): Op<OpContext<T, FF, Deps, UserCtx>, Args, S, E>;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Define multiple Ops at once and create an OpGroup.
|
|
358
|
+
*
|
|
359
|
+
* Property keys become Op names. Supports `this` binding for calling
|
|
360
|
+
* sibling ops within the same batch. Returns an OpGroup that can be:
|
|
361
|
+
* - Prefixed with `.prefix('http')` for column namespacing
|
|
362
|
+
* - Column-mapped with `.mapColumns({ query: 'query' })` for sharing
|
|
363
|
+
* - Wired as a dependency in another module's `deps` config
|
|
364
|
+
*
|
|
365
|
+
* @param definitions - Record of Op functions or existing Op instances
|
|
366
|
+
* @returns OpGroup with all defined Ops accessible as properties
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```typescript
|
|
370
|
+
* export const userOps = defineOps({
|
|
371
|
+
* // Reuse existing Op
|
|
372
|
+
* fetchUser,
|
|
373
|
+
*
|
|
374
|
+
* // Define new op with method syntax
|
|
375
|
+
* async createUser(ctx, data: UserData) {
|
|
376
|
+
* ctx.tag.operation('INSERT');
|
|
377
|
+
* const user = await db.createUser(data);
|
|
378
|
+
* return ctx.ok(user);
|
|
379
|
+
* },
|
|
380
|
+
*
|
|
381
|
+
* // Call sibling op via this.opName
|
|
382
|
+
* async createAndFetch(ctx, data: UserData) {
|
|
383
|
+
* const created = await ctx.span('create', this.createUser, data);
|
|
384
|
+
* if (!created.success) return created;
|
|
385
|
+
* return ctx.span('fetch', this.fetchUser, created.value.id);
|
|
386
|
+
* },
|
|
387
|
+
* });
|
|
388
|
+
*
|
|
389
|
+
* // Wire as dependency with prefix:
|
|
390
|
+
* deps: { users: userOps.prefix('user') }
|
|
391
|
+
*
|
|
392
|
+
* // Invoke from parent context:
|
|
393
|
+
* await ctx.span('create-user', userOps.createUser, userData);
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
defineOps<
|
|
397
|
+
Defs extends Record<
|
|
398
|
+
string,
|
|
399
|
+
| OpFn<OpContext<T, FF, Deps, UserCtx>, unknown[], unknown, unknown>
|
|
400
|
+
| Op<OpContext<T, FF, Deps, UserCtx>, unknown[], unknown, unknown>
|
|
401
|
+
>,
|
|
402
|
+
>(definitions: Defs): OpGroup<OpContext<T, FF, Deps, UserCtx>, OpsFromRecord<OpContext<T, FF, Deps, UserCtx>, Defs>>;
|
|
403
|
+
}
|