@rowsncolumns/functions 14.0.29

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 (149) hide show
  1. package/LICENSE.md +100 -0
  2. package/Readme.md +5 -0
  3. package/dist/cjs/formulas/array-formula.d.ts +4 -0
  4. package/dist/cjs/formulas/array-formula.d.ts.map +1 -0
  5. package/dist/cjs/formulas/array-formula.js +7 -0
  6. package/dist/cjs/formulas/crypto-price.d.ts +4 -0
  7. package/dist/cjs/formulas/crypto-price.d.ts.map +1 -0
  8. package/dist/cjs/formulas/crypto-price.js +63 -0
  9. package/dist/cjs/formulas/datasource.d.ts +4 -0
  10. package/dist/cjs/formulas/datasource.d.ts.map +1 -0
  11. package/dist/cjs/formulas/datasource.js +21 -0
  12. package/dist/cjs/formulas/formula-text.d.ts +5 -0
  13. package/dist/cjs/formulas/formula-text.d.ts.map +1 -0
  14. package/dist/cjs/formulas/formula-text.js +17 -0
  15. package/dist/cjs/formulas/get-pivot-data.d.ts +32 -0
  16. package/dist/cjs/formulas/get-pivot-data.d.ts.map +1 -0
  17. package/dist/cjs/formulas/get-pivot-data.js +188 -0
  18. package/dist/cjs/formulas/hyperlink.d.ts +5 -0
  19. package/dist/cjs/formulas/hyperlink.d.ts.map +1 -0
  20. package/dist/cjs/formulas/hyperlink.js +22 -0
  21. package/dist/cjs/formulas/image.d.ts +5 -0
  22. package/dist/cjs/formulas/image.d.ts.map +1 -0
  23. package/dist/cjs/formulas/image.js +17 -0
  24. package/dist/cjs/formulas/import-data.d.ts +11 -0
  25. package/dist/cjs/formulas/import-data.d.ts.map +1 -0
  26. package/dist/cjs/formulas/import-data.js +46 -0
  27. package/dist/cjs/formulas/index.d.ts +18 -0
  28. package/dist/cjs/formulas/index.d.ts.map +1 -0
  29. package/dist/cjs/formulas/index.js +37 -0
  30. package/dist/cjs/formulas/join.d.ts +4 -0
  31. package/dist/cjs/formulas/join.d.ts.map +1 -0
  32. package/dist/cjs/formulas/join.js +34 -0
  33. package/dist/cjs/formulas/multiply.d.ts +4 -0
  34. package/dist/cjs/formulas/multiply.d.ts.map +1 -0
  35. package/dist/cjs/formulas/multiply.js +15 -0
  36. package/dist/cjs/formulas/real-time.d.ts +4 -0
  37. package/dist/cjs/formulas/real-time.d.ts.map +1 -0
  38. package/dist/cjs/formulas/real-time.js +18 -0
  39. package/dist/cjs/formulas/selection-status.d.ts +4 -0
  40. package/dist/cjs/formulas/selection-status.d.ts.map +1 -0
  41. package/dist/cjs/formulas/selection-status.js +65 -0
  42. package/dist/cjs/formulas/sequence.d.ts +5 -0
  43. package/dist/cjs/formulas/sequence.d.ts.map +1 -0
  44. package/dist/cjs/formulas/sequence.js +29 -0
  45. package/dist/cjs/formulas/server.d.ts +22 -0
  46. package/dist/cjs/formulas/server.d.ts.map +1 -0
  47. package/dist/cjs/formulas/server.js +44 -0
  48. package/dist/cjs/formulas/sparkline.d.ts +5 -0
  49. package/dist/cjs/formulas/sparkline.d.ts.map +1 -0
  50. package/dist/cjs/formulas/sparkline.js +58 -0
  51. package/dist/cjs/formulas/split.d.ts +12 -0
  52. package/dist/cjs/formulas/split.d.ts.map +1 -0
  53. package/dist/cjs/formulas/split.js +48 -0
  54. package/dist/cjs/formulas/star-rating.d.ts +5 -0
  55. package/dist/cjs/formulas/star-rating.d.ts.map +1 -0
  56. package/dist/cjs/formulas/star-rating.js +13 -0
  57. package/dist/cjs/formulas/unique.d.ts +12 -0
  58. package/dist/cjs/formulas/unique.d.ts.map +1 -0
  59. package/dist/cjs/formulas/unique.js +78 -0
  60. package/dist/cjs/function-descriptions.d.ts +3 -0
  61. package/dist/cjs/function-descriptions.d.ts.map +1 -0
  62. package/dist/cjs/function-descriptions.js +8724 -0
  63. package/dist/cjs/index.d.ts +4 -0
  64. package/dist/cjs/index.d.ts.map +1 -0
  65. package/dist/cjs/index.js +7 -0
  66. package/dist/cjs/server.d.ts +4 -0
  67. package/dist/cjs/server.d.ts.map +1 -0
  68. package/dist/cjs/server.js +8 -0
  69. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  70. package/dist/cjs/types.d.ts +2 -0
  71. package/dist/cjs/types.d.ts.map +1 -0
  72. package/dist/cjs/types.js +2 -0
  73. package/dist/cjs/vitest.config.d.ts +3 -0
  74. package/dist/cjs/vitest.config.d.ts.map +1 -0
  75. package/dist/cjs/vitest.config.js +18 -0
  76. package/dist/esm/formulas/array-formula.d.ts +4 -0
  77. package/dist/esm/formulas/array-formula.d.ts.map +1 -0
  78. package/dist/esm/formulas/array-formula.js +3 -0
  79. package/dist/esm/formulas/crypto-price.d.ts +4 -0
  80. package/dist/esm/formulas/crypto-price.d.ts.map +1 -0
  81. package/dist/esm/formulas/crypto-price.js +33 -0
  82. package/dist/esm/formulas/datasource.d.ts +4 -0
  83. package/dist/esm/formulas/datasource.d.ts.map +1 -0
  84. package/dist/esm/formulas/datasource.js +17 -0
  85. package/dist/esm/formulas/formula-text.d.ts +5 -0
  86. package/dist/esm/formulas/formula-text.d.ts.map +1 -0
  87. package/dist/esm/formulas/formula-text.js +12 -0
  88. package/dist/esm/formulas/get-pivot-data.d.ts +32 -0
  89. package/dist/esm/formulas/get-pivot-data.d.ts.map +1 -0
  90. package/dist/esm/formulas/get-pivot-data.js +144 -0
  91. package/dist/esm/formulas/hyperlink.d.ts +5 -0
  92. package/dist/esm/formulas/hyperlink.d.ts.map +1 -0
  93. package/dist/esm/formulas/hyperlink.js +17 -0
  94. package/dist/esm/formulas/image.d.ts +5 -0
  95. package/dist/esm/formulas/image.d.ts.map +1 -0
  96. package/dist/esm/formulas/image.js +13 -0
  97. package/dist/esm/formulas/import-data.d.ts +11 -0
  98. package/dist/esm/formulas/import-data.d.ts.map +1 -0
  99. package/dist/esm/formulas/import-data.js +28 -0
  100. package/dist/esm/formulas/index.d.ts +18 -0
  101. package/dist/esm/formulas/index.d.ts.map +1 -0
  102. package/dist/esm/formulas/index.js +17 -0
  103. package/dist/esm/formulas/join.d.ts +4 -0
  104. package/dist/esm/formulas/join.d.ts.map +1 -0
  105. package/dist/esm/formulas/join.js +25 -0
  106. package/dist/esm/formulas/multiply.d.ts +4 -0
  107. package/dist/esm/formulas/multiply.d.ts.map +1 -0
  108. package/dist/esm/formulas/multiply.js +11 -0
  109. package/dist/esm/formulas/real-time.d.ts +4 -0
  110. package/dist/esm/formulas/real-time.d.ts.map +1 -0
  111. package/dist/esm/formulas/real-time.js +14 -0
  112. package/dist/esm/formulas/selection-status.d.ts +4 -0
  113. package/dist/esm/formulas/selection-status.d.ts.map +1 -0
  114. package/dist/esm/formulas/selection-status.js +39 -0
  115. package/dist/esm/formulas/sequence.d.ts +5 -0
  116. package/dist/esm/formulas/sequence.d.ts.map +1 -0
  117. package/dist/esm/formulas/sequence.js +24 -0
  118. package/dist/esm/formulas/server.d.ts +22 -0
  119. package/dist/esm/formulas/server.d.ts.map +1 -0
  120. package/dist/esm/formulas/server.js +37 -0
  121. package/dist/esm/formulas/sparkline.d.ts +5 -0
  122. package/dist/esm/formulas/sparkline.d.ts.map +1 -0
  123. package/dist/esm/formulas/sparkline.js +52 -0
  124. package/dist/esm/formulas/split.d.ts +12 -0
  125. package/dist/esm/formulas/split.d.ts.map +1 -0
  126. package/dist/esm/formulas/split.js +44 -0
  127. package/dist/esm/formulas/star-rating.d.ts +5 -0
  128. package/dist/esm/formulas/star-rating.d.ts.map +1 -0
  129. package/dist/esm/formulas/star-rating.js +9 -0
  130. package/dist/esm/formulas/unique.d.ts +12 -0
  131. package/dist/esm/formulas/unique.d.ts.map +1 -0
  132. package/dist/esm/formulas/unique.js +58 -0
  133. package/dist/esm/function-descriptions.d.ts +3 -0
  134. package/dist/esm/function-descriptions.d.ts.map +1 -0
  135. package/dist/esm/function-descriptions.js +8721 -0
  136. package/dist/esm/index.d.ts +4 -0
  137. package/dist/esm/index.d.ts.map +1 -0
  138. package/dist/esm/index.js +3 -0
  139. package/dist/esm/server.d.ts +4 -0
  140. package/dist/esm/server.d.ts.map +1 -0
  141. package/dist/esm/server.js +3 -0
  142. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  143. package/dist/esm/types.d.ts +2 -0
  144. package/dist/esm/types.d.ts.map +1 -0
  145. package/dist/esm/types.js +1 -0
  146. package/dist/esm/vitest.config.d.ts +3 -0
  147. package/dist/esm/vitest.config.d.ts.map +1 -0
  148. package/dist/esm/vitest.config.js +15 -0
  149. package/package.json +51 -0
