@delali/narsil 0.3.1-next.131 → 0.3.1-next.141

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 (139) hide show
  1. package/dist/adapters/filesystem.mjs +1 -1
  2. package/dist/adapters/indexeddb.mjs +1 -1
  3. package/dist/analysis-change-HQUT2Z3I.mjs +43 -0
  4. package/dist/analysis-change-entry-TZTG4AZB.mjs +1 -0
  5. package/dist/browser/analysis-change-JPV775LR.mjs +900 -0
  6. package/dist/browser/analysis-change-entry-7HR4LWL3.mjs +1 -0
  7. package/dist/browser/{chunk-UDGB2MWT.mjs → chunk-35B42UFM.mjs} +4 -0
  8. package/dist/browser/chunk-3ZBJYAS4.mjs +19 -0
  9. package/dist/browser/{chunk-2Y3CO4EQ.mjs → chunk-5DB2VDGI.mjs} +1149 -1853
  10. package/dist/browser/chunk-6RHTAVZX.mjs +656 -0
  11. package/dist/browser/chunk-CCOAOO73.mjs +86 -0
  12. package/dist/browser/{chunk-AIIJDWMG.mjs → chunk-D33A5VMU.mjs} +16 -16
  13. package/dist/browser/{chunk-VBBLTD7O.mjs → chunk-HKX2G6WH.mjs} +1520 -2159
  14. package/dist/browser/{chunk-NSCSR6MA.mjs → chunk-KTOK275N.mjs} +606 -830
  15. package/dist/browser/{chunk-D7WQF6DV.mjs → chunk-LVY2LI35.mjs} +2 -2
  16. package/dist/browser/chunk-MVM33ZUL.mjs +993 -0
  17. package/dist/browser/chunk-MWUK3DA5.mjs +2634 -0
  18. package/dist/browser/{chunk-VEGHFP2P.mjs → chunk-MZI3TEOW.mjs} +4 -2
  19. package/dist/browser/chunk-OIZS5KIX.mjs +6 -0
  20. package/dist/browser/chunk-R4WUDZQV.mjs +176 -0
  21. package/dist/browser/{chunk-M5UAAXGU.mjs → chunk-TCLEOZ4P.mjs} +3 -3
  22. package/dist/browser/chunk-VFYMPCOV.mjs +212 -0
  23. package/dist/browser/chunk-WCFCHIBB.mjs +177 -0
  24. package/dist/browser/chunk-XNWPP5NS.mjs +21 -0
  25. package/dist/browser/chunk-ZEV26AQ6.mjs +270 -0
  26. package/dist/browser/cold-module-MJMKNUYJ.mjs +745 -0
  27. package/dist/browser/{durability-wiring-FNZSRH4N.mjs → durability-wiring-SNOWIT6Z.mjs} +370 -95
  28. package/dist/browser/import-TLB2A5LJ.mjs +9 -0
  29. package/dist/browser/module-BUFNZMEU.mjs +12 -0
  30. package/dist/browser/{module-4HIMOQM5.mjs → module-BVP4TKZU.mjs} +397 -109
  31. package/dist/browser/{phrase-module-WESYVU7K.mjs → phrase-module-HGVBO24W.mjs} +1 -1
  32. package/dist/{restore-queue-JAMNRC6T.mjs → browser/restore-queue-ONYNYUDE.mjs} +8 -2
  33. package/dist/browser/{runtime-3X7ZJ5T3.mjs → runtime-VEUH674B.mjs} +2 -2
  34. package/dist/browser/{snapshot-V7VF6BN6.mjs → snapshot-QXBKHJAG.mjs} +135 -183
  35. package/dist/browser/{write-YIC2MKRY.mjs → write-WHFBDWQS.mjs} +64 -90
  36. package/dist/{capabilities-B6WxrWxt.d.ts → capabilities-BCdUwK_L.d.ts} +10 -3
  37. package/dist/chunk-46NZOPHS.mjs +21 -0
  38. package/dist/{chunk-JT3YZGCE.mjs → chunk-5WYVUPGD.mjs} +3 -188
  39. package/dist/chunk-6SNBQESJ.mjs +214 -0
  40. package/dist/{chunk-2C3WXBQS.mjs → chunk-74XB2SXI.mjs} +1 -1
  41. package/dist/chunk-7AUASRE7.mjs +653 -0
  42. package/dist/{chunk-NMXRXFGZ.mjs → chunk-AST3SHFA.mjs} +27 -25
  43. package/dist/chunk-BOJZGUS6.mjs +177 -0
  44. package/dist/{chunk-T4OFG4IQ.mjs → chunk-BRUUBXCB.mjs} +92 -17
  45. package/dist/{chunk-5LX6MOIB.mjs → chunk-C3YDYX6C.mjs} +1 -1
  46. package/dist/chunk-CZQ33DLW.mjs +78 -0
  47. package/dist/{chunk-4GDLFDPZ.mjs → chunk-DD2673TX.mjs} +3 -2
  48. package/dist/{chunk-EUCX5K74.mjs → chunk-DQNKVOJ2.mjs} +65 -65
  49. package/dist/{chunk-RNSC4NFI.mjs → chunk-EEBCDP36.mjs} +3 -1
  50. package/dist/chunk-FOCV4CBZ.mjs +87 -0
  51. package/dist/{chunk-HCGJKDZV.mjs → chunk-GLZHNSGB.mjs} +1 -1
  52. package/dist/chunk-GWOS5DYC.mjs +2637 -0
  53. package/dist/{chunk-PATMDIMN.mjs → chunk-HJJWY6PT.mjs} +1 -1
  54. package/dist/{chunk-CZ7ISLXA.mjs → chunk-HNHCNTVG.mjs} +4 -0
  55. package/dist/{chunk-Y2U5VVWX.mjs → chunk-ICW45TTU.mjs} +1 -1
  56. package/dist/{chunk-TGHNXN7W.mjs → chunk-IO5F7ZBE.mjs} +261 -948
  57. package/dist/{chunk-P36MUFEJ.mjs → chunk-JDDXV6UF.mjs} +2 -1
  58. package/dist/{chunk-7OIQ2SIO.mjs → chunk-KEIYVZUX.mjs} +5 -5
  59. package/dist/{chunk-PU6SKH7O.mjs → chunk-KGOXHLLZ.mjs} +7 -3
  60. package/dist/{chunk-WVRDRLIC.mjs → chunk-KZL72VTC.mjs} +70 -18
  61. package/dist/chunk-L76W3IZJ.mjs +193 -0
  62. package/dist/{chunk-2JWNJSNE.mjs → chunk-LA4WNDHL.mjs} +88 -801
  63. package/dist/{chunk-ZR4VM4A6.mjs → chunk-N37VMC62.mjs} +1 -18
  64. package/dist/{chunk-JJ6EUMXB.mjs → chunk-NJJCPFXN.mjs} +2 -2
  65. package/dist/chunk-NN33CZRE.mjs +86 -0
  66. package/dist/{chunk-2WBY4Y4M.mjs → chunk-NOT5QOHU.mjs} +1 -1
  67. package/dist/{chunk-D5TFRB5G.mjs → chunk-NPNK57CA.mjs} +1 -1
  68. package/dist/chunk-NRUXBYPH.mjs +121 -0
  69. package/dist/{chunk-6SSVIW7Y.mjs → chunk-O4LJQI4G.mjs} +31 -5
  70. package/dist/{chunk-UJWGQIXU.mjs → chunk-QHPYS427.mjs} +1 -0
  71. package/dist/{chunk-F6AAXI7T.mjs → chunk-RHKRTYGO.mjs} +13 -4
  72. package/dist/{chunk-2SEL6SBS.mjs → chunk-RKAVHNRW.mjs} +2 -2
  73. package/dist/{chunk-RCMNL7RI.mjs → chunk-SBMAWTRG.mjs} +41 -4
  74. package/dist/chunk-SRJBFG2T.mjs +881 -0
  75. package/dist/{chunk-X5CNUKD5.mjs → chunk-TNBIK2LQ.mjs} +1663 -1652
  76. package/dist/{chunk-NNO7CO3A.mjs → chunk-UIKN2OTQ.mjs} +1 -1
  77. package/dist/chunk-UUZCQQG2.mjs +209 -0
  78. package/dist/{chunk-6M6SDH3S.mjs → chunk-VEFN6X6Q.mjs} +8 -8
  79. package/dist/chunk-VJEGOELZ.mjs +177 -0
  80. package/dist/chunk-W2COJ5AH.mjs +148 -0
  81. package/dist/{chunk-RWESFSJI.mjs → chunk-WJGO5PGV.mjs} +317 -174
  82. package/dist/{chunk-7X5JST5L.mjs → chunk-WNBRW4Q2.mjs} +16 -2
  83. package/dist/{chunk-SZGRYEIC.mjs → chunk-XS2VM7UE.mjs} +3 -3
  84. package/dist/{chunk-Y4BVTQ53.mjs → chunk-XZ3SRNDJ.mjs} +25 -64
  85. package/dist/{chunk-K77FJXKS.mjs → chunk-YHUTF6EA.mjs} +474 -93
  86. package/dist/{chunk-OGLV4I3L.mjs → chunk-YLNSJQLX.mjs} +12 -7
  87. package/dist/{chunk-SOHMMNCH.mjs → chunk-Z4HFMYNX.mjs} +32 -27
  88. package/dist/{chunk-5W7AEVTH.mjs → chunk-ZMBFWQXN.mjs} +2 -2
  89. package/dist/{chunk-2MKX2SCO.mjs → chunk-ZPWS2SKJ.mjs} +297 -274
  90. package/dist/{chunk-7XY6VD7B.mjs → chunk-ZSWHPKGM.mjs} +1 -1
  91. package/dist/{client-gNAfaHcE.d.ts → client-B12YFALP.d.ts} +18 -3
  92. package/dist/client.d.ts +7 -7
  93. package/dist/client.mjs +11 -1
  94. package/dist/cold-module-4X7WJCFM.mjs +783 -0
  95. package/dist/{config-D1cDv3sE.d.ts → config-BhZxIeb1.d.ts} +10 -1
  96. package/dist/{config-CmYJO34X.d.ts → config-CIG5yDyg.d.ts} +2 -2
  97. package/dist/{direct-executor-HQ4QVDX7.mjs → direct-executor-7XOQ7VQP.mjs} +14 -14
  98. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  99. package/dist/distribution/coordinator/etcd.mjs +1 -1
  100. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  101. package/dist/distribution/transport/grpc.mjs +1 -1
  102. package/dist/distribution.d.ts +24 -8
  103. package/dist/distribution.mjs +982 -211
  104. package/dist/{durability-wiring-S7OX2MAI.mjs → durability-wiring-324D2DDD.mjs} +362 -94
  105. package/dist/embeddings/openai.mjs +2 -2
  106. package/dist/{engine-m_Ddr1bz.d.ts → engine-CtzbHOmG.d.ts} +64 -7
  107. package/dist/import-OOBUW3RR.mjs +44 -0
  108. package/dist/{index-HYnqS1SE.d.ts → index-DsEurhSl.d.ts} +1 -1
  109. package/dist/index.browser.mjs +5 -5
  110. package/dist/index.d.ts +6 -6
  111. package/dist/index.mjs +22 -22
  112. package/dist/{long-query-thread-BSL25PD6.mjs → long-query-thread-4SW7RWDE.mjs} +15 -15
  113. package/dist/{module-2E4XYSGT.mjs → module-DXSJ5LT2.mjs} +378 -87
  114. package/dist/module-IYPLWHGC.mjs +48 -0
  115. package/dist/paged-partition-archive-HFP45PLU.mjs +269 -0
  116. package/dist/partial-words.mjs +5 -5
  117. package/dist/pattern.mjs +3 -3
  118. package/dist/persistence/durability/checkpoint-worker.d.ts +16 -1
  119. package/dist/persistence/durability/checkpoint-worker.mjs +28 -26
  120. package/dist/{phrase-module-JERF2IDG.mjs → phrase-module-5QHBD2VJ.mjs} +1 -1
  121. package/dist/react.d.ts +9 -9
  122. package/dist/react.mjs +4 -0
  123. package/dist/{rerank-DMMT4FZA.mjs → rerank-KTLC3E6N.mjs} +5 -5
  124. package/dist/rerankers/http.mjs +2 -2
  125. package/dist/{browser/restore-queue-GEZ54CA5.mjs → restore-queue-FEYAC4SB.mjs} +8 -2
  126. package/dist/{runtime-7MLQ7J64.mjs → runtime-DYV75DCB.mjs} +6 -6
  127. package/dist/{schema-BTXbHCqA.d.ts → schema-B-Runv0n.d.ts} +7 -0
  128. package/dist/server.d.ts +12 -10
  129. package/dist/server.mjs +54 -21
  130. package/dist/{snapshot-DOQLGGEX.mjs → snapshot-CGM65VCD.mjs} +101 -197
  131. package/dist/synonyms.mjs +6 -4
  132. package/dist/{tasks-Co8HfRD7.d.ts → tasks-CjRJRGTb.d.ts} +26 -8
  133. package/dist/{thread-SKO7CN3R.mjs → thread-KGNAIKPD.mjs} +14 -14
  134. package/dist/vector/search-worker.d.ts +1 -1
  135. package/dist/vector/search-worker.mjs +6 -5
  136. package/dist/workers/entry.mjs +8 -8
  137. package/dist/{write-ZKR7SNRT.mjs → write-2DZPEQL2.mjs} +82 -107
  138. package/openapi.json +114 -6
  139. package/package.json +12 -8
