@vuu-ui/vuu-data-test 3.1.0 → 3.3.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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.1.0",
2
+ "version": "3.3.0",
3
3
  "main": "./src/index.js",
4
4
  "author": "heswell",
5
5
  "license": "Apache-2.0",
@@ -9,13 +9,13 @@
9
9
  "type-defs": "node ../../scripts/build-type-defs.mjs"
10
10
  },
11
11
  "dependencies": {
12
- "@vuu-ui/vuu-data-local": "3.1.0",
13
- "@vuu-ui/vuu-utils": "3.1.0"
12
+ "@vuu-ui/vuu-data-local": "3.3.0",
13
+ "@vuu-ui/vuu-utils": "3.3.0"
14
14
  },
15
15
  "devDependencies": {
16
- "@vuu-ui/vuu-protocol-types": "3.1.0",
17
- "@vuu-ui/vuu-data-types": "3.1.0",
18
- "@vuu-ui/vuu-table-types": "3.1.0"
16
+ "@vuu-ui/vuu-protocol-types": "3.3.0",
17
+ "@vuu-ui/vuu-data-types": "3.3.0",
18
+ "@vuu-ui/vuu-table-types": "3.3.0"
19
19
  },
20
20
  "sideEffects": false,
21
21
  "files": [
@@ -63,17 +63,19 @@ class TickingArrayDataSource extends ArrayDataSource {
63
63
  isSessionDataSourceOf(dataSource) {
64
64
  return this.#sourceTableDataSource === dataSource;
65
65
  }
66
- async createSessionDataSource(copyOption) {
66
+ async createSessionDataSource(copyOption, sessionType = "edit") {
67
67
  const rpcResponse = await this?.rpcRequest?.({
68
68
  type: "RPC_REQUEST",
69
69
  rpcName: "createSessionTable",
70
70
  params: {
71
- copyOption
71
+ copyOption,
72
+ sessionType
72
73
  }
73
74
  });
74
75
  if (isRpcSuccess(rpcResponse)) {
75
76
  const { table: sessionTable } = rpcResponse.data;
76
- const columns = this.config.columns.includes("vuu_action") ? this.config.columns : this.config.columns.concat("vuu_action");
77
+ const baseColumns = this.config.columns.includes("vuuAction") ? this.config.columns : this.config.columns.concat("vuuAction");
78
+ const columns = "import" !== sessionType || baseColumns.includes("vuuRowNum") ? baseColumns : baseColumns.concat("vuuRowNum");
77
79
  const sessionDataSource = this.#vuuModule?.createDataSource(sessionTable.table, sessionTable.table, {
78
80
  ...this.config,
79
81
  columns
@@ -113,11 +115,13 @@ class TickingArrayDataSource extends ArrayDataSource {
113
115
  });
114
116
  }
115
117
  addRow = async (rowData = {})=>{
118
+ const keyValue = rowData[this.tableSchema.key];
119
+ const key = void 0 !== keyValue ? String(keyValue) : "vuuRowNum" in rowData ? String(rowData.vuuRowNum) : void 0;
116
120
  const response = await this.rpcRequest?.({
117
121
  type: "RPC_REQUEST",
118
122
  rpcName: "addRow",
119
123
  params: {
120
- key: rowData[this.tableSchema.key],
124
+ key,
121
125
  data: rowData
122
126
  }
123
127
  });
@@ -177,7 +177,7 @@ class VuuModule {
177
177
  const { key, mode = "hard" } = rpcRequest.params;
178
178
  const sessionTable = this.getSessionTable(viewPortId, false);
179
179
  if (sessionTable) {
180
- if ("soft" === mode) sessionTable.update(key, "vuu_action", "deleteRow");
180
+ if ("soft" === mode) sessionTable.update(key, "vuuAction", "deleteRow");
181
181
  else sessionTable.delete(key);
182
182
  return {
183
183
  type: "SUCCESS_RESULT",
@@ -215,7 +215,7 @@ class VuuModule {
215
215
  const deletedKeys = [];
216
216
  if (selectedRowIds.length > 0) {
217
217
  for (const key of selectedRowIds){
218
- if ("soft" === mode) sessionTable.update(key, "vuu_action", "deleteRow");
218
+ if ("soft" === mode) sessionTable.update(key, "vuuAction", "deleteRow");
219
219
  else sessionTable.delete(key);
220
220
  deletedKeys.push(key);
221
221
  }
@@ -259,7 +259,7 @@ class VuuModule {
259
259
  type: "ERROR_RESULT",
260
260
  errorMessage: `undoRowChange: session row not found for key ${key}`
261
261
  };
262
- const action = sessionRow[sessionTable.map.vuu_action];
262
+ const action = sessionRow[sessionTable.map.vuuAction];
263
263
  if ("addRow" === action) {
264
264
  sessionTable.delete(key);
265
265
  return {
@@ -278,7 +278,7 @@ class VuuModule {
278
278
  const restoredRow = sessionRow.slice();
279
279
  for (const column of sourceTable.schema.columns)restoredRow[sessionTable.map[column.name]] = sourceRow[sourceTable.map[column.name]];
280
280
  sessionTable.updateRow(restoredRow);
281
- sessionTable.update(key, "vuu_action", "");
281
+ sessionTable.update(key, "vuuAction", "");
282
282
  }
283
283
  return {
284
284
  type: "SUCCESS_RESULT",
@@ -312,10 +312,10 @@ class VuuModule {
312
312
  }
313
313
  if (targetTable) try {
314
314
  const sessionRow = sessionTable?.findByKey(key);
315
- if (sessionRow?.[sessionTable.map.vuu_action] === "deleteRow") throw Error("editCell: cannot edit a deleted row");
315
+ if (sessionRow?.[sessionTable.map.vuuAction] === "deleteRow") throw Error("editCell: cannot edit a deleted row");
316
316
  assertUpdateIsValid(targetTable.schema, column, data);
317
317
  targetTable.update(key, column, data);
318
- if (sessionTable && sessionTable.findByKey(key)?.[sessionTable.map.vuu_action] !== "addRow") sessionTable.update(key, "vuu_action", "editCell");
318
+ if (sessionTable && sessionTable.findByKey(key)?.[sessionTable.map.vuuAction] !== "addRow") sessionTable.update(key, "vuuAction", "editCell");
319
319
  return {
320
320
  type: "SUCCESS_RESULT",
321
321
  data: void 0
@@ -374,7 +374,7 @@ class VuuModule {
374
374
  createSessionTableService = async (rpcRequest)=>{
375
375
  if (isCreateSessionTableRpcRequest(rpcRequest)) {
376
376
  const { viewPortId } = rpcRequest.context;
377
- const { copyOption } = rpcRequest.params;
377
+ const { copyOption, sessionType } = rpcRequest.params;
378
378
  const subscription = this.getSubscriptionByViewport(viewPortId);
379
379
  const { dataSource } = subscription;
380
380
  const { table: vuuTable } = dataSource;
@@ -383,7 +383,7 @@ class VuuModule {
383
383
  if (sourceTable) {
384
384
  const sessionTableName = `session-${uuid()}`;
385
385
  try {
386
- const sessionTable = this.createSessionTable(sourceTable, sessionTableName, copyOption, dataSource);
386
+ const sessionTable = this.createSessionTable(sourceTable, sessionTableName, copyOption, dataSource, sessionType);
387
387
  this.#sessionTableMap[sessionTableName] = sessionTable;
388
388
  this.#sessionSourceTableMap[sessionTableName] = vuuTable.table;
389
389
  subscription.sessionTableName = sessionTableName;
@@ -460,9 +460,9 @@ class VuuModule {
460
460
  type: "ERROR_RESULT",
461
461
  errorMessage: `addRow: no active session table for viewport ${viewPortId}`
462
462
  };
463
- const { data } = rpcRequest.params;
463
+ const { data, key } = rpcRequest.params;
464
464
  const keyColumn = sessionTable.schema.key;
465
- const rowKey = data[keyColumn] ?? uuid();
465
+ const rowKey = data[keyColumn] ?? key ?? uuid();
466
466
  const rowData = {
467
467
  ...data,
468
468
  [keyColumn]: rowKey
@@ -470,7 +470,7 @@ class VuuModule {
470
470
  const columnMap = sessionTable.map;
471
471
  const columnCount = Object.keys(columnMap).length;
472
472
  const row = new Array(columnCount).fill("");
473
- row[columnMap.vuu_action] = "addRow";
473
+ row[columnMap.vuuAction] = "addRow";
474
474
  for (const [col, idx] of Object.entries(columnMap))if (void 0 !== rowData[col]) row[idx] = rowData[col];
475
475
  sessionTable.insert(row);
476
476
  return {
@@ -500,7 +500,7 @@ class VuuModule {
500
500
  {
501
501
  let rejectedCount = 0;
502
502
  const vuuMsgIdx = sessionTable.map[this.#sessionTableMessageColumn];
503
- const actionIdx = sessionTable.map.vuu_action;
503
+ const actionIdx = sessionTable.map.vuuAction;
504
504
  const sessionTimestampIdx = sessionTable.map.vuuUpdatedTimestamp;
505
505
  const sourceTimestampIdx = sourceTable.map.vuuUpdatedTimestamp;
506
506
  const sourceColumns = sourceTable.schema.columns;
@@ -559,17 +559,17 @@ class VuuModule {
559
559
  }
560
560
  throw Error("[VuuModule] applyBulkEdits invalid rpc type");
561
561
  };
562
- createSessionTable(sourceTable, sessionTableName, editSessionMode, dataSource) {
562
+ createSessionTable(sourceTable, sessionTableName, editSessionMode, dataSource, sessionType) {
563
563
  if ("All" === editSessionMode || editSessionMode.endsWith("all-rows")) return this.createSessionTableWithAllRows(sourceTable, sessionTableName);
564
564
  if ("Selected" === editSessionMode || "selected-rows" === editSessionMode) return this.createSessionTableFromSelectedRows(sourceTable, sessionTableName, dataSource);
565
- if ("Empty" === editSessionMode || "empty-session-table" === editSessionMode) return this.createEmptySessionTable(sourceTable, sessionTableName);
565
+ if ("Empty" === editSessionMode || "empty-session-table" === editSessionMode) return this.createEmptySessionTable(sourceTable, sessionTableName, sessionType);
566
566
  throw Error(`[VuuModule] createSessionTable, invalid editSessionMode ${editSessionMode}`);
567
567
  }
568
568
  createSessionTableWithAllRows({ data, schema }, _sessionTableName) {
569
569
  const sessionSchema = sessionTableSchema(schema);
570
570
  return new Table(sessionSchema, data.map((row)=>sessionTableRow(row, schema)), buildDataColumnMapFromSchema(sessionSchema));
571
571
  }
572
- createEmptySessionTable({ schema }, sessionTableName) {
572
+ createEmptySessionTable({ schema }, sessionTableName, sessionType) {
573
573
  const sessionSchema = sessionTableSchema({
574
574
  ...schema,
575
575
  table: {
@@ -577,6 +577,10 @@ class VuuModule {
577
577
  table: sessionTableName
578
578
  }
579
579
  });
580
+ if ("import" === sessionType) sessionSchema.columns.push({
581
+ name: "vuuRowNum",
582
+ serverDataType: "int"
583
+ });
580
584
  return new Table(sessionSchema, [], buildDataColumnMapFromSchema(sessionSchema));
581
585
  }
582
586
  createSessionTableFromSelectedRows({ data, map, schema }, sessionTableName, dataSource) {
@@ -4,7 +4,7 @@ const { KEY: KEY } = metadataKeys;
4
4
  const sessionTableRow = (row, schema)=>{
5
5
  const sessionRow = row.slice();
6
6
  if (!schema.columns.some(({ name })=>"vuuMsg" === name)) sessionRow.push("");
7
- if (!schema.columns.some(({ name })=>"vuu_action" === name)) sessionRow.push("");
7
+ if (!schema.columns.some(({ name })=>"vuuAction" === name)) sessionRow.push("");
8
8
  return sessionRow;
9
9
  };
10
10
  const createSessionTableFromSelectedRows = (table, selectedRowIds)=>{
@@ -19,8 +19,8 @@ const sessionTableSchema = (schema)=>{
19
19
  name: "vuuMsg",
20
20
  serverDataType: "string"
21
21
  });
22
- if (!columns.some(({ name })=>"vuu_action" === name)) columns.push({
23
- name: "vuu_action",
22
+ if (!columns.some(({ name })=>"vuuAction" === name)) columns.push({
23
+ name: "vuuAction",
24
24
  serverDataType: "string"
25
25
  });
26
26
  return {
@@ -1,5 +1,5 @@
1
1
  import { ArrayDataSource, type ArrayDataSourceConstructorProps } from "@vuu-ui/vuu-data-local";
2
- import type { DataSourceBase, DataSource, DataSourceRowWithBigint, DataSourceSubscribeCallback, DataSourceSubscribeProps, DataSourceVisualLinkCreatedMessage, DeleteRowMode, CopyOption, EditSessionMode } from "@vuu-ui/vuu-data-types";
2
+ import type { DataSourceBase, DataSource, DataSourceRowWithBigint, DataSourceSubscribeCallback, DataSourceSubscribeProps, DataSourceVisualLinkCreatedMessage, DeleteRowMode, CopyOption, EditSessionMode, SessionType } from "@vuu-ui/vuu-data-types";
3
3
  import type { LinkDescriptorWithLabel, RpcResultError, RpcResultSuccess, VuuCreateVisualLink, VuuMenu, VuuRemoveVisualLink, VuuRowDataItemType, VuuRpcMenuRequest, VuuRpcMenuResponse, VuuRpcServiceRequest } from "@vuu-ui/vuu-protocol-types";
4
4
  import type { IVuuModule, RpcMenuService, RpcService } from "./core/module/VuuModule";
5
5
  import type { Table } from "./Table";
@@ -24,7 +24,7 @@ export declare class TickingArrayDataSource extends ArrayDataSource {
24
24
  get links(): LinkDescriptorWithLabel[] | undefined;
25
25
  getSelectedRowIds(): string[];
26
26
  isSessionDataSourceOf(dataSource: DataSource): boolean;
27
- createSessionDataSource(copyOption: CopyOption): Promise<DataSourceBase<DataSourceRowWithBigint> | undefined>;
27
+ createSessionDataSource(copyOption: CopyOption, sessionType?: SessionType): Promise<DataSourceBase<DataSourceRowWithBigint> | undefined>;
28
28
  beginEditSession(editSessionMode?: EditSessionMode): Promise<DataSourceBase<DataSourceRowWithBigint> | undefined>;
29
29
  editCell(key: string, column: string, data: VuuRowDataItemType): Promise<RpcResultSuccess | RpcResultError>;
30
30
  addRow: (rowData?: Record<string, VuuRowDataItemType>) => Promise<true | string>;
@@ -1,4 +1,4 @@
1
- import type { DataSourceBase, DataSourceConfig, DataSourceRowWithBigint, DataSourceSubscribedMessage, DataSourceVisualLinkCreatedMessage, EditSessionMode, CopyOption, TableSchema } from "@vuu-ui/vuu-data-types";
1
+ import type { DataSourceBase, DataSourceConfig, DataSourceRowWithBigint, DataSourceSubscribedMessage, DataSourceVisualLinkCreatedMessage, EditSessionMode, CopyOption, SessionType, TableSchema } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuMenu, VuuLink, LinkDescriptorWithLabel, VuuRpcMenuResponse, VuuCreateVisualLink, VuuRemoveVisualLink, VuuRpcServiceRequest, RpcResultSuccess, RpcResultError, VuuRpcMenuRequest } from "@vuu-ui/vuu-protocol-types";
3
3
  import { Table } from "../../Table";
4
4
  import { TickingArrayDataSource } from "../../TickingArrayDataSource";
@@ -69,9 +69,9 @@ export declare abstract class VuuModule<T extends string = string> implements IV
69
69
  private addRow;
70
70
  private endEditSession;
71
71
  private applyBulkEdits;
72
- protected createSessionTable(sourceTable: Table, sessionTableName: string, editSessionMode: EditSessionMode | CopyOption, dataSource: TickingArrayDataSource): Table;
72
+ protected createSessionTable(sourceTable: Table, sessionTableName: string, editSessionMode: EditSessionMode | CopyOption, dataSource: TickingArrayDataSource, sessionType?: SessionType): Table;
73
73
  protected createSessionTableWithAllRows({ data, schema }: Table, _sessionTableName: string): Table;
74
- protected createEmptySessionTable({ schema }: Table, sessionTableName: string): Table;
74
+ protected createEmptySessionTable({ schema }: Table, sessionTableName: string, sessionType?: SessionType): Table;
75
75
  protected createSessionTableFromSelectedRows({ data, map, schema }: Table, sessionTableName: string, dataSource: TickingArrayDataSource): Table;
76
76
  }
77
77
  export {};