@reportman/engine 0.0.0-stage → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/LICENSE +373 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/data/columns.d.ts +50 -0
  4. package/dist/data/columns.d.ts.map +1 -0
  5. package/dist/data/columns.js +385 -0
  6. package/dist/data/columns.js.map +1 -0
  7. package/dist/data/databaseinfo.d.ts +41 -0
  8. package/dist/data/databaseinfo.d.ts.map +1 -0
  9. package/dist/data/databaseinfo.js +145 -0
  10. package/dist/data/databaseinfo.js.map +1 -0
  11. package/dist/data/datainfo.d.ts +82 -0
  12. package/dist/data/datainfo.d.ts.map +1 -0
  13. package/dist/data/datainfo.js +449 -0
  14. package/dist/data/datainfo.js.map +1 -0
  15. package/dist/data/errors.d.ts +8 -0
  16. package/dist/data/errors.d.ts.map +1 -0
  17. package/dist/data/errors.js +14 -0
  18. package/dist/data/errors.js.map +1 -0
  19. package/dist/data/host.d.ts +132 -0
  20. package/dist/data/host.d.ts.map +1 -0
  21. package/dist/data/host.js +108 -0
  22. package/dist/data/host.js.map +1 -0
  23. package/dist/data/op.d.ts +21 -0
  24. package/dist/data/op.d.ts.map +1 -0
  25. package/dist/data/op.js +97 -0
  26. package/dist/data/op.js.map +1 -0
  27. package/dist/data/reportdataset.d.ts +116 -0
  28. package/dist/data/reportdataset.d.ts.map +1 -0
  29. package/dist/data/reportdataset.js +396 -0
  30. package/dist/data/reportdataset.js.map +1 -0
  31. package/dist/data/transfer.d.ts +46 -0
  32. package/dist/data/transfer.d.ts.map +1 -0
  33. package/dist/data/transfer.js +100 -0
  34. package/dist/data/transfer.js.map +1 -0
  35. package/dist/data/union.d.ts +88 -0
  36. package/dist/data/union.d.ts.map +1 -0
  37. package/dist/data/union.js +733 -0
  38. package/dist/data/union.js.map +1 -0
  39. package/dist/eval/chinesetables.d.ts +5 -0
  40. package/dist/eval/chinesetables.d.ts.map +1 -0
  41. package/dist/eval/chinesetables.js +8 -0
  42. package/dist/eval/chinesetables.js.map +1 -0
  43. package/dist/eval/evaluator.d.ts +100 -0
  44. package/dist/eval/evaluator.d.ts.map +1 -0
  45. package/dist/eval/evaluator.js +667 -0
  46. package/dist/eval/evaluator.js.map +1 -0
  47. package/dist/eval/exception.d.ts +9 -0
  48. package/dist/eval/exception.d.ts.map +1 -0
  49. package/dist/eval/exception.js +15 -0
  50. package/dist/eval/exception.js.map +1 -0
  51. package/dist/eval/fields.d.ts +60 -0
  52. package/dist/eval/fields.d.ts.map +1 -0
  53. package/dist/eval/fields.js +104 -0
  54. package/dist/eval/fields.js.map +1 -0
  55. package/dist/eval/functions.d.ts +27 -0
  56. package/dist/eval/functions.d.ts.map +1 -0
  57. package/dist/eval/functions.js +810 -0
  58. package/dist/eval/functions.js.map +1 -0
  59. package/dist/eval/identifiers.d.ts +100 -0
  60. package/dist/eval/identifiers.d.ts.map +1 -0
  61. package/dist/eval/identifiers.js +195 -0
  62. package/dist/eval/identifiers.js.map +1 -0
  63. package/dist/eval/parser.d.ts +47 -0
  64. package/dist/eval/parser.d.ts.map +1 -0
  65. package/dist/eval/parser.js +336 -0
  66. package/dist/eval/parser.js.map +1 -0
  67. package/dist/index.d.ts +52 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +42 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/params/param.d.ts +92 -0
  72. package/dist/params/param.d.ts.map +1 -0
  73. package/dist/params/param.js +358 -0
  74. package/dist/params/param.js.map +1 -0
  75. package/dist/params/parameters.d.ts +87 -0
  76. package/dist/params/parameters.d.ts.map +1 -0
  77. package/dist/params/parameters.js +499 -0
  78. package/dist/params/parameters.js.map +1 -0
  79. package/dist/report/barcode/barcodeitem.d.ts +76 -0
  80. package/dist/report/barcode/barcodeitem.d.ts.map +1 -0
  81. package/dist/report/barcode/barcodeitem.js +864 -0
  82. package/dist/report/barcode/barcodeitem.js.map +1 -0
  83. package/dist/report/barcode/code128.d.ts +18 -0
  84. package/dist/report/barcode/code128.d.ts.map +1 -0
  85. package/dist/report/barcode/code128.js +187 -0
  86. package/dist/report/barcode/code128.js.map +1 -0
  87. package/dist/report/barcode/netutil.d.ts +30 -0
  88. package/dist/report/barcode/netutil.d.ts.map +1 -0
  89. package/dist/report/barcode/netutil.js +65 -0
  90. package/dist/report/barcode/netutil.js.map +1 -0
  91. package/dist/report/barcode/pdf417.d.ts +17 -0
  92. package/dist/report/barcode/pdf417.d.ts.map +1 -0
  93. package/dist/report/barcode/pdf417.js +782 -0
  94. package/dist/report/barcode/pdf417.js.map +1 -0
  95. package/dist/report/barcode/pdf417tables.d.ts +11 -0
  96. package/dist/report/barcode/pdf417tables.d.ts.map +1 -0
  97. package/dist/report/barcode/pdf417tables.js +880 -0
  98. package/dist/report/barcode/pdf417tables.js.map +1 -0
  99. package/dist/report/barcode/qrcode.d.ts +14 -0
  100. package/dist/report/barcode/qrcode.d.ts.map +1 -0
  101. package/dist/report/barcode/qrcode.js +214 -0
  102. package/dist/report/barcode/qrcode.js.map +1 -0
  103. package/dist/report/barcode/zxingwidth.d.ts +4 -0
  104. package/dist/report/barcode/zxingwidth.d.ts.map +1 -0
  105. package/dist/report/barcode/zxingwidth.js +247 -0
  106. package/dist/report/barcode/zxingwidth.js.map +1 -0
  107. package/dist/report/chart/chartidens.d.ts +70 -0
  108. package/dist/report/chart/chartidens.d.ts.map +1 -0
  109. package/dist/report/chart/chartidens.js +162 -0
  110. package/dist/report/chart/chartidens.js.map +1 -0
  111. package/dist/report/chart/chartitem.d.ts +110 -0
  112. package/dist/report/chart/chartitem.d.ts.map +1 -0
  113. package/dist/report/chart/chartitem.js +403 -0
  114. package/dist/report/chart/chartitem.js.map +1 -0
  115. package/dist/report/chart/series.d.ts +65 -0
  116. package/dist/report/chart/series.d.ts.map +1 -0
  117. package/dist/report/chart/series.js +74 -0
  118. package/dist/report/chart/series.js.map +1 -0
  119. package/dist/report/chart/vectorchart.d.ts +18 -0
  120. package/dist/report/chart/vectorchart.d.ts.map +1 -0
  121. package/dist/report/chart/vectorchart.js +356 -0
  122. package/dist/report/chart/vectorchart.js.map +1 -0
  123. package/dist/report/convert.d.ts +4 -0
  124. package/dist/report/convert.d.ts.map +1 -0
  125. package/dist/report/convert.js +162 -0
  126. package/dist/report/convert.js.map +1 -0
  127. package/dist/report/errors.d.ts +13 -0
  128. package/dist/report/errors.d.ts.map +1 -0
  129. package/dist/report/errors.js +20 -0
  130. package/dist/report/errors.js.map +1 -0
  131. package/dist/report/identifiers.d.ts +91 -0
  132. package/dist/report/identifiers.d.ts.map +1 -0
  133. package/dist/report/identifiers.js +404 -0
  134. package/dist/report/identifiers.js.map +1 -0
  135. package/dist/report/imageitem.d.ts +66 -0
  136. package/dist/report/imageitem.d.ts.map +1 -0
  137. package/dist/report/imageitem.js +190 -0
  138. package/dist/report/imageitem.js.map +1 -0
  139. package/dist/report/items.d.ts +219 -0
  140. package/dist/report/items.d.ts.map +1 -0
  141. package/dist/report/items.js +1015 -0
  142. package/dist/report/items.js.map +1 -0
  143. package/dist/report/report.d.ts +221 -0
  144. package/dist/report/report.d.ts.map +1 -0
  145. package/dist/report/report.js +1968 -0
  146. package/dist/report/report.js.map +1 -0
  147. package/dist/report/run.d.ts +87 -0
  148. package/dist/report/run.d.ts.map +1 -0
  149. package/dist/report/run.js +121 -0
  150. package/dist/report/run.js.map +1 -0
  151. package/dist/report/section.d.ts +86 -0
  152. package/dist/report/section.d.ts.map +1 -0
  153. package/dist/report/section.js +325 -0
  154. package/dist/report/section.js.map +1 -0
  155. package/dist/report/subreport.d.ts +49 -0
  156. package/dist/report/subreport.d.ts.map +1 -0
  157. package/dist/report/subreport.js +220 -0
  158. package/dist/report/subreport.js.map +1 -0
  159. package/dist/util/base64.d.ts +9 -0
  160. package/dist/util/base64.d.ts.map +1 -0
  161. package/dist/util/base64.js +60 -0
  162. package/dist/util/base64.js.map +1 -0
  163. package/dist/util/chars.d.ts +45 -0
  164. package/dist/util/chars.d.ts.map +1 -0
  165. package/dist/util/chars.js +194 -0
  166. package/dist/util/chars.js.map +1 -0
  167. package/dist/util/compositeformat.d.ts +3 -0
  168. package/dist/util/compositeformat.d.ts.map +1 -0
  169. package/dist/util/compositeformat.js +99 -0
  170. package/dist/util/compositeformat.js.map +1 -0
  171. package/dist/util/culture.d.ts +84 -0
  172. package/dist/util/culture.d.ts.map +1 -0
  173. package/dist/util/culture.js +59 -0
  174. package/dist/util/culture.js.map +1 -0
  175. package/dist/util/cultures.generated.d.ts +3 -0
  176. package/dist/util/cultures.generated.d.ts.map +1 -0
  177. package/dist/util/cultures.generated.js +1043 -0
  178. package/dist/util/cultures.generated.js.map +1 -0
  179. package/dist/util/dateformat.d.ts +21 -0
  180. package/dist/util/dateformat.d.ts.map +1 -0
  181. package/dist/util/dateformat.js +439 -0
  182. package/dist/util/dateformat.js.map +1 -0
  183. package/dist/util/dateparse.d.ts +12 -0
  184. package/dist/util/dateparse.d.ts.map +1 -0
  185. package/dist/util/dateparse.js +1212 -0
  186. package/dist/util/dateparse.js.map +1 -0
  187. package/dist/util/datetime.d.ts +70 -0
  188. package/dist/util/datetime.d.ts.map +1 -0
  189. package/dist/util/datetime.js +265 -0
  190. package/dist/util/datetime.js.map +1 -0
  191. package/dist/util/decimal.d.ts +54 -0
  192. package/dist/util/decimal.d.ts.map +1 -0
  193. package/dist/util/decimal.js +365 -0
  194. package/dist/util/decimal.js.map +1 -0
  195. package/dist/util/delphitext.d.ts +40 -0
  196. package/dist/util/delphitext.d.ts.map +1 -0
  197. package/dist/util/delphitext.js +408 -0
  198. package/dist/util/delphitext.js.map +1 -0
  199. package/dist/util/doubleutil.d.ts +30 -0
  200. package/dist/util/doubleutil.d.ts.map +1 -0
  201. package/dist/util/doubleutil.js +651 -0
  202. package/dist/util/doubleutil.js.map +1 -0
  203. package/dist/util/inflate.d.ts +7 -0
  204. package/dist/util/inflate.d.ts.map +1 -0
  205. package/dist/util/inflate.js +256 -0
  206. package/dist/util/inflate.js.map +1 -0
  207. package/dist/util/netexception.d.ts +59 -0
  208. package/dist/util/netexception.d.ts.map +1 -0
  209. package/dist/util/netexception.js +94 -0
  210. package/dist/util/netexception.js.map +1 -0
  211. package/dist/util/numberformat.d.ts +14 -0
  212. package/dist/util/numberformat.d.ts.map +1 -0
  213. package/dist/util/numberformat.js +828 -0
  214. package/dist/util/numberformat.js.map +1 -0
  215. package/dist/util/numberparse.d.ts +49 -0
  216. package/dist/util/numberparse.d.ts.map +1 -0
  217. package/dist/util/numberparse.js +568 -0
  218. package/dist/util/numberparse.js.map +1 -0
  219. package/dist/util/reportmanres.en.generated.d.ts +2 -0
  220. package/dist/util/reportmanres.en.generated.d.ts.map +1 -0
  221. package/dist/util/reportmanres.en.generated.js +2082 -0
  222. package/dist/util/reportmanres.en.generated.js.map +1 -0
  223. package/dist/util/reportmanres.es.generated.d.ts +2 -0
  224. package/dist/util/reportmanres.es.generated.d.ts.map +1 -0
  225. package/dist/util/reportmanres.es.generated.js +2082 -0
  226. package/dist/util/reportmanres.es.generated.js.map +1 -0
  227. package/dist/util/translator.d.ts +29 -0
  228. package/dist/util/translator.d.ts.map +1 -0
  229. package/dist/util/translator.js +79 -0
  230. package/dist/util/translator.js.map +1 -0
  231. package/dist/variant/coercion.d.ts +9 -0
  232. package/dist/variant/coercion.d.ts.map +1 -0
  233. package/dist/variant/coercion.js +298 -0
  234. package/dist/variant/coercion.js.map +1 -0
  235. package/dist/variant/context.d.ts +25 -0
  236. package/dist/variant/context.d.ts.map +1 -0
  237. package/dist/variant/context.js +22 -0
  238. package/dist/variant/context.js.map +1 -0
  239. package/dist/variant/variant.d.ts +193 -0
  240. package/dist/variant/variant.d.ts.map +1 -0
  241. package/dist/variant/variant.js +1229 -0
  242. package/dist/variant/variant.js.map +1 -0
  243. package/package.json +35 -4
  244. package/README.md +0 -3
