Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@axiomhq/js

Package Overview
Dependencies
Maintainers
8
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axiomhq/js - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

65

dist/cjs/types/client.d.ts

@@ -40,3 +40,3 @@ /// <reference types="node" />

* @param options - optional query options
* @returns result of the query, check: {@link QueryResult}
* @returns result of the query depending on the format in options, check: {@link QueryResult} and {@link TabularQueryResult}
*

@@ -49,3 +49,3 @@ * @example

*/
query: (apl: string, options?: QueryOptions) => Promise<QueryResult>;
query: <TOptions extends QueryOptions, TResult = TOptions["format"] extends "tabular" ? Promise<TabularQueryResult> : Promise<QueryResult>>(apl: string, options?: TOptions) => Promise<TResult>;
/**

@@ -64,3 +64,3 @@ * Executes APL query using the provided APL and returns the result.

*/
aplQuery: (apl: string, options?: QueryOptions) => Promise<QueryResult>;
aplQuery: <TOptions extends QueryOptions, TResult = TOptions["format"] extends "tabular" ? Promise<TabularQueryResult> : Promise<QueryResult>>(apl: string, options?: TOptions) => Promise<TResult>;
}

@@ -202,2 +202,3 @@ /**

endTime?: string;
format?: 'legacy' | 'tabular';
}

@@ -224,2 +225,7 @@ export interface QueryLegacy {

}
export interface TabularAggregation {
name: AggregationOp;
args: any[];
fields: string[];
}
export declare enum AggregationOp {

@@ -300,2 +306,55 @@ Count = "count",

}
export interface RawTabularQueryResult {
datasetNames: string[];
fieldsMetaMap: Record<string, Array<{
description: string;
hidden: boolean;
name: string;
type: string;
unit: string;
}>>;
format: string;
status: Status;
tables: Array<RawAPLResultTable>;
}
export interface TabularQueryResult extends RawTabularQueryResult {
tables: Array<APLResultTable>;
}
export interface RawAPLResultTable {
name: string;
sources: Array<{
name: string;
}>;
fields: Array<{
name: string;
type: string;
agg?: TabularAggregation;
}>;
order: Array<{
name: string;
desc: boolean;
}>;
groups: Array<{
name: string;
}>;
range?: {
field: string;
start: string;
end: string;
};
buckets?: {
field: string;
size: any;
};
columns?: Array<Array<any>>;
}
export interface APLResultTable extends RawAPLResultTable {
/**
* Returns an iterable that yields each row of the table as a record,
* where the keys are the field names and the values are the values in the columns.
*
* @returns {Generator<Record<string, any>, undefined, unknown>}
*/
events: () => Generator<Record<string, any>, undefined, unknown>;
}
export interface Timeseries {

@@ -302,0 +361,0 @@ series?: Array<Interval>;

2

dist/cjs/types/index.d.ts

@@ -1,2 +0,2 @@

export { AxiomWithoutBatching, Axiom, ContentType, ContentEncoding, IngestOptions, IngestStatus, IngestFailure, QueryOptionsBase, QueryOptions, QueryLegacy, Aggregation, AggregationOp, Filter, FilterOp, Order, Projection, VirtualColumn, QueryLegacyResult, QueryResult, Timeseries, Interval, EntryGroup, EntryGroupAgg, Entry, Status, Message, Query } from './client.js';
export { AxiomWithoutBatching, Axiom, ContentType, ContentEncoding, IngestOptions, IngestStatus, IngestFailure, QueryOptionsBase, QueryOptions, QueryLegacy, Aggregation, AggregationOp, Filter, FilterOp, Order, Projection, VirtualColumn, QueryResult, QueryLegacyResult, TabularQueryResult, RawTabularQueryResult, Timeseries, Interval, EntryGroup, EntryGroupAgg, Entry, Status, Message, Query } from './client.js';
export { ClientOptions } from './httpClient.js';

@@ -3,0 +3,0 @@ export { datasets } from './datasets.js';

@@ -77,3 +77,3 @@ import { datasets } from './datasets.js';

* @param options - optional query options
* @returns result of the query, check: {@link QueryResult}
* @returns result of the query depending on the format in options, check: {@link QueryResult} and {@link TabularQueryResult}
*

@@ -94,3 +94,4 @@ * @example

}
return this.client.post(this.localPath + '/datasets/_apl', {
return this.client
.post(this.localPath + '/datasets/_apl', {
body: JSON.stringify(req),

@@ -100,3 +101,31 @@ }, {

nocache: options?.noCache,
format: 'legacy',
format: options?.format ?? 'legacy',
})
.then((res) => {
if (options?.format !== 'tabular') {
return res;
}
const result = res;
return {
...res,
tables: result.tables.map((t) => {
return {
...t,
events: function* () {
let iteration = 0;
if (!this.columns) {
return;
}
while (iteration <= this.columns[0].length) {
const value = Object.fromEntries(this.fields.map((field, fieldIdx) => [field.name, this.columns[fieldIdx][iteration]]));
if (iteration >= this.columns[0].length) {
return value;
}
yield value;
iteration++;
}
},
};
}),
};
});

@@ -103,0 +132,0 @@ };

import { FetchClient } from './fetchClient.js';
const Version = '1.1.1';
const Version = '1.2.0';
const AxiomURL = 'https://api.axiom.co';

@@ -5,0 +5,0 @@ class HTTPClient {

@@ -40,3 +40,3 @@ /// <reference types="node" />

* @param options - optional query options
* @returns result of the query, check: {@link QueryResult}
* @returns result of the query depending on the format in options, check: {@link QueryResult} and {@link TabularQueryResult}
*

@@ -49,3 +49,3 @@ * @example

*/
query: (apl: string, options?: QueryOptions) => Promise<QueryResult>;
query: <TOptions extends QueryOptions, TResult = TOptions["format"] extends "tabular" ? Promise<TabularQueryResult> : Promise<QueryResult>>(apl: string, options?: TOptions) => Promise<TResult>;
/**

@@ -64,3 +64,3 @@ * Executes APL query using the provided APL and returns the result.

*/
aplQuery: (apl: string, options?: QueryOptions) => Promise<QueryResult>;
aplQuery: <TOptions extends QueryOptions, TResult = TOptions["format"] extends "tabular" ? Promise<TabularQueryResult> : Promise<QueryResult>>(apl: string, options?: TOptions) => Promise<TResult>;
}

@@ -202,2 +202,3 @@ /**

endTime?: string;
format?: 'legacy' | 'tabular';
}

@@ -224,2 +225,7 @@ export interface QueryLegacy {

}
export interface TabularAggregation {
name: AggregationOp;
args: any[];
fields: string[];
}
export declare enum AggregationOp {

@@ -300,2 +306,55 @@ Count = "count",

}
export interface RawTabularQueryResult {
datasetNames: string[];
fieldsMetaMap: Record<string, Array<{
description: string;
hidden: boolean;
name: string;
type: string;
unit: string;
}>>;
format: string;
status: Status;
tables: Array<RawAPLResultTable>;
}
export interface TabularQueryResult extends RawTabularQueryResult {
tables: Array<APLResultTable>;
}
export interface RawAPLResultTable {
name: string;
sources: Array<{
name: string;
}>;
fields: Array<{
name: string;
type: string;
agg?: TabularAggregation;
}>;
order: Array<{
name: string;
desc: boolean;
}>;
groups: Array<{
name: string;
}>;
range?: {
field: string;
start: string;
end: string;
};
buckets?: {
field: string;
size: any;
};
columns?: Array<Array<any>>;
}
export interface APLResultTable extends RawAPLResultTable {
/**
* Returns an iterable that yields each row of the table as a record,
* where the keys are the field names and the values are the values in the columns.
*
* @returns {Generator<Record<string, any>, undefined, unknown>}
*/
events: () => Generator<Record<string, any>, undefined, unknown>;
}
export interface Timeseries {

@@ -302,0 +361,0 @@ series?: Array<Interval>;

@@ -1,2 +0,2 @@

export { AxiomWithoutBatching, Axiom, ContentType, ContentEncoding, IngestOptions, IngestStatus, IngestFailure, QueryOptionsBase, QueryOptions, QueryLegacy, Aggregation, AggregationOp, Filter, FilterOp, Order, Projection, VirtualColumn, QueryLegacyResult, QueryResult, Timeseries, Interval, EntryGroup, EntryGroupAgg, Entry, Status, Message, Query } from './client.js';
export { AxiomWithoutBatching, Axiom, ContentType, ContentEncoding, IngestOptions, IngestStatus, IngestFailure, QueryOptionsBase, QueryOptions, QueryLegacy, Aggregation, AggregationOp, Filter, FilterOp, Order, Projection, VirtualColumn, QueryResult, QueryLegacyResult, TabularQueryResult, RawTabularQueryResult, Timeseries, Interval, EntryGroup, EntryGroupAgg, Entry, Status, Message, Query } from './client.js';
export { ClientOptions } from './httpClient.js';

@@ -3,0 +3,0 @@ export { datasets } from './datasets.js';

{
"name": "@axiomhq/js",
"description": "The official javascript bindings for the Axiom API",
"version": "1.1.1",
"version": "1.2.0",
"author": "Axiom, Inc.",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -98,3 +98,3 @@ import { datasets } from './datasets.js';

* @param options - optional query options
* @returns result of the query, check: {@link QueryResult}
* @returns result of the query depending on the format in options, check: {@link QueryResult} and {@link TabularQueryResult}
*

@@ -107,3 +107,9 @@ * @example

*/
query = (apl: string, options?: QueryOptions): Promise<QueryResult> => {
query = <
TOptions extends QueryOptions,
TResult = TOptions['format'] extends 'tabular' ? Promise<TabularQueryResult> : Promise<QueryResult>,
>(
apl: string,
options?: TOptions,
): Promise<TResult> => {
const req: Query = { apl: apl };

@@ -116,13 +122,49 @@ if (options?.startTime) {

}
return this.client.post<QueryResult>(
this.localPath + '/datasets/_apl',
{
body: JSON.stringify(req),
},
{
'streaming-duration': options?.streamingDuration as string,
nocache: options?.noCache as boolean,
format: 'legacy',
},
);
return this.client
.post<TOptions['format'] extends 'tabular' ? RawTabularQueryResult : QueryResult>(
this.localPath + '/datasets/_apl',
{
body: JSON.stringify(req),
},
{
'streaming-duration': options?.streamingDuration as string,
nocache: options?.noCache as boolean,
format: options?.format ?? 'legacy',
},
)
.then((res) => {
if (options?.format !== 'tabular') {
return res;
}
const result = res as RawTabularQueryResult;
return {
...res,
tables: result.tables.map((t) => {
return {
...t,
events: function* () {
let iteration = 0;
if (!this.columns) {
return;
}
while (iteration <= this.columns[0].length) {
const value = Object.fromEntries(
this.fields.map((field, fieldIdx) => [field.name, this.columns![fieldIdx][iteration]]),
);
if (iteration >= this.columns[0].length) {
return value;
}
yield value;
iteration++;
}
},
};
}),
};
}) as Promise<TResult>;
};

@@ -143,3 +185,9 @@

*/
aplQuery = (apl: string, options?: QueryOptions): Promise<QueryResult> => this.query(apl, options);
aplQuery = <
TOptions extends QueryOptions,
TResult = TOptions['format'] extends 'tabular' ? Promise<TabularQueryResult> : Promise<QueryResult>,
>(
apl: string,
options?: TOptions,
): Promise<TResult> => this.query(apl, options);
}

@@ -320,2 +368,3 @@

endTime?: string;
format?: 'legacy' | 'tabular';
}

@@ -345,2 +394,8 @@

export interface TabularAggregation {
name: AggregationOp;
args: any[];
fields: string[];
}
export enum AggregationOp {

@@ -431,2 +486,45 @@ Count = 'count',

export interface RawTabularQueryResult {
datasetNames: string[];
fieldsMetaMap: Record<
string,
Array<{ description: string; hidden: boolean; name: string; type: string; unit: string }>
>;
format: string;
status: Status;
tables: Array<RawAPLResultTable>;
}
export interface TabularQueryResult extends RawTabularQueryResult {
tables: Array<APLResultTable>;
}
export interface RawAPLResultTable {
name: string;
sources: Array<{ name: string }>;
fields: Array<{ name: string; type: string; agg?: TabularAggregation }>;
order: Array<{
name: string;
desc: boolean;
}>;
groups: Array<{ name: string }>;
range?: {
field: string;
start: string;
end: string;
};
buckets?: { field: string; size: any };
columns?: Array<Array<any>>;
}
export interface APLResultTable extends RawAPLResultTable {
/**
* Returns an iterable that yields each row of the table as a record,
* where the keys are the field names and the values are the values in the columns.
*
* @returns {Generator<Record<string, any>, undefined, unknown>}
*/
events: () => Generator<Record<string, any>, undefined, unknown>;
}
export interface Timeseries {

@@ -433,0 +531,0 @@ series?: Array<Interval>;

@@ -1,2 +0,2 @@

export { AxiomWithoutBatching, Axiom, ContentType, ContentEncoding, IngestOptions, IngestStatus, IngestFailure, QueryOptionsBase, QueryOptions, QueryLegacy, Aggregation, AggregationOp, Filter, FilterOp, Order, Projection, VirtualColumn, QueryLegacyResult, QueryResult, Timeseries, Interval, EntryGroup, EntryGroupAgg, Entry, Status, Message, Query } from './client.js';
export { AxiomWithoutBatching, Axiom, ContentType, ContentEncoding, IngestOptions, IngestStatus, IngestFailure, QueryOptionsBase, QueryOptions, QueryLegacy, Aggregation, AggregationOp, Filter, FilterOp, Order, Projection, VirtualColumn, QueryResult, QueryLegacyResult, TabularQueryResult, RawTabularQueryResult, Timeseries, Interval, EntryGroup, EntryGroupAgg, Entry, Status, Message, Query } from './client.js';
export { ClientOptions } from './httpClient.js';

@@ -3,0 +3,0 @@ export { datasets } from './datasets.js';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc