@dotdo/postgres 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +868 -0
- package/dist/cdc/change-stream.d.ts +44 -0
- package/dist/cdc/change-stream.d.ts.map +1 -0
- package/dist/cdc/change-stream.js +95 -0
- package/dist/cdc/change-stream.js.map +1 -0
- package/dist/cdc/filter.d.ts +58 -0
- package/dist/cdc/filter.d.ts.map +1 -0
- package/dist/cdc/filter.js +520 -0
- package/dist/cdc/filter.js.map +1 -0
- package/dist/cdc/index.d.ts +47 -0
- package/dist/cdc/index.d.ts.map +1 -0
- package/dist/cdc/index.js +50 -0
- package/dist/cdc/index.js.map +1 -0
- package/dist/cdc/resume-token.d.ts +60 -0
- package/dist/cdc/resume-token.d.ts.map +1 -0
- package/dist/cdc/resume-token.js +228 -0
- package/dist/cdc/resume-token.js.map +1 -0
- package/dist/cdc/transport/index.d.ts +7 -0
- package/dist/cdc/transport/index.d.ts.map +1 -0
- package/dist/cdc/transport/index.js +7 -0
- package/dist/cdc/transport/index.js.map +1 -0
- package/dist/cdc/transport/sse.d.ts +120 -0
- package/dist/cdc/transport/sse.d.ts.map +1 -0
- package/dist/cdc/transport/sse.js +590 -0
- package/dist/cdc/transport/sse.js.map +1 -0
- package/dist/cdc/transport/websocket.d.ts +130 -0
- package/dist/cdc/transport/websocket.d.ts.map +1 -0
- package/dist/cdc/transport/websocket.js +688 -0
- package/dist/cdc/transport/websocket.js.map +1 -0
- package/dist/cdc/types.d.ts +306 -0
- package/dist/cdc/types.d.ts.map +1 -0
- package/dist/cdc/types.js +8 -0
- package/dist/cdc/types.js.map +1 -0
- package/dist/config/index.d.ts +25 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +25 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/memory.d.ts +139 -0
- package/dist/config/memory.d.ts.map +1 -0
- package/dist/config/memory.js +157 -0
- package/dist/config/memory.js.map +1 -0
- package/dist/config/storage.d.ts +157 -0
- package/dist/config/storage.d.ts.map +1 -0
- package/dist/config/storage.js +178 -0
- package/dist/config/storage.js.map +1 -0
- package/dist/config/streaming.d.ts +117 -0
- package/dist/config/streaming.d.ts.map +1 -0
- package/dist/config/streaming.js +132 -0
- package/dist/config/streaming.js.map +1 -0
- package/dist/config/timeouts.d.ts +168 -0
- package/dist/config/timeouts.d.ts.map +1 -0
- package/dist/config/timeouts.js +192 -0
- package/dist/config/timeouts.js.map +1 -0
- package/dist/extensions/config.d.ts +89 -0
- package/dist/extensions/config.d.ts.map +1 -0
- package/dist/extensions/config.js +216 -0
- package/dist/extensions/config.js.map +1 -0
- package/dist/extensions/geo.d.ts +452 -0
- package/dist/extensions/geo.d.ts.map +1 -0
- package/dist/extensions/geo.js +583 -0
- package/dist/extensions/geo.js.map +1 -0
- package/dist/extensions/index.d.ts +167 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +99 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/loader.d.ts +226 -0
- package/dist/extensions/loader.d.ts.map +1 -0
- package/dist/extensions/loader.js +456 -0
- package/dist/extensions/loader.js.map +1 -0
- package/dist/extensions/pgmq-lite.d.ts +330 -0
- package/dist/extensions/pgmq-lite.d.ts.map +1 -0
- package/dist/extensions/pgmq-lite.js +648 -0
- package/dist/extensions/pgmq-lite.js.map +1 -0
- package/dist/extensions/plugins.d.ts +260 -0
- package/dist/extensions/plugins.d.ts.map +1 -0
- package/dist/extensions/plugins.js +535 -0
- package/dist/extensions/plugins.js.map +1 -0
- package/dist/extensions/registry.d.ts +93 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/extensions/registry.js +182 -0
- package/dist/extensions/registry.js.map +1 -0
- package/dist/extensions/vector.d.ts +106 -0
- package/dist/extensions/vector.d.ts.map +1 -0
- package/dist/extensions/vector.js +129 -0
- package/dist/extensions/vector.js.map +1 -0
- package/dist/iceberg/analytics.d.ts +279 -0
- package/dist/iceberg/analytics.d.ts.map +1 -0
- package/dist/iceberg/analytics.js +448 -0
- package/dist/iceberg/analytics.js.map +1 -0
- package/dist/iceberg/catalog-api.d.ts +39 -0
- package/dist/iceberg/catalog-api.d.ts.map +1 -0
- package/dist/iceberg/catalog-api.js +388 -0
- package/dist/iceberg/catalog-api.js.map +1 -0
- package/dist/iceberg/catalog.d.ts +401 -0
- package/dist/iceberg/catalog.d.ts.map +1 -0
- package/dist/iceberg/catalog.js +677 -0
- package/dist/iceberg/catalog.js.map +1 -0
- package/dist/iceberg/duckdb-wasm.d.ts +447 -0
- package/dist/iceberg/duckdb-wasm.d.ts.map +1 -0
- package/dist/iceberg/duckdb-wasm.js +600 -0
- package/dist/iceberg/duckdb-wasm.js.map +1 -0
- package/dist/iceberg/index.d.ts +92 -0
- package/dist/iceberg/index.d.ts.map +1 -0
- package/dist/iceberg/index.js +119 -0
- package/dist/iceberg/index.js.map +1 -0
- package/dist/iceberg/metadata.d.ts +214 -0
- package/dist/iceberg/metadata.d.ts.map +1 -0
- package/dist/iceberg/metadata.js +535 -0
- package/dist/iceberg/metadata.js.map +1 -0
- package/dist/iceberg/optimizer.d.ts +296 -0
- package/dist/iceberg/optimizer.d.ts.map +1 -0
- package/dist/iceberg/optimizer.js +889 -0
- package/dist/iceberg/optimizer.js.map +1 -0
- package/dist/iceberg/parquet.d.ts +447 -0
- package/dist/iceberg/parquet.d.ts.map +1 -0
- package/dist/iceberg/parquet.js +1225 -0
- package/dist/iceberg/parquet.js.map +1 -0
- package/dist/iceberg/r2-organization.d.ts +422 -0
- package/dist/iceberg/r2-organization.d.ts.map +1 -0
- package/dist/iceberg/r2-organization.js +672 -0
- package/dist/iceberg/r2-organization.js.map +1 -0
- package/dist/iceberg/scheduler-do-example.d.ts +158 -0
- package/dist/iceberg/scheduler-do-example.d.ts.map +1 -0
- package/dist/iceberg/scheduler-do-example.js +261 -0
- package/dist/iceberg/scheduler-do-example.js.map +1 -0
- package/dist/iceberg/scheduler.d.ts +434 -0
- package/dist/iceberg/scheduler.d.ts.map +1 -0
- package/dist/iceberg/scheduler.js +818 -0
- package/dist/iceberg/scheduler.js.map +1 -0
- package/dist/iceberg/schema.d.ts +149 -0
- package/dist/iceberg/schema.d.ts.map +1 -0
- package/dist/iceberg/schema.js +525 -0
- package/dist/iceberg/schema.js.map +1 -0
- package/dist/iceberg/snapshot-manager.d.ts +406 -0
- package/dist/iceberg/snapshot-manager.d.ts.map +1 -0
- package/dist/iceberg/snapshot-manager.js +934 -0
- package/dist/iceberg/snapshot-manager.js.map +1 -0
- package/dist/iceberg/sql-router.d.ts +194 -0
- package/dist/iceberg/sql-router.d.ts.map +1 -0
- package/dist/iceberg/sql-router.js +180 -0
- package/dist/iceberg/sql-router.js.map +1 -0
- package/dist/iceberg/test-fixtures.d.ts +151 -0
- package/dist/iceberg/test-fixtures.d.ts.map +1 -0
- package/dist/iceberg/test-fixtures.js +446 -0
- package/dist/iceberg/test-fixtures.js.map +1 -0
- package/dist/iceberg/time-travel-api.d.ts +102 -0
- package/dist/iceberg/time-travel-api.d.ts.map +1 -0
- package/dist/iceberg/time-travel-api.js +437 -0
- package/dist/iceberg/time-travel-api.js.map +1 -0
- package/dist/iceberg/time-travel.d.ts +293 -0
- package/dist/iceberg/time-travel.d.ts.map +1 -0
- package/dist/iceberg/time-travel.js +689 -0
- package/dist/iceberg/time-travel.js.map +1 -0
- package/dist/iceberg/transformer.d.ts +356 -0
- package/dist/iceberg/transformer.d.ts.map +1 -0
- package/dist/iceberg/transformer.js +770 -0
- package/dist/iceberg/transformer.js.map +1 -0
- package/dist/iceberg/types.d.ts +318 -0
- package/dist/iceberg/types.d.ts.map +1 -0
- package/dist/iceberg/types.js +9 -0
- package/dist/iceberg/types.js.map +1 -0
- package/dist/iceberg/writer.d.ts +144 -0
- package/dist/iceberg/writer.d.ts.map +1 -0
- package/dist/iceberg/writer.js +452 -0
- package/dist/iceberg/writer.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/lineage/index.d.ts +11 -0
- package/dist/lineage/index.d.ts.map +1 -0
- package/dist/lineage/index.js +11 -0
- package/dist/lineage/index.js.map +1 -0
- package/dist/lineage/integration.d.ts +134 -0
- package/dist/lineage/integration.d.ts.map +1 -0
- package/dist/lineage/integration.js +258 -0
- package/dist/lineage/integration.js.map +1 -0
- package/dist/lineage/tracker.d.ts +189 -0
- package/dist/lineage/tracker.d.ts.map +1 -0
- package/dist/lineage/tracker.js +1352 -0
- package/dist/lineage/tracker.js.map +1 -0
- package/dist/lineage/types.d.ts +318 -0
- package/dist/lineage/types.d.ts.map +1 -0
- package/dist/lineage/types.js +9 -0
- package/dist/lineage/types.js.map +1 -0
- package/dist/middleware/index.d.ts +11 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +16 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/rate-limit.d.ts +397 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.js +507 -0
- package/dist/middleware/rate-limit.js.map +1 -0
- package/dist/migration-tooling/external-migration.d.ts +601 -0
- package/dist/migration-tooling/external-migration.d.ts.map +1 -0
- package/dist/migration-tooling/external-migration.js +1612 -0
- package/dist/migration-tooling/external-migration.js.map +1 -0
- package/dist/migration-tooling/index.d.ts +19 -0
- package/dist/migration-tooling/index.d.ts.map +1 -0
- package/dist/migration-tooling/index.js +19 -0
- package/dist/migration-tooling/index.js.map +1 -0
- package/dist/migrations/auto-migrator.d.ts +289 -0
- package/dist/migrations/auto-migrator.d.ts.map +1 -0
- package/dist/migrations/auto-migrator.js +396 -0
- package/dist/migrations/auto-migrator.js.map +1 -0
- package/dist/migrations/bulk-orchestrator.d.ts +403 -0
- package/dist/migrations/bulk-orchestrator.d.ts.map +1 -0
- package/dist/migrations/bulk-orchestrator.js +646 -0
- package/dist/migrations/bulk-orchestrator.js.map +1 -0
- package/dist/migrations/compatibility.d.ts +216 -0
- package/dist/migrations/compatibility.d.ts.map +1 -0
- package/dist/migrations/compatibility.js +651 -0
- package/dist/migrations/compatibility.js.map +1 -0
- package/dist/migrations/do-migrations.d.ts +101 -0
- package/dist/migrations/do-migrations.d.ts.map +1 -0
- package/dist/migrations/do-migrations.js +1060 -0
- package/dist/migrations/do-migrations.js.map +1 -0
- package/dist/migrations/do-migrations.types.d.ts +550 -0
- package/dist/migrations/do-migrations.types.d.ts.map +1 -0
- package/dist/migrations/do-migrations.types.js +15 -0
- package/dist/migrations/do-migrations.types.js.map +1 -0
- package/dist/migrations/drizzle-compat.d.ts +163 -0
- package/dist/migrations/drizzle-compat.d.ts.map +1 -0
- package/dist/migrations/drizzle-compat.js +273 -0
- package/dist/migrations/drizzle-compat.js.map +1 -0
- package/dist/migrations/index.d.ts +109 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +127 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/migration-api.d.ts +161 -0
- package/dist/migrations/migration-api.d.ts.map +1 -0
- package/dist/migrations/migration-api.js +499 -0
- package/dist/migrations/migration-api.js.map +1 -0
- package/dist/migrations/progress-tracker-do.d.ts +195 -0
- package/dist/migrations/progress-tracker-do.d.ts.map +1 -0
- package/dist/migrations/progress-tracker-do.js +339 -0
- package/dist/migrations/progress-tracker-do.js.map +1 -0
- package/dist/migrations/progress-tracker-kv.d.ts +103 -0
- package/dist/migrations/progress-tracker-kv.d.ts.map +1 -0
- package/dist/migrations/progress-tracker-kv.js +231 -0
- package/dist/migrations/progress-tracker-kv.js.map +1 -0
- package/dist/migrations/progress-tracker.d.ts +320 -0
- package/dist/migrations/progress-tracker.d.ts.map +1 -0
- package/dist/migrations/progress-tracker.js +443 -0
- package/dist/migrations/progress-tracker.js.map +1 -0
- package/dist/migrations/registry.d.ts +231 -0
- package/dist/migrations/registry.d.ts.map +1 -0
- package/dist/migrations/registry.js +376 -0
- package/dist/migrations/registry.js.map +1 -0
- package/dist/migrations/runner.d.ts +197 -0
- package/dist/migrations/runner.d.ts.map +1 -0
- package/dist/migrations/runner.js +1167 -0
- package/dist/migrations/runner.js.map +1 -0
- package/dist/migrations/schema-generator.d.ts +111 -0
- package/dist/migrations/schema-generator.d.ts.map +1 -0
- package/dist/migrations/schema-generator.js +335 -0
- package/dist/migrations/schema-generator.js.map +1 -0
- package/dist/migrations/testing.d.ts +321 -0
- package/dist/migrations/testing.d.ts.map +1 -0
- package/dist/migrations/testing.js +645 -0
- package/dist/migrations/testing.js.map +1 -0
- package/dist/migrations/types.d.ts +503 -0
- package/dist/migrations/types.d.ts.map +1 -0
- package/dist/migrations/types.js +11 -0
- package/dist/migrations/types.js.map +1 -0
- package/dist/migrations/validator.d.ts +215 -0
- package/dist/migrations/validator.d.ts.map +1 -0
- package/dist/migrations/validator.js +494 -0
- package/dist/migrations/validator.js.map +1 -0
- package/dist/observability/alerting.d.ts +116 -0
- package/dist/observability/alerting.d.ts.map +1 -0
- package/dist/observability/alerting.js +353 -0
- package/dist/observability/alerting.js.map +1 -0
- package/dist/observability/analytics-engine.d.ts +357 -0
- package/dist/observability/analytics-engine.d.ts.map +1 -0
- package/dist/observability/analytics-engine.js +430 -0
- package/dist/observability/analytics-engine.js.map +1 -0
- package/dist/observability/cost-metrics.d.ts +269 -0
- package/dist/observability/cost-metrics.d.ts.map +1 -0
- package/dist/observability/cost-metrics.js +560 -0
- package/dist/observability/cost-metrics.js.map +1 -0
- package/dist/observability/cross-do-tracing.d.ts +305 -0
- package/dist/observability/cross-do-tracing.d.ts.map +1 -0
- package/dist/observability/cross-do-tracing.js +431 -0
- package/dist/observability/cross-do-tracing.js.map +1 -0
- package/dist/observability/error-rate-collector.d.ts +163 -0
- package/dist/observability/error-rate-collector.d.ts.map +1 -0
- package/dist/observability/error-rate-collector.js +306 -0
- package/dist/observability/error-rate-collector.js.map +1 -0
- package/dist/observability/exporters.d.ts +231 -0
- package/dist/observability/exporters.d.ts.map +1 -0
- package/dist/observability/exporters.js +479 -0
- package/dist/observability/exporters.js.map +1 -0
- package/dist/observability/health-check.d.ts +106 -0
- package/dist/observability/health-check.d.ts.map +1 -0
- package/dist/observability/health-check.js +243 -0
- package/dist/observability/health-check.js.map +1 -0
- package/dist/observability/index.d.ts +297 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +455 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/instrumentation.d.ts +222 -0
- package/dist/observability/instrumentation.d.ts.map +1 -0
- package/dist/observability/instrumentation.js +532 -0
- package/dist/observability/instrumentation.js.map +1 -0
- package/dist/observability/memory-metrics.d.ts +227 -0
- package/dist/observability/memory-metrics.d.ts.map +1 -0
- package/dist/observability/memory-metrics.js +688 -0
- package/dist/observability/memory-metrics.js.map +1 -0
- package/dist/observability/metrics-endpoint.d.ts +91 -0
- package/dist/observability/metrics-endpoint.d.ts.map +1 -0
- package/dist/observability/metrics-endpoint.js +246 -0
- package/dist/observability/metrics-endpoint.js.map +1 -0
- package/dist/observability/metrics.d.ts +88 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +253 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/observability/observability-features.d.ts +488 -0
- package/dist/observability/observability-features.d.ts.map +1 -0
- package/dist/observability/observability-features.js +773 -0
- package/dist/observability/observability-features.js.map +1 -0
- package/dist/observability/prometheus.d.ts +39 -0
- package/dist/observability/prometheus.d.ts.map +1 -0
- package/dist/observability/prometheus.js +120 -0
- package/dist/observability/prometheus.js.map +1 -0
- package/dist/observability/propagation.d.ts +126 -0
- package/dist/observability/propagation.d.ts.map +1 -0
- package/dist/observability/propagation.js +234 -0
- package/dist/observability/propagation.js.map +1 -0
- package/dist/observability/query-latency.d.ts +243 -0
- package/dist/observability/query-latency.d.ts.map +1 -0
- package/dist/observability/query-latency.js +292 -0
- package/dist/observability/query-latency.js.map +1 -0
- package/dist/observability/query-performance.d.ts +169 -0
- package/dist/observability/query-performance.d.ts.map +1 -0
- package/dist/observability/query-performance.js +290 -0
- package/dist/observability/query-performance.js.map +1 -0
- package/dist/observability/storage-tier-metrics.d.ts +174 -0
- package/dist/observability/storage-tier-metrics.d.ts.map +1 -0
- package/dist/observability/storage-tier-metrics.js +306 -0
- package/dist/observability/storage-tier-metrics.js.map +1 -0
- package/dist/observability/tier-cost-optimizer.d.ts +155 -0
- package/dist/observability/tier-cost-optimizer.d.ts.map +1 -0
- package/dist/observability/tier-cost-optimizer.js +536 -0
- package/dist/observability/tier-cost-optimizer.js.map +1 -0
- package/dist/observability/tracer.d.ts +149 -0
- package/dist/observability/tracer.d.ts.map +1 -0
- package/dist/observability/tracer.js +435 -0
- package/dist/observability/tracer.js.map +1 -0
- package/dist/observability/types.d.ts +402 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +103 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/pglite/workers-pglite.d.ts +138 -0
- package/dist/pglite/workers-pglite.d.ts.map +1 -0
- package/dist/pglite/workers-pglite.js +143 -0
- package/dist/pglite/workers-pglite.js.map +1 -0
- package/dist/pglite-assets/pglite.data +0 -0
- package/dist/pglite-assets/pglite.wasm +0 -0
- package/dist/playground/index.d.ts +52 -0
- package/dist/playground/index.d.ts.map +1 -0
- package/dist/playground/index.js +55 -0
- package/dist/playground/index.js.map +1 -0
- package/dist/playground/keyboard-shortcuts.d.ts +116 -0
- package/dist/playground/keyboard-shortcuts.d.ts.map +1 -0
- package/dist/playground/keyboard-shortcuts.js +588 -0
- package/dist/playground/keyboard-shortcuts.js.map +1 -0
- package/dist/playground/playground.d.ts +82 -0
- package/dist/playground/playground.d.ts.map +1 -0
- package/dist/playground/playground.js +271 -0
- package/dist/playground/playground.js.map +1 -0
- package/dist/playground/query-executor.d.ts +115 -0
- package/dist/playground/query-executor.d.ts.map +1 -0
- package/dist/playground/query-executor.js +558 -0
- package/dist/playground/query-executor.js.map +1 -0
- package/dist/playground/query-history.d.ts +92 -0
- package/dist/playground/query-history.d.ts.map +1 -0
- package/dist/playground/query-history.js +259 -0
- package/dist/playground/query-history.js.map +1 -0
- package/dist/playground/result-formatter.d.ts +59 -0
- package/dist/playground/result-formatter.d.ts.map +1 -0
- package/dist/playground/result-formatter.js +341 -0
- package/dist/playground/result-formatter.js.map +1 -0
- package/dist/playground/sample-datasets.d.ts +77 -0
- package/dist/playground/sample-datasets.d.ts.map +1 -0
- package/dist/playground/sample-datasets.js +641 -0
- package/dist/playground/sample-datasets.js.map +1 -0
- package/dist/playground/sample-queries.d.ts +73 -0
- package/dist/playground/sample-queries.d.ts.map +1 -0
- package/dist/playground/sample-queries.js +1095 -0
- package/dist/playground/sample-queries.js.map +1 -0
- package/dist/playground/schema-explorer.d.ts +55 -0
- package/dist/playground/schema-explorer.d.ts.map +1 -0
- package/dist/playground/schema-explorer.js +473 -0
- package/dist/playground/schema-explorer.js.map +1 -0
- package/dist/playground/types.d.ts +430 -0
- package/dist/playground/types.d.ts.map +1 -0
- package/dist/playground/types.js +10 -0
- package/dist/playground/types.js.map +1 -0
- package/dist/readonly/cache-reader.d.ts +145 -0
- package/dist/readonly/cache-reader.d.ts.map +1 -0
- package/dist/readonly/cache-reader.js +198 -0
- package/dist/readonly/cache-reader.js.map +1 -0
- package/dist/readonly/config.d.ts +74 -0
- package/dist/readonly/config.d.ts.map +1 -0
- package/dist/readonly/config.js +67 -0
- package/dist/readonly/config.js.map +1 -0
- package/dist/readonly/index.d.ts +22 -0
- package/dist/readonly/index.d.ts.map +1 -0
- package/dist/readonly/index.js +17 -0
- package/dist/readonly/index.js.map +1 -0
- package/dist/readonly/pglite-wrapper.d.ts +82 -0
- package/dist/readonly/pglite-wrapper.d.ts.map +1 -0
- package/dist/readonly/pglite-wrapper.js +123 -0
- package/dist/readonly/pglite-wrapper.js.map +1 -0
- package/dist/readonly/worker.d.ts +142 -0
- package/dist/readonly/worker.d.ts.map +1 -0
- package/dist/readonly/worker.js +187 -0
- package/dist/readonly/worker.js.map +1 -0
- package/dist/readonly/write-blocker.d.ts +47 -0
- package/dist/readonly/write-blocker.d.ts.map +1 -0
- package/dist/readonly/write-blocker.js +136 -0
- package/dist/readonly/write-blocker.js.map +1 -0
- package/dist/recovery/disaster-recovery.d.ts +326 -0
- package/dist/recovery/disaster-recovery.d.ts.map +1 -0
- package/dist/recovery/disaster-recovery.js +799 -0
- package/dist/recovery/disaster-recovery.js.map +1 -0
- package/dist/recovery/index.d.ts +12 -0
- package/dist/recovery/index.d.ts.map +1 -0
- package/dist/recovery/index.js +12 -0
- package/dist/recovery/index.js.map +1 -0
- package/dist/recovery/parquet-parser.d.ts +321 -0
- package/dist/recovery/parquet-parser.d.ts.map +1 -0
- package/dist/recovery/parquet-parser.js +797 -0
- package/dist/recovery/parquet-parser.js.map +1 -0
- package/dist/retention/index.d.ts +50 -0
- package/dist/retention/index.d.ts.map +1 -0
- package/dist/retention/index.js +50 -0
- package/dist/retention/index.js.map +1 -0
- package/dist/retention/policy.d.ts +344 -0
- package/dist/retention/policy.d.ts.map +1 -0
- package/dist/retention/policy.js +472 -0
- package/dist/retention/policy.js.map +1 -0
- package/dist/retention/purger.d.ts +187 -0
- package/dist/retention/purger.d.ts.map +1 -0
- package/dist/retention/purger.js +411 -0
- package/dist/retention/purger.js.map +1 -0
- package/dist/rls/auth-integration.d.ts +280 -0
- package/dist/rls/auth-integration.d.ts.map +1 -0
- package/dist/rls/auth-integration.js +399 -0
- package/dist/rls/auth-integration.js.map +1 -0
- package/dist/rls/generator.d.ts +249 -0
- package/dist/rls/generator.d.ts.map +1 -0
- package/dist/rls/generator.js +495 -0
- package/dist/rls/generator.js.map +1 -0
- package/dist/rls/index.d.ts +26 -0
- package/dist/rls/index.d.ts.map +1 -0
- package/dist/rls/index.js +58 -0
- package/dist/rls/index.js.map +1 -0
- package/dist/rls/policy.d.ts +116 -0
- package/dist/rls/policy.d.ts.map +1 -0
- package/dist/rls/policy.js +77 -0
- package/dist/rls/policy.js.map +1 -0
- package/dist/rls/validator.d.ts +155 -0
- package/dist/rls/validator.d.ts.map +1 -0
- package/dist/rls/validator.js +792 -0
- package/dist/rls/validator.js.map +1 -0
- package/dist/routing/adaptive-router.d.ts +317 -0
- package/dist/routing/adaptive-router.d.ts.map +1 -0
- package/dist/routing/adaptive-router.js +554 -0
- package/dist/routing/adaptive-router.js.map +1 -0
- package/dist/routing/circuit-breaker.d.ts +339 -0
- package/dist/routing/circuit-breaker.d.ts.map +1 -0
- package/dist/routing/circuit-breaker.js +620 -0
- package/dist/routing/circuit-breaker.js.map +1 -0
- package/dist/routing/cost-metrics.d.ts +133 -0
- package/dist/routing/cost-metrics.d.ts.map +1 -0
- package/dist/routing/cost-metrics.js +259 -0
- package/dist/routing/cost-metrics.js.map +1 -0
- package/dist/routing/do-connection-pool.d.ts +243 -0
- package/dist/routing/do-connection-pool.d.ts.map +1 -0
- package/dist/routing/do-connection-pool.js +572 -0
- package/dist/routing/do-connection-pool.js.map +1 -0
- package/dist/routing/index.d.ts +59 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +59 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/query-complexity-estimator.d.ts +73 -0
- package/dist/routing/query-complexity-estimator.d.ts.map +1 -0
- package/dist/routing/query-complexity-estimator.js +327 -0
- package/dist/routing/query-complexity-estimator.js.map +1 -0
- package/dist/routing/request-coalescing.d.ts +178 -0
- package/dist/routing/request-coalescing.d.ts.map +1 -0
- package/dist/routing/request-coalescing.js +325 -0
- package/dist/routing/request-coalescing.js.map +1 -0
- package/dist/routing/runtime-router.d.ts +107 -0
- package/dist/routing/runtime-router.d.ts.map +1 -0
- package/dist/routing/runtime-router.js +246 -0
- package/dist/routing/runtime-router.js.map +1 -0
- package/dist/routing/tenant-router.d.ts +848 -0
- package/dist/routing/tenant-router.d.ts.map +1 -0
- package/dist/routing/tenant-router.js +1056 -0
- package/dist/routing/tenant-router.js.map +1 -0
- package/dist/routing/websocket-pool.d.ts +119 -0
- package/dist/routing/websocket-pool.d.ts.map +1 -0
- package/dist/routing/websocket-pool.js +436 -0
- package/dist/routing/websocket-pool.js.map +1 -0
- package/dist/storage/cache-layer.d.ts +159 -0
- package/dist/storage/cache-layer.d.ts.map +1 -0
- package/dist/storage/cache-layer.js +245 -0
- package/dist/storage/cache-layer.js.map +1 -0
- package/dist/storage/cost-aware-tiering.d.ts +258 -0
- package/dist/storage/cost-aware-tiering.d.ts.map +1 -0
- package/dist/storage/cost-aware-tiering.js +526 -0
- package/dist/storage/cost-aware-tiering.js.map +1 -0
- package/dist/storage/index.d.ts +87 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +78 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/interfaces.d.ts +856 -0
- package/dist/storage/interfaces.d.ts.map +1 -0
- package/dist/storage/interfaces.js +69 -0
- package/dist/storage/interfaces.js.map +1 -0
- package/dist/storage/r2-layer.d.ts +226 -0
- package/dist/storage/r2-layer.d.ts.map +1 -0
- package/dist/storage/r2-layer.js +307 -0
- package/dist/storage/r2-layer.js.map +1 -0
- package/dist/storage/r2-overflow.d.ts +344 -0
- package/dist/storage/r2-overflow.d.ts.map +1 -0
- package/dist/storage/r2-overflow.js +730 -0
- package/dist/storage/r2-overflow.js.map +1 -0
- package/dist/storage/r2-page-vfs.d.ts +374 -0
- package/dist/storage/r2-page-vfs.d.ts.map +1 -0
- package/dist/storage/r2-page-vfs.js +754 -0
- package/dist/storage/r2-page-vfs.js.map +1 -0
- package/dist/storage/swr-cache.d.ts +181 -0
- package/dist/storage/swr-cache.d.ts.map +1 -0
- package/dist/storage/swr-cache.js +295 -0
- package/dist/storage/swr-cache.js.map +1 -0
- package/dist/storage/tiered-orchestrator.d.ts +951 -0
- package/dist/storage/tiered-orchestrator.d.ts.map +1 -0
- package/dist/storage/tiered-orchestrator.js +1731 -0
- package/dist/storage/tiered-orchestrator.js.map +1 -0
- package/dist/storage/tiered-vfs-swr.d.ts +279 -0
- package/dist/storage/tiered-vfs-swr.d.ts.map +1 -0
- package/dist/storage/tiered-vfs-swr.js +584 -0
- package/dist/storage/tiered-vfs-swr.js.map +1 -0
- package/dist/storage/tiered-vfs.d.ts +405 -0
- package/dist/storage/tiered-vfs.d.ts.map +1 -0
- package/dist/storage/tiered-vfs.js +833 -0
- package/dist/storage/tiered-vfs.js.map +1 -0
- package/dist/streaming/backpressure-controller.d.ts +173 -0
- package/dist/streaming/backpressure-controller.d.ts.map +1 -0
- package/dist/streaming/backpressure-controller.js +344 -0
- package/dist/streaming/backpressure-controller.js.map +1 -0
- package/dist/streaming/buffer-pool.d.ts +241 -0
- package/dist/streaming/buffer-pool.d.ts.map +1 -0
- package/dist/streaming/buffer-pool.js +381 -0
- package/dist/streaming/buffer-pool.js.map +1 -0
- package/dist/streaming/cdc-iceberg-connector.d.ts +272 -0
- package/dist/streaming/cdc-iceberg-connector.d.ts.map +1 -0
- package/dist/streaming/cdc-iceberg-connector.js +408 -0
- package/dist/streaming/cdc-iceberg-connector.js.map +1 -0
- package/dist/streaming/index.d.ts +111 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +128 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/live-cdc-stream.d.ts +400 -0
- package/dist/streaming/live-cdc-stream.d.ts.map +1 -0
- package/dist/streaming/live-cdc-stream.js +703 -0
- package/dist/streaming/live-cdc-stream.js.map +1 -0
- package/dist/streaming/memory-bounded-stream.d.ts +207 -0
- package/dist/streaming/memory-bounded-stream.d.ts.map +1 -0
- package/dist/streaming/memory-bounded-stream.js +340 -0
- package/dist/streaming/memory-bounded-stream.js.map +1 -0
- package/dist/streaming/query-streamer.d.ts +379 -0
- package/dist/streaming/query-streamer.d.ts.map +1 -0
- package/dist/streaming/query-streamer.js +495 -0
- package/dist/streaming/query-streamer.js.map +1 -0
- package/dist/streaming/response-streaming.d.ts +203 -0
- package/dist/streaming/response-streaming.d.ts.map +1 -0
- package/dist/streaming/response-streaming.js +449 -0
- package/dist/streaming/response-streaming.js.map +1 -0
- package/dist/types/branded.d.ts +859 -0
- package/dist/types/branded.d.ts.map +1 -0
- package/dist/types/branded.js +891 -0
- package/dist/types/branded.js.map +1 -0
- package/dist/types/utilities.d.ts +757 -0
- package/dist/types/utilities.d.ts.map +1 -0
- package/dist/types/utilities.js +447 -0
- package/dist/types/utilities.js.map +1 -0
- package/dist/wal/replay-engine.d.ts +344 -0
- package/dist/wal/replay-engine.d.ts.map +1 -0
- package/dist/wal/replay-engine.js +975 -0
- package/dist/wal/replay-engine.js.map +1 -0
- package/dist/worker/__mocks__/capnweb.d.ts +13 -0
- package/dist/worker/__mocks__/capnweb.d.ts.map +1 -0
- package/dist/worker/__mocks__/capnweb.js +15 -0
- package/dist/worker/__mocks__/capnweb.js.map +1 -0
- package/dist/worker/__mocks__/cloudflare-workers.d.ts +31 -0
- package/dist/worker/__mocks__/cloudflare-workers.d.ts.map +1 -0
- package/dist/worker/__mocks__/cloudflare-workers.js +33 -0
- package/dist/worker/__mocks__/cloudflare-workers.js.map +1 -0
- package/dist/worker/__mocks__/pglite.data.d.ts +3 -0
- package/dist/worker/__mocks__/pglite.data.d.ts.map +1 -0
- package/dist/worker/__mocks__/pglite.data.js +20 -0
- package/dist/worker/__mocks__/pglite.data.js.map +1 -0
- package/dist/worker/__mocks__/pglite.wasm.d.ts +3 -0
- package/dist/worker/__mocks__/pglite.wasm.d.ts.map +1 -0
- package/dist/worker/__mocks__/pglite.wasm.js +30 -0
- package/dist/worker/__mocks__/pglite.wasm.js.map +1 -0
- package/dist/worker/auth-rate-limiter.d.ts +270 -0
- package/dist/worker/auth-rate-limiter.d.ts.map +1 -0
- package/dist/worker/auth-rate-limiter.js +332 -0
- package/dist/worker/auth-rate-limiter.js.map +1 -0
- package/dist/worker/auth.d.ts +345 -0
- package/dist/worker/auth.d.ts.map +1 -0
- package/dist/worker/auth.js +837 -0
- package/dist/worker/auth.js.map +1 -0
- package/dist/worker/cdc-backpressure.d.ts +338 -0
- package/dist/worker/cdc-backpressure.d.ts.map +1 -0
- package/dist/worker/cdc-backpressure.js +619 -0
- package/dist/worker/cdc-backpressure.js.map +1 -0
- package/dist/worker/cdc-sse.d.ts +277 -0
- package/dist/worker/cdc-sse.d.ts.map +1 -0
- package/dist/worker/cdc-sse.js +528 -0
- package/dist/worker/cdc-sse.js.map +1 -0
- package/dist/worker/cdc-websocket.d.ts +252 -0
- package/dist/worker/cdc-websocket.d.ts.map +1 -0
- package/dist/worker/cdc-websocket.js +940 -0
- package/dist/worker/cdc-websocket.js.map +1 -0
- package/dist/worker/cdc.d.ts +95 -0
- package/dist/worker/cdc.d.ts.map +1 -0
- package/dist/worker/cdc.js +211 -0
- package/dist/worker/cdc.js.map +1 -0
- package/dist/worker/concerns/auth-concern.d.ts +50 -0
- package/dist/worker/concerns/auth-concern.d.ts.map +1 -0
- package/dist/worker/concerns/auth-concern.js +131 -0
- package/dist/worker/concerns/auth-concern.js.map +1 -0
- package/dist/worker/concerns/cdc-concern.d.ts +99 -0
- package/dist/worker/concerns/cdc-concern.d.ts.map +1 -0
- package/dist/worker/concerns/cdc-concern.js +137 -0
- package/dist/worker/concerns/cdc-concern.js.map +1 -0
- package/dist/worker/concerns/index.d.ts +22 -0
- package/dist/worker/concerns/index.d.ts.map +1 -0
- package/dist/worker/concerns/index.js +13 -0
- package/dist/worker/concerns/index.js.map +1 -0
- package/dist/worker/concerns/query-execution-concern.d.ts +104 -0
- package/dist/worker/concerns/query-execution-concern.d.ts.map +1 -0
- package/dist/worker/concerns/query-execution-concern.js +95 -0
- package/dist/worker/concerns/query-execution-concern.js.map +1 -0
- package/dist/worker/concerns/storage-orchestration-concern.d.ts +78 -0
- package/dist/worker/concerns/storage-orchestration-concern.d.ts.map +1 -0
- package/dist/worker/concerns/storage-orchestration-concern.js +240 -0
- package/dist/worker/concerns/storage-orchestration-concern.js.map +1 -0
- package/dist/worker/do-auth-manager.d.ts +108 -0
- package/dist/worker/do-auth-manager.d.ts.map +1 -0
- package/dist/worker/do-auth-manager.js +212 -0
- package/dist/worker/do-auth-manager.js.map +1 -0
- package/dist/worker/do-pglite-manager.d.ts +137 -0
- package/dist/worker/do-pglite-manager.d.ts.map +1 -0
- package/dist/worker/do-pglite-manager.js +228 -0
- package/dist/worker/do-pglite-manager.js.map +1 -0
- package/dist/worker/do.d.ts +556 -0
- package/dist/worker/do.d.ts.map +1 -0
- package/dist/worker/do.js +1441 -0
- package/dist/worker/do.js.map +1 -0
- package/dist/worker/entry.d.ts +23 -0
- package/dist/worker/entry.d.ts.map +1 -0
- package/dist/worker/entry.js +362 -0
- package/dist/worker/entry.js.map +1 -0
- package/dist/worker/errors.d.ts +106 -0
- package/dist/worker/errors.d.ts.map +1 -0
- package/dist/worker/errors.js +178 -0
- package/dist/worker/errors.js.map +1 -0
- package/dist/worker/health-check-manager.d.ts +141 -0
- package/dist/worker/health-check-manager.d.ts.map +1 -0
- package/dist/worker/health-check-manager.js +145 -0
- package/dist/worker/health-check-manager.js.map +1 -0
- package/dist/worker/index.d.ts +60 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +67 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/memory-pressure.d.ts +892 -0
- package/dist/worker/memory-pressure.d.ts.map +1 -0
- package/dist/worker/memory-pressure.js +1990 -0
- package/dist/worker/memory-pressure.js.map +1 -0
- package/dist/worker/migration-manager.d.ts +153 -0
- package/dist/worker/migration-manager.d.ts.map +1 -0
- package/dist/worker/migration-manager.js +461 -0
- package/dist/worker/migration-manager.js.map +1 -0
- package/dist/worker/plugin-manager.d.ts +147 -0
- package/dist/worker/plugin-manager.d.ts.map +1 -0
- package/dist/worker/plugin-manager.js +408 -0
- package/dist/worker/plugin-manager.js.map +1 -0
- package/dist/worker/proxy.d.ts +330 -0
- package/dist/worker/proxy.d.ts.map +1 -0
- package/dist/worker/proxy.js +504 -0
- package/dist/worker/proxy.js.map +1 -0
- package/dist/worker/query-execution-manager.d.ts +107 -0
- package/dist/worker/query-execution-manager.d.ts.map +1 -0
- package/dist/worker/query-execution-manager.js +155 -0
- package/dist/worker/query-execution-manager.js.map +1 -0
- package/dist/worker/query-executor.d.ts +163 -0
- package/dist/worker/query-executor.d.ts.map +1 -0
- package/dist/worker/query-executor.js +413 -0
- package/dist/worker/query-executor.js.map +1 -0
- package/dist/worker/query-stats-manager.d.ts +117 -0
- package/dist/worker/query-stats-manager.d.ts.map +1 -0
- package/dist/worker/query-stats-manager.js +162 -0
- package/dist/worker/query-stats-manager.js.map +1 -0
- package/dist/worker/result-handler.d.ts +192 -0
- package/dist/worker/result-handler.d.ts.map +1 -0
- package/dist/worker/result-handler.js +346 -0
- package/dist/worker/result-handler.js.map +1 -0
- package/dist/worker/routes.d.ts +135 -0
- package/dist/worker/routes.d.ts.map +1 -0
- package/dist/worker/routes.js +460 -0
- package/dist/worker/routes.js.map +1 -0
- package/dist/worker/rpc-methods-manager.d.ts +142 -0
- package/dist/worker/rpc-methods-manager.d.ts.map +1 -0
- package/dist/worker/rpc-methods-manager.js +195 -0
- package/dist/worker/rpc-methods-manager.js.map +1 -0
- package/dist/worker/rpc.d.ts +259 -0
- package/dist/worker/rpc.d.ts.map +1 -0
- package/dist/worker/rpc.js +398 -0
- package/dist/worker/rpc.js.map +1 -0
- package/dist/worker/schema-version.d.ts +209 -0
- package/dist/worker/schema-version.d.ts.map +1 -0
- package/dist/worker/schema-version.js +450 -0
- package/dist/worker/schema-version.js.map +1 -0
- package/dist/worker/session-manager.d.ts +282 -0
- package/dist/worker/session-manager.d.ts.map +1 -0
- package/dist/worker/session-manager.js +523 -0
- package/dist/worker/session-manager.js.map +1 -0
- package/dist/worker/shutdown-manager.d.ts +188 -0
- package/dist/worker/shutdown-manager.d.ts.map +1 -0
- package/dist/worker/shutdown-manager.js +347 -0
- package/dist/worker/shutdown-manager.js.map +1 -0
- package/dist/worker/sql-transform.d.ts +61 -0
- package/dist/worker/sql-transform.d.ts.map +1 -0
- package/dist/worker/sql-transform.js +312 -0
- package/dist/worker/sql-transform.js.map +1 -0
- package/dist/worker/types.d.ts +738 -0
- package/dist/worker/types.d.ts.map +1 -0
- package/dist/worker/types.js +6 -0
- package/dist/worker/types.js.map +1 -0
- package/dist/worker/user-routes.d.ts +76 -0
- package/dist/worker/user-routes.d.ts.map +1 -0
- package/dist/worker/user-routes.js +188 -0
- package/dist/worker/user-routes.js.map +1 -0
- package/dist/worker/wal-facade.d.ts +138 -0
- package/dist/worker/wal-facade.d.ts.map +1 -0
- package/dist/worker/wal-facade.js +184 -0
- package/dist/worker/wal-facade.js.map +1 -0
- package/dist/worker/wal-r2.d.ts +271 -0
- package/dist/worker/wal-r2.d.ts.map +1 -0
- package/dist/worker/wal-r2.js +689 -0
- package/dist/worker/wal-r2.js.map +1 -0
- package/dist/worker/wal-replay.d.ts +361 -0
- package/dist/worker/wal-replay.d.ts.map +1 -0
- package/dist/worker/wal-replay.js +628 -0
- package/dist/worker/wal-replay.js.map +1 -0
- package/dist/worker/wal-retention.d.ts +389 -0
- package/dist/worker/wal-retention.d.ts.map +1 -0
- package/dist/worker/wal-retention.js +763 -0
- package/dist/worker/wal-retention.js.map +1 -0
- package/dist/worker/wal.d.ts +278 -0
- package/dist/worker/wal.d.ts.map +1 -0
- package/dist/worker/wal.js +467 -0
- package/dist/worker/wal.js.map +1 -0
- package/dist/worker/websocket.d.ts +85 -0
- package/dist/worker/websocket.d.ts.map +1 -0
- package/dist/worker/websocket.js +227 -0
- package/dist/worker/websocket.js.map +1 -0
- package/package.json +108 -0
- package/src/cdc/change-stream.ts +137 -0
- package/src/cdc/filter.ts +646 -0
- package/src/cdc/index.ts +112 -0
- package/src/cdc/resume-token.ts +280 -0
- package/src/cdc/transport/index.ts +7 -0
- package/src/cdc/transport/sse.ts +723 -0
- package/src/cdc/transport/websocket.ts +873 -0
- package/src/cdc/types.ts +346 -0
- package/src/config/index.ts +25 -0
- package/src/config/memory.ts +177 -0
- package/src/config/storage.ts +204 -0
- package/src/config/streaming.ts +147 -0
- package/src/config/timeouts.ts +221 -0
- package/src/extensions/config.test.ts +187 -0
- package/src/extensions/config.ts +278 -0
- package/src/extensions/geo.test.ts +455 -0
- package/src/extensions/geo.ts +858 -0
- package/src/extensions/index.test.ts +259 -0
- package/src/extensions/index.ts +227 -0
- package/src/extensions/loader.test.ts +555 -0
- package/src/extensions/loader.ts +588 -0
- package/src/extensions/pgmq-lite.test.ts +727 -0
- package/src/extensions/pgmq-lite.ts +770 -0
- package/src/extensions/plugins.test.ts +528 -0
- package/src/extensions/plugins.ts +718 -0
- package/src/extensions/registry.test.ts +202 -0
- package/src/extensions/registry.ts +267 -0
- package/src/extensions/vector.test.ts +195 -0
- package/src/extensions/vector.ts +217 -0
- package/src/iceberg/SCHEDULER.md +580 -0
- package/src/iceberg/analytics.test.ts +703 -0
- package/src/iceberg/analytics.ts +727 -0
- package/src/iceberg/catalog-api.test.ts +838 -0
- package/src/iceberg/catalog-api.ts +520 -0
- package/src/iceberg/catalog.test.ts +680 -0
- package/src/iceberg/catalog.ts +1007 -0
- package/src/iceberg/iceberg.test.ts +705 -0
- package/src/iceberg/index.ts +406 -0
- package/src/iceberg/metadata.test.ts +632 -0
- package/src/iceberg/metadata.ts +649 -0
- package/src/iceberg/optimizer.test.ts +868 -0
- package/src/iceberg/optimizer.ts +1287 -0
- package/src/iceberg/parquet.test.ts +899 -0
- package/src/iceberg/parquet.ts +1640 -0
- package/src/iceberg/r2-organization.test.ts +615 -0
- package/src/iceberg/r2-organization.ts +951 -0
- package/src/iceberg/scheduler-do-example.ts +364 -0
- package/src/iceberg/scheduler.test.ts +861 -0
- package/src/iceberg/scheduler.ts +1201 -0
- package/src/iceberg/schema.test.ts +547 -0
- package/src/iceberg/schema.ts +616 -0
- package/src/iceberg/snapshot-manager.test.ts +919 -0
- package/src/iceberg/snapshot-manager.ts +1369 -0
- package/src/iceberg/sql-router.test.ts +334 -0
- package/src/iceberg/sql-router.ts +337 -0
- package/src/iceberg/test-fixtures.ts +605 -0
- package/src/iceberg/time-travel-api.test.ts +1029 -0
- package/src/iceberg/time-travel-api.ts +731 -0
- package/src/iceberg/time-travel.test.ts +1218 -0
- package/src/iceberg/time-travel.ts +1052 -0
- package/src/iceberg/transformer.test.ts +689 -0
- package/src/iceberg/transformer.ts +1029 -0
- package/src/iceberg/types.ts +373 -0
- package/src/iceberg/writer.test.ts +716 -0
- package/src/iceberg/writer.ts +590 -0
- package/src/index.ts +212 -0
- package/src/lineage/index.ts +42 -0
- package/src/lineage/integration.ts +334 -0
- package/src/lineage/tracker.ts +1618 -0
- package/src/lineage/types.ts +354 -0
- package/src/middleware/index.ts +36 -0
- package/src/middleware/rate-limit-concurrent.test.ts +794 -0
- package/src/middleware/rate-limit.test.ts +1568 -0
- package/src/middleware/rate-limit.ts +840 -0
- package/src/migration-tooling/external-migration.test.ts +1864 -0
- package/src/migration-tooling/external-migration.ts +2355 -0
- package/src/migration-tooling/index.ts +19 -0
- package/src/migrations/ARCHITECTURE.md +474 -0
- package/src/migrations/PROGRESS_TRACKING.md +485 -0
- package/src/migrations/auto-migrator.test.ts +732 -0
- package/src/migrations/auto-migrator.ts +531 -0
- package/src/migrations/bulk-orchestrator.test.ts +801 -0
- package/src/migrations/bulk-orchestrator.ts +1039 -0
- package/src/migrations/compatibility.test.ts +958 -0
- package/src/migrations/compatibility.ts +902 -0
- package/src/migrations/do-migrations.test.ts +2620 -0
- package/src/migrations/do-migrations.ts +1289 -0
- package/src/migrations/do-migrations.types.ts +715 -0
- package/src/migrations/drizzle-compat.test.ts +210 -0
- package/src/migrations/drizzle-compat.ts +337 -0
- package/src/migrations/index.ts +334 -0
- package/src/migrations/migration-api.test.ts +438 -0
- package/src/migrations/migration-api.ts +704 -0
- package/src/migrations/progress-tracker-do.ts +518 -0
- package/src/migrations/progress-tracker-kv.ts +305 -0
- package/src/migrations/progress-tracker.test.ts +937 -0
- package/src/migrations/progress-tracker.ts +665 -0
- package/src/migrations/registry.test.ts +331 -0
- package/src/migrations/registry.ts +468 -0
- package/src/migrations/rollback.test.ts +644 -0
- package/src/migrations/runner.test.ts +807 -0
- package/src/migrations/runner.test.ts.backup +759 -0
- package/src/migrations/runner.ts +1459 -0
- package/src/migrations/schema-generator.test.ts +649 -0
- package/src/migrations/schema-generator.ts +513 -0
- package/src/migrations/testing.ts +1037 -0
- package/src/migrations/types.ts +573 -0
- package/src/migrations/validator.test.ts +660 -0
- package/src/migrations/validator.ts +741 -0
- package/src/observability/alerting.test.ts +1133 -0
- package/src/observability/alerting.ts +455 -0
- package/src/observability/analytics-engine.ts +733 -0
- package/src/observability/cost-metrics.ts +804 -0
- package/src/observability/cross-do-tracing.test.ts +516 -0
- package/src/observability/cross-do-tracing.ts +588 -0
- package/src/observability/dashboards/postgres-do-overview.json +1656 -0
- package/src/observability/error-rate-collector.test.ts +977 -0
- package/src/observability/error-rate-collector.ts +518 -0
- package/src/observability/exporters.test.ts +365 -0
- package/src/observability/exporters.ts +650 -0
- package/src/observability/health-check.test.ts +353 -0
- package/src/observability/health-check.ts +341 -0
- package/src/observability/index.test.ts +298 -0
- package/src/observability/index.ts +885 -0
- package/src/observability/instrumentation.test.ts +428 -0
- package/src/observability/instrumentation.ts +788 -0
- package/src/observability/memory-metrics.test.ts +355 -0
- package/src/observability/memory-metrics.ts +990 -0
- package/src/observability/metrics-endpoint.test.ts +402 -0
- package/src/observability/metrics-endpoint.ts +374 -0
- package/src/observability/metrics.test.ts +291 -0
- package/src/observability/metrics.ts +315 -0
- package/src/observability/observability-features.ts +1296 -0
- package/src/observability/prometheus.test.ts +292 -0
- package/src/observability/prometheus.ts +170 -0
- package/src/observability/propagation.test.ts +417 -0
- package/src/observability/propagation.ts +294 -0
- package/src/observability/query-latency.ts +586 -0
- package/src/observability/query-performance.test.ts +406 -0
- package/src/observability/query-performance.ts +491 -0
- package/src/observability/storage-tier-metrics.test.ts +633 -0
- package/src/observability/storage-tier-metrics.ts +570 -0
- package/src/observability/tier-cost-optimizer.ts +740 -0
- package/src/observability/tracer.test.ts +346 -0
- package/src/observability/tracer.ts +585 -0
- package/src/observability/types.test.ts +726 -0
- package/src/observability/types.ts +434 -0
- package/src/pglite/auto-demotion.test.ts +477 -0
- package/src/pglite/auto-demotion.ts +385 -0
- package/src/pglite/auto-promotion.test.ts +824 -0
- package/src/pglite/auto-promotion.ts +547 -0
- package/src/pglite/cache-layer.test.ts +469 -0
- package/src/pglite/cache-layer.ts +271 -0
- package/src/pglite/cold-start-manager.ts +1260 -0
- package/src/pglite/cold-start-optimizer.test.ts +937 -0
- package/src/pglite/cold-start-optimizer.ts +1895 -0
- package/src/pglite/dovfs-adapter.ts +1122 -0
- package/src/pglite/dovfs.ts +1258 -0
- package/src/pglite/etag-cache.test.ts +844 -0
- package/src/pglite/etag-cache.ts +526 -0
- package/src/pglite/index.ts +442 -0
- package/src/pglite/init.test.ts +455 -0
- package/src/pglite/init.ts +574 -0
- package/src/pglite/lifecycle.test.ts +599 -0
- package/src/pglite/lifecycle.ts +704 -0
- package/src/pglite/parallel-loader.test.ts +586 -0
- package/src/pglite/parallel-loader.ts +481 -0
- package/src/pglite/production-pglite.test.ts +666 -0
- package/src/pglite/production-pglite.ts +537 -0
- package/src/pglite/query-executor.ts +614 -0
- package/src/pglite/r2-layer.test.ts +501 -0
- package/src/pglite/r2-layer.ts +322 -0
- package/src/pglite/tiered-init.test.ts +725 -0
- package/src/pglite/tiered-init.ts +556 -0
- package/src/pglite/tiered-vfs.test.ts +726 -0
- package/src/pglite/tiered-vfs.ts +33 -0
- package/src/pglite/tiering-stats.test.ts +531 -0
- package/src/pglite/tiering-stats.ts +407 -0
- package/src/pglite/transaction-hooks.ts +343 -0
- package/src/pglite/warm-loader.test.ts +1701 -0
- package/src/pglite/warm-loader.ts +528 -0
- package/src/pglite/workers-pglite.ts +224 -0
- package/src/pglite-assets/pglite.data +0 -0
- package/src/pglite-assets/pglite.wasm +0 -0
- package/src/pglite.d.ts +47 -0
- package/src/playground/index.ts +137 -0
- package/src/playground/keyboard-shortcuts.ts +677 -0
- package/src/playground/playground.ts +323 -0
- package/src/playground/query-executor.ts +669 -0
- package/src/playground/query-history.ts +328 -0
- package/src/playground/result-formatter.ts +420 -0
- package/src/playground/sample-datasets.ts +674 -0
- package/src/playground/sample-queries.ts +1168 -0
- package/src/playground/schema-explorer.ts +558 -0
- package/src/playground/types.ts +518 -0
- package/src/readonly/cache-reader.test.ts +460 -0
- package/src/readonly/cache-reader.ts +313 -0
- package/src/readonly/config.test.ts +187 -0
- package/src/readonly/config.ts +128 -0
- package/src/readonly/index.ts +50 -0
- package/src/readonly/pglite-wrapper.test.ts +278 -0
- package/src/readonly/pglite-wrapper.ts +184 -0
- package/src/readonly/worker.test.ts +533 -0
- package/src/readonly/worker.ts +341 -0
- package/src/readonly/write-blocker.test.ts +459 -0
- package/src/readonly/write-blocker.ts +175 -0
- package/src/recovery/disaster-recovery.test.ts +618 -0
- package/src/recovery/disaster-recovery.ts +1181 -0
- package/src/recovery/index.ts +43 -0
- package/src/recovery/parquet-parser.ts +974 -0
- package/src/retention/index.ts +74 -0
- package/src/retention/policy.test.ts +571 -0
- package/src/retention/policy.ts +774 -0
- package/src/retention/purger.test.ts +465 -0
- package/src/retention/purger.ts +558 -0
- package/src/rls/auth-integration.test.ts +752 -0
- package/src/rls/auth-integration.ts +533 -0
- package/src/rls/generator.test.ts +829 -0
- package/src/rls/generator.ts +573 -0
- package/src/rls/index.ts +128 -0
- package/src/rls/policy.ts +208 -0
- package/src/rls/rls.test.ts +1071 -0
- package/src/rls/validator.test.ts +930 -0
- package/src/rls/validator.ts +895 -0
- package/src/routing/adaptive-router.test.ts +884 -0
- package/src/routing/adaptive-router.ts +845 -0
- package/src/routing/circuit-breaker.test.ts +1505 -0
- package/src/routing/circuit-breaker.ts +852 -0
- package/src/routing/cost-metrics.test.ts +565 -0
- package/src/routing/cost-metrics.ts +408 -0
- package/src/routing/do-connection-pool.test.ts +1109 -0
- package/src/routing/do-connection-pool.ts +828 -0
- package/src/routing/index.ts +158 -0
- package/src/routing/query-complexity-estimator.test.ts +356 -0
- package/src/routing/query-complexity-estimator.ts +444 -0
- package/src/routing/request-coalescing.test.ts +738 -0
- package/src/routing/request-coalescing.ts +475 -0
- package/src/routing/runtime-router.test.ts +436 -0
- package/src/routing/runtime-router.ts +357 -0
- package/src/routing/tenant-router.test.ts +2493 -0
- package/src/routing/tenant-router.ts +1908 -0
- package/src/routing/websocket-pool.test.ts +551 -0
- package/src/routing/websocket-pool.ts +577 -0
- package/src/storage/access-pattern-tracker.test.ts +874 -0
- package/src/storage/cache-layer.test.ts +560 -0
- package/src/storage/cache-layer.ts +328 -0
- package/src/storage/cost-aware-tiering.test.ts +652 -0
- package/src/storage/cost-aware-tiering.ts +794 -0
- package/src/storage/do-sqlite-blobs.test.ts +937 -0
- package/src/storage/index.ts +272 -0
- package/src/storage/interfaces.ts +974 -0
- package/src/storage/r2-layer.test.ts +653 -0
- package/src/storage/r2-layer.ts +434 -0
- package/src/storage/r2-overflow.ts +920 -0
- package/src/storage/r2-page-vfs.test.ts +2348 -0
- package/src/storage/r2-page-vfs.ts +1054 -0
- package/src/storage/swr-cache.test.ts +832 -0
- package/src/storage/swr-cache.ts +398 -0
- package/src/storage/swr-tiered-integration.test.ts +617 -0
- package/src/storage/tiered-orchestrator.test.ts +2441 -0
- package/src/storage/tiered-orchestrator.ts +2081 -0
- package/src/storage/tiered-vfs-swr.test.ts +736 -0
- package/src/storage/tiered-vfs-swr.ts +735 -0
- package/src/storage/tiered-vfs.test.ts +793 -0
- package/src/storage/tiered-vfs.ts +1082 -0
- package/src/streaming/backpressure-controller.ts +452 -0
- package/src/streaming/buffer-pool.ts +484 -0
- package/src/streaming/cdc-iceberg-connector.ts +605 -0
- package/src/streaming/index.ts +225 -0
- package/src/streaming/live-cdc-stream.ts +985 -0
- package/src/streaming/memory-bounded-stream.ts +443 -0
- package/src/streaming/query-streamer.ts +662 -0
- package/src/streaming/response-streaming.ts +557 -0
- package/src/types/branded.ts +1075 -0
- package/src/types/branded.ts.backup +273 -0
- package/src/types/utilities.ts +1023 -0
- package/src/types/wasm.d.ts +30 -0
- package/src/validation/typed-errors.test.ts +420 -0
- package/src/wal/replay-engine.ts +1264 -0
- package/src/worker/__mocks__/capnweb.ts +15 -0
- package/src/worker/__mocks__/pglite.data.ts +22 -0
- package/src/worker/__mocks__/pglite.wasm.ts +33 -0
- package/src/worker/auth-rate-limiter.test.ts +272 -0
- package/src/worker/auth-rate-limiter.ts +448 -0
- package/src/worker/auth.security-red.test.ts +1236 -0
- package/src/worker/auth.security.test.ts +822 -0
- package/src/worker/auth.test.ts +469 -0
- package/src/worker/auth.ts +1104 -0
- package/src/worker/cdc-backpressure.test.ts +726 -0
- package/src/worker/cdc-backpressure.ts +866 -0
- package/src/worker/cdc-sse.test.ts +780 -0
- package/src/worker/cdc-sse.ts +728 -0
- package/src/worker/cdc-websocket.ts +1229 -0
- package/src/worker/cdc-ws.test.ts +1009 -0
- package/src/worker/cdc.test.ts +327 -0
- package/src/worker/cdc.ts +289 -0
- package/src/worker/concerns/auth-concern.ts +179 -0
- package/src/worker/concerns/cdc-concern.ts +247 -0
- package/src/worker/concerns/index.ts +58 -0
- package/src/worker/concerns/query-execution-concern.ts +194 -0
- package/src/worker/concerns/storage-orchestration-concern.ts +373 -0
- package/src/worker/discriminated-types.test.ts +280 -0
- package/src/worker/do-auth-manager.ts +257 -0
- package/src/worker/do-decomposition.test.ts +1236 -0
- package/src/worker/do-pglite-manager.ts +302 -0
- package/src/worker/do.test.ts +2254 -0
- package/src/worker/do.ts +1878 -0
- package/src/worker/entry.ts +417 -0
- package/src/worker/errors.ts +285 -0
- package/src/worker/health-check-manager.test.ts +261 -0
- package/src/worker/health-check-manager.ts +231 -0
- package/src/worker/index.ts +389 -0
- package/src/worker/memory-pressure.test.ts +1460 -0
- package/src/worker/memory-pressure.ts +2650 -0
- package/src/worker/migration-manager.ts +582 -0
- package/src/worker/neon-compat.test.ts +332 -0
- package/src/worker/plugin-manager.ts +485 -0
- package/src/worker/postgres.do-rpc.d.ts +76 -0
- package/src/worker/proxy.ts +694 -0
- package/src/worker/query-execution-manager.test.ts +303 -0
- package/src/worker/query-execution-manager.ts +219 -0
- package/src/worker/query-executor.test.ts +282 -0
- package/src/worker/query-executor.ts +560 -0
- package/src/worker/query-stats-manager.ts +229 -0
- package/src/worker/result-handler.test.ts +364 -0
- package/src/worker/result-handler.ts +510 -0
- package/src/worker/routes.test.ts +795 -0
- package/src/worker/routes.ts +650 -0
- package/src/worker/rpc-methods-manager.test.ts +326 -0
- package/src/worker/rpc-methods-manager.ts +276 -0
- package/src/worker/rpc.ts +524 -0
- package/src/worker/schema-version.ts +605 -0
- package/src/worker/session-manager.test.ts +506 -0
- package/src/worker/session-manager.ts +732 -0
- package/src/worker/shutdown-manager.ts +469 -0
- package/src/worker/sql-transform.test.ts +286 -0
- package/src/worker/sql-transform.ts +368 -0
- package/src/worker/supabase-compat.test.ts +621 -0
- package/src/worker/types.test.ts +292 -0
- package/src/worker/types.ts +873 -0
- package/src/worker/user-routes.test.ts +703 -0
- package/src/worker/user-routes.ts +303 -0
- package/src/worker/wal-facade.ts +235 -0
- package/src/worker/wal-r2.test.ts +570 -0
- package/src/worker/wal-r2.ts +930 -0
- package/src/worker/wal-replay.test.ts +845 -0
- package/src/worker/wal-replay.ts +897 -0
- package/src/worker/wal-retention.test.ts +758 -0
- package/src/worker/wal-retention.ts +1075 -0
- package/src/worker/wal.test.ts +618 -0
- package/src/worker/wal.ts +697 -0
- package/src/worker/websocket.test.ts +296 -0
- package/src/worker/websocket.ts +284 -0
|
@@ -0,0 +1,1122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PGLite Adapter - Bridges DOVFS to PGLite Filesystem interface
|
|
3
|
+
*
|
|
4
|
+
* This adapter implements PGLite's Filesystem interface using our DOVFS
|
|
5
|
+
* (Durable Object Virtual File System) for persistent storage in Cloudflare
|
|
6
|
+
* Durable Objects.
|
|
7
|
+
*
|
|
8
|
+
* Extends PGLite's BaseFilesystem to provide a synchronous filesystem API
|
|
9
|
+
* over the async DOVFS storage.
|
|
10
|
+
*
|
|
11
|
+
* @module dovfs-adapter
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { DOVFSStorage, FileMetadata } from './dovfs'
|
|
15
|
+
import {
|
|
16
|
+
DOVFS,
|
|
17
|
+
DOVFSFile,
|
|
18
|
+
SQLITE_OK,
|
|
19
|
+
SQLITE_OPEN_READWRITE,
|
|
20
|
+
SQLITE_OPEN_CREATE,
|
|
21
|
+
SQLITE_OPEN_READONLY,
|
|
22
|
+
} from './dovfs'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* BaseFilesystem abstract class compatible with PGLite's filesystem interface.
|
|
26
|
+
*
|
|
27
|
+
* This is a minimal implementation that provides the base functionality needed
|
|
28
|
+
* by DOVFSAdapter without requiring import from pglite internals.
|
|
29
|
+
*
|
|
30
|
+
* @abstract
|
|
31
|
+
*/
|
|
32
|
+
export abstract class BaseFilesystem {
|
|
33
|
+
/** Base data directory for the filesystem */
|
|
34
|
+
protected dataDir?: string
|
|
35
|
+
/** Enable debug logging */
|
|
36
|
+
readonly debug: boolean
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new BaseFilesystem instance.
|
|
40
|
+
* @param dataDir - Optional base data directory path
|
|
41
|
+
* @param options - Configuration options
|
|
42
|
+
* @param options.debug - Enable debug logging (default: false)
|
|
43
|
+
*/
|
|
44
|
+
constructor(dataDir?: string, { debug = false }: { debug?: boolean } = {}) {
|
|
45
|
+
this.dataDir = dataDir
|
|
46
|
+
this.debug = debug
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Sync filesystem to persistent storage.
|
|
51
|
+
* @param _relaxedDurability - If true, allows for less strict durability guarantees
|
|
52
|
+
*/
|
|
53
|
+
async syncToFs(_relaxedDurability?: boolean): Promise<void> {}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Perform initial sync from storage to in-memory representation.
|
|
57
|
+
*/
|
|
58
|
+
async initialSyncFs(): Promise<void> {}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Close the filesystem and release resources.
|
|
62
|
+
*/
|
|
63
|
+
async closeFs(): Promise<void> {}
|
|
64
|
+
|
|
65
|
+
// Filesystem API - abstract methods to be implemented by subclasses
|
|
66
|
+
abstract chmod(path: string, mode: number): void
|
|
67
|
+
abstract close(fd: number): void
|
|
68
|
+
abstract fstat(fd: number): FsStats
|
|
69
|
+
abstract lstat(path: string): FsStats
|
|
70
|
+
abstract mkdir(path: string, options?: { recursive?: boolean; mode?: number }): void
|
|
71
|
+
abstract open(path: string, flags?: string, mode?: number): number
|
|
72
|
+
abstract readdir(path: string): string[]
|
|
73
|
+
abstract read(fd: number, buffer: Uint8Array, offset: number, length: number, position: number): number
|
|
74
|
+
abstract rename(oldPath: string, newPath: string): void
|
|
75
|
+
abstract rmdir(path: string): void
|
|
76
|
+
abstract truncate(path: string, len: number): void
|
|
77
|
+
abstract unlink(path: string): void
|
|
78
|
+
abstract utimes(path: string, atime: number, mtime: number): void
|
|
79
|
+
abstract writeFile(path: string, data: string | Uint8Array, options?: { encoding?: string; mode?: number; flag?: string }): void
|
|
80
|
+
abstract write(fd: number, buffer: Uint8Array, offset: number, length: number, position: number): number
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// PGLite filesystem constants
|
|
84
|
+
/** WASM filesystem prefix path */
|
|
85
|
+
export const WASM_PREFIX = '/tmp/pglite'
|
|
86
|
+
/** PostgreSQL data directory path within WASM filesystem */
|
|
87
|
+
export const PGDATA = WASM_PREFIX + '/base'
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Error codes compatible with Emscripten's FS error system.
|
|
91
|
+
* These codes map to standard POSIX errno values used by Emscripten.
|
|
92
|
+
* @see https://man7.org/linux/man-pages/man3/errno.3.html
|
|
93
|
+
*/
|
|
94
|
+
export const ERRNO_CODES = {
|
|
95
|
+
/** Bad file descriptor */
|
|
96
|
+
EBADF: 8,
|
|
97
|
+
/** File descriptor in bad state */
|
|
98
|
+
EBADFD: 127,
|
|
99
|
+
/** File already exists */
|
|
100
|
+
EEXIST: 20,
|
|
101
|
+
/** Invalid argument */
|
|
102
|
+
EINVAL: 28,
|
|
103
|
+
/** Is a directory (illegal operation on a directory) */
|
|
104
|
+
EISDIR: 31,
|
|
105
|
+
/** No such device */
|
|
106
|
+
ENODEV: 43,
|
|
107
|
+
/** No such file or directory */
|
|
108
|
+
ENOENT: 44,
|
|
109
|
+
/** Not a directory */
|
|
110
|
+
ENOTDIR: 54,
|
|
111
|
+
/** Directory not empty */
|
|
112
|
+
ENOTEMPTY: 55,
|
|
113
|
+
} as const
|
|
114
|
+
|
|
115
|
+
/** Type for ERRNO_CODES keys */
|
|
116
|
+
export type ErrnoCode = keyof typeof ERRNO_CODES
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Filesystem error type with errno code
|
|
120
|
+
*/
|
|
121
|
+
export interface FsError extends Error {
|
|
122
|
+
code: ErrnoCode | string
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* File stats structure compatible with PGLite's FsStats.
|
|
127
|
+
* Mirrors the stat(2) system call structure.
|
|
128
|
+
*/
|
|
129
|
+
export interface FsStats {
|
|
130
|
+
/** Device ID */
|
|
131
|
+
dev: number
|
|
132
|
+
/** Inode number */
|
|
133
|
+
ino: number
|
|
134
|
+
/** File mode (permissions and type) */
|
|
135
|
+
mode: number
|
|
136
|
+
/** Number of hard links */
|
|
137
|
+
nlink: number
|
|
138
|
+
/** User ID of owner */
|
|
139
|
+
uid: number
|
|
140
|
+
/** Group ID of owner */
|
|
141
|
+
gid: number
|
|
142
|
+
/** Device ID (if special file) */
|
|
143
|
+
rdev: number
|
|
144
|
+
/** Total size in bytes */
|
|
145
|
+
size: number
|
|
146
|
+
/** Block size for filesystem I/O */
|
|
147
|
+
blksize: number
|
|
148
|
+
/** Number of 512B blocks allocated */
|
|
149
|
+
blocks: number
|
|
150
|
+
/** Time of last access (ms since epoch) */
|
|
151
|
+
atime: number
|
|
152
|
+
/** Time of last modification (ms since epoch) */
|
|
153
|
+
mtime: number
|
|
154
|
+
/** Time of last status change (ms since epoch) */
|
|
155
|
+
ctime: number
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** File open mode flags used internally */
|
|
159
|
+
const FILE_MODE_READ = 0x01
|
|
160
|
+
const FILE_MODE_WRITE = 0x02
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Open file descriptor tracking.
|
|
164
|
+
* Maintains state for each open file handle.
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
interface OpenFile {
|
|
168
|
+
/** Full path to the file */
|
|
169
|
+
path: string
|
|
170
|
+
/** DOVFS file handle */
|
|
171
|
+
file: DOVFSFile
|
|
172
|
+
/** Current read/write position */
|
|
173
|
+
position: number
|
|
174
|
+
/** Open flags (SQLITE_OPEN_*) */
|
|
175
|
+
flags: number
|
|
176
|
+
/** Internal mode flags (FILE_MODE_READ, FILE_MODE_WRITE) */
|
|
177
|
+
modeFlags: number
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* In-memory file node for virtual filesystem.
|
|
182
|
+
* Represents either a file or directory in the virtual filesystem tree.
|
|
183
|
+
* @internal
|
|
184
|
+
*/
|
|
185
|
+
interface FileNode {
|
|
186
|
+
/** File or directory name (basename) */
|
|
187
|
+
name: string
|
|
188
|
+
/** Full path */
|
|
189
|
+
path: string
|
|
190
|
+
/** File mode (permissions and type flags) */
|
|
191
|
+
mode: number
|
|
192
|
+
/** Size in bytes (0 for directories) */
|
|
193
|
+
size: number
|
|
194
|
+
/** True if this node represents a directory */
|
|
195
|
+
isDirectory: boolean
|
|
196
|
+
/** Creation timestamp (ms since epoch) */
|
|
197
|
+
created: number
|
|
198
|
+
/** Last modification timestamp (ms since epoch) */
|
|
199
|
+
modified: number
|
|
200
|
+
/** Last access timestamp (ms since epoch) */
|
|
201
|
+
accessed: number
|
|
202
|
+
/** File contents (undefined for directories) */
|
|
203
|
+
data?: Uint8Array
|
|
204
|
+
/** Child nodes (only for directories) */
|
|
205
|
+
children?: Map<string, FileNode>
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Creates a filesystem error with the appropriate code.
|
|
210
|
+
* @param code - Error code name (e.g., 'ENOENT', 'EBADF')
|
|
211
|
+
* @param message - Human-readable error message
|
|
212
|
+
* @returns Error object with code property set
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
function createFsError(code: ErrnoCode, message: string): NodeJS.ErrnoException {
|
|
216
|
+
const error = new Error(message) as NodeJS.ErrnoException
|
|
217
|
+
error.code = code
|
|
218
|
+
return error
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* DOVFSAdapter - Adapts DOVFS for use with PGLite
|
|
223
|
+
*
|
|
224
|
+
* This class extends PGLite's BaseFilesystem and implements the filesystem
|
|
225
|
+
* operations required by PGLite, using DOVFS for persistent storage.
|
|
226
|
+
*
|
|
227
|
+
* The adapter maintains an in-memory representation of the filesystem tree
|
|
228
|
+
* while using DOVFS for persistent storage of file contents. This design
|
|
229
|
+
* allows for synchronous filesystem operations (required by PGLite's WASM
|
|
230
|
+
* interface) while deferring async storage operations to sync points.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const storage = ctx.storage; // Durable Object storage
|
|
235
|
+
* const adapter = new DOVFSAdapter(storage, '/pgdata', { debug: false });
|
|
236
|
+
* await adapter.initialSyncFs();
|
|
237
|
+
* // Use adapter for filesystem operations
|
|
238
|
+
* await adapter.closeFs();
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export class DOVFSAdapter extends BaseFilesystem {
|
|
242
|
+
/** Durable Object storage interface */
|
|
243
|
+
private storage: DOVFSStorage
|
|
244
|
+
/** DOVFS instance for file operations */
|
|
245
|
+
private dovfs: DOVFS
|
|
246
|
+
/** Map of open file descriptors to their state */
|
|
247
|
+
private files: Map<number, OpenFile> = new Map()
|
|
248
|
+
/** Next file descriptor to assign (starts after stdin/stdout/stderr) */
|
|
249
|
+
private nextFd: number = 3
|
|
250
|
+
/** In-memory filesystem tree */
|
|
251
|
+
private inMemoryNodes: Map<string, FileNode> = new Map()
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Creates a new DOVFSAdapter instance.
|
|
255
|
+
* @param storage - Durable Object storage interface
|
|
256
|
+
* @param dataDir - Optional base data directory path
|
|
257
|
+
* @param options - Configuration options
|
|
258
|
+
* @param options.debug - Enable debug logging (default: false)
|
|
259
|
+
*/
|
|
260
|
+
constructor(
|
|
261
|
+
storage: DOVFSStorage,
|
|
262
|
+
dataDir?: string,
|
|
263
|
+
options: { debug?: boolean } = {}
|
|
264
|
+
) {
|
|
265
|
+
super(dataDir, options)
|
|
266
|
+
this.storage = storage
|
|
267
|
+
this.dovfs = new DOVFS(storage)
|
|
268
|
+
this.initRootDirectory()
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Initialize root directory structure.
|
|
273
|
+
* Creates the root node with proper directory permissions.
|
|
274
|
+
* @internal
|
|
275
|
+
*/
|
|
276
|
+
private initRootDirectory(): void {
|
|
277
|
+
const now = Date.now()
|
|
278
|
+
this.inMemoryNodes.set('/', {
|
|
279
|
+
name: '',
|
|
280
|
+
path: '/',
|
|
281
|
+
mode: 0o40755, // Directory with rwxr-xr-x
|
|
282
|
+
size: 0,
|
|
283
|
+
isDirectory: true,
|
|
284
|
+
created: now,
|
|
285
|
+
modified: now,
|
|
286
|
+
accessed: now,
|
|
287
|
+
children: new Map(),
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Get or create a directory node in the filesystem tree.
|
|
293
|
+
* @param path - Absolute path to the directory
|
|
294
|
+
* @param mode - Optional mode (permissions) for the directory
|
|
295
|
+
* @returns The directory FileNode
|
|
296
|
+
* @internal
|
|
297
|
+
*/
|
|
298
|
+
private getOrCreateDir(path: string, mode?: number): FileNode {
|
|
299
|
+
const existing = this.inMemoryNodes.get(path)
|
|
300
|
+
if (existing) return existing
|
|
301
|
+
|
|
302
|
+
const now = Date.now()
|
|
303
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
304
|
+
const name = parts[parts.length - 1] || ''
|
|
305
|
+
|
|
306
|
+
// Combine directory type with provided permissions or default
|
|
307
|
+
const dirMode = 0o40000 | (mode !== undefined ? (mode & 0o777) : 0o755)
|
|
308
|
+
|
|
309
|
+
const node: FileNode = {
|
|
310
|
+
name,
|
|
311
|
+
path,
|
|
312
|
+
mode: dirMode,
|
|
313
|
+
size: 0,
|
|
314
|
+
isDirectory: true,
|
|
315
|
+
created: now,
|
|
316
|
+
modified: now,
|
|
317
|
+
accessed: now,
|
|
318
|
+
children: new Map(),
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
this.inMemoryNodes.set(path, node)
|
|
322
|
+
|
|
323
|
+
// Add to parent directory
|
|
324
|
+
const parentPath = '/' + parts.slice(0, -1).join('/')
|
|
325
|
+
const parent = this.inMemoryNodes.get(parentPath || '/')
|
|
326
|
+
if (parent?.children) {
|
|
327
|
+
parent.children.set(name, node)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return node
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Get or create a file node in the filesystem tree.
|
|
335
|
+
* If the file exists and data is provided, updates the file content.
|
|
336
|
+
* @param path - Absolute path to the file
|
|
337
|
+
* @param data - Optional file content
|
|
338
|
+
* @param mode - Optional file permissions (default: 0o644)
|
|
339
|
+
* @returns The file FileNode
|
|
340
|
+
* @internal
|
|
341
|
+
*/
|
|
342
|
+
private getOrCreateFile(path: string, data?: Uint8Array, mode?: number): FileNode {
|
|
343
|
+
const existing = this.inMemoryNodes.get(path)
|
|
344
|
+
if (existing && !existing.isDirectory) {
|
|
345
|
+
if (data !== undefined) {
|
|
346
|
+
existing.data = data
|
|
347
|
+
existing.size = data.length
|
|
348
|
+
existing.modified = Date.now()
|
|
349
|
+
}
|
|
350
|
+
if (mode !== undefined) {
|
|
351
|
+
// Update mode, preserving file type bits
|
|
352
|
+
existing.mode = 0o100000 | (mode & 0o777)
|
|
353
|
+
}
|
|
354
|
+
return existing
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const now = Date.now()
|
|
358
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
359
|
+
const name = parts[parts.length - 1] || ''
|
|
360
|
+
|
|
361
|
+
// Combine regular file type with provided permissions or default
|
|
362
|
+
const fileMode = 0o100000 | (mode !== undefined ? (mode & 0o777) : 0o644)
|
|
363
|
+
|
|
364
|
+
const node: FileNode = {
|
|
365
|
+
name,
|
|
366
|
+
path,
|
|
367
|
+
mode: fileMode,
|
|
368
|
+
size: data?.length ?? 0,
|
|
369
|
+
isDirectory: false,
|
|
370
|
+
created: now,
|
|
371
|
+
modified: now,
|
|
372
|
+
accessed: now,
|
|
373
|
+
data,
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
this.inMemoryNodes.set(path, node)
|
|
377
|
+
|
|
378
|
+
// Add to parent directory
|
|
379
|
+
const parentPath = '/' + parts.slice(0, -1).join('/')
|
|
380
|
+
const parent = this.inMemoryNodes.get(parentPath || '/')
|
|
381
|
+
if (parent?.children) {
|
|
382
|
+
parent.children.set(name, node)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return node
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Log a debug message if debug mode is enabled.
|
|
390
|
+
* @param args - Arguments to log
|
|
391
|
+
* @internal
|
|
392
|
+
*/
|
|
393
|
+
private log(...args: unknown[]): void {
|
|
394
|
+
if (this.debug) {
|
|
395
|
+
console.log('[DOVFSAdapter]', ...args)
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Change file mode (permissions).
|
|
401
|
+
* Updates the mode bits for the specified file or directory.
|
|
402
|
+
* @param path - Absolute path to the file or directory
|
|
403
|
+
* @param mode - New mode bits (e.g., 0o644 for rw-r--r--)
|
|
404
|
+
* @throws {NodeJS.ErrnoException} ENOENT if path does not exist
|
|
405
|
+
*/
|
|
406
|
+
chmod(path: string, mode: number): void {
|
|
407
|
+
this.log('chmod', path, mode)
|
|
408
|
+
const node = this.inMemoryNodes.get(path)
|
|
409
|
+
if (!node) {
|
|
410
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, chmod '${path}'`)
|
|
411
|
+
}
|
|
412
|
+
// Preserve the file type bits (high bits) and update permission bits
|
|
413
|
+
const typeBits = node.mode & 0o170000
|
|
414
|
+
node.mode = typeBits | (mode & 0o777)
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Close a file descriptor and release associated resources.
|
|
419
|
+
* Flushes any pending writes to storage before closing.
|
|
420
|
+
* @param fd - File descriptor to close
|
|
421
|
+
* @throws {NodeJS.ErrnoException} EBADF if fd is not a valid open file descriptor
|
|
422
|
+
*/
|
|
423
|
+
close(fd: number): void {
|
|
424
|
+
this.log('close', fd)
|
|
425
|
+
const openFile = this.files.get(fd)
|
|
426
|
+
if (!openFile) {
|
|
427
|
+
throw createFsError('EBADF', `EBADF: bad file descriptor, close '${fd}'`)
|
|
428
|
+
}
|
|
429
|
+
// Flush pending writes and close the file
|
|
430
|
+
// Note: We fire-and-forget here since PGLite expects synchronous close.
|
|
431
|
+
// Errors are logged but not propagated; use syncToFs() for guaranteed durability.
|
|
432
|
+
void openFile.file.xClose().catch((err: unknown) => {
|
|
433
|
+
this.log('Error closing file:', err)
|
|
434
|
+
})
|
|
435
|
+
this.files.delete(fd)
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Get file stats by file descriptor.
|
|
440
|
+
* @param fd - Open file descriptor
|
|
441
|
+
* @returns File stats structure
|
|
442
|
+
* @throws {NodeJS.ErrnoException} EBADF if fd is not a valid open file descriptor
|
|
443
|
+
*/
|
|
444
|
+
fstat(fd: number): FsStats {
|
|
445
|
+
this.log('fstat', fd)
|
|
446
|
+
const openFile = this.files.get(fd)
|
|
447
|
+
if (!openFile) {
|
|
448
|
+
throw createFsError('EBADF', `EBADF: bad file descriptor, fstat '${fd}'`)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const node = this.inMemoryNodes.get(openFile.path)
|
|
452
|
+
const now = Date.now()
|
|
453
|
+
|
|
454
|
+
// Use in-memory node size if available, otherwise fall back to DOVFSFile size
|
|
455
|
+
const size = node?.size ?? openFile.file.size
|
|
456
|
+
|
|
457
|
+
return {
|
|
458
|
+
dev: 0,
|
|
459
|
+
ino: 0,
|
|
460
|
+
mode: node?.mode ?? 0o100644,
|
|
461
|
+
nlink: 1,
|
|
462
|
+
uid: 0,
|
|
463
|
+
gid: 0,
|
|
464
|
+
rdev: 0,
|
|
465
|
+
size,
|
|
466
|
+
blksize: 4096,
|
|
467
|
+
blocks: Math.ceil(size / 512),
|
|
468
|
+
atime: node?.accessed ?? now,
|
|
469
|
+
mtime: node?.modified ?? now,
|
|
470
|
+
ctime: node?.created ?? now,
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Get file stats by path.
|
|
476
|
+
* Note: This implementation does not follow symlinks (same as lstat behavior).
|
|
477
|
+
* @param path - Absolute path to the file or directory
|
|
478
|
+
* @returns File stats structure
|
|
479
|
+
* @throws {NodeJS.ErrnoException} ENOENT if path does not exist
|
|
480
|
+
*/
|
|
481
|
+
lstat(path: string): FsStats {
|
|
482
|
+
this.log('lstat', path)
|
|
483
|
+
const node = this.inMemoryNodes.get(path)
|
|
484
|
+
|
|
485
|
+
if (!node) {
|
|
486
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, lstat '${path}'`)
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return {
|
|
490
|
+
dev: 0,
|
|
491
|
+
ino: 0,
|
|
492
|
+
mode: node.mode,
|
|
493
|
+
nlink: 1,
|
|
494
|
+
uid: 0,
|
|
495
|
+
gid: 0,
|
|
496
|
+
rdev: 0,
|
|
497
|
+
size: node.size,
|
|
498
|
+
blksize: 4096,
|
|
499
|
+
blocks: Math.ceil(node.size / 512),
|
|
500
|
+
atime: node.accessed,
|
|
501
|
+
mtime: node.modified,
|
|
502
|
+
ctime: node.created,
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Create a directory.
|
|
508
|
+
* @param path - Absolute path for the new directory
|
|
509
|
+
* @param options - Optional configuration
|
|
510
|
+
* @param options.recursive - If true, create parent directories as needed (like mkdir -p)
|
|
511
|
+
* @param options.mode - Directory permissions (default: 0o755)
|
|
512
|
+
* @throws {NodeJS.ErrnoException} ENOENT if parent directory does not exist (non-recursive)
|
|
513
|
+
* @throws {NodeJS.ErrnoException} EEXIST if directory already exists (non-recursive)
|
|
514
|
+
*/
|
|
515
|
+
mkdir(path: string, options?: { recursive?: boolean; mode?: number }): void {
|
|
516
|
+
this.log('mkdir', path, options)
|
|
517
|
+
const mode = options?.mode
|
|
518
|
+
|
|
519
|
+
if (options?.recursive) {
|
|
520
|
+
// Create all directories in the path
|
|
521
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
522
|
+
let currentPath = ''
|
|
523
|
+
for (let i = 0; i < parts.length; i++) {
|
|
524
|
+
currentPath += '/' + parts[i]
|
|
525
|
+
if (!this.inMemoryNodes.has(currentPath)) {
|
|
526
|
+
// Only apply custom mode to the final directory
|
|
527
|
+
const dirMode = i === parts.length - 1 ? mode : undefined
|
|
528
|
+
this.getOrCreateDir(currentPath, dirMode)
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
// Check parent exists
|
|
533
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
534
|
+
const parentPath = '/' + parts.slice(0, -1).join('/')
|
|
535
|
+
if (parts.length > 1 && !this.inMemoryNodes.has(parentPath)) {
|
|
536
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, mkdir '${path}'`)
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// Check if already exists
|
|
540
|
+
if (this.inMemoryNodes.has(path)) {
|
|
541
|
+
throw createFsError('EEXIST', `EEXIST: file already exists, mkdir '${path}'`)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
this.getOrCreateDir(path, mode)
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Open a file and return a file descriptor.
|
|
550
|
+
*
|
|
551
|
+
* Note: This method initiates async file opening but returns synchronously
|
|
552
|
+
* as required by PGLite's interface. The file is opened lazily - the async
|
|
553
|
+
* open operation runs in the background, and any errors are logged.
|
|
554
|
+
* Use syncToFs() to ensure all operations are complete.
|
|
555
|
+
*
|
|
556
|
+
* @param path - Absolute path to the file
|
|
557
|
+
* @param flags - Open mode: 'r' (read), 'w'/'w+' (write/create), 'a' (append), 'r+' (read/write)
|
|
558
|
+
* @param mode - File permissions when creating (default: 0o644)
|
|
559
|
+
* @returns File descriptor (integer >= 3)
|
|
560
|
+
* @throws {NodeJS.ErrnoException} ENOENT if file doesn't exist in read mode
|
|
561
|
+
*/
|
|
562
|
+
open(path: string, flags?: string, mode?: number): number {
|
|
563
|
+
this.log('open', path, flags, mode)
|
|
564
|
+
|
|
565
|
+
// Parse flags string to SQLITE open flags and internal mode flags
|
|
566
|
+
let openFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
|
|
567
|
+
let modeFlags = FILE_MODE_READ | FILE_MODE_WRITE
|
|
568
|
+
const isReadOnly = flags === 'r'
|
|
569
|
+
const requiresExisting = flags === 'r' || flags === 'r+'
|
|
570
|
+
|
|
571
|
+
if (flags === 'r') {
|
|
572
|
+
openFlags = SQLITE_OPEN_READONLY
|
|
573
|
+
modeFlags = FILE_MODE_READ
|
|
574
|
+
} else if (flags === 'w' || flags === 'w+') {
|
|
575
|
+
openFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
|
|
576
|
+
modeFlags = FILE_MODE_READ | FILE_MODE_WRITE
|
|
577
|
+
} else if (flags === 'a') {
|
|
578
|
+
openFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
|
|
579
|
+
modeFlags = FILE_MODE_WRITE
|
|
580
|
+
} else if (flags === 'r+') {
|
|
581
|
+
openFlags = SQLITE_OPEN_READWRITE
|
|
582
|
+
modeFlags = FILE_MODE_READ | FILE_MODE_WRITE
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Check if file exists for read modes
|
|
586
|
+
const existingNode = this.inMemoryNodes.get(path)
|
|
587
|
+
if (requiresExisting && !existingNode) {
|
|
588
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, open '${path}'`)
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// Ensure parent directory exists for write modes
|
|
592
|
+
if (!isReadOnly) {
|
|
593
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
594
|
+
if (parts.length > 1) {
|
|
595
|
+
const parentPath = '/' + parts.slice(0, -1).join('/')
|
|
596
|
+
if (!this.inMemoryNodes.has(parentPath)) {
|
|
597
|
+
this.mkdir(parentPath, { recursive: true })
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// Create DOVFS file handle
|
|
603
|
+
const file = new DOVFSFile(this.storage, path, openFlags)
|
|
604
|
+
|
|
605
|
+
// Assign file descriptor
|
|
606
|
+
const fd = this.nextFd++
|
|
607
|
+
this.files.set(fd, {
|
|
608
|
+
path,
|
|
609
|
+
file,
|
|
610
|
+
position: 0,
|
|
611
|
+
flags: openFlags,
|
|
612
|
+
modeFlags,
|
|
613
|
+
})
|
|
614
|
+
|
|
615
|
+
// Ensure node exists in memory with the provided mode
|
|
616
|
+
if (!existingNode) {
|
|
617
|
+
this.getOrCreateFile(path, undefined, mode)
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// Open the file asynchronously
|
|
621
|
+
// Note: PGLite expects synchronous return, so we fire-and-forget here.
|
|
622
|
+
// The file handle tracks its own open state.
|
|
623
|
+
void file.xOpen().catch((err: unknown) => {
|
|
624
|
+
this.log('Error opening file:', err)
|
|
625
|
+
})
|
|
626
|
+
|
|
627
|
+
return fd
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Read directory contents.
|
|
632
|
+
* @param path - Absolute path to the directory
|
|
633
|
+
* @returns Array of entry names (not full paths)
|
|
634
|
+
* @throws {NodeJS.ErrnoException} ENOENT if path does not exist
|
|
635
|
+
* @throws {NodeJS.ErrnoException} ENOTDIR if path is not a directory
|
|
636
|
+
*/
|
|
637
|
+
readdir(path: string): string[] {
|
|
638
|
+
this.log('readdir', path)
|
|
639
|
+
const node = this.inMemoryNodes.get(path)
|
|
640
|
+
|
|
641
|
+
if (!node) {
|
|
642
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, scandir '${path}'`)
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if (!node.isDirectory) {
|
|
646
|
+
throw createFsError('ENOTDIR', `ENOTDIR: not a directory, scandir '${path}'`)
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
return Array.from(node.children?.keys() ?? [])
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Read data from a file descriptor into a buffer.
|
|
654
|
+
* @param fd - Open file descriptor
|
|
655
|
+
* @param buffer - Buffer to read data into
|
|
656
|
+
* @param offset - Offset within buffer to start writing
|
|
657
|
+
* @param length - Maximum number of bytes to read
|
|
658
|
+
* @param position - File position to read from
|
|
659
|
+
* @returns Number of bytes actually read (0 at EOF)
|
|
660
|
+
* @throws {NodeJS.ErrnoException} EBADF if fd is not a valid open file descriptor
|
|
661
|
+
*/
|
|
662
|
+
read(
|
|
663
|
+
fd: number,
|
|
664
|
+
buffer: Uint8Array,
|
|
665
|
+
offset: number,
|
|
666
|
+
length: number,
|
|
667
|
+
position: number
|
|
668
|
+
): number {
|
|
669
|
+
this.log('read', fd, offset, length, position)
|
|
670
|
+
|
|
671
|
+
const openFile = this.files.get(fd)
|
|
672
|
+
if (!openFile) {
|
|
673
|
+
throw createFsError('EBADF', `EBADF: bad file descriptor, read '${fd}'`)
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// Use in-memory data if available
|
|
677
|
+
const node = this.inMemoryNodes.get(openFile.path)
|
|
678
|
+
if (node?.data) {
|
|
679
|
+
const start = position
|
|
680
|
+
const end = Math.min(start + length, node.data.length)
|
|
681
|
+
const bytesToRead = end - start
|
|
682
|
+
|
|
683
|
+
if (bytesToRead <= 0) return 0
|
|
684
|
+
|
|
685
|
+
buffer.set(node.data.subarray(start, end), offset)
|
|
686
|
+
return bytesToRead
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// No data in memory - return 0 (EOF)
|
|
690
|
+
return 0
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Rename a file or directory.
|
|
695
|
+
* Moves the entry from oldPath to newPath, updating all internal references.
|
|
696
|
+
* For directories, also updates all children paths recursively.
|
|
697
|
+
* @param oldPath - Current absolute path
|
|
698
|
+
* @param newPath - New absolute path
|
|
699
|
+
* @throws {FsError} ENOENT if oldPath does not exist
|
|
700
|
+
*/
|
|
701
|
+
rename(oldPath: string, newPath: string): void {
|
|
702
|
+
this.log('rename', oldPath, newPath)
|
|
703
|
+
|
|
704
|
+
const node = this.inMemoryNodes.get(oldPath)
|
|
705
|
+
if (!node) {
|
|
706
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, rename '${oldPath}' -> '${newPath}'`)
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// If destination exists, remove it first (overwrite behavior)
|
|
710
|
+
const existingDest = this.inMemoryNodes.get(newPath)
|
|
711
|
+
if (existingDest) {
|
|
712
|
+
if (existingDest.isDirectory) {
|
|
713
|
+
// Can only overwrite empty directories
|
|
714
|
+
if (existingDest.children && existingDest.children.size > 0) {
|
|
715
|
+
throw createFsError('ENOTEMPTY', `ENOTEMPTY: directory not empty, rename '${oldPath}' -> '${newPath}'`)
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
// Remove the destination
|
|
719
|
+
this.inMemoryNodes.delete(newPath)
|
|
720
|
+
const destParts = newPath.split('/').filter(p => p !== '')
|
|
721
|
+
const destParentPath = '/' + destParts.slice(0, -1).join('/')
|
|
722
|
+
const destParent = this.inMemoryNodes.get(destParentPath || '/')
|
|
723
|
+
if (destParent?.children) {
|
|
724
|
+
destParent.children.delete(destParts[destParts.length - 1])
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// Collect all nodes to rename (node + descendants for directories)
|
|
729
|
+
const nodesToRename: Array<{ oldPath: string; node: FileNode }> = []
|
|
730
|
+
|
|
731
|
+
const collectNodes = (currentPath: string, currentNode: FileNode): void => {
|
|
732
|
+
nodesToRename.push({ oldPath: currentPath, node: currentNode })
|
|
733
|
+
if (currentNode.isDirectory && currentNode.children) {
|
|
734
|
+
for (const [childName, childNode] of currentNode.children) {
|
|
735
|
+
const childOldPath = currentPath + '/' + childName
|
|
736
|
+
collectNodes(childOldPath, childNode)
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
collectNodes(oldPath, node)
|
|
741
|
+
|
|
742
|
+
// Remove from old parent's children first
|
|
743
|
+
const oldParts = oldPath.split('/').filter(p => p !== '')
|
|
744
|
+
const oldParentPath = '/' + oldParts.slice(0, -1).join('/')
|
|
745
|
+
const oldParent = this.inMemoryNodes.get(oldParentPath || '/')
|
|
746
|
+
if (oldParent?.children) {
|
|
747
|
+
oldParent.children.delete(oldParts[oldParts.length - 1])
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// Update all nodes with new paths
|
|
751
|
+
for (const { oldPath: nodeOldPath, node: n } of nodesToRename) {
|
|
752
|
+
this.inMemoryNodes.delete(nodeOldPath)
|
|
753
|
+
|
|
754
|
+
// Calculate new path by replacing oldPath prefix with newPath
|
|
755
|
+
const relativePath = nodeOldPath.slice(oldPath.length)
|
|
756
|
+
const nodeNewPath = newPath + relativePath
|
|
757
|
+
|
|
758
|
+
const newParts = nodeNewPath.split('/').filter(p => p !== '')
|
|
759
|
+
n.name = newParts[newParts.length - 1] || ''
|
|
760
|
+
n.path = nodeNewPath
|
|
761
|
+
|
|
762
|
+
this.inMemoryNodes.set(nodeNewPath, n)
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// Add to new parent's children
|
|
766
|
+
const parts = newPath.split('/').filter(p => p !== '')
|
|
767
|
+
const newParentPath = '/' + parts.slice(0, -1).join('/')
|
|
768
|
+
let newParent = this.inMemoryNodes.get(newParentPath || '/')
|
|
769
|
+
|
|
770
|
+
// Ensure new parent exists
|
|
771
|
+
if (!newParent && newParentPath !== '') {
|
|
772
|
+
this.mkdir(newParentPath, { recursive: true })
|
|
773
|
+
newParent = this.inMemoryNodes.get(newParentPath)
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
if (newParent?.children) {
|
|
777
|
+
newParent.children.set(node.name, node)
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Remove an empty directory.
|
|
783
|
+
* @param path - Absolute path to the directory
|
|
784
|
+
* @throws {FsError} ENOENT if path does not exist
|
|
785
|
+
* @throws {FsError} ENOTDIR if path is not a directory
|
|
786
|
+
* @throws {FsError} ENOTEMPTY if directory is not empty
|
|
787
|
+
* @throws {FsError} EINVAL if trying to remove root directory
|
|
788
|
+
*/
|
|
789
|
+
rmdir(path: string): void {
|
|
790
|
+
this.log('rmdir', path)
|
|
791
|
+
|
|
792
|
+
// Cannot remove root directory
|
|
793
|
+
if (path === '/') {
|
|
794
|
+
throw createFsError('EINVAL', `EINVAL: invalid argument, rmdir '${path}'`)
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
const node = this.inMemoryNodes.get(path)
|
|
798
|
+
if (!node) {
|
|
799
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, rmdir '${path}'`)
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if (!node.isDirectory) {
|
|
803
|
+
throw createFsError('ENOTDIR', `ENOTDIR: not a directory, rmdir '${path}'`)
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
if (node.children && node.children.size > 0) {
|
|
807
|
+
throw createFsError('ENOTEMPTY', `ENOTEMPTY: directory not empty, rmdir '${path}'`)
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// Remove from parent's children
|
|
811
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
812
|
+
const parentPath = '/' + parts.slice(0, -1).join('/')
|
|
813
|
+
const parent = this.inMemoryNodes.get(parentPath || '/')
|
|
814
|
+
if (parent?.children) {
|
|
815
|
+
parent.children.delete(node.name)
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
this.inMemoryNodes.delete(path)
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Truncate a file to a specified length.
|
|
823
|
+
* If length is less than current size, data is removed.
|
|
824
|
+
* If length is greater than current size, the file is extended with zeros.
|
|
825
|
+
* @param path - Absolute path to the file
|
|
826
|
+
* @param len - New file length in bytes
|
|
827
|
+
* @throws {FsError} ENOENT if path does not exist
|
|
828
|
+
* @throws {FsError} EISDIR if path is a directory
|
|
829
|
+
*/
|
|
830
|
+
truncate(path: string, len: number): void {
|
|
831
|
+
this.log('truncate', path, len)
|
|
832
|
+
|
|
833
|
+
const node = this.inMemoryNodes.get(path)
|
|
834
|
+
if (!node) {
|
|
835
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, truncate '${path}'`)
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
if (node.isDirectory) {
|
|
839
|
+
throw createFsError('EISDIR', `EISDIR: illegal operation on a directory, truncate '${path}'`)
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
if (node.data) {
|
|
843
|
+
if (len < node.data.length) {
|
|
844
|
+
// Shrink: create smaller array
|
|
845
|
+
node.data = node.data.slice(0, len)
|
|
846
|
+
} else if (len > node.data.length) {
|
|
847
|
+
// Grow: create larger array, copy existing data
|
|
848
|
+
const newData = new Uint8Array(len)
|
|
849
|
+
newData.set(node.data)
|
|
850
|
+
node.data = newData
|
|
851
|
+
}
|
|
852
|
+
node.size = len
|
|
853
|
+
} else {
|
|
854
|
+
// No existing data - create zero-filled array
|
|
855
|
+
node.data = new Uint8Array(len)
|
|
856
|
+
node.size = len
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
node.modified = Date.now()
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Remove a file.
|
|
864
|
+
* @param path - Absolute path to the file
|
|
865
|
+
* @throws {FsError} ENOENT if path does not exist
|
|
866
|
+
* @throws {FsError} EISDIR if path is a directory (use rmdir instead)
|
|
867
|
+
*/
|
|
868
|
+
unlink(path: string): void {
|
|
869
|
+
this.log('unlink', path)
|
|
870
|
+
|
|
871
|
+
const node = this.inMemoryNodes.get(path)
|
|
872
|
+
if (!node) {
|
|
873
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, unlink '${path}'`)
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
if (node.isDirectory) {
|
|
877
|
+
throw createFsError('EISDIR', `EISDIR: illegal operation on a directory, unlink '${path}'`)
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// Remove from parent's children
|
|
881
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
882
|
+
const parentPath = '/' + parts.slice(0, -1).join('/')
|
|
883
|
+
const parent = this.inMemoryNodes.get(parentPath || '/')
|
|
884
|
+
if (parent?.children) {
|
|
885
|
+
parent.children.delete(node.name)
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
this.inMemoryNodes.delete(path)
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Update file access and modification times.
|
|
893
|
+
* @param path - Absolute path to the file or directory
|
|
894
|
+
* @param atime - Access time in milliseconds since epoch
|
|
895
|
+
* @param mtime - Modification time in milliseconds since epoch
|
|
896
|
+
* @throws {FsError} ENOENT if path does not exist
|
|
897
|
+
*/
|
|
898
|
+
utimes(path: string, atime: number, mtime: number): void {
|
|
899
|
+
this.log('utimes', path, atime, mtime)
|
|
900
|
+
|
|
901
|
+
const node = this.inMemoryNodes.get(path)
|
|
902
|
+
if (!node) {
|
|
903
|
+
throw createFsError('ENOENT', `ENOENT: no such file or directory, utimes '${path}'`)
|
|
904
|
+
}
|
|
905
|
+
node.accessed = atime
|
|
906
|
+
node.modified = mtime
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Write a file directly.
|
|
911
|
+
* @param path - Absolute path to the file
|
|
912
|
+
* @param data - Data to write (string or Uint8Array)
|
|
913
|
+
* @param options - Optional configuration
|
|
914
|
+
* @param options.encoding - Text encoding (default: utf-8)
|
|
915
|
+
* @param options.mode - File permissions (default: 0o644)
|
|
916
|
+
* @param options.flag - Open flags (default: 'w')
|
|
917
|
+
*/
|
|
918
|
+
writeFile(
|
|
919
|
+
path: string,
|
|
920
|
+
data: string | Uint8Array,
|
|
921
|
+
options?: { encoding?: string; mode?: number; flag?: string }
|
|
922
|
+
): void {
|
|
923
|
+
this.log('writeFile', path, options)
|
|
924
|
+
|
|
925
|
+
// Ensure parent directory exists
|
|
926
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
927
|
+
if (parts.length > 1) {
|
|
928
|
+
const parentPath = '/' + parts.slice(0, -1).join('/')
|
|
929
|
+
if (!this.inMemoryNodes.has(parentPath)) {
|
|
930
|
+
this.mkdir(parentPath, { recursive: true })
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// Convert string to Uint8Array if needed
|
|
935
|
+
let bytes: Uint8Array
|
|
936
|
+
if (typeof data === 'string') {
|
|
937
|
+
bytes = new TextEncoder().encode(data)
|
|
938
|
+
} else {
|
|
939
|
+
bytes = data
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
this.getOrCreateFile(path, bytes, options?.mode)
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Write to a file descriptor.
|
|
947
|
+
* @param fd - Open file descriptor
|
|
948
|
+
* @param buffer - Buffer containing data to write
|
|
949
|
+
* @param offset - Offset within buffer to start reading
|
|
950
|
+
* @param length - Number of bytes to write
|
|
951
|
+
* @param position - File position to write at
|
|
952
|
+
* @returns Number of bytes written
|
|
953
|
+
* @throws {NodeJS.ErrnoException} EBADF if fd is invalid or opened read-only
|
|
954
|
+
*/
|
|
955
|
+
write(
|
|
956
|
+
fd: number,
|
|
957
|
+
buffer: Uint8Array,
|
|
958
|
+
offset: number,
|
|
959
|
+
length: number,
|
|
960
|
+
position: number
|
|
961
|
+
): number {
|
|
962
|
+
this.log('write', fd, offset, length, position)
|
|
963
|
+
|
|
964
|
+
const openFile = this.files.get(fd)
|
|
965
|
+
if (!openFile) {
|
|
966
|
+
throw createFsError('EBADF', `EBADF: bad file descriptor, write '${fd}'`)
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// Check if file was opened for writing
|
|
970
|
+
if (!(openFile.modeFlags & FILE_MODE_WRITE)) {
|
|
971
|
+
throw createFsError('EBADF', `EBADF: bad file descriptor (read-only), write '${fd}'`)
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// Get or create the node
|
|
975
|
+
let node = this.inMemoryNodes.get(openFile.path)
|
|
976
|
+
if (!node) {
|
|
977
|
+
node = this.getOrCreateFile(openFile.path)
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// Prepare the data to write
|
|
981
|
+
const dataToWrite = buffer.subarray(offset, offset + length)
|
|
982
|
+
|
|
983
|
+
// Expand or create data buffer if needed
|
|
984
|
+
const requiredSize = position + length
|
|
985
|
+
if (!node.data || node.data.length < requiredSize) {
|
|
986
|
+
const newData = new Uint8Array(requiredSize)
|
|
987
|
+
if (node.data) {
|
|
988
|
+
newData.set(node.data)
|
|
989
|
+
}
|
|
990
|
+
node.data = newData
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
// Write the data
|
|
994
|
+
node.data.set(dataToWrite, position)
|
|
995
|
+
node.size = Math.max(node.size, requiredSize)
|
|
996
|
+
node.modified = Date.now()
|
|
997
|
+
|
|
998
|
+
return length
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Sync all open files to storage
|
|
1003
|
+
* @throws If storage operations fail
|
|
1004
|
+
*/
|
|
1005
|
+
async syncToFs(relaxedDurability?: boolean): Promise<void> {
|
|
1006
|
+
this.log('syncToFs', relaxedDurability)
|
|
1007
|
+
|
|
1008
|
+
// Write all in-memory file data to DOVFS
|
|
1009
|
+
// Collect all errors and report them
|
|
1010
|
+
const errors: Error[] = []
|
|
1011
|
+
|
|
1012
|
+
for (const [path, node] of this.inMemoryNodes) {
|
|
1013
|
+
if (!node.isDirectory && node.data && node.data.length > 0) {
|
|
1014
|
+
try {
|
|
1015
|
+
const file = new DOVFSFile(
|
|
1016
|
+
this.storage,
|
|
1017
|
+
path,
|
|
1018
|
+
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
|
|
1019
|
+
)
|
|
1020
|
+
const result = await file.xOpen()
|
|
1021
|
+
if (result !== SQLITE_OK) {
|
|
1022
|
+
// xOpen failed - check for original error or create descriptive one
|
|
1023
|
+
if (file.lastError) {
|
|
1024
|
+
errors.push(file.lastError)
|
|
1025
|
+
} else {
|
|
1026
|
+
errors.push(new Error(`Failed to open file ${path}: SQLITE error ${result}`))
|
|
1027
|
+
}
|
|
1028
|
+
continue
|
|
1029
|
+
}
|
|
1030
|
+
const writeResult = await file.xWrite(node.data, 0)
|
|
1031
|
+
if (writeResult !== SQLITE_OK) {
|
|
1032
|
+
if (file.lastError) {
|
|
1033
|
+
errors.push(file.lastError)
|
|
1034
|
+
} else {
|
|
1035
|
+
errors.push(new Error(`Failed to write file ${path}: SQLITE error ${writeResult}`))
|
|
1036
|
+
}
|
|
1037
|
+
continue
|
|
1038
|
+
}
|
|
1039
|
+
const syncResult = await file.xSync(0)
|
|
1040
|
+
if (syncResult !== SQLITE_OK) {
|
|
1041
|
+
if (file.lastError) {
|
|
1042
|
+
errors.push(file.lastError)
|
|
1043
|
+
} else {
|
|
1044
|
+
errors.push(new Error(`Failed to sync file ${path}: SQLITE error ${syncResult}`))
|
|
1045
|
+
}
|
|
1046
|
+
continue
|
|
1047
|
+
}
|
|
1048
|
+
await file.xClose()
|
|
1049
|
+
} catch (error) {
|
|
1050
|
+
errors.push(error instanceof Error ? error : new Error(String(error)))
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
// If any errors occurred, throw the first one
|
|
1056
|
+
if (errors.length > 0) {
|
|
1057
|
+
throw errors[0]
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* Initial sync from storage
|
|
1063
|
+
*/
|
|
1064
|
+
async initialSyncFs(): Promise<void> {
|
|
1065
|
+
this.log('initialSyncFs')
|
|
1066
|
+
|
|
1067
|
+
// Load existing files from DOVFS
|
|
1068
|
+
const files = await this.dovfs.listFiles()
|
|
1069
|
+
for (const path of files) {
|
|
1070
|
+
const info = await this.dovfs.getFileInfo(path)
|
|
1071
|
+
if (info) {
|
|
1072
|
+
// Create directory structure
|
|
1073
|
+
const parts = path.split('/').filter(p => p !== '')
|
|
1074
|
+
let currentPath = ''
|
|
1075
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
1076
|
+
currentPath += '/' + parts[i]
|
|
1077
|
+
if (!this.inMemoryNodes.has(currentPath)) {
|
|
1078
|
+
this.getOrCreateDir(currentPath)
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// Load file data
|
|
1083
|
+
const file = new DOVFSFile(this.storage, path, SQLITE_OPEN_READONLY)
|
|
1084
|
+
const result = await file.xOpen()
|
|
1085
|
+
if (result === SQLITE_OK && info.size > 0) {
|
|
1086
|
+
const data = new Uint8Array(info.size)
|
|
1087
|
+
await file.xRead(data, 0)
|
|
1088
|
+
await file.xClose()
|
|
1089
|
+
this.getOrCreateFile(path, data)
|
|
1090
|
+
} else {
|
|
1091
|
+
this.getOrCreateFile(path, new Uint8Array(0))
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Close the filesystem
|
|
1099
|
+
*/
|
|
1100
|
+
async closeFs(): Promise<void> {
|
|
1101
|
+
this.log('closeFs')
|
|
1102
|
+
|
|
1103
|
+
// Close all open files
|
|
1104
|
+
for (const [fd] of this.files) {
|
|
1105
|
+
this.close(fd)
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// Final sync
|
|
1109
|
+
await this.syncToFs()
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Create a DOVFSAdapter instance
|
|
1115
|
+
*/
|
|
1116
|
+
export function createDOVFSAdapter(
|
|
1117
|
+
storage: DOVFSStorage,
|
|
1118
|
+
dataDir?: string,
|
|
1119
|
+
options?: { debug?: boolean }
|
|
1120
|
+
): DOVFSAdapter {
|
|
1121
|
+
return new DOVFSAdapter(storage, dataDir, options)
|
|
1122
|
+
}
|