@influxdata/influxdb-client-giraffe 1.34.0-nightly.3719 → 1.34.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.
- package/dist/index.d.mts +92 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { FluxTableMetaData, FluxResultObserver, QueryApi, ParameterizedQuery } from '@influxdata/influxdb-client';
|
|
2
|
+
import { Table, FromFluxResult } from '@influxdata/giraffe';
|
|
3
|
+
|
|
4
|
+
/** A type of a function that creates a new giraffe table of a specified length */
|
|
5
|
+
type GiraffeTableFactory = (length: number) => Table;
|
|
6
|
+
/**
|
|
7
|
+
* AcceptRowFunction allows to accept/reject specific rows or terminate processing.
|
|
8
|
+
* @param row - CSV result data row
|
|
9
|
+
* @param tableMeta - CSV table metadata with column descriptors
|
|
10
|
+
* @returns true to accept row, false to skip row, undefined means stop processing
|
|
11
|
+
**/
|
|
12
|
+
type AcceptRowFunction = (row: string[], tableMeta: FluxTableMetaData) => true | false | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Contains parameters that optimize/drive creation of the query result Table.
|
|
15
|
+
*/
|
|
16
|
+
interface TableOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Accept allows to accept/reject specific rows or terminate processing.
|
|
19
|
+
**/
|
|
20
|
+
accept?: AcceptRowFunction | AcceptRowFunction[];
|
|
21
|
+
/**
|
|
22
|
+
* Sets maximum table length, QUERY_MAX_TABLE_LENGTH when undefined.
|
|
23
|
+
*/
|
|
24
|
+
maxTableLength?: number;
|
|
25
|
+
/** column keys to collect in the table, undefined means all columns */
|
|
26
|
+
columns?: string[];
|
|
27
|
+
/** compute also fluxGroupKeyUnion */
|
|
28
|
+
computeFluxGroupKeyUnion?: boolean;
|
|
29
|
+
/** compute also resultColumnNames */
|
|
30
|
+
computeResultColumnNames?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* QUERY_MAX_TABLE_LENGTH is a default max table length,
|
|
34
|
+
* it can be overriden in TableOptions.
|
|
35
|
+
*/
|
|
36
|
+
declare const QUERY_MAX_TABLE_LENGTH = 100000;
|
|
37
|
+
/**
|
|
38
|
+
* Creates an accept function that stops processing
|
|
39
|
+
* if the table reaches the specified max rows.
|
|
40
|
+
* @param size - maximum processed rows
|
|
41
|
+
* @returns AcceptRowFunction that enforces that most max rows are processed
|
|
42
|
+
*/
|
|
43
|
+
declare function acceptMaxTableLength(max: number): AcceptRowFunction;
|
|
44
|
+
/**
|
|
45
|
+
* Creates influxdb-client-js's FluxResultObserver that collects row results to a Table instance
|
|
46
|
+
* @param resolve - called when the Table is collected
|
|
47
|
+
* @param reject - called upon error
|
|
48
|
+
* @param tableOptions - tableOptions allow to filter or even stop the processing of rows, or restrict the columns to collect
|
|
49
|
+
* @returns FluxResultObserver that collects table data from result rows
|
|
50
|
+
*/
|
|
51
|
+
declare function createCollector(resolve: (value: FromFluxResult) => void, reject: (reason?: any) => void, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): FluxResultObserver<string[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Transforms annotated CSV query response to Giraffe's FromFluxResult.
|
|
54
|
+
*
|
|
55
|
+
* @param csv - annotated CSV flux query response
|
|
56
|
+
* @param tableFactory - creates a new Giraffe table
|
|
57
|
+
* @param tableOptions - tableOptions allows to filter or even stop the processing of rows, specify maximum rows or restrict the columns to collect
|
|
58
|
+
* @returns a new FromFluxResult instance
|
|
59
|
+
*/
|
|
60
|
+
declare function csvToFromFluxResult(csv: string, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): FromFluxResult;
|
|
61
|
+
/**
|
|
62
|
+
* Transforms annotated CSV query response to Giraffe's Table.
|
|
63
|
+
*
|
|
64
|
+
* @param csv - annotated CSV flux query response
|
|
65
|
+
* @param tableFactory - creates a new Giraffe table
|
|
66
|
+
* @param tableOptions - tableOptions allows to filter or even stop the processing of rows, specify maximum rows or restrict the columns to collect.
|
|
67
|
+
* @returns a new Table instance
|
|
68
|
+
*/
|
|
69
|
+
declare function csvToTable(csv: string, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): Table;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Executes a flux query and collects results into a Giraffe's Table.
|
|
73
|
+
*
|
|
74
|
+
* @param queryApi - InfluxDB client's QueryApi instance
|
|
75
|
+
* @param query - query to execute
|
|
76
|
+
* @param tableFactory - creates a new Giraffe table
|
|
77
|
+
* @param tableOptions - tableOptions allows to filter or even stop the processing of rows, specify maximum rows or restrict the columns to collect.
|
|
78
|
+
* @returns Promise with query results
|
|
79
|
+
*/
|
|
80
|
+
declare function queryToTable(queryApi: QueryApi, query: string | ParameterizedQuery, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): Promise<Table>;
|
|
81
|
+
/**
|
|
82
|
+
* Executes a flux query and iterrativelly collects results into a Giraffe's FromFluxResult.
|
|
83
|
+
*
|
|
84
|
+
* @param queryApi - InfluxDB client's QueryApi instance
|
|
85
|
+
* @param query - query to execute
|
|
86
|
+
* @param tableFactory - creates a new Giraffe table
|
|
87
|
+
* @param tableOptions - tableOptions allows to filter or even stop the processing of rows, specify maximum rows or restrict the columns to collect
|
|
88
|
+
* @returns a Promise with query results
|
|
89
|
+
*/
|
|
90
|
+
declare function queryToFromFluxResult(queryApi: QueryApi, query: string | ParameterizedQuery, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): Promise<FromFluxResult>;
|
|
91
|
+
|
|
92
|
+
export { type AcceptRowFunction, type GiraffeTableFactory, QUERY_MAX_TABLE_LENGTH, type TableOptions, acceptMaxTableLength, createCollector, csvToFromFluxResult, csvToTable, queryToFromFluxResult, queryToTable };
|
package/dist/index.d.ts
CHANGED
|
@@ -89,4 +89,4 @@ declare function queryToTable(queryApi: QueryApi, query: string | ParameterizedQ
|
|
|
89
89
|
*/
|
|
90
90
|
declare function queryToFromFluxResult(queryApi: QueryApi, query: string | ParameterizedQuery, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): Promise<FromFluxResult>;
|
|
91
91
|
|
|
92
|
-
export { AcceptRowFunction, GiraffeTableFactory, QUERY_MAX_TABLE_LENGTH, TableOptions, acceptMaxTableLength, createCollector, csvToFromFluxResult, csvToTable, queryToFromFluxResult, queryToTable };
|
|
92
|
+
export { type AcceptRowFunction, type GiraffeTableFactory, QUERY_MAX_TABLE_LENGTH, type TableOptions, acceptMaxTableLength, createCollector, csvToFromFluxResult, csvToTable, queryToFromFluxResult, queryToTable };
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@influxdata/influxdb-client-giraffe"] = {}));
|
|
5
5
|
})(this, (function (exports) {
|
|
6
|
-
"use strict";var g=(()=>{var b=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var B=(e,r)=>{for(var t in r)b(e,t,{get:r[t],enumerable:!0})},
|
|
7
|
-
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:
|
|
8
|
-
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};function
|
|
6
|
+
"use strict";var g=(()=>{var b=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var B=(e,r)=>{for(var t in r)b(e,t,{get:r[t],enumerable:!0})},N=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of $(r))!L.call(e,s)&&s!==t&&b(e,s,{get:()=>r[s],enumerable:!(n=A(r,s))||n.enumerable});return e};var _=e=>N(b({},"__esModule",{value:!0}),e);var re={};B(re,{QUERY_MAX_TABLE_LENGTH:()=>S,acceptMaxTableLength:()=>D,createCollector:()=>y,csvToFromFluxResult:()=>O,csvToTable:()=>Z,queryToFromFluxResult:()=>te,queryToTable:()=>ee});var M=class{constructor(){this._reuse=!1}get reuse(){return this._reuse}set reuse(e){e&&!this.reusedValues&&(this.reusedValues=new Array(10)),this._reuse=e}withReuse(){return this.reuse=!0,this}splitLine(e){if(e==null)return this.lastSplitLength=0,[];let r=0,t=0,n=this._reuse?this.reusedValues:[],s=0;for(let i=0;i<e.length;i++){let c=e[i];if(c===","){if(r%2===0){let u=this.getValue(e,t,i,r);this._reuse?n[s++]=u:n.push(u),t=i+1,r=0}}else c==='"'&&r++}let o=this.getValue(e,t,e.length,r);return this._reuse?(n[s]=o,this.lastSplitLength=s+1):(n.push(o),this.lastSplitLength=n.length),n}getValue(e,r,t,n){return r===e.length?"":n===0?e.substring(r,t):n===2?e.substring(r+1,t-1):e.substring(r+1,t-1).replace(/""/gi,'"')}},x=e=>e,P={boolean:e=>e===""?null:e==="true",unsignedLong:e=>e===""?null:+e,long:e=>e===""?null:+e,double(e){switch(e){case"":return null;case"+Inf":return Number.POSITIVE_INFINITY;case"-Inf":return Number.NEGATIVE_INFINITY;default:return+e}},string:x,base64Binary:x,duration:e=>e===""?null:e,"dateTime:RFC3339":e=>e===""?null:e},U=class{get(e){var r;let t=e[this.index];return(t===""||t===void 0)&&this.defaultValue&&(t=this.defaultValue),((r=P[this.dataType])!=null?r:x)(t)}},k=Object.freeze({label:"",dataType:"",group:!1,defaultValue:"",index:Number.MAX_SAFE_INTEGER,get:()=>{}});function I(){return new U}var j=class v extends Error{constructor(r){super(r),this.name="IllegalArgumentError",Object.setPrototypeOf(this,v.prototype)}};var z=class{constructor(e){e.forEach((r,t)=>r.index=t),this.columns=e}column(e,r=!0){for(let t=0;t<this.columns.length;t++){let n=this.columns[t];if(n.label===e)return n}if(r)throw new j(`Column ${e} not found!`);return k}toObject(e){let r={};for(let t=0;t<this.columns.length&&t<e.length;t++){let n=this.columns[t];r[n.label]=n.get(e)}return r}get(e,r){return this.column(r,!1).get(e)}};function V(e){return new z(e)}function C(e){let r=new M().withReuse(),t,n=!0,s=0,o,i={error(c){e.error(c)},next(c){if(c==="")n=!0,t=void 0;else{let u=r.splitLine(c),a=r.lastSplitLength;if(n){if(!t){t=new Array(a);for(let l=0;l<a;l++)t[l]=I()}if(u[0].startsWith("#")){if(u[0]==="#datatype")for(let l=1;l<a;l++)t[l].dataType=u[l];else if(u[0]==="#default")for(let l=1;l<a;l++)t[l].defaultValue=u[l];else if(u[0]==="#group")for(let l=1;l<a;l++)t[l].group=u[l][0]==="t"}else{u[0]===""?(s=1,t=t.slice(1)):s=0;for(let l=s;l<a;l++)t[l-s].label=u[l];o=V(t),n=!1}}else return e.next(u.slice(s,a),o)}return!0},complete(){e.complete()}};return e.useCancellable&&(i.useCancellable=e.useCancellable.bind(e)),e.useResume&&(i.useResume=e.useResume.bind(e)),i}function F(e,r){let t=!1,n=0,s=0;for(;s<e.length;){let o=e.charCodeAt(s);if(o===10){if(!t){let i=s>0&&e.charCodeAt(s-1)===13?s-1:s;r.next(e.substring(n,i)),n=s+1}}else o===34&&(t=!t);s++}n<s&&r.next(e.substring(n,s)),r.complete()}var q=typeof Symbol=="function"&&Symbol.observable||"@@observable",H=class{constructor(e,r){this.isClosed=!1;try{r({next:t=>{e.next(t)},error:t=>{this.isClosed=!0,e.error(t)},complete:()=>{this.isClosed=!0,e.complete()},useCancellable:t=>{this.cancellable=t}})}catch(t){this.isClosed=!0,e.error(t)}}get closed(){return this.isClosed}unsubscribe(){var e;(e=this.cancellable)==null||e.cancel(),this.isClosed=!0}};function w(){}function G(e){let{next:r,error:t,complete:n}=e;return{next:r?r.bind(e):w,error:t?t.bind(e):w,complete:n?n.bind(e):w}}var se=class{constructor(e,r){this.executor=e,this.decorator=r}subscribe(e,r,t){let n=G(typeof e!="object"||e===null?{next:e,error:r,complete:t}:e);return new H(this.decorator(n),this.executor)}[q](){return this}};function T(e,r){return function(t){let n="",s=0,o=0;for(;o<t.length;){let i=e.indexOf(t[o]);i>=0&&(n+=t.substring(s,o),n+=r[i],s=o+1),o++}return s==0?t:(s<t.length&&(n+=t.substring(s,t.length)),n)}}function W(e,r){let t=T(e,r);return n=>'"'+t(n)+'"'}var ie={measurement:T(`,
|
|
7
|
+
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:W('"\\',['\\"',"\\\\"]),tag:T(`, =
|
|
8
|
+
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};function J(e){return!1}J(!0);var oe=Date.now();var K=Symbol("FLUX_VALUE"),le=class{constructor(e){this.fluxValue=e}toString(){return this.fluxValue}[K](){return this.fluxValue}};function E(e,r,t,{computeFluxGroupKeyUnion:n,computeResultColumnNames:s}){let o=t(e),i=[],c=new Set;return Object.keys(r).forEach(u=>{let a=r[u];a.multipleTypes||(a.data.length=e,o=o.addColumn(u,a.fluxDataType,a.type,a.data,a.name),n&&a.group&&i.push(u),s&&a.name==="result"&&a.data.forEach(l=>c.add(l)))}),{table:o,fluxGroupKeyUnion:i,resultColumnNames:Array.from(c)}}var S=1e5;function D(e){let r=0;return()=>{if(r>=e){console.log(`csv2Table: max table length ${e} reached, processing stopped`);return}return r++,!0}}function Q(e){let r=e.maxTableLength===void 0?S:e.maxTableLength,t=[];return e.accept&&(Array.isArray(e.accept)?t.push(...e.accept):t.push(e.accept)),t.push(D(r)),(n,s)=>{for(let o=0;o<t.length;o++){let i=t[o](n,s);if(i===void 0||i===!1)return i}return!0}}function X(e,r,t){switch(r){case"boolean":return n=>(n[e]===""?t:n[e])==="true";case"number":return n=>{let s=n[e]===""?t:n[e];return s===""?null:Number(s)};case"time":return n=>Date.parse(n[e]===""?t:n[e]);default:return n=>n[e]===""?t:n[e]}}function Y(e){switch(e){case"boolean":return"boolean";case"unsignedLong":case"long":case"double":return"number";default:return e&&e.startsWith("dateTime")?"time":"string"}}function y(e,r,t,n={}){let{columns:s}=n,o=Q(n),i={},c,u,a=0,l;return{next(d,g){switch(o(d,g)){case!0:break;case!1:return;default:l==null||l.cancel();return}if(g!==u){c=[];for(let h of g.columns){let p=Y(h.dataType);if(s&&!s.includes(h.label))continue;let m=h.label,f=i[m];f&&(f.multipleTypes?(m=`${h.label} (${p})`,f=i[m]):f.type!==p&&(i[`${f.name} (${f.type})`]=f,i[h.label]={name:h.label,multipleTypes:!0},m=`${h.label} (${p})`,f=i[m]));let R={name:h.label,fluxDataType:h.dataType,type:p,data:f?f.data:[],group:(f==null?void 0:f.group)||h.group,toValue:X(h.index,p,h.defaultValue)};c.push(R),i[m]=R}u=g}for(let h=0;h<c.length;h++){let p=c[h];p.data[a]=p.toValue(d)}a++},complete(){e(E(a,i,t,n))},error(d){d.name==="AbortError"&&(console.log("queryTable: request aborted:",d),e(E(a,i,t,n))),r(d)},useCancellable(d){l=d}}}function O(e,r,t){let n,s,o=y(i=>n=i,i=>s=i,r,{computeFluxGroupKeyUnion:!0,computeResultColumnNames:!0,...t});if(F(e,C(o)),s)throw s;return n}function Z(e,r,t){return O(e,r,{computeFluxGroupKeyUnion:!1,...t}).table}function ee(e,r,t,n){return new Promise((s,o)=>{e.queryRows(r,y(s,o,t,n))}).then(s=>s.table)}function te(e,r,t,n){return new Promise((s,o)=>{e.queryRows(r,y(s,o,t,{...n,computeFluxGroupKeyUnion:!0}))})}return _(re);})();
|
|
9
9
|
Object.defineProperty(exports, '__esModule', { value: true });Object.assign(exports, g);}));
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.gz
CHANGED
|
Binary file
|