@@ -1,8 +1,10 @@
1
- import { DEFAULT_PAGE_SIZE } from './chunk-UDGB2MWT.mjs';
1
+ import { DEFAULT_PAGE_SIZE } from './chunk-35B42UFM.mjs';
2
2
 
3
3
  // src/engine/constants.ts
4
4
  var MIN_DOCUMENTS_FOR_SEGMENTS = 64;
5
5
  var BATCH_CHUNK_SIZE = 1e3;
6
+ var ANALYSIS_HOLD_APPLY_INTERVAL_MS = 100;
7
+ var ANALYSIS_CHANGE_MEMBERS = ["language", "tokenizer", "stopWords"];
6
8
  var DEFAULT_LIMIT = DEFAULT_PAGE_SIZE;
7
9
  var DEFAULT_OFFSET = 0;
8
10
  var INDEX_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
@@ -27,4 +29,4 @@ var SUGGEST_OVERSAMPLE_FACTOR = 1.5;
27
29
  var SUGGEST_OVERSAMPLE_PADDING = 10;
28
30
  var MAX_SUGGEST_SCATTER_LIMIT = Math.ceil(MAX_SUGGEST_LIMIT * SUGGEST_OVERSAMPLE_FACTOR) + SUGGEST_OVERSAMPLE_PADDING;
