@donotdev/crud 0.2.3 → 0.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.
Files changed (267) hide show
  1. package/dist/CrudService.bulk.d.ts +13 -14
  2. package/dist/CrudService.bulk.d.ts.map +1 -1
  3. package/dist/CrudService.bulk.js +1 -1
  4. package/dist/CrudService.bulkAcross.d.ts +12 -7
  5. package/dist/CrudService.bulkAcross.d.ts.map +1 -1
  6. package/dist/CrudService.bulkAcross.js +1 -1
  7. package/dist/CrudService.bulkReconciliation.d.ts +4 -0
  8. package/dist/CrudService.bulkReconciliation.d.ts.map +1 -0
  9. package/dist/CrudService.bulkReconciliation.js +1 -0
  10. package/dist/CrudService.cache.d.ts +1 -1
  11. package/dist/CrudService.cache.d.ts.map +1 -1
  12. package/dist/CrudService.cache.js +1 -1
  13. package/dist/CrudService.d.ts +35 -6
  14. package/dist/CrudService.d.ts.map +1 -1
  15. package/dist/CrudService.js +1 -1
  16. package/dist/CrudService.mutations.d.ts +3 -3
  17. package/dist/CrudService.mutations.d.ts.map +1 -1
  18. package/dist/CrudService.mutations.js +1 -1
  19. package/dist/CrudService.optimistic.d.ts +2 -2
  20. package/dist/CrudService.optimistic.d.ts.map +1 -1
  21. package/dist/CrudService.optimistic.js +1 -1
  22. package/dist/CrudService.subscriptions.js +1 -1
  23. package/dist/CrudService.writeRules.d.ts +57 -0
  24. package/dist/CrudService.writeRules.d.ts.map +1 -0
  25. package/dist/CrudService.writeRules.js +1 -0
  26. package/dist/CrudService.writeSchema.d.ts +64 -0
  27. package/dist/CrudService.writeSchema.d.ts.map +1 -0
  28. package/dist/CrudService.writeSchema.js +1 -0
  29. package/dist/CrudStore.d.ts +10 -1
  30. package/dist/CrudStore.d.ts.map +1 -1
  31. package/dist/CrudStore.js +1 -1
  32. package/dist/FieldRegistry.d.ts +1 -1
  33. package/dist/FieldRegistry.d.ts.map +1 -1
  34. package/dist/adapters/FunctionsAdapter.d.ts +3 -3
  35. package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
  36. package/dist/adapters/FunctionsAdapter.js +1 -1
  37. package/dist/components/CrudButton.d.ts +3 -2
  38. package/dist/components/CrudButton.d.ts.map +1 -1
  39. package/dist/components/CrudCard.d.ts.map +1 -1
  40. package/dist/components/CrudCard.js +1 -1
  41. package/dist/components/DateFilter.js +1 -1
  42. package/dist/components/EntityFilters.d.ts +23 -4
  43. package/dist/components/EntityFilters.d.ts.map +1 -1
  44. package/dist/components/EntityFilters.js +1 -1
  45. package/dist/components/FormFieldRenderer.d.ts +21 -4
  46. package/dist/components/FormFieldRenderer.d.ts.map +1 -1
  47. package/dist/components/FormFieldRenderer.js +1 -1
  48. package/dist/components/FormLayout.d.ts.map +1 -1
  49. package/dist/components/FormLayout.js +1 -1
  50. package/dist/components/SortableCardList.d.ts +47 -0
  51. package/dist/components/SortableCardList.d.ts.map +1 -0
  52. package/dist/components/SortableCardList.js +1 -0
  53. package/dist/components/YearFilter.js +1 -1
  54. package/dist/components/controlled/complex/ControlledAddressField.d.ts.map +1 -1
  55. package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
  56. package/dist/components/controlled/complex/ControlledDateField.d.ts.map +1 -1
  57. package/dist/components/controlled/complex/ControlledDateField.js +1 -1
  58. package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts +9 -0
  59. package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts.map +1 -1
  60. package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
  61. package/dist/components/controlled/complex/ControlledMultiInputField.d.ts.map +1 -1
  62. package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
  63. package/dist/components/controlled/complex/ControlledTimestampField.d.ts.map +1 -1
  64. package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
  65. package/dist/components/controlled/fieldOptions.d.ts +9 -0
  66. package/dist/components/controlled/fieldOptions.d.ts.map +1 -1
  67. package/dist/components/controlled/fieldOptions.js +1 -1
  68. package/dist/components/controlled/file/ControlledImageField.js +1 -1
  69. package/dist/components/controlled/input/ControlledCurrencyField.d.ts.map +1 -1
  70. package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
  71. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  72. package/dist/components/controlled/input/ControlledNumberField.d.ts.map +1 -1
  73. package/dist/components/controlled/input/ControlledNumberField.js +1 -1
  74. package/dist/components/controlled/input/ControlledPasswordField.d.ts.map +1 -1
  75. package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
  76. package/dist/components/controlled/input/ControlledPhoneField.d.ts.map +1 -1
  77. package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
  78. package/dist/components/controlled/input/ControlledPriceField.d.ts.map +1 -1
  79. package/dist/components/controlled/input/ControlledPriceField.js +1 -1
  80. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  81. package/dist/components/controlled/input/ControlledTextField.d.ts.map +1 -1
  82. package/dist/components/controlled/input/ControlledTextField.js +1 -1
  83. package/dist/components/controlled/input/ControlledTextareaField.d.ts.map +1 -1
  84. package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
  85. package/dist/components/controlled/select/ControlledComboboxField.d.ts.map +1 -1
  86. package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
  87. package/dist/components/controlled/select/ControlledDropdownField.d.ts.map +1 -1
  88. package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
  89. package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts.map +1 -1
  90. package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
  91. package/dist/components/controlled/select/ControlledReferenceField.d.ts.map +1 -1
  92. package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
  93. package/dist/components/controlled/select/ControlledYearField.d.ts.map +1 -1
  94. package/dist/components/controlled/select/ControlledYearField.js +1 -1
  95. package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
  96. package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
  97. package/dist/components/fields/display/MapFieldDisplay.js +1 -1
  98. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  99. package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
  100. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  101. package/dist/components/form/fields/AddressFieldComponent.d.ts +3 -1
  102. package/dist/components/form/fields/AddressFieldComponent.d.ts.map +1 -1
  103. package/dist/components/form/fields/AddressFieldComponent.js +1 -1
  104. package/dist/components/form/fields/ComboboxComponent.d.ts +2 -0
  105. package/dist/components/form/fields/ComboboxComponent.d.ts.map +1 -1
  106. package/dist/components/form/fields/ComboboxComponent.js +1 -1
  107. package/dist/components/form/fields/CurrencyFieldComponent.d.ts +2 -0
  108. package/dist/components/form/fields/CurrencyFieldComponent.d.ts.map +1 -1
  109. package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
  110. package/dist/components/form/fields/DateFieldComponent.d.ts +2 -0
  111. package/dist/components/form/fields/DateFieldComponent.d.ts.map +1 -1
  112. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  113. package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
  114. package/dist/components/form/fields/DropdownComponent.d.ts +2 -0
  115. package/dist/components/form/fields/DropdownComponent.d.ts.map +1 -1
  116. package/dist/components/form/fields/DropdownComponent.js +1 -1
  117. package/dist/components/form/fields/DurationFieldComponent.d.ts.map +1 -1
  118. package/dist/components/form/fields/DurationFieldComponent.js +1 -1
  119. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  120. package/dist/components/form/fields/GdprConsentFieldComponent.d.ts.map +1 -1
  121. package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
  122. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  123. package/dist/components/form/fields/ImageFieldComponent.d.ts.map +1 -1
  124. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  125. package/dist/components/form/fields/MultiDropdownComponent.d.ts +2 -0
  126. package/dist/components/form/fields/MultiDropdownComponent.d.ts.map +1 -1
  127. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  128. package/dist/components/form/fields/MultiInputTextFieldComponent.d.ts +2 -0
  129. package/dist/components/form/fields/MultiInputTextFieldComponent.d.ts.map +1 -1
  130. package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
  131. package/dist/components/form/fields/NumberFieldComponent.d.ts +2 -0
  132. package/dist/components/form/fields/NumberFieldComponent.d.ts.map +1 -1
  133. package/dist/components/form/fields/NumberFieldComponent.js +1 -1
  134. package/dist/components/form/fields/PasswordFieldComponent.d.ts +2 -0
  135. package/dist/components/form/fields/PasswordFieldComponent.d.ts.map +1 -1
  136. package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
  137. package/dist/components/form/fields/PhoneNumberComponent.d.ts +11 -1
  138. package/dist/components/form/fields/PhoneNumberComponent.d.ts.map +1 -1
  139. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  140. package/dist/components/form/fields/PriceFieldComponent.d.ts +2 -0
  141. package/dist/components/form/fields/PriceFieldComponent.d.ts.map +1 -1
  142. package/dist/components/form/fields/PriceFieldComponent.js +1 -1
  143. package/dist/components/form/fields/RangeFieldComponent.js +1 -1
  144. package/dist/components/form/fields/ReferenceFieldComponent.d.ts +3 -1
  145. package/dist/components/form/fields/ReferenceFieldComponent.d.ts.map +1 -1
  146. package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
  147. package/dist/components/form/fields/RichTextComponent.js +1 -1
  148. package/dist/components/form/fields/TextAreaComponent.d.ts +2 -0
  149. package/dist/components/form/fields/TextAreaComponent.d.ts.map +1 -1
  150. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  151. package/dist/components/form/fields/TextFieldComponent.d.ts +3 -1
  152. package/dist/components/form/fields/TextFieldComponent.d.ts.map +1 -1
  153. package/dist/components/form/fields/TextFieldComponent.js +1 -1
  154. package/dist/components/form/fields/TimestampFieldComponent.d.ts +2 -0
  155. package/dist/components/form/fields/TimestampFieldComponent.d.ts.map +1 -1
  156. package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
  157. package/dist/components/index.d.ts +2 -0
  158. package/dist/components/index.d.ts.map +1 -1
  159. package/dist/components/index.js +1 -1
  160. package/dist/fieldTypeRegistry.d.ts +2 -2
  161. package/dist/fieldTypeRegistry.d.ts.map +1 -1
  162. package/dist/fieldTypeRegistry.js +1 -1
  163. package/dist/fieldTypeRegistry.store.d.ts +0 -2
  164. package/dist/fieldTypeRegistry.store.d.ts.map +1 -1
  165. package/dist/fieldTypeRegistry.store.js +1 -1
  166. package/dist/fieldTypeRegistry.types.d.ts +8 -9
  167. package/dist/fieldTypeRegistry.types.d.ts.map +1 -1
  168. package/dist/forms/FormNavigation.d.ts +24 -0
  169. package/dist/forms/FormNavigation.d.ts.map +1 -0
  170. package/dist/forms/FormNavigation.js +1 -0
  171. package/dist/forms/childRows.d.ts +184 -0
  172. package/dist/forms/childRows.d.ts.map +1 -0
  173. package/dist/forms/childRows.js +1 -0
  174. package/dist/forms/extend.d.ts +88 -0
  175. package/dist/forms/extend.d.ts.map +1 -0
  176. package/dist/forms/extend.js +1 -0
  177. package/dist/forms/hooks/useEntityField.d.ts +11 -5
  178. package/dist/forms/hooks/useEntityField.d.ts.map +1 -1
  179. package/dist/forms/hooks/useEntityField.js +1 -1
  180. package/dist/forms/hooks/useEntityForm.d.ts +50 -5
  181. package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
  182. package/dist/forms/hooks/useEntityForm.js +1 -1
  183. package/dist/forms/hooks/useFormDraftState.d.ts +53 -0
  184. package/dist/forms/hooks/useFormDraftState.d.ts.map +1 -0
  185. package/dist/forms/hooks/useFormDraftState.js +1 -0
  186. package/dist/forms/index.d.ts +6 -2
  187. package/dist/forms/index.d.ts.map +1 -1
  188. package/dist/forms/index.js +1 -1
  189. package/dist/forms/types.d.ts +171 -25
  190. package/dist/forms/types.d.ts.map +1 -1
  191. package/dist/forms/utils/buildInitialValues.d.ts +32 -17
  192. package/dist/forms/utils/buildInitialValues.d.ts.map +1 -1
  193. package/dist/forms/utils/buildInitialValues.js +1 -1
  194. package/dist/forms/utils/conditionAwareResolver.d.ts +35 -0
  195. package/dist/forms/utils/conditionAwareResolver.d.ts.map +1 -0
  196. package/dist/forms/utils/conditionAwareResolver.js +1 -0
  197. package/dist/forms/utils/emptyValue.d.ts +34 -0
  198. package/dist/forms/utils/emptyValue.d.ts.map +1 -0
  199. package/dist/forms/utils/emptyValue.js +1 -0
  200. package/dist/forms/utils/getFieldsForOperation.d.ts +30 -19
  201. package/dist/forms/utils/getFieldsForOperation.d.ts.map +1 -1
  202. package/dist/forms/utils/getFieldsForOperation.js +1 -1
  203. package/dist/forms/utils/index.d.ts +1 -0
  204. package/dist/forms/utils/index.d.ts.map +1 -1
  205. package/dist/forms/utils/index.js +1 -1
  206. package/dist/forms/utils/isFieldEditable.d.ts +21 -22
  207. package/dist/forms/utils/isFieldEditable.d.ts.map +1 -1
  208. package/dist/forms/utils/isFieldEditable.js +1 -1
  209. package/dist/forms/utils/writableFields.d.ts +19 -0
  210. package/dist/forms/utils/writableFields.d.ts.map +1 -0
  211. package/dist/forms/utils/writableFields.js +1 -0
  212. package/dist/hooks/index.d.ts +2 -0
  213. package/dist/hooks/index.d.ts.map +1 -1
  214. package/dist/hooks/index.js +1 -1
  215. package/dist/hooks/useChildRows.d.ts +161 -0
  216. package/dist/hooks/useChildRows.d.ts.map +1 -0
  217. package/dist/hooks/useChildRows.js +1 -0
  218. package/dist/hooks/useCrudFilters.d.ts +21 -1
  219. package/dist/hooks/useCrudFilters.d.ts.map +1 -1
  220. package/dist/hooks/useCrudFilters.js +1 -1
  221. package/dist/hooks/useExtensionRows.d.ts +24 -0
  222. package/dist/hooks/useExtensionRows.d.ts.map +1 -0
  223. package/dist/hooks/useExtensionRows.js +1 -0
  224. package/dist/hooks/useFieldConditions.d.ts +2 -2
  225. package/dist/hooks/useFieldConditions.d.ts.map +1 -1
  226. package/dist/hooks/useFieldConditions.js +1 -1
  227. package/dist/hooks/useReferenceResolver.d.ts +4 -1
  228. package/dist/hooks/useReferenceResolver.d.ts.map +1 -1
  229. package/dist/hooks/useReferenceResolver.js +1 -1
  230. package/dist/index.d.ts +6 -5
  231. package/dist/index.d.ts.map +1 -1
  232. package/dist/index.js +1 -1
  233. package/dist/registerBuiltinFieldTypes.d.ts +2 -0
  234. package/dist/registerBuiltinFieldTypes.d.ts.map +1 -1
  235. package/dist/registerBuiltinFieldTypes.js +1 -1
  236. package/dist/stores/FormStore.d.ts +116 -5
  237. package/dist/stores/FormStore.d.ts.map +1 -1
  238. package/dist/stores/FormStore.js +1 -1
  239. package/dist/stores/UploadStore.js +1 -1
  240. package/dist/stores/index.d.ts +1 -1
  241. package/dist/stores/index.d.ts.map +1 -1
  242. package/dist/stores/index.js +1 -1
  243. package/dist/symbol-index.json +1 -1
  244. package/dist/tsconfig.tsbuildinfo +1 -1
  245. package/dist/types.d.ts +38 -6
  246. package/dist/types.d.ts.map +1 -1
  247. package/dist/useCrud.d.ts +7 -5
  248. package/dist/useCrud.d.ts.map +1 -1
  249. package/dist/useCrud.js +1 -1
  250. package/dist/useCrudDoc.js +1 -1
  251. package/dist/utils/clientListProcessing.d.ts +9 -12
  252. package/dist/utils/clientListProcessing.d.ts.map +1 -1
  253. package/dist/utils/clientListProcessing.js +1 -1
  254. package/dist/utils/collections.d.ts.map +1 -1
  255. package/dist/utils/collections.js +1 -1
  256. package/dist/utils/filterUrl.d.ts +45 -0
  257. package/dist/utils/filterUrl.d.ts.map +1 -0
  258. package/dist/utils/filterUrl.js +1 -0
  259. package/dist/utils/matchesFilter.d.ts +27 -3
  260. package/dist/utils/matchesFilter.d.ts.map +1 -1
  261. package/dist/utils/matchesFilter.js +1 -1
  262. package/dist/utils/uploadValidation.js +1 -1
  263. package/dist/utils/useRowTranslator.js +1 -1
  264. package/guidelines/COMPONENTS.md +82 -11
  265. package/guidelines/CRUD.md +242 -7
  266. package/guidelines/GOTCHAS.md +17 -1
  267. package/package.json +3 -3
