@kepler.gl/table 3.3.0-alpha.16 → 3.3.0-alpha.17

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.
@@ -0,0 +1,48 @@
1
+ import { Field, ProtoDataset } from '@kepler.gl/types';
2
+ import { DataContainerInterface } from '@kepler.gl/utils';
3
+ export type ColumnEditDataset = {
4
+ fields: Field[];
5
+ dataContainer: DataContainerInterface;
6
+ };
7
+ export type ColumnEditPayload = {
8
+ data: ProtoDataset['data'];
9
+ renames: Record<string, string>;
10
+ };
11
+ export declare const EDITABLE_FIELD_TYPES: readonly ["integer", "real", "string", "timestamp"];
12
+ export type EditableFieldType = (typeof EDITABLE_FIELD_TYPES)[number];
13
+ export type ColumnTypeConversionError = {
14
+ rowIndex: number;
15
+ value: unknown;
16
+ reason: string;
17
+ };
18
+ export type ChangeColumnTypeResult = {
19
+ payload: ColumnEditPayload;
20
+ error?: never;
21
+ } | {
22
+ payload?: never;
23
+ error: ColumnTypeConversionError;
24
+ };
25
+ export declare function formatColumnTypeConversionError(error: ColumnTypeConversionError): string;
26
+ /** Validate every candidate in one pass without allocating converted columns. */
27
+ export declare function getCompatibleColumnTypes(dataContainer: DataContainerInterface, fieldIndex: number, currentType: string): EditableFieldType[];
28
+ /**
29
+ * Field descriptor for `updateDataset`, with accessors and per-column stats
30
+ * stripped so the table rebuilds them against the new container.
31
+ */
32
+ export declare function schemaField(field: Field, name: string): ProtoDataset['data']['fields'][number];
33
+ /**
34
+ * Project a dataset down to `columns`, preserving Arrow vectors when the
35
+ * container exposes them so a rename does not round-trip typed columns
36
+ * through plain rows.
37
+ */
38
+ export declare function projectDatasetColumns(dataset: ColumnEditDataset, columns: {
39
+ sourceIndex: number;
40
+ name: string;
41
+ }[]): ProtoDataset['data'];
42
+ export declare function buildRenameColumnData(dataset: ColumnEditDataset, fieldName: string, newName: string): ColumnEditPayload | null;
43
+ export declare function buildDeleteColumnData(dataset: ColumnEditDataset, fieldName: string): ColumnEditPayload | null;
44
+ /**
45
+ * Convert an entire column before returning an update payload. A failed value
46
+ * returns its row and leaves the source dataset untouched.
47
+ */
48
+ export declare function buildChangeColumnTypeData(dataset: ColumnEditDataset, fieldName: string, newType: string): ChangeColumnTypeResult | null;
@@ -2,9 +2,11 @@ export * from './types';
2
2
  export * from './aggregations';
3
3
  export * from './geometry';
4
4
  export * from './table-helpers';
5
+ export * from './column-edit';
5
6
  export * from './group-by';
6
7
  export * from './join';
7
8
  export * from './spatial-join';
9
+ export * from './suitability';
8
10
  export { makeResultProtoDataset } from './proto-dataset';
9
11
  import { DatasetOpsEngine } from './types';
10
12
  export declare const inMemoryDatasetOpsEngine: DatasetOpsEngine;
@@ -0,0 +1,15 @@
1
+ import { Field, ProtoDataset } from '@kepler.gl/types';
2
+ import { DataStandardization, DatasetOpsTable, SuitabilityDatasetConfig, WeightStandardization } from './types';
3
+ /** Only plain numeric columns can carry a suitability weight. */
4
+ export declare function isSuitabilityWeightField(field: {
5
+ type?: string;
6
+ }): boolean;
7
+ export declare function defaultSuitabilityWeights(fields: Field[]): Record<string, number>;
8
+ export declare function standardizeColumn(values: (number | null)[], method: DataStandardization): (number | null)[];
9
+ export declare function standardizeWeights(weights: number[], method: WeightStandardization): number[];
10
+ /**
11
+ * Scores every row as the weighted sum of its standardized values, and returns the source
12
+ * columns plus the score as a new dataset. A row scores null when any weighted value is
13
+ * missing, so partial rows do not masquerade as low scores.
14
+ */
15
+ export declare function suitabilityDataset(dataset: DatasetOpsTable, config: SuitabilityDatasetConfig): ProtoDataset;
@@ -1,9 +1,12 @@
1
1
  import { Field } from '@kepler.gl/types';
