cry-search 1.0.0 → 1.0.3

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.
Files changed (37) hide show
  1. package/CLAUDE.md +144 -13
  2. package/README.md +111 -5
  3. package/dist/common/SearchUniverse.d.ts.map +1 -1
  4. package/dist/common/findInLinkedArrays.d.ts +1 -1
  5. package/dist/common/findInLinkedArrays.d.ts.map +1 -1
  6. package/dist/common/numeric/AugmentedMetadata.d.ts +111 -0
  7. package/dist/common/numeric/AugmentedMetadata.d.ts.map +1 -0
  8. package/dist/common/numeric/findInLinkedArrays.d.ts +1 -1
  9. package/dist/common/numeric/index.d.ts +3 -0
  10. package/dist/common/numeric/index.d.ts.map +1 -1
  11. package/dist/common/numeric/searchInData.d.ts.map +1 -1
  12. package/dist/common/numeric/syncSearchArrayMetadata.d.ts +64 -0
  13. package/dist/common/numeric/syncSearchArrayMetadata.d.ts.map +1 -0
  14. package/dist/common/numeric/updateSearchLinkedMetadata.d.ts +130 -0
  15. package/dist/common/numeric/updateSearchLinkedMetadata.d.ts.map +1 -0
  16. package/dist/common/syncSearchArrayMetadata.d.ts +12 -8
  17. package/dist/common/syncSearchArrayMetadata.d.ts.map +1 -1
  18. package/dist/common/updateSearchLinkedMetadata.d.ts +26 -16
  19. package/dist/common/updateSearchLinkedMetadata.d.ts.map +1 -1
  20. package/dist/index.cjs +265 -490
  21. package/dist/index.d.cts +3 -9
  22. package/dist/index.d.ts +3 -9
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +265 -490
  25. package/dist/string.cjs +922 -0
  26. package/dist/string.d.cts +26 -0
  27. package/dist/string.d.ts +26 -0
  28. package/dist/string.d.ts.map +1 -0
  29. package/dist/string.js +890 -0
  30. package/dist/types/index.d.ts +21 -3
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/utils/matchTokenNumeric.d.ts +17 -2
  33. package/dist/utils/matchTokenNumeric.d.ts.map +1 -1
  34. package/dist/utils/sanitiseString.d.ts +7 -3
  35. package/dist/utils/sanitiseString.d.ts.map +1 -1
  36. package/dist/utils/tokenize.d.ts.map +1 -1
  37. package/package.json +14 -4
