@pagamio/frontend-commons-lib 0.8.330 → 0.8.331

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.
@@ -1 +1,2 @@
1
1
  export * from './functionHelper';
2
+ export * from './withSyntheticId';
@@ -1 +1,2 @@
1
1
  export * from './functionHelper';
2
+ export * from './withSyntheticId';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Mirror a row's primary-key field into a top-level `id` so the row
3
+ * satisfies `BaseEntity` (and MRT's row keying) when the underlying entity
4
+ * has a composite PK or a non-`id`-named PK (e.g. `customerId`, `orderId`).
5
+ *
6
+ * Usage in a usePagamioTable queryFn:
7
+ *
8
+ * queryFn: async (params) => {
9
+ * const res = await getThings(params);
10
+ * return { ...res, data: withSyntheticId(res.data, 'customerId') };
11
+ * }
12
+ *
13
+ * The synthesized `id` is purely for the table layer — it never goes back
14
+ * to the server.
15
+ */
16
+ export declare const withSyntheticId: <T extends Record<string, unknown>, K extends keyof T>(rows: T[], key: K) => Array<T & {
17
+ id: T[K];
18
+ }>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Mirror a row's primary-key field into a top-level `id` so the row
3
+ * satisfies `BaseEntity` (and MRT's row keying) when the underlying entity
4
+ * has a composite PK or a non-`id`-named PK (e.g. `customerId`, `orderId`).
5
+ *
6
+ * Usage in a usePagamioTable queryFn:
7
+ *
8
+ * queryFn: async (params) => {
9
+ * const res = await getThings(params);
10
+ * return { ...res, data: withSyntheticId(res.data, 'customerId') };
11
+ * }
12
+ *
13
+ * The synthesized `id` is purely for the table layer — it never goes back
14
+ * to the server.
15
+ */
16
+ export const withSyntheticId = (rows, key) => rows.map((row) => ({ ...row, id: row[key] }));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagamio/frontend-commons-lib",
3
3
  "description": "Pagamio library for Frontend reusable components like the form engine and table container",
4
- "version": "0.8.330",
4
+ "version": "0.8.331",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": false