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

@uwdata/mosaic-core

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uwdata/mosaic-core - npm Package Compare versions

Comparing version 0.12.1 to 0.12.2

dist/types/types.d.ts

11

dist/types/Coordinator.d.ts

@@ -8,5 +8,2 @@ /**

/**
* @typedef {import('@uwdata/mosaic-sql').Query | string} QueryType
*/
/**
* A Mosaic Coordinator manages all database communication for clients and

@@ -95,3 +92,6 @@ * handles selection updates. The Coordinator also performs optimizations

* @param {'arrow' | 'json'} [options.type] The query result format type.
* @param {boolean} [options.cache=true] If true, cache the query result.
* @param {boolean} [options.cache=true] If true, cache the query result
* client-side within the QueryManager.
* @param {boolean} [options.persist] If true, request the database
* server to persist a cached query server-side.
* @param {number} [options.priority] The query priority, defaults to

@@ -104,2 +104,3 @@ * `Priority.Normal`.

cache?: boolean;
persist?: boolean;
priority?: number;

@@ -168,3 +169,3 @@ }): QueryResult;

}
export type QueryType = import("@uwdata/mosaic-sql").Query | string;
export type QueryType = import("@uwdata/mosaic-sql").Query | import("@uwdata/mosaic-sql").DescribeQuery | string;
import { QueryManager } from './QueryManager.js';

@@ -171,0 +172,0 @@ import { PreAggregator } from './preagg/PreAggregator.js';

@@ -12,2 +12,4 @@ export { MosaicClient } from "./MosaicClient.js";

export { toDataColumns } from "./util/to-data-columns.js";
export { queryFieldInfo } from "./util/field-info.js";
export { jsType } from "./util/js-type.js";
export type ClauseMetadata = import("./util/selection-types.js").ClauseMetadata;

@@ -14,0 +16,0 @@ export type PointMetadata = import("./util/selection-types.js").PointMetadata;

@@ -36,11 +36,12 @@ /**

* Return an array of fields queried by this client.
* @returns {object[]|null} The fields to retrieve info for.
* @returns {import('./types.js').FieldInfoRequest[] | null}
* The fields to retrieve info for.
*/
fields(): object[] | null;
fields(): import("./types.js").FieldInfoRequest[] | null;
/**
* Called by the coordinator to set the field info for this client.
* @param {*} info The field info result.
* @param {import('./types.js').FieldInfo[]} info The field info result.
* @returns {this}
*/
fieldInfo(info: any): this;
fieldInfo(info: import("./types.js").FieldInfo[]): this;
/**

@@ -47,0 +48,0 @@ * Return a query specifying the data needed by this client.

@@ -26,3 +26,3 @@ /**

* @param {import('@uwdata/mosaic-sql').ExprValue[]} fields The table columns or expressions to select.
* @param {any[][] | undefined} value The selected values, as an array of
* @param {any[][] | null | undefined} value The selected values, as an array of
* arrays. Each subarray contains values for each *fields* entry.

@@ -36,3 +36,3 @@ * @param {object} options Additional clause properties.

*/
export function clausePoints(fields: import("@uwdata/mosaic-sql").ExprValue[], value: any[][] | undefined, { source, clients }: {
export function clausePoints(fields: import("@uwdata/mosaic-sql").ExprValue[], value: any[][] | null | undefined, { source, clients }: {
source: any;

@@ -44,3 +44,3 @@ clients?: Set<MosaicClient>;

* @param {import('@uwdata/mosaic-sql').ExprValue} field The table column or expression to select.
* @param {Extent} value The selected interval as a [lo, hi] array.
* @param {Extent | null | undefined} value The selected interval as a [lo, hi] array.
* @param {object} options Additional clause properties.

@@ -56,3 +56,3 @@ * @param {*} options.source The source component generating this clause.

*/
export function clauseInterval(field: import("@uwdata/mosaic-sql").ExprValue, value: Extent, { source, clients, bin, scale, pixelSize }: {
export function clauseInterval(field: import("@uwdata/mosaic-sql").ExprValue, value: Extent | null | undefined, { source, clients, bin, scale, pixelSize }: {
source: any;

@@ -67,3 +67,3 @@ clients?: Set<MosaicClient>;

* @param {import('@uwdata/mosaic-sql').ExprValue[]} fields The table columns or expressions to select.
* @param {Extent[]} value The selected intervals, as an array of extents.
* @param {Extent[] | null | undefined} value The selected intervals, as an array of extents.
* @param {object} options Additional clause properties.

@@ -80,3 +80,3 @@ * @param {*} options.source The source component generating this clause.

*/
export function clauseIntervals(fields: import("@uwdata/mosaic-sql").ExprValue[], value: Extent[], { source, clients, bin, scales, pixelSize }: {
export function clauseIntervals(fields: import("@uwdata/mosaic-sql").ExprValue[], value: Extent[] | null | undefined, { source, clients, bin, scales, pixelSize }: {
source: any;

@@ -91,3 +91,3 @@ clients?: Set<MosaicClient>;

* @param {import('@uwdata/mosaic-sql').ExprValue} field The table column or expression to select.
* @param {string} value The selected text search query string.
* @param {string | null | undefined} value The selected text search query string.
* @param {object} options Additional clause properties.

@@ -102,3 +102,3 @@ * @param {*} options.source The source component generating this clause.

*/
export function clauseMatch(field: import("@uwdata/mosaic-sql").ExprValue, value: string, { source, clients, method }: {
export function clauseMatch(field: import("@uwdata/mosaic-sql").ExprValue, value: string | null | undefined, { source, clients, method }: {
source: any;

@@ -105,0 +105,0 @@ clients?: Set<MosaicClient>;

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

export function queryFieldInfo(mc: any, fields: any): Promise<any[]>;
/**
* Queries information about fields of a table.
* If the `fields` array contains a single field with the column set to '*',
* the function will retrieve and return the table information using `getTableInfo`.
* Otherwise, it will query individual field information using `getFieldInfo`
* for each field in the `fields` array.
* @param {import('../Coordinator.js').Coordinator} mc A Mosaic coordinator.
* @param {import('../types.js').FieldInfoRequest[]} fields
* @returns {Promise<import('../types.js').FieldInfo[]>}
*/
export function queryFieldInfo(mc: import("../Coordinator.js").Coordinator, fields: import("../types.js").FieldInfoRequest[]): Promise<import("../types.js").FieldInfo[]>;
export const Count: "count";

@@ -3,0 +13,0 @@ export const Nulls: "nulls";

@@ -1,1 +0,7 @@

export function jsType(type: any): "string" | "number" | "date" | "boolean" | "array" | "object";
/**
* Maps a SQL data type to its corresponding JavaScript type.
* @param {string} type The name of a SQL data type
* @returns {import('../types.js').JSType} The corresponding JavaScript type name
* @throws {Error} Throws an error if the given SQL type name is unsupported or unrecognized.
*/
export function jsType(type: string): import("../types.js").JSType;
{
"name": "@uwdata/mosaic-core",
"version": "0.12.1",
"version": "0.12.2",
"description": "Scalable and extensible linked data views.",

@@ -35,8 +35,8 @@ "keywords": [

"@uwdata/flechette": "^1.1.1",
"@uwdata/mosaic-sql": "^0.12.1"
"@uwdata/mosaic-sql": "^0.12.2"
},
"devDependencies": {
"@uwdata/mosaic-duckdb": "^0.12.1"
"@uwdata/mosaic-duckdb": "^0.12.2"
},
"gitHead": "fe3a7c34352da54ec36a1ebf557846f46a649782"
"gitHead": "0ca741d840b98039255f26a5ceedf10be66f790e"
}

@@ -10,2 +10,8 @@ import { socketConnector } from './connectors/socket.js';

/**
* @typedef {import('@uwdata/mosaic-sql').Query
* | import('@uwdata/mosaic-sql').DescribeQuery
* | string} QueryType
*/
/**
* The singleton Coordinator instance.

@@ -31,6 +37,2 @@ * @type {Coordinator}

/**
* @typedef {import('@uwdata/mosaic-sql').Query | string} QueryType
*/
/**
* A Mosaic Coordinator manages all database communication for clients and

@@ -139,3 +141,6 @@ * handles selection updates. The Coordinator also performs optimizations

* @param {'arrow' | 'json'} [options.type] The query result format type.
* @param {boolean} [options.cache=true] If true, cache the query result.
* @param {boolean} [options.cache=true] If true, cache the query result
* client-side within the QueryManager.
* @param {boolean} [options.persist] If true, request the database
* server to persist a cached query server-side.
* @param {number} [options.priority] The query priority, defaults to

@@ -142,0 +147,0 @@ * `Priority.Normal`.

@@ -25,2 +25,4 @@ export { MosaicClient } from './MosaicClient.js';

export { toDataColumns } from './util/to-data-columns.js';
export { queryFieldInfo } from './util/field-info.js';
export { jsType } from './util/js-type.js';

@@ -27,0 +29,0 @@ /**

@@ -52,3 +52,4 @@ import { throttle } from './util/throttle.js';

* Return an array of fields queried by this client.
* @returns {object[]|null} The fields to retrieve info for.
* @returns {import('./types.js').FieldInfoRequest[] | null}
* The fields to retrieve info for.
*/

@@ -61,3 +62,3 @@ fields() {

* Called by the coordinator to set the field info for this client.
* @param {*} info The field info result.
* @param {import('./types.js').FieldInfo[]} info The field info result.
* @returns {this}

@@ -64,0 +65,0 @@ */

@@ -43,3 +43,3 @@ import { ExprNode, and, contains, isBetween, isIn, isNotDistinct, literal, or, prefix, regexp_matches, suffix } from '@uwdata/mosaic-sql';

* @param {import('@uwdata/mosaic-sql').ExprValue[]} fields The table columns or expressions to select.
* @param {any[][] | undefined} value The selected values, as an array of
* @param {any[][] | null | undefined} value The selected values, as an array of
* arrays. Each subarray contains values for each *fields* entry.

@@ -79,3 +79,3 @@ * @param {object} options Additional clause properties.

* @param {import('@uwdata/mosaic-sql').ExprValue} field The table column or expression to select.
* @param {Extent} value The selected interval as a [lo, hi] array.
* @param {Extent | null | undefined} value The selected interval as a [lo, hi] array.
* @param {object} options Additional clause properties.

@@ -98,3 +98,2 @@ * @param {*} options.source The source component generating this clause.

}) {
/** @type {ExprNode | null} */
const predicate = value != null ? isBetween(field, value) : null;

@@ -109,3 +108,3 @@ /** @type {import('./util/selection-types.js').IntervalMetadata} */

* @param {import('@uwdata/mosaic-sql').ExprValue[]} fields The table columns or expressions to select.
* @param {Extent[]} value The selected intervals, as an array of extents.
* @param {Extent[] | null | undefined} value The selected intervals, as an array of extents.
* @param {object} options Additional clause properties.

@@ -129,3 +128,2 @@ * @param {*} options.source The source component generating this clause.

}) {
/** @type {ExprNode | null} */
const predicate = value != null

@@ -144,3 +142,3 @@ ? and(fields.map((f, i) => isBetween(f, value[i])))

* @param {import('@uwdata/mosaic-sql').ExprValue} field The table column or expression to select.
* @param {string} value The selected text search query string.
* @param {string | null | undefined} value The selected text search query string.
* @param {object} options Additional clause properties.

@@ -147,0 +145,0 @@ * @param {*} options.source The source component generating this clause.

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

import { AggregateNode, Query, asTableRef, count, isNull, max, min, sql } from '@uwdata/mosaic-sql';
import { AggregateNode, Query, asTableRef, count, isAggregateExpression, isNode, isNull, max, min, sql } from '@uwdata/mosaic-sql';
import { jsType } from './js-type.js';

@@ -12,3 +12,6 @@

/**
* @type {Record<string, (column: string) => AggregateNode>}
* @type {Record<
* import('../types.js').Stat,
* (column: import('../types.js').FieldRef) => AggregateNode
* >}
*/

@@ -24,14 +27,22 @@ const statMap = {

/**
*
* @param {string} table
* @param {string} column
* @param {string[]|Set<string>} stats
* @returns
* Get summary stats of the given column
* @param {import('../types.js').FieldInfoRequest} field
* @returns {Query}
*/
function summarize(table, column, stats) {
function summarize({ table, column, stats }) {
return Query
.from(table)
.select(Array.from(stats, s => ({[s]: statMap[s](column)})));
.select(Array.from(stats, s => ({ [s]: statMap[s](column) })));
}
/**
* Queries information about fields of a table.
* If the `fields` array contains a single field with the column set to '*',
* the function will retrieve and return the table information using `getTableInfo`.
* Otherwise, it will query individual field information using `getFieldInfo`
* for each field in the `fields` array.
* @param {import('../Coordinator.js').Coordinator} mc A Mosaic coordinator.
* @param {import('../types.js').FieldInfoRequest[]} fields
* @returns {Promise<import('../types.js').FieldInfo[]>}
*/
export async function queryFieldInfo(mc, fields) {

@@ -47,2 +58,8 @@ if (fields.length === 1 && fields[0].column === '*') {

/**
* Get information about a single field of a table.
* @param {import('../Coordinator.js').Coordinator} mc A Mosaic coordinator.
* @param {import('../types.js').FieldInfoRequest} field
* @returns {Promise<import('../types.js').FieldInfo>}
*/
async function getFieldInfo(mc, { table, column, stats }) {

@@ -54,3 +71,5 @@ // generate and issue a query for field metadata info

.select({ column })
.groupby(column.aggregate ? sql`ALL` : []);
.groupby(isNode(column) && isAggregateExpression(column) ? sql`ALL` : []);
/** @type {import('../types.js').ColumnDescription[]} */
const [desc] = Array.from(await mc.query(Query.describe(q)));

@@ -66,7 +85,7 @@ const info = {

// no need for summary statistics
if (!(stats?.length || stats?.size)) return info;
if (!stats?.length) return info;
// query for summary stats
const [result] = await mc.query(
summarize(table, column, stats),
summarize({ table, column, stats }),
{ persist: true }

@@ -79,5 +98,12 @@ );

/**
* Get information about the fields of a table.
* @param {import('../Coordinator.js').Coordinator} mc A Mosaic coordinator.
* @param {string} table The table name.
* @returns {Promise<import('../types.js').FieldInfo[]>}
*/
async function getTableInfo(mc, table) {
const result = await mc.query(`DESCRIBE ${asTableRef(table)}`);
return Array.from(result).map(desc => ({
/** @type {import('../types.js').ColumnDescription[]} */
const result = Array.from(await mc.query(`DESCRIBE ${asTableRef(table)}`));
return result.map(desc => ({
table,

@@ -84,0 +110,0 @@ column: desc.column_name,

@@ -0,1 +1,7 @@

/**
* Maps a SQL data type to its corresponding JavaScript type.
* @param {string} type The name of a SQL data type
* @returns {import('../types.js').JSType} The corresponding JavaScript type name
* @throws {Error} Throws an error if the given SQL type name is unsupported or unrecognized.
*/
export function jsType(type) {

@@ -2,0 +8,0 @@ switch (type) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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