flowerbi 3.4.2 → 3.5.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.
@@ -15,6 +15,11 @@ export declare class QueryColumn<T extends FilterValue> {
15
15
  * @param filters Optional filters to apply.
16
16
  */
17
17
  count(filters?: FilterJson[]): AggregationJson;
18
+ /**
19
+ * Aggregates the column by counting distinct values.
20
+ * @param filters Optional filters to apply.
21
+ */
22
+ countDistinct(filters?: FilterJson[]): AggregationJson;
18
23
  /**
19
24
  * Aggregates the column by selecting the minimum value.
20
25
  * @param filters Optional filters to apply.
@@ -41,6 +41,13 @@ var QueryColumn = /** @class */ (function () {
41
41
  QueryColumn.prototype.count = function (filters) {
42
42
  return this.aggregation("Count", filters);
43
43
  };
44
+ /**
45
+ * Aggregates the column by counting distinct values.
46
+ * @param filters Optional filters to apply.
47
+ */
48
+ QueryColumn.prototype.countDistinct = function (filters) {
49
+ return this.aggregation("CountDistinct", filters);
50
+ };
44
51
  /**
45
52
  * Aggregates the column by selecting the minimum value.
46
53
  * @param filters Optional filters to apply.
@@ -1 +1 @@
1
- {"version":3,"file":"QueryColumn.js","sourceRoot":"","sources":["../src/QueryColumn.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;;GAGG;AACH;IACI;;OAEG;IACH,qBAA4B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAElC,iCAAW,GAArB,UAAsB,eAAgC,EAAE,OAAsB;QAC1E,OAAO;YACH,MAAM,EAAE,IAAI,CAAC,IAAI;YACjB,QAAQ,EAAE,eAAe;YACzB,OAAO,SAAA;SACV,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,2BAAK,GAAL,UAAM,OAAsB;QACxB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,yBAAG,GAAH,UAAI,OAAsB;QACtB,OAAO,IAAI,CA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,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,0CAAoB,GAApB,UAAqB,KAAQ;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,uCAAiB,GAAjB,UAAkB,KAAQ;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,wBAAE,GAAF,UAAG,KAA8C;QAC7C,OAAO;YACH,MAAM,EAAE,IAAI,CAAC,IAAI;YACjB,QAAQ,EAAE,IAAI;YACd,KAAK,OAAA;SACR,CAAC;IACN,CAAC;IACL,kBAAC;AAAD,CAAC,AA5HD,IA4HC;AA5HY,kCAAW;AA8HxB;IAA0E,sCAAc;IACpF;;OAEG;IACH,4BAA4B,IAAY;QAAxC,YACI,kBAAM,IAAI,CAAC,SACd;QAF2B,UAAI,GAAJ,IAAI,CAAQ;;IAExC,CAAC;IAED;;;OAGG;IACH,gCAAG,GAAH,UAAI,OAAsB;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,gCAAG,GAAH,UAAI,OAAsB;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IACL,yBAAC;AAAD,CAAC,AAvBD,CAA0E,WAAW,GAuBpF;AAvBY,gDAAkB"}
@@ -18,7 +18,7 @@ export interface FilterJson {
18
18
  /**
19
19
  * The allowed aggregation function names.
20
20
  */
21
- export declare type AggregationType = "Count" | "Sum" | "Avg" | "Min" | "Max";
21
+ export declare type AggregationType = "Count" | "Sum" | "Avg" | "Min" | "Max" | "CountDistinct";
22
22
  /**
23
23
  * Describes an aggregated values. It is always taken from one column, with
24
24
  * a function applied to it. Filters can optionally be supplied to limit
@@ -15,4 +15,4 @@ export declare function distinct<T>(arr: T[]): T[];
15
15
  *
16
16
  * @param obj The object to obtain keys from.
17
17
  */
18
- export declare function keysOf<T>(obj: T): (keyof T)[];
18
+ export declare function keysOf<T extends object>(obj: T): (keyof T)[];
@@ -1 +1 @@
1
- {"version":3,"file":"arrayHelpers.js","sourceRoot":"","sources":["../src/arrayHelpers.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,QAAQ,CAAI,GAAQ;IAChC,IAAM,GAAG,GAAyB,EAAE,CAAC;IAErC,KAAmB,UAAG,EAAH,WAAG,EAAH,iBAAG,EAAH,IAAG,EAAE;QAAnB,IAAM,IAAI,YAAA;QACX,GAAG,CAAC,UAAG,IAAI,CAAE,CAAC,GAAG,IAAI,CAAC;KACzB;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AARD,4BAQC;AAED;;;;;;;;;GASG;AACH,SAAgB,MAAM,CAAI,GAAM;IAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAgB,CAAC;AAC3C,CAAC;AAFD,wBAEC"}
1
+ {"version":3,"file":"arrayHelpers.js","sourceRoot":"","sources":["../src/arrayHelpers.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,QAAQ,CAAI,GAAQ;IAChC,IAAM,GAAG,GAAyB,EAAE,CAAC;IAErC,KAAmB,UAAG,EAAH,WAAG,EAAH,iBAAG,EAAH,IAAG,EAAE;QAAnB,IAAM,IAAI,YAAA;QACX,GAAG,CAAC,UAAG,IAAI,CAAE,CAAC,GAAG,IAAI,CAAC;KACzB;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AARD,4BAQC;AAED;;;;;;;;;GASG;AACH,SAAgB,MAAM,CAAmB,GAAM;IAC3C,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAgB,CAAC;AAC3C,CAAC;AAFD,wBAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowerbi",
3
- "version": "3.4.2",
3
+ "version": "3.5.0",
4
4
  "author": "Daniel Earwicker <dan@earwicker.com>",
5
5
  "license": "MIT",
6
6
  "description": "FlowerBI: ultra-minimal BI analytics query and UI tools",
@@ -26,6 +26,14 @@ export class QueryColumn<T extends FilterValue> {
26
26
  return this.aggregation("Count", filters);
27
27
  }
28
28
 
29
+ /**
30
+ * Aggregates the column by counting distinct values.
31
+ * @param filters Optional filters to apply.
32
+ */
33
+ countDistinct(filters?: FilterJson[]) {
34
+ return this.aggregation("CountDistinct", filters);
35
+ }
36
+
29
37
  /**
30
38
  * Aggregates the column by selecting the minimum value.
31
39
  * @param filters Optional filters to apply.
package/src/QueryJson.ts CHANGED
@@ -9,7 +9,7 @@ export type FilterOperator = "=" | "<>" | ">" | "<" | ">=" | "<=" | "IN";
9
9
  export type FilterValue = string | number | boolean | Date | unknown | string[] | number[];
10
10
 
11
11
  /**
12
- * Specifies a filter criterion. The column is specified by a string of the
12
+ * Specifies a filter criterion. The column is specified by a string of the
13
13
  * form `table.column`.
14
14
  */
15
15
  export interface FilterJson {
@@ -21,10 +21,10 @@ export interface FilterJson {
21
21
  /**
22
22
  * The allowed aggregation function names.
23
23
  */
24
- export type AggregationType = "Count" | "Sum" | "Avg" | "Min" | "Max";
24
+ export type AggregationType = "Count" | "Sum" | "Avg" | "Min" | "Max" | "CountDistinct";
25
25
 
26
26
  /**
27
- * Describes an aggregated values. It is always taken from one column, with
27
+ * Describes an aggregated values. It is always taken from one column, with
28
28
  * a function applied to it. Filters can optionally be supplied to limit
29
29
  * the set of rows included in the aggregation. The column is specified by a
30
30
  * string of the form `table.column`.
@@ -37,7 +37,7 @@ export interface AggregationJson {
37
37
 
38
38
  /**
39
39
  * Specifies an ordering criteria: which column to sort by, and optionally
40
- * whether it is descending (the default is ascending). The column is
40
+ * whether it is descending (the default is ascending). The column is
41
41
  * specified by a string of the form `table.column`.
42
42
  */
43
43
  export interface OrderingJson {
@@ -2,7 +2,7 @@
2
2
  * Returns the distinct (unique) values from an array. The comparison
3
3
  * method is very simplistic: all values are converted to strings
4
4
  * before comparison.
5
- * @param arr
5
+ * @param arr
6
6
  */
7
7
  export function distinct<T>(arr: T[]) {
8
8
  const map: { [key: string]: T } = {};
@@ -18,12 +18,12 @@ export function distinct<T>(arr: T[]) {
18
18
  * Returns the names of properties (i.e. the keys) in an object, statically
19
19
  * typed so each has the string literal type of one of the properties. This
20
20
  * is not always correct, because the type will include properties inherited
21
- * from the prototype, where as the values returned at runtime will never
21
+ * from the prototype, where as the values returned at runtime will never
22
22
  * include inherited properties. But it's a useful approximation in situations
23
23
  * where prototype inheritance can be ignored.
24
- *
24
+ *
25
25
  * @param obj The object to obtain keys from.
26
26
  */
27
- export function keysOf<T>(obj: T) {
27
+ export function keysOf<T extends object>(obj: T) {
28
28
  return Object.keys(obj) as (keyof T)[];
29
29
  }