29
31
 
30
- export { ABSOLUTE_WINDOWS_PATH_PATTERN, BATCH_CHUNK_SIZE, DEFAULT_LIMIT, DEFAULT_OFFSET, DEFAULT_SUGGEST_LIMIT, EXPORT_CHUNK_BYTES, FOREIGN_STATS_TTL_MS, HEAP_PRESSURE_REARM_FRACTION, HEAP_PRESSURE_WARNING_FRACTION, IMPORT_BATCH_DOCUMENTS, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, MAX_EXPORT_LINE_BYTES, MAX_IMPORT_REFUSALS_REPORTED, MAX_INDEX_CONFIGURATION_BYTES, MAX_INDEX_NAME_LENGTH, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, MAX_SWEEP_INTERVAL_MS, MIN_DOCUMENTS_FOR_SEGMENTS, MIN_SWEEP_INTERVAL_MS, MODULE_URL_SCHEME_PATTERN, STATISTICS_BROADCAST_INTERVAL_MS };
32
+ export { ABSOLUTE_WINDOWS_PATH_PATTERN, ANALYSIS_CHANGE_MEMBERS, ANALYSIS_HOLD_APPLY_INTERVAL_MS, BATCH_CHUNK_SIZE, DEFAULT_LIMIT, DEFAULT_OFFSET, DEFAULT_SUGGEST_LIMIT, EXPORT_CHUNK_BYTES, FOREIGN_STATS_TTL_MS, HEAP_PRESSURE_REARM_FRACTION, HEAP_PRESSURE_WARNING_FRACTION, IMPORT_BATCH_DOCUMENTS, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, MAX_EXPORT_LINE_BYTES, MAX_IMPORT_REFUSALS_REPORTED, MAX_INDEX_CONFIGURATION_BYTES, MAX_INDEX_NAME_LENGTH, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, MAX_SWEEP_INTERVAL_MS, MIN_DOCUMENTS_FOR_SEGMENTS, MIN_SWEEP_INTERVAL_MS, MODULE_URL_SCHEME_PATTERN, STATISTICS_BROADCAST_INTERVAL_MS };
@@ -0,0 +1,6 @@
1
+ // src/runtime/idle-heap-cleanup.browser.ts
2
+ function collectAndReturnPages() {
3
+ return false;
4
+ }
5
+
6
+ export { collectAndReturnPages };
@@ -0,0 +1,176 @@
1
+ import { extractVectorFieldsFromSchema, readHeapStatistics, readResidentMemory } from './chunk-5DB2VDGI.mjs';
2
+ import { collectAndReturnPages } from './chunk-OIZS5KIX.mjs';
3
+ import { NarsilError, ErrorCodes } from './chunk-35B42UFM.mjs';
4
+
5
+ // src/engine/snapshot/constants.ts
6
+ var RESTORE_WORST_HEAP_BYTES_PER_STORED_BYTE = 0.2;
7
+ var RESTORE_WORST_HEAP_BYTES_PER_EARLIER_SNAPSHOT_BYTE = 7.86;
8
+ var RESTORE_WORST_HEAP_BYTES_PER_VECTOR = 264;
9
+ var RESTORE_WORST_HEAP_BYTES_PER_VECTOR_DIMENSION = 0.24;
10
+ var RESTORE_WORST_HEAP_BYTES_PER_EARLIER_SNAPSHOT_VECTOR = 738;
11
+ var RESTORE_WORST_HEAP_BYTES_PER_EARLIER_SNAPSHOT_VECTOR_DIMENSION = 0.2;
12
+ var RESTORE_WORST_EXTERNAL_BYTES_PER_STORED_BYTE = 4.06;
13
+ var RESTORE_WORST_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_BYTE = 14.5;
14
+ var RESTORE_WORST_EXTERNAL_BYTES_PER_VECTOR = 1482;
15
+ var RESTORE_WORST_EXTERNAL_BYTES_PER_VECTOR_DIMENSION = 9.29;
16
+ var RESTORE_WORST_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_VECTOR = 2141;
17
+ var RESTORE_WORST_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_VECTOR_DIMENSION = 24.15;
18
+ var RESTORE_FLOOR_HEAP_BYTES_PER_STORED_BYTE = 0.16;
19
+ var RESTORE_FLOOR_HEAP_BYTES_PER_EARLIER_SNAPSHOT_BYTE = 6.16;
20
+ var RESTORE_FLOOR_HEAP_BYTES_PER_VECTOR = 204;
21
+ var RESTORE_FLOOR_HEAP_BYTES_PER_VECTOR_DIMENSION = 0.17;
22
+ var RESTORE_FLOOR_HEAP_BYTES_PER_EARLIER_SNAPSHOT_VECTOR = 695;
23
+ var RESTORE_FLOOR_HEAP_BYTES_PER_EARLIER_SNAPSHOT_VECTOR_DIMENSION = 0.04;
24
+ var RESTORE_FLOOR_EXTERNAL_BYTES_PER_STORED_BYTE = 2.14;
25
+ var RESTORE_FLOOR_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_BYTE = 5.05;
26
+ var RESTORE_FLOOR_EXTERNAL_BYTES_PER_VECTOR = 1080;
27
+ var RESTORE_FLOOR_EXTERNAL_BYTES_PER_VECTOR_DIMENSION = 0.72;
28
+ var RESTORE_FLOOR_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_VECTOR = 1744;
29
+ var RESTORE_FLOOR_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_VECTOR_DIMENSION = 20.05;
30
+ var RESTORE_ESTIMATE_MARGIN = 1.25;
31
+ var MAX_SNAPSHOT_ANALYSIS_ATTEMPTS = 3;
32
+
33
+ // src/engine/snapshot/memory-budget.ts
34
+ var MEGABYTE_BYTES = 1048576;
35
+ var ARCHIVE_RATES = {
36
+ worst: {
37
+ heap: {
38
+ perStoredByte: RESTORE_WORST_HEAP_BYTES_PER_STORED_BYTE,
39
+ perVector: RESTORE_WORST_HEAP_BYTES_PER_VECTOR,
40
+ perVectorDimension: RESTORE_WORST_HEAP_BYTES_PER_VECTOR_DIMENSION
41
+ },
42
+ external: {
43
+ perStoredByte: RESTORE_WORST_EXTERNAL_BYTES_PER_STORED_BYTE,
44
+ perVector: RESTORE_WORST_EXTERNAL_BYTES_PER_VECTOR,
45
+ perVectorDimension: RESTORE_WORST_EXTERNAL_BYTES_PER_VECTOR_DIMENSION
46
+ }
47
+ },
48
+ floor: {
49
+ heap: {
50
+ perStoredByte: RESTORE_FLOOR_HEAP_BYTES_PER_STORED_BYTE,
51
+ perVector: RESTORE_FLOOR_HEAP_BYTES_PER_VECTOR,
52
+ perVectorDimension: RESTORE_FLOOR_HEAP_BYTES_PER_VECTOR_DIMENSION
53
+ },
54
+ external: {
55
+ perStoredByte: RESTORE_FLOOR_EXTERNAL_BYTES_PER_STORED_BYTE,
56
+ perVector: RESTORE_FLOOR_EXTERNAL_BYTES_PER_VECTOR,
57
+ perVectorDimension: RESTORE_FLOOR_EXTERNAL_BYTES_PER_VECTOR_DIMENSION
58
+ }
59
+ }
60
+ };
61
+ var EARLIER_SNAPSHOT_RATES = {
62
+ worst: {
63
+ heap: {
64
+ perStoredByte: RESTORE_WORST_HEAP_BYTES_PER_EARLIER_SNAPSHOT_BYTE,
65
+ perVector: RESTORE_WORST_HEAP_BYTES_PER_EARLIER_SNAPSHOT_VECTOR,
66
+ perVectorDimension: RESTORE_WORST_HEAP_BYTES_PER_EARLIER_SNAPSHOT_VECTOR_DIMENSION
67
+ },
68
+ external: {
69
+ perStoredByte: RESTORE_WORST_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_BYTE,
70
+ perVector: RESTORE_WORST_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_VECTOR,
71
+ perVectorDimension: RESTORE_WORST_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_VECTOR_DIMENSION
72
+ }
73
+ },
74
+ floor: {
75
+ heap: {
76
+ perStoredByte: RESTORE_FLOOR_HEAP_BYTES_PER_EARLIER_SNAPSHOT_BYTE,
77
+ perVector: RESTORE_FLOOR_HEAP_BYTES_PER_EARLIER_SNAPSHOT_VECTOR,
78
+ perVectorDimension: RESTORE_FLOOR_HEAP_BYTES_PER_EARLIER_SNAPSHOT_VECTOR_DIMENSION
79
+ },
80
+ external: {
81
+ perStoredByte: RESTORE_FLOOR_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_BYTE,
82
+ perVector: RESTORE_FLOOR_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_VECTOR,
83
+ perVectorDimension: RESTORE_FLOOR_EXTERNAL_BYTES_PER_EARLIER_SNAPSHOT_VECTOR_DIMENSION
84
+ }
85
+ }
86
+ };
87
+ function bytesAt(rate, storedBytes, vectors) {
88
+ let bytes = storedBytes * rate.perStoredByte;
89
+ for (const { dimension, count } of vectors) bytes += count * (rate.perVector + dimension * rate.perVectorDimension);
90
+ return bytes;
91
+ }
92
+ function footprintAt(rates, replacesIndex, storedBytes, vectors) {
93
+ const chosen = replacesIndex ? rates.worst : rates.floor;
94
+ const scale = replacesIndex ? RESTORE_ESTIMATE_MARGIN : 1 / RESTORE_ESTIMATE_MARGIN;
95
+ return {
96
+ heapBytes: bytesAt(chosen.heap, storedBytes, vectors) * scale,
97
+ externalBytes: bytesAt(chosen.external, storedBytes, vectors) * scale
98
+ };
99
+ }
100
+ function deadCountOf(dead) {
101
+ if (dead === null) return 0;
102
+ let count = 0;
103
+ for (const byte of dead) {
104
+ for (let bits = byte; bits !== 0; bits &= bits - 1) count += 1;
105
+ }
106
+ return count;
107
+ }
108
+ function storedBytesOfSegments(manifest) {
109
+ let bytes = 0;
110
+ for (const partition of manifest.partitions) {
111
+ for (const segment of partition.segments) bytes += segment.bytes;
112
+ }
113
+ return bytes;
114
+ }
115
+ function archiveFootprint(prepared, manifest, replacesIndex, segmentBytes) {
116
+ const dimensions = extractVectorFieldsFromSchema(prepared.config.schema);
117
+ const vectors = [];
118
+ for (const field of manifest.vectors) {
119
+ const dimension = dimensions.get(field.fieldPath) ?? 0;
120
+ for (const file of field.files) vectors.push({ dimension, count: Math.max(0, file.count - deadCountOf(file.dead)) });
121
+ }
122
+ return footprintAt(ARCHIVE_RATES, replacesIndex, segmentBytes, vectors);
123
+ }
124
+ function earlierSnapshotFootprint(prepared, partitionBytes, vectorCounts, replacesIndex) {
125
+ const dimensions = extractVectorFieldsFromSchema(prepared.config.schema);
126
+ const vectors = [...vectorCounts].map(([fieldPath, count]) => ({ dimension: dimensions.get(fieldPath) ?? 0, count }));
127
+ return footprintAt(EARLIER_SNAPSHOT_RATES, replacesIndex, partitionBytes, vectors);
128
+ }
129
+ function inMegabytes(bytes) {
130
+ return Math.ceil(bytes / MEGABYTE_BYTES);
131
+ }
132
+ function shortfallOf(heapBytes, processBytes, countInUse) {
133
+ const heap = readHeapStatistics();
134
+ if (heap !== null) {
135
+ const limitBytes = heap.configuredLimitBytes ?? heap.limitBytes;
136
+ const availableBytes = countInUse ? limitBytes - heap.usedBytes : limitBytes;
137
+ if (heapBytes > availableBytes) return { budget: "heap", neededBytes: heapBytes, availableBytes };
138
+ }
139
+ const resident = readResidentMemory();
140
+ if (resident !== null) {
141
+ const availableBytes = countInUse ? resident.limitBytes - resident.residentBytes : resident.limitBytes;
142
+ if (processBytes > availableBytes) return { budget: "process", neededBytes: processBytes, availableBytes };
143
+ }
144
+ return null;
145
+ }
146
+ function refuse(indexName, replacesIndex, shortfall) {
147
+ const { budget, neededBytes, availableBytes } = shortfall;
148
+ const where = budget === "heap" ? "of JavaScript heap" : "of process memory";
149
+ const outcome = replacesIndex ? "so the index keeps its earlier contents. Drop the index first to free the memory that it holds, or give the process more memory, then restore again" : "so the engine creates no index. Give the process more memory, then restore again";
150
+ throw new NarsilError(
151
+ ErrorCodes.RESTORE_MEMORY_EXCEEDED,
152
+ `The restore of index "${indexName}" needs about ${inMegabytes(neededBytes)} MB ${where}, and this process has ${inMegabytes(Math.max(0, availableBytes))} MB free, ${outcome}`,
153
+ { indexName, budget, neededBytes, availableBytes }
154
+ );
155
+ }
156
+ function requireAnalysisRebuildMemory(indexName, termBytes) {
157
+ if (shortfallOf(termBytes, termBytes, true) === null) return;
158
+ const shortfall = shortfallOf(termBytes, termBytes, collectAndReturnPages());
159
+ if (shortfall === null) return;
160
+ const { budget, neededBytes, availableBytes } = shortfall;
161
+ const where = budget === "heap" ? "of JavaScript heap" : "of process memory";
162
+ throw new NarsilError(
163
+ ErrorCodes.ANALYSIS_REBUILD_MEMORY_EXCEEDED,
164
+ `The analysis change of index "${indexName}" needs about ${inMegabytes(neededBytes)} MB ${where} for a second copy of its terms, and this process has ${inMegabytes(Math.max(0, availableBytes))} MB free, so the index keeps its current settings. Give the process more memory, then change the settings again`,
165
+ { indexName, budget, neededBytes, availableBytes }
166
+ );
167
+ }
168
+ function requireRestoreMemory(indexName, footprint, replacesIndex) {
169
+ const processBytes = footprint.heapBytes + footprint.externalBytes;
170
+ if (shortfallOf(footprint.heapBytes, processBytes, true) === null) return;
171
+ const collected = collectAndReturnPages();
172
+ const shortfall = shortfallOf(footprint.heapBytes, processBytes, collected || replacesIndex);
173
+ if (shortfall !== null) refuse(indexName, replacesIndex, shortfall);
174
+ }
175
+
176
+ export { MAX_SNAPSHOT_ANALYSIS_ATTEMPTS, archiveFootprint, earlierSnapshotFootprint, requireAnalysisRebuildMemory, requireRestoreMemory, storedBytesOfSegments };
@@ -1,5 +1,5 @@
1
- import { removeDocumentVectors, prepareDocumentVectors, insertDocumentVectors, getNestedValue, requireValidFieldTypes, VECTOR_PATTERN } from './chunk-2Y3CO4EQ.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-UDGB2MWT.mjs';
1
+ import { removeDocumentVectors, prepareDocumentVectors, insertDocumentVectors, getNestedValue, requireValidFieldTypes, VECTOR_PATTERN } from './chunk-5DB2VDGI.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-35B42UFM.mjs';
3
3
  import { decode } from '@msgpack/msgpack';
