@reportman/engine 0.0.0-stage → 4.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 (252) 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 +1974 -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/delphidateformat.d.ts +34 -0
  196. package/dist/util/delphidateformat.d.ts.map +1 -0
  197. package/dist/util/delphidateformat.js +247 -0
  198. package/dist/util/delphidateformat.js.map +1 -0
  199. package/dist/util/delphiformatsettings.generated.d.ts +3 -0
  200. package/dist/util/delphiformatsettings.generated.d.ts.map +1 -0
  201. package/dist/util/delphiformatsettings.generated.js +15 -0
  202. package/dist/util/delphiformatsettings.generated.js.map +1 -0
  203. package/dist/util/delphitext.d.ts +40 -0
  204. package/dist/util/delphitext.d.ts.map +1 -0
  205. package/dist/util/delphitext.js +408 -0
  206. package/dist/util/delphitext.js.map +1 -0
  207. package/dist/util/doubleutil.d.ts +30 -0
  208. package/dist/util/doubleutil.d.ts.map +1 -0
  209. package/dist/util/doubleutil.js +651 -0
  210. package/dist/util/doubleutil.js.map +1 -0
  211. package/dist/util/inflate.d.ts +7 -0
  212. package/dist/util/inflate.d.ts.map +1 -0
  213. package/dist/util/inflate.js +256 -0
  214. package/dist/util/inflate.js.map +1 -0
  215. package/dist/util/netexception.d.ts +59 -0
  216. package/dist/util/netexception.d.ts.map +1 -0
  217. package/dist/util/netexception.js +94 -0
  218. package/dist/util/netexception.js.map +1 -0
  219. package/dist/util/numberformat.d.ts +14 -0
  220. package/dist/util/numberformat.d.ts.map +1 -0
  221. package/dist/util/numberformat.js +828 -0
  222. package/dist/util/numberformat.js.map +1 -0
  223. package/dist/util/numberparse.d.ts +49 -0
  224. package/dist/util/numberparse.d.ts.map +1 -0
  225. package/dist/util/numberparse.js +568 -0
  226. package/dist/util/numberparse.js.map +1 -0
  227. package/dist/util/reportmanres.en.generated.d.ts +2 -0
  228. package/dist/util/reportmanres.en.generated.d.ts.map +1 -0
  229. package/dist/util/reportmanres.en.generated.js +2082 -0
  230. package/dist/util/reportmanres.en.generated.js.map +1 -0
  231. package/dist/util/reportmanres.es.generated.d.ts +2 -0
  232. package/dist/util/reportmanres.es.generated.d.ts.map +1 -0
  233. package/dist/util/reportmanres.es.generated.js +2082 -0
  234. package/dist/util/reportmanres.es.generated.js.map +1 -0
  235. package/dist/util/translator.d.ts +29 -0
  236. package/dist/util/translator.d.ts.map +1 -0
  237. package/dist/util/translator.js +79 -0
  238. package/dist/util/translator.js.map +1 -0
  239. package/dist/variant/coercion.d.ts +9 -0
  240. package/dist/variant/coercion.d.ts.map +1 -0
  241. package/dist/variant/coercion.js +298 -0
  242. package/dist/variant/coercion.js.map +1 -0
  243. package/dist/variant/context.d.ts +30 -0
  244. package/dist/variant/context.d.ts.map +1 -0
  245. package/dist/variant/context.js +22 -0
  246. package/dist/variant/context.js.map +1 -0
  247. package/dist/variant/variant.d.ts +193 -0
  248. package/dist/variant/variant.d.ts.map +1 -0
  249. package/dist/variant/variant.js +1235 -0
  250. package/dist/variant/variant.js.map +1 -0
  251. package/package.json +35 -4
  252. package/README.md +0 -3