@@ -0,0 +1,130 @@
1
+ import type { Id, SearchableData, SearchableObject, SearchableObjectSpec, UpsertResult, SyncLinkedResult } from '../../types/index.js';
2
+ import type { NumericLinkedSearchMetadataWithData } from './createSearchLinkedMetadata.js';
3
+ export type { UpsertResult, SyncLinkedResult } from '../../types/index.js';
4
+ /**
5
+ * Upserts a primary item into the linked metadata (numeric version).
6
+ *
7
+ * - If the item doesn't exist, adds it to data, metadata, and initializes primaryToLinked index
8
+ * - If the item exists, updates data and metadata
9
+ * - Handles `_deleted`/`_blocked` items by removing their metadata
10
+ *
11
+ * @typeParam TPrimary - Type of primary items
12
+ * @typeParam TLinked - Type of linked items
13
+ * @typeParam C - Type of the search context
14
+ *
15
+ * @param linked - The linked metadata to update (mutated in place)
16
+ * @param item - The primary item to upsert
17
+ * @param spec - Optional specification for how to extract searchable text
18
+ * @returns UpsertResult indicating if item was added or updated
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const stranka = { _id: 's1', ime: 'Janez', priimek: 'Novak' };
23
+ * const result = upsertPrimaryItemNumeric(linkedMeta, stranka, spec);
24
+ * // result.added === true if stranka was new
25
+ * ```
26
+ */
27
+ export declare function upsertPrimaryItemNumeric<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: NumericLinkedSearchMetadataWithData<TPrimary, TLinked>, item: TPrimary, spec?: SearchableObjectSpec<TPrimary, C>): UpsertResult;
28
+ /**
29
+ * Removes a primary item from the linked metadata (numeric version).
30
+ *
31
+ * Removes the item from data, metadata, and the primaryToLinked index.
32
+ * Note: This does NOT automatically remove linked items - they will become orphans.
33
+ * If you want to also remove linked items, call {@link removeLinkedItemNumeric} for each.
34
+ *
35
+ * @typeParam TPrimary - Type of primary items
36
+ * @typeParam TLinked - Type of linked items
37
+ *
38
+ * @param linked - The linked metadata to update (mutated in place)
39
+ * @param primaryId - The ID of the primary item to remove
40
+ * @returns true if item was found and removed, false if not found
41
+ */
42
+ export declare function removePrimaryItemNumeric<TPrimary extends SearchableObject, TLinked extends SearchableObject>(linked: NumericLinkedSearchMetadataWithData<TPrimary, TLinked>, primaryId: Id): boolean;
43
+ /**
44
+ * Upserts a linked item into the linked metadata (numeric version).
45
+ *
46
+ * - If the item doesn't exist, adds it
47
+ * - If the item exists, updates it
48
+ * - Handles foreign key changes by updating the primaryToLinked index
49
+ * (removes from old primary's list, adds to new primary's list)
50
+ * - Handles `_deleted`/`_blocked` items by removing their metadata
51
+ *
52
+ * @typeParam TPrimary - Type of primary items
53
+ * @typeParam TLinked - Type of linked items
54
+ * @typeParam C - Type of the search context
55
+ *
56
+ * @param linked - The linked metadata to update (mutated in place)
57
+ * @param item - The linked item to upsert
58
+ * @param foreignKeyGetter - Function to get the primary ID from a linked item
59
+ * @param spec - Optional specification for how to extract searchable text
60
+ * @returns UpsertResult indicating if item was added or updated, and previous primary ID if FK changed
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const pacient = { _id: 'p1', ime: 'Rex', stranka_id: 's1' };
65
+ * const result = upsertLinkedItemNumeric(linkedMeta, pacient, (p) => p.stranka_id, spec);
66
+ *
67
+ * // If the pacient moved to a different stranka:
68
+ * pacient.stranka_id = 's2';
69
+ * const result2 = upsertLinkedItemNumeric(linkedMeta, pacient, (p) => p.stranka_id, spec);
70
+ * // result2.previousPrimaryId === 's1'
71
+ * ```
72
+ */
73
+ export declare function upsertLinkedItemNumeric<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: NumericLinkedSearchMetadataWithData<TPrimary, TLinked>, item: TLinked, foreignKeyGetter: (item: TLinked) => Id | undefined, spec?: SearchableObjectSpec<TLinked, C>): UpsertResult;
74
+ /**
75
+ * Removes a linked item from the linked metadata (numeric version).
76
+ *
77
+ * Removes the item from data, metadata, and the primaryToLinked index.
78
+ *
79
+ * @typeParam TPrimary - Type of primary items
80
+ * @typeParam TLinked - Type of linked items
81
+ *
82
+ * @param linked - The linked metadata to update (mutated in place)
83
+ * @param linkedId - The ID of the linked item to remove
84
+ * @param foreignKeyGetter - Function to get the primary ID from a linked item
85
+ * @returns true if item was found and removed, false if not found
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * removeLinkedItemNumeric(linkedMeta, 'pacient-id', (p) => p.stranka_id);
90
+ * ```
91
+ */
92
+ export declare function removeLinkedItemNumeric<TPrimary extends SearchableObject, TLinked extends SearchableObject>(linked: NumericLinkedSearchMetadataWithData<TPrimary, TLinked>, linkedId: Id, foreignKeyGetter: (item: TLinked) => Id | undefined): boolean;
93
+ /**
94
+ * Syncs all linked items for a specific primary item (numeric version).
95
+ *
96
+ * This function performs a full sync of linked items belonging to a single primary:
97
+ * - Removes linked items that are no longer in the new data
98
+ * - Updates existing linked items if their tokens changed
99
+ * - Adds new linked items
100
+ * - Only processes items whose foreign key points to the given primary
101
+ *
102
+ * Use this when you have a complete new set of linked items for a primary
103
+ * and want to update the metadata to match.
104
+ *
105
+ * @typeParam TPrimary - Type of primary items
106
+ * @typeParam TLinked - Type of linked items
107
+ * @typeParam C - Type of the search context
108
+ *
109
+ * @param linked - The linked metadata to update (mutated in place)
110
+ * @param primaryId - The primary ID to sync linked items for
111
+ * @param newLinkedItems - The new linked items (only items with matching FK will be processed)
112
+ * @param foreignKeyGetter - Function to get the primary ID from a linked item
113
+ * @param spec - Optional specification for how to extract searchable text
114
+ * @returns SyncLinkedResult with counts of added/updated/removed items
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const newPacienti = arrayToSearchableData(freshPacientiFromServer);
119
+ * const result = syncLinkedItemsForPrimaryNumeric(
120
+ * linkedMeta,
121
+ * 'stranka-1',
122
+ * newPacienti,
123
+ * (p) => p.stranka_id,
124
+ * spec
125
+ * );
126
+ * console.log(`Added: ${result.added}, Updated: ${result.updated}, Removed: ${result.removed}`);
127
+ * ```
128
+ */
129
+ export declare function syncLinkedItemsForPrimaryNumeric<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: NumericLinkedSearchMetadataWithData<TPrimary, TLinked>, primaryId: Id, newLinkedItems: SearchableData<TLinked>, foreignKeyGetter: (item: TLinked) => Id | undefined, spec?: SearchableObjectSpec<TLinked, C>): SyncLinkedResult;
130
+ //# sourceMappingURL=updateSearchLinkedMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateSearchLinkedMetadata.d.ts","sourceRoot":"","sources":["../../../src/common/numeric/updateSearchLinkedMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,EAAE,EACF,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAEjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAA;AAK1F,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAkB1E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAChC,CAAC,GAAG,OAAO,EAEX,MAAM,EAAE,mCAAmC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC9D,IAAI,EAAE,QAAQ,EACd,IAAI,CAAC,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC,GACvC,YAAY,CAwBd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAChC,MAAM,EAAE,mCAAmC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,CAUxF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAChC,CAAC,GAAG,OAAO,EAEX,MAAM,EAAE,mCAAmC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC9D,IAAI,EAAE,OAAO,EACb,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,EAAE,GAAG,SAAS,EACnD,IAAI,CAAC,EAAE,oBAAoB,CAAC,OAAO,EAAE,CAAC,CAAC,GACtC,YAAY,CA0Dd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAEhC,MAAM,EAAE,mCAAmC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC9D,QAAQ,EAAE,EAAE,EACZ,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,EAAE,GAAG,SAAS,GAClD,OAAO,CAyBT;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAChC,CAAC,GAAG,OAAO,EAEX,MAAM,EAAE,mCAAmC,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC9D,SAAS,EAAE,EAAE,EACb,cAAc,EAAE,cAAc,CAAC,OAAO,CAAC,EACvC,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,EAAE,GAAG,SAAS,EACnD,IAAI,CAAC,EAAE,oBAAoB,CAAC,OAAO,EAAE,CAAC,CAAC,GACtC,gBAAgB,CA8DlB"}
@@ -1,7 +1,9 @@
1
1
  import type { SearchMetadata, SearchableData, SearchableObject, SearchableObjectSpec, SyncResult, SyncOptions } from '../types';
