@gscdump/engine 1.4.0 → 1.4.2

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.
Files changed (366) hide show
  1. package/dist/adapters/duckdb-node.d.mts +7 -0
  2. package/dist/adapters/duckdb-node.mjs +94 -0
  3. package/dist/adapters/filesystem.d.mts +1 -1
  4. package/dist/adapters/filesystem.mjs +1 -1
  5. package/dist/adapters/hyparquet.d.mts +4 -3
  6. package/dist/adapters/hyparquet.mjs +7 -3
  7. package/dist/adapters/node-harness.d.mts +38 -0
  8. package/dist/adapters/node-harness.mjs +47 -0
  9. package/dist/adapters/node.d.mts +4 -100
  10. package/dist/adapters/node.mjs +4 -240
  11. package/dist/adapters/parquet-attach.d.mts +23 -0
  12. package/dist/adapters/parquet-attach.mjs +21 -0
  13. package/dist/adapters/r2-manifest.d.mts +82 -0
  14. package/dist/adapters/r2-manifest.mjs +364 -0
  15. package/dist/adapters/r2.d.mts +1 -1
  16. package/dist/adapters/read-optional.mjs +15 -0
  17. package/dist/adapters/snapshot-attach.d.mts +38 -0
  18. package/dist/adapters/snapshot-attach.mjs +85 -0
  19. package/dist/analysis-types.d.mts +56 -1
  20. package/dist/analyzer/define.d.mts +48 -0
  21. package/dist/analyzer/define.mjs +60 -0
  22. package/dist/analyzer/dispatch.d.mts +17 -0
  23. package/dist/analyzer/index.d.mts +4 -14
  24. package/dist/analyzer/index.mjs +4 -112
  25. package/dist/analyzer/registry.d.mts +33 -0
  26. package/dist/analyzer/registry.mjs +49 -0
  27. package/dist/analyzer/types.d.mts +95 -0
  28. package/dist/analyzer/types.mjs +5 -0
  29. package/dist/coerce.d.mts +4 -0
  30. package/dist/compaction.d.mts +14 -0
  31. package/dist/{_chunks/parquet-plan.mjs → compaction.mjs} +2 -138
  32. package/dist/contracts.d.mts +1 -2
  33. package/dist/{_chunks/schema.d.mts → drizzle-schema.d.mts} +152 -184
  34. package/dist/{_chunks/schema.mjs → drizzle-schema.mjs} +6 -78
  35. package/dist/{_chunks/snapshot.d.mts → duckdb.d.mts} +1 -14
  36. package/dist/duckdb.mjs +207 -0
  37. package/dist/engine.d.mts +4 -0
  38. package/dist/engine.mjs +385 -0
  39. package/dist/entities.d.mts +3 -52
  40. package/dist/entities.mjs +867 -2
  41. package/dist/errors.d.mts +114 -1
  42. package/dist/gc.mjs +92 -0
  43. package/dist/iceberg/append-sink.d.mts +14 -0
  44. package/dist/iceberg/append-sink.mjs +142 -0
  45. package/dist/iceberg/catalog.d.mts +71 -0
  46. package/dist/iceberg/catalog.mjs +109 -0
  47. package/dist/iceberg/index.d.mts +4 -13
  48. package/dist/iceberg/index.mjs +3 -244
  49. package/dist/iceberg/overwrite-writer.d.mts +161 -0
  50. package/dist/iceberg/overwrite-writer.mjs +102 -0
  51. package/dist/iceberg/pyiceberg-runtime.mjs +34 -0
  52. package/dist/iceberg/schema.d.mts +69 -0
  53. package/dist/{_chunks/schema2.mjs → iceberg/schema.mjs} +3 -2
  54. package/dist/index.d.mts +14 -190
  55. package/dist/index.mjs +10 -645
  56. package/dist/ingest-accumulator.d.mts +1 -1
  57. package/dist/ingest.d.mts +1 -1
  58. package/dist/layout.d.mts +31 -0
  59. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.bitreader.mjs +88 -0
  60. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.blocks.mjs +120 -0
  61. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.context.mjs +1805 -0
  62. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.contextmap.mjs +49 -0
  63. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.dictionary.mjs +984 -0
  64. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.huffman.mjs +266 -0
  65. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.mjs +340 -0
  66. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.prefix.mjs +109 -0
  67. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.streams.mjs +21 -0
  68. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/brotli.transform.mjs +190 -0
  69. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/compressors.mjs +7 -0
  70. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/gzip.huffman.mjs +121 -0
  71. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/gzip.mjs +176 -0
  72. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/index.mjs +7 -0
  73. package/dist/node_modules/.pnpm/hyparquet-compressors@1.1.1/node_modules/hyparquet-compressors/src/lz4.mjs +52 -0
  74. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/bloom.mjs +93 -0
  75. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/bytewriter.mjs +91 -0
  76. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/column.mjs +186 -0
  77. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/datapage.mjs +113 -0
  78. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/delta.mjs +111 -0
  79. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/dictionary.mjs +99 -0
  80. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/dremel.mjs +116 -0
  81. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/encoding.mjs +51 -0
  82. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/geospatial.mjs +84 -0
  83. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/index.mjs +7 -0
  84. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/indexes.mjs +31 -0
  85. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/metadata.mjs +138 -0
  86. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/node.mjs +8 -0
  87. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/parquet-writer.mjs +139 -0
  88. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/plain.mjs +68 -0
  89. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/schema.mjs +254 -0
  90. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/snappy.mjs +125 -0
  91. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/splitstream.mjs +38 -0
  92. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/thrift.mjs +79 -0
  93. package/dist/{_chunks/libs/hyparquet-writer.d.mts → node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/types.d.mts} +2 -2
  94. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/unconvert.mjs +247 -0
  95. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/variant.mjs +321 -0
  96. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/wkb.mjs +79 -0
  97. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/write-rows.mjs +122 -0
  98. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/src/write.mjs +5 -0
  99. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/types/bytewriter.d.mts +1 -0
  100. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/types/index.d.mts +10 -0
  101. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/types/node.d.mts +3 -0
  102. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/types/parquet-writer.d.mts +2 -0
  103. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/types/schema.d.mts +2 -0
  104. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/types/wkb.d.mts +1 -0
  105. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/types/write-rows.d.mts +1 -0
  106. package/dist/node_modules/.pnpm/hyparquet-writer@0.16.1_patch_hash_7a5e451ac7634d7546ac56bcc5eadacf7715a6241640c2b5a5bc0cfc9763b8ec/node_modules/hyparquet-writer/types/write.d.mts +1 -0
  107. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/assemble.mjs +3 -0
  108. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/bloom.mjs +69 -0
  109. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/column.mjs +8 -0
  110. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/constants.mjs +80 -0
  111. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/convert.mjs +3 -0
  112. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/datapage.mjs +6 -0
  113. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/delta.mjs +2 -0
  114. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/encoding.mjs +2 -0
  115. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/filter.mjs +3 -0
  116. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/geoparquet.mjs +1 -0
  117. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/index.mjs +7 -0
  118. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/indexes.mjs +5 -0
  119. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/metadata.mjs +7 -0
  120. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/node.mjs +3 -0
  121. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/plain.mjs +1 -0
  122. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/plan.mjs +5 -0
  123. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/query.mjs +3 -0
  124. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/read.mjs +6 -0
  125. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/rowgroup.mjs +7 -0
  126. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/schema.mjs +54 -0
  127. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/snappy.mjs +1 -0
  128. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/thrift.mjs +1 -0
  129. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/types.d.mts +1 -0
  130. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/utils.mjs +19 -0
  131. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/variant.mjs +3 -0
  132. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/wkb.mjs +1 -0
  133. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/src/xxhash.mjs +68 -0
  134. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/types/index.d.mts +7 -0
  135. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/types/indexes.d.mts +1 -0
  136. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/types/metadata.d.mts +1 -0
  137. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/types/node.d.mts +2 -0
  138. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/types/query.d.mts +1 -0
  139. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/types/read.d.mts +1 -0
  140. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/types/snappy.d.mts +1 -0
  141. package/dist/node_modules/.pnpm/hyparquet@1.26.1/node_modules/hyparquet/types/utils.d.mts +1 -0
  142. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/assemble.mjs +144 -0
  143. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/bloom.mjs +124 -0
  144. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/column.mjs +127 -0
  145. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/constants.mjs +75 -0
  146. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/convert.mjs +118 -0
  147. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/datapage.mjs +144 -0
  148. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/delta.mjs +65 -0
  149. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/encoding.mjs +76 -0
  150. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/filter.mjs +98 -0
  151. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/geoparquet.mjs +24 -0
  152. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/index.mjs +7 -0
  153. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/indexes.mjs +16 -0
  154. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/metadata.mjs +235 -0
  155. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/node.mjs +7 -0
  156. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/plain.mjs +78 -0
  157. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/plan.mjs +147 -0
  158. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/query.mjs +3 -0
  159. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/read.mjs +106 -0
  160. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/rowgroup.mjs +154 -0
  161. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/schema.mjs +75 -0
  162. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/snappy.mjs +70 -0
  163. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/thrift.mjs +86 -0
  164. package/dist/{_chunks/libs/hyparquet.d.mts → node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/types.d.mts} +6 -8
  165. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/utils.mjs +31 -0
  166. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/variant.mjs +225 -0
  167. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/wkb.mjs +94 -0
  168. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/src/xxhash.mjs +68 -0
  169. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/types/index.d.mts +10 -0
  170. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/types/indexes.d.mts +1 -0
  171. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/types/metadata.d.mts +1 -0
  172. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/types/node.d.mts +3 -0
  173. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/types/query.d.mts +1 -0
  174. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/types/read.d.mts +1 -0
  175. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/types/snappy.d.mts +1 -0
  176. package/dist/node_modules/.pnpm/hyparquet@1.26.2/node_modules/hyparquet/types/utils.d.mts +1 -0
  177. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/avro/avro.metadata.mjs +1 -0
  178. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/avro/avro.read.mjs +4 -0
  179. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/avro/avro.write.mjs +2 -0
  180. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/catalog/file.mjs +1 -0
  181. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/catalog/loadTable.mjs +3 -0
  182. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/catalog/rest.mjs +73 -0
  183. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/create.mjs +67 -0
  184. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/delete.mjs +2 -0
  185. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/fetch.mjs +8 -0
  186. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/index.mjs +13 -0
  187. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/json.mjs +147 -0
  188. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/manifest.mjs +2 -0
  189. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/metadata.mjs +3 -0
  190. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/prune.mjs +4 -0
  191. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/puffin/deletion-vector.mjs +2 -0
  192. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/puffin/puffin.mjs +2 -0
  193. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/puffin/roaring.mjs +1 -0
  194. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/read.mjs +9 -0
  195. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/s3.mjs +3 -0
  196. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/schema.mjs +76 -0
  197. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/sigv4.mjs +2 -0
  198. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/sql/icebergDataSource.mjs +8 -0
  199. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/sql/icebergQuery.mjs +5 -0
  200. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/sql/whereFilter.mjs +1 -0
  201. package/dist/{_chunks/libs/icebird.d.mts → node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/types.d.mts} +5 -33
  202. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/utils.mjs +8 -0
  203. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/commit.mjs +5 -0
  204. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/conversions.mjs +19 -0
  205. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/delete-file.mjs +3 -0
  206. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/geospatial.mjs +1 -0
  207. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/manifest-list.mjs +2 -0
  208. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/manifest.mjs +3 -0
  209. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/parquet.mjs +5 -0
  210. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/partition.mjs +75 -0
  211. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/rewrite.mjs +10 -0
  212. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/serde.mjs +2 -0
  213. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/snapshot.mjs +5 -0
  214. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/sort.mjs +3 -0
  215. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/stage-deletion-vector.mjs +11 -0
  216. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/stage-position-delete.mjs +8 -0
  217. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/stage.mjs +10 -0
  218. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/stats.mjs +4 -0
  219. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/transform.mjs +60 -0
  220. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/src/write/write.mjs +45 -0
  221. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/catalog/file.d.mts +1 -0
  222. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/catalog/rest.d.mts +1 -0
  223. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/create.d.mts +1 -0
  224. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/fetch.d.mts +1 -0
  225. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/index.d.mts +13 -0
  226. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/manifest.d.mts +1 -0
  227. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/metadata.d.mts +1 -0
  228. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/read.d.mts +2 -0
  229. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/s3.d.mts +1 -0
  230. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/sql/icebergDataSource.d.mts +2 -0
  231. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/sql/icebergQuery.d.mts +2 -0
  232. package/dist/node_modules/.pnpm/icebird@0.8.15_patch_hash_d1902372376af18885e7c7dce807f1ecab86c2f86a9d1ff65d51e3b63b64b057/node_modules/icebird/types/write/write.d.mts +32 -0
  233. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/ast.d.mts +1 -0
  234. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/backend/dataSource.mjs +1 -0
  235. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/accumulator.mjs +2 -0
  236. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/aggregates.mjs +10 -0
  237. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/execute.mjs +15 -0
  238. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/join.mjs +5 -0
  239. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/scanColumn.mjs +1 -0
  240. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/sort.mjs +5 -0
  241. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/streamingAggregate.mjs +9 -0
  242. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/utils.mjs +1 -0
  243. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/window.mjs +5 -0
  244. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/execute/yield.mjs +17 -0
  245. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/expression/alias.mjs +1 -0
  246. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/expression/binary.mjs +1 -0
  247. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/expression/date.mjs +1 -0
  248. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/expression/evaluate.mjs +15 -0
  249. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/expression/math.mjs +1 -0
  250. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/expression/regexp.mjs +2 -0
  251. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/expression/strings.mjs +3 -0
  252. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/index.d.mts +1 -0
  253. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/index.mjs +9 -0
  254. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/expression.mjs +6 -0
  255. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/extractTables.mjs +1 -0
  256. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/functions.mjs +5 -0
  257. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/joins.mjs +7 -0
  258. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/parse.mjs +10 -0
  259. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/primary.mjs +8 -0
  260. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/state.mjs +2 -0
  261. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/tokenize.mjs +3 -0
  262. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/parse/types.d.mts +1 -0
  263. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/plan/columns.mjs +3 -0
  264. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/plan/plan.mjs +7 -0
  265. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/plan/types.d.mts +1 -0
  266. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/spatial/bbox.mjs +2 -0
  267. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/spatial/equality.mjs +2 -0
  268. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/spatial/operations.mjs +5 -0
  269. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/spatial/pointRelations.mjs +2 -0
  270. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/spatial/primitives.mjs +2 -0
  271. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/spatial/segments.mjs +2 -0
  272. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/spatial/spatial.mjs +6 -0
  273. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/spatial/wkt.mjs +1 -0
  274. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/types.d.mts +3 -0
  275. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/validation/aggregates.mjs +3 -0
  276. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/validation/executionErrors.mjs +2 -0
  277. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/validation/functions.mjs +2 -0
  278. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/validation/keywords.mjs +1 -0
  279. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/validation/parseErrors.mjs +2 -0
  280. package/dist/node_modules/.pnpm/squirreling@0.15.0/node_modules/squirreling/src/validation/tables.mjs +2 -0
  281. package/dist/parquet-plan.d.mts +15 -0
  282. package/dist/parquet-plan.mjs +139 -0
  283. package/dist/parquet-pushdown.mjs +58 -0
  284. package/dist/period/index.d.mts +52 -1
  285. package/dist/planner.d.mts +2 -14
  286. package/dist/planner.mjs +2 -1
  287. package/dist/profile.d.mts +21 -0
  288. package/dist/profile.mjs +27 -0
  289. package/dist/query-dim.d.mts +54 -0
  290. package/dist/query-dim.mjs +91 -0
  291. package/dist/report/define.d.mts +8 -0
  292. package/dist/report/define.mjs +15 -0
  293. package/dist/report/hash.d.mts +13 -0
  294. package/dist/report/hash.mjs +29 -0
  295. package/dist/report/index.d.mts +4 -170
  296. package/dist/report/index.mjs +3 -55
  297. package/dist/report/registry.d.mts +18 -0
  298. package/dist/report/registry.mjs +14 -0
  299. package/dist/report/types.d.mts +139 -0
  300. package/dist/resolver/adapter.d.mts +13 -0
  301. package/dist/resolver/adapter.mjs +27 -0
  302. package/dist/resolver/canonical-source.d.mts +5 -0
  303. package/dist/resolver/canonical-source.mjs +14 -0
  304. package/dist/resolver/compile.d.mts +15 -0
  305. package/dist/resolver/compile.mjs +396 -0
  306. package/dist/resolver/datasets.d.mts +16 -0
  307. package/dist/resolver/datasets.mjs +159 -0
  308. package/dist/resolver/extras-overlay.d.mts +37 -0
  309. package/dist/resolver/extras-overlay.mjs +17 -0
  310. package/dist/resolver/filter-utils.d.mts +10 -0
  311. package/dist/resolver/filter-utils.mjs +59 -0
  312. package/dist/resolver/fragments.d.mts +60 -0
  313. package/dist/resolver/fragments.mjs +206 -0
  314. package/dist/resolver/index.d.mts +11 -371
  315. package/dist/resolver/index.mjs +10 -1
  316. package/dist/resolver/pg-adapter.d.mts +56 -0
  317. package/dist/resolver/pg-adapter.mjs +112 -0
  318. package/dist/resolver/run-query.d.mts +172 -0
  319. package/dist/resolver/run-query.mjs +241 -0
  320. package/dist/resolver/schema-drift.d.mts +15 -0
  321. package/dist/resolver/schema-drift.mjs +12 -0
  322. package/dist/rollups.d.mts +4 -4
  323. package/dist/rollups.mjs +3 -2
  324. package/dist/schedule.mjs +100 -0
  325. package/dist/schema.d.mts +34 -1
  326. package/dist/schema.mjs +78 -1
  327. package/dist/sink-node.d.mts +1 -159
  328. package/dist/sink-node.mjs +1 -133
  329. package/dist/sink.d.mts +125 -0
  330. package/dist/sinks/in-memory-sink.d.mts +25 -0
  331. package/dist/sinks/in-memory-sink.mjs +61 -0
  332. package/dist/sinks/index.d.mts +2 -0
  333. package/dist/sinks/index.mjs +2 -0
  334. package/dist/snapshot.d.mts +14 -0
  335. package/dist/source/attached-table.d.mts +45 -0
  336. package/dist/source/attached-table.mjs +55 -0
  337. package/dist/source/create-sql-query-source.d.mts +24 -0
  338. package/dist/source/create-sql-query-source.mjs +28 -0
  339. package/dist/source/index.d.mts +6 -66
  340. package/dist/source/index.mjs +9 -82
  341. package/dist/source/source-types.d.mts +49 -0
  342. package/dist/{_chunks/storage.d.mts → storage.d.mts} +4 -14
  343. package/dist/sync-config.d.mts +36 -0
  344. package/dist/sync-config.mjs +98 -0
  345. package/dist/vendor/hysnappy-purejs.mjs +12 -1
  346. package/package.json +9 -4
  347. package/dist/_chunks/analysis-types.d.mts +0 -57
  348. package/dist/_chunks/contracts.d.mts +0 -1
  349. package/dist/_chunks/engine.mjs +0 -731
  350. package/dist/_chunks/entities.mjs +0 -967
  351. package/dist/_chunks/errors.d.mts +0 -115
  352. package/dist/_chunks/index.d.mts +0 -53
  353. package/dist/_chunks/libs/hyparquet-compressors.mjs +0 -2796
  354. package/dist/_chunks/libs/hyparquet-writer.mjs +0 -2524
  355. package/dist/_chunks/libs/hyparquet.mjs +0 -2596
  356. package/dist/_chunks/libs/icebird.mjs +0 -564
  357. package/dist/_chunks/registry.d.mts +0 -213
  358. package/dist/_chunks/resolver.mjs +0 -1220
  359. package/dist/_chunks/sink.d.mts +0 -257
  360. /package/dist/{_chunks → analyzer}/dispatch.mjs +0 -0
  361. /package/dist/{_chunks/coerce.mjs → coerce.mjs} +0 -0
  362. /package/dist/{_chunks/layout.mjs → layout.mjs} +0 -0
  363. /package/dist/{_chunks/manifest-store-utils.mjs → manifest-store-utils.mjs} +0 -0
  364. /package/dist/{_chunks/libs/fzstd.mjs → node_modules/.pnpm/fzstd@0.1.1/node_modules/fzstd/esm/index.mjs} +0 -0
  365. /package/dist/{_chunks → resolver}/types.d.mts +0 -0
  366. /package/dist/{_chunks/schedule.d.mts → schedule.d.mts} +0 -0