@@ -0,0 +1,396 @@
1
+ // Port of Reportman.Reporting.ReportDataset: the rows of a dataset as the report navigates them.
2
+ //
3
+ // With a reader (the rows of a query) it keeps a two record buffer, so the engine can go back one
4
+ // record (a group change is detected on the next record, and the group footer prints the values of
5
+ // the previous one) but not two. With a view (rows given whole: a DataViewOverride, or the table an
6
+ // HTTP agent returns) it moves by index. The C# class is a DataTable; here it keeps its columns and
7
+ // at most two rows, and answers the evaluator as a FieldTable.
8
+ import { toUpperNet } from '../util/chars.js';
9
+ import { duplicateNameException } from './errors.js';
10
+ import { argumentException, NetException, nullReferenceException } from '../util/netexception.js';
11
+ import { Variant } from '../variant/variant.js';
12
+ import { columnValue, schemaColumnType, storedToVariant, storedTypeName, storeValue, } from './columns.js';
13
+ /** IDataReader over a materialised result: Read moves to the next row. */
14
+ export class ResultReader {
15
+ result;
16
+ pos = -1;
17
+ constructor(result) {
18
+ this.result = result;
19
+ }
20
+ get fieldCount() {
21
+ return this.result.columns.length;
22
+ }
23
+ read() {
24
+ if (this.pos < this.result.rows.length)
25
+ this.pos++;
26
+ return this.pos < this.result.rows.length;
27
+ }
28
+ /** reader[i] of the current row. */
29
+ value(i) {
30
+ const row = this.result.rows[this.pos];
31
+ if (row === undefined)
32
+ throw new Error('No data exists for the row/column.');
33
+ if (i < 0 || i >= this.result.columns.length)
34
+ throw new RangeError('Index was outside the bounds of the array.');
35
+ return row[i];
36
+ }
37
+ }
38
+ /** A DataView over rows given whole, already converted to the types of their columns. */
39
+ export class ResultView {
40
+ columns;
41
+ rows;
42
+ constructor(columns, rows) {
43
+ this.columns = columns;
44
+ this.rows = rows;
45
+ }
46
+ get count() {
47
+ return this.rows.length;
48
+ }
49
+ /**
50
+ * The view of a host result, as the DataTable the host filled: the columns keep their names
51
+ * and types, the values are stored in those types.
52
+ */
53
+ static fromResult(result, locale, culture) {
54
+ const columns = [];
55
+ for (const col of result.columns) {
56
+ if (columns.some((c) => toUpperNet(c.name) === toUpperNet(col.name)))
57
+ throw duplicateNameException(col.name);
58
+ columns.push({ name: col.name, type: col.type, maxLength: -1 });
59
+ }
60
+ const rows = result.rows.map((row) => columns.map((c, i) => storeValue(c, row[i], locale, culture)));
61
+ return new ResultView(columns, rows);
62
+ }
63
+ /**
64
+ * DataView.FindRows: the rows whose sort columns have the values of the key. A view without
65
+ * sort finds nothing (the C# ArgumentException); the view of a union has one (UnionView).
66
+ */
67
+ findRows(_key) {
68
+ throw argumentException('Find finds a row based on a Sort order, and no Sort order is specified.');
69
+ }
70
+ }
71
+ /** A row of the dataset (DataRow): its values by column index. */
72
+ export class DatasetRow {
73
+ values;
74
+ dataset;
75
+ constructor(dataset, values) {
76
+ this.dataset = dataset;
77
+ this.values = values;
78
+ }
79
+ index(name) {
80
+ const i = this.dataset.indexOfColumn(name);
81
+ if (i < 0)
82
+ throw new Error(`Column '${name}' does not belong to table .`);
83
+ return i;
84
+ }
85
+ /** row[name] as a Variant (Variant.AssignFromObject of the value). */
86
+ variant(name) {
87
+ const i = typeof name === 'number' ? name : this.index(name);
88
+ return storedToVariant(this.dataset.columns[i], this.values[i] ?? null);
89
+ }
90
+ /** row[name] as the boxed .NET value: its type and value. */
91
+ boxed(name) {
92
+ const i = typeof name === 'number' ? name : this.index(name);
93
+ const value = this.values[i] ?? null;
94
+ return { type: storedTypeName(this.dataset.columns[i], value), value };
95
+ }
96
+ }
97
+ export class ReportDataset {
98
+ fEof = false;
99
+ fInternalEof = false;
100
+ fLastFetched = 0;
101
+ fBuffer = 0;
102
+ fCurrent = 0;
103
+ fCurrentReader = null;
104
+ fCurrentView = null;
105
+ /** The rows of the view the filter found (CurrentRowSet; null: every row of the view). */
106
+ currentRowSet = null;
107
+ fViewFilter = null;
108
+ /** The rows of the two record buffer (reader mode). */
109
+ rows = [];
110
+ fColumns = [];
111
+ /** ColumnSizes: the size of each column the reader gives one for. */
112
+ columnSizes = new Map();
113
+ /** When false a new reader keeps the columns (the same SQL executed again). */
114
+ updateColumns = false;
115
+ /** OnDataChange (C# +=: a listener added twice is called twice). */
116
+ onDataChange = [];
117
+ /** DataTable.Locale: the culture strings are parsed with when they are stored. */
118
+ locale;
119
+ /** The culture values print with (value.ToString() of a string column). */
120
+ culture;
121
+ invariant;
122
+ now;
123
+ constructor(locale, culture, invariant, now) {
124
+ this.locale = locale;
125
+ this.culture = culture;
126
+ this.invariant = invariant;
127
+ this.now = now;
128
+ }
129
+ get columns() {
130
+ return this.fColumns;
131
+ }
132
+ /** DataTable.Columns.IndexOf: case-insensitive. */
133
+ indexOfColumn(name) {
134
+ const cols = this.fColumns;
135
+ for (let i = 0; i < cols.length; i++)
136
+ if (cols[i].name === name)
137
+ return i;
138
+ const upper = toUpperNet(name);
139
+ for (let i = 0; i < cols.length; i++)
140
+ if (toUpperNet(cols[i].name) === upper)
141
+ return i;
142
+ return -1;
143
+ }
144
+ /** IdenField.GetValue: the value of a column in the current row (Null without rows). */
145
+ getValue(_row, column) {
146
+ if (this.currentRowCount > 0) {
147
+ const row = this.currentRow;
148
+ if (row !== null)
149
+ return row.variant(column);
150
+ }
151
+ return Variant.null;
152
+ }
153
+ /** The number of records loaded (reader: the rows of the buffer; view: its rows). */
154
+ get currentRowCount() {
155
+ if (this.fCurrentReader !== null)
156
+ return this.rows.length;
157
+ if (this.fCurrentView !== null)
158
+ return this.currentRowSet !== null ? this.currentRowSet.length : this.fCurrentView.count;
159
+ return 0;
160
+ }
161
+ /** A reader or a view is assigned. */
162
+ get active() {
163
+ return this.fCurrentReader !== null || this.fCurrentView !== null;
164
+ }
165
+ /** The rows the view gives: the ones the filter found, or all of them. */
166
+ viewRows() {
167
+ return this.currentRowSet ?? this.fCurrentView.rows;
168
+ }
169
+ viewRow(index) {
170
+ const values = this.viewRows()[index];
171
+ if (values === undefined)
172
+ throw new NetException('IndexOutOfRangeException',
173
+ // The DataRowView[] of the filter, or the DataView
174
+ this.currentRowSet !== null ? 'Index was outside the bounds of the array.' : `There is no row at position ${index}.`);
175
+ return new DatasetRow(this, values);
176
+ }
177
+ /** The current row; null when there is none. */
178
+ get currentRow() {
179
+ if (this.fCurrentView !== null) {
180
+ const count = this.viewRows().length;
181
+ if (this.fCurrent < count)
182
+ return this.viewRow(this.fCurrent);
183
+ if (count > 0)
184
+ return this.viewRow(count - 1);
185
+ return null;
186
+ }
187
+ if (this.rows.length > this.fCurrent)
188
+ return this.rows[this.fCurrent] ?? null;
189
+ return null;
190
+ }
191
+ /** The row of the buffer that is not the current one. */
192
+ get otherRow() {
193
+ if (this.fCurrentView !== null) {
194
+ if (this.fCurrent > 0)
195
+ return this.viewRow(this.fCurrent - 1);
196
+ return this.viewRow(0);
197
+ }
198
+ if (this.rows.length < 2)
199
+ return this.rows[this.fCurrent] ?? null;
200
+ return this.rows[this.fBuffer] ?? null;
201
+ }
202
+ get currentReader() {
203
+ return this.fCurrentReader;
204
+ }
205
+ /** Assigning a reader loads its first record. */
206
+ set currentReader(value) {
207
+ if (this.fCurrentReader !== value) {
208
+ this.fCurrentReader = value;
209
+ this.doUpdateData();
210
+ }
211
+ }
212
+ get currentView() {
213
+ return this.fCurrentView;
214
+ }
215
+ set currentView(value) {
216
+ if (this.fCurrentView !== value) {
217
+ this.fCurrentView = value;
218
+ this.doUpdateData();
219
+ }
220
+ }
221
+ /** ViewFilter: the values of the sort columns of the view the rows must have (null: all the rows). */
222
+ get viewFilter() {
223
+ return this.fViewFilter;
224
+ }
225
+ set viewFilter(value) {
226
+ this.fViewFilter = value;
227
+ this.updateViewRows();
228
+ }
229
+ updateViewRows() {
230
+ this.currentRowSet = null;
231
+ if (this.fViewFilter !== null) {
232
+ if (this.fCurrentView === null)
233
+ throw nullReferenceException();
234
+ this.currentRowSet = this.fCurrentView.findRows(this.fViewFilter);
235
+ this.fCurrent = 0;
236
+ this.fEof = this.currentRowSet.length === 0;
237
+ this.fInternalEof = this.fEof;
238
+ }
239
+ }
240
+ /** No more records, or no data assigned. */
241
+ get eof() {
242
+ if (this.fCurrentReader === null && this.fCurrentView === null)
243
+ return true;
244
+ return this.fInternalEof;
245
+ }
246
+ fill(row, reader) {
247
+ const now = this.now();
248
+ const culture = this.culture();
249
+ for (let i = 0; i < this.fColumns.length; i++) {
250
+ const col = this.fColumns[i];
251
+ row.values[i] = storeValue(col, columnValue(col, reader.value(i), this.invariant, now), this.locale, culture);
252
+ }
253
+ }
254
+ newRow() {
255
+ return new DatasetRow(this, new Array(this.fColumns.length).fill(null));
256
+ }
257
+ doUpdateData() {
258
+ if (this.updateColumns)
259
+ this.fColumns = [];
260
+ this.columnSizes.clear();
261
+ this.rows.length = 0;
262
+ this.fEof = false;
263
+ this.fInternalEof = false;
264
+ if (this.fCurrentReader === null && this.fCurrentView === null) {
265
+ this.fEof = true;
266
+ this.fInternalEof = true;
267
+ return;
268
+ }
269
+ if (this.fColumns.length === 0) {
270
+ if (this.fCurrentReader !== null) {
271
+ const columns = [];
272
+ this.fCurrentReader.result.columns.forEach((info, i) => {
273
+ let acolname = toUpperNet(info.name);
274
+ if (info.size !== null && info.size !== undefined) {
275
+ if (this.columnSizes.has(acolname))
276
+ throw new Error('Repeated column: ' + acolname);
277
+ this.columnSizes.set(acolname, info.size);
278
+ }
279
+ if (acolname.length < 1)
280
+ acolname = 'Column' + String(i);
281
+ if (columns.some((c) => toUpperNet(c.name) === toUpperNet(acolname)))
282
+ throw duplicateNameException(acolname);
283
+ const type = schemaColumnType(info.type, info.declaredType);
284
+ // MaxLength of a string column: the size given (ADO.NET providers always give one, -1 when
285
+ // unknown; a host that gives none is taken as -1)
286
+ const maxLength = type === 'String' && info.size !== null && info.size !== undefined ? info.size : -1;
287
+ columns.push({ name: acolname, type, maxLength });
288
+ });
289
+ this.fColumns = columns;
290
+ }
291
+ else {
292
+ this.fColumns = this.fCurrentView.columns.map((c) => ({ name: c.name, type: c.type, maxLength: -1 }));
293
+ }
294
+ }
295
+ this.fCurrent = 0;
296
+ this.fBuffer = -1;
297
+ this.fLastFetched = 0;
298
+ if (this.fCurrentReader !== null && this.fCurrentView === null) {
299
+ if (this.fCurrentReader.read()) {
300
+ const arow = this.newRow();
301
+ this.rows.push(arow);
302
+ this.fill(arow, this.fCurrentReader);
303
+ }
304
+ else {
305
+ this.fEof = true;
306
+ this.fInternalEof = true;
307
+ }
308
+ this.fViewFilter = null;
309
+ this.updateViewRows();
310
+ }
311
+ else if (this.fCurrentView.count === 0) {
312
+ this.fEof = true;
313
+ this.fInternalEof = true;
314
+ }
315
+ }
316
+ /** Back to the first record (views only). */
317
+ first() {
318
+ if (this.fCurrentView === null)
319
+ throw new Error('First only supported memeory');
320
+ this.fCurrent = 0;
321
+ this.fEof = this.viewRows().length === 0;
322
+ this.fInternalEof = this.fEof;
323
+ }
324
+ *dataChanged() {
325
+ // C# parity: the delegate list is the one at the time of the call
326
+ for (const listener of [...this.onDataChange])
327
+ yield* listener(this);
328
+ }
329
+ /** Moves to the next record; after Prior only the current row changes. */
330
+ *next() {
331
+ if (this.fCurrentView !== null) {
332
+ if (this.fCurrent < this.viewRows().length - 1) {
333
+ this.fCurrent++;
334
+ yield* this.dataChanged();
335
+ return true;
336
+ }
337
+ this.fInternalEof = true;
338
+ this.fEof = true;
339
+ return false;
340
+ }
341
+ const reader = this.fCurrentReader;
342
+ if (reader === null)
343
+ return false;
344
+ if (this.fLastFetched !== this.fCurrent) {
345
+ this.fCurrent = this.fLastFetched;
346
+ this.fInternalEof = this.fEof;
347
+ yield* this.dataChanged();
348
+ return true;
349
+ }
350
+ if (this.fEof)
351
+ return false;
352
+ this.fEof = !reader.read();
353
+ if (this.fEof) {
354
+ this.fInternalEof = true;
355
+ return false;
356
+ }
357
+ let arow;
358
+ if (this.rows.length < 2) {
359
+ this.fLastFetched = this.rows.length;
360
+ this.fBuffer = this.fCurrent;
361
+ this.fCurrent = this.fLastFetched;
362
+ arow = this.newRow();
363
+ this.rows.push(arow);
364
+ }
365
+ else {
366
+ arow = this.rows[this.fBuffer];
367
+ this.fLastFetched = this.fBuffer;
368
+ this.fBuffer = this.fCurrent;
369
+ this.fCurrent = this.fLastFetched;
370
+ }
371
+ this.fill(arow, reader);
372
+ yield* this.dataChanged();
373
+ return true;
374
+ }
375
+ /** Moves to the previous record (only one back). */
376
+ *prior() {
377
+ if (this.fCurrentView !== null) {
378
+ if (this.fCurrent === 0)
379
+ return false;
380
+ this.fCurrent--;
381
+ yield* this.dataChanged();
382
+ return true;
383
+ }
384
+ if (this.fCurrentReader === null)
385
+ return false;
386
+ if (this.rows.length < 2)
387
+ return false;
388
+ if (this.fLastFetched === this.fCurrent)
389
+ this.fCurrent = this.fBuffer;
390
+ else
391
+ this.fCurrent = this.fLastFetched;
392
+ yield* this.dataChanged();
393
+ return true;
394
+ }
395
+ }
396
+ //# sourceMappingURL=reportdataset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportdataset.js","sourceRoot":"","sources":["../../src/data/reportdataset.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,EAAE;AACF,kGAAkG;AAClG,mGAAmG;AACnG,oGAAoG;AACpG,oGAAoG;AACpG,+DAA+D;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EACL,WAAW,EAEX,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,UAAU,GAEX,MAAM,cAAc,CAAC;AAItB,0EAA0E;AAC1E,MAAM,OAAO,YAAY;IACd,MAAM,CAAc;IACrB,GAAG,GAAG,CAAC,CAAC,CAAC;IAEjB,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IACpC,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;YAAE,IAAI,C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,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;;YACjE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC;QACvC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ import type { DataColumnInfo, DataValue, QueryCommand, QueryParameter, QueryResult } from './host.js';
2
+ /** A value as plain data: what a structured clone keeps (Date, bigint, Uint8Array) is left as it is. */
3
+ export type TransferValue = null | undefined | string | number | bigint | boolean | Uint8Array | Date | {
4
+ readonly decimal: readonly [string, number, boolean];
5
+ } | {
6
+ readonly dateTime: readonly [bigint, number];
7
+ };
8
+ export declare function encodeDataValue(v: DataValue): TransferValue;
9
+ export declare function decodeDataValue(v: TransferValue): DataValue;
10
+ /** A command as plain data. */
11
+ export interface TransferCommand {
12
+ readonly sql: string;
13
+ readonly parameters: readonly (Omit<QueryParameter, 'value'> & {
14
+ readonly value: TransferValue;
15
+ })[];
16
+ readonly dataset: string;
17
+ }
18
+ export declare function encodeQueryCommand(c: QueryCommand): TransferCommand;
19
+ export declare function decodeQueryCommand(c: TransferCommand): QueryCommand;
20
+ /** A result as plain data. */
21
+ export interface TransferResult {
22
+ readonly columns: readonly DataColumnInfo[];
23
+ readonly rows: readonly (readonly TransferValue[])[];
24
+ }
25
+ export declare function encodeQueryResult(r: QueryResult): TransferResult;
26
+ export declare function decodeQueryResult(r: TransferResult): QueryResult;
27
+ /**
28
+ * An exception as plain data: its .NET type (a NetException), its name and message, the values of
29
+ * its own fields (a driver's exception keeps its error number, SQLSTATE, status entries...) and its
30
+ * cause.
31
+ */
32
+ export interface TransferError {
33
+ readonly netType: string | undefined;
34
+ readonly name: string;
35
+ readonly message: string;
36
+ readonly fields: Readonly<Record<string, unknown>>;
37
+ readonly cause?: TransferError;
38
+ }
39
+ export declare function encodeError(e: unknown): TransferError;
40
+ /**
41
+ * The exception of the plain data. A driver rebuilds its own exception classes with `rebuild` (it
42
+ * returns undefined for the others): a NetException of another type, or a plain Error with its
43
+ * name, otherwise.
44
+ */
45
+ export declare function decodeError(w: TransferError, rebuild?: (w: TransferError) => Error | undefined): Error;
46
+ //# sourceMappingURL=transfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../src/data/transfer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEtG,wGAAwG;AACxG,MAAM,MAAM,aAAa,GACrB,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,UAAU,GACV,IAAI,GACJ;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAErD,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,aAAa,CAI3D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,CAM3D;AAED,+BAA+B;AAC/B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;KAAE,CAAC,EAAE,CAAC;IACpG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,eAAe,CAMnE;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,YAAY,CAEnE;AAED,8BAA8B;AAC9B,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,EAAE,CAAC;CACtD;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,GAAG,cAAc,CAEhE;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,cAAc,GAAG,WAAW,CAEhE;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC;AAwBD,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,aAAa,CAUrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,KAAK,GAAG,SAAS,GAAG,KAAK,CActG"}
@@ -0,0 +1,100 @@
1
+ // The plain data of a data connection that answers from another thread (the worker of a synchronous
2
+ // driver: the calls of the engine wait for it): the values of the engine (CsDecimal and RpDateTime
3
+ // are classes, a structured clone would lose them), the commands, the results and the exceptions
4
+ // with their .NET type and their own fields.
5
+ import { CsDecimal } from '../util/decimal.js';
6
+ import { RpDateTime } from '../util/datetime.js';
7
+ import { NetException } from '../util/netexception.js';
8
+ export function encodeDataValue(v) {
9
+ if (v instanceof CsDecimal)
10
+ return { decimal: [v.mag.toString(), v.scale, v.negative] };
11
+ if (v instanceof RpDateTime)
12
+ return { dateTime: [v.ticks, v.kind] };
13
+ return v;
14
+ }
15
+ export function decodeDataValue(v) {
16
+ if (v !== null && typeof v === 'object' && !(v instanceof Uint8Array) && !(v instanceof Date)) {
17
+ if ('decimal' in v)
18
+ return CsDecimal.fromParts(BigInt(v.decimal[0]), v.decimal[1], v.decimal[2]);
19
+ return RpDateTime.fromTicks(v.dateTime[0], v.dateTime[1]);
20
+ }
21
+ return v;
22
+ }
23
+ export function encodeQueryCommand(c) {
24
+ return {
25
+ sql: c.sql,
26
+ parameters: c.parameters.map((p) => ({ ...p, value: encodeDataValue(p.value) })),
27
+ dataset: c.dataset,
28
+ };
29
+ }
30
+ export function decodeQueryCommand(c) {
31
+ return { sql: c.sql, parameters: c.parameters.map((p) => ({ ...p, value: decodeDataValue(p.value) })), dataset: c.dataset };
32
+ }
33
+ export function encodeQueryResult(r) {
34
+ return { columns: r.columns, rows: r.rows.map((row) => row.map(encodeDataValue)) };
35
+ }
36
+ export function decodeQueryResult(r) {
37
+ return { columns: r.columns, rows: r.rows.map((row) => row.map(decodeDataValue)) };
38
+ }
39
+ /** Plain data: primitives, and arrays and plain objects of them. */
40
+ function isPlain(v, depth = 0) {
41
+ if (v === null || v === undefined)
42
+ return true;
43
+ const t = typeof v;
44
+ if (t === 'string' || t === 'number' || t === 'bigint' || t === 'boolean')
45
+ return true;
46
+ if (t !== 'object' || depth > 8)
47
+ return false;
48
+ if (Array.isArray(v))
49
+ return v.every((x) => isPlain(x, depth + 1));
50
+ const proto = Object.getPrototypeOf(v);
51
+ if (proto !== Object.prototype && proto !== null)
52
+ return false;
53
+ return Object.values(v).every((x) => isPlain(x, depth + 1));
54
+ }
55
+ /** The own fields of an exception that cross: plain data only (no functions, no class instances). */
56
+ function plainFields(e) {
57
+ const fields = {};
58
+ for (const [k, v] of Object.entries(e)) {
59
+ if (k === 'netType' || k === 'name' || k === 'message' || k === 'stack' || k === 'cause')
60
+ continue;
61
+ if (isPlain(v))
62
+ fields[k] = v;
63
+ }
64
+ return fields;
65
+ }
66
+ export function encodeError(e) {
67
+ const err = e instanceof Error ? e : new Error(String(e));
68
+ const cause = err.cause;
69
+ return {
70
+ netType: err instanceof NetException ? err.netType : undefined,
71
+ name: err.name,
72
+ message: err.message,
73
+ fields: plainFields(err),
74
+ cause: cause instanceof Error ? encodeError(cause) : undefined,
75
+ };
76
+ }
77
+ /**
78
+ * The exception of the plain data. A driver rebuilds its own exception classes with `rebuild` (it
79
+ * returns undefined for the others): a NetException of another type, or a plain Error with its
80
+ * name, otherwise.
81
+ */
82
+ export function decodeError(w, rebuild) {
83
+ let e = rebuild?.(w);
84
+ if (e === undefined) {
85
+ if (w.netType !== undefined)
86
+ e = new NetException(w.netType, w.message);
87
+ else {
88
+ e = new Error(w.message);
89
+ e.name = w.name;
90
+ }
91
+ for (const [k, v] of Object.entries(w.fields)) {
92
+ if (!(k in e))
93
+ e[k] = v;
94
+ }
95
+ }
96
+ if (w.cause !== undefined)
97
+ e.cause = decodeError(w.cause, rebuild);
98
+ return e;
99
+ }
100
+ //# sourceMappingURL=transfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../src/data/transfer.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,mGAAmG;AACnG,iGAAiG;AACjG,6CAA6C;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAgBvD,MAAM,UAAU,eAAe,CAAC,CAAY;IAC1C,IAAI,CAAC,YAAY,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxF,IAAI,CAAC,YAAY,UAAU;QAAE,OAAO,EAAE,QAAQ,EA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,CAAC,CAAC,CAAC,CAAC,SAAS;KAC/D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,CAAgB,EAAE,OAAiD;IAC7F,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACpB,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;YAAE,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;aACnE,CAAC;YACJ,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;QAClB,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAAG,CAAwC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IACD,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS;QAAG,CAAyB,CAAC,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5F,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,88 @@
1
+ import type { CultureInfo } from '../util/culture.js';
2
+ import { RpDateTime } from '../util/datetime.js';
3
+ import { type DataColumn, type StoredValue } from './columns.js';
4
+ import type { DataColumnType, DataValue } from './host.js';
5
+ import { ResultView } from './reportdataset.js';
6
+ /** A DataTable of a union: its columns and its rows. */
7
+ export interface UnionTable {
8
+ readonly columns: DataColumn[];
9
+ readonly rows: StoredValue[][];
10
+ }
11
+ /** The cultures and the clock the values of a union are converted and compared with. */
12
+ export interface UnionContext {
13
+ /** CultureInfo.CurrentCulture while the union is built (also the Locale of its DataTables). */
14
+ readonly culture: CultureInfo;
15
+ readonly invariant: CultureInfo;
16
+ /** The date of a text with a time only (DateTime.Parse). */
17
+ readonly now: RpDateTime;
18
+ }
19
+ /** The .NET type of a boxed value (a column type but Object). */
20
+ type NetType = Exclude<DataColumnType, 'Object'>;
21
+ /** A value of a row as the boxed object C# handles: its .NET type and its value; null is DBNull. */
22
+ interface Boxed {
23
+ readonly type: NetType;
24
+ readonly value: Exclude<StoredValue, null>;
25
+ }
26
+ /** The comparer of texts of a culture: IgnoreCase | IgnoreKanaType | IgnoreWidth (see above). */
27
+ export declare function unionCollator(culture: CultureInfo): Intl.Collator;
28
+ /** Strings.FromSemiColon: the parts between semicolons, empty ones too ("" gives one part). */
29
+ export declare function fromSemiColon(text: string): string[];
30
+ /** Strings.RemoveBlanks. */
31
+ export declare function removeBlanks(list: readonly string[]): string[];
32
+ /** DataTable.Clone: the columns, no rows. */
33
+ export declare function cloneTable(table: UnionTable): UnionTable;
34
+ /**
35
+ * DataColumnCollection.IndexOf: the column with that name, else the only one with that name
36
+ * without regard to case (-1 when there is none, or more than one).
37
+ */
38
+ export declare function indexOfColumn(table: UnionTable, name: string): number;
39
+ /**
40
+ * ConvertUnionValue: a value converted to the type of the column it goes to (as a Variant
41
+ * assigned to a field of the Delphi engine is): the value itself when it is of that type,
42
+ * Convert.ToString(value, InvariantCulture) for a text column, otherwise
43
+ * Convert.ChangeType(value, type, InvariantCulture). The value goes into a row of a union, so it
44
+ * is the value the DataTable gives back (a double -0.0 is 0.0).
45
+ */
46
+ export declare function convertUnionValue(v: Boxed | null, type: DataColumnType, ctx: UnionContext): StoredValue;
47
+ /** OrderedRows by the names of the index fields. */
48
+ export declare function orderedRows(table: UnionTable, indexFields: readonly string[], ctx: UnionContext): StoredValue[][];
49
+ /**
50
+ * ExtractUnionFields: the dataset alias of a union entry, "ALIAS" or "ALIAS-FIELD1;FIELD2", and
51
+ * its common fields in upper case (the first '-' ends the alias).
52
+ */
53
+ export declare function extractUnionFields(entry: string): {
54
+ alias: string;
55
+ commonFields: string[];
56
+ };
57
+ /**
58
+ * CombineAddDataset: adds the rows of a dataset to the result of a union. The result takes the
59
+ * columns of the first one, and the values of each row fill its columns by position. With
60
+ * grouping, a row whose index fields (by position) have the values of a row already there adds
61
+ * its other values to it (numbers are added, texts joined) instead.
62
+ */
63
+ export declare function combineAddDataset(client: UnionTable | null, data: UnionTable, group: boolean, indexFields: readonly string[], alias: string, fewerFieldsText: string, ctx: UnionContext): UnionTable;
64
+ /**
65
+ * CombineParallel: a parallel union. The columns of the first dataset, an integer column named as
66
+ * the prefix (0 for the rows only the first one has, 1 for the rows the second one reaches), and
67
+ * the columns of the second one with the prefix but its common fields. With common fields each
68
+ * row of the second dataset fills the first row of the first one with the same values that it
69
+ * has not filled yet, or a new row; the result is ordered by the prefix column and then by the
70
+ * common fields. Without them the rows are paired by position.
71
+ */
72
+ export declare function combineParallel(data1: UnionTable, rows1: readonly (readonly StoredValue[])[], data2: UnionTable, prefix: string, commonFields: readonly string[], originalFields: readonly string[], ctx: UnionContext): UnionTable;
73
+ /**
74
+ * The DataView of a union: the rows of its table sorted by the columns of its sort (the rows with
75
+ * the same values in the order of the table), and FindRows on them.
76
+ */
77
+ export declare class UnionView extends ResultView {
78
+ private readonly sort;
79
+ private readonly ctx;
80
+ constructor(table: UnionTable, sort: string, ctx: UnionContext);
81
+ /**
82
+ * DataView.FindRows: the rows whose sort columns have the values of the key, each value
83
+ * converted to the type of its column first.
84
+ */
85
+ findRows(key: readonly DataValue[]): readonly (readonly StoredValue[])[];
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=union.d.ts.map