2
2
  export type { SyncResult, SyncOptions } from '../types';
3
3
  /**
4
- * Syncs search metadata with new data.
4
+ * Syncs string-based search metadata with new data.
5
+ *
6
+ * LEGACY: Use syncSearchArrayMetadataNumeric for new code.
5
7
  *
6
8
  * This function performs a full sync of metadata against the provided data:
7
9
  * - Adds metadata for new items
@@ -9,7 +11,7 @@ export type { SyncResult, SyncOptions } from '../types';
9
11
  * - Updates metadata for items whose tokens have changed
10
12
  *
11
13
  * Use this when you have completely new data to sync with. If you have both
12
- * previous and new data available, use {@link syncSearchArrayMetadataWithPrevious}
14
+ * previous and new data available, use {@link syncSearchArrayMetadataStringWithPrevious}
13
15
  * for more efficient diffing.
14
16
  *
15
17
  * @typeParam T - Type of the searchable objects
@@ -23,16 +25,18 @@ export type { SyncResult, SyncOptions } from '../types';
23
25
  * @example
24
26
  * ```typescript
25
27
  * const newProducts = arrayToSearchableData(freshProductsFromServer);
26
- * const result = syncSearchArrayMetadata(metadata, newProducts, spec);
28
+ * const result = syncSearchArrayMetadataString(metadata, newProducts, spec);
27
29
  *
28
30
  * console.log(`Added: ${result.added}, Updated: ${result.updated}, Removed: ${result.removed}`);
29
31
  * ```
30
32
  */