4
4
 
5
5
  function applyIndexEntry(entry, manager, vectorFieldPaths, vecIndexes) {
@@ -636,4 +636,4 @@ function decodeKeywordSegment(payload, shared) {
636
636
  return writeRecords === null ? { schema, tombstones, arrays } : { schema, tombstones, arrays, writeRecords };
637
637
  }
638
638
 
639
- export { KEYWORD_SEGMENT_ENVELOPE_VERSION, KEYWORD_SEGMENT_PAYLOAD_VERSION, applyDeleteEntry, applyIndexEntry, decodeKeywordSegment, littleEndianBytes, restoreVectorFields, setNestedValue, uint64Bytes };
639
+ export { KEYWORD_SEGMENT_ENVELOPE_VERSION, KEYWORD_SEGMENT_PAYLOAD_VERSION, applyDeleteEntry, applyIndexEntry, decodeBooleanColumns, decodeEnumColumns, decodeFieldLengths, decodeGeopointColumns, decodeKeywordSegment, decodePartialWords, decodePatternColumns, decodeSurfaceForms, decodeValueColumns, littleEndianBytes, requireEntriesAscend, requireOffsets, requireUtf8Entries, restoreVectorFields, setNestedValue, uint32sFrom, uint64Bytes };
@@ -0,0 +1,212 @@
1
+ import { chunksOf, restoredConfigFields, restoredEmbedding } from './chunk-ZEV26AQ6.mjs';
2
+ import { untagDocumentLine } from './chunk-WCFCHIBB.mjs';
3
+ import { flattenSchema, requireConfigurationShape } from './chunk-5DB2VDGI.mjs';
4
+ import { MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, MAX_IMPORT_REFUSALS_REPORTED } from './chunk-MZI3TEOW.mjs';
5
+ import { NarsilError, ErrorCodes } from './chunk-35B42UFM.mjs';
6
+
7
+ // src/engine/export/lines.ts
8
+ var NEWLINE = 10;
9
+ function joined(parts, total) {
10
+ if (parts.length === 1) return parts[0];
11
+ const bytes = new Uint8Array(total);
12
+ let offset = 0;
13
+ for (const part of parts) {
14
+ bytes.set(part, offset);
15
+ offset += part.byteLength;
16
+ }
17
+ return bytes;
18
+ }
19
+ async function* exportLines(source, maxLineBytes) {
20
+ const decoder = new TextDecoder("utf-8", { fatal: true });
21
+ let parts = [];
22
+ let pending = 0;
23
+ let overflowing = false;
24
+ let line = 0;
25
+ const finishLine = () => {
26
+ line += 1;
27
+ if (overflowing) {
28
+ overflowing = false;
29
+ parts = [];
30
+ pending = 0;
31
+ return { line, refused: "too-long" };
32
+ }
33
+ const bytes = joined(parts, pending);
34
+ parts = [];
35
+ pending = 0;
36
+ try {
37
+ return { line, text: decoder.decode(bytes) };
38
+ } catch {
39
+ return { line, refused: "not-utf8" };
40
+ }
41
+ };
42
+ for await (const chunk of chunksOf(source)) {
43
+ let start = 0;
44
+ for (; ; ) {
45
+ const newline = chunk.indexOf(NEWLINE, start);
46
+ const end = newline < 0 ? chunk.byteLength : newline;
47
+ const piece = chunk.subarray(start, end);
48
+ if (!overflowing && pending + piece.byteLength <= maxLineBytes) {
49
+ if (piece.byteLength > 0) parts.push(piece.slice());
50
+ pending += piece.byteLength;
51
+ } else {
52
+ overflowing = true;
53
+ parts = [];
54
+ }
55
+ if (newline < 0) break;
56
+ yield finishLine();
57
+ start = newline + 1;
58
+ }
59
+ }
60
+ if (pending > 0 || overflowing) yield finishLine();
61
+ }
62
+
63
+ // src/engine/export/import.ts
64
+ var DOCUMENT_EXPORT_FORMAT = "narsil-export";
65
+ var DOCUMENT_EXPORT_VERSION = 1;
66
+ function invalidHeader(message) {
67
+ throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The document export header ${message}`);
68
+ }
69
+ function isRecord(value) {
70
+ return typeof value === "object" && value !== null && !Array.isArray(value);
71
+ }
72
+ function configOfHeader(line) {
73
+ if (line === void 0) invalidHeader("is missing");
74
+ if (!("text" in line)) {
75
+ invalidHeader(
76
+ line.refused === "too-long" ? `passes the line limit of ${MAX_EXPORT_LINE_BYTES} bytes` : "is not UTF-8"
77
+ );
78
+ }
79
+ let raw;
80
+ try {
81
+ raw = JSON.parse(line.text);
82
+ } catch {
83
+ invalidHeader("is not JSON");
84
+ }
85
+ if (!isRecord(raw) || raw.format !== DOCUMENT_EXPORT_FORMAT || raw.version !== DOCUMENT_EXPORT_VERSION) {
86
+ invalidHeader(`must name format "${DOCUMENT_EXPORT_FORMAT}" and version ${DOCUMENT_EXPORT_VERSION}`);
87
+ }
88
+ const configuration = requireConfigurationShape(raw.index, "document export header");
89
+ const fields = restoredConfigFields(configuration, (message) => invalidHeader(message));
90
+ const embedding = restoredEmbedding(configuration.embedding, (message) => invalidHeader(message));
91
+ return {
92
+ schema: configuration.schema,
93
+ language: configuration.language,
94
+ ...fields,
95
+ ...embedding === void 0 ? {} : {
96
+ embedding: {
97
+ fields: embedding.fields,
98
+ ...embedding.adapter === void 0 ? {} : { adapter: embedding.adapter }
99
+ }
100
+ }
101
+ };
102
+ }
103
+ async function prepareIndex(engine, indexName, config) {
104
+ if (!engine.listIndexes().some((index) => index.name === indexName)) {
105
+ await engine.createIndex(indexName, config);
106
+ return;
107
+ }
108
+ const existing = flattenSchema(engine.getStats(indexName).schema);
109
+ const exported = flattenSchema(config.schema);
110
+ const fields = /* @__PURE__ */ new Set([...Object.keys(existing), ...Object.keys(exported)]);
111
+ for (const field of fields) {
112
+ if (existing[field] === exported[field]) continue;
113
+ throw new NarsilError(
114
+ ErrorCodes.CONFIG_INVALID,
115
+ `Index "${indexName}" gives field "${field}" another type than the export does, so the import cannot write into it`,
116
+ { indexName, field }
117
+ );
118
+ }
119
+ }
120
+ function highestReportedAt(refused) {
121
+ let highest = 0;
122
+ for (let at = 1; at < refused.length; at++) {
123
+ if (refused[at].line > refused[highest].line) highest = at;
124
+ }
125
+ return highest;
126
+ }
127
+ function refuse(state, line, code, message) {
128
+ state.result.refusedCount += 1;
129
+ const refused = state.result.refused;
130
+ if (refused.length < MAX_IMPORT_REFUSALS_REPORTED) {
131
+ refused.push({ line, code, message });
132
+ if (refused.length === MAX_IMPORT_REFUSALS_REPORTED) state.highestReported = highestReportedAt(refused);
133
+ return;
134
+ }
135
+ if (line >= refused[state.highestReported].line) return;
136
+ refused[state.highestReported] = { line, code, message };
137
+ state.highestReported = highestReportedAt(refused);
138
+ }
139
+ async function flush(state) {
140
+ if (state.batch.length === 0) return;
141
+ const batch = state.batch;
142
+ state.batch = [];
143
+ state.batchIds = /* @__PURE__ */ new Set();
144
+ const lineOf = new Map(batch.map((entry) => [entry.docId, entry.line]));
145
+ const inserts = [];
146
+ const updates = [];
147
+ for (const entry of batch) {
148
+ if (await state.engine.has(state.indexName, entry.docId))
149
+ updates.push({ docId: entry.docId, document: entry.document });
150
+ else inserts.push(entry.document);
151
+ }
152
+ for (const outcome of [
153
+ inserts.length === 0 ? null : await state.engine.insertBatch(state.indexName, inserts, { skipClone: true }),
154
+ updates.length === 0 ? null : await state.engine.updateBatch(state.indexName, updates)
155
+ ]) {
156
+ if (outcome === null) continue;
157
+ state.result.imported += outcome.succeeded.length;
158
+ for (const failure of outcome.failed) {
159
+ const code = failure.error instanceof NarsilError ? failure.error.code : ErrorCodes.DOC_VALIDATION_FAILED;
160
+ refuse(state, lineOf.get(failure.docId) ?? 0, code, failure.error.message);
161
+ }
162
+ }
163
+ }
164
+ async function takeLine(state, entry) {
165
+ if (!("text" in entry)) {
166
+ const message = entry.refused === "too-long" ? `The line passes the limit of ${MAX_EXPORT_LINE_BYTES} bytes` : "The line is not UTF-8";
167
+ refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, message);
168
+ return;
169
+ }
170
+ if (entry.text.length === 0) return;
171
+ let document;
172
+ try {
173
+ document = JSON.parse(entry.text);
174
+ } catch {
175
+ refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, "The line is not JSON");
176
+ return;
177
+ }
178
+ if (!isRecord(document) || typeof document.id !== "string" || document.id.length === 0) {
179
+ refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, "The line holds no document with a string id");
180
+ return;
181
+ }
182
+ try {
183
+ untagDocumentLine(entry.text, document);
184
+ } catch (error) {
185
+ if (!(error instanceof NarsilError)) throw error;
186
+ refuse(state, entry.line, error.code, error.message);
187
+ return;
188
+ }
189
+ if (state.batchIds.has(document.id)) await flush(state);
190
+ state.batch.push({ line: entry.line, docId: document.id, document });
191
+ state.batchIds.add(document.id);
192
+ if (state.batch.length >= IMPORT_BATCH_DOCUMENTS) await flush(state);
193
+ }
194
+ async function readDocumentExport(engine, indexName, source) {
195
+ const lines = exportLines(source, MAX_EXPORT_LINE_BYTES);
196
+ const header = await lines.next();
197
+ await prepareIndex(engine, indexName, configOfHeader(header.done === true ? void 0 : header.value));
198
+ const state = {
199
+ engine,
200
+ indexName,
201
+ batch: [],
202
+ batchIds: /* @__PURE__ */ new Set(),
203
+ result: { imported: 0, refusedCount: 0, refused: [] },
204
+ highestReported: 0
205
+ };
206
+ for await (const entry of lines) await takeLine(state, entry);
207
+ await flush(state);
208
+ state.result.refused.sort((a, b) => a.line - b.line);
209
+ return state.result;
210
+ }
211
+
212
+ export { DOCUMENT_EXPORT_FORMAT, DOCUMENT_EXPORT_VERSION, readDocumentExport };
@@ -0,0 +1,177 @@
1
+ import { MAX_DOCUMENT_NESTING_DEPTH } from './chunk-5DB2VDGI.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-35B42UFM.mjs';
3
+
4
+ // src/serialization/base64.ts
5
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6
+ var PAD = 61;
7
+ var BYTES_PER_GROUP = 3;
8
+ var CHARACTERS_PER_GROUP = 4;
9
+ var ASCII_LIMIT = 128;
10
+ var ENCODE = new Uint8Array(ALPHABET.length);
11
+ var DECODE = new Int8Array(ASCII_LIMIT).fill(-1);
12
+ for (let at = 0; at < ALPHABET.length; at++) {
13
+ ENCODE[at] = ALPHABET.charCodeAt(at);
14
+ DECODE[ALPHABET.charCodeAt(at)] = at;
15
+ }
16
+ var asciiDecoder = new TextDecoder();
17
+ function encodeBase64(bytes) {
18
+ const out = new Uint8Array(Math.ceil(bytes.byteLength / BYTES_PER_GROUP) * CHARACTERS_PER_GROUP);
19
+ let write = 0;
20
+ let read = 0;
21
+ for (; read + BYTES_PER_GROUP <= bytes.byteLength; read += BYTES_PER_GROUP) {
22
+ const group = bytes[read] << 16 | bytes[read + 1] << 8 | bytes[read + 2];
23
+ out[write++] = ENCODE[group >>> 18];
24
+ out[write++] = ENCODE[group >>> 12 & 63];
25
+ out[write++] = ENCODE[group >>> 6 & 63];
26
+ out[write++] = ENCODE[group & 63];
27
+ }
28
+ const left = bytes.byteLength - read;
29
+ if (left > 0) {
30
+ const group = bytes[read] << 16 | (left === 2 ? bytes[read + 1] << 8 : 0);
31
+ out[write++] = ENCODE[group >>> 18];
32
+ out[write++] = ENCODE[group >>> 12 & 63];
33
+ out[write++] = left === 2 ? ENCODE[group >>> 6 & 63] : PAD;
34
+ out[write++] = PAD;
35
+ }
36
+ return asciiDecoder.decode(out);
37
+ }
38
+ function sextetAt(text, at) {
39
+ const code = text.charCodeAt(at);
40
+ return code < ASCII_LIMIT ? DECODE[code] : -1;
41
+ }
42
+ function decodeExactBase64(text) {
43
+ if (text.length % CHARACTERS_PER_GROUP !== 0) return null;
44
+ const padding = text.endsWith("==") ? 2 : text.endsWith("=") ? 1 : 0;
45
+ const out = new Uint8Array(text.length / CHARACTERS_PER_GROUP * BYTES_PER_GROUP - padding);
46
+ const fullEnd = padding === 0 ? text.length : text.length - CHARACTERS_PER_GROUP;
47
+ let write = 0;
48
+ for (let at = 0; at < fullEnd; at += CHARACTERS_PER_GROUP) {
49
+ const a2 = sextetAt(text, at);
50
+ const b2 = sextetAt(text, at + 1);
51
+ const c2 = sextetAt(text, at + 2);
52
+ const d = sextetAt(text, at + 3);
53
+ if ((a2 | b2 | c2 | d) < 0) return null;
54
+ const group = a2 << 18 | b2 << 12 | c2 << 6 | d;
55
+ out[write++] = group >>> 16;
56
+ out[write++] = group >>> 8 & 255;
57
+ out[write++] = group & 255;
58
+ }
59
+ if (padding === 0) return out;
60
+ const a = sextetAt(text, fullEnd);
61
+ const b = sextetAt(text, fullEnd + 1);
62
+ const c = padding === 1 ? sextetAt(text, fullEnd + 2) : 0;
63
+ if ((a | b | c) < 0) return null;
64
+ if (padding === 2 && (b & 15) !== 0) return null;
65
+ if (padding === 1 && (c & 3) !== 0) return null;
66
+ out[write++] = a << 2 | b >>> 4;
67
+ if (padding === 1) out[write] = (b & 15) << 4 | c >>> 2;
68
+ return out;
69
+ }
70
+
71
+ // src/engine/export/tags.ts
72
+ var TAG_PREFIX = "$";
73
+ var DATE_TAG = "$date";
74
+ var BYTES_TAG = "$bytes";
75
+ var NUMBER_TAG = "$number";
76
+ var OBJECT_TAG = "$object";
77
+ var MILLISECONDS_PER_SECOND = 1e3;
78
+ var NANOSECONDS_PER_MILLISECOND = 1e6;
79
+ var MAX_NANOSECONDS = 999999999;
80
+ var MAX_DATE_MILLISECONDS = 864e13;
81
+ var ESCAPED_TAG_PREFIX = "\\u0024";
82
+ var NON_FINITE_NUMBERS = /* @__PURE__ */ new Map([
83
+ ["NaN", Number.NaN],
84
+ ["Infinity", Number.POSITIVE_INFINITY],
85
+ ["-Infinity", Number.NEGATIVE_INFINITY]
86
+ ]);
87
+ function refuse(path, reason) {
88
+ throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path === "" ? "(document)" : path}" ${reason}`, {
89
+ field: path
90
+ });
91
+ }
92
+ function isRecord(value) {
93
+ return typeof value === "object" && value !== null && !Array.isArray(value);
94
+ }
95
+ function startsWithTagPrefix(key) {
96
+ return key.startsWith(TAG_PREFIX);
97
+ }
98
+ function soleTagKey(record) {
99
+ let sole = null;
100
+ for (const key of Object.keys(record)) {
101
+ if (sole !== null) return null;
102
+ sole = key;
103
+ }
104
+ return sole !== null && startsWithTagPrefix(sole) ? sole : null;
105
+ }
106
+ function dateOf(value, path) {
107
+ if (!Array.isArray(value) || value.length !== 2)
108
+ refuse(path, `holds a "${DATE_TAG}" tag other than [seconds, nanoseconds]`);
109
+ const seconds = value[0];
110
+ const nanoseconds = value[1];
111
+ if (typeof seconds !== "number" || !Number.isSafeInteger(seconds)) {
112
+ refuse(
113
+ path,
114
+ `holds a "${DATE_TAG}" tag whose seconds are not an integer from -${Number.MAX_SAFE_INTEGER} to ${Number.MAX_SAFE_INTEGER}`
115
+ );
116
+ }
117
+ if (typeof nanoseconds !== "number" || !Number.isInteger(nanoseconds) || nanoseconds < 0 || nanoseconds > MAX_NANOSECONDS) {
118
+ refuse(path, `holds a "${DATE_TAG}" tag whose nanoseconds are not an integer from 0 to ${MAX_NANOSECONDS}`);
119
+ }
120
+ const milliseconds = seconds * MILLISECONDS_PER_SECOND + nanoseconds / NANOSECONDS_PER_MILLISECOND;
121
+ if (Math.abs(milliseconds) > MAX_DATE_MILLISECONDS)
122
+ refuse(path, `holds a "${DATE_TAG}" tag outside the range of a date`);
123
+ return new Date(milliseconds);
124
+ }
125
+ function bytesOf(value, path) {
126
+ const bytes = typeof value === "string" ? decodeExactBase64(value) : null;
127
+ if (bytes === null) refuse(path, `holds a "${BYTES_TAG}" tag whose text is not padded base64`);
128
+ return bytes;
129
+ }
130
+ function numberOf(value, path) {
131
+ const number = typeof value === "string" ? NON_FINITE_NUMBERS.get(value) : void 0;
132
+ if (number === void 0) refuse(path, `holds a "${NUMBER_TAG}" tag other than "NaN", "Infinity", or "-Infinity"`);
133
+ return number;
134
+ }
135
+ function requireDepth(path, depth) {
136
+ if (depth >= MAX_DOCUMENT_NESTING_DEPTH) refuse(path, `nests deeper than ${MAX_DOCUMENT_NESTING_DEPTH} levels`);
137
+ }
138
+ function untagMap(record, path, depth) {
139
+ requireDepth(path, depth);
140
+ for (const key of Object.keys(record)) {
141
+ record[key] = untag(record[key], path === "" ? key : `${path}.${key}`, depth + 1);
142
+ }
143
+ return record;
144
+ }
145
+ function untagList(list, path, depth) {
146
+ requireDepth(path, depth);
147
+ for (let at = 0; at < list.length; at++) list[at] = untag(list[at], `${path}[${at}]`, depth + 1);
148
+ return list;
149
+ }
150
+ function untagTag(tag, value, path, depth) {
151
+ switch (tag) {
152
+ case DATE_TAG:
153
+ return dateOf(value, path);
154
+ case BYTES_TAG:
155
+ return bytesOf(value, path);
156
+ case NUMBER_TAG:
157
+ return numberOf(value, path);
158
+ case OBJECT_TAG:
159
+ if (!isRecord(value)) refuse(path, `holds an "${OBJECT_TAG}" tag whose value is not an object`);
160
+ return untagMap(value, path, depth);
161
+ default:
162
+ return refuse(path, `holds an object whose only key, "${tag}", names no tag`);
163
+ }
164
+ }
165
+ function untag(value, path, depth) {
166
+ if (typeof value !== "object" || value === null) return value;
167
+ if (Array.isArray(value)) return untagList(value, path, depth);
168
+ const record = value;
169
+ const tag = soleTagKey(record);
170
+ return tag === null ? untagMap(record, path, depth) : untagTag(tag, record[tag], path, depth);
171
+ }
172
+ function untagDocumentLine(text, parsed) {
173
+ if (!text.includes(`"${TAG_PREFIX}`) && !text.includes(ESCAPED_TAG_PREFIX)) return parsed;
174
+ return untagMap(parsed, "", 0);
175
+ }
176
+
177
+ export { BYTES_TAG, DATE_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND, NUMBER_TAG, OBJECT_TAG, encodeBase64, startsWithTagPrefix, untagDocumentLine };
@@ -0,0 +1,21 @@
1
+ // src/engine/analysis-change-entry.ts
2
+ function holdsChangeWork(entry) {
3
+ return entry !== void 0 && (entry.pendingAnalysis !== null || entry.durableAnalysis !== null);
4
+ }
5
+ async function abandonChangeOf(core, indexName) {
6
+ if (!holdsChangeWork(core.indexRegistry.get(indexName))) return;
7
+ const { abandonAnalysisChange } = await import('./analysis-change-JPV775LR.mjs');
8
+ await abandonAnalysisChange(core, indexName);
9
+ }
10
+ async function resumeChangeOf(core, indexName) {
11
+ if ((core.indexRegistry.get(indexName)?.pendingAnalysis ?? null) === null) return;
12
+ if (core.mutationCtx.capacityScope === "partition") return;
13
+ if (core.executor.getManager(indexName) === void 0) return;
14
+ const { resumeAnalysisChange } = await import('./analysis-change-JPV775LR.mjs');
15
+ void resumeAnalysisChange(core, indexName).catch(() => void 0);
16
+ }
17
+ async function resumeEveryChange(core) {
18
+ for (const indexName of [...core.indexRegistry.keys()]) await resumeChangeOf(core, indexName);
19
+ }
20
+
21
+ export { abandonChangeOf, resumeChangeOf, resumeEveryChange };