package/LICENSE.md ADDED
@@ -0,0 +1,100 @@
1
+ # Rows n' Columns Commercial License Agreement
2
+
3
+ This Rows n' Columns Commercial License Agreement (the "Agreement") governs
4
+ the use of the Rows n' Columns software packages published under the
5
+ `@rowsncolumns` npm scope, including associated JavaScript, WebAssembly
6
+ binaries, stylesheets, type definitions and documentation (the "Software").
7
+
8
+ The Software is **not** open source. Downloading or installing the Software
9
+ from a public package registry does not grant any right to use it beyond the
10
+ evaluation use described below.
11
+
12
+ ## 1. Definitions
13
+
14
+ - **"Licensor"** means Rows n' Columns (rowsncolumns.app).
15
+ - **"Licensee"** means the individual or legal entity identified in an Order.
16
+ - **"Order"** means a purchase of a license for the Software from Licensor,
17
+ identified by an order ID and associated with a License Key.
18
+ - **"License Key"** means the signed key issued by Licensor that identifies
19
+ the Licensee, license tier, and Update Window.
20
+ - **"Update Window"** means the period stated in the Order during which
21
+ Software versions released by Licensor are covered by the License Key.
22
+
23
+ ## 2. License Grant
24
+
25
+ Subject to payment of the applicable fees and compliance with this Agreement,
26
+ Licensor grants Licensee a non-exclusive, non-transferable, worldwide license
27
+ to use, and to distribute in compiled form as an embedded component of
28
+ Licensee's own applications, any version of the Software released during the
29
+ Update Window, in accordance with the license tier stated in the Order.
30
+
31
+ This grant is perpetual for versions released during the Update Window:
32
+ Licensee may continue to use those versions after the Update Window ends.
33
+ Versions released after the Update Window ends require a new or renewed
34
+ Order.
35
+
36
+ ## 3. Evaluation Use
37
+
38
+ The Software may be used without a License Key solely for internal
39
+ evaluation and development purposes. Evaluation use in production, or
40
+ removal or suppression of evaluation notices, is not permitted.
41
+
42
+ ## 4. Restrictions
43
+
44
+ Except as expressly permitted by this Agreement or by applicable law that
45
+ cannot be contractually waived, Licensee shall not:
46
+
47
+ 1. redistribute, resell, sublicense, or otherwise make the Software
48
+ available as a standalone product, library, or development component;
49
+ 2. use the Software to build a product that competes with the Software;
50
+ 3. remove, alter, or circumvent License Key validation, evaluation notices,
51
+ watermarks, or copyright notices in the Software;
52
+ 4. share License Keys with any third party, or use a License Key outside
53
+ the scope of the tier stated in the Order;
54
+ 5. reverse engineer, decompile, or disassemble the Software except to the
55
+ extent permitted by applicable law.
56
+
57
+ ## 5. Ownership
58
+
59
+ The Software is licensed, not sold. Licensor and its licensors retain all
60
+ right, title, and interest in and to the Software, including all
61
+ intellectual property rights.
62
+
63
+ ## 6. Third-Party Components
64
+
65
+ The Software may include third-party open-source components. Those
66
+ components remain governed by their own license terms, which are included
67
+ with the applicable component and are not limited by this Agreement.
68
+
69
+ ## 7. Termination
70
+
71
+ This Agreement terminates automatically upon material breach by Licensee
72
+ that remains uncured 30 days after written notice. Upon termination,
73
+ Licensee must cease use and distribution of the Software, except that
74
+ end-user copies of Licensee applications already distributed in compliance
75
+ with this Agreement are unaffected.
76
+
77
+ ## 8. Warranty Disclaimer
78
+
79
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
80
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
81
+ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
82
+
83
+ ## 9. Limitation of Liability
84
+
85
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL LICENSOR BE LIABLE
86
+ FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES,
87
+ OR ANY LOSS OF PROFITS, DATA, OR GOODWILL, ARISING OUT OF OR RELATED TO THIS
88
+ AGREEMENT, AND LICENSOR'S AGGREGATE LIABILITY SHALL NOT EXCEED THE FEES PAID
89
+ BY LICENSEE IN THE TWELVE MONTHS PRECEDING THE CLAIM.
90
+
91
+ ## 10. General
92
+
93
+ This Agreement constitutes the entire agreement between the parties
94
+ concerning the Software and supersedes any prior agreements. If any
95
+ provision is held unenforceable, the remainder remains in effect. Failure to
96
+ enforce a provision is not a waiver.
97
+
98
+ For licensing inquiries, visit <https://www.rowsncolumns.app/pricing>.
99
+
100
+ Copyright © Rows n' Columns. All rights reserved.
package/Readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # Functions
2
+
3
+ Contains function descriptions and custom functions used by calculator
4
+
5
+ TODO
@@ -0,0 +1,4 @@
1
+ import type { FunctionArgument } from "@rowsncolumns/calculator";
2
+ import type FormulaParser from "@rowsncolumns/fast-formula-parser";
3
+ export declare const ARRAYFORMULA: (_: FormulaParser, arg: FunctionArgument) => import("@rowsncolumns/fast-formula-parser").FormulaResult;
4
+ //# sourceMappingURL=array-formula.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-formula.d.ts","sourceRoot":"","sources":["../../../formulas/array-formula.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAEnE,eAAO,MAAM,YAAY,GAAI,GAAG,aAAa,EAAE,KAAK,gBAAgB,8DAEnE,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ARRAYFORMULA = void 0;
4
+ var ARRAYFORMULA = function (_, arg) {
5
+ return arg.value;
6
+ };
7
+ exports.ARRAYFORMULA = ARRAYFORMULA;
@@ -0,0 +1,4 @@
1
+ import { FunctionArgument } from "@rowsncolumns/calculator";
2
+ import type FormulaParser from "@rowsncolumns/fast-formula-parser";
3
+ export declare const CRYPTOPRICE: (parser: FormulaParser, arg: FunctionArgument) => Promise<number[][]>;
4
+ //# sourceMappingURL=crypto-price.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-price.d.ts","sourceRoot":"","sources":["../../../formulas/crypto-price.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAGnE,eAAO,MAAM,WAAW,GACtB,QAAQ,aAAa,EACrB,KAAK,gBAAgB,wBAoCtB,CAAC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CRYPTOPRICE = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var calculator_1 = require("@rowsncolumns/calculator");
6
+ var fast_formula_parser_1 = require("@rowsncolumns/fast-formula-parser");
7
+ var CRYPTOPRICE = function (parser, arg) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
8
+ var fetchPrices;
9
+ return tslib_1.__generator(this, function (_a) {
10
+ switch (_a.label) {
11
+ case 0:
12
+ if (!arg || !arg.value || arg.value instanceof fast_formula_parser_1.FormulaError) {
13
+ throw new fast_formula_parser_1.FormulaError("#VALUE!", "Symbol pair is required");
14
+ }
15
+ fetchPrices = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
16
+ var results, values, err_1;
17
+ return tslib_1.__generator(this, function (_a) {
18
+ switch (_a.label) {
19
+ case 0:
20
+ _a.trys.push([0, 3, , 4]);
21
+ return [4 /*yield*/, fetch("https://api.gemini.com/v2/ticker/".concat(String(arg.value).toLowerCase()), {
22
+ method: "GET",
23
+ })];
24
+ case 1:
25
+ results = _a.sent();
26
+ return [4 /*yield*/, results.json()];
27
+ case 2:
28
+ values = _a.sent();
29
+ return [2 /*return*/, [[Number(values.ask), Number(values.bid)]]];
30
+ case 3:
31
+ err_1 = _a.sent();
32
+ throw new fast_formula_parser_1.FormulaError("#NULL!", String(err_1));
33
+ case 4: return [2 /*return*/];
34
+ }
35
+ });
36
+ }); };
37
+ (0, calculator_1.calculationPipeline)(parser, function (onUpdate) {
38
+ var timeout = setInterval(function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
39
+ var values;
40
+ return tslib_1.__generator(this, function (_a) {
41
+ switch (_a.label) {
42
+ case 0: return [4 /*yield*/, fetchPrices()];
43
+ case 1:
44
+ values = _a.sent();
45
+ if (values !== undefined) {
46
+ onUpdate(values);
47
+ }
48
+ return [2 /*return*/];
49
+ }
50
+ });
51
+ }); }, 5000);
52
+ console.log("Sub", timeout);
53
+ return function () {
54
+ console.log("Unsub", timeout);
55
+ clearInterval(timeout);
56
+ };
57
+ });
58
+ return [4 /*yield*/, fetchPrices()];
59
+ case 1: return [2 /*return*/, _a.sent()];
60
+ }
61
+ });
62
+ }); };
63
+ exports.CRYPTOPRICE = CRYPTOPRICE;
@@ -0,0 +1,4 @@
1
+ import { FunctionArgument, DataSource } from "@rowsncolumns/calculator";
2
+ import FormulaParser from "@rowsncolumns/fast-formula-parser";
3
+ export declare const DATASOURCE: (parser: FormulaParser, data: FunctionArgument, limit: FunctionArgument) => DataSource | undefined;
4
+ //# sourceMappingURL=datasource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../../formulas/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,aAA+B,MAAM,mCAAmC,CAAC;AAGhF,eAAO,MAAM,UAAU,GACrB,QAAQ,aAAa,EACrB,MAAM,gBAAgB,EACtB,OAAO,gBAAgB,KACtB,UAAU,GAAG,SAsBf,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DATASOURCE = void 0;
4
+ var calculator_1 = require("@rowsncolumns/calculator");
5
+ var fast_formula_parser_1 = require("@rowsncolumns/fast-formula-parser");
6
+ var utils_1 = require("@rowsncolumns/utils");
7
+ var DATASOURCE = function (parser, data, limit) {
8
+ if (parser.isPreview) {
9
+ return undefined;
10
+ }
11
+ if (!data.value || !Array.isArray(data.value)) {
12
+ // throw new FormulaError("#NA!", "Invalid data");
13
+ }
14
+ if (limit && !(0, utils_1.isNumber)(limit.value)) {
15
+ throw new fast_formula_parser_1.FormulaError("#NA!", "Limit should be a number");
16
+ }
17
+ var rowCount = (0, utils_1.isNil)(limit === null || limit === void 0 ? void 0 : limit.value) ? undefined : Number(limit.value);
18
+ var datasource = new calculator_1.DataSource(parser, parser.position, data.value, rowCount);
19
+ return datasource;
20
+ };
21
+ exports.DATASOURCE = DATASOURCE;
@@ -0,0 +1,5 @@
1
+ import type { FunctionArgument } from "@rowsncolumns/calculator";
2
+ import type FormulaParser from "@rowsncolumns/fast-formula-parser";
3
+ import type { CellData } from "@rowsncolumns/common-types";
4
+ export declare const FORMULATEXT: (parser: FormulaParser<CellData>, arg: FunctionArgument) => string;
5
+ //# sourceMappingURL=formula-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula-text.d.ts","sourceRoot":"","sources":["../../../formulas/formula-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAEnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,eAAO,MAAM,WAAW,GACtB,QAAQ,aAAa,CAAC,QAAQ,CAAC,EAC/B,KAAK,gBAAgB,WAatB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORMULATEXT = void 0;
4
+ var fast_formula_parser_1 = require("@rowsncolumns/fast-formula-parser");
5
+ var FORMULATEXT = function (parser, arg) {
6
+ var _a;
7
+ var cellData = parser.getCellData(arg.position);
8
+ var userEnteredValue = Array.isArray(cellData)
9
+ ? undefined
10
+ : (_a = cellData === null || cellData === void 0 ? void 0 : cellData.ue) !== null && _a !== void 0 ? _a : cellData === null || cellData === void 0 ? void 0 : cellData.userEnteredValue;
11
+ var formulaValue = userEnteredValue === null || userEnteredValue === void 0 ? void 0 : userEnteredValue.formulaValue;
12
+ if (formulaValue) {
13
+ return formulaValue;
14
+ }
15
+ throw new fast_formula_parser_1.FormulaError("#NA", "Invalid formula parse result.");
16
+ };
17
+ exports.FORMULATEXT = FORMULATEXT;
@@ -0,0 +1,32 @@
1
+ import type { FunctionArgument } from "@rowsncolumns/calculator";
2
+ /**
3
+ * GETPIVOTDATA(value_name, pivot_range, [field, item, ...])
4
+ *
5
+ * Looks up an aggregated value at the intersection of the named
6
+ * value column and the named field/item criteria within a rendered
7
+ * pivot range.
8
+ *
9
+ * Excel signature support:
10
+ * - GETPIVOTDATA("Sum of Revenue", $A$1)
11
+ * → grand total of "Sum of Revenue" (no criteria)
12
+ * - GETPIVOTDATA("Sum of Revenue", $A$1, "Region", "West")
13
+ * → cell at intersection where Region=West
14
+ * - GETPIVOTDATA("Sum of Revenue", $A$1, "Region", "West", "Year", 2024)
15
+ * → multi-field criteria, ANDed
16
+ *
17
+ * This implementation treats the pivot range as a 2D matrix and
18
+ * does header-matching: it scans the leading row(s) for column-
19
+ * dimension headers, the leading column(s) for row-dimension
20
+ * headers, and resolves the requested value at the intersection.
21
+ *
22
+ * Returns `#REF!` if criteria don't resolve to a unique cell, or
23
+ * `#NA!` if `value_name` isn't found in the range.
24
+ *
25
+ * Limitations vs Excel:
26
+ * - Doesn't honor pivot scoping (which pivot owns the cell). We
27
+ * work off the provided range only.
28
+ * - Doesn't auto-derive "Sum of X" / "Avg of X" — caller must
29
+ * pass the rendered header verbatim.
30
+ */
31
+ export declare const GETPIVOTDATA: (_parser: unknown, valueName: FunctionArgument, pivotRange: FunctionArgument, ...criteria: FunctionArgument[]) => unknown;
32
+ //# sourceMappingURL=get-pivot-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-pivot-data.d.ts","sourceRoot":"","sources":["../../../formulas/get-pivot-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY,GACvB,SAAS,OAAO,EAChB,WAAW,gBAAgB,EAC3B,YAAY,gBAAgB,EAC5B,GAAG,UAAU,gBAAgB,EAAE,KAC9B,OA4HF,CAAC"}
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GETPIVOTDATA = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var fast_formula_parser_1 = require("@rowsncolumns/fast-formula-parser");
6
+ /**
7
+ * GETPIVOTDATA(value_name, pivot_range, [field, item, ...])
8
+ *
9
+ * Looks up an aggregated value at the intersection of the named
10
+ * value column and the named field/item criteria within a rendered
11
+ * pivot range.
12
+ *
13
+ * Excel signature support:
14
+ * - GETPIVOTDATA("Sum of Revenue", $A$1)
15
+ * → grand total of "Sum of Revenue" (no criteria)
16
+ * - GETPIVOTDATA("Sum of Revenue", $A$1, "Region", "West")
17
+ * → cell at intersection where Region=West
18
+ * - GETPIVOTDATA("Sum of Revenue", $A$1, "Region", "West", "Year", 2024)
19
+ * → multi-field criteria, ANDed
20
+ *
21
+ * This implementation treats the pivot range as a 2D matrix and
22
+ * does header-matching: it scans the leading row(s) for column-
23
+ * dimension headers, the leading column(s) for row-dimension
24
+ * headers, and resolves the requested value at the intersection.
25
+ *
26
+ * Returns `#REF!` if criteria don't resolve to a unique cell, or
27
+ * `#NA!` if `value_name` isn't found in the range.
28
+ *
29
+ * Limitations vs Excel:
30
+ * - Doesn't honor pivot scoping (which pivot owns the cell). We
31
+ * work off the provided range only.
32
+ * - Doesn't auto-derive "Sum of X" / "Avg of X" — caller must
33
+ * pass the rendered header verbatim.
34
+ */
35
+ var GETPIVOTDATA = function (_parser, valueName, pivotRange) {
36
+ var e_1, _a, e_2, _b, e_3, _c;
37
+ var _d, _e, _f, _g, _h, _j, _k, _l, _m;
38
+ var criteria = [];
39
+ for (var _i = 3; _i < arguments.length; _i++) {
40
+ criteria[_i - 3] = arguments[_i];
41
+ }
42
+ if (valueName == null || pivotRange == null) {
43
+ throw new fast_formula_parser_1.FormulaError("#NA!", "GETPIVOTDATA requires value name and pivot range");
44
+ }
45
+ var target = String((_d = valueName.value) !== null && _d !== void 0 ? _d : "")
46
+ .trim()
47
+ .toLowerCase();
48
+ if (!target) {
49
+ throw new fast_formula_parser_1.FormulaError("#NA!", "GETPIVOTDATA value name is empty");
50
+ }
51
+ // The pivot range arrives as a 2-D array (FunctionArgument.value
52
+ // for a CellRange is rows[cols][]). Single-cell args come in as
53
+ // a scalar — coerce to the 2D shape.
54
+ var raw = pivotRange.value;
55
+ var matrix = Array.isArray(raw)
56
+ ? Array.isArray(raw[0])
57
+ ? raw
58
+ : [raw]
59
+ : [[raw]];
60
+ if (matrix.length === 0 || matrix[0].length === 0) {
61
+ throw new fast_formula_parser_1.FormulaError("#REF!", "GETPIVOTDATA range is empty");
62
+ }
63
+ // Parse criteria into pairs.
64
+ var pairs = [];
65
+ for (var i = 0; i < criteria.length; i += 2) {
66
+ var field = String((_f = (_e = criteria[i]) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : "")
67
+ .trim()
68
+ .toLowerCase();
69
+ var item = String((_h = (_g = criteria[i + 1]) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : "")
70
+ .trim()
71
+ .toLowerCase();
72
+ if (!field)
73
+ continue;
74
+ pairs.push({ field: field, item: item });
75
+ }
76
+ var cellAt = function (r, c) {
77
+ var _a, _b;
78
+ return String((_b = (_a = matrix[r]) === null || _a === void 0 ? void 0 : _a[c]) !== null && _b !== void 0 ? _b : "")
79
+ .trim()
80
+ .toLowerCase();
81
+ };
82
+ // Find the value column: scan all cells; the topmost row that
83
+ // contains `target` is the value-header row, and we record the
84
+ // column index. Excel typically puts these in row 0 or 1 of the
85
+ // rendered range.
86
+ var numRows = matrix.length;
87
+ var numCols = matrix[0].length;
88
+ var valueColumn = -1;
89
+ var valueHeaderRow = -1;
90
+ outer: for (var r = 0; r < numRows; r++) {
91
+ for (var c = 0; c < numCols; c++) {
92
+ if (cellAt(r, c) === target) {
93
+ valueColumn = c;
94
+ valueHeaderRow = r;
95
+ break outer;
96
+ }
97
+ }
98
+ }
99
+ if (valueColumn < 0) {
100
+ throw new fast_formula_parser_1.FormulaError("#NA!", "GETPIVOTDATA: value '".concat(valueName.value, "' not found in range"));
101
+ }
102
+ // No criteria → assume the grand-total cell. Convention in Excel
103
+ // is the last row of the value column (after subtotals settle).
104
+ // Fall back to first non-header cell if no row qualifies.
105
+ if (pairs.length === 0) {
106
+ for (var r = numRows - 1; r > valueHeaderRow; r--) {
107
+ var v = (_j = matrix[r]) === null || _j === void 0 ? void 0 : _j[valueColumn];
108
+ if (v != null && v !== "")
109
+ return v;
110
+ }
111
+ return (_l = (_k = matrix[valueHeaderRow + 1]) === null || _k === void 0 ? void 0 : _k[valueColumn]) !== null && _l !== void 0 ? _l : null;
112
+ }
113
+ // Match a row: for each criterion (field, item), find the
114
+ // column where the header row contains `field`, then check the
115
+ // candidate row's cell at that column equals `item`. ALL pairs
116
+ // must match (AND).
117
+ var fieldColumns = new Map();
118
+ try {
119
+ for (var pairs_1 = tslib_1.__values(pairs), pairs_1_1 = pairs_1.next(); !pairs_1_1.done; pairs_1_1 = pairs_1.next()) {
120
+ var field = pairs_1_1.value.field;
121
+ for (var c = 0; c < numCols; c++) {
122
+ // Find any row where header[r][c] === field. Excel pivots
123
+ // typically place row dimensions in left columns; we find
124
+ // any column whose header anywhere in the leading rows
125
+ // matches.
126
+ var matched = false;
127
+ for (var r = 0; r <= valueHeaderRow; r++) {
128
+ if (cellAt(r, c) === field) {
129
+ fieldColumns.set(field, c);
130
+ matched = true;
131
+ break;
132
+ }
133
+ }
134
+ if (matched)
135
+ break;
136
+ }
137
+ }
138
+ }
139
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
140
+ finally {
141
+ try {
142
+ if (pairs_1_1 && !pairs_1_1.done && (_a = pairs_1.return)) _a.call(pairs_1);
143
+ }
144
+ finally { if (e_1) throw e_1.error; }
145
+ }
146
+ try {
147
+ // If any field can't be located → #REF!
148
+ for (var pairs_2 = tslib_1.__values(pairs), pairs_2_1 = pairs_2.next(); !pairs_2_1.done; pairs_2_1 = pairs_2.next()) {
149
+ var field = pairs_2_1.value.field;
150
+ if (!fieldColumns.has(field)) {
151
+ throw new fast_formula_parser_1.FormulaError("#REF!", "GETPIVOTDATA: field '".concat(field, "' not found"));
152
+ }
153
+ }
154
+ }
155
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
156
+ finally {
157
+ try {
158
+ if (pairs_2_1 && !pairs_2_1.done && (_b = pairs_2.return)) _b.call(pairs_2);
159
+ }
160
+ finally { if (e_2) throw e_2.error; }
161
+ }
162
+ for (var r = valueHeaderRow + 1; r < numRows; r++) {
163
+ var allMatch = true;
164
+ try {
165
+ for (var pairs_3 = (e_3 = void 0, tslib_1.__values(pairs)), pairs_3_1 = pairs_3.next(); !pairs_3_1.done; pairs_3_1 = pairs_3.next()) {
166
+ var _o = pairs_3_1.value, field = _o.field, item = _o.item;
167
+ var col = fieldColumns.get(field);
168
+ if (cellAt(r, col) !== item) {
169
+ allMatch = false;
170
+ break;
171
+ }
172
+ }
173
+ }
174
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
175
+ finally {
176
+ try {
177
+ if (pairs_3_1 && !pairs_3_1.done && (_c = pairs_3.return)) _c.call(pairs_3);
178
+ }
179
+ finally { if (e_3) throw e_3.error; }
180
+ }
181
+ if (allMatch) {
182
+ var v = (_m = matrix[r]) === null || _m === void 0 ? void 0 : _m[valueColumn];
183
+ return v !== null && v !== void 0 ? v : null;
184
+ }
185
+ }
186
+ throw new fast_formula_parser_1.FormulaError("#REF!", "GETPIVOTDATA: no row matches the supplied criteria");
187
+ };
188
+ exports.GETPIVOTDATA = GETPIVOTDATA;
@@ -0,0 +1,5 @@
1
+ import type { FunctionArgument } from "@rowsncolumns/calculator";
2
+ import type FormulaParser from "@rowsncolumns/fast-formula-parser";
3
+ import { type HyperlinkResult } from "@rowsncolumns/common-types";
4
+ export declare const HYPERLINK: (_: FormulaParser, url: FunctionArgument, title?: FunctionArgument) => HyperlinkResult | undefined;
5
+ //# sourceMappingURL=hyperlink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperlink.d.ts","sourceRoot":"","sources":["../../../formulas/hyperlink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGlE,eAAO,MAAM,SAAS,GACpB,GAAG,aAAa,EAChB,KAAK,gBAAgB,EACrB,QAAO,gBAAsB,KAC5B,eAAe,GAAG,SAepB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HYPERLINK = void 0;
4
+ var fast_formula_parser_1 = require("@rowsncolumns/fast-formula-parser");
5
+ var HYPERLINK = function (_, url, title) {
6
+ if (title === void 0) { title = url; }
7
+ if (!url.value) {
8
+ throw new fast_formula_parser_1.FormulaError("#VALUE!", "URL is required");
9
+ }
10
+ if (typeof url.value !== "string") {
11
+ throw new fast_formula_parser_1.FormulaError("#VALUE!", "URL should be a string");
12
+ }
13
+ if (typeof title.value !== "string") {
14
+ throw new fast_formula_parser_1.FormulaError("#VALUE!", "URL should be a string");
15
+ }
16
+ return {
17
+ title: title.value,
18
+ url: url.value,
19
+ kind: "hyperlink",
20
+ };
21
+ };
22
+ exports.HYPERLINK = HYPERLINK;
@@ -0,0 +1,5 @@
1
+ import type { FunctionArgument } from "@rowsncolumns/calculator";
2
+ import type FormulaParser from "@rowsncolumns/fast-formula-parser";
3
+ import { type ImageResult } from "@rowsncolumns/common-types";
4
+ export declare const IMAGE: (_: FormulaParser, url: FunctionArgument) => ImageResult;
5
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../formulas/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,eAAO,MAAM,KAAK,GAAI,GAAG,aAAa,EAAE,KAAK,gBAAgB,KAAG,WAW/D,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IMAGE = void 0;
4
+ var fast_formula_parser_1 = require("@rowsncolumns/fast-formula-parser");
5
+ var IMAGE = function (_, url) {
6
+ if (!url.value) {
7
+ throw new fast_formula_parser_1.FormulaError("#VALUE!", "URL is required");
8
+ }
9
+ if (typeof url.value !== "string") {
10
+ throw new fast_formula_parser_1.FormulaError("#VALUE!", "URL should be a string");
11
+ }
12
+ return {
13
+ imageUrl: url.value,
14
+ kind: "image",
15
+ };
16
+ };
17
+ exports.IMAGE = IMAGE;
@@ -0,0 +1,11 @@
1
+ import type { FunctionArgument } from "@rowsncolumns/calculator";
2
+ import type FormulaParser from "@rowsncolumns/fast-formula-parser";
3
+ /**
4
+ * // =IMPORTDATA("https://api.covidtracking.com/v1/us/daily.csv")
5
+ * =IMPORTDATA("https://api.covidtracking.com/v1/us/current.json")
6
+ * @param parser
7
+ * @param url
8
+ * @returns
9
+ */
10
+ export declare const IMPORTDATA: (parser: FormulaParser, url: FunctionArgument) => Promise<string[][] | undefined>;
11
+ //# sourceMappingURL=import-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-data.d.ts","sourceRoot":"","sources":["../../../formulas/import-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAInE;;;;;;GAMG;AAEH,eAAO,MAAM,UAAU,GAErB,QAAQ,aAAa,EACrB,KAAK,gBAAgB,oCAmBtB,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IMPORTDATA = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var fast_formula_parser_1 = require("@rowsncolumns/fast-formula-parser");
6
+ var toolkit_1 = require("@rowsncolumns/toolkit");
7
+ /**
8
+ * // =IMPORTDATA("https://api.covidtracking.com/v1/us/daily.csv")
9
+ * =IMPORTDATA("https://api.covidtracking.com/v1/us/current.json")
10
+ * @param parser
11
+ * @param url
12
+ * @returns
13
+ */
14
+ var IMPORTDATA = function (
15
+ // getContext,
16
+ parser, url) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
17
+ var fileExtension, response, results, err_1;
18
+ return tslib_1.__generator(this, function (_a) {
19
+ switch (_a.label) {
20
+ case 0:
21
+ if (!(url === null || url === void 0 ? void 0 : url.value) || typeof (url === null || url === void 0 ? void 0 : url.value) !== "string") {
22
+ throw new fast_formula_parser_1.FormulaError("#VALUE!", "URL is missing");
23
+ }
24
+ fileExtension = url.value.split(".").pop();
25
+ if (fileExtension && !(["tsv", "csv"].indexOf(fileExtension) !== -1)) {
26
+ throw new fast_formula_parser_1.FormulaError("#N/A", "Only CSV and TSV are supported by IMPORTDATA");
27
+ }
28
+ return [4 /*yield*/, fetch(url.value)];
29
+ case 1: return [4 /*yield*/, (_a.sent()).text()];
30
+ case 2:
31
+ response = _a.sent();
32
+ _a.label = 3;
33
+ case 3:
34
+ _a.trys.push([3, 5, , 6]);
35
+ return [4 /*yield*/, (0, toolkit_1.parseCSV)(response)];
36
+ case 4:
37
+ results = _a.sent();
38
+ return [2 /*return*/, results];
39
+ case 5:
40
+ err_1 = _a.sent();
41
+ throw new fast_formula_parser_1.FormulaError("#VALUE", String(err_1));
42
+ case 6: return [2 /*return*/];
43
+ }
44
+ });
45
+ }); };
46
+ exports.IMPORTDATA = IMPORTDATA;
@@ -0,0 +1,18 @@
1
+ export { IMPORTDATA } from "./import-data";
2
+ export { ARRAYFORMULA } from "./array-formula";
3
+ export { STARRATING } from "./star-rating";
4
+ export { HYPERLINK } from "./hyperlink";
5
+ export { REALTIME } from "./real-time";
6
+ export { CRYPTOPRICE } from "./crypto-price";
7
+ export { IMAGE } from "./image";
8
+ export { SELECTION_STATUS } from "./selection-status";
9
+ export { MULTIPLY } from "./multiply";
10
+ export { UNIQUE } from "./unique";
11
+ export { SEQUENCE } from "./sequence";
12
+ export { JOIN } from "./join";
13
+ export { SPLIT } from "./split";
14
+ export { DATASOURCE } from "./datasource";
15
+ export { FORMULATEXT } from "./formula-text";
16
+ export { SPARKLINE } from "./sparkline";
17
+ export { GETPIVOTDATA } from "./get-pivot-data";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../formulas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}