31
- export declare function syncSearchArrayMetadata<T extends SearchableObject, C = unknown>(metadata: SearchMetadata, newData: SearchableData<T>, spec?: SearchableObjectSpec<T, C>): SyncResult;
33
+ export declare function syncSearchArrayMetadataString<T extends SearchableObject, C = unknown>(metadata: SearchMetadata, newData: SearchableData<T>, spec?: SearchableObjectSpec<T, C>): SyncResult;
32
34
  /**
33
- * Syncs search metadata using previous and new data for efficient diffing.
35
+ * Syncs string-based search metadata using previous and new data for efficient diffing.
36
+ *
37
+ * LEGACY: Use syncSearchArrayMetadataNumericWithPrevious for new code.
34
38
  *
35
- * More efficient than {@link syncSearchArrayMetadata} when you have both the
39
+ * More efficient than {@link syncSearchArrayMetadataString} when you have both the
36
40
  * previous and new data available. Uses the previous data to determine
37
41
  * what was removed without iterating through all metadata keys.
38
42
  *
@@ -51,7 +55,7 @@ export declare function syncSearchArrayMetadata<T extends SearchableObject, C =
51
55
  * const previousProducts = currentData;
52
56
  * const newProducts = arrayToSearchableData(freshProductsFromServer);
53
57
  *
54
- * const result = syncSearchArrayMetadataWithPrevious(
58
+ * const result = syncSearchArrayMetadataStringWithPrevious(
55
59
  * metadata,
56
60
  * previousProducts,
57
61
  * newProducts,
@@ -60,5 +64,5 @@ export declare function syncSearchArrayMetadata<T extends SearchableObject, C =
60
64
  * );
61
65
  * ```
62
66
  */
63
- export declare function syncSearchArrayMetadataWithPrevious<T extends SearchableObject, C = unknown>(metadata: SearchMetadata, previousData: SearchableData<T>, newData: SearchableData<T>, options?: SyncOptions, spec?: SearchableObjectSpec<T, C>): SyncResult;
67
+ export declare function syncSearchArrayMetadataStringWithPrevious<T extends SearchableObject, C = unknown>(metadata: SearchMetadata, previousData: SearchableData<T>, newData: SearchableData<T>, options?: SyncOptions, spec?: SearchableObjectSpec<T, C>): SyncResult;
64
68
  //# sourceMappingURL=syncSearchArrayMetadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"syncSearchArrayMetadata.d.ts","sourceRoot":"","sources":["../../src/common/syncSearchArrayMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EAEpB,UAAU,EACV,WAAW,EACZ,MAAM,UAAU,CAAC;AAIlB,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAkBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,EAAE,CAAC,GAAG,OAAO,EAC7E,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAC1B,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAChC,UAAU,CAiDZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,mCAAmC,CAAC,CAAC,SAAS,gBAAgB,EAAE,CAAC,GAAG,OAAO,EACzF,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,EAC/B,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAC1B,OAAO,CAAC,EAAE,WAAW,EACrB,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAChC,UAAU,CAmDZ"}