@@ -0,0 +1,132 @@
1
+ import type { DatabaseInfo, DataInfo } from '@reportman/lib';
2
+ import type { CsDecimal } from '../util/decimal.js';
3
+ import type { RpDateTime } from '../util/datetime.js';
4
+ import type { MaybePromise } from './op.js';
5
+ /**
6
+ * The .NET type of a column (DataColumn.DataType): the types an ADO.NET reader gives. 'Binary' is
7
+ * byte[]; 'Object' a column of mixed values. The engine converts every value it stores to the type
8
+ * of its column, as a DataTable does (see columns.ts).
9
+ */
10
+ export type DataColumnType = 'String' | 'Int64' | 'Int32' | 'Int16' | 'Byte' | 'Boolean' | 'Double' | 'Single' | 'Decimal' | 'DateTime' | 'Binary' | 'Object';
11
+ /** A column of a result: a row of IDataReader.GetSchemaTable. */
12
+ export interface DataColumnInfo {
13
+ /** ColumnName as the database gives it; the engine upper-cases it, as C# does. */
14
+ name: string;
15
+ /** DataType. */
16
+ type: DataColumnType;
17
+ /** ColumnSize (MaxLength of a string column); null or absent when the provider gives none. */
18
+ size?: number | null;
19
+ /**
20
+ * DataTypeName: the type the column was declared with (SQLite "DATE", "VARCHAR"...), without
21
+ * its size. A String, Int64 or Double column declared DATE, DATETIME or TIMESTAMP is a date
22
+ * column (SQLite keeps dates as text or numbers), as in the C# and Delphi engines.
23
+ */
24
+ declaredType?: string | null;
25
+ }
26
+ /**
27
+ * A value of a row: null or undefined (DBNull), string, number, bigint (Int64), boolean,
28
+ * Uint8Array (byte[]), CsDecimal, RpDateTime or a JavaScript Date (its local fields). A number in
29
+ * an integer column stays an integer; other values are converted to the column type as C# does.
30
+ */
31
+ export type DataValue = null | undefined | string | number | bigint | boolean | Uint8Array | CsDecimal | RpDateTime | Date;
32
+ /** The rows of a query (a materialised IDataReader): its columns and its rows, in order. */
33
+ export interface QueryResult {
34
+ columns: readonly DataColumnInfo[];
35
+ rows: readonly (readonly DataValue[])[];
36
+ }
37
+ /** System.Data.DbType of a parameter, as the engine types it (Variant.GetDbType). */
38
+ export type ParameterDbType = 'Object' | 'Boolean' | 'Byte' | 'SByte' | 'Int32' | 'Int64' | 'Decimal' | 'Double' | 'DateTime' | 'Binary' | 'String';
39
+ /**
40
+ * The .NET type of a parameter value (the object C# assigns to IDbDataParameter.Value):
41
+ * 'Null' is C# null (no value: ADO.NET providers refuse it, Microsoft.Data.Sqlite with "Value must
42
+ * be set."), 'DBNull' a database NULL, 'Char' a one-character string.
43
+ */
44
+ export type ParameterValueType = 'Null' | 'DBNull' | 'Boolean' | 'Byte' | 'Char' | 'Int32' | 'Int64' | 'Decimal' | 'Double' | 'DateTime' | 'String' | 'Binary' | 'Object';
45
+ /** A named parameter of a command. */
46
+ export interface QueryParameter {
47
+ /** The parameter alias, without prefix (GETVALUEFROMSQL names it "@" + alias, as C#). */
48
+ readonly name: string;
49
+ /**
50
+ * The value: undefined for 'Null', null for 'DBNull', boolean, number (Byte, Int32, Double),
51
+ * bigint (Int64), string (String, Char), CsDecimal, RpDateTime, Uint8Array.
52
+ */
53
+ readonly value: DataValue;
54
+ readonly valueType: ParameterValueType;
55
+ readonly dbType: ParameterDbType;
56
+ }
57
+ /** A command to execute (IDbCommand.ExecuteReader). */
58
+ export interface QueryCommand {
59
+ /** The SQL, with its `:NAME` / `@NAME` placeholders. */
60
+ readonly sql: string;
61
+ readonly parameters: readonly QueryParameter[];
62
+ /** The dataset alias the command belongs to ("" for GETVALUEFROMSQL). */
63
+ readonly dataset: string;
64
+ }
65
+ /** An open connection (IDbConnection with its implicit transaction). */
66
+ export interface DataConnection {
67
+ /** Executes a query and returns its columns and rows. */
68
+ query(command: QueryCommand): MaybePromise<QueryResult>;
69
+ /** Ends the implicit transaction (commit true, as DisConnect; false rolls back) and closes. */
70
+ close(commit: boolean): MaybePromise<void>;
71
+ }
72
+ /** System.Data.IsolationLevel names. */
73
+ export type IsolationLevelName = 'Unspecified' | 'Chaos' | 'ReadUncommitted' | 'ReadCommitted' | 'RepeatableRead' | 'Serializable' | 'Snapshot';
74
+ /** What the engine knows of a report connection when it asks the host to open it. */
75
+ export interface ConnectionRequest {
76
+ /** The report connection, as the report has it. */
77
+ readonly database: DatabaseInfo;
78
+ readonly alias: string;
79
+ /**
80
+ * The connection string C# would use: the report parameter ALIAS_ADOCONNECTIONSTRING, else
81
+ * ADOCONNECTIONSTRING, else the connection's own; for a SQLite connection of the Delphi engine,
82
+ * "Data Source=" + its DBPARAM_DATABASE.
83
+ */
84
+ readonly connectionString: string;
85
+ /** The provider factory C# would use ("SQLiteCore" for a SQLite connection of the Delphi engine). */
86
+ readonly providerFactory: string;
87
+ /** A SQLite connection of the Delphi engine (DatabaseInfo.IsEngineSqlite). */
88
+ readonly engineSqlite: boolean;
89
+ /** The report parameter of a connection parameter (ALIAS_DBPARAM_NAME, else DBPARAM_NAME): "" when absent. */
90
+ dbParam(name: string): string;
91
+ /** The isolation level of the implicit transaction (TransIsolation). */
92
+ readonly isolationLevel: IsolationLevelName;
93
+ }
94
+ /** What the engine knows of a dataset when it asks the host for its rows. */
95
+ export interface DatasetRequest {
96
+ readonly dataset: DataInfo;
97
+ readonly alias: string;
98
+ }
99
+ /** The data host. */
100
+ export interface DataHost {
101
+ /** Opens a connection and starts its implicit transaction (DatabaseInfo.Connect). */
102
+ connect(request: ConnectionRequest): MaybePromise<DataConnection>;
103
+ /**
104
+ * The rows of a dataset given by the host (DataViewOverride), or undefined to run its SQL. The
105
+ * engine asks it each time the dataset opens. As in C#, the report connection of the dataset is
106
+ * still opened (connect), so a host that only gives rows returns a connection that does nothing.
107
+ */
108
+ datasetRows?(request: DatasetRequest): MaybePromise<QueryResult | undefined>;
109
+ }
110
+ /** A host without databases: every connection fails, the error naming it. */
111
+ export declare const noDataHost: DataHost;
112
+ /** A named placeholder found by rewriteNamedParameters. */
113
+ export interface NamedPlaceholder {
114
+ /** The name without prefix. */
115
+ name: string;
116
+ /** The prefix (":", "@" or "$"). */
117
+ prefix: string;
118
+ /** Position of the prefix in the original SQL. */
119
+ index: number;
120
+ }
121
+ /**
122
+ * Rewrites the named placeholders of a SQL text (`:NAME`, `@NAME`, `$NAME`) with what `replace`
123
+ * returns for each one (for example "?" or "$1"), and lists them in order. String literals ('...'
124
+ * with '' inside), quoted identifiers ("...", [...], `...`), line comments (--) and block
125
+ * comments are left as they are, and so are `::` casts, `@@` variables and a prefix not followed
126
+ * by a name.
127
+ */
128
+ export declare function rewriteNamedParameters(sql: string, replace: (placeholder: NamedPlaceholder, ordinal: number) => string, prefixes?: string): {
129
+ sql: string;
130
+ placeholders: NamedPlaceholder[];
131
+ };
132
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/data/host.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,MAAM,GACN,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,UAAU,GACV,QAAQ,GACR,QAAQ,CAAC;AAEb,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,8FAA8F;IAC9F,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;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,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAUD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,EACnE,QAAQ,SAAQ,GACf;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,gBAAgB,EAAE,CAAA;CAAE,CA4DnD"}
@@ -0,0 +1,108 @@
1
+ // The data host contract: what the engine asks of the program that runs a report, in the role
2
+ // ADO.NET plays for the C# engine (DbProviderFactory, IDbConnection, IDbCommand, IDataReader).
3
+ //
4
+ // The engine never opens a database. For each report connection (DatabaseInfo) it asks the host
5
+ // for a DataConnection, runs the SQL of each dataset (DataInfo) through it with typed named
6
+ // parameters, and reads columns and rows back. A host may also give the rows of a dataset itself
7
+ // (the C# DataViewOverride): that is how a dataset comes from a REST API.
8
+ //
9
+ // Placeholders. The engine sends the SQL of the report as it is, after the text substitutions of
10
+ // the substitution parameters: named placeholders written `:NAME` (the Delphi form, the one the
11
+ // sample reports use) or `@NAME` (the .NET form, also what ConvertToDotNet writes). A parameter
12
+ // arrives with its name without prefix (the parameter alias), as C# names its IDbDataParameter;
13
+ // a provider binds it to `:NAME`, `@NAME` or `$NAME`, as Microsoft.Data.Sqlite does. A driver
14
+ // for a database with other placeholders (`?`, `$1`) rewrites them with rewriteNamedParameters,
15
+ // which skips string literals, quoted identifiers and comments.
16
+ //
17
+ // Transactions. As in C#, opening a connection starts an implicit transaction (with the isolation
18
+ // level of the report connection) and every command runs inside it, the ones of the datasets and
19
+ // the one of GETVALUEFROMSQL; closing the connection at the end of the report (or when the report
20
+ // fails) commits it.
21
+ //
22
+ // Results are materialised (every row at once); a streaming variant may come later.
23
+ //
24
+ // Host methods may return plain values or promises. A dataset opened from inside an expression
25
+ // (a field of a dataset not open yet, REOPEN, GETVALUEFROMSQL) needs plain values: see op.ts.
26
+ /** A host without databases: every connection fails, the error naming it. */
27
+ export const noDataHost = {
28
+ connect(request) {
29
+ throw new Error('No data host: the report connection ' + request.alias + ' cannot be opened');
30
+ },
31
+ };
32
+ function isNameStart(c) {
33
+ return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c === '_' || c.charCodeAt(0) > 127;
34
+ }
35
+ function isNameChar(c) {
36
+ return isNameStart(c) || (c >= '0' && c <= '9');
37
+ }
38
+ /**
39
+ * Rewrites the named placeholders of a SQL text (`:NAME`, `@NAME`, `$NAME`) with what `replace`
40
+ * returns for each one (for example "?" or "$1"), and lists them in order. String literals ('...'
41
+ * with '' inside), quoted identifiers ("...", [...], `...`), line comments (--) and block
42
+ * comments are left as they are, and so are `::` casts, `@@` variables and a prefix not followed
43
+ * by a name.
44
+ */
45
+ export function rewriteNamedParameters(sql, replace, prefixes = ':@$') {
46
+ const placeholders = [];
47
+ let out = '';
48
+ let i = 0;
49
+ const n = sql.length;
50
+ while (i < n) {
51
+ const c = sql.charAt(i);
52
+ if (c === "'" || c === '"' || c === '`' || c === '[') {
53
+ const close = c === '[' ? ']' : c;
54
+ let j = i + 1;
55
+ while (j < n) {
56
+ if (sql.charAt(j) === close) {
57
+ if (close !== ']' && sql.charAt(j + 1) === close) {
58
+ j += 2;
59
+ continue;
60
+ }
61
+ break;
62
+ }
63
+ j++;
64
+ }
65
+ out += sql.substring(i, Math.min(j + 1, n));
66
+ i = j + 1;
67
+ continue;
68
+ }
69
+ if (c === '-' && sql.charAt(i + 1) === '-') {
70
+ let j = sql.indexOf('\n', i);
71
+ if (j < 0)
72
+ j = n;
73
+ out += sql.substring(i, j);
74
+ i = j;
75
+ continue;
76
+ }
77
+ if (c === '/' && sql.charAt(i + 1) === '*') {
78
+ let j = sql.indexOf('*/', i + 2);
79
+ j = j < 0 ? n : j + 2;
80
+ out += sql.substring(i, j);
81
+ i = j;
82
+ continue;
83
+ }
84
+ if (prefixes.includes(c)) {
85
+ const next = sql.charAt(i + 1);
86
+ // "::" casts and "@@" variables are not parameters
87
+ if (next === c) {
88
+ out += c + next;
89
+ i += 2;
90
+ continue;
91
+ }
92
+ if (next.length > 0 && isNameStart(next)) {
93
+ let j = i + 2;
94
+ while (j < n && isNameChar(sql.charAt(j)))
95
+ j++;
96
+ const placeholder = { name: sql.substring(i + 1, j), prefix: c, index: i };
97
+ out += replace(placeholder, placeholders.length);
98
+ placeholders.push(placeholder);
99
+ i = j;
100
+ continue;
101
+ }
102
+ }
103
+ out += c;
104
+ i++;
105
+ }
106
+ return { sql: out, placeholders };
107
+ }
108
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/data/host.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,+FAA+F;AAC/F,EAAE;AACF,gGAAgG;AAChG,4FAA4F;AAC5F,iGAAiG;AACjG,0EAA0E;AAC1E,EAAE;AACF,iGAAiG;AACjG,gGAAgG;AAChG,gGAAgG;AAChG,gGAAgG;AAChG,8FAA8F;AAC9F,gGAAgG;AAChG,gEAAgE;AAChE,EAAE;AACF,kGAAkG;AAClG,iGAAiG;AACjG,kGAAkG;AAClG,qBAAqB;AACrB,EAAE;AACF,oFAAoF;AACpF,EAAE;AACF,+FAA+F;AAC/F,8FAA8F;AAwK9F,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAa;IAClC,OAAO,CAAC,OAA0B;QAChC,MAAM,IAAI,KAAK,CAAC,sCAAsC,GAAG,OAAO,CAAC,KAAK,GAAG,mBAAmB,CAAC,CAAC;IAChG,CAAC;CACF,CAAC;AAYF,SAAS,WAAW,CAAC,CAAS;IAC5B,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,C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IAAI,CAAC;gBAChB,CAAC,IAAI,CAAC,CAAC;gBACP,SAAS;YACX,CAAC;YACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACd,OAAO,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;oBAAE,CAAC,EAAE,CAAC;gBAC/C,MAAM,WAAW,GAAqB,EAAE,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;gBAC7F,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;gBACjD,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAC/B,CAAC,GAAG,CAAC,CAAC;gBACN,SAAS;YACX,CAAC;QACH,CAAC;QACD,GAAG,IAAI,CAAC,CAAC;QACT,CAAC,EAAE,CAAC;IACN,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /** An operation that may wait for the host: a generator that yields host results. */
2
+ export type Op<T> = Generator<unknown, T, unknown>;
3
+ /** A value or a promise of it: what a host method may return. */
4
+ export type MaybePromise<T> = T | PromiseLike<T>;
5
+ /** Waits for a host result inside an Op: `const r = yield* wait(host.query(...))`. */
6
+ export declare function wait<T>(value: MaybePromise<T>): Op<T>;
7
+ /** Runs an Op, awaiting the promises it yields. */
8
+ export declare function runAsync<T>(op: Op<T>): Promise<T>;
9
+ /** The error of an operation that needs a synchronous host and got a promise. */
10
+ export declare class SynchronousDataRequiredError extends Error {
11
+ constructor(what: string);
12
+ }
13
+ /**
14
+ * Whether a run failed because the report needs a synchronous data host: the error itself, or the
15
+ * error of the report item that was evaluating (a ReportException keeps only its message, as in C#).
16
+ * A host can then run the report again with a synchronous driver.
17
+ */
18
+ export declare function isSynchronousDataRequired(error: unknown): boolean;
19
+ /** Runs an Op synchronously; a promise from the host fails with SynchronousDataRequiredError. */
20
+ export declare function runSync<T>(op: Op<T>, what: string): T;
21
+ //# sourceMappingURL=op.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"op.d.ts","sourceRoot":"","sources":["../../src/data/op.ts"],"names":[],"mappings":"AAWA,qFAAqF;AACrF,MAAM,MAAM,EAAE,CAAC,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;AAEnD,iEAAiE;AACjE,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAUjD,sFAAsF;AACtF,wBAAiB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAEtD;AAED,mDAAmD;AACnD,wBAAsB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBvD;AAMD,iFAAiF;AACjF,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,IAAI,EAAE,MAAM;CASzB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGjE;AAED,iGAAiG;AACjG,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAmBrD"}
@@ -0,0 +1,97 @@
1
+ // How the engine reaches the host's data without making the evaluator asynchronous.
2
+ //
3
+ // The C# engine opens datasets, moves records and re-executes details synchronously, sometimes from
4
+ // inside an expression (a field of a dataset that is not open yet opens it; REOPEN; GETVALUEFROMSQL).
5
+ // Here every operation that may reach the host is written once as a generator (an Op): it yields the
6
+ // value the host returned (a plain value or a promise) and is resumed with the resolved value.
7
+ //
8
+ // - runAsync drives an Op awaiting what it yields: the asynchronous API (opening, next record, pages).
9
+ // - runSync drives an Op inside a synchronous evaluation: it works when the host answers with plain
10
+ // values (node:sqlite does) and fails with a clear error when the host returns a promise.
11
+ function isThenable(value) {
12
+ return (value !== null &&
13
+ (typeof value === 'object' || typeof value === 'function') &&
14
+ typeof value.then === 'function');
15
+ }
16
+ /** Waits for a host result inside an Op: `const r = yield* wait(host.query(...))`. */
17
+ export function* wait(value) {
18
+ return (yield value);
19
+ }
20
+ /** Runs an Op, awaiting the promises it yields. */
21
+ export async function runAsync(op) {
22
+ let input = undefined;
23
+ let error = undefined;
24
+ let failed = false;
25
+ for (;;) {
26
+ let step;
27
+ if (failed) {
28
+ failed = false;
29
+ step = op.throw(error);
30
+ }
31
+ else
32
+ step = op.next(input);
33
+ if (step.done)
34
+ return step.value;
35
+ const value = step.value;
36
+ if (isThenable(value)) {
37
+ try {
38
+ input = await value;
39
+ }
40
+ catch (e) {
41
+ error = e;
42
+ failed = true;
43
+ }
44
+ }
45
+ else
46
+ input = value;
47
+ }
48
+ }
49
+ const SYNCHRONOUS_DATA_REQUIRED = ' needs the data while an expression is being evaluated, and the data host answered asynchronously (it ' +
50
+ 'returned a promise).';
51
+ /** The error of an operation that needs a synchronous host and got a promise. */
52
+ export class SynchronousDataRequiredError extends Error {
53
+ constructor(what) {
54
+ super(what +
55
+ SYNCHRONOUS_DATA_REQUIRED +
56
+ ' Open the dataset before printing (OpenOnStart), or give a data host whose connect and query return ' +
57
+ 'their results directly.');
58
+ this.name = 'SynchronousDataRequiredError';
59
+ }
60
+ }
61
+ /**
62
+ * Whether a run failed because the report needs a synchronous data host: the error itself, or the
63
+ * error of the report item that was evaluating (a ReportException keeps only its message, as in C#).
64
+ * A host can then run the report again with a synchronous driver.
65
+ */
66
+ export function isSynchronousDataRequired(error) {
67
+ if (error instanceof SynchronousDataRequiredError)
68
+ return true;
69
+ return error instanceof Error && error.message.includes(SYNCHRONOUS_DATA_REQUIRED);
70
+ }
71
+ /** Runs an Op synchronously; a promise from the host fails with SynchronousDataRequiredError. */
72
+ export function runSync(op, what) {
73
+ let input = undefined;
74
+ let error = undefined;
75
+ let failed = false;
76
+ for (;;) {
77
+ let step;
78
+ if (failed) {
79
+ failed = false;
80
+ step = op.throw(error);
81
+ }
82
+ else
83
+ step = op.next(input);
84
+ if (step.done)
85
+ return step.value;
86
+ const value = step.value;
87
+ if (isThenable(value)) {
88
+ // The pending host call is abandoned: its rejection must not be reported as unhandled.
89
+ value.then(undefined, () => undefined);
90
+ error = new SynchronousDataRequiredError(what);
91
+ failed = true;
92
+ }
93
+ else
94
+ input = value;
95
+ }
96
+ }
97
+ //# sourceMappingURL=op.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"op.js","sourceRoot":"","sources":["../../src/data/op.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,oGAAoG;AACpG,sGAAsG;AACtG,qGAAqG;AACrG,+FAA+F;AAC/F,EAAE;AACF,uGAAuG;AACvG,oGAAoG;AACpG,4FAA4F;AAQ5F,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,CACL,KAAK,KAAK,IAAI;QACd,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;QAC1D,OAAQ,KAA4B,CAAC,IAAI,KAAK,UAAU,CACzD,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,SAAS,CAAC,CAAC,IAAI,CAAI,KAAsB;IAC7C,OAAO,CAAC,MAAM,KAAK,CAAM,CAAC;AAC5B,CAAC;AAED,mDAAmD;AACnD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAI,EAAS;IACzC,IAAI,KAAK,GAAY,SAAS,CAAC;IAC/B,IAAI,KAAK,GAAY,SAAS,CAAC;I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AY,SAAS,CAAC;IAC/B,IAAI,KAAK,GAAY,SAAS,CAAC;IAC/B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,SAAS,CAAC;QACR,IAAI,IAAgC,CAAC;QACrC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,GAAG,KAAK,CAAC;YACf,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;;YAAM,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,uFAAuF;YACvF,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACvC,KAAK,GAAG,IAAI,4BAA4B,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;;YAAM,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,116 @@
1
+ import type { FieldTable } from '../eval/fields.js';
2
+ import type { CultureInfo } from '../util/culture.js';
3
+ import type { RpDateTime } from '../util/datetime.js';
4
+ import { Variant } from '../variant/variant.js';
5
+ import { type DataColumn, type StoredValue } from './columns.js';
6
+ import type { DataValue, ParameterValueType, QueryResult } from './host.js';
7
+ import type { Op } from './op.js';
8
+ /** IDataReader over a materialised result: Read moves to the next row. */
9
+ export declare class ResultReader {
10
+ readonly result: QueryResult;
11
+ private pos;
12
+ constructor(result: QueryResult);
13
+ get fieldCount(): number;
14
+ read(): boolean;
15
+ /** reader[i] of the current row. */
16
+ value(i: number): DataValue;
17
+ }
18
+ /** A DataView over rows given whole, already converted to the types of their columns. */
19
+ export declare class ResultView {
20
+ readonly columns: readonly DataColumn[];
21
+ readonly rows: readonly (readonly StoredValue[])[];
22
+ constructor(columns: readonly DataColumn[], rows: readonly (readonly StoredValue[])[]);
23
+ get count(): number;
24
+ /**
25
+ * The view of a host result, as the DataTable the host filled: the columns keep their names
26
+ * and types, the values are stored in those types.
27
+ */
28
+ static fromResult(result: QueryResult, locale: CultureInfo, culture: CultureInfo): ResultView;
29
+ /**
30
+ * DataView.FindRows: the rows whose sort columns have the values of the key. A view without
31
+ * sort finds nothing (the C# ArgumentException); the view of a union has one (UnionView).
32
+ */
33
+ findRows(_key: readonly DataValue[]): readonly (readonly StoredValue[])[];
34
+ }
35
+ /** A row of the dataset (DataRow): its values by column index. */
36
+ export declare class DatasetRow {
37
+ readonly values: StoredValue[];
38
+ private readonly dataset;
39
+ constructor(dataset: ReportDataset, values: StoredValue[]);
40
+ private index;
41
+ /** row[name] as a Variant (Variant.AssignFromObject of the value). */
42
+ variant(name: string | number): Variant;
43
+ /** row[name] as the boxed .NET value: its type and value. */
44
+ boxed(name: string | number): {
45
+ type: ParameterValueType;
46
+ value: StoredValue;
47
+ };
48
+ }
49
+ /** DataChange: a listener of the record changes of a dataset (it may re-execute a detail). */
50
+ export type DataChangeListener = (data: ReportDataset) => Op<void>;
51
+ export declare class ReportDataset implements FieldTable {
52
+ private fEof;
53
+ private fInternalEof;
54
+ private fLastFetched;
55
+ private fBuffer;
56
+ private fCurrent;
57
+ private fCurrentReader;
58
+ private fCurrentView;
59
+ /** The rows of the view the filter found (CurrentRowSet; null: every row of the view). */
60
+ private currentRowSet;
61
+ private fViewFilter;
62
+ /** The rows of the two record buffer (reader mode). */
63
+ private readonly rows;
64
+ private fColumns;
65
+ /** ColumnSizes: the size of each column the reader gives one for. */
66
+ readonly columnSizes: Map<string, number>;
67
+ /** When false a new reader keeps the columns (the same SQL executed again). */
68
+ updateColumns: boolean;
69
+ /** OnDataChange (C# +=: a listener added twice is called twice). */
70
+ readonly onDataChange: DataChangeListener[];
71
+ /** DataTable.Locale: the culture strings are parsed with when they are stored. */
72
+ private readonly locale;
73
+ /** The culture values print with (value.ToString() of a string column). */
74
+ private readonly culture;
75
+ private readonly invariant;
76
+ private readonly now;
77
+ constructor(locale: CultureInfo, culture: () => CultureInfo, invariant: CultureInfo, now: () => RpDateTime);
78
+ get columns(): readonly DataColumn[];
79
+ /** DataTable.Columns.IndexOf: case-insensitive. */
80
+ indexOfColumn(name: string): number;
81
+ /** IdenField.GetValue: the value of a column in the current row (Null without rows). */
82
+ getValue(_row: number, column: string): unknown;
83
+ /** The number of records loaded (reader: the rows of the buffer; view: its rows). */
84
+ get currentRowCount(): number;
85
+ /** A reader or a view is assigned. */
86
+ get active(): boolean;
87
+ /** The rows the view gives: the ones the filter found, or all of them. */
88
+ private viewRows;
89
+ private viewRow;
90
+ /** The current row; null when there is none. */
91
+ get currentRow(): DatasetRow | null;
92
+ /** The row of the buffer that is not the current one. */
93
+ get otherRow(): DatasetRow | null;
94
+ get currentReader(): ResultReader | null;
95
+ /** Assigning a reader loads its first record. */
96
+ set currentReader(value: ResultReader | null);
97
+ get currentView(): ResultView | null;
98
+ set currentView(value: ResultView | null);
99
+ /** ViewFilter: the values of the sort columns of the view the rows must have (null: all the rows). */
100
+ get viewFilter(): readonly DataValue[] | null;
101
+ set viewFilter(value: readonly DataValue[] | null);
102
+ private updateViewRows;
103
+ /** No more records, or no data assigned. */
104
+ get eof(): boolean;
105
+ private fill;
106
+ private newRow;
107
+ private doUpdateData;
108
+ /** Back to the first record (views only). */
109
+ first(): void;
110
+ private dataChanged;
111
+ /** Moves to the next record; after Prior only the current row changes. */
112
+ next(): Op<boolean>;
113
+ /** Moves to the previous record (only one back). */
114
+ prior(): Op<boolean>;
115
+ }
116
+ //# sourceMappingURL=reportdataset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportdataset.d.ts","sourceRoot":"","sources":["../../src/data/reportdataset.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD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