Skip to content

Commit

Permalink
move date generators to test data package (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
heswell authored Oct 27, 2023
1 parent 3cd0826 commit 211fbf9
Show file tree
Hide file tree
Showing 38 changed files with 34 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
BasketDefinitionsReferenceData,
} from "../reference-data";
import { BaseUpdateGenerator } from "../UpdateGenerator";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";

export const RowGenerator: RowGeneratorFactory =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";
import {
BasketDesignReferenceData,
BasketDesignColumnMap,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { BasketColumnMap, BasketReferenceData } from "../reference-data";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";

export const RowGenerator: RowGeneratorFactory =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";
import {
BasketOrdersReferenceData,
BasketOrdersColumnMap,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { ExtendedColumnConfig } from "../useTableConfig";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";
import { currencies, locations, suffixes } from "./generatedData";

function random(min: number, max: number) {
Expand Down Expand Up @@ -75,10 +74,7 @@ export const RowGenerator: RowGeneratorFactory = () => (index: number) => {
];
};

export const ColumnGenerator: ColumnGeneratorFn = (
columns = [],
columnConfig: ExtendedColumnConfig = {}
) => {
export const ColumnGenerator: ColumnGeneratorFn = (columns = []) => {
const schema = getSchema("childOrders");
const schemaColumns: ColumnDescriptor[] = schema.columns;
if (typeof columns === "number") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";
import {
InstrumentReferenceData,
InstrumentColumnMap,
} from "../reference-data";
import { getCalculatedColumnType, isCalculatedColumn } from "@finos/vuu-utils";
import { ExtendedColumnConfig } from "../useTableConfig";

export type ExtendedColumnConfig = { [key: string]: Partial<ColumnDescriptor> };

export const RowGenerator: RowGeneratorFactory =
(columnNames?: string[]) => (index: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
InstrumentPricesReferenceData,
} from "../reference-data";
import { BaseUpdateGenerator } from "../UpdateGenerator";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";

const instrumentPriceSchema = getSchema("instrumentPrices");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { ExtendedColumnConfig } from "../useTableConfig";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";

export type ExtendedColumnConfig = { [key: string]: Partial<ColumnDescriptor> };

function random(min: number, max: number) {
min = Math.ceil(min);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { ExtendedColumnConfig } from "../useTableConfig";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";
import { getSchema } from "@finos/vuu-data-test";
import { getSchema } from "../tableSchemas";
import { currencies, locations, suffixes } from "./generatedData";

function random(min: number, max: number) {
Expand Down Expand Up @@ -67,11 +66,7 @@ export const RowGenerator: RowGeneratorFactory = () => (index: number) => {
];
};

export const ColumnGenerator: ColumnGeneratorFn = (
columns = [],
columnConfig: ExtendedColumnConfig = {}
) => {
console.log({ columnConfig });
export const ColumnGenerator: ColumnGeneratorFn = (columns = []) => {
const schema = getSchema("parentOrders");
const schemaColumns: ColumnDescriptor[] = schema.columns;
if (typeof columns === "number") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { buildColumnMap } from "@finos/vuu-utils";
import { PriceReferenceData } from "../reference-data";
import { ExtendedColumnConfig } from "../useTableConfig";
import { ColumnGeneratorFn, RowGeneratorFactory } from "./vuu-row-generator";
import { BaseUpdateGenerator } from "../UpdateGenerator";
import { getAllSchemas } from "@finos/vuu-data-test";
import { getAllSchemas } from "../tableSchemas";

export const RowGenerator: RowGeneratorFactory = () => (index: number) => {
if (index >= PriceReferenceData.length) {
Expand All @@ -21,11 +20,7 @@ const tickingColumns = [bid, bidSize, ask, askSize];
export const createUpdateGenerator = () =>
new BaseUpdateGenerator(tickingColumns);

export const ColumnGenerator: ColumnGeneratorFn = (
columns = [],
columnConfig: ExtendedColumnConfig = {}
) => {
console.log({ columnConfig });
export const ColumnGenerator: ColumnGeneratorFn = (columns = []) => {
const schemaColumns: ColumnDescriptor[] = pricesSchema.columns;
if (typeof columns === "number") {
throw Error("PricesColumnGenerator must be passed columns (strings)");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ColumnDescriptor } from "@finos/vuu-datagrid-types";
import { VuuRowDataItemType, VuuTable } from "@finos/vuu-protocol-types";
import { RowAtIndexFunc } from "../ArrayProxy";
import * as dataGenerators from ".";
import { UpdateGenerator } from "../rowUpdates";

type RowAtIndexFunc<T = unknown> = (index: number) => T | undefined;

export const VuuColumnGenerator = (columnCount: number): string[] =>
["Row No"].concat(
Array(columnCount)
Expand Down
1 change: 1 addition & 0 deletions vuu-ui/packages/vuu-data-test/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./tableSchemas";
export * from "./data-generators/vuu-row-generator";
6 changes: 6 additions & 0 deletions vuu-ui/packages/vuu-data-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions":{
"composite": true
},
}
1 change: 1 addition & 0 deletions vuu-ui/scripts/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const packages = [
"vuu-codemirror",
"vuu-data",
"vuu-data-react",
"vuu-data-test",
"vuu-data-ag-grid",
"vuu-data-test",
"vuu-data-types",
Expand Down
5 changes: 4 additions & 1 deletion vuu-ui/showcase/src/examples/utils/TickingArrayDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
} from "@finos/vuu-data";
import { VuuRange } from "@finos/vuu-protocol-types";
import { DataSourceRow } from "@finos/vuu-data-types";
import { RowUpdates, UpdateGenerator } from "./rowUpdates";
import {
RowUpdates,
UpdateGenerator,
} from "@finos/vuu-data-test/src/rowUpdates";

export interface TickingArrayDataSourceConstructorProps
extends ArrayDataSourceConstructorProps {
Expand Down
5 changes: 1 addition & 4 deletions vuu-ui/showcase/src/examples/utils/createArrayDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { TickingArrayDataSource } from "./TickingArrayDataSource";
import {
getColumnAndRowGenerator,
populateArray,
} from "./data-generators/vuu-row-generator";
import { getColumnAndRowGenerator, populateArray } from "@finos/vuu-data-test";
import { VuuTable } from "@finos/vuu-protocol-types";

export const createArrayDataSource = ({
Expand Down
1 change: 0 additions & 1 deletion vuu-ui/showcase/src/examples/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export * from "./ErrorDisplay";
export * from "./useAutoLoginToVuuServer";
export * from "./useTableConfig";
export * from "./useTestDataSource";
export * from "./data-generators/vuu-row-generator";
46 changes: 0 additions & 46 deletions vuu-ui/showcase/src/examples/utils/useColumns.ts

This file was deleted.

5 changes: 1 addition & 4 deletions vuu-ui/showcase/src/examples/utils/useTableConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { useMemo } from "react";
import { ArrayProxy } from "./ArrayProxy";
import { makeSuggestions } from "./makeSuggestions";
import { TickingArrayDataSource } from "./TickingArrayDataSource";
import {
getColumnAndRowGenerator,
populateArray,
} from "./data-generators/vuu-row-generator";
import { getColumnAndRowGenerator, populateArray } from "@finos/vuu-data-test";

const NO_CONFIG = {} as const;
const NO_COLUMNS: number[] = [];
Expand Down
2 changes: 1 addition & 1 deletion vuu-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"sample-apps/*/index.ts",
"sample-apps/*/src",
"global.d.ts"
],
, "packages/vuu-data-test/src/UpdateGenerator.ts" ],
"exclude": ["**/*.cy.*", "**/*.test.*"],
"references": [
{"path" : "packages/vuu-codemirror"},
Expand Down

0 comments on commit 211fbf9

Please sign in to comment.