1
+ {"version":3,"file":"syncSearchArrayMetadata.d.ts","sourceRoot":"","sources":["../../src/common/syncSearchArrayMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EAEpB,UAAU,EACV,WAAW,EACZ,MAAM,UAAU,CAAC;AAIlB,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAkBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,gBAAgB,EAAE,CAAC,GAAG,OAAO,EACnF,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAC1B,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAChC,UAAU,CAiDZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,yCAAyC,CAAC,CAAC,SAAS,gBAAgB,EAAE,CAAC,GAAG,OAAO,EAC/F,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,EAC/B,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAC1B,OAAO,CAAC,EAAE,WAAW,EACrB,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAChC,UAAU,CAmDZ"}
@@ -1,7 +1,9 @@
1
1
  import type { Id, SearchableData, SearchableObject, SearchableObjectSpec, SearchLinkedMetadataWithData, UpsertResult, SyncLinkedResult } from '../types';
2
2
  export type { UpsertResult, SyncLinkedResult } from '../types';
3
3
  /**
4
- * Upserts a primary item into the linked metadata.
4
+ * Upserts a primary item into the linked metadata (string-based).
5
+ *
6
+ * LEGACY: Use upsertPrimaryItemNumeric for new code.
5
7
  *
6
8
  * - If the item doesn't exist, adds it to data, metadata, and initializes primaryToLinked index
7
9
  * - If the item exists, updates data and metadata
@@ -19,17 +21,19 @@ export type { UpsertResult, SyncLinkedResult } from '../types';
19
21
  * @example
20
22
  * ```typescript
21
23
  * const stranka = { _id: 's1', ime: 'Janez', priimek: 'Novak' };
22
- * const result = upsertPrimaryItem(linkedMeta, stranka, spec);
24
+ * const result = upsertPrimaryItemString(linkedMeta, stranka, spec);
23
25
  * // result.added === true if stranka was new
24
26
  * ```
25
27
  */
26
- export declare function upsertPrimaryItem<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, item: TPrimary, spec?: SearchableObjectSpec<TPrimary, C>): UpsertResult;
28
+ export declare function upsertPrimaryItemString<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, item: TPrimary, spec?: SearchableObjectSpec<TPrimary, C>): UpsertResult;
27
29
  /**
28
- * Removes a primary item from the linked metadata.
30
+ * Removes a primary item from the linked metadata (string-based).
31
+ *
32
+ * LEGACY: Use removePrimaryItemNumeric for new code.
29
33
  *
30
34
  * Removes the item from data, metadata, and the primaryToLinked index.
31
35
  * Note: This does NOT automatically remove linked items - they will become orphans.
32
- * If you want to also remove linked items, call {@link removeLinkedItem} for each.
36
+ * If you want to also remove linked items, call {@link removeLinkedItemString} for each.
33
37
  *
34
38
  * @typeParam TPrimary - Type of primary items
35
39
  * @typeParam TLinked - Type of linked items
@@ -38,9 +42,11 @@ export declare function upsertPrimaryItem<TPrimary extends SearchableObject, TLi
38
42
  * @param primaryId - The ID of the primary item to remove
39
43
  * @returns true if item was found and removed, false if not found
40
44
  */
41
- export declare function removePrimaryItem<TPrimary extends SearchableObject, TLinked extends SearchableObject>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, primaryId: Id): boolean;
45
+ export declare function removePrimaryItemString<TPrimary extends SearchableObject, TLinked extends SearchableObject>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, primaryId: Id): boolean;
42
46
  /**
43
- * Upserts a linked item into the linked metadata.
47
+ * Upserts a linked item into the linked metadata (string-based).
48
+ *
49
+ * LEGACY: Use upsertLinkedItemNumeric for new code.
44
50
  *
45
51
  * - If the item doesn't exist, adds it
46
52
  * - If the item exists, updates it
@@ -61,17 +67,19 @@ export declare function removePrimaryItem<TPrimary extends SearchableObject, TLi
61
67
  * @example
62
68
  * ```typescript
63
69
  * const pacient = { _id: 'p1', ime: 'Rex', stranka_id: 's1' };
64
- * const result = upsertLinkedItem(linkedMeta, pacient, (p) => p.stranka_id, spec);
70
+ * const result = upsertLinkedItemString(linkedMeta, pacient, (p) => p.stranka_id, spec);
65
71
  *
66
72
  * // If the pacient moved to a different stranka:
67
73
  * pacient.stranka_id = 's2';
68
- * const result2 = upsertLinkedItem(linkedMeta, pacient, (p) => p.stranka_id, spec);
74
+ * const result2 = upsertLinkedItemString(linkedMeta, pacient, (p) => p.stranka_id, spec);
69
75
  * // result2.previousPrimaryId === 's1'
70
76
  * ```
71
77
  */