@@ -1,731 +0,0 @@
1
- import { dayPartition, hourPartition, inferSearchType, objectKey, tenantPrefix } from "./layout.mjs";
2
- import { coerceRows } from "./coerce.mjs";
3
- import { SCHEMAS, TABLE_METADATA, currentSchemaVersion, dateColumnsFor, dedupeByNaturalKey } from "./schema.mjs";
4
- import { compactTieredImpl, compileLogicalQueryPlan, dedupeOverlappingTiers, splitOverlappingTiers, substituteNamedFiles } from "./parquet-plan.mjs";
5
- import { dateReplaceClause as dateReplaceClause$1 } from "../sql-fragments.mjs";
6
- import { sqlEscape } from "../sql-bind.mjs";
7
- import { encodeJsonBigintSafe } from "@gscdump/lakehouse/bigint";
8
- import { buildLogicalPlan } from "gscdump/query/plan";
9
- import { normalizeUrl } from "gscdump/normalize";
10
- const DEFAULT_BUFFER_READ_CONCURRENCY = 16;
11
- const MAX_BUFFER_READ_CONCURRENCY = 64;
12
- function bufferReadConcurrency(value, fileCount) {
13
- return Math.max(1, Math.min(fileCount || 1, typeof value === "number" && Number.isFinite(value) ? Math.floor(value) : DEFAULT_BUFFER_READ_CONCURRENCY, MAX_BUFFER_READ_CONCURRENCY));
14
- }
15
- async function registerBufferedFiles(db, files, dataSource, registered, signal, maxConcurrency) {
16
- const batchSize = bufferReadConcurrency(maxConcurrency, files.length);
17
- for (let i = 0; i < files.length; i += batchSize) {
18
- signal?.throwIfAborted();
19
- const batch = files.slice(i, i + batchSize);
20
- const buffers = await Promise.all(batch.map((file) => dataSource.read(file.key, void 0, signal)));
21
- for (let j = 0; j < batch.length; j++) {
22
- signal?.throwIfAborted();
23
- const file = batch[j];
24
- await db.registerFileBuffer(file.name, buffers[j]);
25
- registered.push(file.name);
26
- }
27
- }
28
- }
29
- async function encodeBytes(db, table, rows) {
30
- const inName = db.makeTempPath("json");
31
- const outName = db.makeTempPath("parquet");
32
- const jsonBytes = encodeJsonBigintSafe(coerceRows(rows));
33
- const registered = [];
34
- await db.registerFileBuffer(inName, jsonBytes);
35
- registered.push(inName);
36
- try {
37
- const sql = rows.length === 0 ? `COPY (SELECT * FROM ${emptyTableSchema(table)} WHERE FALSE) TO '${sqlEscape(outName)}' (FORMAT PARQUET, COMPRESSION ZSTD)` : `COPY (SELECT * FROM read_json_auto('${sqlEscape(inName)}', format='array', columns=${columnsJson(table)})) TO '${sqlEscape(outName)}' (FORMAT PARQUET, COMPRESSION ZSTD)`;
38
- await db.query(sql);
39
- registered.push(outName);
40
- return await db.copyFileToBuffer(outName);
41
- } finally {
42
- await db.dropFiles(registered);
43
- }
44
- }
45
- async function decodeBytes(db, bytes, table) {
46
- const name = db.makeTempPath("parquet");
47
- await db.registerFileBuffer(name, bytes);
48
- try {
49
- return await db.query(`SELECT * ${dateReplaceClause(table)} FROM read_parquet('${sqlEscape(name)}')`);
50
- } finally {
51
- await db.dropFiles([name]);
52
- }
53
- }
54
- function createDuckDBCodec(factory, options = {}) {
55
- return {
56
- async writeRows(ctx, rows, key, dataSource) {
57
- const bytes = await encodeBytes(await factory.getDuckDB(), ctx.table, rows);
58
- await dataSource.write(key, bytes);
59
- return {
60
- bytes: bytes.byteLength,
61
- rowCount: rows.length
62
- };
63
- },
64
- async readRows(ctx, key, dataSource) {
65
- return decodeBytes(await factory.getDuckDB(), await dataSource.read(key), ctx.table);
66
- },
67
- async compactRows(ctx, inputKeys, outputKey, dataSource) {
68
- const db = await factory.getDuckDB();
69
- if (inputKeys.length === 0) {
70
- const bytes = await encodeBytes(db, ctx.table, []);
71
- await dataSource.write(outputKey, bytes);
72
- return {
73
- bytes: bytes.byteLength,
74
- rowCount: 0
75
- };
76
- }
77
- const inputUris = inputKeys.map((k) => dataSource.uri?.(k));
78
- if (inputUris.every((u) => u !== void 0)) {
79
- const outName = db.makeTempPath("parquet");
80
- const fileList = inputUris.map((u) => `'${sqlEscape(u)}'`).join(", ");
81
- try {
82
- await db.query(`COPY (${dedupedMergeSql(ctx.table, fileList)}) TO '${sqlEscape(outName)}' (FORMAT PARQUET, COMPRESSION ZSTD)`);
83
- const bytes = await db.copyFileToBuffer(outName);
84
- const countRows = await db.query(`SELECT count(*)::BIGINT AS n FROM read_parquet('${sqlEscape(outName)}')`);
85
- const rowCount = Number(countRows[0]?.n ?? 0);
86
- await dataSource.write(outputKey, bytes);
87
- return {
88
- bytes: bytes.byteLength,
89
- rowCount
90
- };
91
- } finally {
92
- await db.dropFiles([outName]);
93
- }
94
- }
95
- const inNames = [];
96
- const outName = db.makeTempPath("parquet");
97
- const registered = [];
98
- const bufferedInputs = inputKeys.map((key) => {
99
- const name = db.makeTempPath("parquet");
100
- inNames.push(name);
101
- return {
102
- key,
103
- name
104
- };
105
- });
106
- try {
107
- await registerBufferedFiles(db, bufferedInputs, dataSource, registered, void 0, options.bufferReadConcurrency);
108
- const fileList = inNames.map((n) => `'${sqlEscape(n)}'`).join(", ");
109
- await db.query(`COPY (${dedupedMergeSql(ctx.table, fileList)}) TO '${sqlEscape(outName)}' (FORMAT PARQUET, COMPRESSION ZSTD)`);
110
- registered.push(outName);
111
- const bytes = await db.copyFileToBuffer(outName);
112
- const countRows = await db.query(`SELECT count(*)::BIGINT AS n FROM read_parquet('${sqlEscape(outName)}')`);
113
- const rowCount = Number(countRows[0]?.n ?? 0);
114
- await dataSource.write(outputKey, bytes);
115
- return {
116
- bytes: bytes.byteLength,
117
- rowCount
118
- };
119
- } finally {
120
- await db.dropFiles(registered);
121
- }
122
- }
123
- };
124
- }
125
- const quoteCol = (c) => `"${c.replace(/"/g, "\"\"")}"`;
126
- function dedupedMergeSql(table, fileListSql) {
127
- const base = `SELECT * FROM read_parquet([${fileListSql}], union_by_name = true)`;
128
- const sortKey = SCHEMAS[table].sortKey;
129
- const clusterKey = TABLE_METADATA[table].clusterKey;
130
- const dedup = sortKey.length === 0 ? base : `${base} QUALIFY row_number() OVER (PARTITION BY ${sortKey.map(quoteCol).join(", ")}) = 1`;
131
- if (clusterKey.length === 0) return dedup;
132
- return `${dedup} ORDER BY ${clusterKey.map(quoteCol).join(", ")}`;
133
- }
134
- function rewriteEmptyFileSets(sql, placeholders, defaultTable, placeholderTables) {
135
- let out = sql;
136
- for (const [name, keys] of Object.entries(placeholders)) {
137
- if (keys.length > 0) continue;
138
- const emptyFallback = `(SELECT * FROM ${emptyTableSchema(placeholderTables?.[name] ?? defaultTable)} WHERE FALSE)`;
139
- const pattern = new RegExp(`read_parquet\\(\\s*\\{\\{${name}\\}\\}\\s*(?:,\\s*union_by_name\\s*=\\s*true\\s*)?\\)`, "g");
140
- out = out.replace(pattern, emptyFallback);
141
- }
142
- return out;
143
- }
144
- function createDuckDBExecutor(factory, options = {}) {
145
- return { async execute({ sql, params, fileKeys, placeholderTables, dataSource, table, signal, profiler }) {
146
- signal?.throwIfAborted();
147
- const db = await factory.getDuckDB();
148
- const placeholders = {};
149
- const registered = [];
150
- const totalFiles = Object.values(fileKeys).reduce((n, keys) => n + keys.length, 0);
151
- const endRegister = profiler?.start("files.register", { files: totalFiles });
152
- try {
153
- const bufferedByName = /* @__PURE__ */ new Map();
154
- for (const [name, keys] of Object.entries(fileKeys)) {
155
- const resolved = [];
156
- for (let i = 0; i < keys.length; i++) {
157
- const key = keys[i];
158
- const uri = dataSource.uri?.(key);
159
- if (uri !== void 0) resolved.push(uri);
160
- else {
161
- if (!bufferedByName.has(key)) bufferedByName.set(key, {
162
- key,
163
- name: key
164
- });
165
- resolved.push(key);
166
- }
167
- }
168
- placeholders[name] = resolved;
169
- }
170
- await registerBufferedFiles(db, [...bufferedByName.values()], dataSource, registered, signal, options.bufferReadConcurrency);
171
- endRegister?.({ buffered: registered.length });
172
- signal?.throwIfAborted();
173
- const finalSql = substituteNamedFiles(rewriteEmptyFileSets(sql, placeholders, table, placeholderTables), placeholders);
174
- const endQuery = profiler?.start("query.run");
175
- const rows = await db.query(finalSql, params);
176
- endQuery?.({ rows: rows.length });
177
- return {
178
- rows,
179
- sql: finalSql
180
- };
181
- } finally {
182
- if (registered.length > 0) await db.dropFiles(registered);
183
- }
184
- } };
185
- }
186
- function emptyTableSchema(table) {
187
- return `(FROM (VALUES ${placeholderValues(table)}) t(${columnList(table)}))`;
188
- }
189
- function dateReplaceClause(table) {
190
- if (!table) return "";
191
- return dateReplaceClause$1(dateColumnsFor(table), "string");
192
- }
193
- function columnList(table) {
194
- return SCHEMAS[table].columns.map((c) => c.name).join(", ");
195
- }
196
- function placeholderValues(table) {
197
- return `(${SCHEMAS[table].columns.map((c) => defaultForType(c.type)).join(", ")})`;
198
- }
199
- function defaultForType(t) {
200
- if (t === "VARCHAR") return "''";
201
- if (t === "DATE") return "DATE '1970-01-01'";
202
- if (t === "INTEGER" || t === "BIGINT") return "0";
203
- if (t === "DOUBLE") return "CAST(0 AS DOUBLE)";
204
- return "NULL";
205
- }
206
- function columnsJson(table) {
207
- return `{${SCHEMAS[table].columns.map((c) => `'${c.name}': '${c.type}'`).join(", ")}}`;
208
- }
209
- const DEFAULT_HOURLY_RETENTION_MS = 2160 * 60 * 60 * 1e3;
210
- const VERSION_RE = /__v(\d+)\.parquet$/;
211
- function parseLockScope(key) {
212
- const match = VERSION_RE.exec(key);
213
- if (!match) return void 0;
214
- const parts = key.slice(0, match.index).split("/");
215
- if (parts.length < 4) return void 0;
216
- const userPart = parts[0];
217
- if (!userPart.startsWith("u_")) return void 0;
218
- const userId = userPart.slice(2);
219
- const partition = parts.slice(-2).join("/");
220
- const table = parts[parts.length - 3];
221
- return {
222
- userId,
223
- siteId: parts.length >= 5 ? parts.slice(1, -3).join("/") : void 0,
224
- table,
225
- partition
226
- };
227
- }
228
- async function gcOrphansImpl(deps, now, graceMs, opts = {}) {
229
- const cutoff = now - graceMs;
230
- const retired = await deps.manifestStore.listRetired(cutoff);
231
- if (retired.length > 0) {
232
- await deps.dataSource.delete(retired.map((e) => e.objectKey));
233
- await deps.manifestStore.delete(retired);
234
- }
235
- let hourlyDeleted = 0;
236
- if (opts.userId) {
237
- const hourlyCutoff = now - (opts.hourlyRetentionMs ?? DEFAULT_HOURLY_RETENTION_MS);
238
- const expiredHourly = (await deps.manifestStore.listAll({
239
- userId: opts.userId,
240
- siteId: opts.siteId
241
- })).filter((e) => e.partition.startsWith("hourly/") && e.createdAt < hourlyCutoff);
242
- if (expiredHourly.length > 0) {
243
- await deps.dataSource.delete(expiredHourly.map((e) => e.objectKey));
244
- await deps.manifestStore.delete(expiredHourly);
245
- hourlyDeleted = expiredHourly.length;
246
- }
247
- }
248
- let sweptOrphans = 0;
249
- if (opts.userId) {
250
- const prefix = tenantPrefix({
251
- userId: opts.userId,
252
- siteId: opts.siteId
253
- });
254
- const knownEntries = await deps.manifestStore.listAll({
255
- userId: opts.userId,
256
- siteId: opts.siteId
257
- });
258
- const knownSet = new Set(knownEntries.map((e) => e.objectKey));
259
- const orphans = [];
260
- const keyStream = deps.dataSource.streamList ? deps.dataSource.streamList(prefix) : async function* () {
261
- const all = await deps.dataSource.list(prefix);
262
- for (const k of all) yield k;
263
- }();
264
- for await (const key of keyStream) {
265
- if (knownSet.has(key)) continue;
266
- const match = VERSION_RE.exec(key);
267
- if (!match) continue;
268
- if (Number(match[1]) <= cutoff) orphans.push(key);
269
- }
270
- const byScope = /* @__PURE__ */ new Map();
271
- for (const key of orphans) {
272
- const scope = parseLockScope(key);
273
- if (!scope) continue;
274
- const sk = `${scope.userId}|${scope.siteId ?? ""}|${scope.table}|${scope.partition}`;
275
- const bucket = byScope.get(sk) ?? {
276
- scope,
277
- keys: []
278
- };
279
- bucket.keys.push(key);
280
- byScope.set(sk, bucket);
281
- }
282
- for (const { scope, keys } of byScope.values()) await deps.manifestStore.withLock(scope, async () => {
283
- const known = await deps.manifestStore.listAll({
284
- userId: scope.userId,
285
- siteId: scope.siteId,
286
- table: scope.table,
287
- partitions: [scope.partition]
288
- });
289
- const knownInScope = new Set(known.map((e) => e.objectKey));
290
- const stillOrphans = keys.filter((k) => !knownInScope.has(k));
291
- if (stillOrphans.length > 0) {
292
- await deps.dataSource.delete(stillOrphans);
293
- sweptOrphans += stillOrphans.length;
294
- }
295
- });
296
- }
297
- return { deleted: retired.length + sweptOrphans + hourlyDeleted };
298
- }
299
- const PUSHABLE_COLUMN = {
300
- country: "country",
301
- query: "query",
302
- searchAppearance: "searchAppearance"
303
- };
304
- function txLeaf(leaf, columns) {
305
- if (leaf.operator !== "equals") return null;
306
- const column = PUSHABLE_COLUMN[leaf.dimension];
307
- if (!column || !columns.has(column)) return null;
308
- return { [column]: { $eq: leaf.expression } };
309
- }
310
- function combineFilters(parts, groupType) {
311
- const first = parts[0];
312
- if (!first) return null;
313
- if (parts.length === 1) return first;
314
- return groupType === "or" ? { $or: [...parts] } : { $and: [...parts] };
315
- }
316
- function txExact(node, columns) {
317
- const groupType = node._groupType ?? "and";
318
- const leafParts = [];
319
- for (const leaf of node._filters) {
320
- const t = txLeaf(leaf, columns);
321
- if (!t) return null;
322
- leafParts.push(t);
323
- }
324
- if (groupType === "or") {
325
- if (node._nestedGroups?.length || leafParts.length === 0) return null;
326
- return combineFilters(leafParts, "or");
327
- }
328
- const parts = leafParts;
329
- for (const group of node._nestedGroups ?? []) {
330
- const t = txExact(group, columns);
331
- if (!t) return null;
332
- parts.push(t);
333
- }
334
- if (parts.length === 0) return null;
335
- return combineFilters(parts, "and");
336
- }
337
- function extractParquetPushdown(state, table) {
338
- const filter = state?.filter;
339
- const schema = SCHEMAS[table];
340
- if (!filter || !schema) return void 0;
341
- const columns = new Set(schema.columns.map((c) => c.name));
342
- if ((filter._groupType ?? "and") === "or") return txExact(filter, columns) ?? void 0;
343
- const parts = [];
344
- for (const leaf of filter._filters) {
345
- const t = txLeaf(leaf, columns);
346
- if (t) parts.push(t);
347
- }
348
- for (const group of filter._nestedGroups ?? []) {
349
- const t = txExact(group, columns);
350
- if (t) parts.push(t);
351
- }
352
- if (parts.length === 0) return void 0;
353
- return combineFilters(parts, "and") ?? void 0;
354
- }
355
- const URL_PURGE_TABLES = ["pages", "page_queries"];
356
- const MAX_DAY_BYTES = 100 * 1024 * 1024;
357
- const URL_COLUMNS = /* @__PURE__ */ new Set();
358
- for (const t of Object.keys(SCHEMAS)) for (const col of SCHEMAS[t].columns) if (col.name === "url") URL_COLUMNS.add(`${t}:url`);
359
- function normalizeRow(table, row) {
360
- if (!URL_COLUMNS.has(`${table}:url`)) return row;
361
- const url = row.url;
362
- if (typeof url !== "string") return row;
363
- const normalized = normalizeUrl(url);
364
- if (normalized === url) return row;
365
- return {
366
- ...row,
367
- url: normalized
368
- };
369
- }
370
- const DAILY_PARTITION_RE = /^daily\/(\d{4}-\d{2}-\d{2})$/;
371
- function queryRangeOf(partitions) {
372
- if (!partitions) return void 0;
373
- let min;
374
- let max;
375
- for (const p of partitions) {
376
- const m = DAILY_PARTITION_RE.exec(p);
377
- if (!m) continue;
378
- const d = m[1];
379
- if (min === void 0 || d < min) min = d;
380
- if (max === void 0 || d > max) max = d;
381
- }
382
- return min !== void 0 ? {
383
- start: min,
384
- end: max
385
- } : void 0;
386
- }
387
- function createStorageEngine(opts) {
388
- const { dataSource, manifestStore, codec, executor } = opts;
389
- const defaultNow = opts.now ?? (() => Date.now());
390
- async function writeDay(ctx, rows) {
391
- if (!ctx.date) throw new Error("writeDay requires ctx.date");
392
- const date = ctx.date;
393
- const now = (ctx.now ?? defaultNow)();
394
- const partition = dayPartition(date);
395
- const searchType = ctx.searchType;
396
- return manifestStore.withLock({
397
- userId: ctx.userId,
398
- siteId: ctx.siteId,
399
- table: ctx.table,
400
- partition
401
- }, async () => {
402
- const superseding = await manifestStore.listLive({
403
- userId: ctx.userId,
404
- siteId: ctx.siteId,
405
- table: ctx.table,
406
- partitions: [partition],
407
- searchType: inferSearchType({ searchType })
408
- });
409
- const normalizedRows = dedupeByNaturalKey(ctx.table, rows.map((r) => normalizeRow(ctx.table, r)));
410
- const key = objectKey(ctx, ctx.table, partition, now, searchType);
411
- const { bytes: writtenBytes, rowCount } = await codec.writeRows({ table: ctx.table }, normalizedRows, key, dataSource);
412
- let bytes = writtenBytes;
413
- if (bytes === 0 && rowCount > 0 && dataSource.head) {
414
- const probed = await dataSource.head(key);
415
- if (probed) bytes = probed.bytes;
416
- }
417
- if (bytes > 104857600) {
418
- const sizeError = /* @__PURE__ */ new Error(`writeDay payload ${bytes} bytes exceeds ${MAX_DAY_BYTES} hard ceiling (table=${ctx.table}, key=${key})`);
419
- try {
420
- await dataSource.delete([key]);
421
- } catch (deleteError) {
422
- throw new AggregateError([sizeError, deleteError], `${sizeError.message}; failed to delete oversized object`);
423
- }
424
- throw sizeError;
425
- }
426
- const entry = {
427
- userId: ctx.userId,
428
- siteId: ctx.siteId,
429
- table: ctx.table,
430
- partition,
431
- objectKey: key,
432
- rowCount,
433
- bytes,
434
- createdAt: now,
435
- schemaVersion: currentSchemaVersion(ctx.table),
436
- tier: "raw",
437
- ...searchType !== void 0 ? { searchType } : {}
438
- };
439
- await manifestStore.registerVersion(entry, superseding);
440
- await manifestStore.bumpWatermark({
441
- userId: ctx.userId,
442
- siteId: ctx.siteId,
443
- table: ctx.table,
444
- ...searchType !== void 0 ? { searchType } : {}
445
- }, date, now);
446
- });
447
- }
448
- async function writeHour(ctx, rows) {
449
- if (!ctx.date) throw new Error("writeHour requires ctx.date (the PT calendar day)");
450
- const date = ctx.date;
451
- const now = (ctx.now ?? defaultNow)();
452
- const partition = hourPartition(date);
453
- const searchType = ctx.searchType;
454
- return manifestStore.withLock({
455
- userId: ctx.userId,
456
- siteId: ctx.siteId,
457
- table: ctx.table,
458
- partition
459
- }, async () => {
460
- const live = await manifestStore.listLive({
461
- userId: ctx.userId,
462
- siteId: ctx.siteId,
463
- table: ctx.table,
464
- partitions: [partition],
465
- searchType: inferSearchType({ searchType })
466
- });
467
- const existing = [];
468
- for (const entry of live) {
469
- const rs = await codec.readRows({ table: ctx.table }, entry.objectKey, dataSource);
470
- existing.push(...rs);
471
- }
472
- const dedup = /* @__PURE__ */ new Map();
473
- for (const r of existing) {
474
- const k = `${String(r.url ?? "")}\0${String(r.hour ?? "")}`;
475
- dedup.set(k, r);
476
- }
477
- for (const r of rows) {
478
- const normalized = normalizeRow(ctx.table, r);
479
- const k = `${String(normalized.url ?? "")}\0${String(normalized.hour ?? "")}`;
480
- dedup.set(k, normalized);
481
- }
482
- const merged = [...dedup.values()];
483
- const key = objectKey(ctx, ctx.table, partition, now, searchType);
484
- const { bytes: writtenBytes, rowCount } = await codec.writeRows({ table: ctx.table }, merged, key, dataSource);
485
- let bytes = writtenBytes;
486
- if (bytes === 0 && rowCount > 0 && dataSource.head) {
487
- const probed = await dataSource.head(key);
488
- if (probed) bytes = probed.bytes;
489
- }
490
- if (bytes > 104857600) {
491
- const sizeError = /* @__PURE__ */ new Error(`writeHour payload ${bytes} bytes exceeds ${MAX_DAY_BYTES} hard ceiling (table=${ctx.table}, key=${key})`);
492
- try {
493
- await dataSource.delete([key]);
494
- } catch (deleteError) {
495
- throw new AggregateError([sizeError, deleteError], `${sizeError.message}; failed to delete oversized object`);
496
- }
497
- throw sizeError;
498
- }
499
- const entry = {
500
- userId: ctx.userId,
501
- siteId: ctx.siteId,
502
- table: ctx.table,
503
- partition,
504
- objectKey: key,
505
- rowCount,
506
- bytes,
507
- createdAt: now,
508
- schemaVersion: currentSchemaVersion(ctx.table),
509
- tier: "raw",
510
- ...searchType !== void 0 ? { searchType } : {}
511
- };
512
- await manifestStore.registerVersion(entry, live);
513
- await manifestStore.bumpWatermark({
514
- userId: ctx.userId,
515
- siteId: ctx.siteId,
516
- table: ctx.table,
517
- ...searchType !== void 0 ? { searchType } : {}
518
- }, date, now);
519
- });
520
- }
521
- async function runSQL(opts) {
522
- opts.signal?.throwIfAborted();
523
- const profiler = opts.profiler;
524
- const entries = Object.entries(opts.fileSets);
525
- const endList = profiler?.start("manifest.list", { fileSets: entries.length });
526
- const perSet = await Promise.all(entries.map(async ([name, ref]) => {
527
- if (ref.keys !== void 0) return [name, ref.keys];
528
- return [name, dedupeOverlappingTiers(await manifestStore.listLive({
529
- userId: opts.ctx.userId,
530
- siteId: opts.ctx.siteId,
531
- table: ref.table,
532
- partitions: ref.partitions,
533
- ...opts.searchType !== void 0 ? { searchType: opts.searchType } : {}
534
- }), queryRangeOf(ref.partitions)).map((e) => e.objectKey)];
535
- }));
536
- opts.signal?.throwIfAborted();
537
- const fileKeys = {};
538
- for (const [name, keys] of perSet) fileKeys[name] = keys;
539
- const uniqueKeys = [...new Set(perSet.flatMap(([, keys]) => keys))];
540
- endList?.({ files: uniqueKeys.length });
541
- let table = opts.table;
542
- if (!table) {
543
- if (new Set(entries.map(([, ref]) => ref.table)).size > 1) throw new Error("runSQL requires explicit ctx.table when fileSets reference multiple tables.");
544
- table = entries[0]?.[1].table;
545
- }
546
- if (!table) throw new Error("runSQL requires at least one fileSet or an explicit table");
547
- const placeholderTables = {};
548
- for (const [name, ref] of entries) placeholderTables[name] = ref.table;
549
- const endExec = profiler?.start("executor.execute", { files: uniqueKeys.length });
550
- const result = await executor.execute({
551
- sql: opts.sql,
552
- params: opts.params ?? [],
553
- fileKeys,
554
- placeholderTables,
555
- dataSource,
556
- table,
557
- signal: opts.signal,
558
- ...opts.pushdownFilters ? { pushdownFilters: opts.pushdownFilters } : {},
559
- ...profiler ? { profiler } : {}
560
- });
561
- endExec?.({ rows: result.rows.length });
562
- return {
563
- rows: result.rows,
564
- sql: result.sql,
565
- objectKeys: uniqueKeys
566
- };
567
- }
568
- async function query(ctx, state) {
569
- const plan = buildLogicalPlan(state, { regex: true });
570
- const table = ctx.table ?? plan.dataset;
571
- const resolved = compileLogicalQueryPlan(plan, table);
572
- const pushdown = extractParquetPushdown(state, table);
573
- return runSQL({
574
- ctx: {
575
- userId: ctx.userId,
576
- siteId: ctx.siteId
577
- },
578
- table,
579
- fileSets: { FILES: {
580
- table,
581
- partitions: resolved.partitions
582
- } },
583
- sql: resolved.sql,
584
- params: resolved.params,
585
- signal: ctx.signal,
586
- ...pushdown ? { pushdownFilters: { FILES: pushdown } } : {},
587
- ...ctx.searchType !== void 0 ? { searchType: ctx.searchType } : {},
588
- ...ctx.profiler ? { profiler: ctx.profiler } : {}
589
- });
590
- }
591
- async function compactTiered(ctx, thresholds) {
592
- return compactTieredImpl({
593
- dataSource,
594
- manifestStore,
595
- codec
596
- }, ctx, (ctx.now ?? defaultNow)(), thresholds);
597
- }
598
- async function reconcileSubsumed(ctx) {
599
- const { subsumed } = splitOverlappingTiers(await manifestStore.listLive({
600
- userId: ctx.userId,
601
- siteId: ctx.siteId,
602
- table: ctx.table
603
- }));
604
- if (subsumed.length === 0) return {
605
- retired: 0,
606
- partitions: []
607
- };
608
- await manifestStore.registerVersions([], subsumed);
609
- return {
610
- retired: subsumed.length,
611
- partitions: subsumed.map((e) => e.partition)
612
- };
613
- }
614
- async function gcOrphans(ctx, graceMs) {
615
- return gcOrphansImpl({
616
- dataSource,
617
- manifestStore
618
- }, (ctx.now ?? defaultNow)(), graceMs, {
619
- userId: ctx.userId,
620
- siteId: ctx.siteId,
621
- ...ctx.hourlyRetentionMs !== void 0 ? { hourlyRetentionMs: ctx.hourlyRetentionMs } : {}
622
- });
623
- }
624
- async function purgeTenant(ctx) {
625
- const prefix = tenantPrefix(ctx);
626
- const keys = [];
627
- const keyStream = dataSource.streamList ? dataSource.streamList(prefix) : async function* () {
628
- for (const k of await dataSource.list(prefix)) yield k;
629
- }();
630
- for await (const key of keyStream) keys.push(key);
631
- const manifestResult = await manifestStore.purgeTenant({
632
- userId: ctx.userId,
633
- siteId: ctx.siteId
634
- });
635
- if (keys.length > 0) await dataSource.delete(keys);
636
- return {
637
- userId: ctx.userId,
638
- siteId: ctx.siteId,
639
- prefix,
640
- objectsDeleted: keys.length,
641
- entriesRemoved: manifestResult.entriesRemoved,
642
- watermarksRemoved: manifestResult.watermarksRemoved,
643
- syncStatesRemoved: manifestResult.syncStatesRemoved,
644
- at: defaultNow()
645
- };
646
- }
647
- async function purgeUrls(ctx, urls) {
648
- const now = defaultNow();
649
- const urlSet = new Set(urls);
650
- let entriesRewritten = 0;
651
- let rowsRemoved = 0;
652
- let bytesAfter = 0;
653
- if (urlSet.size === 0) return {
654
- userId: ctx.userId,
655
- siteId: ctx.siteId,
656
- urlsRequested: 0,
657
- entriesRewritten: 0,
658
- rowsRemoved: 0,
659
- bytesAfter: 0,
660
- at: now
661
- };
662
- for (const table of URL_PURGE_TABLES) {
663
- const entries = await manifestStore.listLive({
664
- userId: ctx.userId,
665
- siteId: ctx.siteId,
666
- table
667
- });
668
- for (const entry of entries) await manifestStore.withLock({
669
- userId: entry.userId,
670
- siteId: entry.siteId,
671
- table,
672
- partition: entry.partition
673
- }, async () => {
674
- const rows = await codec.readRows({ table }, entry.objectKey, dataSource);
675
- const kept = rows.filter((r) => typeof r.url !== "string" || !urlSet.has(r.url));
676
- const removed = rows.length - kept.length;
677
- if (removed === 0) return;
678
- const searchType = entry.searchType;
679
- const newKey = objectKey({
680
- userId: entry.userId,
681
- siteId: entry.siteId
682
- }, table, entry.partition, now, searchType);
683
- const { bytes, rowCount } = await codec.writeRows({ table }, kept, newKey, dataSource);
684
- const newEntry = {
685
- userId: entry.userId,
686
- siteId: entry.siteId,
687
- table,
688
- partition: entry.partition,
689
- objectKey: newKey,
690
- rowCount,
691
- bytes,
692
- createdAt: now,
693
- schemaVersion: entry.schemaVersion ?? currentSchemaVersion(table),
694
- ...entry.tier !== void 0 ? { tier: entry.tier } : {},
695
- ...searchType !== void 0 ? { searchType } : {}
696
- };
697
- await manifestStore.registerVersion(newEntry, [entry]);
698
- entriesRewritten++;
699
- rowsRemoved += removed;
700
- bytesAfter += bytes;
701
- });
702
- }
703
- return {
704
- userId: ctx.userId,
705
- siteId: ctx.siteId,
706
- urlsRequested: urlSet.size,
707
- entriesRewritten,
708
- rowsRemoved,
709
- bytesAfter,
710
- at: now
711
- };
712
- }
713
- return {
714
- writeDay,
715
- writeHour,
716
- query,
717
- runSQL,
718
- compactTiered,
719
- reconcileSubsumed,
720
- gcOrphans,
721
- purgeTenant,
722
- purgeUrls,
723
- listLive: (filter) => manifestStore.listLive(filter),
724
- listAll: (filter) => manifestStore.listAll(filter),
725
- getWatermarks: (filter) => manifestStore.getWatermarks(filter),
726
- getSyncStates: (filter) => manifestStore.getSyncStates(filter),
727
- setSyncState: (scope, state, detail) => manifestStore.setSyncState(scope, state, detail),
728
- readObject: (key) => dataSource.read(key)
729
- };
730
- }
731
- export { MAX_DAY_BYTES, createDuckDBCodec, createDuckDBExecutor, createStorageEngine };