package/dist/types.d.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  * @since 0.0.1
12
12
  * @author AMBROISE PARK Consulting
13
13
  */
14
- import type { BulkAcrossBatch, BulkAcrossResult, BulkOperations, BulkResult, CrudCreateInput, CrudDocQuery, CrudListQuery, dndevSchema, ICrudAdapter, QueryClient, QueryOptions, PaginatedQueryResult, ListSchemaType, SecurityContext } from '@donotdev/core';
14
+ import type { AnyEntity, BulkAcrossBatch, BulkAcrossOptions, BulkAcrossResult, BulkOperations, BulkResult, CrudCreateInput, CrudDocQuery, CrudListQuery, dndevSchema, ICrudAdapter, QueryClient, QueryOptions, PaginatedQueryResult, ListSchemaType, SecurityContext } from '@donotdev/core';
15
15
  /**
16
16
  * Optimistic operation status
17
17
  */
@@ -107,6 +107,20 @@ export interface CrudActions {
107
107
  setShowFavoritesOnly: (collection: string, show: boolean) => void;
108
108
  setPageSize: (collection: string, pageSize: number) => void;
109
109
  getFilters: (collection: string) => FilterState;
110
+ /**
111
+ * URL sync of a filter state (`f_*` params, see CRUD.md "URL sync"). Default: a key
112
+ * that is an entity collection (defineEntity) syncs with that entity's fields; any
113
+ * other key (an `EntityFilters` `filterKey`) does not. `entity` opts a key in
114
+ * (its fields decode the params), `null` opts it out.
115
+ * @since 0.3.0
116
+ */
117
+ setFilterUrlSync: (key: string, entity: AnyEntity | null) => void;
118
+ /**
119
+ * Re-read a URL-synced filter state from the current URL (no-op for other keys, on
120
+ * the server, or while this page's own URL write is pending).
121
+ * @since 0.3.0
122
+ */
123
+ syncFiltersFromUrl: (key: string) => void;
110
124
  getShowFavoritesOnly: (collection: string) => boolean;
111
125
  getPageSize: (collection: string) => number | undefined;
112
126
  /** Add item optimistically (before server confirms) */
@@ -163,6 +177,12 @@ export interface MutationOptions {
163
177
  * - undefined: use global setting (hideSuccessToasts)
164
178
  */
165
179
  showSuccessToast?: boolean;
180
+ /**
181
+ * The collection's read schema (`useCrud` passes it): the stored row a write
182
+ * returns is filtered with it for the requester's role before it is cached.
183
+ * @since 0.3.0
184
+ */
185
+ readSchema?: dndevSchema<unknown>;
166
186
  }
167
187
  /**
168
188
  * CRUD Service Interface
@@ -186,8 +206,10 @@ export interface CrudServiceInterface {
186
206
  getDocQueryOptions<T>(collection: string, id: string, schema: dndevSchema<unknown>, cacheOptions?: CacheOptions): CrudDocQuery<T>;
187
207
  get<T>(collection: string, id: string, schema: dndevSchema<T>, options?: CacheOptions): Promise<T | null>;
188
208
  query<T>(collection: string, options: QueryOptions, schema: dndevSchema<T>, cacheOptions?: CacheOptions, schemaType?: ListSchemaType): Promise<PaginatedQueryResult<T>>;
189
- set<T>(collection: string, id: string, data: T, schema: dndevSchema<T>, options?: MutationOptions): Promise<void>;
190
- update<T>(collection: string, id: string, data: Partial<T>, schema?: dndevSchema<T>, options?: MutationOptions): Promise<void>;
209
+ set<T>(collection: string, id: string, data: T, schema: dndevSchema<T>, options?: MutationOptions): Promise<Record<string, unknown>>;
210
+ update<T>(collection: string, id: string, data: Partial<T>, schema?: dndevSchema<T>, options?: MutationOptions): Promise<Record<string, unknown>>;
211
+ /** Logical delete (CRUD rule 3): the update `{ status: 'deleted' }`; `delete` is the hard delete. */
212
+ remove(collection: string, id: string): Promise<void>;
191
213
  delete(collection: string, id: string, options?: MutationOptions): Promise<void>;
192
214
  add<T extends Record<string, unknown>>(collection: string, data: CrudCreateInput<T>, schema: dndevSchema<T>, options?: MutationOptions): Promise<string>;
193
215
  /**
@@ -209,13 +231,13 @@ export interface CrudServiceInterface {
209
231
  update?: dndevSchema<T>;
210
232
  }, options?: MutationOptions): Promise<BulkResult>;
211
233
  /**
212
- * Cross-collection atomic bulk write. One optimistic pass, writes in
213
- * topological order, one toast, coordinated rollback.
234
+ * Cross-collection bulk write. Legacy execution is ordered but not atomic.
235
+ * Atomic execution requires an adapter capability and rejects without writing when unsupported.
214
236
  *
215
237
  * @throws {BulkCollisionError} Id collision within a single batch.
216
238
  * @throws {BulkAcrossCycleError} `dependsOn` contains a cycle.
217
239
  */
218
- bulkAcross(batches: BulkAcrossBatch[], options?: MutationOptions): Promise<BulkAcrossResult>;
240
+ bulkAcross(batches: BulkAcrossBatch[], options?: BulkAcrossOptions): Promise<BulkAcrossResult>;
219
241
  subscribe<T>(collection: string, id: string, callback: (data: T | null, error?: Error) => void, schema: dndevSchema<T>): () => void;
220
242
  subscribeToCollection<T>(collection: string, options: QueryOptions, callback: (data: T[], error?: Error) => void, schema: dndevSchema<T>): () => void;
221
243
  /** Add with optimistic update - shows item immediately, confirms/rolls back after server */
@@ -230,6 +252,16 @@ export interface CrudServiceInterface {
230
252
  deleteOptimistic(collection: string, id: string, options?: MutationOptions): Promise<void>;
231
253
  /** Invalidate all cached queries for a collection */
232
254
  invalidateCollection(collection: string): Promise<void>;
255
+ /**
256
+ * Cache a row stored by a write that did not go through this service (an app
257
+ * RPC, a server function): the document cache and every cached list holding it
258
+ * take the row as stored, without a refetch.
259
+ * @param row - The full row as the backend returned it, read-filtered for the requester
260
+ * @since 0.3.0
261
+ */
262
+ cacheStored<T extends {
263
+ id: string;
264
+ }>(collection: string, row: T): void;
233
265
  /** Get the shared QueryClient instance from @donotdev/core */
234
266
  getQueryClient(): QueryClient;
235
267
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAEX,uFAAuF;AACvF,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE,yCAAyC;AACzC,eAAO,MAAM,cAAc;;;IAGzB,0EA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, BulkResult, dndevSchema, FeatureStatus, InferEntityRow, OperationSchemas, CrudAPI, ScopeConfig } from '@donotdev/core';
1
+ import type { AnyEntity, BulkAcrossBatch, BulkAcrossOptions, BulkAcrossResult, BulkOperations, BulkResult, dndevSchema, FeatureStatus, InferEntityRow, OperationSchemas, CrudAPI, ScopeConfig } from '@donotdev/core';
2
2
  import type { CrudServiceInterface, CacheOptions, MutationOptions } from './types';
3
3
  export declare const EMPTY_DATA: Record<string, unknown>;
4
4
  export declare const EMPTY_OPTIMISTIC: Record<string, unknown>;
@@ -43,9 +43,11 @@ export interface UseCrudReturn<T extends Record<string, unknown>> extends CrudAP
43
43
  */
44
44
  bulk: (ops: BulkOperations<T>, options?: MutationOptions) => Promise<BulkResult>;
45
45
  /**
46
- * Cross-collection atomic bulk write. Does NOT require the hook's own entity
47
- * to be one of the collections. Each batch carries its own schemas.
48
- * One optimistic pass, writes in topological order, one toast, coordinated rollback.
46
+ * Ordered cross-collection bulk write, NOT a database transaction. Does NOT
47
+ * require the hook's own entity to be one of the collections. Each batch
48
+ * carries its own schemas. One optimistic pass, writes in topological waves.
49
+ * Failure stops subsequent waves after all started writes settle, reverts
50
+ * optimistic state, then refetches. Committed rows survive; the call rejects.
49
51
  *
50
52
  * @example
51
53
  * ```tsx
@@ -57,7 +59,7 @@ export interface UseCrudReturn<T extends Record<string, unknown>> extends CrudAP
57
59
  * ]);
58
60
  * ```
59
61
  */
60
- bulkAcross: (batches: BulkAcrossBatch[], options?: MutationOptions) => Promise<BulkAcrossResult>;
62
+ bulkAcross: (batches: BulkAcrossBatch[], options?: BulkAcrossOptions) => Promise<BulkAcrossResult>;
61
63
  /** @internal Collection name */
62
64
  _collection: string;
63
65
  /** @internal Generated schemas */
@@ -1 +1 @@
1
- {"version":3,"file":"useCrud.d.ts","sourceRoot":"","sources":["../src/useCrud.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,UAA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BG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,CAAC;AACtD,wBAAgB,OAAO,CAAC,CAAC,SAAS,SAAS,EACzC,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAC1C,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,wBAAgB,OAAO,CACrB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AACrE,wBAAgB,OAAO,CACrB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE3D,kBAAkB,EAAE,SAAS,GAAG,MAAM,EACtC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC1B,aAAa,CAAC,CAAC,CAAC,CAAC"}
package/dist/useCrud.js CHANGED
@@ -1 +1 @@
1
- "use client";import{useEffect as L,useMemo as w,useCallback as o}from"react";import{useFeatureConsent as W,FRAMEWORK_FEATURES as Z,FEATURE_STATUS as f,handleError as B,isClient as H,createSchemas as J,DEGRADED_CRUD_API as Q,getGlobalSingleton as V}from"@donotdev/core";import{getCrudService as F}from"./CrudService";import{useCrudStore as d}from"./CrudStore";import{injectScope as g,injectScopeFilter as X}from"./utils/scopeUtils";const $={},ee={};function M(){return V("crud-service",()=>({service:null,initPromise:null,errorNotified:!1}))}function n(){return C()}function C(){const u=M(),i=u.service??F();return i.attachProvider()?(u.service||(i.setStore(d),u.service=i),i):null}function te(u,i={}){const p=W(Z.CRUD),N=d(e=>e.crudService),y=p&&!N&&!C(),b=p?y?f.INITIALIZING:f.READY:f.DEGRADED,h=u==="status",v=!h&&typeof u=="object"?u:i.entity,r=h?"__status__":typeof u=="string"?u:u.collection,l=v?.scope,_=i.noCache??!1,A=i.staleTime,m=w(()=>({noCache:_,staleTime:A}),[_,A]),s=w(()=>{if(!h){if(i.schema){const e=i.schema;return{create:e,draft:e,update:e,get:e,list:e,listCard:e,delete:e}}if(v)return J(v)}},[h,i.schema,v?.name,r]),U=d(e=>e.collections[r]?.loading||!1),E=d(e=>e.collections[r]?.error||null);L(()=>{if(!H()||!p||!s)return;const{crudService:e}=d.getState(),a=C();if(a){e||d.getState().setCrudService(a);return}const t=M();e||t.service||t.initPromise||(t.initPromise=(async()=>{try{if(t.service||d.getState().crudService)return;const c=F();t.service=c,c.setStore(d),await c.initialize(),t.errorNotified=!1,d.getState().setCrudService(c)}catch(c){t.errorNotified||(B(c,{userMessage:"Failed to initialize CRUD service.",context:{collection:r},severity:"error"}),t.errorNotified=!0)}finally{t.initPromise=null}})())},[p,r,s?"hasSchema":"noSchema"]);const T=y||U,Y=b===f.READY,G=o(async e=>{const a=n();return!a||!s?null:a.get(r,e,s.get,m)},[r,s?"hasSchema":"noSchema",m]),O=o(async(e,a,t)=>{const c=n();if(!c||!s)return;const S=g(a,l),K=S?.status==="draft"?s.draft:s.create;await c.set(r,e,S,K,t)},[r,s?"hasSchema":"noSchema",l?.provider]),j=o(async(e,a,t)=>{const c=n();c&&await c.update(r,e,a,s?.update,t)},[r,s]),q=o(async(e,a)=>{const t=n();t&&await t.delete(r,e,a)},[r]),x=o(async(e,a)=>{const t=n();if(!t||!s)return"";const c=g(e,l),S=c?.status==="draft"?s.draft:s.create;return t.add(r,c,S,a)},[r,s?"hasSchema":"noSchema",l?.provider]),D=o(async(e,a)=>{const t=n();return t?t.bulkAcross(e,a):{results:{}}},[]),I=o(async(e,a)=>{const t=n();if(!t||!s)return{insertedIds:[],updatedIds:[],deletedIds:[],failed:[]};const c={inserts:e.inserts?.map(S=>g(S,l)),updates:e.updates,deletes:e.deletes};return t.bulk(r,c,{create:s.create,draft:s.draft,update:s.update},a)},[r,s?"hasSchema":"noSchema",l?.provider]),z=o(async e=>{const a=n();if(!a||!s)return[];const t=X(e,l);return(await a.query(r,t,s.get,m)).items},[r,s?"hasSchema":"noSchema",m,l?.provider]),R=o((e,a)=>{const t=n();return!t||!s?()=>{}:t.subscribe(r,e,a,s.get)},[r,s?"hasSchema":"noSchema"]),P=o((e,a)=>{const t=n();return!t||!s?()=>{}:t.subscribeToCollection(r,e,a,s.get)},[r,s?"hasSchema":"noSchema"]),k=o(async()=>{const e=n();e&&await e.invalidateCollection(r)},[r]);return h?b:Y?{status:f.READY,loading:T,error:E,get:G,set:O,update:j,delete:q,add:x,bulk:I,bulkAcross:D,query:z,subscribe:R,subscribeToCollection:P,invalidate:k,isAvailable:!0,_collection:r,_schemas:s,_cacheOptions:m,_scope:l}:{...Q,status:b,loading:T,error:E,subscribe:R,subscribeToCollection:P,invalidate:k,bulk:I,bulkAcross:D,_collection:r,_schemas:s,_cacheOptions:m,_scope:l}}export{$ as EMPTY_DATA,ee as EMPTY_OPTIMISTIC,n as getCrudServiceInstance,te as useCrud};
1
+ "use client";import{useEffect as L,useMemo as U,useCallback as n}from"react";import{useFeatureConsent as W,AtomicBulkError as Z,FRAMEWORK_FEATURES as H,FEATURE_STATUS as f,handleError as J,isClient as Q,createSchemas as V,DEGRADED_CRUD_API as X,getGlobalSingleton as $}from"@donotdev/core";import{getCrudService as F}from"./CrudService";import{useCrudStore as m}from"./CrudStore";import{injectScope as C,injectScopeFilter as ee}from"./utils/scopeUtils";const te={},re={};function M(){return $("crud-service",()=>({service:null,initPromise:null,errorNotified:!1}))}function i(){return y()}function y(){const u=M(),o=u.service??F();return o.attachProvider()?(u.service||(o.setStore(m),u.service=o),o):null}function se(u,o={}){const v=W(H.CRUD),N=m(e=>e.crudService),A=v&&!N&&!y(),b=v?A?f.INITIALIZING:f.READY:f.DEGRADED,S=u==="status",p=!S&&typeof u=="object"?u:o.entity,r=S?"__status__":typeof u=="string"?u:u.collection,l=p?.scope,_=o.noCache??!1,E=o.staleTime,h=U(()=>({noCache:_,staleTime:E}),[_,E]),a=U(()=>{if(!S){if(o.schema){const e=o.schema;return{create:e,draft:e,update:e,get:e,list:e,listCard:e,delete:e}}if(p)return V(p)}},[S,o.schema,p?.name,r]),Y=m(e=>e.collections[r]?.loading||!1),T=m(e=>e.collections[r]?.error||null);L(()=>{if(!Q()||!v||!a)return;const{crudService:e}=m.getState(),s=y();if(s){e||m.getState().setCrudService(s);return}const t=M();e||t.service||t.initPromise||(t.initPromise=(async()=>{try{if(t.service||m.getState().crudService)return;const c=F();t.service=c,c.setStore(m),await c.initialize(),t.errorNotified=!1,m.getState().setCrudService(c)}catch(c){t.errorNotified||(J(c,{userMessage:"Failed to initialize CRUD service.",context:{collection:r},severity:"error"}),t.errorNotified=!0)}finally{t.initPromise=null}})())},[v,r,a?"hasSchema":"noSchema"]);const D=A||Y,G=b===f.READY,O=n(async e=>{const s=i();return!s||!a?null:s.get(r,e,a.get,h)},[r,a?"hasSchema":"noSchema",h]),d=a,j=n(async(e,s,t)=>{const c=i();if(!c||!d)return;const g=C(s,l);return c.set(r,e,g,d.create,{...t,readSchema:d.get})},[r,a?"hasSchema":"noSchema",l?.provider]),x=n(async(e,s,t)=>{const c=i();if(!(!c||!d))return c.update(r,e,s,d.update,{...t,readSchema:d.get})},[r,a]),q=n(async e=>{const s=i();!s||!d||await s.remove(r,e)},[r,a]),z=n(async(e,s)=>{const t=i();t&&await t.delete(r,e,s)},[r]),B=n(async(e,s)=>{const t=i();if(!t||!d)return"";const c=C(e,l);return t.add(r,c,d.create,{...s,readSchema:d.get})},[r,a?"hasSchema":"noSchema",l?.provider]),I=n(async(e,s)=>{const t=i();if(!t){if(s?.execution==="atomic")throw new Z("CRUD service is unavailable","not-committed");return{results:{}}}return t.bulkAcross(e,s)},[]),R=n(async(e,s)=>{const t=i();if(!t||!a)return{insertedIds:[],updatedIds:[],deletedIds:[],failed:[]};const c={inserts:e.inserts?.map(g=>C(g,l)),updates:e.updates,deletes:e.deletes};return t.bulk(r,c,{create:a.create,draft:a.draft,update:a.update},s)},[r,a?"hasSchema":"noSchema",l?.provider]),K=n(async e=>{const s=i();if(!s||!a)return[];const t=ee(e,l);return(await s.query(r,t,a.get,h)).items},[r,a?"hasSchema":"noSchema",h,l?.provider]),P=n((e,s)=>{const t=i();return!t||!a?()=>{}:t.subscribe(r,e,s,a.get)},[r,a?"hasSchema":"noSchema"]),k=n((e,s)=>{const t=i();return!t||!a?()=>{}:t.subscribeToCollection(r,e,s,a.get)},[r,a?"hasSchema":"noSchema"]),w=n(async()=>{const e=i();e&&await e.invalidateCollection(r)},[r]);return S?b:G?{status:f.READY,loading:D,error:T,get:O,set:j,update:x,remove:q,delete:z,add:B,bulk:R,bulkAcross:I,query:K,subscribe:P,subscribeToCollection:k,invalidate:w,isAvailable:!0,_collection:r,_schemas:a,_cacheOptions:h,_scope:l}:{...X,status:b,loading:D,error:T,subscribe:P,subscribeToCollection:k,invalidate:w,bulk:R,bulkAcross:I,_collection:r,_schemas:a,_cacheOptions:h,_scope:l}}export{te as EMPTY_DATA,re as EMPTY_OPTIMISTIC,i as getCrudServiceInstance,se as useCrud};
@@ -1 +1 @@
1
- import{useCallback as R,useMemo as q}from"react";import{FEATURE_STATUS as A,isClient as w,useQuery as E,useQueryClient as L}from"@donotdev/core";import{cachedListRow as O}from"./CrudService.cache";import{useCrudStore as Q}from"./CrudStore";import{useCrud as T,getCrudServiceInstance as U}from"./useCrud";import{useServerPrefetch as K}from"./useServerPrefetch";import{applyOptimisticToDoc as N}from"./utils/mergeWithOptimistic";import{useRowTranslator as P}from"./utils/useRowTranslator";function k(u,t,r={}){const a=r.enabled??!0,s=T("status"),c=s===A.READY,{_collection:o,_schemas:d,_cacheOptions:C,_scope:D}=T(u,r),m=Q(_=>t?_.collections[o]?.optimistic[t]:void 0),p=c?U():null,e=p&&d&&t?p.getDocQueryOptions(o,t,d.get,C):null,F=L(),l=e&&t?O(F,o,t):void 0,{data:i,isLoading:I,isFetching:b,error:S,refetch:f}=E({queryKey:e?.queryKey??["crud",o,"get",null],queryFn:e?.queryFn??(()=>Promise.resolve(null)),staleTime:e?.staleTime,...l&&{initialData:l.data,initialDataUpdatedAt:l.updatedAt},enabled:a&&!!e});K(e,a,D);const y=P(u,r),g=q(()=>y(N(i??null,m)),[y,i,m]),n=!w(),h=!!e,v=R(async()=>{h&&await f()},[f,h]);return c?{status:s,data:g,loading:n?a&&!!e&&i===void 0:I,fetching:n?!1:b,notFound:i!==void 0&&g===null,error:n?null:S,refresh:v,isAvailable:!0}:{status:s,data:null,loading:s===A.INITIALIZING&&a&&!!t,fetching:!1,notFound:!1,error:null,refresh:v,isAvailable:!1}}export{k as useCrudDoc};
1
+ import{useCallback as R,useMemo as q}from"react";import{FEATURE_STATUS as A,isClient as w,useQuery as E,useQueryClient as L}from"@donotdev/core";import{cachedListRow as O}from"./CrudService.cache";import{useCrudStore as Q}from"./CrudStore";import{useCrud as T,getCrudServiceInstance as U}from"./useCrud";import{useServerPrefetch as K}from"./useServerPrefetch";import{applyOptimisticToDoc as N}from"./utils/mergeWithOptimistic";import{useRowTranslator as P}from"./utils/useRowTranslator";function k(u,t,i={}){const r=i.enabled??!0,s=T("status"),c=s===A.READY,{_collection:o,_schemas:d,_cacheOptions:C,_scope:D}=T(u,i),m=Q(_=>t?_.collections[o]?.optimistic[t]:void 0),p=c?U():null,e=p&&d&&t?p.getDocQueryOptions(o,t,d.get,C):null,F=L(),l=e&&t?O(F,o,t):void 0,{data:a,isLoading:I,isFetching:b,error:S,refetch:f}=E({queryKey:e?.queryKey??["crud",o,"get",null],queryFn:e?.queryFn??(()=>Promise.resolve(null)),staleTime:e?.staleTime,...l&&{initialData:l.data,initialDataUpdatedAt:l.updatedAt},enabled:r&&!!e});K(e,r,D);const y=P(u,i),g=q(()=>y(N(a??null,m)),[y,a,m]),n=!w(),h=!!e,v=R(async()=>{h&&await f()},[f,h]);return c?{status:s,data:g,loading:n?r&&!!e&&a===void 0:I,fetching:n?!1:b,notFound:a!==void 0&&g===null,error:n?null:S,refresh:v,isAvailable:!0}:{status:s,data:null,loading:s===A.INITIALIZING&&r&&!!t,fetching:!1,notFound:!1,error:null,refresh:v,isAvailable:!1}}export{k as useCrudDoc};
@@ -1,12 +1,3 @@
1
- /**
2
- * @fileoverview Client-side list processing utilities
3
- * @description Pure functions for filtering, searching, and sorting entity items.
4
- * Used by useCrudList/useCrudCardList hooks and UI components.
5
- *
6
- * @version 0.1.0
7
- * @since 0.0.1
8
- * @author AMBROISE PARK Consulting
9
- */
10
1
  import type { AnyEntity } from '@donotdev/core';
11
2
  import type { FilterState } from '../types';
12
3
  /**
@@ -37,8 +28,9 @@ export interface ClientSortConfig {
37
28
  */
38
29
  export type ClientSort<T = Record<string, unknown>> = ClientSortConfig | ((a: T, b: T) => number);
39
30
  /**
40
- * Apply filter state to items using entity field type metadata.
41
- * Typically called automatically by `useCrudList`/`useCrudCardList` via `processed`.
31
+ * Apply filter state to items using entity field type metadata: every filter must
32
+ * match ({@link matchesFilter} semantics per field type; the field's `filter.wildcard`
33
+ * applies). Typically called automatically by `useCrudList`/`useCrudCardList` via `processed`.
42
34
  * Export available for advanced use cases (e.g. filtering outside React).
43
35
  *
44
36
  * @param items - Raw items array
@@ -55,10 +47,15 @@ export type ClientSort<T = Record<string, unknown>> = ClientSortConfig | ((a: T,
55
47
  export declare function applyFilters<T extends Record<string, any>>(items: T[], filters: FilterState, entity: AnyEntity): T[];
56
48
  /**
57
49
  * Returns the list of searchable field names for an entity.
58
- * Uses entity.search.fields if defined, otherwise auto-detects text-like visible fields.
50
+ * Uses entity.search.fields if defined, otherwise auto-detects the visible fields
51
+ * whose stored value is text (descriptor `value.kind === 'text'`, custom types
52
+ * with a string `validation.schema` included; references are ids, not searched).
59
53
  *
60
54
  * @param entity - Entity definition
61
55
  * @returns Array of field names to search
56
+ *
57
+ * @version 0.2.0
58
+ * @since 0.0.1
62
59
  */
63
60
  export declare function getSearchableFields(entity: AnyEntity): string[];
64
61
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"clientListProcessing.d.ts","sourceRoot":"","sources":["../../src/utils/clientListProcessing.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC9C,gBAAgB,GAChB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC;AAE7B;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxD,KAAK,EAAE,CAAC,EAAE,EACV,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,SAAS,GAChB,CAAC,EAAE,CAWL;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,EAAE,CAyB/D;AAED;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACvD,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAS,GAChB,CAAC,EAAE,CA+BL;AAED;;;;;;;;;;;;;;;;;;GAkBG;AAEH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrD,KAAK,EAAE,CAAC,EAAE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CAAC,EAAE,EACV,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAClB,CAAC,EAAE,CAwCL"}
@@ -1 +1 @@
1
- import{matchesFilter as u}from"./matchesFilter";import{getValueType as f}from"../fieldTypeRegistry.store";function d(t,i,l){const o=Object.entries(i);return o.length===0?t:t.filter(n=>o.every(([r,c])=>{const e=l.fields[r]?.type||"text";return u(n[r],c,e)}))}function a(t){if(t.search?.fields&&t.search.fields.length>0)return t.search.fields;const i=new Set(["string"]),l=[];for(const[o,n]of Object.entries(t.fields)){if(n.visibility==="hidden"||n.visibility==="technical")continue;const r=f(n.type);r&&i.has(r)&&l.push(o)}return l}function p(t,i,l){if(!i||i.trim()==="")return t;const o=i.toLowerCase(),n=a(l);return n.length===0?t.filter(r=>Object.values(r).some(c=>c==null?!1:String(c).toLowerCase().includes(o))):t.filter(r=>n.some(c=>{const e=r[c];return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(o):String(e).toLowerCase().includes(o)}))}function m(t,i){if(typeof i=="function")return[...t].sort(i);const{field:l,direction:o="asc"}=i,n=o==="desc"?-1:1;return[...t].sort((r,c)=>{const e=r[l],s=c[l];return e==null&&s==null?0:e==null?1:s==null?-1:typeof e=="number"&&typeof s=="number"?(e-s)*n:typeof e=="object"&&"amount"in e&&typeof s=="object"&&"amount"in s?(e.amount-s.amount)*n:e instanceof Date&&s instanceof Date?(e.getTime()-s.getTime())*n:String(e).localeCompare(String(s))*n})}export{d as applyFilters,p as applySearch,m as applySort,a as getSearchableFields};
1
+ import{describeEntity as u}from"@donotdev/core";import{matchesFilter as f}from"./matchesFilter";import"../fieldTypeRegistry.store";function d(t,n,s){const o=Object.entries(n);return o.length===0?t:t.filter(r=>o.every(([l,c])=>{const e=s.fields[l],i=e?.type||"text";return f(r[l],c,i,e?.filter)}))}function a(t){if(t.search?.fields&&t.search.fields.length>0)return t.search.fields;const n=[],{fields:s}=u(t);for(const[o,r]of Object.entries(s))r.visibleAt==="hidden"||r.visibleAt==="technical"||r.value.kind==="text"&&n.push(o);return n}function m(t,n,s){if(!n||n.trim()==="")return t;const o=n.toLowerCase(),r=a(s);return r.length===0?t.filter(l=>Object.values(l).some(c=>c==null?!1:String(c).toLowerCase().includes(o))):t.filter(l=>r.some(c=>{const e=l[c];return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(o):String(e).toLowerCase().includes(o)}))}function p(t,n){if(typeof n=="function")return[...t].sort(n);const{field:s,direction:o="asc"}=n,r=o==="desc"?-1:1;return[...t].sort((l,c)=>{const e=l[s],i=c[s];return e==null&&i==null?0:e==null?1:i==null?-1:typeof e=="number"&&typeof i=="number"?(e-i)*r:typeof e=="object"&&"amount"in e&&typeof i=="object"&&"amount"in i?(e.amount-i.amount)*r:e instanceof Date&&i instanceof Date?(e.getTime()-i.getTime())*r:String(e).localeCompare(String(i))*r})}export{d as applyFilters,m as applySearch,p as applySort,a as getSearchableFields};
@@ -1 +1 @@
1
- {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/utils/collections.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAInE;;;;;;GAMG;AACH,MAAM,WAAW,gCAAgC,CAAC,CAAC;IACjD,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1E,IAAI,EAAE,CAAC,MAAM,E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CAAA;KAAE,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1E,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACjC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;CAC/C;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,gCAAgC,CAAC,CAAC,CAAC,GAC1C,OAAO,CAAC,CAAC,EAAE,CAAC,CAWd;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,gCAAgC,CAAC,CAAC,CAAC,EAC3C,IAAI,EAAE,CAAC,EAAE,GACR,OAAO,CAAC,IAAI,CAAC,CAMf;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,yBAAyB,CAAC,CAAC,CAAC,EACpC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB"}
@@ -1 +1 @@
1
- import{getCrudService as i}from"../CrudService";async function p(a,t){const e=i(),s=[],o=t.range?.start??1,c=t.range?.end??28;for(let r=o;r<=c;r++){const m=String(r),n=await e.get(t.path(a),m,t.schema);n&&s.push(n)}return s}async function d(a,t,e){const s=i();for(const o of e){const c=t.idOf(o);await s.set(t.path(a),c,o,t.schema)}}async function h(a,t,e){const s=i();if(t.idFrom){const o=t.idFrom(e);return s.set(t.path(a),o,e,t.schema)}return s.add(t.path(a),e,t.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
1
+ import{getCrudService as i}from"../CrudService";async function p(o,t){const a=i(),e=[],s=t.range?.start??1,r=t.range?.end??28;for(let c=s;c<=r;c++){const m=String(c),n=await a.get(t.path(o),m,t.schema);n&&e.push(n)}return e}async function d(o,t,a){const e=i();for(const s of a){const r=t.idOf(s);await e.set(t.path(o),r,s,t.schema)}}async function h(o,t,a){const e=i();if(t.idFrom){const s=t.idFrom(a);await e.set(t.path(o),s,a,t.schema);return}return e.add(t.path(o),a,t.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @fileoverview Filter state ↔ URL search params
3
+ * @description Pure encoding of a filter state (`FilterState`) as `f_*` search params,
4
+ * decided by the entity's field types. Used by CrudStore URL sync. No `location` access.
5
+ *
6
+ * Format (one param per value, standard percent-encoding, commas safe):
7
+ * - range fields (number, price, date, year...): `f_<field>_min`, `f_<field>_max`
8
+ * - option fields (select, radio, multiselect, reference: filter types `select`,
9
+ * `multiselect`, `reference`): `f_<field>` repeated, always decoded as an array
10
+ * - other fields (text, rating...): `f_<field>`; repeated → array, single → string
11
+ *
12
+ * @version 0.1.0
13
+ * @since 0.3.0
14
+ * @author AMBROISE PARK Consulting
15
+ */
16
+ import type { AnyEntity } from '@donotdev/core';
17
+ import type { FilterState } from '../types';
18
+ /** Prefix of filter search params */
19
+ export declare const FILTER_PARAM_PREFIX = "f_";
20
+ /**
21
+ * Write `filters` into `params`: removes the entity's `f_*` params, then writes the
22
+ * filters of the entity's fields. Params of other fields and non-filter params stay.
23
+ *
24
+ * @param params - Search params to update in place
25
+ * @param filters - Filter state
26
+ * @param entity - Entity whose field types decide the encoding
27
+ */
28
+ export declare function writeFilterParams(params: URLSearchParams, filters: FilterState, entity: AnyEntity): void;
29
+ /**
30
+ * Read the filter state of `entity`'s fields from a search string.
31
+ *
32
+ * @param search - `location.search` (with or without `?`)
33
+ * @param entity - Entity whose field types decide the decoding
34
+ * @returns The filter state (fields without params are absent)
35
+ */
36
+ export declare function readFilterParams(search: string, entity: AnyEntity): FilterState;
37
+ /**
38
+ * Canonical encoding of a filter state (sorted params): two states that encode the
39
+ * same are the same URL.
40
+ *
41
+ * @param filters - Filter state
42
+ * @param entity - Entity whose field types decide the encoding
43
+ */
44
+ export declare function encodeFilterParams(filters: FilterState, entity: AnyEntity): string;
45
+ //# sourceMappingURL=filterUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterUrl.d.ts","sourceRoot":"","sources":["../../src/utils/filterUrl.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAK5C,qCAAqC;AACrC,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAgBxC;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,SAAS,GAChB,IAAI,CAiBN;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,GAChB,WAAW,CA8Bb;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,SAAS,GAChB,MAAM,CAKR"}
@@ -0,0 +1 @@
1
+ import{getFilterType as g}from"../fieldTypeRegistry.store";const d=new Set(["select","multiselect","reference"]),c="f_";function m(t,i){const e=t.fields[i];return e?g(e.type):void 0}function h(t,i){if(!t.startsWith(c))return!1;const e=t.slice(c.length);if(e in i.fields)return m(i,e)!=="range";const r=/^(.+)_(min|max)$/.exec(e);return!!r&&m(i,r[1])==="range"}function u(t,i,e){[...new Set(t.keys())].filter(r=>h(r,e)).forEach(r=>t.delete(r));for(const[r,n]of Object.entries(i)){if(!(r in e.fields))continue;const s=`${c}${r}`;typeof n=="string"?n!==""&&t.append(s,n):Array.isArray(n)?n.forEach(a=>t.append(s,a)):(n.min&&t.set(`${s}_min`,n.min),n.max&&t.set(`${s}_max`,n.max))}}function p(t,i){const e=new URLSearchParams(t),r={};for(const n of Object.keys(i.fields)){const s=`${c}${n}`,a=m(i,n);if(a==="range"){const o=e.get(`${s}_min`),l=e.get(`${s}_max`);(o||l)&&(r[n]={...o?{min:o}:{},...l?{max:l}:{}});continue}const f=e.getAll(s).filter(o=>o!=="");f.length!==0&&(r[n]=a!==void 0&&d.has(a)||f.length>1?f:f[0])}return r}function _(t,i){const e=new URLSearchParams;return u(e,t,i),e.sort(),e.toString()}export{c as FILTER_PARAM_PREFIX,_ as encodeFilterParams,p as readFilterParams,u as writeFilterParams};
@@ -1,8 +1,28 @@
1
+ /**
2
+ * @fileoverview Standalone filter matching utility
3
+ * @description Pure function to check if an item value matches a filter value.
4
+ * Extracted from EntityFilters.tsx for reuse in hooks and non-React contexts.
5
+ *
6
+ * @version 0.1.0
7
+ * @since 0.0.1
8
+ * @author AMBROISE PARK Consulting
9
+ */
10
+ import type { FieldFilterConfig } from '@donotdev/core';
1
11
  /**
2
12
  * Pure filter matching utility — checks if an item value matches a filter value.
3
13
  *
4
- * Supports all built-in field types: text (contains), number/price (range),
5
- * date/datetime (range), select (exact), multiselect (contains), address (formatted_address).
14
+ * Matching by the field type's filter type (`getFilterType`):
15
+ * - `text`: case-insensitive substring; `address`: substring of `formatted_address`
16
+ * - `select`, `multiselect`, `reference` (option codes, ids): exact, case-sensitive
17
+ * equality. An array item value (multiselect) matches when any of its items is
18
+ * selected; an array filter value selects any of its values (any-of). A value
19
+ * holding `filter.wildcard` matches any selection.
20
+ * - `range` (number, price amount, date): min/max; `rating`: minimum
21
+ *
22
+ * Null/undefined handling for range filters:
23
+ * - MIN only → exclude null/undefined
24
+ * - MAX only → include null/undefined
25
+ * - MIN + MAX → exclude null/undefined
6
26
  *
7
27
  * Null/undefined handling for range filters:
8
28
  * - MIN only → exclude null/undefined
@@ -12,6 +32,7 @@
12
32
  * @param itemValue - The item's field value to test
13
33
  * @param filterValue - The filter criterion (string, range, date, array)
14
34
  * @param fieldType - Entity field type (e.g. 'text', 'number', 'date', 'price')
35
+ * @param filterConfig - The field's `filter` config (`wildcard`); `applyFilters` passes it
15
36
  * @returns true if item passes the filter
16
37
  *
17
38
  * @example
@@ -21,6 +42,9 @@
21
42
  * matchesFilter('hello world', 'hello', 'text'); // true (contains)
22
43
  * matchesFilter(42, { min: '10', max: '50' }, 'number'); // true (in range)
23
44
  * matchesFilter(null, { min: '10' }, 'number'); // false (null excluded)
45
+ * matchesFilter('toner_pad', 'toner', 'select'); // false (exact)
46
+ * matchesFilter(['dry', 'oily'], ['oily', 'normal'], 'multiselect'); // true (any-of)
47
+ * matchesFilter(['all'], 'dry', 'multiselect', { wildcard: 'all' }); // true
24
48
  * ```
25
49
  */
26
50
  export declare function matchesFilter(itemValue: any, filterValue: string | {
@@ -41,5 +65,5 @@ export declare function matchesFilter(itemValue: any, filterValue: string | {
41
65
  } | {
42
66
  date: string;
43
67
  time?: string;
44
- }[], fieldType: string): boolean;
68
+ }[], fieldType: string, filterConfig?: FieldFilterConfig): boolean;
45
69
  //# sourceMappingURL=matchesFilter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matchesFilter.d.ts","sourceRoot":"","sources":["../../src/utils/matchesFilter.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAE3B,SAAS,EAAE,GAAG,EAEd,WAAW,EACP,MAAM,GACN;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9B,MAAM,EAAE,GACR;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B;IACE,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC,GACD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EAErC,SAAS,EAAE,MAAM,GAChB,OAAO,CA0VT"}
1
+ {"version":3,"file":"matchesFilter.d.ts","sourceRoot":"","sources":["../../src/utils/matchesFilter.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA0BxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,aAAa,CAE3B,SAAS,EAAE,GAAG,EAEd,WAAW,EACP,MAAM,GACN;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9B,MAAM,EAAE,GACR;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B;IACE,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC,GACD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EAErC,SAAS,EAAE,MAAM,EAEjB,YAAY,CAAC,EAAE,iBAAiB,GAC/B,OAAO,CAuVT"}
@@ -1 +1 @@
1
- import{getFilterType as N}from"../fieldTypeRegistry.store";function S(t,n,e){if(!n)return!0;if(Array.isArray(n)){if(n.length===0)return!0;if(!(N(e)==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp")))return n.some(a=>{if(typeof a=="object"&&"date"in a){const D=a.date;if(t==null)return!1;const m=t instanceof Date?t:new Date(t);return isNaN(m.getTime())?!1:m.toISOString().split("T")[0]===D}return String(t)===String(a)});if(t==null)return!1;const i=t instanceof Date?t:new Date(t);if(isNaN(i.getTime()))return!1;const o=i.toISOString().split("T")[0];return n.some(a=>typeof a=="string"?o===a:typeof a=="object"&&"date"in a?o===a.date:!1)}if(typeof n=="object"&&"date"in n&&!("min"in n)&&!Array.isArray(n)){if(!(N(e)==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp")))return!1;const i=n.date;if(!i)return!0;if(t==null)return!1;const o=t instanceof Date?t.toISOString().split("T")[0]:new Date(t).toISOString().split("T")[0];if((e==="datetime-local"||e==="timestamp")&&n.time){const a=t instanceof Date?t.toISOString().slice(11,16):new Date(t).toISOString().slice(11,16);return o===i&&a===n.time}return o===i}if(typeof n=="object"&&"min"in n){const i=N(e);if(!i)return!0;const o=i==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp"),a=i==="range"&&!o,D=e==="price",m=D&&t!=null&&typeof t=="object"?Number(t.amount):a&&t!=null?typeof t=="number"?t:Number(t):NaN;if(a||D){if(typeof n.min=="object"&&n.min!==null&&"date"in n.min)return!1;const r=n,c=typeof r.min=="string"&&r.min!=="",g=typeof r.max=="string"&&r.max!=="";return c&&!g?t==null||isNaN(m)?!1:m>=Number(r.min):!c&&g?t==null?!0:isNaN(m)?!1:m<=Number(r.max):c&&g?t==null||isNaN(m)?!1:m>=Number(r.min)&&m<=Number(r.max):!0}if(o){if(typeof n.min=="object"&&n.min!==null&&"date"in n.min&&!("min"in n.min)){const s=n,l=s.min,u=s.max,w=l?.date&&l.date!=="",y=u?.date&&u.date!=="";if(w&&!y){if(t==null)return!1;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const d=new Date(l.date+(l.time?`T${l.time}:00`:"T00:00:00"));return f>=d}if(!w&&y&&u){if(t==null)return!0;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const d=new Date(u.date+(u.time?`T${u.time}:00`:"T23:59:59"));return f<=d}if(w&&y&&u){if(t==null)return!1;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const d=new Date(l.date+(l.time?`T${l.time}:00`:"T00:00:00")),T=new Date(u.date+(u.time?`T${u.time}:00`:"T23:59:59"));return f>=d&&f<=T}return!0}const r=n,c=typeof r.min=="string"&&r.min!=="",g=typeof r.max=="string"&&r.max!=="";if(c&&!g){if(t==null)return!1;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s>=new Date(r.min)}if(!c&&g){if(t==null)return!0;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s<=new Date(r.max)}if(c&&g){if(t==null)return!1;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s>=new Date(r.min)&&s<=new Date(r.max)}return!0}}if(typeof n=="string"&&N(e)==="rating"){if(t==null)return!1;const i=Number(n),o=typeof t=="number"?t:Number(t);return isNaN(i)||isNaN(o)?!1:o>=i}const p=N(e);if(!p)return!0;if(p==="address")return t==null?!1:typeof t=="object"&&"formatted_address"in t?String(t.formatted_address).toLowerCase().includes(String(n).toLowerCase()):!1;if(p==="multiselect"){if(!Array.isArray(t)||t.length===0)return!1;const i=String(n).toLowerCase();return t.some(o=>String(o).toLowerCase().includes(i))}return t==null?!1:String(t).toLowerCase().includes(String(n).toLowerCase())}export{S as matchesFilter};
1
+ import{getFilterType as D}from"../fieldTypeRegistry.store";const b=new Set(["select","multiselect","reference"]);function x(t,n,e){if(t==null)return!1;const w=(Array.isArray(t)?t:[t]).map(String);if(e!==void 0&&w.includes(e))return!0;const y=new Set(n.map(String));return w.some(N=>y.has(N))}function I(t,n,e,w){if(!n)return!0;const y=w?.wildcard;if(Array.isArray(n)){if(n.length===0)return!0;const r=D(e);if(!(r==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp")))return r&&b.has(r)?x(t,n,y):n.some(a=>{if(typeof a=="object"&&"date"in a){const u=a.date;if(t==null)return!1;const i=t instanceof Date?t:new Date(t);return isNaN(i.getTime())?!1:i.toISOString().split("T")[0]===u}return String(t)===String(a)});if(t==null)return!1;const o=t instanceof Date?t:new Date(t);if(isNaN(o.getTime()))return!1;const c=o.toISOString().split("T")[0];return n.some(a=>typeof a=="string"?c===a:typeof a=="object"&&"date"in a?c===a.date:!1)}if(typeof n=="object"&&"date"in n&&!("min"in n)&&!Array.isArray(n)){if(!(D(e)==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp")))return!1;const r=n.date;if(!r)return!0;if(t==null)return!1;const o=t instanceof Date?t.toISOString().split("T")[0]:new Date(t).toISOString().split("T")[0];if((e==="datetime-local"||e==="timestamp")&&n.time){const c=t instanceof Date?t.toISOString().slice(11,16):new Date(t).toISOString().slice(11,16);return o===r&&c===n.time}return o===r}if(typeof n=="object"&&"min"in n){const r=D(e);if(!r)return!0;const o=r==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp"),c=r==="range"&&!o,a=e==="price",u=a&&t!=null&&typeof t=="object"?Number(t.amount):c&&t!=null?typeof t=="number"?t:Number(t):NaN;if(c||a){if(typeof n.min=="object"&&n.min!==null&&"date"in n.min)return!1;const i=n,d=typeof i.min=="string"&&i.min!=="",g=typeof i.max=="string"&&i.max!=="";return d&&!g?t==null||isNaN(u)?!1:u>=Number(i.min):!d&&g?t==null?!0:isNaN(u)?!1:u<=Number(i.max):d&&g?t==null||isNaN(u)?!1:u>=Number(i.min)&&u<=Number(i.max):!0}if(o){if(typeof n.min=="object"&&n.min!==null&&"date"in n.min&&!("min"in n.min)){const s=n,l=s.min,m=s.max,S=l?.date&&l.date!=="",T=m?.date&&m.date!=="";if(S&&!T){if(t==null)return!1;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const p=new Date(l.date+(l.time?`T${l.time}:00`:"T00:00:00"));return f>=p}if(!S&&T&&m){if(t==null)return!0;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const p=new Date(m.date+(m.time?`T${m.time}:00`:"T23:59:59"));return f<=p}if(S&&T&&m){if(t==null)return!1;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const p=new Date(l.date+(l.time?`T${l.time}:00`:"T00:00:00")),j=new Date(m.date+(m.time?`T${m.time}:00`:"T23:59:59"));return f>=p&&f<=j}return!0}const i=n,d=typeof i.min=="string"&&i.min!=="",g=typeof i.max=="string"&&i.max!=="";if(d&&!g){if(t==null)return!1;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s>=new Date(i.min)}if(!d&&g){if(t==null)return!0;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s<=new Date(i.max)}if(d&&g){if(t==null)return!1;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s>=new Date(i.min)&&s<=new Date(i.max)}return!0}}if(typeof n=="string"&&D(e)==="rating"){if(t==null)return!1;const r=Number(n),o=typeof t=="number"?t:Number(t);return isNaN(r)||isNaN(o)?!1:o>=r}const N=D(e);return N?N==="address"?t==null?!1:typeof t=="object"&&"formatted_address"in t?String(t.formatted_address).toLowerCase().includes(String(n).toLowerCase()):!1:b.has(N)?x(t,[n],y):t==null?!1:String(t).toLowerCase().includes(String(n).toLowerCase()):!0}export{I as matchesFilter};
@@ -1 +1 @@
1
- "use client";function o(r){return!r||typeof r!="string"?!1:r.startsWith("https://")&&!r.startsWith("blob:")}function h(r){return!(!r||typeof r!="object"||!o(r.fullUrl)||r.thumbUrl&&!o(r.thumbUrl))}function i(r,l=""){const t=[];if(r==null)return t;if(typeof r=="string")return r.startsWith("blob:")&&t.push(l||"root"),t;if(typeof r!="object")return t;if(Array.isArray(r))r.forEach((e,s)=>{const n=l?`${l}[${s}]`:`[${s}]`;t.push(...i(e,n))});else{const e=r;if(e.fullUrl!==void 0&&e.thumbUrl!==void 0){const s=e.fullUrl,n=e.thumbUrl,u=typeof s=="string"&&!o(s),c=n&&typeof n=="string"&&!o(n);if(u||c){const f=l||"root";t.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(e).forEach(([s,n])=>{const u=l?`${l}.${s}`:s;t.push(...i(n,u))})}return t}function b(r){return i(r).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,o as isStorageUrl,h as validatePicture};
1
+ "use client";function u(r){return!r||typeof r!="string"?!1:r.startsWith("https://")&&!r.startsWith("blob:")}function h(r){return!(!r||typeof r!="object"||!u(r.fullUrl)||r.thumbUrl&&!u(r.thumbUrl))}function i(r,l=""){const t=[];if(r==null)return t;if(typeof r=="string")return r.startsWith("blob:")&&t.push(l||"root"),t;if(typeof r!="object")return t;if(Array.isArray(r))r.forEach((s,o)=>{const n=l?`${l}[${o}]`:`[${o}]`;t.push(...i(s,n))});else{const s=r;if(s.fullUrl!==void 0&&s.thumbUrl!==void 0){const o=s.fullUrl,n=s.thumbUrl,e=typeof o=="string"&&!u(o),c=n&&typeof n=="string"&&!u(n);if(e||c){const f=l||"root";t.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(s).forEach(([o,n])=>{const e=l?`${l}.${o}`:o;t.push(...i(n,e))})}return t}function b(r){return i(r).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,u as isStorageUrl,h as validatePicture};
@@ -1 +1 @@
1
- import{useCallback as u,useMemo as f}from"react";import{getTranslatedFieldNames as m,translateRow as c,useTranslation as g}from"@donotdev/core";const p=a=>a;function d(a,o){const{language:n}=g(),r=o.translate??!0,s=(typeof a=="string"?o.entity:a)?.fields??null,t=f(()=>s?m(s):[],[s]),l=r&&t.length>0,i=u(e=>e&&typeof e=="object"?c(e,t,n):e,[t,n]);return l?i:p}export{d as useRowTranslator};
1
+ import{useCallback as u,useMemo as f}from"react";import{getTranslatedFieldNames as m,translateRow as c,useTranslation as g}from"@donotdev/core";const p=e=>e;function d(e,o){const{language:n}=g(),r=o.translate??!0,a=(typeof e=="string"?o.entity:e)?.fields??null,t=f(()=>a?m(a):[],[a]),l=r&&t.length>0,i=u(s=>s&&typeof s=="object"?c(s,t,n):s,[t,n]);return l?i:p}export{d as useRowTranslator};
@@ -36,12 +36,26 @@ Card-based list with infinite scroll.
36
36
  const { items, loading, refresh } = useCrudCardList(articleEntity);
37
37
  ```
38
38
 
39
+ ### EntityFilters / useCrudFilters
40
+ Filter panel for an entity: option fields (select, radio, multiselect, reference) are multi-select with exact matching, text fields substring, numbers/dates ranges. The lists of the collection apply the same state; it syncs with the URL (`?f_type=serum&f_type=essence`).
41
+
42
+ ```tsx
43
+ <EntityFilters entity={productEntity} data={rows} fieldsToFilter={['type', 'skinTypes', 'brandId']} />
44
+ const { items } = useCrudCardList(productEntity); // filtered by that state
45
+
46
+ // Picker: own state, not in the URL
47
+ <EntityFilters entity={productEntity} filterKey="products#picker" />
48
+ const { filters } = useCrudFilters({ collection: 'products#picker' });
49
+ ```
50
+
51
+ Matching per field type, `filter.wildcard`, URL format and opt-in/out: CRUD.md "Filters".
52
+
39
53
  ---
40
54
 
41
55
  ## Form Components
42
56
 
43
57
  ### EntityFormRenderer
44
- Auto-render full entity form from definition.
58
+ Auto-render full entity form from definition. Import from `@donotdev/ui`; it supplies the entity translator and viewer role automatically.
45
59
 
46
60
  ```tsx
47
61
  <EntityFormRenderer
@@ -51,11 +65,24 @@ Auto-render full entity form from definition.
51
65
  />
52
66
  ```
53
67
 
68
+ `onSubmit` is optional: without it the default writer saves the record (update, or add on create) plus the child rows joined to the form (nested `EntityList` on this record) in one `bulkAcross`. See CRUD.md "Child rows". `onSubmit` / `onSecondarySubmit` receive the fields the form writes (typed `FormValues<E, Op>`: `E` from `entity`, `Op` from `operation`, both operations when omitted), not the whole row; `defaultValues` is typed `EntityFormDefaultValues<E, Op>` (the stored row on edit, `Partial<CreateInput<E>>` on create). Fields the viewer cannot edit render read-only: computed ones from form state, the others (technical, `editable: false`, role-denied) from the stored record.
69
+
54
70
  ### FormFieldRenderer
55
71
  Render single field. Used inside custom forms.
56
72
 
57
73
  ```tsx
58
- <FormFieldRenderer field={field} control={form.control} />
74
+ <FormFieldRenderer name={field.name} config={field.config} control={form.control} t={form.t} />
75
+ ```
76
+
77
+ Built-in uncontrolled adapters translate their labels with the supplied `t` before rendering visual components, including submit/reset buttons in controlled forms. Custom adapters still receive raw label/config keys plus `t` and own their label translation.
78
+
79
+ `field-array` add/remove accessible names and the missing-subfields diagnostic use `crud:fieldArray.*` keys through the supplied translator; child fields keep the entity translator.
80
+
81
+ `onlyOptions` offers a subset of a select/multiselect/radio/combobox field's declared options, in the given order (e.g. the reasons a person may record; the database writes the others). Display only: validation still accepts every declared value. Unknown value or no static options = throws.
82
+
83
+ ```tsx
84
+ <FormFieldRenderer name="reason" config={config} control={form.control} t={t}
85
+ onlyOptions={['breakage', 'loss', 'theft']} />
59
86
  ```
60
87
 
61
88
  ### EntityList
@@ -65,7 +92,9 @@ Data table for entity collection.
65
92
  <EntityList entity={userEntity} onRowClick={(user) => edit(user.id)} />
66
93
  ```
67
94
 
68
- `editable` edits the list in place (text, number, select, radio, reference fields the viewer may edit; references as dropdowns). Check rows to set one field on all of them; paste blocks from Excel. Save = one `bulk({ updates })`.
95
+ `editable` edits the list in place (text, number, select, radio, reference fields the viewer may edit; references as dropdowns). Check rows to set one field on all of them; paste blocks from Excel. Save = one `bulk({ updates })`. `editable={false}`: read-only (no Add, no selection, no delete).
96
+
97
+ `parent={{ field, value }}` lists one record's children. When `editable` (default) and an edit form is open on that record, the rows join it (no own Save; the form's Save writes them; link tables add through a picker); `value: null` shows "Create the draft before adding …". Joined lists show every line (no filters section, search, export or pagination). `extraColumns` (app columns from the edited row) and `actions` (toolbar content) are optional overrides. `extend={{ offer: { entity: productOfferEntity, field: 'productId' } }}` adds a 1:1 extension's columns (`offer.price`), edited and saved with the rows. See CRUD.md "Child rows" and "1:1 extension".
69
98
 
70
99
  ```tsx
71
100
  <EntityList entity={productEntity} editable />
@@ -75,30 +104,72 @@ Data table for entity collection.
75
104
  Card grid for entity collection.
76
105
 
77
106
  ```tsx
78
- <EntityCardList entity={productEntity} renderCard={(item) => <ProductCard {...item} />} />
107
+ <EntityCardList entity={productEntity} renderCardOverlay={(item) => item.featured ? <Badge>…</Badge> : null} />
108
+ ```
109
+
110
+ Cards are `CrudCard`s laid out by the entity's `listCardFields` (title / subtitle / content / footer slots); there is no `renderCard` prop. A fully custom card: `useCrudCardList` (+ `EntityFilters`) and your own grid.
111
+
112
+ ### SortableCardList
113
+ Cards in a grid the user re-orders before saving (routine steps, ranked selections). Drag the whole card (mouse; touch after a 200 ms hold); the card's own buttons and links stay clicks. With `handleOnly` (cards that are links or buttons), only the grip drags. Keyboard: Space/Enter on the grip, arrows, Space/Enter (Escape cancels). Each card's bar: grip, move-before / move-after, and a remove (X) button at the end with `onRemove`. Screen readers get translated instructions and pick-up / move / drop announcements. Stateless: the caller owns `items` (unique ids) and saves the order received in `onReorder`. Labels come from the `crud` namespace (`sortable.*`); `itemLabel` names each item for them.
114
+
115
+ ```tsx
116
+ <SortableCardList
117
+ items={productIds}
118
+ onReorder={setProductIds}
119
+ onRemove={(id) => setProductIds(productIds.filter((p) => p !== id))}
120
+ itemLabel={(id) => byId.get(id)?.name ?? id}
121
+ renderItem={(id, index) => <Card title={`${index + 1}. ${byId.get(id)?.name}`} />}
122
+ />
79
123
  ```
80
124
 
125
+ | Prop | Default | |
126
+ |---|---|---|
127
+ | `items: readonly string[]` | required | Ids in their current order |
128
+ | `onReorder: (items: string[]) => void` | required | New order after a drag or a move button |
129
+ | `renderItem: (id, index) => ReactNode` | required | Card content |
130
+ | `itemLabel: (id) => string` | required | Accessible item name for the grip, buttons and announcements |
131
+ | `onRemove?: (id) => void` | none | Adds the remove (X) button at the end of the bar |
132
+ | `handleOnly?: boolean` | `false` | Only the grip drags (mouse, touch): for cards that are links or buttons |
133
+ | `disabled?: boolean` | `false` | No dragging, buttons disabled |
134
+ | `cols?: GridCols` | `[1, 2, 3, 4]` | Grid columns |
135
+
136
+ ---|---|---|
137
+ | `items: readonly string[]` | required | Ids in their current order |
138
+ | `onReorder: (items: string[]) => void` | required | New order after a drag or a move button |
139
+ | `renderItem: (id, index) => ReactNode` | required | Card content (remove button included, if any) |
140
+ | `itemLabel: (id) => string` | required | Accessible item name for the handle and move buttons |
141
+ | `disabled?: boolean` | `false` | No dragging, move buttons disabled |
142
+ | `cols?: GridCols` | `[1, 2, 3, 4]` | Grid columns |
143
+
81
144
  ---
82
145
 
83
146
  ## Form Building Blocks
84
147
 
85
- For custom forms, use these low-level utilities:
148
+ For custom layouts, use `useEntityForm`. It automatically resolves translations from `[entity.namespace, 'crud']`; the signed-in viewer role must still be supplied:
86
149
 
87
150
  ```tsx
88
- import { useEntityForm, getFieldsForOperation, validateEntity } from '@donotdev/crud';
89
-
90
- const { register, handleSubmit, fields, formState } = useEntityForm(productEntity, {
91
- operation: 'create'
151
+ import { useAuth } from '@donotdev/auth';
152
+ import { useEntityForm } from '@donotdev/crud';
153
+
154
+ const viewerRole = useAuth('userRole');
155
+ const form = useEntityForm(productEntity, {
156
+ formId: 'product-create',
157
+ operation: 'create',
158
+ viewerRole,
92
159
  });
93
160
  ```
94
161
 
162
+ **No `t` option required:** Each form resolves its own entity namespace, with shared CRUD labels and language/SSR support. Pass the returned `form.t` to every `FormFieldRenderer` / `DisplayFieldRenderer`. Supply `options.t` only to intentionally bypass the default entity + CRUD namespace resolution with your own translator; it fully replaces the default. Never duplicate entity labels/options in page locales.
163
+
164
+ Use stable, unique form IDs; respect field editability and live `useFieldConditions`; submit writes through `form.handleSubmit`. See CRUD → Custom Forms for the complete contract.
165
+
95
166
  | Export | Purpose |
96
167
  |--------|---------|
97
168
  | `useEntityForm` | React Hook Form wrapper for entities |
98
169
  | `useEntityField` | Single field hook |
99
- | `getFieldsForOperation` | Get editable fields for create/edit |
170
+ | `getFieldsForOperation` | Form fields for create/edit (`editable`, `written`), from the entity descriptor |
100
171
  | `validateEntity` | Validate data against entity schema |
101
- | `isFieldEditable` | Check if field is editable |
172
+ | `isFieldEditable` | `isFieldEditable(entity, field, viewerRole, op)`: whether the field is an input |
102
173
 
103
174
  ---
104
175