72
- export declare function upsertLinkedItem<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, item: TLinked, foreignKeyGetter: (item: TLinked) => Id | undefined, spec?: SearchableObjectSpec<TLinked, C>): UpsertResult;
78
+ export declare function upsertLinkedItemString<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, item: TLinked, foreignKeyGetter: (item: TLinked) => Id | undefined, spec?: SearchableObjectSpec<TLinked, C>): UpsertResult;
73
79
  /**
74
- * Removes a linked item from the linked metadata.
80
+ * Removes a linked item from the linked metadata (string-based).
81
+ *
82
+ * LEGACY: Use removeLinkedItemNumeric for new code.
75
83
  *
76
84
  * Removes the item from data, metadata, and the primaryToLinked index.
77
85
  *
@@ -85,12 +93,14 @@ export declare function upsertLinkedItem<TPrimary extends SearchableObject, TLin
85
93
  *
86
94
  * @example
87
95
  * ```typescript
88
- * removeLinkedItem(linkedMeta, 'pacient-id', (p) => p.stranka_id);
96
+ * removeLinkedItemString(linkedMeta, 'pacient-id', (p) => p.stranka_id);
89
97
  * ```
90
98
  */
91
- export declare function removeLinkedItem<TPrimary extends SearchableObject, TLinked extends SearchableObject>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, linkedId: Id, foreignKeyGetter: (item: TLinked) => Id | undefined): boolean;
99
+ export declare function removeLinkedItemString<TPrimary extends SearchableObject, TLinked extends SearchableObject>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, linkedId: Id, foreignKeyGetter: (item: TLinked) => Id | undefined): boolean;
92
100
  /**
93
- * Syncs all linked items for a specific primary item.
101
+ * Syncs all linked items for a specific primary item (string-based).
102
+ *
103
+ * LEGACY: Use syncLinkedItemsForPrimaryNumeric for new code.
94
104
  *
95
105
  * This function performs a full sync of linked items belonging to a single primary:
96
106
  * - Removes linked items that are no longer in the new data
@@ -115,7 +125,7 @@ export declare function removeLinkedItem<TPrimary extends SearchableObject, TLin
115
125
  * @example
116
126
  * ```typescript
117
127
  * const newPacienti = arrayToSearchableData(freshPacientiFromServer);
118
- * const result = syncLinkedItemsForPrimary(
128
+ * const result = syncLinkedItemsForPrimaryString(
119
129
  * linkedMeta,
120
130
  * 'stranka-1',
121
131
  * newPacienti,
@@ -125,5 +135,5 @@ export declare function removeLinkedItem<TPrimary extends SearchableObject, TLin
125
135
  * console.log(`Added: ${result.added}, Updated: ${result.updated}, Removed: ${result.removed}`);
126
136
  * ```
127
137
  */
128
- export declare function syncLinkedItemsForPrimary<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, primaryId: Id, newLinkedItems: SearchableData<TLinked>, foreignKeyGetter: (item: TLinked) => Id | undefined, spec?: SearchableObjectSpec<TLinked, C>): SyncLinkedResult;
138
+ export declare function syncLinkedItemsForPrimaryString<TPrimary extends SearchableObject, TLinked extends SearchableObject, C = unknown>(linked: SearchLinkedMetadataWithData<TPrimary, TLinked>, primaryId: Id, newLinkedItems: SearchableData<TLinked>, foreignKeyGetter: (item: TLinked) => Id | undefined, spec?: SearchableObjectSpec<TLinked, C>): SyncLinkedResult;
129
139
  //# sourceMappingURL=updateSearchLinkedMetadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateSearchLinkedMetadata.d.ts","sourceRoot":"","sources":["../../src/common/updateSearchLinkedMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,EAAE,EACF,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAIlB,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAkB/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAChC,CAAC,GAAG,OAAO,EAEX,MAAM,EAAE,4BAA4B,CAAC,QAAQ,EAAE,OAAO,CAAC,EACvD,IAAI,EAAE,QAAQ,EACd,IAAI,CAAC,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC,GACvC,YAAY,CAqBd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,gBAAgB,EAChC,MAAM,EAAE,4BAA4B,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,CAUjF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,SAAS,gBAAgB,EACjC,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