@rex0220/kintone-sql-tools 3.28.0 → 3.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,7 +95,7 @@
95
95
  "format": "esm"
96
96
  },
97
97
  "src/core/dmlGuard.ts": {
98
- "bytes": 8488,
98
+ "bytes": 9379,
99
99
  "imports": [
100
100
  {
101
101
  "path": "src/types/ast.ts",
@@ -159,7 +159,7 @@
159
159
  "format": "esm"
160
160
  },
161
161
  "src/converter/selectToKintone.ts": {
162
- "bytes": 28156,
162
+ "bytes": 29239,
163
163
  "imports": [
164
164
  {
165
165
  "path": "../types/ast",
@@ -560,7 +560,7 @@
560
560
  "format": "esm"
561
561
  },
562
562
  "src/core/existingRecordValidation.ts": {
563
- "bytes": 6056,
563
+ "bytes": 6562,
564
564
  "imports": [
565
565
  {
566
566
  "path": "src/core/dmlValidationCandidates.ts",
@@ -1161,7 +1161,7 @@
1161
1161
  "format": "esm"
1162
1162
  },
1163
1163
  "src/execute.ts": {
1164
- "bytes": 453813,
1164
+ "bytes": 461839,
1165
1165
  "imports": [
1166
1166
  {
1167
1167
  "path": "src/lexer/lexer.ts",
@@ -1497,7 +1497,7 @@
1497
1497
  "format": "esm"
1498
1498
  },
1499
1499
  "src/engine-library/errors.ts": {
1500
- "bytes": 3031,
1500
+ "bytes": 3714,
1501
1501
  "imports": [
1502
1502
  {
1503
1503
  "path": "src/api/fetchAll.ts",
@@ -1623,10 +1623,21 @@
1623
1623
  "format": "esm"
1624
1624
  },
1625
1625
  "src/engine-library/options.ts": {
1626
- "bytes": 3253,
1626
+ "bytes": 5024,
1627
1627
  "imports": [],
1628
1628
  "format": "esm"
1629
1629
  },
1630
+ "src/engine-library/resultMapping.ts": {
1631
+ "bytes": 1867,
1632
+ "imports": [
1633
+ {
1634
+ "path": "src/execute.ts",
1635
+ "kind": "import-statement",
1636
+ "original": "../execute"
1637
+ }
1638
+ ],
1639
+ "format": "esm"
1640
+ },
1630
1641
  "src/core/sql.ts": {
1631
1642
  "bytes": 858,
1632
1643
  "imports": [
@@ -1648,14 +1659,29 @@
1648
1659
  ],
1649
1660
  "format": "esm"
1650
1661
  },
1662
+ "src/core/applyGuard.ts": {
1663
+ "bytes": 638,
1664
+ "imports": [],
1665
+ "format": "esm"
1666
+ },
1651
1667
  "src/engine-library/statementGuard.ts": {
1652
- "bytes": 3420,
1668
+ "bytes": 4597,
1653
1669
  "imports": [
1654
1670
  {
1655
1671
  "path": "src/core/sql.ts",
1656
1672
  "kind": "import-statement",
1657
1673
  "original": "../core/sql"
1658
1674
  },
1675
+ {
1676
+ "path": "src/core/applyGuard.ts",
1677
+ "kind": "import-statement",
1678
+ "original": "../core/applyGuard"
1679
+ },
1680
+ {
1681
+ "path": "src/core/dmlGuard.ts",
1682
+ "kind": "import-statement",
1683
+ "original": "../core/dmlGuard"
1684
+ },
1659
1685
  {
1660
1686
  "path": "src/core/klikeValidation.ts",
1661
1687
  "kind": "import-statement",
@@ -1669,8 +1695,49 @@
1669
1695
  ],
1670
1696
  "format": "esm"
1671
1697
  },
1698
+ "src/engine-library/batch.ts": {
1699
+ "bytes": 3529,
1700
+ "imports": [
1701
+ {
1702
+ "path": "src/execute.ts",
1703
+ "kind": "import-statement",
1704
+ "original": "../execute"
1705
+ },
1706
+ {
1707
+ "path": "src/engine-library/errors.ts",
1708
+ "kind": "import-statement",
1709
+ "original": "./errors"
1710
+ },
1711
+ {
1712
+ "path": "src/engine-library/cursorScope.ts",
1713
+ "kind": "import-statement",
1714
+ "original": "./cursorScope"
1715
+ },
1716
+ {
1717
+ "path": "src/engine-library/options.ts",
1718
+ "kind": "import-statement",
1719
+ "original": "./options"
1720
+ },
1721
+ {
1722
+ "path": "src/engine-library/readonlyClient.ts",
1723
+ "kind": "import-statement",
1724
+ "original": "./readonlyClient"
1725
+ },
1726
+ {
1727
+ "path": "src/engine-library/resultMapping.ts",
1728
+ "kind": "import-statement",
1729
+ "original": "./resultMapping"
1730
+ },
1731
+ {
1732
+ "path": "src/engine-library/statementGuard.ts",
1733
+ "kind": "import-statement",
1734
+ "original": "./statementGuard"
1735
+ }
1736
+ ],
1737
+ "format": "esm"
1738
+ },
1672
1739
  "src/engine-library/query.ts": {
1673
- "bytes": 3614,
1740
+ "bytes": 2547,
1674
1741
  "imports": [
1675
1742
  {
1676
1743
  "path": "src/execute.ts",
@@ -1697,6 +1764,11 @@
1697
1764
  "kind": "import-statement",
1698
1765
  "original": "./readonlyClient"
1699
1766
  },
1767
+ {
1768
+ "path": "src/engine-library/resultMapping.ts",
1769
+ "kind": "import-statement",
1770
+ "original": "./resultMapping"
1771
+ },
1700
1772
  {
1701
1773
  "path": "src/engine-library/statementGuard.ts",
1702
1774
  "kind": "import-statement",
@@ -1706,7 +1778,7 @@
1706
1778
  "format": "esm"
1707
1779
  },
1708
1780
  "src/engine-library/index.ts": {
1709
- "bytes": 985,
1781
+ "bytes": 1160,
1710
1782
  "imports": [
1711
1783
  {
1712
1784
  "path": "src/engine-library/errors.ts",
@@ -1718,6 +1790,11 @@
1718
1790
  "kind": "import-statement",
1719
1791
  "original": "./browserClient"
1720
1792
  },
1793
+ {
1794
+ "path": "src/engine-library/batch.ts",
1795
+ "kind": "import-statement",
1796
+ "original": "./batch"
1797
+ },
1721
1798
  {
1722
1799
  "path": "src/engine-library/query.ts",
1723
1800
  "kind": "import-statement",
@@ -1727,12 +1804,12 @@
1727
1804
  "format": "esm"
1728
1805
  },
1729
1806
  "src/engine-library/versionRegistry.ts": {
1730
- "bytes": 2952,
1807
+ "bytes": 3002,
1731
1808
  "imports": [],
1732
1809
  "format": "esm"
1733
1810
  },
1734
1811
  "src/engine-library/umd.ts": {
1735
- "bytes": 509,
1812
+ "bytes": 529,
1736
1813
  "imports": [
1737
1814
  {
1738
1815
  "path": "src/engine-library/index.ts",
@@ -1770,7 +1847,7 @@
1770
1847
  "bytesInOutput": 139
1771
1848
  },
1772
1849
  "src/core/grouping.ts": {
1773
- "bytesInOutput": 1281
1850
+ "bytesInOutput": 1284
1774
1851
  },
1775
1852
  "src/core/aggregateExpression.ts": {
1776
1853
  "bytesInOutput": 2592
@@ -1782,7 +1859,7 @@
1782
1859
  "bytesInOutput": 92192
1783
1860
  },
1784
1861
  "src/core/dmlGuard.ts": {
1785
- "bytesInOutput": 1881
1862
+ "bytesInOutput": 2857
1786
1863
  },
1787
1864
  "src/core/applyPatchScope.ts": {
1788
1865
  "bytesInOutput": 12612
@@ -1797,7 +1874,7 @@
1797
1874
  "bytesInOutput": 5075
1798
1875
  },
1799
1876
  "src/converter/selectToKintone.ts": {
1800
- "bytesInOutput": 8913
1877
+ "bytesInOutput": 9186
1801
1878
  },
1802
1879
  "src/core/cteInlining.ts": {
1803
1880
  "bytesInOutput": 1224
@@ -1818,7 +1895,10 @@
1818
1895
  "bytesInOutput": 559
1819
1896
  },
1820
1897
  "src/core/groupingValidation.ts": {
1821
- "bytesInOutput": 5173
1898
+ "bytesInOutput": 5175
1899
+ },
1900
+ "src/core/batch.ts": {
1901
+ "bytesInOutput": 5518
1822
1902
  },
1823
1903
  "src/core/fieldSemantics.ts": {
1824
1904
  "bytesInOutput": 1368
@@ -1830,7 +1910,7 @@
1830
1910
  "bytesInOutput": 11162
1831
1911
  },
1832
1912
  "src/engine/evalWhere.ts": {
1833
- "bytesInOutput": 5516
1913
+ "bytesInOutput": 5752
1834
1914
  },
1835
1915
  "src/core/dmlCustomCheck.ts": {
1836
1916
  "bytesInOutput": 1250
@@ -1845,7 +1925,7 @@
1845
1925
  "bytesInOutput": 9946
1846
1926
  },
1847
1927
  "src/converter/applyPatchToKintone.ts": {
1848
- "bytesInOutput": 4478
1928
+ "bytesInOutput": 4501
1849
1929
  },
1850
1930
  "src/core/numberPrecision.ts": {
1851
1931
  "bytesInOutput": 870
@@ -1857,7 +1937,7 @@
1857
1937
  "bytesInOutput": 2802
1858
1938
  },
1859
1939
  "src/core/existingRecordValidation.ts": {
1860
- "bytesInOutput": 3341
1940
+ "bytesInOutput": 3491
1861
1941
  },
1862
1942
  "src/core/postImageValidation.ts": {
1863
1943
  "bytesInOutput": 2207
@@ -1883,11 +1963,14 @@
1883
1963
  "src/core/applyUpsertExecutePrepared.ts": {
1884
1964
  "bytesInOutput": 1487
1885
1965
  },
1966
+ "src/core/batchVariables.ts": {
1967
+ "bytesInOutput": 667
1968
+ },
1886
1969
  "src/core/outerJoinSearchAbortGuard.ts": {
1887
1970
  "bytesInOutput": 366
1888
1971
  },
1889
1972
  "src/core/explainMetadata.ts": {
1890
- "bytesInOutput": 626
1973
+ "bytesInOutput": 627
1891
1974
  },
1892
1975
  "src/core/optimization/sharedPlanner.ts": {
1893
1976
  "bytesInOutput": 339
@@ -1923,7 +2006,7 @@
1923
2006
  "bytesInOutput": 2656
1924
2007
  },
1925
2008
  "src/engine/process.ts": {
1926
- "bytesInOutput": 19953
2009
+ "bytesInOutput": 19954
1927
2010
  },
1928
2011
  "src/converter/subtableAdapter.ts": {
1929
2012
  "bytesInOutput": 643
@@ -1983,10 +2066,10 @@
1983
2066
  "bytesInOutput": 412
1984
2067
  },
1985
2068
  "src/execute.ts": {
1986
- "bytesInOutput": 163191
2069
+ "bytesInOutput": 176457
1987
2070
  },
1988
2071
  "src/engine-library/errors.ts": {
1989
- "bytesInOutput": 1116
2072
+ "bytesInOutput": 1306
1990
2073
  },
1991
2074
  "src/api/cursorLeaseManager.ts": {
1992
2075
  "bytesInOutput": 1777
@@ -2013,16 +2096,25 @@
2013
2096
  "bytesInOutput": 766
2014
2097
  },
2015
2098
  "src/engine-library/options.ts": {
2016
- "bytesInOutput": 1584
2099
+ "bytesInOutput": 2212
2100
+ },
2101
+ "src/engine-library/resultMapping.ts": {
2102
+ "bytesInOutput": 777
2017
2103
  },
2018
2104
  "src/core/sql.ts": {
2019
- "bytesInOutput": 84
2105
+ "bytesInOutput": 186
2106
+ },
2107
+ "src/core/applyGuard.ts": {
2108
+ "bytesInOutput": 236
2020
2109
  },
2021
2110
  "src/engine-library/statementGuard.ts": {
2022
- "bytesInOutput": 1082
2111
+ "bytesInOutput": 1704
2112
+ },
2113
+ "src/engine-library/batch.ts": {
2114
+ "bytesInOutput": 896
2023
2115
  },
2024
2116
  "src/engine-library/query.ts": {
2025
- "bytesInOutput": 1231
2117
+ "bytesInOutput": 603
2026
2118
  },
2027
2119
  "src/engine-library/index.ts": {
2028
2120
  "bytesInOutput": 16
@@ -2031,10 +2123,10 @@
2031
2123
  "bytesInOutput": 1000
2032
2124
  },
2033
2125
  "src/engine-library/umd.ts": {
2034
- "bytesInOutput": 115
2126
+ "bytesInOutput": 127
2035
2127
  }
2036
2128
  },
2037
- "bytes": 504254
2129
+ "bytes": 528205
2038
2130
  }
2039
2131
  }
2040
2132
  }
@@ -31,12 +31,29 @@ export interface ReadonlyAppInfo {
31
31
  name: string;
32
32
  description: string;
33
33
  }
34
+ /**
35
+ * Read-only field metadata supplied to the engine.
36
+ *
37
+ * `VALIDATE` only checks constraints present in this metadata. If a BYO client
38
+ * omits `optionOrder`, `required`, or the min/max metadata below, those
39
+ * constraints are not validated and the result can silently contain zero
40
+ * errors. BYO clients must pass the corresponding values from
41
+ * `/k/v1/app/form/fields.json`.
42
+ *
43
+ * `createReadonlyKintoneClient()` supplies these values automatically, so its
44
+ * users do not need to change their client.
45
+ */
34
46
  export interface ReadonlyFieldInfo {
35
47
  code: string;
36
48
  label: string;
37
49
  fieldType: string;
38
50
  optionOrder?: Record<string, number>;
39
51
  sortKind?: "number" | "string";
52
+ required?: boolean;
53
+ minValue?: string;
54
+ maxValue?: string;
55
+ minLength?: string;
56
+ maxLength?: string;
40
57
  inSubtable?: boolean;
41
58
  subtableCode?: string;
42
59
  }
@@ -69,6 +86,33 @@ export interface RunQueryOptions {
69
86
  fetchParallel?: number;
70
87
  cursorMaxActive?: number;
71
88
  }
89
+ /**
90
+ * Options for one read-only runBatch invocation.
91
+ *
92
+ * Temporary tables and variables exist only for that invocation. A batch is
93
+ * fail-closed: any failed statement makes runBatch throw instead of returning
94
+ * a partial BatchResult.
95
+ */
96
+ export interface RunBatchOptions {
97
+ client: ReadonlyKintoneClient;
98
+ maxRecords?: number;
99
+ onLimitReached?: "error" | "truncate";
100
+ fetchParallel?: number;
101
+ cursorMaxActive?: number;
102
+ /**
103
+ * DECLARE されたバッチ変数へ渡す文字列値。
104
+ * キーは @ を付けず、大文字小文字を区別しない。SET 変数には注入できない。
105
+ */
106
+ variables?: Readonly<Record<string, string>>;
107
+ /**
108
+ * CREATE TEMP TABLE 1 表あたりの実体化行数上限(既定 10,000)。
109
+ * 超過は onLimitReached: "truncate" でも常に error となる。
110
+ *
111
+ * 一時テーブルは利用者アプリのプロセス内メモリに runBatch 呼び出し単位で実体化される。
112
+ * 同時に存在できるのは最大 16 表で、DROP TEMP TABLE により解放された枠は同じバッチ内で再利用できる。
113
+ */
114
+ tempTableMaxRows?: number;
115
+ }
72
116
  export interface QueryColumn {
73
117
  name: string;
74
118
  valueType: "string";
@@ -85,14 +129,68 @@ export interface QueryMetrics {
85
129
  elapsedMs: number;
86
130
  cursorRecordsScanned: number;
87
131
  }
132
+ export type ValidateConstraintCategory = "required" | "length" | "range" | "choice";
133
+ export interface ValidateConstraintMetadata {
134
+ /** Constraint categories present on the fields targeted by VALIDATE. */
135
+ present: ValidateConstraintCategory[];
136
+ /** Known constraint categories absent from the fields targeted by VALIDATE. */
137
+ absent: ValidateConstraintCategory[];
138
+ }
88
139
  export interface QueryResult {
89
140
  type: "query";
90
141
  rows: readonly Readonly<Record<string, string>>[];
91
142
  columns: readonly QueryColumn[];
92
143
  rowCount: number;
93
144
  warnings: readonly string[];
145
+ /** Present only for an existing-record VALIDATE query. */
146
+ validateStats?: {
147
+ errorRecords: number;
148
+ errorCount: number;
149
+ constraintMetadata?: ValidateConstraintMetadata;
150
+ };
94
151
  metrics: QueryMetrics;
95
152
  }
153
+ /** Named now so a future DML VALIDATE ONLY result can extend this union additively. */
154
+ export type BatchResultItem = QueryResult;
155
+ export interface BatchStatementInfo {
156
+ /** Zero-based statement index in the submitted batch. */
157
+ readonly index: number;
158
+ /** Parser statement type, such as SELECT or CREATE_TEMP_TABLE. */
159
+ readonly type: string;
160
+ /**
161
+ * Successful BatchResult values contain successful statements only.
162
+ * A statement error makes runBatch throw instead of returning this DTO.
163
+ */
164
+ readonly status: "success" | "error" | "skipped";
165
+ readonly tempTable?: string;
166
+ readonly rowCount?: number;
167
+ readonly resultIndex?: number;
168
+ readonly error?: {
169
+ readonly code: string;
170
+ readonly message: string;
171
+ };
172
+ readonly skippedReason?: string;
173
+ }
174
+ /**
175
+ * Successful read-only batch result.
176
+ *
177
+ * There is intentionally no `ok` field: if any statement fails, runBatch
178
+ * throws KsqlEngineError and returns no partial results. The error identifies
179
+ * the failed statement through statementIndex and statementType.
180
+ */
181
+ export interface BatchResult {
182
+ readonly type: "batch";
183
+ readonly batch: true;
184
+ readonly statementCount: number;
185
+ readonly statements: readonly BatchStatementInfo[];
186
+ /**
187
+ * Row-returning statement results.
188
+ * Every metrics object is the same batch-wide aggregate, not a per-statement
189
+ * measurement; do not use it to attribute cost to an individual statement.
190
+ */
191
+ readonly results: readonly BatchResultItem[];
192
+ readonly warnings: readonly string[];
193
+ }
96
194
  export interface ExplainResult {
97
195
  type: "explain";
98
196
  lines: readonly string[];
@@ -1,3 +1,11 @@
1
1
  import type { ExplainResult, QueryResult, RunQueryOptions } from "./publicTypes";
2
+ /**
3
+ * Executes one row-returning read-only statement: SELECT, WITH, UNION,
4
+ * SHOW APPS, DESCRIBE, or existing-record VALIDATE.
5
+ */
2
6
  export declare function runQuery(sql: string, options: RunQueryOptions): Promise<QueryResult>;
7
+ /**
8
+ * Explains one SELECT, WITH, or UNION query without reading records.
9
+ * CREATE TEMP TABLE is not accepted; explain its source SELECT instead.
10
+ */
3
11
  export declare function explainQuery(sql: string, options: Omit<RunQueryOptions, "onLimitReached">): Promise<ExplainResult>;