2
2
  import { DatasetOpsTable } from './types';
3
- export declare function isTabularDatasetForOps(dataset?: {
3
+ type DatasetOpTarget = {
4
4
  type?: string;
5
5
  disableDataOperation?: boolean;
6
- } | null): boolean;
6
+ } | null;
7
+ export declare function isTabularDatasetForOps(dataset?: DatasetOpTarget): boolean;
8
+ export declare function canMutateDatasetSchema(dataset?: DatasetOpTarget): boolean;
7
9
  export declare function findFieldByName(fields: Field[], name: string | null | undefined): Field | undefined;
8
10
  export declare function rowValue(dataset: DatasetOpsTable, rowIndex: number, field: Field): unknown;
9
11
  export declare function rowCount(dataset: DatasetOpsTable): number;
12
+ export {};
@@ -11,7 +11,7 @@ export declare const DATASET_OPS_AGGREGATIONS: {
11
11
  readonly merge: "merge";
12
12
  };
13
13
  export type DatasetOpAggregation = (typeof DATASET_OPS_AGGREGATIONS)[keyof typeof DATASET_OPS_AGGREGATIONS];
14
- export type DerivedDatasetType = 'groupBy' | 'join' | 'spatialJoin';
14
+ export type DerivedDatasetType = 'groupBy' | 'join' | 'spatialJoin' | 'suitability';
15
15
  export type DerivedDatasetMetadata = {
16
16
  type: DerivedDatasetType;
17
17
  sourceDataIds: string[];
@@ -110,8 +110,55 @@ export type JoinOp = {
110
110
  isConfigActive: boolean;
111
111
  error?: string | null;
112
112
  };
113
+ export declare const WEIGHT_STANDARDIZATIONS: {
114
+ readonly raw: "raw";
115
+ readonly normalize: "normalize";
116
+ };
117
+ export type WeightStandardization = (typeof WEIGHT_STANDARDIZATIONS)[keyof typeof WEIGHT_STANDARDIZATIONS];
118
+ export declare const WEIGHT_STANDARDIZATION_OPTIONS: {
119
+ id: WeightStandardization;
120
+ labelId: string;
121
+ }[];
122
+ export declare const DATA_STANDARDIZATIONS: {
123
+ readonly raw: "raw";
124
+ readonly range: "range";
125
+ readonly zScore: "zScore";
126
+ };
127
+ export type DataStandardization = (typeof DATA_STANDARDIZATIONS)[keyof typeof DATA_STANDARDIZATIONS];
128
+ export declare const DATA_STANDARDIZATION_OPTIONS: {
129
+ id: DataStandardization;
130
+ labelId: string;
131
+ }[];
132
+ export declare const DEFAULT_SUITABILITY_SCORE_FIELD = "score";
133
+ export declare const DEFAULT_SUITABILITY_WEIGHT = 1;
134
+ export declare const SUITABILITY_WEIGHT_RANGE: [number, number];
135
+ export type SuitabilityDatasetConfig = {
136
+ /** Weight per source field name. Fields absent from this map are not scored. */
137
+ weights: Record<string, number>;
138
+ weightStandardization?: WeightStandardization;
139
+ dataStandardization?: DataStandardization;
140
+ outputFieldName?: string;
141
+ columns?: string[];
142
+ label?: string;
143
+ resultId?: string;
144
+ operationId?: string;
145
+ };
146
+ export type SuitabilityOp = {
147
+ id: string;
148
+ dataId: string;
149
+ weights: Record<string, number>;
150
+ weightStandardization: WeightStandardization;
151
+ dataStandardization: DataStandardization;
152
+ outputFieldName: string;
153
+ columns?: string[];
154
+ resultId: string;
155
+ resultLabel: string;
156
+ isConfigActive: boolean;
157
+ error?: string | null;
158
+ };
113
159
  export type DatasetOpsEngine = {
114
160
  groupByDataset: (dataset: DatasetOpsTable, config: GroupByDatasetConfig) => ProtoDataset;
115
161
  joinDatasets: (left: DatasetOpsTable, right: DatasetOpsTable, config: JoinDatasetConfig) => ProtoDataset;
116
162
  spatialJoinDatasets: (left: DatasetOpsTable, right: DatasetOpsTable, config: SpatialJoinDatasetConfig) => ProtoDataset;
163
+ suitabilityDataset: (dataset: DatasetOpsTable, config: SuitabilityDatasetConfig) => ProtoDataset;
117
164
  };