mongo.do 0.1.0 → 0.1.1
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/dist/cli/index.d.ts +1 -15
- package/dist/cli/index.js +4083 -196
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +2740 -20
- package/dist/index.js +9375 -27
- package/dist/index.js.map +1 -1
- package/dist/worker-entrypoint-BEW23Gmp.d.ts +1331 -0
- package/dist/worker.d.ts +6 -5
- package/dist/worker.js +5477 -18
- package/dist/worker.js.map +1 -1
- package/package.json +3 -2
- package/dist/agentfs/adapters/anthropic.d.ts +0 -176
- package/dist/agentfs/adapters/anthropic.d.ts.map +0 -1
- package/dist/agentfs/adapters/anthropic.js +0 -629
- package/dist/agentfs/adapters/anthropic.js.map +0 -1
- package/dist/agentfs/adapters/index.d.ts +0 -21
- package/dist/agentfs/adapters/index.d.ts.map +0 -1
- package/dist/agentfs/adapters/index.js +0 -23
- package/dist/agentfs/adapters/index.js.map +0 -1
- package/dist/agentfs/adapters/vercel.d.ts +0 -260
- package/dist/agentfs/adapters/vercel.d.ts.map +0 -1
- package/dist/agentfs/adapters/vercel.js +0 -288
- package/dist/agentfs/adapters/vercel.js.map +0 -1
- package/dist/agentfs/glob.d.ts +0 -116
- package/dist/agentfs/glob.d.ts.map +0 -1
- package/dist/agentfs/glob.js +0 -270
- package/dist/agentfs/glob.js.map +0 -1
- package/dist/agentfs/grep.d.ts +0 -83
- package/dist/agentfs/grep.d.ts.map +0 -1
- package/dist/agentfs/grep.js +0 -193
- package/dist/agentfs/grep.js.map +0 -1
- package/dist/agentfs/index.d.ts +0 -22
- package/dist/agentfs/index.d.ts.map +0 -1
- package/dist/agentfs/index.js +0 -18
- package/dist/agentfs/index.js.map +0 -1
- package/dist/agentfs/kv-store.d.ts +0 -128
- package/dist/agentfs/kv-store.d.ts.map +0 -1
- package/dist/agentfs/kv-store.js +0 -227
- package/dist/agentfs/kv-store.js.map +0 -1
- package/dist/agentfs/mondo-agent.d.ts +0 -255
- package/dist/agentfs/mondo-agent.d.ts.map +0 -1
- package/dist/agentfs/mondo-agent.js +0 -879
- package/dist/agentfs/mondo-agent.js.map +0 -1
- package/dist/agentfs/toolcalls.d.ts +0 -130
- package/dist/agentfs/toolcalls.d.ts.map +0 -1
- package/dist/agentfs/toolcalls.js +0 -178
- package/dist/agentfs/toolcalls.js.map +0 -1
- package/dist/agentfs/types.d.ts +0 -171
- package/dist/agentfs/types.d.ts.map +0 -1
- package/dist/agentfs/types.js +0 -7
- package/dist/agentfs/types.js.map +0 -1
- package/dist/agentfs/vfs.d.ts +0 -249
- package/dist/agentfs/vfs.d.ts.map +0 -1
- package/dist/agentfs/vfs.js +0 -469
- package/dist/agentfs/vfs.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/mcp.d.ts +0 -119
- package/dist/cli/mcp.d.ts.map +0 -1
- package/dist/cli/mcp.js +0 -418
- package/dist/cli/mcp.js.map +0 -1
- package/dist/cli/server.d.ts +0 -179
- package/dist/cli/server.d.ts.map +0 -1
- package/dist/cli/server.js +0 -441
- package/dist/cli/server.js.map +0 -1
- package/dist/client/Collection.d.ts +0 -199
- package/dist/client/Collection.d.ts.map +0 -1
- package/dist/client/Collection.js +0 -256
- package/dist/client/Collection.js.map +0 -1
- package/dist/client/Database.d.ts +0 -68
- package/dist/client/Database.d.ts.map +0 -1
- package/dist/client/Database.js +0 -105
- package/dist/client/Database.js.map +0 -1
- package/dist/client/MongoClient.d.ts +0 -165
- package/dist/client/MongoClient.d.ts.map +0 -1
- package/dist/client/MongoClient.js +0 -307
- package/dist/client/MongoClient.js.map +0 -1
- package/dist/client/aggregation-cursor.d.ts +0 -210
- package/dist/client/aggregation-cursor.d.ts.map +0 -1
- package/dist/client/aggregation-cursor.js +0 -509
- package/dist/client/aggregation-cursor.js.map +0 -1
- package/dist/client/bulk-write.d.ts +0 -216
- package/dist/client/bulk-write.d.ts.map +0 -1
- package/dist/client/bulk-write.js +0 -63
- package/dist/client/bulk-write.js.map +0 -1
- package/dist/client/change-stream.d.ts +0 -245
- package/dist/client/change-stream.d.ts.map +0 -1
- package/dist/client/change-stream.js +0 -429
- package/dist/client/change-stream.js.map +0 -1
- package/dist/client/cursor.d.ts +0 -85
- package/dist/client/cursor.d.ts.map +0 -1
- package/dist/client/cursor.js +0 -156
- package/dist/client/cursor.js.map +0 -1
- package/dist/client/http-cursor.d.ts +0 -233
- package/dist/client/http-cursor.d.ts.map +0 -1
- package/dist/client/http-cursor.js +0 -496
- package/dist/client/http-cursor.js.map +0 -1
- package/dist/client/index.d.ts +0 -18
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -24
- package/dist/client/index.js.map +0 -1
- package/dist/client/mongo-client.d.ts +0 -60
- package/dist/client/mongo-client.d.ts.map +0 -1
- package/dist/client/mongo-client.js +0 -190
- package/dist/client/mongo-client.js.map +0 -1
- package/dist/client/mongo-collection.d.ts +0 -359
- package/dist/client/mongo-collection.d.ts.map +0 -1
- package/dist/client/mongo-collection.js +0 -1641
- package/dist/client/mongo-collection.js.map +0 -1
- package/dist/client/mongo-cursor.d.ts +0 -257
- package/dist/client/mongo-cursor.d.ts.map +0 -1
- package/dist/client/mongo-cursor.js +0 -621
- package/dist/client/mongo-cursor.js.map +0 -1
- package/dist/client/mongo-database.d.ts +0 -88
- package/dist/client/mongo-database.d.ts.map +0 -1
- package/dist/client/mongo-database.js +0 -139
- package/dist/client/mongo-database.js.map +0 -1
- package/dist/client/session.d.ts +0 -210
- package/dist/client/session.d.ts.map +0 -1
- package/dist/client/session.js +0 -326
- package/dist/client/session.js.map +0 -1
- package/dist/durable-object/index-manager.d.ts +0 -173
- package/dist/durable-object/index-manager.d.ts.map +0 -1
- package/dist/durable-object/index-manager.js +0 -764
- package/dist/durable-object/index-manager.js.map +0 -1
- package/dist/durable-object/index.d.ts +0 -12
- package/dist/durable-object/index.d.ts.map +0 -1
- package/dist/durable-object/index.js +0 -8
- package/dist/durable-object/index.js.map +0 -1
- package/dist/durable-object/mcp-handler.d.ts +0 -52
- package/dist/durable-object/mcp-handler.d.ts.map +0 -1
- package/dist/durable-object/mcp-handler.js +0 -186
- package/dist/durable-object/mcp-handler.js.map +0 -1
- package/dist/durable-object/migrations.d.ts +0 -40
- package/dist/durable-object/migrations.d.ts.map +0 -1
- package/dist/durable-object/migrations.js +0 -121
- package/dist/durable-object/migrations.js.map +0 -1
- package/dist/durable-object/mondo-database.d.ts +0 -148
- package/dist/durable-object/mondo-database.d.ts.map +0 -1
- package/dist/durable-object/mondo-database.js +0 -621
- package/dist/durable-object/mondo-database.js.map +0 -1
- package/dist/durable-object/schema.d.ts +0 -192
- package/dist/durable-object/schema.d.ts.map +0 -1
- package/dist/durable-object/schema.js +0 -186
- package/dist/durable-object/schema.js.map +0 -1
- package/dist/embedding/document-serializer.d.ts +0 -118
- package/dist/embedding/document-serializer.d.ts.map +0 -1
- package/dist/embedding/document-serializer.js +0 -339
- package/dist/embedding/document-serializer.js.map +0 -1
- package/dist/embedding/embedding-manager.d.ts +0 -136
- package/dist/embedding/embedding-manager.d.ts.map +0 -1
- package/dist/embedding/embedding-manager.js +0 -176
- package/dist/embedding/embedding-manager.js.map +0 -1
- package/dist/embedding/index.d.ts +0 -9
- package/dist/embedding/index.d.ts.map +0 -1
- package/dist/embedding/index.js +0 -9
- package/dist/embedding/index.js.map +0 -1
- package/dist/executor/aggregation-executor.d.ts +0 -93
- package/dist/executor/aggregation-executor.d.ts.map +0 -1
- package/dist/executor/aggregation-executor.js +0 -275
- package/dist/executor/aggregation-executor.js.map +0 -1
- package/dist/executor/function-executor.d.ts +0 -39
- package/dist/executor/function-executor.d.ts.map +0 -1
- package/dist/executor/function-executor.js +0 -168
- package/dist/executor/function-executor.js.map +0 -1
- package/dist/executor/index.d.ts +0 -4
- package/dist/executor/index.d.ts.map +0 -1
- package/dist/executor/index.js +0 -4
- package/dist/executor/index.js.map +0 -1
- package/dist/executor/vector-search-executor.d.ts +0 -71
- package/dist/executor/vector-search-executor.d.ts.map +0 -1
- package/dist/executor/vector-search-executor.js +0 -113
- package/dist/executor/vector-search-executor.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/mcp/adapters/anthropic-adapter.d.ts +0 -256
- package/dist/mcp/adapters/anthropic-adapter.d.ts.map +0 -1
- package/dist/mcp/adapters/anthropic-adapter.js +0 -409
- package/dist/mcp/adapters/anthropic-adapter.js.map +0 -1
- package/dist/mcp/adapters/base-adapter.d.ts +0 -164
- package/dist/mcp/adapters/base-adapter.d.ts.map +0 -1
- package/dist/mcp/adapters/base-adapter.js +0 -277
- package/dist/mcp/adapters/base-adapter.js.map +0 -1
- package/dist/mcp/adapters/errors.d.ts +0 -173
- package/dist/mcp/adapters/errors.d.ts.map +0 -1
- package/dist/mcp/adapters/errors.js +0 -305
- package/dist/mcp/adapters/errors.js.map +0 -1
- package/dist/mcp/adapters/index.d.ts +0 -65
- package/dist/mcp/adapters/index.d.ts.map +0 -1
- package/dist/mcp/adapters/index.js +0 -92
- package/dist/mcp/adapters/index.js.map +0 -1
- package/dist/mcp/adapters/streaming.d.ts +0 -200
- package/dist/mcp/adapters/streaming.d.ts.map +0 -1
- package/dist/mcp/adapters/streaming.js +0 -381
- package/dist/mcp/adapters/streaming.js.map +0 -1
- package/dist/mcp/adapters/vercel-adapter.d.ts +0 -321
- package/dist/mcp/adapters/vercel-adapter.d.ts.map +0 -1
- package/dist/mcp/adapters/vercel-adapter.js +0 -487
- package/dist/mcp/adapters/vercel-adapter.js.map +0 -1
- package/dist/mcp/agent.d.ts +0 -192
- package/dist/mcp/agent.d.ts.map +0 -1
- package/dist/mcp/agent.js +0 -338
- package/dist/mcp/agent.js.map +0 -1
- package/dist/mcp/cli.d.ts +0 -71
- package/dist/mcp/cli.d.ts.map +0 -1
- package/dist/mcp/cli.js +0 -218
- package/dist/mcp/cli.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -15
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js +0 -20
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/sandbox/database-proxy.d.ts +0 -118
- package/dist/mcp/sandbox/database-proxy.d.ts.map +0 -1
- package/dist/mcp/sandbox/database-proxy.js +0 -154
- package/dist/mcp/sandbox/database-proxy.js.map +0 -1
- package/dist/mcp/sandbox/index.d.ts +0 -8
- package/dist/mcp/sandbox/index.d.ts.map +0 -1
- package/dist/mcp/sandbox/index.js +0 -7
- package/dist/mcp/sandbox/index.js.map +0 -1
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -72
- package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
- package/dist/mcp/sandbox/miniflare-evaluator.js +0 -379
- package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
- package/dist/mcp/sandbox/template.d.ts +0 -48
- package/dist/mcp/sandbox/template.d.ts.map +0 -1
- package/dist/mcp/sandbox/template.js +0 -147
- package/dist/mcp/sandbox/template.js.map +0 -1
- package/dist/mcp/sandbox/worker-evaluator.d.ts +0 -160
- package/dist/mcp/sandbox/worker-evaluator.d.ts.map +0 -1
- package/dist/mcp/sandbox/worker-evaluator.js +0 -217
- package/dist/mcp/sandbox/worker-evaluator.js.map +0 -1
- package/dist/mcp/server.d.ts +0 -75
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -278
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/tool-call-auditor.d.ts +0 -188
- package/dist/mcp/tool-call-auditor.d.ts.map +0 -1
- package/dist/mcp/tool-call-auditor.js +0 -198
- package/dist/mcp/tool-call-auditor.js.map +0 -1
- package/dist/mcp/tools/do.d.ts +0 -51
- package/dist/mcp/tools/do.d.ts.map +0 -1
- package/dist/mcp/tools/do.js +0 -113
- package/dist/mcp/tools/do.js.map +0 -1
- package/dist/mcp/tools/fetch.d.ts +0 -43
- package/dist/mcp/tools/fetch.d.ts.map +0 -1
- package/dist/mcp/tools/fetch.js +0 -127
- package/dist/mcp/tools/fetch.js.map +0 -1
- package/dist/mcp/tools/index.d.ts +0 -9
- package/dist/mcp/tools/index.d.ts.map +0 -1
- package/dist/mcp/tools/index.js +0 -9
- package/dist/mcp/tools/index.js.map +0 -1
- package/dist/mcp/tools/search.d.ts +0 -60
- package/dist/mcp/tools/search.d.ts.map +0 -1
- package/dist/mcp/tools/search.js +0 -278
- package/dist/mcp/tools/search.js.map +0 -1
- package/dist/mcp/transport/http.d.ts +0 -144
- package/dist/mcp/transport/http.d.ts.map +0 -1
- package/dist/mcp/transport/http.js +0 -545
- package/dist/mcp/transport/http.js.map +0 -1
- package/dist/mcp/transport/index.d.ts +0 -10
- package/dist/mcp/transport/index.d.ts.map +0 -1
- package/dist/mcp/transport/index.js +0 -12
- package/dist/mcp/transport/index.js.map +0 -1
- package/dist/mcp/transport/stdio.d.ts +0 -132
- package/dist/mcp/transport/stdio.d.ts.map +0 -1
- package/dist/mcp/transport/stdio.js +0 -466
- package/dist/mcp/transport/stdio.js.map +0 -1
- package/dist/mcp/types.d.ts +0 -476
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/mcp/types.js +0 -178
- package/dist/mcp/types.js.map +0 -1
- package/dist/olap/cdc/cdc-buffer.d.ts +0 -92
- package/dist/olap/cdc/cdc-buffer.d.ts.map +0 -1
- package/dist/olap/cdc/cdc-buffer.js +0 -146
- package/dist/olap/cdc/cdc-buffer.js.map +0 -1
- package/dist/olap/cdc/cdc-emitter.d.ts +0 -118
- package/dist/olap/cdc/cdc-emitter.d.ts.map +0 -1
- package/dist/olap/cdc/cdc-emitter.js +0 -217
- package/dist/olap/cdc/cdc-emitter.js.map +0 -1
- package/dist/olap/cdc/cdc-schema.d.ts +0 -119
- package/dist/olap/cdc/cdc-schema.d.ts.map +0 -1
- package/dist/olap/cdc/cdc-schema.js +0 -253
- package/dist/olap/cdc/cdc-schema.js.map +0 -1
- package/dist/olap/cdc/index.d.ts +0 -10
- package/dist/olap/cdc/index.d.ts.map +0 -1
- package/dist/olap/cdc/index.js +0 -10
- package/dist/olap/cdc/index.js.map +0 -1
- package/dist/olap/clickhouse/iceberg.d.ts +0 -164
- package/dist/olap/clickhouse/iceberg.d.ts.map +0 -1
- package/dist/olap/clickhouse/iceberg.js +0 -138
- package/dist/olap/clickhouse/iceberg.js.map +0 -1
- package/dist/olap/clickhouse/index.d.ts +0 -14
- package/dist/olap/clickhouse/index.d.ts.map +0 -1
- package/dist/olap/clickhouse/index.js +0 -14
- package/dist/olap/clickhouse/index.js.map +0 -1
- package/dist/olap/clickhouse/mapper.d.ts +0 -170
- package/dist/olap/clickhouse/mapper.d.ts.map +0 -1
- package/dist/olap/clickhouse/mapper.js +0 -654
- package/dist/olap/clickhouse/mapper.js.map +0 -1
- package/dist/olap/clickhouse/olap-backend.d.ts +0 -181
- package/dist/olap/clickhouse/olap-backend.d.ts.map +0 -1
- package/dist/olap/clickhouse/olap-backend.js +0 -1083
- package/dist/olap/clickhouse/olap-backend.js.map +0 -1
- package/dist/olap/clickhouse/query-executor.d.ts +0 -163
- package/dist/olap/clickhouse/query-executor.d.ts.map +0 -1
- package/dist/olap/clickhouse/query-executor.js +0 -560
- package/dist/olap/clickhouse/query-executor.js.map +0 -1
- package/dist/olap/clickhouse/query.d.ts +0 -134
- package/dist/olap/clickhouse/query.d.ts.map +0 -1
- package/dist/olap/clickhouse/query.js +0 -512
- package/dist/olap/clickhouse/query.js.map +0 -1
- package/dist/olap/stage/index.d.ts +0 -6
- package/dist/olap/stage/index.d.ts.map +0 -1
- package/dist/olap/stage/index.js +0 -6
- package/dist/olap/stage/index.js.map +0 -1
- package/dist/olap/stage/parser.d.ts +0 -68
- package/dist/olap/stage/parser.d.ts.map +0 -1
- package/dist/olap/stage/parser.js +0 -293
- package/dist/olap/stage/parser.js.map +0 -1
- package/dist/olap/stage/router.d.ts +0 -94
- package/dist/olap/stage/router.d.ts.map +0 -1
- package/dist/olap/stage/router.js +0 -390
- package/dist/olap/stage/router.js.map +0 -1
- package/dist/rpc/endpoint.d.ts +0 -52
- package/dist/rpc/endpoint.d.ts.map +0 -1
- package/dist/rpc/endpoint.js +0 -734
- package/dist/rpc/endpoint.js.map +0 -1
- package/dist/rpc/index.d.ts +0 -34
- package/dist/rpc/index.d.ts.map +0 -1
- package/dist/rpc/index.js +0 -45
- package/dist/rpc/index.js.map +0 -1
- package/dist/rpc/rpc-client.d.ts +0 -275
- package/dist/rpc/rpc-client.d.ts.map +0 -1
- package/dist/rpc/rpc-client.js +0 -735
- package/dist/rpc/rpc-client.js.map +0 -1
- package/dist/rpc/rpc-target.d.ts +0 -220
- package/dist/rpc/rpc-target.d.ts.map +0 -1
- package/dist/rpc/rpc-target.js +0 -500
- package/dist/rpc/rpc-target.js.map +0 -1
- package/dist/rpc/worker-entrypoint.d.ts +0 -159
- package/dist/rpc/worker-entrypoint.d.ts.map +0 -1
- package/dist/rpc/worker-entrypoint.js +0 -212
- package/dist/rpc/worker-entrypoint.js.map +0 -1
- package/dist/server.d.ts +0 -18
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -129
- package/dist/server.js.map +0 -1
- package/dist/studio/components/browser/CollectionItem.d.ts +0 -26
- package/dist/studio/components/browser/CollectionItem.d.ts.map +0 -1
- package/dist/studio/components/browser/CollectionItem.js +0 -143
- package/dist/studio/components/browser/CollectionItem.js.map +0 -1
- package/dist/studio/components/browser/CollectionTree.d.ts +0 -45
- package/dist/studio/components/browser/CollectionTree.d.ts.map +0 -1
- package/dist/studio/components/browser/CollectionTree.js +0 -207
- package/dist/studio/components/browser/CollectionTree.js.map +0 -1
- package/dist/studio/components/browser/ConnectedDatabaseBrowser.d.ts +0 -51
- package/dist/studio/components/browser/ConnectedDatabaseBrowser.d.ts.map +0 -1
- package/dist/studio/components/browser/ConnectedDatabaseBrowser.js +0 -185
- package/dist/studio/components/browser/ConnectedDatabaseBrowser.js.map +0 -1
- package/dist/studio/components/browser/DatabaseBrowser.d.ts +0 -46
- package/dist/studio/components/browser/DatabaseBrowser.d.ts.map +0 -1
- package/dist/studio/components/browser/DatabaseBrowser.js +0 -304
- package/dist/studio/components/browser/DatabaseBrowser.js.map +0 -1
- package/dist/studio/components/browser/__tests__/CollectionItem.test.d.ts +0 -5
- package/dist/studio/components/browser/__tests__/CollectionItem.test.d.ts.map +0 -1
- package/dist/studio/components/browser/__tests__/CollectionItem.test.js +0 -169
- package/dist/studio/components/browser/__tests__/CollectionItem.test.js.map +0 -1
- package/dist/studio/components/browser/__tests__/CollectionTree.test.d.ts +0 -5
- package/dist/studio/components/browser/__tests__/CollectionTree.test.d.ts.map +0 -1
- package/dist/studio/components/browser/__tests__/CollectionTree.test.js +0 -203
- package/dist/studio/components/browser/__tests__/CollectionTree.test.js.map +0 -1
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.e2e.test.d.ts +0 -8
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.e2e.test.d.ts.map +0 -1
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.e2e.test.js +0 -522
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.e2e.test.js.map +0 -1
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.test.d.ts +0 -5
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.test.d.ts.map +0 -1
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.test.js +0 -518
- package/dist/studio/components/browser/__tests__/DatabaseBrowser.test.js.map +0 -1
- package/dist/studio/components/browser/__tests__/setup.d.ts +0 -5
- package/dist/studio/components/browser/__tests__/setup.d.ts.map +0 -1
- package/dist/studio/components/browser/__tests__/setup.js +0 -22
- package/dist/studio/components/browser/__tests__/setup.js.map +0 -1
- package/dist/studio/components/browser/index.d.ts +0 -15
- package/dist/studio/components/browser/index.d.ts.map +0 -1
- package/dist/studio/components/browser/index.js +0 -10
- package/dist/studio/components/browser/index.js.map +0 -1
- package/dist/studio/components/browser/types.d.ts +0 -33
- package/dist/studio/components/browser/types.d.ts.map +0 -1
- package/dist/studio/components/browser/types.js +0 -5
- package/dist/studio/components/browser/types.js.map +0 -1
- package/dist/studio/components/connection/ConnectionForm.d.ts +0 -59
- package/dist/studio/components/connection/ConnectionForm.d.ts.map +0 -1
- package/dist/studio/components/connection/ConnectionForm.js +0 -274
- package/dist/studio/components/connection/ConnectionForm.js.map +0 -1
- package/dist/studio/components/connection/ConnectionList.d.ts +0 -59
- package/dist/studio/components/connection/ConnectionList.d.ts.map +0 -1
- package/dist/studio/components/connection/ConnectionList.js +0 -286
- package/dist/studio/components/connection/ConnectionList.js.map +0 -1
- package/dist/studio/components/connection/ConnectionPanel.d.ts +0 -132
- package/dist/studio/components/connection/ConnectionPanel.d.ts.map +0 -1
- package/dist/studio/components/connection/ConnectionPanel.js +0 -293
- package/dist/studio/components/connection/ConnectionPanel.js.map +0 -1
- package/dist/studio/components/connection/__tests__/ConnectionPanel.test.d.ts +0 -8
- package/dist/studio/components/connection/__tests__/ConnectionPanel.test.d.ts.map +0 -1
- package/dist/studio/components/connection/__tests__/ConnectionPanel.test.js +0 -632
- package/dist/studio/components/connection/__tests__/ConnectionPanel.test.js.map +0 -1
- package/dist/studio/components/connection/__tests__/setup.d.ts +0 -5
- package/dist/studio/components/connection/__tests__/setup.d.ts.map +0 -1
- package/dist/studio/components/connection/__tests__/setup.js +0 -11
- package/dist/studio/components/connection/__tests__/setup.js.map +0 -1
- package/dist/studio/components/connection/index.d.ts +0 -10
- package/dist/studio/components/connection/index.d.ts.map +0 -1
- package/dist/studio/components/connection/index.js +0 -7
- package/dist/studio/components/connection/index.js.map +0 -1
- package/dist/studio/components/crud/DeleteDocumentDialog.d.ts +0 -91
- package/dist/studio/components/crud/DeleteDocumentDialog.d.ts.map +0 -1
- package/dist/studio/components/crud/DeleteDocumentDialog.js +0 -273
- package/dist/studio/components/crud/DeleteDocumentDialog.js.map +0 -1
- package/dist/studio/components/crud/DocumentEditor.d.ts +0 -32
- package/dist/studio/components/crud/DocumentEditor.d.ts.map +0 -1
- package/dist/studio/components/crud/DocumentEditor.js +0 -546
- package/dist/studio/components/crud/DocumentEditor.js.map +0 -1
- package/dist/studio/components/crud/InsertDocumentDialog.d.ts +0 -78
- package/dist/studio/components/crud/InsertDocumentDialog.d.ts.map +0 -1
- package/dist/studio/components/crud/InsertDocumentDialog.js +0 -323
- package/dist/studio/components/crud/InsertDocumentDialog.js.map +0 -1
- package/dist/studio/components/crud/__tests__/DeleteDocumentDialog.test.d.ts +0 -5
- package/dist/studio/components/crud/__tests__/DeleteDocumentDialog.test.d.ts.map +0 -1
- package/dist/studio/components/crud/__tests__/DeleteDocumentDialog.test.js +0 -298
- package/dist/studio/components/crud/__tests__/DeleteDocumentDialog.test.js.map +0 -1
- package/dist/studio/components/crud/__tests__/DocumentEditor.test.d.ts +0 -8
- package/dist/studio/components/crud/__tests__/DocumentEditor.test.d.ts.map +0 -1
- package/dist/studio/components/crud/__tests__/DocumentEditor.test.js +0 -368
- package/dist/studio/components/crud/__tests__/DocumentEditor.test.js.map +0 -1
- package/dist/studio/components/crud/__tests__/InsertDocumentDialog.test.d.ts +0 -2
- package/dist/studio/components/crud/__tests__/InsertDocumentDialog.test.d.ts.map +0 -1
- package/dist/studio/components/crud/__tests__/InsertDocumentDialog.test.js +0 -352
- package/dist/studio/components/crud/__tests__/InsertDocumentDialog.test.js.map +0 -1
- package/dist/studio/components/crud/__tests__/setup.d.ts +0 -5
- package/dist/studio/components/crud/__tests__/setup.d.ts.map +0 -1
- package/dist/studio/components/crud/__tests__/setup.js +0 -22
- package/dist/studio/components/crud/__tests__/setup.js.map +0 -1
- package/dist/studio/components/crud/index.d.ts +0 -12
- package/dist/studio/components/crud/index.d.ts.map +0 -1
- package/dist/studio/components/crud/index.js +0 -11
- package/dist/studio/components/crud/index.js.map +0 -1
- package/dist/studio/hooks/useConnection.d.ts +0 -127
- package/dist/studio/hooks/useConnection.d.ts.map +0 -1
- package/dist/studio/hooks/useConnection.js +0 -414
- package/dist/studio/hooks/useConnection.js.map +0 -1
- package/dist/studio/hooks/useDatabaseBrowser.d.ts +0 -107
- package/dist/studio/hooks/useDatabaseBrowser.d.ts.map +0 -1
- package/dist/studio/hooks/useDatabaseBrowser.js +0 -294
- package/dist/studio/hooks/useDatabaseBrowser.js.map +0 -1
- package/dist/studio/index.d.ts +0 -16
- package/dist/studio/index.d.ts.map +0 -1
- package/dist/studio/index.js +0 -14
- package/dist/studio/index.js.map +0 -1
- package/dist/studio/types/connection.d.ts +0 -266
- package/dist/studio/types/connection.d.ts.map +0 -1
- package/dist/studio/types/connection.js +0 -159
- package/dist/studio/types/connection.js.map +0 -1
- package/dist/studio/vitest.config.d.ts +0 -3
- package/dist/studio/vitest.config.d.ts.map +0 -1
- package/dist/studio/vitest.config.js +0 -33
- package/dist/studio/vitest.config.js.map +0 -1
- package/dist/translator/aggregation-translator.d.ts +0 -51
- package/dist/translator/aggregation-translator.d.ts.map +0 -1
- package/dist/translator/aggregation-translator.js +0 -324
- package/dist/translator/aggregation-translator.js.map +0 -1
- package/dist/translator/dialect.d.ts +0 -131
- package/dist/translator/dialect.d.ts.map +0 -1
- package/dist/translator/dialect.js +0 -276
- package/dist/translator/dialect.js.map +0 -1
- package/dist/translator/geo-translator.d.ts +0 -91
- package/dist/translator/geo-translator.d.ts.map +0 -1
- package/dist/translator/geo-translator.js +0 -587
- package/dist/translator/geo-translator.js.map +0 -1
- package/dist/translator/hybrid-translator.d.ts +0 -70
- package/dist/translator/hybrid-translator.d.ts.map +0 -1
- package/dist/translator/hybrid-translator.js +0 -193
- package/dist/translator/hybrid-translator.js.map +0 -1
- package/dist/translator/index.d.ts +0 -13
- package/dist/translator/index.d.ts.map +0 -1
- package/dist/translator/index.js +0 -11
- package/dist/translator/index.js.map +0 -1
- package/dist/translator/query-translator.d.ts +0 -211
- package/dist/translator/query-translator.d.ts.map +0 -1
- package/dist/translator/query-translator.js +0 -1276
- package/dist/translator/query-translator.js.map +0 -1
- package/dist/translator/search-highlight.d.ts +0 -83
- package/dist/translator/search-highlight.d.ts.map +0 -1
- package/dist/translator/search-highlight.js +0 -83
- package/dist/translator/search-highlight.js.map +0 -1
- package/dist/translator/search-translator.d.ts +0 -155
- package/dist/translator/search-translator.d.ts.map +0 -1
- package/dist/translator/search-translator.js +0 -241
- package/dist/translator/search-translator.js.map +0 -1
- package/dist/translator/stages/add-fields-stage.d.ts +0 -7
- package/dist/translator/stages/add-fields-stage.d.ts.map +0 -1
- package/dist/translator/stages/add-fields-stage.js +0 -72
- package/dist/translator/stages/add-fields-stage.js.map +0 -1
- package/dist/translator/stages/bucket-stage.d.ts +0 -7
- package/dist/translator/stages/bucket-stage.d.ts.map +0 -1
- package/dist/translator/stages/bucket-stage.js +0 -87
- package/dist/translator/stages/bucket-stage.js.map +0 -1
- package/dist/translator/stages/count-stage.d.ts +0 -7
- package/dist/translator/stages/count-stage.d.ts.map +0 -1
- package/dist/translator/stages/count-stage.js +0 -12
- package/dist/translator/stages/count-stage.js.map +0 -1
- package/dist/translator/stages/expression-translator.d.ts +0 -68
- package/dist/translator/stages/expression-translator.d.ts.map +0 -1
- package/dist/translator/stages/expression-translator.js +0 -467
- package/dist/translator/stages/expression-translator.js.map +0 -1
- package/dist/translator/stages/facet-stage.d.ts +0 -13
- package/dist/translator/stages/facet-stage.d.ts.map +0 -1
- package/dist/translator/stages/facet-stage.js +0 -26
- package/dist/translator/stages/facet-stage.js.map +0 -1
- package/dist/translator/stages/fusion-stages.d.ts +0 -118
- package/dist/translator/stages/fusion-stages.d.ts.map +0 -1
- package/dist/translator/stages/fusion-stages.js +0 -201
- package/dist/translator/stages/fusion-stages.js.map +0 -1
- package/dist/translator/stages/group-stage.d.ts +0 -8
- package/dist/translator/stages/group-stage.d.ts.map +0 -1
- package/dist/translator/stages/group-stage.js +0 -123
- package/dist/translator/stages/group-stage.js.map +0 -1
- package/dist/translator/stages/index.d.ts +0 -24
- package/dist/translator/stages/index.d.ts.map +0 -1
- package/dist/translator/stages/index.js +0 -24
- package/dist/translator/stages/index.js.map +0 -1
- package/dist/translator/stages/join-optimizer.d.ts +0 -37
- package/dist/translator/stages/join-optimizer.d.ts.map +0 -1
- package/dist/translator/stages/join-optimizer.js +0 -93
- package/dist/translator/stages/join-optimizer.js.map +0 -1
- package/dist/translator/stages/limit-stage.d.ts +0 -7
- package/dist/translator/stages/limit-stage.d.ts.map +0 -1
- package/dist/translator/stages/limit-stage.js +0 -11
- package/dist/translator/stages/limit-stage.js.map +0 -1
- package/dist/translator/stages/lookup-stage.d.ts +0 -7
- package/dist/translator/stages/lookup-stage.d.ts.map +0 -1
- package/dist/translator/stages/lookup-stage.js +0 -73
- package/dist/translator/stages/lookup-stage.js.map +0 -1
- package/dist/translator/stages/match-stage.d.ts +0 -7
- package/dist/translator/stages/match-stage.d.ts.map +0 -1
- package/dist/translator/stages/match-stage.js +0 -14
- package/dist/translator/stages/match-stage.js.map +0 -1
- package/dist/translator/stages/optimizer.d.ts +0 -15
- package/dist/translator/stages/optimizer.d.ts.map +0 -1
- package/dist/translator/stages/optimizer.js +0 -249
- package/dist/translator/stages/optimizer.js.map +0 -1
- package/dist/translator/stages/parallel-facet.d.ts +0 -47
- package/dist/translator/stages/parallel-facet.d.ts.map +0 -1
- package/dist/translator/stages/parallel-facet.js +0 -57
- package/dist/translator/stages/parallel-facet.js.map +0 -1
- package/dist/translator/stages/project-stage.d.ts +0 -8
- package/dist/translator/stages/project-stage.d.ts.map +0 -1
- package/dist/translator/stages/project-stage.js +0 -145
- package/dist/translator/stages/project-stage.js.map +0 -1
- package/dist/translator/stages/search-stage.d.ts +0 -60
- package/dist/translator/stages/search-stage.d.ts.map +0 -1
- package/dist/translator/stages/search-stage.js +0 -89
- package/dist/translator/stages/search-stage.js.map +0 -1
- package/dist/translator/stages/skip-stage.d.ts +0 -7
- package/dist/translator/stages/skip-stage.d.ts.map +0 -1
- package/dist/translator/stages/skip-stage.js +0 -11
- package/dist/translator/stages/skip-stage.js.map +0 -1
- package/dist/translator/stages/sort-stage.d.ts +0 -7
- package/dist/translator/stages/sort-stage.d.ts.map +0 -1
- package/dist/translator/stages/sort-stage.js +0 -21
- package/dist/translator/stages/sort-stage.js.map +0 -1
- package/dist/translator/stages/types.d.ts +0 -136
- package/dist/translator/stages/types.d.ts.map +0 -1
- package/dist/translator/stages/types.js +0 -5
- package/dist/translator/stages/types.js.map +0 -1
- package/dist/translator/stages/unwind-stage.d.ts +0 -7
- package/dist/translator/stages/unwind-stage.d.ts.map +0 -1
- package/dist/translator/stages/unwind-stage.js +0 -61
- package/dist/translator/stages/unwind-stage.js.map +0 -1
- package/dist/translator/stages/vector-search-stage.d.ts +0 -53
- package/dist/translator/stages/vector-search-stage.d.ts.map +0 -1
- package/dist/translator/stages/vector-search-stage.js +0 -62
- package/dist/translator/stages/vector-search-stage.js.map +0 -1
- package/dist/translator/update-translator.d.ts +0 -148
- package/dist/translator/update-translator.d.ts.map +0 -1
- package/dist/translator/update-translator.js +0 -819
- package/dist/translator/update-translator.js.map +0 -1
- package/dist/translator/vector-translator.d.ts +0 -89
- package/dist/translator/vector-translator.d.ts.map +0 -1
- package/dist/translator/vector-translator.js +0 -106
- package/dist/translator/vector-translator.js.map +0 -1
- package/dist/types/env.d.ts +0 -31
- package/dist/types/env.d.ts.map +0 -1
- package/dist/types/env.js +0 -5
- package/dist/types/env.js.map +0 -1
- package/dist/types/function.d.ts +0 -65
- package/dist/types/function.d.ts.map +0 -1
- package/dist/types/function.js +0 -5
- package/dist/types/function.js.map +0 -1
- package/dist/types/index.d.ts +0 -137
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -13
- package/dist/types/index.js.map +0 -1
- package/dist/types/mongodb.d.ts +0 -258
- package/dist/types/mongodb.d.ts.map +0 -1
- package/dist/types/mongodb.js +0 -5
- package/dist/types/mongodb.js.map +0 -1
- package/dist/types/objectid.d.ts +0 -130
- package/dist/types/objectid.d.ts.map +0 -1
- package/dist/types/objectid.js +0 -314
- package/dist/types/objectid.js.map +0 -1
- package/dist/types/rpc.d.ts +0 -313
- package/dist/types/rpc.d.ts.map +0 -1
- package/dist/types/rpc.js +0 -136
- package/dist/types/rpc.js.map +0 -1
- package/dist/types/vectorize.d.ts +0 -136
- package/dist/types/vectorize.d.ts.map +0 -1
- package/dist/types/vectorize.js +0 -8
- package/dist/types/vectorize.js.map +0 -1
- package/dist/utils/sql-safety.d.ts +0 -64
- package/dist/utils/sql-safety.d.ts.map +0 -1
- package/dist/utils/sql-safety.js +0 -112
- package/dist/utils/sql-safety.js.map +0 -1
- package/dist/validation/document-validator.d.ts +0 -195
- package/dist/validation/document-validator.d.ts.map +0 -1
- package/dist/validation/document-validator.js +0 -529
- package/dist/validation/document-validator.js.map +0 -1
- package/dist/vectorize/document-serializer.d.ts +0 -119
- package/dist/vectorize/document-serializer.d.ts.map +0 -1
- package/dist/vectorize/document-serializer.js +0 -320
- package/dist/vectorize/document-serializer.js.map +0 -1
- package/dist/wire/auth/index.d.ts +0 -5
- package/dist/wire/auth/index.d.ts.map +0 -1
- package/dist/wire/auth/index.js +0 -5
- package/dist/wire/auth/index.js.map +0 -1
- package/dist/wire/auth/scram.d.ts +0 -160
- package/dist/wire/auth/scram.d.ts.map +0 -1
- package/dist/wire/auth/scram.js +0 -425
- package/dist/wire/auth/scram.js.map +0 -1
- package/dist/wire/backend/interface.d.ts +0 -168
- package/dist/wire/backend/interface.d.ts.map +0 -1
- package/dist/wire/backend/interface.js +0 -10
- package/dist/wire/backend/interface.js.map +0 -1
- package/dist/wire/backend/local-sqlite.d.ts +0 -89
- package/dist/wire/backend/local-sqlite.d.ts.map +0 -1
- package/dist/wire/backend/local-sqlite.js +0 -1002
- package/dist/wire/backend/local-sqlite.js.map +0 -1
- package/dist/wire/backend/query-router.d.ts +0 -197
- package/dist/wire/backend/query-router.d.ts.map +0 -1
- package/dist/wire/backend/query-router.js +0 -590
- package/dist/wire/backend/query-router.js.map +0 -1
- package/dist/wire/backend/validation.d.ts +0 -26
- package/dist/wire/backend/validation.d.ts.map +0 -1
- package/dist/wire/backend/validation.js +0 -79
- package/dist/wire/backend/validation.js.map +0 -1
- package/dist/wire/backend/workers-proxy.d.ts +0 -95
- package/dist/wire/backend/workers-proxy.d.ts.map +0 -1
- package/dist/wire/backend/workers-proxy.js +0 -429
- package/dist/wire/backend/workers-proxy.js.map +0 -1
- package/dist/wire/commands/admin.d.ts +0 -49
- package/dist/wire/commands/admin.d.ts.map +0 -1
- package/dist/wire/commands/admin.js +0 -272
- package/dist/wire/commands/admin.js.map +0 -1
- package/dist/wire/commands/aggregate.d.ts +0 -15
- package/dist/wire/commands/aggregate.d.ts.map +0 -1
- package/dist/wire/commands/aggregate.js +0 -98
- package/dist/wire/commands/aggregate.js.map +0 -1
- package/dist/wire/commands/auth.d.ts +0 -58
- package/dist/wire/commands/auth.d.ts.map +0 -1
- package/dist/wire/commands/auth.js +0 -158
- package/dist/wire/commands/auth.js.map +0 -1
- package/dist/wire/commands/crud.d.ts +0 -49
- package/dist/wire/commands/crud.d.ts.map +0 -1
- package/dist/wire/commands/crud.js +0 -336
- package/dist/wire/commands/crud.js.map +0 -1
- package/dist/wire/commands/hello.d.ts +0 -35
- package/dist/wire/commands/hello.d.ts.map +0 -1
- package/dist/wire/commands/hello.js +0 -204
- package/dist/wire/commands/hello.js.map +0 -1
- package/dist/wire/commands/index.d.ts +0 -24
- package/dist/wire/commands/index.d.ts.map +0 -1
- package/dist/wire/commands/index.js +0 -145
- package/dist/wire/commands/index.js.map +0 -1
- package/dist/wire/commands/router.d.ts +0 -46
- package/dist/wire/commands/router.d.ts.map +0 -1
- package/dist/wire/commands/router.js +0 -151
- package/dist/wire/commands/router.js.map +0 -1
- package/dist/wire/commands/types.d.ts +0 -51
- package/dist/wire/commands/types.d.ts.map +0 -1
- package/dist/wire/commands/types.js +0 -15
- package/dist/wire/commands/types.js.map +0 -1
- package/dist/wire/index.d.ts +0 -15
- package/dist/wire/index.d.ts.map +0 -1
- package/dist/wire/index.js +0 -19
- package/dist/wire/index.js.map +0 -1
- package/dist/wire/message.d.ts +0 -49
- package/dist/wire/message.d.ts.map +0 -1
- package/dist/wire/message.js +0 -299
- package/dist/wire/message.js.map +0 -1
- package/dist/wire/server.d.ts +0 -145
- package/dist/wire/server.d.ts.map +0 -1
- package/dist/wire/server.js +0 -284
- package/dist/wire/server.js.map +0 -1
- package/dist/wire/types.d.ts +0 -140
- package/dist/wire/types.d.ts.map +0 -1
- package/dist/wire/types.js +0 -64
- package/dist/wire/types.js.map +0 -1
- package/dist/worker.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,2741 @@
|
|
|
1
|
+
import { S as SQLStorage, I as IndexInfo, c as IndexSpec, C as CreateIndexOptions, d as CreateIndexResult, D as DropIndexResult, T as TTLIndexInfo, e as ExpiredDocumentsQuery, f as TTLMetadata, g as TTLCleanupResult, O as ObjectId$1, P as PipelineStage, R as RpcClientOptions, h as EventHandler, i as RpcRequest, j as DeduplicatorOptions } from './worker-entrypoint-BEW23Gmp.js';
|
|
2
|
+
export { G as BatchResponse, X as BatchedExecutorOptions, a3 as BatchedRpcExecutor, V as CollectionRef, a8 as DEFAULT_OPTIONS, U as DatabaseRef, w as DurableObjectId, v as DurableObjectNamespace, x as DurableObjectStub, o as ErrorCode, $ as ErrorCodeValue, E as ExecutionContext, K as HttpRpcErrorResponse, H as HttpRpcRequest, L as HttpRpcResponse, J as HttpRpcSuccessResponse, N as LegacyRpcRequest, Q as LegacyRpcResponse, u as MessageType, a9 as MondoBindings, b as MondoDatabase, a as MondoEntrypoint, aa as MondoEntrypointOptions, M as MondoEnv, a1 as MondoRpcTarget, Y as PipelineOp, a4 as PipelineTracker, a5 as PipelinedRpcProxy, Z as ReconnectEvent, _ as RpcHandler, M as RpcMondoEnv, F as RpcResponse, a0 as RpcTarget, m as SCHEMA_TABLES, l as SCHEMA_VERSION, n as SQLStatement, k as SchemaManager, z as WorkerCode, W as WorkerEntrypoint, B as WorkerEntrypointType, y as WorkerLoader, A as WorkerStub, a as default, q as errorResponse, p as getErrorCodeName, a7 as isMondoEnv, t as legacyErrorResponse, r as legacySuccessResponse, a2 as newWorkersRpcResponse, s as successResponse, a6 as validateEnv } from './worker-entrypoint-BEW23Gmp.js';
|
|
3
|
+
import { DurableObjectNamespace } from '@cloudflare/workers-types';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
|
-
* mongo.do
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
* Index Manager for mongo.do
|
|
8
|
+
*
|
|
9
|
+
* Manages SQLite indexes for MongoDB-style collections backed by Durable Objects.
|
|
10
|
+
* Indexes are created on json_extract expressions to enable efficient querying.
|
|
11
|
+
*
|
|
12
|
+
* TTL (Time-To-Live) Index Support:
|
|
13
|
+
* - createIndex({field: 1}, {expireAfterSeconds: N}) creates a TTL index
|
|
14
|
+
* - Documents with date values in the TTL field will expire after N seconds
|
|
15
|
+
* - Background cleanup removes expired documents periodically
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generates an index name from collection name and key specification
|
|
20
|
+
*/
|
|
21
|
+
declare function generateIndexName(collectionName: string, keys: IndexSpec): string;
|
|
22
|
+
/**
|
|
23
|
+
* Generates the SQLite index name (prefixed for internal use)
|
|
24
|
+
*/
|
|
25
|
+
declare function generateSQLiteIndexName(collectionName: string, keys: IndexSpec, unique?: boolean): string;
|
|
26
|
+
/**
|
|
27
|
+
* Builds the SQL CREATE INDEX statement for given index specification
|
|
28
|
+
*/
|
|
29
|
+
declare function buildCreateIndexSQL(collectionName: string, collectionId: number, keys: IndexSpec, options?: CreateIndexOptions): {
|
|
30
|
+
sql: string;
|
|
31
|
+
indexName: string;
|
|
32
|
+
sqliteIndexName: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* IndexManager handles creation, deletion, and listing of indexes
|
|
36
|
+
* Includes TTL (Time-To-Live) index support for automatic document expiration
|
|
37
|
+
*/
|
|
38
|
+
declare class IndexManager {
|
|
39
|
+
private storage;
|
|
40
|
+
private cleanupIntervalMs;
|
|
41
|
+
private ttlMetadataCache;
|
|
42
|
+
constructor(storage: SQLStorage);
|
|
43
|
+
/**
|
|
44
|
+
* Ensure the collections and documents tables exist.
|
|
45
|
+
*
|
|
46
|
+
* UNIFIED SCHEMA: This uses the same schema as MondoDatabase/SchemaManager.
|
|
47
|
+
* The schema is defined in schema.ts/migrations.ts as the single source of truth.
|
|
48
|
+
* This method creates the tables if they don't exist (for standalone IndexManager usage).
|
|
49
|
+
*/
|
|
50
|
+
ensureMetadataTable(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Get or create a collection and return its ID
|
|
53
|
+
*/
|
|
54
|
+
getOrCreateCollection(name: string): {
|
|
55
|
+
id: number;
|
|
56
|
+
created: boolean;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Get collection metadata
|
|
60
|
+
*/
|
|
61
|
+
getCollection(name: string): {
|
|
62
|
+
id: number;
|
|
63
|
+
indexes: IndexInfo[];
|
|
64
|
+
} | null;
|
|
65
|
+
/**
|
|
66
|
+
* Create an index on a collection
|
|
67
|
+
*/
|
|
68
|
+
createIndex(collectionName: string, keys: IndexSpec, options?: CreateIndexOptions): CreateIndexResult;
|
|
69
|
+
/**
|
|
70
|
+
* List all indexes on a collection
|
|
71
|
+
*/
|
|
72
|
+
listIndexes(collectionName: string): IndexInfo[];
|
|
73
|
+
/**
|
|
74
|
+
* Drop a specific index by name
|
|
75
|
+
*/
|
|
76
|
+
dropIndex(collectionName: string, indexName: string): DropIndexResult;
|
|
77
|
+
/**
|
|
78
|
+
* Drop all indexes on a collection (except _id)
|
|
79
|
+
*/
|
|
80
|
+
dropIndexes(collectionName: string): DropIndexResult;
|
|
81
|
+
/**
|
|
82
|
+
* Get index usage hints for a query
|
|
83
|
+
* Returns suggested index names that could be used for the query
|
|
84
|
+
*/
|
|
85
|
+
getIndexHints(collectionName: string, queryFields: string[]): string[];
|
|
86
|
+
/**
|
|
87
|
+
* Get all TTL indexes across all collections
|
|
88
|
+
*/
|
|
89
|
+
getTTLIndexes(): TTLIndexInfo[];
|
|
90
|
+
/**
|
|
91
|
+
* Check if a specific index is a TTL index
|
|
92
|
+
*/
|
|
93
|
+
isTTLIndex(collectionName: string, indexName: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Check if a value is a valid date for TTL purposes
|
|
96
|
+
* Accepts Date objects, ISO strings, and Unix timestamps (in ms)
|
|
97
|
+
*/
|
|
98
|
+
isValidTTLFieldValue(value: unknown): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Calculate expiration time for a document
|
|
101
|
+
*/
|
|
102
|
+
calculateExpirationTime(dateValue: Date | string | number, expireAfterSeconds: number): Date;
|
|
103
|
+
/**
|
|
104
|
+
* Check if a document is expired based on its TTL field
|
|
105
|
+
*/
|
|
106
|
+
isDocumentExpired(document: Record<string, unknown>, field: string, expireAfterSeconds: number): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Build SQL query to delete expired documents for a collection
|
|
109
|
+
*/
|
|
110
|
+
buildExpiredDocumentsQuery(collectionName: string, field: string, expireAfterSeconds: number): ExpiredDocumentsQuery;
|
|
111
|
+
/**
|
|
112
|
+
* Get TTL metadata for a specific index
|
|
113
|
+
*/
|
|
114
|
+
getTTLMetadata(collectionName: string, indexName: string): TTLMetadata | null;
|
|
115
|
+
/**
|
|
116
|
+
* Record a TTL cleanup operation for tracking purposes
|
|
117
|
+
*/
|
|
118
|
+
recordTTLCleanup(collectionName: string, indexName: string, deletedCount: number): void;
|
|
119
|
+
/**
|
|
120
|
+
* Get the next cleanup time based on the configured interval
|
|
121
|
+
*/
|
|
122
|
+
getNextCleanupTime(): number;
|
|
123
|
+
/**
|
|
124
|
+
* Set the cleanup interval in milliseconds
|
|
125
|
+
*/
|
|
126
|
+
setCleanupInterval(intervalMs: number): void;
|
|
127
|
+
/**
|
|
128
|
+
* Run TTL cleanup across all collections with TTL indexes
|
|
129
|
+
* Deletes all expired documents and returns cleanup statistics
|
|
130
|
+
*/
|
|
131
|
+
runTTLCleanup(): Promise<TTLCleanupResult>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Cloudflare Vectorize types for vector search
|
|
136
|
+
*
|
|
137
|
+
* These interfaces match the Cloudflare Vectorize API for compatibility
|
|
138
|
+
* with the Workers AI embeddings and vector similarity search.
|
|
139
|
+
*/
|
|
140
|
+
/**
|
|
141
|
+
* Supported metadata value types for vector storage
|
|
142
|
+
*/
|
|
143
|
+
type VectorizeMetadataValue = string | number | boolean | string[];
|
|
144
|
+
/**
|
|
145
|
+
* Metadata object attached to vectors
|
|
146
|
+
*/
|
|
147
|
+
type VectorizeMetadata = Record<string, VectorizeMetadataValue>;
|
|
148
|
+
/**
|
|
149
|
+
* A vector with its ID, values, and optional metadata
|
|
150
|
+
*/
|
|
151
|
+
interface VectorizeVector {
|
|
152
|
+
/** Unique identifier for the vector */
|
|
153
|
+
id: string;
|
|
154
|
+
/** The embedding vector values */
|
|
155
|
+
values: number[] | Float32Array | Float64Array;
|
|
156
|
+
/** Optional namespace for organizing vectors */
|
|
157
|
+
namespace?: string;
|
|
158
|
+
/** Optional metadata attached to the vector */
|
|
159
|
+
metadata?: VectorizeMetadata;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Options for querying vectors
|
|
163
|
+
*/
|
|
164
|
+
interface VectorizeQueryOptions {
|
|
165
|
+
/** Number of results to return (default: 10) */
|
|
166
|
+
topK?: number;
|
|
167
|
+
/** Optional namespace to search within */
|
|
168
|
+
namespace?: string;
|
|
169
|
+
/** Whether to return vector values (default: false) */
|
|
170
|
+
returnValues?: boolean;
|
|
171
|
+
/** Whether to return metadata (default: false) */
|
|
172
|
+
returnMetadata?: 'none' | 'indexed' | 'all';
|
|
173
|
+
/** Optional filter expression for metadata filtering */
|
|
174
|
+
filter?: Record<string, VectorizeMetadataValue>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A match result from a vector query
|
|
178
|
+
*/
|
|
179
|
+
interface VectorizeMatch {
|
|
180
|
+
/** The vector ID */
|
|
181
|
+
id: string;
|
|
182
|
+
/** Similarity score (higher is more similar) */
|
|
183
|
+
score: number;
|
|
184
|
+
/** The vector values (if returnValues was true) */
|
|
185
|
+
values?: number[];
|
|
186
|
+
/** The metadata (if returnMetadata was set) */
|
|
187
|
+
metadata?: VectorizeMetadata;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Result from a vector query operation
|
|
191
|
+
*/
|
|
192
|
+
interface VectorizeQueryResult {
|
|
193
|
+
/** Number of matches returned */
|
|
194
|
+
count: number;
|
|
195
|
+
/** The matching vectors */
|
|
196
|
+
matches: VectorizeMatch[];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Result from a vector mutation operation (insert, upsert, delete)
|
|
200
|
+
*/
|
|
201
|
+
interface VectorizeMutationResult {
|
|
202
|
+
/** Number of vectors affected */
|
|
203
|
+
count: number;
|
|
204
|
+
/** IDs of affected vectors */
|
|
205
|
+
ids: string[];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Vectorize index interface matching Cloudflare's API
|
|
209
|
+
*/
|
|
210
|
+
interface VectorizeIndex {
|
|
211
|
+
/**
|
|
212
|
+
* Query the index for similar vectors
|
|
213
|
+
* @param vector - The query vector
|
|
214
|
+
* @param options - Query options
|
|
215
|
+
*/
|
|
216
|
+
query(vector: number[] | Float32Array | Float64Array, options?: VectorizeQueryOptions): Promise<VectorizeQueryResult>;
|
|
217
|
+
/**
|
|
218
|
+
* Insert vectors into the index
|
|
219
|
+
* @param vectors - Vectors to insert
|
|
220
|
+
*/
|
|
221
|
+
insert(vectors: VectorizeVector[]): Promise<VectorizeMutationResult>;
|
|
222
|
+
/**
|
|
223
|
+
* Upsert vectors into the index (insert or update)
|
|
224
|
+
* @param vectors - Vectors to upsert
|
|
225
|
+
*/
|
|
226
|
+
upsert(vectors: VectorizeVector[]): Promise<VectorizeMutationResult>;
|
|
227
|
+
/**
|
|
228
|
+
* Delete vectors by ID
|
|
229
|
+
* @param ids - IDs of vectors to delete
|
|
230
|
+
*/
|
|
231
|
+
deleteByIds(ids: string[]): Promise<VectorizeMutationResult>;
|
|
232
|
+
/**
|
|
233
|
+
* Get vectors by ID
|
|
234
|
+
* @param ids - IDs of vectors to retrieve
|
|
235
|
+
*/
|
|
236
|
+
getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
237
|
+
/**
|
|
238
|
+
* Describe the index configuration
|
|
239
|
+
*/
|
|
240
|
+
describe(): Promise<{
|
|
241
|
+
dimensions: number;
|
|
242
|
+
vectorsCount: number;
|
|
243
|
+
config: {
|
|
244
|
+
dimensions: number;
|
|
245
|
+
metric: 'cosine' | 'euclidean' | 'dot-product';
|
|
246
|
+
};
|
|
247
|
+
}>;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Workers AI binding interface for embeddings
|
|
251
|
+
*/
|
|
252
|
+
interface Ai {
|
|
253
|
+
/**
|
|
254
|
+
* Run an AI model
|
|
255
|
+
* @param model - The model identifier (e.g., '@cf/baai/bge-m3')
|
|
256
|
+
* @param inputs - The inputs for the model
|
|
257
|
+
*/
|
|
258
|
+
run<T = unknown>(model: string, inputs: Record<string, unknown>): Promise<T>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Cloudflare Workers environment bindings
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Environment interface for Cloudflare Workers
|
|
267
|
+
*/
|
|
268
|
+
interface Env {
|
|
269
|
+
/**
|
|
270
|
+
* Durable Object namespace for MondoDatabase instances
|
|
271
|
+
*/
|
|
272
|
+
MONDO_DATABASE: DurableObjectNamespace;
|
|
273
|
+
/**
|
|
274
|
+
* Optional Vectorize index binding for vector search
|
|
275
|
+
*/
|
|
276
|
+
VECTORIZE?: VectorizeIndex;
|
|
277
|
+
/**
|
|
278
|
+
* Optional Workers AI binding for generating embeddings
|
|
279
|
+
*/
|
|
280
|
+
AI?: Ai;
|
|
281
|
+
/**
|
|
282
|
+
* Optional embedding model to use (e.g., '@cf/baai/bge-m3')
|
|
283
|
+
*/
|
|
284
|
+
EMBEDDING_MODEL?: string;
|
|
285
|
+
/**
|
|
286
|
+
* Optional flag to enable/disable automatic embedding generation
|
|
287
|
+
*/
|
|
288
|
+
EMBEDDING_ENABLED?: string;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* MongoDB-compatible type definitions
|
|
293
|
+
*/
|
|
294
|
+
/**
|
|
295
|
+
* A BSON document - the fundamental data structure in MongoDB
|
|
296
|
+
*/
|
|
297
|
+
interface Document$3 {
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
_id?: string | ObjectId;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* ObjectId type for document identifiers
|
|
303
|
+
*/
|
|
304
|
+
interface ObjectId {
|
|
305
|
+
toString(): string;
|
|
306
|
+
toHexString(): string;
|
|
307
|
+
getTimestamp(): Date;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Filter query type for finding documents
|
|
311
|
+
*/
|
|
312
|
+
type Filter<T = Document$3> = {
|
|
313
|
+
[P in keyof T]?: T[P] | FilterOperators<T[P]>;
|
|
314
|
+
} & RootFilterOperators<T>;
|
|
315
|
+
/**
|
|
316
|
+
* Filter operators like $eq, $gt, $lt, etc.
|
|
317
|
+
*/
|
|
318
|
+
interface FilterOperators<T> {
|
|
319
|
+
$eq?: T;
|
|
320
|
+
$ne?: T;
|
|
321
|
+
$gt?: T;
|
|
322
|
+
$gte?: T;
|
|
323
|
+
$lt?: T;
|
|
324
|
+
$lte?: T;
|
|
325
|
+
$in?: T[];
|
|
326
|
+
$nin?: T[];
|
|
327
|
+
$exists?: boolean;
|
|
328
|
+
$type?: string | number;
|
|
329
|
+
$regex?: string | RegExp;
|
|
330
|
+
$options?: string;
|
|
331
|
+
$not?: FilterOperators<T>;
|
|
332
|
+
$elemMatch?: T extends (infer U)[] ? Filter<U & Document$3> : never;
|
|
333
|
+
$size?: number;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Root-level filter operators like $and, $or, $nor
|
|
337
|
+
*/
|
|
338
|
+
interface RootFilterOperators<T> {
|
|
339
|
+
$and?: Filter<T & Document$3>[];
|
|
340
|
+
$or?: Filter<T & Document$3>[];
|
|
341
|
+
$nor?: Filter<T & Document$3>[];
|
|
342
|
+
$text?: {
|
|
343
|
+
$search: string;
|
|
344
|
+
$language?: string;
|
|
345
|
+
$caseSensitive?: boolean;
|
|
346
|
+
$diacriticSensitive?: boolean;
|
|
347
|
+
};
|
|
348
|
+
$where?: string | ((this: T) => boolean);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Update filter type for modifying documents
|
|
352
|
+
*/
|
|
353
|
+
interface UpdateFilter<T extends Document$3 = Document$3> {
|
|
354
|
+
$set?: Partial<T>;
|
|
355
|
+
$unset?: {
|
|
356
|
+
[P in keyof T]?: '' | 1 | true;
|
|
357
|
+
};
|
|
358
|
+
$inc?: {
|
|
359
|
+
[P in keyof T]?: number;
|
|
360
|
+
};
|
|
361
|
+
$mul?: {
|
|
362
|
+
[P in keyof T]?: number;
|
|
363
|
+
};
|
|
364
|
+
$min?: Partial<T>;
|
|
365
|
+
$max?: Partial<T>;
|
|
366
|
+
$rename?: {
|
|
367
|
+
[key: string]: string;
|
|
368
|
+
};
|
|
369
|
+
$push?: {
|
|
370
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? U | ArrayUpdateOperators<U> : never;
|
|
371
|
+
};
|
|
372
|
+
$pull?: {
|
|
373
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? U | Filter<U & Document$3> : never;
|
|
374
|
+
};
|
|
375
|
+
$addToSet?: {
|
|
376
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? U | {
|
|
377
|
+
$each: U[];
|
|
378
|
+
} : never;
|
|
379
|
+
};
|
|
380
|
+
$pop?: {
|
|
381
|
+
[P in keyof T]?: 1 | -1;
|
|
382
|
+
};
|
|
383
|
+
$currentDate?: {
|
|
384
|
+
[P in keyof T]?: true | {
|
|
385
|
+
$type: 'date' | 'timestamp';
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Array update operators for $push
|
|
391
|
+
*/
|
|
392
|
+
interface ArrayUpdateOperators<T> {
|
|
393
|
+
$each?: T[];
|
|
394
|
+
$slice?: number;
|
|
395
|
+
$sort?: 1 | -1 | {
|
|
396
|
+
[key: string]: 1 | -1;
|
|
397
|
+
};
|
|
398
|
+
$position?: number;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Options for find operations
|
|
402
|
+
*/
|
|
403
|
+
interface FindOptions$2<T extends Document$3 = Document$3> {
|
|
404
|
+
projection?: {
|
|
405
|
+
[P in keyof T]?: 0 | 1 | boolean;
|
|
406
|
+
} | undefined;
|
|
407
|
+
sort?: {
|
|
408
|
+
[P in keyof T]?: 1 | -1;
|
|
409
|
+
} | [string, 1 | -1][] | undefined;
|
|
410
|
+
skip?: number | undefined;
|
|
411
|
+
limit?: number | undefined;
|
|
412
|
+
hint?: string | {
|
|
413
|
+
[key: string]: 1 | -1;
|
|
414
|
+
} | undefined;
|
|
415
|
+
maxTimeMS?: number | undefined;
|
|
416
|
+
readConcern?: {
|
|
417
|
+
level: 'local' | 'majority' | 'linearizable' | 'available' | 'snapshot';
|
|
418
|
+
} | undefined;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Result of insertOne operation
|
|
422
|
+
*/
|
|
423
|
+
interface InsertOneResult$1 {
|
|
424
|
+
acknowledged: boolean;
|
|
425
|
+
insertedId: string | ObjectId;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Result of insertMany operation
|
|
429
|
+
*/
|
|
430
|
+
interface InsertManyResult$1 {
|
|
431
|
+
acknowledged: boolean;
|
|
432
|
+
insertedCount: number;
|
|
433
|
+
insertedIds: {
|
|
434
|
+
[key: number]: string | ObjectId;
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Result of update operations
|
|
439
|
+
*/
|
|
440
|
+
interface UpdateResult$1 {
|
|
441
|
+
acknowledged: boolean;
|
|
442
|
+
matchedCount: number;
|
|
443
|
+
modifiedCount: number;
|
|
444
|
+
upsertedCount: number;
|
|
445
|
+
upsertedId?: string | ObjectId;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Result of delete operations
|
|
449
|
+
*/
|
|
450
|
+
interface DeleteResult$1 {
|
|
451
|
+
acknowledged: boolean;
|
|
452
|
+
deletedCount: number;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Options for aggregation pipeline
|
|
456
|
+
*/
|
|
457
|
+
interface AggregateOptions {
|
|
458
|
+
allowDiskUse?: boolean | undefined;
|
|
459
|
+
maxTimeMS?: number | undefined;
|
|
460
|
+
bypassDocumentValidation?: boolean | undefined;
|
|
461
|
+
readConcern?: {
|
|
462
|
+
level: string;
|
|
463
|
+
} | undefined;
|
|
464
|
+
collation?: CollationOptions | undefined;
|
|
465
|
+
hint?: string | Document$3 | undefined;
|
|
466
|
+
comment?: string | undefined;
|
|
467
|
+
let?: Document$3 | undefined;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Collation options for string comparison
|
|
471
|
+
*/
|
|
472
|
+
interface CollationOptions {
|
|
473
|
+
locale: string;
|
|
474
|
+
caseLevel?: boolean;
|
|
475
|
+
caseFirst?: 'upper' | 'lower' | 'off';
|
|
476
|
+
strength?: 1 | 2 | 3 | 4 | 5;
|
|
477
|
+
numericOrdering?: boolean;
|
|
478
|
+
alternate?: 'non-ignorable' | 'shifted';
|
|
479
|
+
maxVariable?: 'punct' | 'space';
|
|
480
|
+
backwards?: boolean;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Index specification for createIndex
|
|
484
|
+
*/
|
|
485
|
+
interface IndexSpecification {
|
|
486
|
+
key: {
|
|
487
|
+
[key: string]: 1 | -1 | 'text' | '2dsphere' | '2d' | 'hashed';
|
|
488
|
+
};
|
|
489
|
+
name?: string;
|
|
490
|
+
unique?: boolean;
|
|
491
|
+
sparse?: boolean;
|
|
492
|
+
background?: boolean;
|
|
493
|
+
expireAfterSeconds?: number;
|
|
494
|
+
partialFilterExpression?: Filter;
|
|
495
|
+
collation?: CollationOptions;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Aggregation pipeline stage types
|
|
499
|
+
*/
|
|
500
|
+
type AggregationStage = {
|
|
501
|
+
$match: Filter;
|
|
502
|
+
} | {
|
|
503
|
+
$project: Document$3;
|
|
504
|
+
} | {
|
|
505
|
+
$group: {
|
|
506
|
+
_id: unknown;
|
|
507
|
+
[key: string]: unknown;
|
|
508
|
+
};
|
|
509
|
+
} | {
|
|
510
|
+
$sort: {
|
|
511
|
+
[key: string]: 1 | -1;
|
|
512
|
+
};
|
|
513
|
+
} | {
|
|
514
|
+
$limit: number;
|
|
515
|
+
} | {
|
|
516
|
+
$skip: number;
|
|
517
|
+
} | {
|
|
518
|
+
$unwind: string | {
|
|
519
|
+
path: string;
|
|
520
|
+
preserveNullAndEmptyArrays?: boolean;
|
|
521
|
+
};
|
|
522
|
+
} | {
|
|
523
|
+
$lookup: LookupStage;
|
|
524
|
+
} | {
|
|
525
|
+
$addFields: Document$3;
|
|
526
|
+
} | {
|
|
527
|
+
$replaceRoot: {
|
|
528
|
+
newRoot: string | Document$3;
|
|
529
|
+
};
|
|
530
|
+
} | {
|
|
531
|
+
$count: string;
|
|
532
|
+
} | {
|
|
533
|
+
$facet: {
|
|
534
|
+
[key: string]: AggregationStage[];
|
|
535
|
+
};
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* $lookup stage configuration
|
|
539
|
+
*/
|
|
540
|
+
interface LookupStage {
|
|
541
|
+
from: string;
|
|
542
|
+
localField?: string;
|
|
543
|
+
foreignField?: string;
|
|
544
|
+
as: string;
|
|
545
|
+
let?: Document$3;
|
|
546
|
+
pipeline?: AggregationStage[];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* HTTP Cursors - MongoDB-compatible cursor implementations for HTTP client
|
|
551
|
+
*
|
|
552
|
+
* These cursors wrap HTTP requests to provide lazy evaluation, streaming,
|
|
553
|
+
* and MongoDB-compatible iteration patterns for find() and aggregate() operations.
|
|
554
|
+
*/
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Sort direction: 1 for ascending, -1 for descending
|
|
558
|
+
*/
|
|
559
|
+
type SortDirection = 1 | -1;
|
|
560
|
+
/**
|
|
561
|
+
* Sort specification with field names and directions
|
|
562
|
+
*/
|
|
563
|
+
type SortSpec = Record<string, SortDirection>;
|
|
564
|
+
/**
|
|
565
|
+
* Projection specification: 1 to include, 0 to exclude
|
|
566
|
+
*/
|
|
567
|
+
type ProjectionSpec = Record<string, 0 | 1>;
|
|
568
|
+
/**
|
|
569
|
+
* HTTP request function type
|
|
570
|
+
*/
|
|
571
|
+
type HttpRequestFn<T> = (method: string, path: string, body?: unknown) => Promise<T>;
|
|
572
|
+
/**
|
|
573
|
+
* HttpFindCursor - Cursor for find() operations via HTTP
|
|
574
|
+
*
|
|
575
|
+
* Provides MongoDB-compatible cursor interface with:
|
|
576
|
+
* - Lazy evaluation (data fetched on first access)
|
|
577
|
+
* - Chainable modifiers (sort, limit, skip, project)
|
|
578
|
+
* - Async iteration support
|
|
579
|
+
* - toArray() for collecting all results
|
|
580
|
+
*/
|
|
581
|
+
declare class HttpFindCursor<TDocument extends Document$3 = Document$3> {
|
|
582
|
+
private readonly requestFn;
|
|
583
|
+
private readonly filter;
|
|
584
|
+
private _sort?;
|
|
585
|
+
private _limit?;
|
|
586
|
+
private _skip?;
|
|
587
|
+
private _projection?;
|
|
588
|
+
private _batchSize?;
|
|
589
|
+
private _buffer;
|
|
590
|
+
private _position;
|
|
591
|
+
private _fetched;
|
|
592
|
+
private _closed;
|
|
593
|
+
private _error;
|
|
594
|
+
/**
|
|
595
|
+
* Create a new HttpFindCursor
|
|
596
|
+
*
|
|
597
|
+
* @param requestFn - Function to make HTTP requests
|
|
598
|
+
* @param filter - Query filter
|
|
599
|
+
* @param options - Initial find options
|
|
600
|
+
*/
|
|
601
|
+
constructor(requestFn: HttpRequestFn<TDocument[]>, filter?: Filter<TDocument>, options?: FindOptions$2<TDocument>);
|
|
602
|
+
/**
|
|
603
|
+
* Whether the cursor is closed
|
|
604
|
+
*/
|
|
605
|
+
get closed(): boolean;
|
|
606
|
+
/**
|
|
607
|
+
* Number of documents currently buffered
|
|
608
|
+
*/
|
|
609
|
+
get bufferedCount(): number;
|
|
610
|
+
/**
|
|
611
|
+
* Set the sort order for documents
|
|
612
|
+
*/
|
|
613
|
+
sort(spec: SortSpec): this;
|
|
614
|
+
/**
|
|
615
|
+
* Set a limit on the number of documents to return
|
|
616
|
+
*/
|
|
617
|
+
limit(count: number): this;
|
|
618
|
+
/**
|
|
619
|
+
* Set the number of documents to skip
|
|
620
|
+
*/
|
|
621
|
+
skip(count: number): this;
|
|
622
|
+
/**
|
|
623
|
+
* Set the projection for returned documents
|
|
624
|
+
*/
|
|
625
|
+
project(spec: ProjectionSpec): this;
|
|
626
|
+
/**
|
|
627
|
+
* Set the batch size for streaming (hint for server)
|
|
628
|
+
*/
|
|
629
|
+
batchSize(size: number): this;
|
|
630
|
+
/**
|
|
631
|
+
* Ensure data has been fetched from the server
|
|
632
|
+
*/
|
|
633
|
+
private ensureFetched;
|
|
634
|
+
/**
|
|
635
|
+
* Get the next document from the cursor
|
|
636
|
+
* Returns null when exhausted
|
|
637
|
+
*/
|
|
638
|
+
next(): Promise<TDocument | null>;
|
|
639
|
+
/**
|
|
640
|
+
* Check if there are more documents
|
|
641
|
+
*/
|
|
642
|
+
hasNext(): Promise<boolean>;
|
|
643
|
+
/**
|
|
644
|
+
* Get all documents as an array
|
|
645
|
+
*/
|
|
646
|
+
toArray(): Promise<TDocument[]>;
|
|
647
|
+
/**
|
|
648
|
+
* Iterate over all documents with a callback
|
|
649
|
+
* Return false from callback to stop iteration
|
|
650
|
+
*/
|
|
651
|
+
forEach(callback: (doc: TDocument, index: number) => void | false | Promise<void | false>): Promise<void>;
|
|
652
|
+
/**
|
|
653
|
+
* Transform documents with a mapping function
|
|
654
|
+
*/
|
|
655
|
+
map<U>(fn: (doc: TDocument, index: number) => U): MappedHttpCursor<TDocument, U>;
|
|
656
|
+
/**
|
|
657
|
+
* Count documents without consuming the cursor
|
|
658
|
+
*/
|
|
659
|
+
count(): Promise<number>;
|
|
660
|
+
/**
|
|
661
|
+
* Close the cursor and release resources
|
|
662
|
+
*/
|
|
663
|
+
close(): Promise<void>;
|
|
664
|
+
/**
|
|
665
|
+
* Clone this cursor with the same options
|
|
666
|
+
*/
|
|
667
|
+
clone(): HttpFindCursor<TDocument>;
|
|
668
|
+
/**
|
|
669
|
+
* Async iterator implementation
|
|
670
|
+
* Supports for-await-of syntax
|
|
671
|
+
*/
|
|
672
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<TDocument>;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Mapped cursor for transformed results
|
|
676
|
+
*/
|
|
677
|
+
declare class MappedHttpCursor<TDocument extends Document$3, U> {
|
|
678
|
+
private readonly _cursor;
|
|
679
|
+
private readonly _mapFn;
|
|
680
|
+
constructor(cursor: HttpFindCursor<TDocument>, mapFn: (doc: TDocument, index: number) => U);
|
|
681
|
+
toArray(): Promise<U[]>;
|
|
682
|
+
forEach(callback: (doc: U, index: number) => void | false | Promise<void | false>): Promise<void>;
|
|
683
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<U>;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* HttpAggregationCursor - Cursor for aggregate() operations via HTTP
|
|
687
|
+
*
|
|
688
|
+
* Provides MongoDB-compatible cursor interface with:
|
|
689
|
+
* - Lazy evaluation (pipeline executed on first access)
|
|
690
|
+
* - Async iteration support
|
|
691
|
+
* - toArray() for collecting all results
|
|
692
|
+
*/
|
|
693
|
+
declare class HttpAggregationCursor<TResult extends Document$3 = Document$3> {
|
|
694
|
+
private readonly requestFn;
|
|
695
|
+
private readonly pipeline;
|
|
696
|
+
private readonly options;
|
|
697
|
+
private _buffer;
|
|
698
|
+
private _position;
|
|
699
|
+
private _fetched;
|
|
700
|
+
private _closed;
|
|
701
|
+
private _error;
|
|
702
|
+
/**
|
|
703
|
+
* Create a new HttpAggregationCursor
|
|
704
|
+
*
|
|
705
|
+
* @param requestFn - Function to make HTTP requests
|
|
706
|
+
* @param pipeline - Aggregation pipeline stages
|
|
707
|
+
* @param options - Aggregation options
|
|
708
|
+
*/
|
|
709
|
+
constructor(requestFn: HttpRequestFn<TResult[]>, pipeline: AggregationStage[], options?: AggregateOptions);
|
|
710
|
+
/**
|
|
711
|
+
* Whether the cursor is closed
|
|
712
|
+
*/
|
|
713
|
+
get closed(): boolean;
|
|
714
|
+
/**
|
|
715
|
+
* Number of documents currently buffered
|
|
716
|
+
*/
|
|
717
|
+
get bufferedCount(): number;
|
|
718
|
+
/**
|
|
719
|
+
* Ensure data has been fetched from the server
|
|
720
|
+
*/
|
|
721
|
+
private ensureFetched;
|
|
722
|
+
/**
|
|
723
|
+
* Get the next document from the cursor
|
|
724
|
+
* Returns null when exhausted
|
|
725
|
+
*/
|
|
726
|
+
next(): Promise<TResult | null>;
|
|
727
|
+
/**
|
|
728
|
+
* Check if there are more documents
|
|
729
|
+
*/
|
|
730
|
+
hasNext(): Promise<boolean>;
|
|
731
|
+
/**
|
|
732
|
+
* Get all documents as an array
|
|
733
|
+
*/
|
|
734
|
+
toArray(): Promise<TResult[]>;
|
|
735
|
+
/**
|
|
736
|
+
* Iterate over all documents with a callback
|
|
737
|
+
* Return false from callback to stop iteration
|
|
738
|
+
*/
|
|
739
|
+
forEach(callback: (doc: TResult, index: number) => void | false | Promise<void | false>): Promise<void>;
|
|
740
|
+
/**
|
|
741
|
+
* Transform documents with a mapping function
|
|
742
|
+
*/
|
|
743
|
+
map<U>(fn: (doc: TResult, index: number) => U): MappedHttpAggregationCursor<TResult, U>;
|
|
744
|
+
/**
|
|
745
|
+
* Close the cursor and release resources
|
|
746
|
+
*/
|
|
747
|
+
close(): Promise<void>;
|
|
748
|
+
/**
|
|
749
|
+
* Clone this cursor with the same options
|
|
750
|
+
*/
|
|
751
|
+
clone(): HttpAggregationCursor<TResult>;
|
|
752
|
+
/**
|
|
753
|
+
* Async iterator implementation
|
|
754
|
+
* Supports for-await-of syntax
|
|
755
|
+
*/
|
|
756
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<TResult>;
|
|
757
|
+
/**
|
|
758
|
+
* Explain the aggregation plan (returns pipeline stages)
|
|
759
|
+
*/
|
|
760
|
+
explain(): {
|
|
761
|
+
pipeline: AggregationStage[];
|
|
762
|
+
options: AggregateOptions;
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Mapped aggregation cursor for transformed results
|
|
767
|
+
*/
|
|
768
|
+
declare class MappedHttpAggregationCursor<TResult extends Document$3, U> {
|
|
769
|
+
private readonly _cursor;
|
|
770
|
+
private readonly _mapFn;
|
|
771
|
+
constructor(cursor: HttpAggregationCursor<TResult>, mapFn: (doc: TResult, index: number) => U);
|
|
772
|
+
toArray(): Promise<U[]>;
|
|
773
|
+
forEach(callback: (doc: U, index: number) => void | false | Promise<void | false>): Promise<void>;
|
|
774
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<U>;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Collection - MongoDB-compatible collection interface
|
|
779
|
+
*
|
|
780
|
+
* Provides CRUD operations on documents within a collection.
|
|
781
|
+
*/
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Collection class
|
|
785
|
+
*
|
|
786
|
+
* Provides MongoDB-compatible operations on a collection of documents.
|
|
787
|
+
*/
|
|
788
|
+
declare class Collection$1<TDocument extends Document$3 = Document$3> {
|
|
789
|
+
private env;
|
|
790
|
+
private dbName;
|
|
791
|
+
private collectionName;
|
|
792
|
+
/**
|
|
793
|
+
* Create a new Collection instance
|
|
794
|
+
*
|
|
795
|
+
* @param env - Cloudflare Workers environment with MONDO_DATABASE binding
|
|
796
|
+
* @param dbName - The name of the database
|
|
797
|
+
* @param collectionName - The name of the collection
|
|
798
|
+
*/
|
|
799
|
+
constructor(env: Env, dbName: string, collectionName: string);
|
|
800
|
+
/**
|
|
801
|
+
* Get the Durable Object stub for this collection's database
|
|
802
|
+
*/
|
|
803
|
+
private getStub;
|
|
804
|
+
/**
|
|
805
|
+
* Make a request to the Durable Object
|
|
806
|
+
*/
|
|
807
|
+
private request;
|
|
808
|
+
/**
|
|
809
|
+
* Insert a single document
|
|
810
|
+
*
|
|
811
|
+
* @param doc - The document to insert
|
|
812
|
+
* @returns InsertOneResult with the inserted document's _id
|
|
813
|
+
*/
|
|
814
|
+
insertOne(doc: Omit<TDocument, '_id'> | TDocument): Promise<InsertOneResult$1>;
|
|
815
|
+
/**
|
|
816
|
+
* Insert multiple documents
|
|
817
|
+
*
|
|
818
|
+
* @param docs - Array of documents to insert
|
|
819
|
+
* @returns InsertManyResult with count and inserted IDs
|
|
820
|
+
*/
|
|
821
|
+
insertMany(docs: Array<Omit<TDocument, '_id'> | TDocument>): Promise<InsertManyResult$1>;
|
|
822
|
+
/**
|
|
823
|
+
* Find a single document matching the filter
|
|
824
|
+
*
|
|
825
|
+
* @param filter - Query filter
|
|
826
|
+
* @param options - Find options (projection, sort, etc.)
|
|
827
|
+
* @returns The matching document or null
|
|
828
|
+
*/
|
|
829
|
+
findOne(filter?: Filter<TDocument>, options?: FindOptions$2<TDocument>): Promise<TDocument | null>;
|
|
830
|
+
/**
|
|
831
|
+
* Find all documents matching the filter
|
|
832
|
+
*
|
|
833
|
+
* Returns a cursor that supports:
|
|
834
|
+
* - Async iteration with `for await (const doc of cursor)`
|
|
835
|
+
* - Converting to array with `await cursor.toArray()`
|
|
836
|
+
* - Chainable modifiers: sort(), limit(), skip(), project()
|
|
837
|
+
*
|
|
838
|
+
* @param filter - Query filter
|
|
839
|
+
* @param options - Find options (projection, sort, skip, limit, etc.)
|
|
840
|
+
* @returns HttpFindCursor for iterating over results
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```typescript
|
|
844
|
+
* // Using toArray
|
|
845
|
+
* const docs = await collection.find({ status: 'active' }).toArray()
|
|
846
|
+
*
|
|
847
|
+
* // Using async iterator
|
|
848
|
+
* for await (const doc of collection.find({ status: 'active' })) {
|
|
849
|
+
* console.log(doc)
|
|
850
|
+
* }
|
|
851
|
+
*
|
|
852
|
+
* // Using chainable modifiers
|
|
853
|
+
* const docs = await collection.find({})
|
|
854
|
+
* .sort({ name: 1 })
|
|
855
|
+
* .limit(10)
|
|
856
|
+
* .skip(5)
|
|
857
|
+
* .toArray()
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
860
|
+
find(filter?: Filter<TDocument>, options?: FindOptions$2<TDocument>): HttpFindCursor<TDocument>;
|
|
861
|
+
/**
|
|
862
|
+
* Update a single document matching the filter
|
|
863
|
+
*
|
|
864
|
+
* @param filter - Query filter
|
|
865
|
+
* @param update - Update operations
|
|
866
|
+
* @returns UpdateResult with match and modify counts
|
|
867
|
+
*/
|
|
868
|
+
updateOne(filter: Filter<TDocument>, update: UpdateFilter<TDocument>): Promise<UpdateResult$1>;
|
|
869
|
+
/**
|
|
870
|
+
* Update all documents matching the filter
|
|
871
|
+
*
|
|
872
|
+
* @param filter - Query filter
|
|
873
|
+
* @param update - Update operations
|
|
874
|
+
* @returns UpdateResult with match and modify counts
|
|
875
|
+
*/
|
|
876
|
+
updateMany(filter: Filter<TDocument>, update: UpdateFilter<TDocument>): Promise<UpdateResult$1>;
|
|
877
|
+
/**
|
|
878
|
+
* Replace a single document matching the filter
|
|
879
|
+
*
|
|
880
|
+
* @param filter - Query filter
|
|
881
|
+
* @param replacement - The replacement document
|
|
882
|
+
* @returns UpdateResult
|
|
883
|
+
*/
|
|
884
|
+
replaceOne(filter: Filter<TDocument>, replacement: Omit<TDocument, '_id'>): Promise<UpdateResult$1>;
|
|
885
|
+
/**
|
|
886
|
+
* Delete a single document matching the filter
|
|
887
|
+
*
|
|
888
|
+
* @param filter - Query filter
|
|
889
|
+
* @returns DeleteResult with deleted count
|
|
890
|
+
*/
|
|
891
|
+
deleteOne(filter: Filter<TDocument>): Promise<DeleteResult$1>;
|
|
892
|
+
/**
|
|
893
|
+
* Delete all documents matching the filter
|
|
894
|
+
*
|
|
895
|
+
* @param filter - Query filter
|
|
896
|
+
* @returns DeleteResult with deleted count
|
|
897
|
+
*/
|
|
898
|
+
deleteMany(filter: Filter<TDocument>): Promise<DeleteResult$1>;
|
|
899
|
+
/**
|
|
900
|
+
* Count documents matching the filter
|
|
901
|
+
*
|
|
902
|
+
* @param filter - Query filter
|
|
903
|
+
* @returns Number of matching documents
|
|
904
|
+
*/
|
|
905
|
+
countDocuments(filter?: Filter<TDocument>): Promise<number>;
|
|
906
|
+
/**
|
|
907
|
+
* Get estimated document count (faster but less accurate)
|
|
908
|
+
*
|
|
909
|
+
* @returns Estimated number of documents
|
|
910
|
+
*/
|
|
911
|
+
estimatedDocumentCount(): Promise<number>;
|
|
912
|
+
/**
|
|
913
|
+
* Execute an aggregation pipeline
|
|
914
|
+
*
|
|
915
|
+
* Returns a cursor that supports:
|
|
916
|
+
* - Async iteration with `for await (const doc of cursor)`
|
|
917
|
+
* - Converting to array with `await cursor.toArray()`
|
|
918
|
+
* - forEach iteration with `await cursor.forEach(callback)`
|
|
919
|
+
*
|
|
920
|
+
* @param pipeline - Array of aggregation stages
|
|
921
|
+
* @param options - Aggregation options
|
|
922
|
+
* @returns HttpAggregationCursor for iterating over results
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```typescript
|
|
926
|
+
* // Using toArray
|
|
927
|
+
* const results = await collection.aggregate([
|
|
928
|
+
* { $match: { status: 'active' } },
|
|
929
|
+
* { $group: { _id: '$category', count: { $sum: 1 } } }
|
|
930
|
+
* ]).toArray()
|
|
931
|
+
*
|
|
932
|
+
* // Using async iterator
|
|
933
|
+
* for await (const doc of collection.aggregate([
|
|
934
|
+
* { $match: { status: 'active' } }
|
|
935
|
+
* ])) {
|
|
936
|
+
* console.log(doc)
|
|
937
|
+
* }
|
|
938
|
+
* ```
|
|
939
|
+
*/
|
|
940
|
+
aggregate<TResult extends Document$3 = Document$3>(pipeline: AggregationStage[], options?: AggregateOptions): HttpAggregationCursor<TResult>;
|
|
941
|
+
/**
|
|
942
|
+
* Get distinct values for a field
|
|
943
|
+
*
|
|
944
|
+
* @param field - The field to get distinct values for
|
|
945
|
+
* @param filter - Optional filter
|
|
946
|
+
* @returns Array of distinct values
|
|
947
|
+
*/
|
|
948
|
+
distinct<TValue = unknown>(field: keyof TDocument, filter?: Filter<TDocument>): Promise<TValue[]>;
|
|
949
|
+
/**
|
|
950
|
+
* Create an index on this collection
|
|
951
|
+
*
|
|
952
|
+
* @param indexSpec - Index specification
|
|
953
|
+
* @returns Name of the created index
|
|
954
|
+
*/
|
|
955
|
+
createIndex(indexSpec: IndexSpecification): Promise<string>;
|
|
956
|
+
/**
|
|
957
|
+
* Drop an index from this collection
|
|
958
|
+
*
|
|
959
|
+
* @param indexName - Name of the index to drop
|
|
960
|
+
*/
|
|
961
|
+
dropIndex(indexName: string): Promise<void>;
|
|
962
|
+
/**
|
|
963
|
+
* List all indexes on this collection
|
|
964
|
+
*
|
|
965
|
+
* @returns Array of index information
|
|
966
|
+
*/
|
|
967
|
+
listIndexes(): Promise<IndexSpecification[]>;
|
|
968
|
+
/**
|
|
969
|
+
* Drop this collection
|
|
970
|
+
*/
|
|
971
|
+
drop(): Promise<void>;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Database - MongoDB-compatible database interface
|
|
976
|
+
*
|
|
977
|
+
* Represents a database in mongo.do and provides access to collections.
|
|
978
|
+
*/
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Database class
|
|
982
|
+
*
|
|
983
|
+
* Provides access to collections within a database.
|
|
984
|
+
* Each database corresponds to a Durable Object instance.
|
|
985
|
+
*/
|
|
986
|
+
declare class Database$1 {
|
|
987
|
+
private env;
|
|
988
|
+
private dbName;
|
|
989
|
+
/**
|
|
990
|
+
* Create a new Database instance
|
|
991
|
+
*
|
|
992
|
+
* @param env - Cloudflare Workers environment with MONDO_DATABASE binding
|
|
993
|
+
* @param name - The name of the database
|
|
994
|
+
*/
|
|
995
|
+
constructor(env: Env, name: string);
|
|
996
|
+
/**
|
|
997
|
+
* Get the name of this database
|
|
998
|
+
*/
|
|
999
|
+
get databaseName(): string;
|
|
1000
|
+
/**
|
|
1001
|
+
* Get a collection from this database
|
|
1002
|
+
*
|
|
1003
|
+
* @param name - The name of the collection
|
|
1004
|
+
* @returns A Collection instance
|
|
1005
|
+
*/
|
|
1006
|
+
collection<TDocument extends Record<string, unknown> = Record<string, unknown>>(name: string): Collection$1<TDocument>;
|
|
1007
|
+
/**
|
|
1008
|
+
* List all collections in this database
|
|
1009
|
+
*
|
|
1010
|
+
* @returns Array of collection names
|
|
1011
|
+
*/
|
|
1012
|
+
listCollections(): Promise<{
|
|
1013
|
+
name: string;
|
|
1014
|
+
type: string;
|
|
1015
|
+
}[]>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Create a new collection
|
|
1018
|
+
*
|
|
1019
|
+
* @param name - The name of the collection to create
|
|
1020
|
+
* @returns void
|
|
1021
|
+
*/
|
|
1022
|
+
createCollection(name: string): Promise<void>;
|
|
1023
|
+
/**
|
|
1024
|
+
* Drop a collection from this database
|
|
1025
|
+
*
|
|
1026
|
+
* @param name - The name of the collection to drop
|
|
1027
|
+
* @returns true if collection was dropped, false if it didn't exist
|
|
1028
|
+
*/
|
|
1029
|
+
dropCollection(name: string): Promise<boolean>;
|
|
1030
|
+
/**
|
|
1031
|
+
* Get database statistics
|
|
1032
|
+
*/
|
|
1033
|
+
stats(): Promise<{
|
|
1034
|
+
db: string;
|
|
1035
|
+
collections: number;
|
|
1036
|
+
objects: number;
|
|
1037
|
+
dataSize: number;
|
|
1038
|
+
}>;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* ClientSession - MongoDB-compatible session for transaction support
|
|
1043
|
+
*
|
|
1044
|
+
* Provides transaction management APIs compatible with MongoDB driver:
|
|
1045
|
+
* - startTransaction(options)
|
|
1046
|
+
* - commitTransaction()
|
|
1047
|
+
* - abortTransaction()
|
|
1048
|
+
* - withTransaction(callback, options)
|
|
1049
|
+
*
|
|
1050
|
+
* Maps MongoDB transactions to SQLite BEGIN/COMMIT/ROLLBACK semantics.
|
|
1051
|
+
*/
|
|
1052
|
+
/**
|
|
1053
|
+
* Read concern levels supported by MongoDB
|
|
1054
|
+
*/
|
|
1055
|
+
interface ReadConcern {
|
|
1056
|
+
level: 'local' | 'available' | 'majority' | 'linearizable' | 'snapshot';
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Write concern options supported by MongoDB
|
|
1060
|
+
*/
|
|
1061
|
+
interface WriteConcern {
|
|
1062
|
+
w?: number | 'majority';
|
|
1063
|
+
wtimeoutMS?: number;
|
|
1064
|
+
journal?: boolean;
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Transaction options for startTransaction and withTransaction
|
|
1068
|
+
*/
|
|
1069
|
+
interface TransactionOptions {
|
|
1070
|
+
readConcern?: ReadConcern;
|
|
1071
|
+
writeConcern?: WriteConcern;
|
|
1072
|
+
maxCommitTimeMS?: number;
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Session options for startSession
|
|
1076
|
+
*/
|
|
1077
|
+
interface ClientSessionOptions {
|
|
1078
|
+
defaultTransactionOptions?: TransactionOptions;
|
|
1079
|
+
causalConsistency?: boolean;
|
|
1080
|
+
snapshot?: boolean;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Transaction states
|
|
1084
|
+
*/
|
|
1085
|
+
type TransactionState = 'none' | 'starting' | 'in_progress' | 'committed' | 'aborted';
|
|
1086
|
+
/**
|
|
1087
|
+
* Session ID structure (MongoDB compatible)
|
|
1088
|
+
*/
|
|
1089
|
+
declare class SessionId {
|
|
1090
|
+
readonly id: Buffer | Uint8Array;
|
|
1091
|
+
private readonly _hexString;
|
|
1092
|
+
constructor(id: Buffer | Uint8Array);
|
|
1093
|
+
toString(): string;
|
|
1094
|
+
toHexString(): string;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Transaction callback function type
|
|
1098
|
+
*/
|
|
1099
|
+
type TransactionCallback<T> = (session: ClientSession) => Promise<T>;
|
|
1100
|
+
/**
|
|
1101
|
+
* Forward reference to MongoClient (to avoid circular imports)
|
|
1102
|
+
*/
|
|
1103
|
+
interface MongoClientLike {
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Interface for collections that support transaction rollback
|
|
1107
|
+
*/
|
|
1108
|
+
interface TransactableCollection {
|
|
1109
|
+
_getCollectionKey(): string;
|
|
1110
|
+
_createSnapshot(): Map<string, Record<string, unknown>>;
|
|
1111
|
+
_restoreFromSnapshot(snapshot: Map<string, Record<string, unknown>>): void;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* ClientSession provides MongoDB-compatible session and transaction support
|
|
1115
|
+
*
|
|
1116
|
+
* Transactions are mapped to SQLite as follows:
|
|
1117
|
+
* - startTransaction() -> BEGIN TRANSACTION
|
|
1118
|
+
* - commitTransaction() -> COMMIT
|
|
1119
|
+
* - abortTransaction() -> ROLLBACK
|
|
1120
|
+
*/
|
|
1121
|
+
declare class ClientSession {
|
|
1122
|
+
private readonly _client;
|
|
1123
|
+
private readonly _id;
|
|
1124
|
+
private readonly _options;
|
|
1125
|
+
private _transactionState;
|
|
1126
|
+
private _transactionOptions;
|
|
1127
|
+
private _transactionNumber;
|
|
1128
|
+
private _hasEnded;
|
|
1129
|
+
private _collectionSnapshots;
|
|
1130
|
+
private _trackedCollections;
|
|
1131
|
+
constructor(client: MongoClientLike, options?: ClientSessionOptions);
|
|
1132
|
+
/**
|
|
1133
|
+
* Generate a unique session ID
|
|
1134
|
+
*/
|
|
1135
|
+
private _generateSessionId;
|
|
1136
|
+
/**
|
|
1137
|
+
* Get the session ID
|
|
1138
|
+
*/
|
|
1139
|
+
get id(): SessionId;
|
|
1140
|
+
/**
|
|
1141
|
+
* Get the client that created this session
|
|
1142
|
+
*/
|
|
1143
|
+
get client(): MongoClientLike;
|
|
1144
|
+
/**
|
|
1145
|
+
* Check if the session is currently in a transaction
|
|
1146
|
+
*/
|
|
1147
|
+
get inTransaction(): boolean;
|
|
1148
|
+
/**
|
|
1149
|
+
* Get the current transaction state
|
|
1150
|
+
*/
|
|
1151
|
+
get transactionState(): TransactionState;
|
|
1152
|
+
/**
|
|
1153
|
+
* Get the current transaction options
|
|
1154
|
+
*/
|
|
1155
|
+
get transactionOptions(): TransactionOptions | null;
|
|
1156
|
+
/**
|
|
1157
|
+
* Get the current transaction number
|
|
1158
|
+
*/
|
|
1159
|
+
get transactionNumber(): number;
|
|
1160
|
+
/**
|
|
1161
|
+
* Check if the session has ended
|
|
1162
|
+
*/
|
|
1163
|
+
get hasEnded(): boolean;
|
|
1164
|
+
/**
|
|
1165
|
+
* Start a new transaction
|
|
1166
|
+
*
|
|
1167
|
+
* Maps to SQLite: BEGIN TRANSACTION
|
|
1168
|
+
*
|
|
1169
|
+
* @param options - Transaction options (readConcern, writeConcern, maxCommitTimeMS)
|
|
1170
|
+
* @throws Error if a transaction is already in progress
|
|
1171
|
+
*/
|
|
1172
|
+
startTransaction(options?: TransactionOptions): void;
|
|
1173
|
+
/**
|
|
1174
|
+
* Commit the current transaction
|
|
1175
|
+
*
|
|
1176
|
+
* Maps to SQLite: COMMIT
|
|
1177
|
+
*
|
|
1178
|
+
* @throws Error if no transaction is in progress
|
|
1179
|
+
*/
|
|
1180
|
+
commitTransaction(): Promise<void>;
|
|
1181
|
+
/**
|
|
1182
|
+
* Abort the current transaction
|
|
1183
|
+
*
|
|
1184
|
+
* Maps to SQLite: ROLLBACK
|
|
1185
|
+
*
|
|
1186
|
+
* @throws Error if no transaction is in progress
|
|
1187
|
+
*/
|
|
1188
|
+
abortTransaction(): Promise<void>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Execute a callback within a transaction with automatic commit/abort
|
|
1191
|
+
*
|
|
1192
|
+
* This method:
|
|
1193
|
+
* 1. Starts a transaction
|
|
1194
|
+
* 2. Executes the callback
|
|
1195
|
+
* 3. Commits on success, aborts on error
|
|
1196
|
+
* 4. Retries on transient transaction errors
|
|
1197
|
+
*
|
|
1198
|
+
* @param callback - Function to execute within the transaction
|
|
1199
|
+
* @param options - Transaction options
|
|
1200
|
+
* @returns The result of the callback
|
|
1201
|
+
*/
|
|
1202
|
+
withTransaction<T>(callback: TransactionCallback<T>, options?: TransactionOptions): Promise<T>;
|
|
1203
|
+
/**
|
|
1204
|
+
* End the session
|
|
1205
|
+
*
|
|
1206
|
+
* If a transaction is in progress, it will be aborted.
|
|
1207
|
+
*/
|
|
1208
|
+
endSession(): Promise<void>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Mark the transaction as in progress (called on first operation)
|
|
1211
|
+
* @internal
|
|
1212
|
+
*/
|
|
1213
|
+
_markInProgress(): void;
|
|
1214
|
+
/**
|
|
1215
|
+
* Track a collection for transaction rollback support
|
|
1216
|
+
* Creates a snapshot of the collection's data on first write operation
|
|
1217
|
+
* @internal
|
|
1218
|
+
*/
|
|
1219
|
+
_trackCollection(collection: TransactableCollection): void;
|
|
1220
|
+
/**
|
|
1221
|
+
* Get the SQL command for starting a transaction
|
|
1222
|
+
* @internal
|
|
1223
|
+
*/
|
|
1224
|
+
_getBeginCommand(): string;
|
|
1225
|
+
/**
|
|
1226
|
+
* Get the SQL command for committing a transaction
|
|
1227
|
+
* @internal
|
|
1228
|
+
*/
|
|
1229
|
+
_getCommitCommand(): string;
|
|
1230
|
+
/**
|
|
1231
|
+
* Get the SQL command for rolling back a transaction
|
|
1232
|
+
* @internal
|
|
1233
|
+
*/
|
|
1234
|
+
_getRollbackCommand(): string;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* MongoClient - MongoDB-compatible client for mongo.do
|
|
1239
|
+
*
|
|
1240
|
+
* Provides connection management and database access for
|
|
1241
|
+
* MongoDB-compatible operations. Supports two modes:
|
|
1242
|
+
*
|
|
1243
|
+
* 1. URI-based connection (for testing/in-memory):
|
|
1244
|
+
* const client = new MongoClient('mongodo://localhost:27017/mydb')
|
|
1245
|
+
*
|
|
1246
|
+
* 2. Env-based connection (for Cloudflare Durable Objects):
|
|
1247
|
+
* const client = new MongoClient(env)
|
|
1248
|
+
*
|
|
1249
|
+
* The URI-based mode uses in-memory storage and is suitable for testing.
|
|
1250
|
+
* The Env-based mode connects to Cloudflare Durable Objects for production.
|
|
1251
|
+
*/
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* Options for MongoClient
|
|
1255
|
+
*/
|
|
1256
|
+
interface MongoClientOptions {
|
|
1257
|
+
/**
|
|
1258
|
+
* Application name for connection metadata
|
|
1259
|
+
*/
|
|
1260
|
+
appName?: string;
|
|
1261
|
+
/**
|
|
1262
|
+
* Host for the connection (URI mode)
|
|
1263
|
+
*/
|
|
1264
|
+
host?: string;
|
|
1265
|
+
/**
|
|
1266
|
+
* Port for the connection (URI mode)
|
|
1267
|
+
*/
|
|
1268
|
+
port?: number;
|
|
1269
|
+
/**
|
|
1270
|
+
* Maximum connection pool size (URI mode)
|
|
1271
|
+
*/
|
|
1272
|
+
maxPoolSize?: number;
|
|
1273
|
+
/**
|
|
1274
|
+
* Minimum connection pool size (URI mode)
|
|
1275
|
+
*/
|
|
1276
|
+
minPoolSize?: number;
|
|
1277
|
+
/**
|
|
1278
|
+
* Connection timeout in milliseconds
|
|
1279
|
+
*/
|
|
1280
|
+
connectTimeoutMS?: number;
|
|
1281
|
+
/**
|
|
1282
|
+
* Socket timeout in milliseconds
|
|
1283
|
+
*/
|
|
1284
|
+
socketTimeoutMS?: number;
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Connection mode for the client
|
|
1288
|
+
*/
|
|
1289
|
+
type ConnectionMode = 'uri' | 'env';
|
|
1290
|
+
/**
|
|
1291
|
+
* MongoClient - The main entry point for interacting with mongo.do
|
|
1292
|
+
*
|
|
1293
|
+
* Provides a MongoDB-compatible API for database operations.
|
|
1294
|
+
* Supports both URI-based connections (for testing) and
|
|
1295
|
+
* Cloudflare Workers environment bindings (for production).
|
|
1296
|
+
*
|
|
1297
|
+
* @example URI-based (testing/in-memory):
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* const client = new MongoClient('mongodo://localhost:27017/mydb')
|
|
1300
|
+
* await client.connect()
|
|
1301
|
+
* const db = client.db('mydb')
|
|
1302
|
+
* ```
|
|
1303
|
+
*
|
|
1304
|
+
* @example Env-based (Cloudflare Durable Objects):
|
|
1305
|
+
* ```typescript
|
|
1306
|
+
* const client = new MongoClient(env)
|
|
1307
|
+
* await client.connect()
|
|
1308
|
+
* const db = client.db('mydb')
|
|
1309
|
+
* ```
|
|
1310
|
+
*/
|
|
1311
|
+
declare class MongoClient$1 {
|
|
1312
|
+
private readonly _mode;
|
|
1313
|
+
private readonly _uri?;
|
|
1314
|
+
private readonly _parsedURI?;
|
|
1315
|
+
private readonly _env?;
|
|
1316
|
+
private readonly _options;
|
|
1317
|
+
private _isConnected;
|
|
1318
|
+
private readonly _mongoDatabaseCache;
|
|
1319
|
+
private readonly _databaseCache;
|
|
1320
|
+
/**
|
|
1321
|
+
* Create a new MongoClient instance
|
|
1322
|
+
*
|
|
1323
|
+
* @param uriOrEnv - Either a connection URI string or Cloudflare Workers environment
|
|
1324
|
+
* @param options - Optional connection options
|
|
1325
|
+
*/
|
|
1326
|
+
constructor(uriOrEnv: string | Env, options?: MongoClientOptions);
|
|
1327
|
+
/**
|
|
1328
|
+
* Get the client options
|
|
1329
|
+
*/
|
|
1330
|
+
get options(): Readonly<MongoClientOptions>;
|
|
1331
|
+
/**
|
|
1332
|
+
* Check if the client is currently connected
|
|
1333
|
+
*/
|
|
1334
|
+
get isConnected(): boolean;
|
|
1335
|
+
/**
|
|
1336
|
+
* Get the connection mode
|
|
1337
|
+
*/
|
|
1338
|
+
get mode(): ConnectionMode;
|
|
1339
|
+
/**
|
|
1340
|
+
* Get the connection URI (URI mode only)
|
|
1341
|
+
*/
|
|
1342
|
+
get uri(): string | undefined;
|
|
1343
|
+
/**
|
|
1344
|
+
* Connect to the database
|
|
1345
|
+
*
|
|
1346
|
+
* In mongo.do, this is mostly a no-op since connections are handled lazily.
|
|
1347
|
+
* For Durable Objects mode, connections are per-request.
|
|
1348
|
+
* For URI mode (in-memory), this initializes the connection state.
|
|
1349
|
+
*
|
|
1350
|
+
* @returns This client for chaining
|
|
1351
|
+
*/
|
|
1352
|
+
connect(): Promise<MongoClient$1>;
|
|
1353
|
+
/**
|
|
1354
|
+
* Close the connection
|
|
1355
|
+
*
|
|
1356
|
+
* Clears database caches and resets connection state.
|
|
1357
|
+
*/
|
|
1358
|
+
close(): Promise<void>;
|
|
1359
|
+
/**
|
|
1360
|
+
* Get a database instance
|
|
1361
|
+
*
|
|
1362
|
+
* In URI mode, returns a MongoDatabase (in-memory).
|
|
1363
|
+
* In Env mode, returns a Database (Durable Objects).
|
|
1364
|
+
*
|
|
1365
|
+
* @param dbName - Database name (optional in URI mode, uses default from URI)
|
|
1366
|
+
* @returns A database instance (MongoDatabase or Database based on mode)
|
|
1367
|
+
*/
|
|
1368
|
+
db(dbName?: string): MongoDatabase | Database$1;
|
|
1369
|
+
/**
|
|
1370
|
+
* Get a MongoDatabase instance (URI/in-memory mode)
|
|
1371
|
+
* @internal
|
|
1372
|
+
*/
|
|
1373
|
+
private _getMongoDatabase;
|
|
1374
|
+
/**
|
|
1375
|
+
* Get a Database instance (Env/Durable Objects mode)
|
|
1376
|
+
* @internal
|
|
1377
|
+
*/
|
|
1378
|
+
private _getDatabase;
|
|
1379
|
+
/**
|
|
1380
|
+
* Get the default database name from the connection URI
|
|
1381
|
+
* Only available in URI mode.
|
|
1382
|
+
*/
|
|
1383
|
+
get defaultDatabase(): string;
|
|
1384
|
+
/**
|
|
1385
|
+
* Start a client session for transaction support
|
|
1386
|
+
*
|
|
1387
|
+
* Sessions are primarily used in URI/in-memory mode.
|
|
1388
|
+
* Durable Objects mode uses SQLite transactions internally.
|
|
1389
|
+
*
|
|
1390
|
+
* @param options - Session options including default transaction options
|
|
1391
|
+
* @returns A new ClientSession instance
|
|
1392
|
+
*/
|
|
1393
|
+
startSession(options?: ClientSessionOptions): ClientSession;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* MongoDatabase - MongoDB-compatible database interface
|
|
1398
|
+
*
|
|
1399
|
+
* Provides collection access and database-level operations.
|
|
1400
|
+
*/
|
|
1401
|
+
|
|
1402
|
+
interface CreateCollectionOptions {
|
|
1403
|
+
capped?: boolean;
|
|
1404
|
+
size?: number;
|
|
1405
|
+
max?: number;
|
|
1406
|
+
validator?: object;
|
|
1407
|
+
validationLevel?: 'off' | 'strict' | 'moderate';
|
|
1408
|
+
validationAction?: 'error' | 'warn';
|
|
1409
|
+
}
|
|
1410
|
+
interface CollectionInfo {
|
|
1411
|
+
name: string;
|
|
1412
|
+
type: 'collection';
|
|
1413
|
+
options: Record<string, unknown>;
|
|
1414
|
+
info: {
|
|
1415
|
+
readOnly: boolean;
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
declare class MongoDatabase {
|
|
1419
|
+
private readonly _databaseName;
|
|
1420
|
+
private readonly collectionCache;
|
|
1421
|
+
private readonly collections;
|
|
1422
|
+
constructor(_client: MongoClient$1, name: string);
|
|
1423
|
+
/**
|
|
1424
|
+
* Get the database name
|
|
1425
|
+
*/
|
|
1426
|
+
get databaseName(): string;
|
|
1427
|
+
/**
|
|
1428
|
+
* Get a collection instance
|
|
1429
|
+
* @param name - Collection name
|
|
1430
|
+
*/
|
|
1431
|
+
collection<TSchema extends Document = Document>(name: string): MongoCollection<TSchema>;
|
|
1432
|
+
/**
|
|
1433
|
+
* List all collections in the database
|
|
1434
|
+
*/
|
|
1435
|
+
listCollections(filter?: {
|
|
1436
|
+
name?: string;
|
|
1437
|
+
}): ListCollectionsCursor;
|
|
1438
|
+
/**
|
|
1439
|
+
* Create a new collection
|
|
1440
|
+
*/
|
|
1441
|
+
createCollection<TSchema extends Document = Document>(name: string, options?: CreateCollectionOptions): Promise<MongoCollection<TSchema>>;
|
|
1442
|
+
/**
|
|
1443
|
+
* Drop a collection
|
|
1444
|
+
*/
|
|
1445
|
+
dropCollection(name: string): Promise<boolean>;
|
|
1446
|
+
/**
|
|
1447
|
+
* Drop the entire database
|
|
1448
|
+
*/
|
|
1449
|
+
dropDatabase(): Promise<boolean>;
|
|
1450
|
+
/**
|
|
1451
|
+
* Get collection info for listing
|
|
1452
|
+
* @internal
|
|
1453
|
+
*/
|
|
1454
|
+
_getCollectionInfos(filter?: {
|
|
1455
|
+
name?: string;
|
|
1456
|
+
}): CollectionInfo[];
|
|
1457
|
+
/**
|
|
1458
|
+
* Register a collection (called by collection when data is first written)
|
|
1459
|
+
* @internal
|
|
1460
|
+
*/
|
|
1461
|
+
_registerCollection(name: string): void;
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Cursor for listing collections
|
|
1465
|
+
*/
|
|
1466
|
+
declare class ListCollectionsCursor {
|
|
1467
|
+
private readonly database;
|
|
1468
|
+
private readonly filter?;
|
|
1469
|
+
constructor(database: MongoDatabase, filter?: {
|
|
1470
|
+
name?: string;
|
|
1471
|
+
});
|
|
1472
|
+
toArray(): Promise<CollectionInfo[]>;
|
|
1473
|
+
forEach(callback: (info: CollectionInfo) => void): Promise<void>;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1477
|
+
* FindCursor - MongoDB-compatible cursor for query results
|
|
1478
|
+
*
|
|
1479
|
+
* Provides chainable methods for sorting, limiting, skipping, and projecting
|
|
1480
|
+
* query results. Supports async iteration and array conversion.
|
|
1481
|
+
*/
|
|
1482
|
+
|
|
1483
|
+
type Document$2 = Record<string, unknown>;
|
|
1484
|
+
interface FindOptions$1 {
|
|
1485
|
+
projection?: Record<string, 0 | 1>;
|
|
1486
|
+
sort?: Record<string, 1 | -1>;
|
|
1487
|
+
limit?: number;
|
|
1488
|
+
skip?: number;
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* FindCursor provides lazy evaluation of MongoDB queries
|
|
1492
|
+
*/
|
|
1493
|
+
declare class FindCursor<TSchema extends Document$2 = Document$2> {
|
|
1494
|
+
private readonly collection;
|
|
1495
|
+
private readonly filter;
|
|
1496
|
+
private _projection?;
|
|
1497
|
+
private _sort?;
|
|
1498
|
+
private _limit?;
|
|
1499
|
+
private _skip?;
|
|
1500
|
+
private _executed;
|
|
1501
|
+
private _results;
|
|
1502
|
+
constructor(collection: MongoCollection<any>, filter: object, options?: FindOptions$1);
|
|
1503
|
+
/**
|
|
1504
|
+
* Set the sort order
|
|
1505
|
+
*/
|
|
1506
|
+
sort(spec: Record<string, 1 | -1>): this;
|
|
1507
|
+
/**
|
|
1508
|
+
* Set the maximum number of documents to return
|
|
1509
|
+
*/
|
|
1510
|
+
limit(count: number): this;
|
|
1511
|
+
/**
|
|
1512
|
+
* Set the number of documents to skip
|
|
1513
|
+
*/
|
|
1514
|
+
skip(count: number): this;
|
|
1515
|
+
/**
|
|
1516
|
+
* Set the projection for returned documents
|
|
1517
|
+
*/
|
|
1518
|
+
project(spec: Record<string, 0 | 1>): this;
|
|
1519
|
+
/**
|
|
1520
|
+
* Execute the query and return all documents as an array
|
|
1521
|
+
*/
|
|
1522
|
+
toArray(): Promise<TSchema[]>;
|
|
1523
|
+
/**
|
|
1524
|
+
* Execute callback for each document
|
|
1525
|
+
*/
|
|
1526
|
+
forEach(callback: (doc: TSchema) => void): Promise<void>;
|
|
1527
|
+
/**
|
|
1528
|
+
* Count documents matching the query
|
|
1529
|
+
*/
|
|
1530
|
+
count(): Promise<number>;
|
|
1531
|
+
/**
|
|
1532
|
+
* Check if there are any documents
|
|
1533
|
+
*/
|
|
1534
|
+
hasNext(): Promise<boolean>;
|
|
1535
|
+
/**
|
|
1536
|
+
* Get the next document (simple implementation)
|
|
1537
|
+
*/
|
|
1538
|
+
next(): Promise<TSchema | null>;
|
|
1539
|
+
/**
|
|
1540
|
+
* Map over documents
|
|
1541
|
+
*/
|
|
1542
|
+
map<U>(fn: (doc: TSchema) => U): MappedCursor<TSchema, U>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Async iterator support
|
|
1545
|
+
*/
|
|
1546
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<TSchema>;
|
|
1547
|
+
}
|
|
1548
|
+
/**
|
|
1549
|
+
* Cursor with map transformation applied
|
|
1550
|
+
*/
|
|
1551
|
+
declare class MappedCursor<TSchema extends Document$2, U> {
|
|
1552
|
+
private readonly cursor;
|
|
1553
|
+
private readonly mapFn;
|
|
1554
|
+
constructor(cursor: FindCursor<TSchema>, mapFn: (doc: TSchema) => U);
|
|
1555
|
+
toArray(): Promise<U[]>;
|
|
1556
|
+
forEach(callback: (doc: U) => void): Promise<void>;
|
|
1557
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<U>;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Bulk Write Operations - MongoDB-compatible bulk write support
|
|
1562
|
+
*
|
|
1563
|
+
* Provides types and utilities for bulk write operations that can
|
|
1564
|
+
* batch multiple insert, update, and delete operations into a single
|
|
1565
|
+
* request for improved performance.
|
|
1566
|
+
*/
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* Base document type
|
|
1570
|
+
*/
|
|
1571
|
+
type Document$1 = Record<string, unknown>;
|
|
1572
|
+
/**
|
|
1573
|
+
* Insert one operation in a bulk write
|
|
1574
|
+
*/
|
|
1575
|
+
interface InsertOneModel<TDocument extends Document$1 = Document$1> {
|
|
1576
|
+
insertOne: {
|
|
1577
|
+
document: TDocument;
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Update one operation in a bulk write
|
|
1582
|
+
*/
|
|
1583
|
+
interface UpdateOneModel<TDocument extends Document$1 = Document$1> {
|
|
1584
|
+
updateOne: {
|
|
1585
|
+
filter: Partial<TDocument> | object;
|
|
1586
|
+
update: object;
|
|
1587
|
+
upsert?: boolean;
|
|
1588
|
+
arrayFilters?: object[];
|
|
1589
|
+
hint?: string | object;
|
|
1590
|
+
collation?: object;
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Update many operation in a bulk write
|
|
1595
|
+
*/
|
|
1596
|
+
interface UpdateManyModel<TDocument extends Document$1 = Document$1> {
|
|
1597
|
+
updateMany: {
|
|
1598
|
+
filter: Partial<TDocument> | object;
|
|
1599
|
+
update: object;
|
|
1600
|
+
upsert?: boolean;
|
|
1601
|
+
arrayFilters?: object[];
|
|
1602
|
+
hint?: string | object;
|
|
1603
|
+
collation?: object;
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Replace one operation in a bulk write
|
|
1608
|
+
*/
|
|
1609
|
+
interface ReplaceOneModel<TDocument extends Document$1 = Document$1> {
|
|
1610
|
+
replaceOne: {
|
|
1611
|
+
filter: object;
|
|
1612
|
+
replacement: TDocument;
|
|
1613
|
+
upsert?: boolean;
|
|
1614
|
+
hint?: string | object;
|
|
1615
|
+
collation?: object;
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Delete one operation in a bulk write
|
|
1620
|
+
*/
|
|
1621
|
+
interface DeleteOneModel {
|
|
1622
|
+
deleteOne: {
|
|
1623
|
+
filter: object;
|
|
1624
|
+
hint?: string | object;
|
|
1625
|
+
collation?: object;
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Delete many operation in a bulk write
|
|
1630
|
+
*/
|
|
1631
|
+
interface DeleteManyModel {
|
|
1632
|
+
deleteMany: {
|
|
1633
|
+
filter: object;
|
|
1634
|
+
hint?: string | object;
|
|
1635
|
+
collation?: object;
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Union type of all bulk write operation models
|
|
1640
|
+
*/
|
|
1641
|
+
type BulkWriteOperation<TDocument extends Document$1 = Document$1> = InsertOneModel<TDocument> | UpdateOneModel<TDocument> | UpdateManyModel<TDocument> | ReplaceOneModel<TDocument> | DeleteOneModel | DeleteManyModel;
|
|
1642
|
+
/**
|
|
1643
|
+
* Options for bulk write operations
|
|
1644
|
+
*/
|
|
1645
|
+
interface BulkWriteOptions {
|
|
1646
|
+
/**
|
|
1647
|
+
* If true (default), operations are executed in order.
|
|
1648
|
+
* If an error occurs, remaining operations are not executed.
|
|
1649
|
+
* If false, operations may be executed in any order, and all
|
|
1650
|
+
* operations are attempted regardless of errors.
|
|
1651
|
+
*/
|
|
1652
|
+
ordered?: boolean;
|
|
1653
|
+
/**
|
|
1654
|
+
* If true, bypass document validation during write operations
|
|
1655
|
+
*/
|
|
1656
|
+
bypassDocumentValidation?: boolean;
|
|
1657
|
+
/**
|
|
1658
|
+
* Comment to attach to the operation
|
|
1659
|
+
*/
|
|
1660
|
+
comment?: string | object;
|
|
1661
|
+
/**
|
|
1662
|
+
* Map of parameter names and values for use with $$var syntax
|
|
1663
|
+
*/
|
|
1664
|
+
let?: Document$1;
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Result of a bulk write operation
|
|
1668
|
+
*/
|
|
1669
|
+
interface BulkWriteResult {
|
|
1670
|
+
/**
|
|
1671
|
+
* Whether the write was acknowledged by the server
|
|
1672
|
+
*/
|
|
1673
|
+
acknowledged: boolean;
|
|
1674
|
+
/**
|
|
1675
|
+
* Number of documents inserted
|
|
1676
|
+
*/
|
|
1677
|
+
insertedCount: number;
|
|
1678
|
+
/**
|
|
1679
|
+
* Number of documents matched for update/replace operations
|
|
1680
|
+
*/
|
|
1681
|
+
matchedCount: number;
|
|
1682
|
+
/**
|
|
1683
|
+
* Number of documents modified by update/replace operations
|
|
1684
|
+
*/
|
|
1685
|
+
modifiedCount: number;
|
|
1686
|
+
/**
|
|
1687
|
+
* Number of documents deleted
|
|
1688
|
+
*/
|
|
1689
|
+
deletedCount: number;
|
|
1690
|
+
/**
|
|
1691
|
+
* Number of documents upserted
|
|
1692
|
+
*/
|
|
1693
|
+
upsertedCount: number;
|
|
1694
|
+
/**
|
|
1695
|
+
* Map of operation index to inserted document _id
|
|
1696
|
+
*/
|
|
1697
|
+
insertedIds: Record<number, ObjectId$1 | string>;
|
|
1698
|
+
/**
|
|
1699
|
+
* Array of upserted document information
|
|
1700
|
+
*/
|
|
1701
|
+
upsertedIds: Record<number, ObjectId$1 | string>;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
/**
|
|
1705
|
+
* ChangeStream - MongoDB-compatible change stream implementation
|
|
1706
|
+
*
|
|
1707
|
+
* Provides real-time notifications for data changes in a collection.
|
|
1708
|
+
* Supports filtering with $match pipeline stages and resume tokens for
|
|
1709
|
+
* reliable resumption after disconnections.
|
|
1710
|
+
*
|
|
1711
|
+
* @see https://www.mongodb.com/docs/manual/changeStreams/
|
|
1712
|
+
*/
|
|
1713
|
+
|
|
1714
|
+
/**
|
|
1715
|
+
* Change event operation types
|
|
1716
|
+
*/
|
|
1717
|
+
type OperationType = 'insert' | 'update' | 'replace' | 'delete' | 'drop' | 'invalidate';
|
|
1718
|
+
/**
|
|
1719
|
+
* Namespace identifying the collection
|
|
1720
|
+
*/
|
|
1721
|
+
interface ChangeStreamNamespace {
|
|
1722
|
+
db: string;
|
|
1723
|
+
coll: string;
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Document key identifying the changed document
|
|
1727
|
+
*/
|
|
1728
|
+
interface DocumentKey {
|
|
1729
|
+
_id: ObjectId$1;
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Description of fields updated/removed in an update operation
|
|
1733
|
+
*/
|
|
1734
|
+
interface UpdateDescription {
|
|
1735
|
+
updatedFields: Record<string, unknown>;
|
|
1736
|
+
removedFields: string[];
|
|
1737
|
+
truncatedArrays?: Array<{
|
|
1738
|
+
field: string;
|
|
1739
|
+
newSize: number;
|
|
1740
|
+
}>;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* A change event emitted by the change stream
|
|
1744
|
+
*/
|
|
1745
|
+
interface ChangeEvent<TDocument = Record<string, unknown>> {
|
|
1746
|
+
/** Resume token for this event */
|
|
1747
|
+
_id: ResumeToken;
|
|
1748
|
+
/** Type of operation that triggered this event */
|
|
1749
|
+
operationType: OperationType;
|
|
1750
|
+
/** Timestamp when the change occurred */
|
|
1751
|
+
clusterTime: Date;
|
|
1752
|
+
/** Database and collection namespace */
|
|
1753
|
+
ns: ChangeStreamNamespace;
|
|
1754
|
+
/** The _id of the affected document */
|
|
1755
|
+
documentKey: DocumentKey;
|
|
1756
|
+
/** Full document (for insert, replace, or update with fullDocument option) */
|
|
1757
|
+
fullDocument?: TDocument;
|
|
1758
|
+
/** Description of updated/removed fields (for update operations) */
|
|
1759
|
+
updateDescription?: UpdateDescription;
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Options for creating a change stream
|
|
1763
|
+
*/
|
|
1764
|
+
interface ChangeStreamOptions {
|
|
1765
|
+
/** How to handle fullDocument for update operations */
|
|
1766
|
+
fullDocument?: 'default' | 'updateLookup' | 'whenAvailable' | 'required';
|
|
1767
|
+
/** Resume after this token (exclusive) */
|
|
1768
|
+
resumeAfter?: ResumeToken;
|
|
1769
|
+
/** Start after this token (exclusive) - similar to resumeAfter */
|
|
1770
|
+
startAfter?: ResumeToken;
|
|
1771
|
+
/** Start at a specific operation time */
|
|
1772
|
+
startAtOperationTime?: Date;
|
|
1773
|
+
/** Maximum time to wait for new events in ms */
|
|
1774
|
+
maxAwaitTimeMS?: number;
|
|
1775
|
+
/** Batch size for fetching events */
|
|
1776
|
+
batchSize?: number;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Aggregation pipeline stage for filtering change events
|
|
1780
|
+
*/
|
|
1781
|
+
interface MatchStage {
|
|
1782
|
+
$match: Record<string, unknown>;
|
|
1783
|
+
}
|
|
1784
|
+
type ChangeStreamPipeline = MatchStage[];
|
|
1785
|
+
/**
|
|
1786
|
+
* Parsed resume token data
|
|
1787
|
+
*/
|
|
1788
|
+
interface ParsedResumeToken {
|
|
1789
|
+
database: string;
|
|
1790
|
+
collection: string;
|
|
1791
|
+
sequence: number;
|
|
1792
|
+
timestamp: number;
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* Resume token for resuming a change stream
|
|
1796
|
+
*/
|
|
1797
|
+
interface ResumeToken {
|
|
1798
|
+
_data: string;
|
|
1799
|
+
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Utility class for generating and parsing resume tokens
|
|
1802
|
+
*/
|
|
1803
|
+
declare const ResumeToken: {
|
|
1804
|
+
/**
|
|
1805
|
+
* Generate a new resume token
|
|
1806
|
+
*/
|
|
1807
|
+
generate(database: string, collection: string, sequence: number): ResumeToken;
|
|
1808
|
+
/**
|
|
1809
|
+
* Parse a resume token back to its components
|
|
1810
|
+
*/
|
|
1811
|
+
parse(token: ResumeToken): ParsedResumeToken;
|
|
1812
|
+
/**
|
|
1813
|
+
* Compare two tokens for ordering
|
|
1814
|
+
*/
|
|
1815
|
+
compare(a: ResumeToken, b: ResumeToken): number;
|
|
1816
|
+
};
|
|
1817
|
+
/**
|
|
1818
|
+
* MongoDB-compatible change stream cursor
|
|
1819
|
+
*
|
|
1820
|
+
* Allows watching for changes on a collection in real-time.
|
|
1821
|
+
* Supports filtering, resume tokens, and async iteration.
|
|
1822
|
+
*
|
|
1823
|
+
* @example
|
|
1824
|
+
* ```typescript
|
|
1825
|
+
* const changeStream = collection.watch([
|
|
1826
|
+
* { $match: { operationType: 'insert' } }
|
|
1827
|
+
* ])
|
|
1828
|
+
*
|
|
1829
|
+
* for await (const event of changeStream) {
|
|
1830
|
+
* console.log('Change:', event.operationType, event.fullDocument)
|
|
1831
|
+
* }
|
|
1832
|
+
* ```
|
|
1833
|
+
*/
|
|
1834
|
+
declare class ChangeStream<TDocument = Record<string, unknown>> {
|
|
1835
|
+
private readonly database;
|
|
1836
|
+
private readonly collection;
|
|
1837
|
+
private readonly pipeline;
|
|
1838
|
+
private readonly options;
|
|
1839
|
+
private readonly getDocumentById;
|
|
1840
|
+
private readonly getChangeEvents;
|
|
1841
|
+
private readonly onClose?;
|
|
1842
|
+
private _closed;
|
|
1843
|
+
private _resumeToken;
|
|
1844
|
+
private _currentSequence;
|
|
1845
|
+
private _pendingEvents;
|
|
1846
|
+
constructor(database: string, collection: string, pipeline: ChangeStreamPipeline, options: ChangeStreamOptions, callbacks: {
|
|
1847
|
+
getDocumentById: (id: ObjectId$1) => Promise<TDocument | null>;
|
|
1848
|
+
getChangeEvents: (afterSequence: number) => Promise<StoredChangeEvent[]>;
|
|
1849
|
+
getCurrentSequence: () => number;
|
|
1850
|
+
onClose?: () => void;
|
|
1851
|
+
});
|
|
1852
|
+
/**
|
|
1853
|
+
* Whether the change stream is closed
|
|
1854
|
+
*/
|
|
1855
|
+
get closed(): boolean;
|
|
1856
|
+
/**
|
|
1857
|
+
* Get the current resume token (for the last received event)
|
|
1858
|
+
*/
|
|
1859
|
+
getResumeToken(): ResumeToken | null;
|
|
1860
|
+
/**
|
|
1861
|
+
* Get the next change event (blocking)
|
|
1862
|
+
* Returns null if the stream is closed
|
|
1863
|
+
*/
|
|
1864
|
+
next(): Promise<ChangeEvent<TDocument> | null>;
|
|
1865
|
+
/**
|
|
1866
|
+
* Try to get the next event without blocking
|
|
1867
|
+
* Returns null immediately if no events are available
|
|
1868
|
+
*/
|
|
1869
|
+
tryNext(): Promise<ChangeEvent<TDocument> | null>;
|
|
1870
|
+
/**
|
|
1871
|
+
* Check if there are more events available
|
|
1872
|
+
*/
|
|
1873
|
+
hasNext(): Promise<boolean>;
|
|
1874
|
+
/**
|
|
1875
|
+
* Close the change stream
|
|
1876
|
+
*/
|
|
1877
|
+
close(): Promise<void>;
|
|
1878
|
+
/**
|
|
1879
|
+
* Get a stream interface for the change stream
|
|
1880
|
+
*/
|
|
1881
|
+
stream(): AsyncIterable<ChangeEvent<TDocument>>;
|
|
1882
|
+
/**
|
|
1883
|
+
* Async iterator implementation
|
|
1884
|
+
*/
|
|
1885
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<ChangeEvent<TDocument>>;
|
|
1886
|
+
/**
|
|
1887
|
+
* Fetch new events from the change event store
|
|
1888
|
+
*/
|
|
1889
|
+
private fetchNewEvents;
|
|
1890
|
+
/**
|
|
1891
|
+
* Transform a stored event into a ChangeEvent
|
|
1892
|
+
*/
|
|
1893
|
+
private transformStoredEvent;
|
|
1894
|
+
/**
|
|
1895
|
+
* Check if an event matches the pipeline filters
|
|
1896
|
+
*/
|
|
1897
|
+
private matchesPipeline;
|
|
1898
|
+
/**
|
|
1899
|
+
* Check if an event matches a $match condition
|
|
1900
|
+
*/
|
|
1901
|
+
private matchesCondition;
|
|
1902
|
+
/**
|
|
1903
|
+
* Match a comparison operator
|
|
1904
|
+
*/
|
|
1905
|
+
private matchesOperator;
|
|
1906
|
+
/**
|
|
1907
|
+
* Get a nested value from an object using dot notation
|
|
1908
|
+
*/
|
|
1909
|
+
private getNestedValue;
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Internal structure for stored change events
|
|
1913
|
+
*/
|
|
1914
|
+
interface StoredChangeEvent {
|
|
1915
|
+
sequence: number;
|
|
1916
|
+
operationType: OperationType;
|
|
1917
|
+
documentId: string | ObjectId$1;
|
|
1918
|
+
timestamp: number;
|
|
1919
|
+
fullDocument?: Record<string, unknown>;
|
|
1920
|
+
updatedFields?: Record<string, unknown>;
|
|
1921
|
+
removedFields?: string[];
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* AggregationCursor - Async cursor for MongoDB aggregation pipeline results
|
|
1926
|
+
*
|
|
1927
|
+
* Provides:
|
|
1928
|
+
* - Async iteration with for-await-of
|
|
1929
|
+
* - toArray() for collecting all results
|
|
1930
|
+
* - Support for async pipeline stages ($function, $lookup with pipeline)
|
|
1931
|
+
* - Proper error propagation from async stages
|
|
1932
|
+
*/
|
|
1933
|
+
|
|
1934
|
+
/**
|
|
1935
|
+
* Options for aggregation cursor
|
|
1936
|
+
*/
|
|
1937
|
+
interface AggregationCursorOptions {
|
|
1938
|
+
/** Batch size for streaming results */
|
|
1939
|
+
batchSize?: number;
|
|
1940
|
+
/** Allow disk use for large result sets */
|
|
1941
|
+
allowDiskUse?: boolean;
|
|
1942
|
+
/** Maximum time for operation (ms) */
|
|
1943
|
+
maxTimeMS?: number;
|
|
1944
|
+
/** Comment for the operation */
|
|
1945
|
+
comment?: string;
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Async function stage definition ($function)
|
|
1949
|
+
*/
|
|
1950
|
+
interface FunctionStage {
|
|
1951
|
+
body: string | ((...args: unknown[]) => unknown | Promise<unknown>);
|
|
1952
|
+
args: unknown[];
|
|
1953
|
+
lang: 'js';
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* Executor function type for running pipeline against data
|
|
1957
|
+
*/
|
|
1958
|
+
type PipelineExecutor<T> = (documents: T[], stage: PipelineStage, context: AsyncExecutionContext) => Promise<T[]>;
|
|
1959
|
+
/**
|
|
1960
|
+
* Context for async pipeline execution
|
|
1961
|
+
*/
|
|
1962
|
+
interface AsyncExecutionContext {
|
|
1963
|
+
/** Collection name being aggregated */
|
|
1964
|
+
collectionName: string;
|
|
1965
|
+
/** Lookup function for $lookup stages */
|
|
1966
|
+
lookupCollection?: (name: string) => Promise<Document[]>;
|
|
1967
|
+
/** Custom function executor for $function stages */
|
|
1968
|
+
functionExecutor?: (fn: FunctionStage, doc: Document) => Promise<unknown>;
|
|
1969
|
+
/** Abort signal for cancellation */
|
|
1970
|
+
abortSignal?: AbortSignal;
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* AggregationCursor provides async iteration over aggregation pipeline results
|
|
1974
|
+
*/
|
|
1975
|
+
declare class AggregationCursor<TSchema extends Document = Document> extends EventEmitter {
|
|
1976
|
+
private readonly _pipeline;
|
|
1977
|
+
private readonly _options;
|
|
1978
|
+
private readonly _fetchFn;
|
|
1979
|
+
private readonly _asyncExecutor;
|
|
1980
|
+
private readonly _context;
|
|
1981
|
+
private _buffer;
|
|
1982
|
+
private _position;
|
|
1983
|
+
private _fetched;
|
|
1984
|
+
private _closed;
|
|
1985
|
+
private _error;
|
|
1986
|
+
/**
|
|
1987
|
+
* Create a new AggregationCursor
|
|
1988
|
+
*
|
|
1989
|
+
* @param pipeline - The aggregation pipeline stages
|
|
1990
|
+
* @param fetchFn - Function to fetch and execute the pipeline
|
|
1991
|
+
* @param options - Cursor options
|
|
1992
|
+
* @param asyncExecutor - Optional executor for async stages
|
|
1993
|
+
* @param context - Execution context
|
|
1994
|
+
*/
|
|
1995
|
+
constructor(pipeline: PipelineStage[], fetchFn: () => Promise<TSchema[]>, options?: AggregationCursorOptions, asyncExecutor?: PipelineExecutor<TSchema>, context?: AsyncExecutionContext);
|
|
1996
|
+
/**
|
|
1997
|
+
* Whether the cursor is closed
|
|
1998
|
+
*/
|
|
1999
|
+
get closed(): boolean;
|
|
2000
|
+
/**
|
|
2001
|
+
* Get the pipeline being executed
|
|
2002
|
+
*/
|
|
2003
|
+
get pipeline(): PipelineStage[];
|
|
2004
|
+
/**
|
|
2005
|
+
* Number of documents currently buffered
|
|
2006
|
+
*/
|
|
2007
|
+
get bufferedCount(): number;
|
|
2008
|
+
/**
|
|
2009
|
+
* Execute the pipeline and fetch results
|
|
2010
|
+
*/
|
|
2011
|
+
private ensureFetched;
|
|
2012
|
+
/**
|
|
2013
|
+
* Check if pipeline contains async stages
|
|
2014
|
+
*/
|
|
2015
|
+
private hasAsyncStages;
|
|
2016
|
+
/**
|
|
2017
|
+
* Check if $lookup stage requires async execution
|
|
2018
|
+
*/
|
|
2019
|
+
private isAsyncLookup;
|
|
2020
|
+
/**
|
|
2021
|
+
* Execute async stages in the pipeline
|
|
2022
|
+
*/
|
|
2023
|
+
private executeAsyncStages;
|
|
2024
|
+
/**
|
|
2025
|
+
* Execute $function stage
|
|
2026
|
+
*/
|
|
2027
|
+
private executeFunctionStage;
|
|
2028
|
+
/**
|
|
2029
|
+
* Execute $lookup with pipeline (async)
|
|
2030
|
+
*/
|
|
2031
|
+
private executeAsyncLookup;
|
|
2032
|
+
/**
|
|
2033
|
+
* Get nested value from document
|
|
2034
|
+
*/
|
|
2035
|
+
private getNestedValue;
|
|
2036
|
+
/**
|
|
2037
|
+
* Check if two values are equal
|
|
2038
|
+
*/
|
|
2039
|
+
private valuesEqual;
|
|
2040
|
+
/**
|
|
2041
|
+
* Check if document matches an expression (simplified)
|
|
2042
|
+
*/
|
|
2043
|
+
private matchesExpression;
|
|
2044
|
+
/**
|
|
2045
|
+
* Evaluate $expr
|
|
2046
|
+
*/
|
|
2047
|
+
private evaluateExpr;
|
|
2048
|
+
/**
|
|
2049
|
+
* Evaluate a comparison operator
|
|
2050
|
+
*/
|
|
2051
|
+
private evaluateOperator;
|
|
2052
|
+
/**
|
|
2053
|
+
* Get the next document
|
|
2054
|
+
*/
|
|
2055
|
+
next(): Promise<TSchema | null>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Check if there are more documents
|
|
2058
|
+
*/
|
|
2059
|
+
hasNext(): Promise<boolean>;
|
|
2060
|
+
/**
|
|
2061
|
+
* Get all documents as an array
|
|
2062
|
+
*/
|
|
2063
|
+
toArray(): Promise<TSchema[]>;
|
|
2064
|
+
/**
|
|
2065
|
+
* Execute callback for each document
|
|
2066
|
+
*/
|
|
2067
|
+
forEach(callback: (doc: TSchema, index: number) => void | false | Promise<void | false>): Promise<void>;
|
|
2068
|
+
/**
|
|
2069
|
+
* Transform documents
|
|
2070
|
+
*/
|
|
2071
|
+
map<U>(fn: (doc: TSchema, index: number) => U): MappedAggregationCursor<TSchema, U>;
|
|
2072
|
+
/**
|
|
2073
|
+
* Close the cursor
|
|
2074
|
+
*/
|
|
2075
|
+
close(): Promise<void>;
|
|
2076
|
+
/**
|
|
2077
|
+
* Async iterator support for for-await-of
|
|
2078
|
+
*/
|
|
2079
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<TSchema>;
|
|
2080
|
+
/**
|
|
2081
|
+
* Clone the cursor
|
|
2082
|
+
*/
|
|
2083
|
+
clone(): AggregationCursor<TSchema>;
|
|
2084
|
+
/**
|
|
2085
|
+
* Explain the aggregation plan
|
|
2086
|
+
*/
|
|
2087
|
+
explain(): AggregationPlan;
|
|
2088
|
+
/**
|
|
2089
|
+
* Check if a stage is async
|
|
2090
|
+
*/
|
|
2091
|
+
private isAsyncStage;
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Mapped cursor for transformed results
|
|
2095
|
+
*/
|
|
2096
|
+
declare class MappedAggregationCursor<TSchema extends Document, U> {
|
|
2097
|
+
private readonly _cursor;
|
|
2098
|
+
private readonly _mapFn;
|
|
2099
|
+
constructor(cursor: AggregationCursor<TSchema>, mapFn: (doc: TSchema, index: number) => U);
|
|
2100
|
+
toArray(): Promise<U[]>;
|
|
2101
|
+
forEach(callback: (doc: U, index: number) => void | false | Promise<void | false>): Promise<void>;
|
|
2102
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<U>;
|
|
2103
|
+
}
|
|
2104
|
+
/**
|
|
2105
|
+
* Aggregation plan interface
|
|
2106
|
+
*/
|
|
2107
|
+
interface AggregationPlan {
|
|
2108
|
+
pipeline: Array<{
|
|
2109
|
+
stage: string;
|
|
2110
|
+
isAsync: boolean;
|
|
2111
|
+
}>;
|
|
2112
|
+
hasAsyncStages: boolean;
|
|
2113
|
+
options: AggregationCursorOptions;
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
/**
|
|
2117
|
+
* MongoCollection - MongoDB-compatible collection interface
|
|
2118
|
+
*
|
|
2119
|
+
* Provides CRUD operations and query support for documents.
|
|
2120
|
+
* This is the client-side in-memory implementation for testing.
|
|
2121
|
+
*/
|
|
2122
|
+
|
|
2123
|
+
type Document = Record<string, unknown>;
|
|
2124
|
+
interface InsertOneResult {
|
|
2125
|
+
acknowledged: boolean;
|
|
2126
|
+
insertedId: ObjectId$1;
|
|
2127
|
+
}
|
|
2128
|
+
interface InsertManyResult {
|
|
2129
|
+
acknowledged: boolean;
|
|
2130
|
+
insertedCount: number;
|
|
2131
|
+
insertedIds: Record<number, ObjectId$1>;
|
|
2132
|
+
}
|
|
2133
|
+
interface UpdateResult {
|
|
2134
|
+
acknowledged: boolean;
|
|
2135
|
+
matchedCount: number;
|
|
2136
|
+
modifiedCount: number;
|
|
2137
|
+
upsertedId?: ObjectId$1;
|
|
2138
|
+
upsertedCount?: number;
|
|
2139
|
+
}
|
|
2140
|
+
interface DeleteResult {
|
|
2141
|
+
acknowledged: boolean;
|
|
2142
|
+
deletedCount: number;
|
|
2143
|
+
}
|
|
2144
|
+
interface SessionOption {
|
|
2145
|
+
session?: ClientSession;
|
|
2146
|
+
}
|
|
2147
|
+
interface FindOptions extends SessionOption {
|
|
2148
|
+
projection?: Record<string, 0 | 1> | undefined;
|
|
2149
|
+
sort?: Record<string, 1 | -1> | undefined;
|
|
2150
|
+
limit?: number | undefined;
|
|
2151
|
+
skip?: number | undefined;
|
|
2152
|
+
}
|
|
2153
|
+
interface InsertOneOptions extends SessionOption {
|
|
2154
|
+
}
|
|
2155
|
+
interface InsertManyOptions extends SessionOption {
|
|
2156
|
+
}
|
|
2157
|
+
interface UpdateOptions extends SessionOption {
|
|
2158
|
+
upsert?: boolean | undefined;
|
|
2159
|
+
arrayFilters?: object[] | undefined;
|
|
2160
|
+
}
|
|
2161
|
+
interface ReplaceOptions extends SessionOption {
|
|
2162
|
+
upsert?: boolean | undefined;
|
|
2163
|
+
}
|
|
2164
|
+
interface DeleteOptions extends SessionOption {
|
|
2165
|
+
}
|
|
2166
|
+
interface FindOneAndUpdateOptions extends SessionOption {
|
|
2167
|
+
projection?: Record<string, 0 | 1> | undefined;
|
|
2168
|
+
sort?: Record<string, 1 | -1> | undefined;
|
|
2169
|
+
upsert?: boolean | undefined;
|
|
2170
|
+
returnDocument?: 'before' | 'after' | undefined;
|
|
2171
|
+
}
|
|
2172
|
+
interface FindOneAndDeleteOptions extends SessionOption {
|
|
2173
|
+
projection?: Record<string, 0 | 1> | undefined;
|
|
2174
|
+
sort?: Record<string, 1 | -1> | undefined;
|
|
2175
|
+
}
|
|
2176
|
+
interface FindOneAndReplaceOptions extends SessionOption {
|
|
2177
|
+
projection?: Record<string, 0 | 1> | undefined;
|
|
2178
|
+
sort?: Record<string, 1 | -1> | undefined;
|
|
2179
|
+
upsert?: boolean | undefined;
|
|
2180
|
+
returnDocument?: 'before' | 'after' | undefined;
|
|
2181
|
+
}
|
|
2182
|
+
/**
|
|
2183
|
+
* MongoCollection provides CRUD operations for documents
|
|
2184
|
+
*/
|
|
2185
|
+
declare class MongoCollection<TSchema extends Document = Document> implements TransactableCollection {
|
|
2186
|
+
private readonly database;
|
|
2187
|
+
private readonly _collectionName;
|
|
2188
|
+
private documents;
|
|
2189
|
+
private readonly _changeEventStore;
|
|
2190
|
+
private readonly _activeChangeStreams;
|
|
2191
|
+
constructor(database: MongoDatabase, name: string);
|
|
2192
|
+
/**
|
|
2193
|
+
* Get the collection name
|
|
2194
|
+
*/
|
|
2195
|
+
get collectionName(): string;
|
|
2196
|
+
/**
|
|
2197
|
+
* Ensure collection is created in the database
|
|
2198
|
+
* @internal
|
|
2199
|
+
*/
|
|
2200
|
+
_ensureCreated(): Promise<void>;
|
|
2201
|
+
/**
|
|
2202
|
+
* Drop collection data
|
|
2203
|
+
* @internal
|
|
2204
|
+
*/
|
|
2205
|
+
_drop(): Promise<void>;
|
|
2206
|
+
/**
|
|
2207
|
+
* Get a unique key for this collection (used for transaction tracking)
|
|
2208
|
+
* @internal
|
|
2209
|
+
*/
|
|
2210
|
+
_getCollectionKey(): string;
|
|
2211
|
+
/**
|
|
2212
|
+
* Create a snapshot of the current collection data
|
|
2213
|
+
* @internal
|
|
2214
|
+
*/
|
|
2215
|
+
_createSnapshot(): Map<string, Record<string, unknown>>;
|
|
2216
|
+
/**
|
|
2217
|
+
* Restore collection data from a snapshot (used for transaction rollback)
|
|
2218
|
+
* @internal
|
|
2219
|
+
*/
|
|
2220
|
+
_restoreFromSnapshot(snapshot: Map<string, Record<string, unknown>>): void;
|
|
2221
|
+
/**
|
|
2222
|
+
* Track this collection in a session for transaction support
|
|
2223
|
+
* @internal
|
|
2224
|
+
*/
|
|
2225
|
+
private _trackInSession;
|
|
2226
|
+
/**
|
|
2227
|
+
* Insert a single document
|
|
2228
|
+
*/
|
|
2229
|
+
insertOne(doc: TSchema, options?: InsertOneOptions): Promise<InsertOneResult>;
|
|
2230
|
+
/**
|
|
2231
|
+
* Insert multiple documents
|
|
2232
|
+
*/
|
|
2233
|
+
insertMany(docs: TSchema[], options?: InsertManyOptions): Promise<InsertManyResult>;
|
|
2234
|
+
/**
|
|
2235
|
+
* Find a single document
|
|
2236
|
+
*/
|
|
2237
|
+
findOne(filter?: object, options?: FindOptions): Promise<(TSchema & {
|
|
2238
|
+
_id: ObjectId$1;
|
|
2239
|
+
}) | null>;
|
|
2240
|
+
/**
|
|
2241
|
+
* Find multiple documents, returns a cursor
|
|
2242
|
+
*/
|
|
2243
|
+
find(filter?: object, options?: FindOptions): FindCursor<TSchema & {
|
|
2244
|
+
_id: ObjectId$1;
|
|
2245
|
+
}>;
|
|
2246
|
+
/**
|
|
2247
|
+
* Internal method to execute find query
|
|
2248
|
+
* @internal
|
|
2249
|
+
*/
|
|
2250
|
+
_findDocuments(filter: object, options?: {
|
|
2251
|
+
sort?: Record<string, 1 | -1>;
|
|
2252
|
+
skip?: number;
|
|
2253
|
+
limit?: number;
|
|
2254
|
+
}): (TSchema & {
|
|
2255
|
+
_id: ObjectId$1;
|
|
2256
|
+
})[];
|
|
2257
|
+
/**
|
|
2258
|
+
* Update a single document
|
|
2259
|
+
*/
|
|
2260
|
+
updateOne(filter: object, update: object, options?: UpdateOptions): Promise<UpdateResult>;
|
|
2261
|
+
/**
|
|
2262
|
+
* Update multiple documents
|
|
2263
|
+
*/
|
|
2264
|
+
updateMany(filter: object, update: object, options?: UpdateOptions): Promise<UpdateResult>;
|
|
2265
|
+
/**
|
|
2266
|
+
* Replace a single document
|
|
2267
|
+
*/
|
|
2268
|
+
replaceOne(filter: object, replacement: TSchema, options?: ReplaceOptions): Promise<UpdateResult>;
|
|
2269
|
+
/**
|
|
2270
|
+
* Delete a single document
|
|
2271
|
+
*/
|
|
2272
|
+
deleteOne(filter: object, options?: DeleteOptions): Promise<DeleteResult>;
|
|
2273
|
+
/**
|
|
2274
|
+
* Delete multiple documents
|
|
2275
|
+
*/
|
|
2276
|
+
deleteMany(filter: object, options?: DeleteOptions): Promise<DeleteResult>;
|
|
2277
|
+
/**
|
|
2278
|
+
* Count documents matching filter
|
|
2279
|
+
*/
|
|
2280
|
+
countDocuments(filter?: object): Promise<number>;
|
|
2281
|
+
/**
|
|
2282
|
+
* Find one and update
|
|
2283
|
+
*/
|
|
2284
|
+
findOneAndUpdate(filter: object, update: object, options?: FindOneAndUpdateOptions): Promise<(TSchema & {
|
|
2285
|
+
_id: ObjectId$1;
|
|
2286
|
+
}) | null>;
|
|
2287
|
+
/**
|
|
2288
|
+
* Find one and delete
|
|
2289
|
+
*/
|
|
2290
|
+
findOneAndDelete(filter: object, options?: FindOneAndDeleteOptions): Promise<(TSchema & {
|
|
2291
|
+
_id: ObjectId$1;
|
|
2292
|
+
}) | null>;
|
|
2293
|
+
/**
|
|
2294
|
+
* Find one and replace
|
|
2295
|
+
*/
|
|
2296
|
+
findOneAndReplace(filter: object, replacement: TSchema, options?: FindOneAndReplaceOptions): Promise<(TSchema & {
|
|
2297
|
+
_id: ObjectId$1;
|
|
2298
|
+
}) | null>;
|
|
2299
|
+
/**
|
|
2300
|
+
* Execute multiple write operations in a single batch
|
|
2301
|
+
*
|
|
2302
|
+
* @param operations - Array of bulk write operations
|
|
2303
|
+
* @param options - Bulk write options
|
|
2304
|
+
* @returns BulkWriteResult with operation counts
|
|
2305
|
+
*/
|
|
2306
|
+
bulkWrite(operations: BulkWriteOperation<TSchema>[], options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
2307
|
+
/**
|
|
2308
|
+
* Drop the collection
|
|
2309
|
+
*/
|
|
2310
|
+
drop(): Promise<boolean>;
|
|
2311
|
+
/**
|
|
2312
|
+
* Watch for changes on this collection
|
|
2313
|
+
*
|
|
2314
|
+
* Creates a change stream that emits events for insert, update, replace, and delete operations.
|
|
2315
|
+
*
|
|
2316
|
+
* @param pipeline - Optional aggregation pipeline for filtering events (supports $match)
|
|
2317
|
+
* @param options - Change stream options
|
|
2318
|
+
* @returns A ChangeStream instance
|
|
2319
|
+
*
|
|
2320
|
+
* @example
|
|
2321
|
+
* ```typescript
|
|
2322
|
+
* const changeStream = collection.watch([
|
|
2323
|
+
* { $match: { operationType: 'insert' } }
|
|
2324
|
+
* ])
|
|
2325
|
+
*
|
|
2326
|
+
* for await (const event of changeStream) {
|
|
2327
|
+
* console.log('Change:', event.operationType, event.fullDocument)
|
|
2328
|
+
* }
|
|
2329
|
+
* ```
|
|
2330
|
+
*/
|
|
2331
|
+
watch(pipeline?: ChangeStreamPipeline, options?: ChangeStreamOptions): ChangeStream<TSchema>;
|
|
2332
|
+
/**
|
|
2333
|
+
* Check if a document matches a filter
|
|
2334
|
+
* @internal
|
|
2335
|
+
*/
|
|
2336
|
+
private _matchesFilter;
|
|
2337
|
+
/**
|
|
2338
|
+
* Check if a value matches operator conditions
|
|
2339
|
+
*/
|
|
2340
|
+
private _matchesOperators;
|
|
2341
|
+
/**
|
|
2342
|
+
* Compare two values for equality
|
|
2343
|
+
*/
|
|
2344
|
+
private _valuesEqual;
|
|
2345
|
+
/**
|
|
2346
|
+
* Get nested value from document using dot notation
|
|
2347
|
+
*/
|
|
2348
|
+
private _getNestedValue;
|
|
2349
|
+
/**
|
|
2350
|
+
* Apply update operators to a document
|
|
2351
|
+
*/
|
|
2352
|
+
private _applyUpdate;
|
|
2353
|
+
/**
|
|
2354
|
+
* Set a nested value in an object
|
|
2355
|
+
*/
|
|
2356
|
+
private _setNestedValue;
|
|
2357
|
+
/**
|
|
2358
|
+
* Delete a nested value from an object
|
|
2359
|
+
*/
|
|
2360
|
+
private _deleteNestedValue;
|
|
2361
|
+
/**
|
|
2362
|
+
* Sort documents by the given sort specification
|
|
2363
|
+
*/
|
|
2364
|
+
private _sortDocuments;
|
|
2365
|
+
/**
|
|
2366
|
+
* Apply projection to a document
|
|
2367
|
+
* @internal
|
|
2368
|
+
*/
|
|
2369
|
+
_applyProjection(doc: TSchema & {
|
|
2370
|
+
_id: ObjectId$1;
|
|
2371
|
+
}, projection: Record<string, 0 | 1>): TSchema & {
|
|
2372
|
+
_id: ObjectId$1;
|
|
2373
|
+
};
|
|
2374
|
+
/**
|
|
2375
|
+
* Extract updated and removed fields from an update object
|
|
2376
|
+
* @internal
|
|
2377
|
+
*/
|
|
2378
|
+
private _extractUpdateChanges;
|
|
2379
|
+
/**
|
|
2380
|
+
* Execute an aggregation pipeline on the collection
|
|
2381
|
+
*
|
|
2382
|
+
* Returns an AggregationCursor that supports:
|
|
2383
|
+
* - Async iteration with `for await (const doc of cursor)`
|
|
2384
|
+
* - Converting to array with `await cursor.toArray()`
|
|
2385
|
+
* - forEach iteration with `await cursor.forEach(callback)`
|
|
2386
|
+
*
|
|
2387
|
+
* Supports async stages like $function and $lookup with pipeline.
|
|
2388
|
+
*
|
|
2389
|
+
* @param pipeline - Array of aggregation pipeline stages
|
|
2390
|
+
* @param options - Aggregation options
|
|
2391
|
+
* @returns AggregationCursor for iterating over results
|
|
2392
|
+
*
|
|
2393
|
+
* @example
|
|
2394
|
+
* ```typescript
|
|
2395
|
+
* // Using toArray
|
|
2396
|
+
* const results = await collection.aggregate([
|
|
2397
|
+
* { $match: { status: 'active' } },
|
|
2398
|
+
* { $group: { _id: '$category', count: { $sum: 1 } } }
|
|
2399
|
+
* ]).toArray()
|
|
2400
|
+
*
|
|
2401
|
+
* // Using async iterator
|
|
2402
|
+
* for await (const doc of collection.aggregate([
|
|
2403
|
+
* { $match: { status: 'active' } }
|
|
2404
|
+
* ])) {
|
|
2405
|
+
* console.log(doc)
|
|
2406
|
+
* }
|
|
2407
|
+
* ```
|
|
2408
|
+
*/
|
|
2409
|
+
aggregate<TResult extends Document = TSchema>(pipeline: PipelineStage[], options?: AggregationCursorOptions): AggregationCursor<TResult>;
|
|
2410
|
+
/**
|
|
2411
|
+
* Execute $function stage on a document
|
|
2412
|
+
* @internal
|
|
2413
|
+
*/
|
|
2414
|
+
private _executeFunctionStage;
|
|
2415
|
+
/**
|
|
2416
|
+
* Execute aggregation pipeline on documents (in-memory implementation)
|
|
2417
|
+
* @internal
|
|
2418
|
+
*/
|
|
2419
|
+
private _executeAggregationPipeline;
|
|
2420
|
+
/**
|
|
2421
|
+
* Execute $project stage
|
|
2422
|
+
* @internal
|
|
2423
|
+
*/
|
|
2424
|
+
private _executeProjectStage;
|
|
2425
|
+
/**
|
|
2426
|
+
* Execute $group stage
|
|
2427
|
+
* @internal
|
|
2428
|
+
*/
|
|
2429
|
+
private _executeGroupStage;
|
|
2430
|
+
/**
|
|
2431
|
+
* Execute $sort stage
|
|
2432
|
+
* @internal
|
|
2433
|
+
*/
|
|
2434
|
+
private _executeSortStage;
|
|
2435
|
+
/**
|
|
2436
|
+
* Execute $unwind stage
|
|
2437
|
+
* @internal
|
|
2438
|
+
*/
|
|
2439
|
+
private _executeUnwindStage;
|
|
2440
|
+
/**
|
|
2441
|
+
* Execute $addFields/$set stage
|
|
2442
|
+
* @internal
|
|
2443
|
+
*/
|
|
2444
|
+
private _executeAddFieldsStage;
|
|
2445
|
+
/**
|
|
2446
|
+
* Execute $lookup stage
|
|
2447
|
+
* @internal
|
|
2448
|
+
*/
|
|
2449
|
+
private _executeLookupStage;
|
|
2450
|
+
/**
|
|
2451
|
+
* Evaluate an expression (simplified)
|
|
2452
|
+
* @internal
|
|
2453
|
+
*/
|
|
2454
|
+
private _evaluateExpression;
|
|
2455
|
+
/**
|
|
2456
|
+
* Evaluate a condition
|
|
2457
|
+
* @internal
|
|
2458
|
+
*/
|
|
2459
|
+
private _evaluateCondition;
|
|
2460
|
+
/**
|
|
2461
|
+
* Compare two expression values
|
|
2462
|
+
* @internal
|
|
2463
|
+
*/
|
|
2464
|
+
private _compareExprValues;
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
/**
|
|
2468
|
+
* RPC Client - Client-side RPC handler for capnweb-style Workers RPC
|
|
2469
|
+
*
|
|
2470
|
+
* Implements:
|
|
2471
|
+
* - HTTP batch protocol
|
|
2472
|
+
* - WebSocket sessions
|
|
2473
|
+
* - Auto-reconnection
|
|
2474
|
+
* - Request deduplication
|
|
2475
|
+
*/
|
|
2476
|
+
|
|
2477
|
+
/**
|
|
2478
|
+
* Deduplicates identical concurrent requests
|
|
2479
|
+
*/
|
|
2480
|
+
declare class RequestDeduplicator {
|
|
2481
|
+
private cache;
|
|
2482
|
+
private ttl;
|
|
2483
|
+
private cleanupInterval;
|
|
2484
|
+
constructor(options?: DeduplicatorOptions);
|
|
2485
|
+
/**
|
|
2486
|
+
* Start the cleanup interval
|
|
2487
|
+
*/
|
|
2488
|
+
private startCleanup;
|
|
2489
|
+
/**
|
|
2490
|
+
* Stop the cleanup interval
|
|
2491
|
+
*/
|
|
2492
|
+
destroy(): void;
|
|
2493
|
+
/**
|
|
2494
|
+
* Clean up expired entries
|
|
2495
|
+
*/
|
|
2496
|
+
private cleanup;
|
|
2497
|
+
/**
|
|
2498
|
+
* Check if a key exists and is not expired
|
|
2499
|
+
*/
|
|
2500
|
+
has(key: string): boolean;
|
|
2501
|
+
/**
|
|
2502
|
+
* Get a cached promise
|
|
2503
|
+
*/
|
|
2504
|
+
get(key: string): Promise<unknown> | undefined;
|
|
2505
|
+
/**
|
|
2506
|
+
* Set a promise for a key
|
|
2507
|
+
*/
|
|
2508
|
+
set(key: string, promise: Promise<unknown>): void;
|
|
2509
|
+
/**
|
|
2510
|
+
* Generate a cache key from method and params
|
|
2511
|
+
*/
|
|
2512
|
+
static generateKey(method: string, params: unknown[]): string;
|
|
2513
|
+
}
|
|
2514
|
+
/**
|
|
2515
|
+
* WebSocket-based RPC transport
|
|
2516
|
+
*/
|
|
2517
|
+
declare class WebSocketRpcTransport {
|
|
2518
|
+
private ws;
|
|
2519
|
+
private messageId;
|
|
2520
|
+
private pending;
|
|
2521
|
+
private messageHandlers;
|
|
2522
|
+
private options;
|
|
2523
|
+
constructor(ws: WebSocket, options?: {
|
|
2524
|
+
timeout?: number;
|
|
2525
|
+
});
|
|
2526
|
+
/**
|
|
2527
|
+
* Set up the WebSocket message handler
|
|
2528
|
+
*/
|
|
2529
|
+
private setupMessageHandler;
|
|
2530
|
+
/**
|
|
2531
|
+
* Handle incoming message
|
|
2532
|
+
*/
|
|
2533
|
+
private handleMessage;
|
|
2534
|
+
/**
|
|
2535
|
+
* Send a request over WebSocket
|
|
2536
|
+
*/
|
|
2537
|
+
send(request: Omit<RpcRequest, 'id'>): Promise<unknown>;
|
|
2538
|
+
/**
|
|
2539
|
+
* Add a message handler for streaming responses
|
|
2540
|
+
*/
|
|
2541
|
+
onMessage(handler: (message: unknown) => void): () => void;
|
|
2542
|
+
/**
|
|
2543
|
+
* Close the connection
|
|
2544
|
+
*/
|
|
2545
|
+
close(): void;
|
|
2546
|
+
/**
|
|
2547
|
+
* Get connection state
|
|
2548
|
+
*/
|
|
2549
|
+
get readyState(): number;
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* RPC client for connecting to Mondo workers
|
|
2553
|
+
*/
|
|
2554
|
+
declare class RpcClient {
|
|
2555
|
+
private url;
|
|
2556
|
+
readonly options: Required<RpcClientOptions>;
|
|
2557
|
+
readonly transport: 'http' | 'websocket';
|
|
2558
|
+
private eventHandlers;
|
|
2559
|
+
private batchMode;
|
|
2560
|
+
private batchQueue;
|
|
2561
|
+
private deduplicator;
|
|
2562
|
+
private wsTransport;
|
|
2563
|
+
constructor(url: string, options?: RpcClientOptions);
|
|
2564
|
+
/**
|
|
2565
|
+
* Make an RPC call
|
|
2566
|
+
*/
|
|
2567
|
+
call(method: string, params: unknown[]): Promise<unknown>;
|
|
2568
|
+
/**
|
|
2569
|
+
* Execute the actual RPC call
|
|
2570
|
+
*/
|
|
2571
|
+
private executeCall;
|
|
2572
|
+
/**
|
|
2573
|
+
* Execute with retry logic
|
|
2574
|
+
*/
|
|
2575
|
+
private executeWithRetry;
|
|
2576
|
+
/**
|
|
2577
|
+
* Start batch mode
|
|
2578
|
+
*/
|
|
2579
|
+
startBatch(): void;
|
|
2580
|
+
/**
|
|
2581
|
+
* End batch mode and send all queued requests
|
|
2582
|
+
*/
|
|
2583
|
+
endBatch(): Promise<void>;
|
|
2584
|
+
/**
|
|
2585
|
+
* Register an event handler
|
|
2586
|
+
*/
|
|
2587
|
+
on<T = unknown>(event: string, handler: EventHandler<T>): void;
|
|
2588
|
+
/**
|
|
2589
|
+
* Remove an event handler
|
|
2590
|
+
*/
|
|
2591
|
+
off<T = unknown>(event: string, handler: EventHandler<T>): void;
|
|
2592
|
+
/**
|
|
2593
|
+
* Emit an event
|
|
2594
|
+
*/
|
|
2595
|
+
emit<T = unknown>(event: string, data: T): void;
|
|
2596
|
+
/**
|
|
2597
|
+
* Connect via WebSocket
|
|
2598
|
+
*/
|
|
2599
|
+
connectWebSocket(): Promise<void>;
|
|
2600
|
+
/**
|
|
2601
|
+
* Close the client connection
|
|
2602
|
+
*/
|
|
2603
|
+
close(): void;
|
|
2604
|
+
}
|
|
2605
|
+
/**
|
|
2606
|
+
* MongoDB-compatible client wrapper over RPC
|
|
2607
|
+
*/
|
|
2608
|
+
declare class MongoClient {
|
|
2609
|
+
private client;
|
|
2610
|
+
private isConnected;
|
|
2611
|
+
private dbName;
|
|
2612
|
+
constructor(url: string, options?: RpcClientOptions);
|
|
2613
|
+
/**
|
|
2614
|
+
* Parse MongoDB URL to extract RPC endpoint
|
|
2615
|
+
*/
|
|
2616
|
+
private parseMongoUrl;
|
|
2617
|
+
/**
|
|
2618
|
+
* Connect to the database
|
|
2619
|
+
*/
|
|
2620
|
+
connect(): Promise<MongoClient>;
|
|
2621
|
+
/**
|
|
2622
|
+
* Get a database reference
|
|
2623
|
+
*/
|
|
2624
|
+
db(name?: string): Database;
|
|
2625
|
+
/**
|
|
2626
|
+
* Close the connection
|
|
2627
|
+
*/
|
|
2628
|
+
close(): void;
|
|
2629
|
+
/**
|
|
2630
|
+
* Check if connected
|
|
2631
|
+
*/
|
|
2632
|
+
get connected(): boolean;
|
|
2633
|
+
}
|
|
2634
|
+
/**
|
|
2635
|
+
* Database reference
|
|
2636
|
+
*/
|
|
2637
|
+
declare class Database {
|
|
2638
|
+
private client;
|
|
2639
|
+
private name;
|
|
2640
|
+
constructor(client: RpcClient, name: string);
|
|
2641
|
+
/**
|
|
2642
|
+
* Get a collection reference
|
|
2643
|
+
*/
|
|
2644
|
+
collection(name: string): Collection;
|
|
2645
|
+
}
|
|
2646
|
+
/**
|
|
2647
|
+
* RPC Find Cursor - Simple cursor for RPC-based find operations
|
|
2648
|
+
*/
|
|
2649
|
+
declare class RpcFindCursor<T = unknown> {
|
|
2650
|
+
private client;
|
|
2651
|
+
private dbName;
|
|
2652
|
+
private collectionName;
|
|
2653
|
+
private query;
|
|
2654
|
+
private _sort?;
|
|
2655
|
+
private _limit?;
|
|
2656
|
+
private _skip?;
|
|
2657
|
+
private _projection?;
|
|
2658
|
+
private _buffer;
|
|
2659
|
+
private _position;
|
|
2660
|
+
private _fetched;
|
|
2661
|
+
private _closed;
|
|
2662
|
+
constructor(client: RpcClient, dbName: string, collectionName: string, query?: Record<string, unknown>);
|
|
2663
|
+
get closed(): boolean;
|
|
2664
|
+
sort(spec: Record<string, 1 | -1>): this;
|
|
2665
|
+
limit(count: number): this;
|
|
2666
|
+
skip(count: number): this;
|
|
2667
|
+
project(spec: Record<string, 0 | 1>): this;
|
|
2668
|
+
private ensureFetched;
|
|
2669
|
+
next(): Promise<T | null>;
|
|
2670
|
+
hasNext(): Promise<boolean>;
|
|
2671
|
+
toArray(): Promise<T[]>;
|
|
2672
|
+
forEach(callback: (doc: T, index: number) => void | false | Promise<void | false>): Promise<void>;
|
|
2673
|
+
count(): Promise<number>;
|
|
2674
|
+
close(): Promise<void>;
|
|
2675
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
2676
|
+
}
|
|
2677
|
+
/**
|
|
2678
|
+
* RPC Aggregation Cursor - Simple cursor for RPC-based aggregate operations
|
|
2679
|
+
*/
|
|
2680
|
+
declare class RpcAggregationCursor<T = unknown> {
|
|
2681
|
+
private client;
|
|
2682
|
+
private dbName;
|
|
2683
|
+
private collectionName;
|
|
2684
|
+
private pipeline;
|
|
2685
|
+
private options;
|
|
2686
|
+
private _buffer;
|
|
2687
|
+
private _position;
|
|
2688
|
+
private _fetched;
|
|
2689
|
+
private _closed;
|
|
2690
|
+
constructor(client: RpcClient, dbName: string, collectionName: string, pipeline?: unknown[], options?: Record<string, unknown>);
|
|
2691
|
+
get closed(): boolean;
|
|
2692
|
+
private ensureFetched;
|
|
2693
|
+
next(): Promise<T | null>;
|
|
2694
|
+
hasNext(): Promise<boolean>;
|
|
2695
|
+
toArray(): Promise<T[]>;
|
|
2696
|
+
forEach(callback: (doc: T, index: number) => void | false | Promise<void | false>): Promise<void>;
|
|
2697
|
+
close(): Promise<void>;
|
|
2698
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
2699
|
+
}
|
|
2700
|
+
/**
|
|
2701
|
+
* Collection reference
|
|
2702
|
+
*/
|
|
2703
|
+
declare class Collection {
|
|
2704
|
+
private client;
|
|
2705
|
+
private dbName;
|
|
2706
|
+
private collectionName;
|
|
2707
|
+
constructor(client: RpcClient, dbName: string, collectionName: string);
|
|
2708
|
+
/**
|
|
2709
|
+
* Find documents - returns a cursor
|
|
2710
|
+
*/
|
|
2711
|
+
find(query?: Record<string, unknown>): RpcFindCursor;
|
|
2712
|
+
/**
|
|
2713
|
+
* Find one document
|
|
2714
|
+
*/
|
|
2715
|
+
findOne(query?: Record<string, unknown>): Promise<unknown | null>;
|
|
2716
|
+
/**
|
|
2717
|
+
* Aggregate pipeline - returns a cursor
|
|
2718
|
+
*/
|
|
2719
|
+
aggregate(pipeline?: unknown[], options?: Record<string, unknown>): RpcAggregationCursor;
|
|
2720
|
+
/**
|
|
2721
|
+
* Insert one document
|
|
2722
|
+
*/
|
|
2723
|
+
insertOne(document: Record<string, unknown>): Promise<{
|
|
2724
|
+
insertedId: string;
|
|
2725
|
+
}>;
|
|
2726
|
+
/**
|
|
2727
|
+
* Update one document
|
|
2728
|
+
*/
|
|
2729
|
+
updateOne(filter: Record<string, unknown>, update: Record<string, unknown>): Promise<{
|
|
2730
|
+
matchedCount: number;
|
|
2731
|
+
modifiedCount: number;
|
|
2732
|
+
}>;
|
|
2733
|
+
/**
|
|
2734
|
+
* Delete one document
|
|
2735
|
+
*/
|
|
2736
|
+
deleteOne(filter: Record<string, unknown>): Promise<{
|
|
2737
|
+
deletedCount: number;
|
|
2738
|
+
}>;
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
export { CreateIndexOptions, CreateIndexResult, DeduplicatorOptions, DropIndexResult, EventHandler, IndexInfo, IndexManager, IndexSpec, MongoClient, MongoCollection, ObjectId$1 as ObjectId, RequestDeduplicator, RpcClient, RpcClientOptions, RpcRequest, SQLStorage, WebSocketRpcTransport, buildCreateIndexSQL, generateIndexName, generateSQLiteIndexName };
|