@platforma-sdk/model 1.20.27 → 1.21.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/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const PlatformaSDKVersion = "1.20.27";
1
+ export declare const PlatformaSDKVersion = "1.21.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,YAAY,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/model",
3
- "version": "1.20.27",
3
+ "version": "1.21.0",
4
4
  "description": "Platforma.bio SDK / Block Model",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -6,6 +6,7 @@ import {
6
6
  matchAxisId,
7
7
  PColumn,
8
8
  PColumnIdAndSpec,
9
+ PColumnSpec,
9
10
  PColumnValues,
10
11
  PObjectId,
11
12
  PTableHandle,
@@ -282,6 +283,31 @@ export type PlTableFiltersModel = {
282
283
  filters?: PTableRecordFilter[];
283
284
  };
284
285
 
286
+ export type CreatePlDataTableOps = {
287
+ /** Table filters, should contain */
288
+ filters?: PTableRecordFilter[];
289
+
290
+ /**
291
+ * Selects columns for which will be inner-joined to the table.
292
+ *
293
+ * Default behaviour: all columns are considered to be core
294
+ */
295
+ coreColumnPredicate?: (spec: PColumnSpec) => boolean;
296
+
297
+ /**
298
+ * Determines how core columns should be joined together:
299
+ * inner - so user will only see records present in all core columns
300
+ * full - so user will only see records present in any of the core columns
301
+ *
302
+ * All non-core columns will be left joined to the table produced by the core
303
+ * columns, in other words records form the pool of non-core columns will only
304
+ * make their way into the final table if core table contins corresponding key.
305
+ *
306
+ * Default: 'full'
307
+ */
308
+ coreJoinType?: 'inner' | 'full';
309
+ };
310
+
285
311
  /**
286
312
  * Create p-table handle given ui table state
287
313
  *
@@ -293,9 +319,32 @@ export type PlTableFiltersModel = {
293
319
  export function createPlDataTable<A, U>(
294
320
  ctx: RenderCtx<A, U>,
295
321
  columns: PColumn<TreeNodeAccessor | PColumnValues>[],
296
- tableState?: PlDataTableState,
297
- filters?: PTableRecordFilter[]
322
+ tableState: PlDataTableState | undefined
323
+ ): PTableHandle | undefined;
324
+ export function createPlDataTable<A, U>(
325
+ ctx: RenderCtx<A, U>,
326
+ columns: PColumn<TreeNodeAccessor | PColumnValues>[],
327
+ tableState: PlDataTableState | undefined,
328
+ ops: CreatePlDataTableOps
329
+ ): PTableHandle | undefined;
330
+ /** @deprecated use method with extended ops as the last argument */
331
+ export function createPlDataTable<A, U>(
332
+ ctx: RenderCtx<A, U>,
333
+ columns: PColumn<TreeNodeAccessor | PColumnValues>[],
334
+ tableState: PlDataTableState | undefined,
335
+ filters: PTableRecordFilter[]
336
+ ): PTableHandle | undefined;
337
+ export function createPlDataTable<A, U>(
338
+ ctx: RenderCtx<A, U>,
339
+ columns: PColumn<TreeNodeAccessor | PColumnValues>[],
340
+ tableState: PlDataTableState | undefined,
341
+ ops?: PTableRecordFilter[] | CreatePlDataTableOps
298
342
  ): PTableHandle | undefined {
343
+ // ops migration for backward compatibility with previous deprecated API
344
+ if (Array.isArray(ops)) {
345
+ ops = { filters: ops };
346
+ }
347
+
299
348
  const allLabelCols = ctx.resultPool
300
349
  .getData()
301
350
  .entries.map((d) => d.obj)
@@ -351,16 +400,28 @@ export function createPlDataTable<A, U>(
351
400
  )
352
401
  return undefined;
353
402
 
403
+ let coreColumns = columns;
404
+ const secondaryColumns: typeof columns = [];
405
+
406
+ if (ops?.coreColumnPredicate) {
407
+ coreColumns = [];
408
+ for (const c of columns)
409
+ if (ops.coreColumnPredicate(c.spec)) coreColumns.push(c);
410
+ else secondaryColumns.push(c);
411
+ }
412
+
413
+ secondaryColumns.push(...labelColumns.values());
414
+
354
415
  return ctx.createPTable({
355
416
  src: {
356
417
  type: 'outer',
357
418
  primary: {
358
- type: 'full',
359
- entries: columns.map((c) => ({ type: 'column', column: c }))
419
+ type: ops?.coreJoinType ?? 'full',
420
+ entries: coreColumns.map((c) => ({ type: 'column', column: c }))
360
421
  },
361
- secondary: [...labelColumns.values()].map((c) => ({ type: 'column', column: c }))
422
+ secondary: secondaryColumns.map((c) => ({ type: 'column', column: c }))
362
423
  },
363
- filters: [...(tableState?.pTableParams?.filters ?? []), ...(filters ?? [])],
424
+ filters: [...(ops?.filters ?? []), ...(tableState?.pTableParams?.filters ?? [])],
364
425
  sorting: tableState?.pTableParams?.sorting ?? []
365
426
  });
366
427
  }